Skip to content

Commit

Permalink
Export typed display modes array
Browse files Browse the repository at this point in the history
  • Loading branch information
christianliebel committed Jun 29, 2020
1 parent 5a64a69 commit f669228
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/lib/cmds/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as fs from 'fs';
import Color = require('color');
import * as inquirer from 'inquirer';
import {Config, DISPLAY_MODES, JdkHelper, KeyTool, Log, TwaGenerator, TwaManifest,
import {Config, DisplayModes, JdkHelper, KeyTool, Log, TwaGenerator, TwaManifest,
util} from '@bubblewrap/core';
import {validateColor, validateKeyPassword, validateUrl, notEmpty} from '../inputHelpers';
import {ParsedArgs} from 'minimist';
Expand Down Expand Up @@ -55,7 +55,7 @@ async function confirmTwaConfig(twaManifest: TwaManifest): Promise<TwaManifest>
type: 'list',
message: 'Display mode to be used:',
default: twaManifest.display,
choices: DISPLAY_MODES,
choices: DisplayModes,
}, {
name: 'themeColor',
type: 'input',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {GradleWrapper} from './lib/GradleWrapper';
import Log from './lib/Log';
import {JdkHelper} from './lib/jdk/JdkHelper';
import {KeyTool} from './lib/jdk/KeyTool';
import {TwaManifest, DISPLAY_MODES} from './lib/TwaManifest';
import {TwaManifest, DisplayModes} from './lib/TwaManifest';
import {TwaGenerator} from './lib/TwaGenerator';
import {DigitalAssetLinks} from './lib/DigitalAssetLinks';
import * as util from './lib/util';
Expand All @@ -34,6 +34,6 @@ export {AndroidSdkTools,
Log,
TwaGenerator,
TwaManifest,
DISPLAY_MODES,
DisplayModes,
util,
};
7 changes: 4 additions & 3 deletions packages/core/src/lib/TwaManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ const MIN_SHORTCUT_ICON_SIZE = 96;
const MIN_NOTIFICATION_ICON_SIZE = 48;

// Supported display modes for TWA
export const DISPLAY_MODES = ['standalone', 'fullscreen'];
type DisplayMode = typeof DISPLAY_MODES[number];
const DISPLAY_MODE_VALUES = ['standalone', 'fullscreen'];
type DisplayMode = typeof DISPLAY_MODE_VALUES[number];
export const DisplayModes: DisplayMode[] = [...DISPLAY_MODE_VALUES];

export function asDisplayMode(input: string): DisplayMode | null {
return DISPLAY_MODES.includes(input) ? input as DisplayMode : null;
return DISPLAY_MODE_VALUES.includes(input) ? input as DisplayMode : null;
}

// Default values used on the Twa Manifest
Expand Down

0 comments on commit f669228

Please sign in to comment.