From 79334e4275aa2ce1c07f3337ed7c7f1be7e7f018 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Tue, 24 Nov 2020 18:00:50 -0800 Subject: [PATCH 1/2] feat(cli): add types for plugins configuration --- cli/src/declarations.ts | 189 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 1 deletion(-) diff --git a/cli/src/declarations.ts b/cli/src/declarations.ts index 310435a00..eeecbdd24 100644 --- a/cli/src/declarations.ts +++ b/cli/src/declarations.ts @@ -352,5 +352,192 @@ export interface CapacitorConfig { preferences?: { [key: string]: string | undefined }; }; - plugins?: { [key: string]: any }; + /** + * Configure plugins. + * + * This is an object with configuration values specified by plugin class + * name. + * + * @since 1.0.0 + */ + plugins?: { + Keyboard?: { + /** + * Configure the way the app is resized when the Keyboard appears. + * + * @since 1.0.0 + * @default native + */ + resize?: 'none' | 'native' | 'body' | 'ionic'; + + /** + * Use the dark style keyboard instead of the regular one. + * + * @since 1.0.0 + */ + style?: 'dark'; + }; + + LocalNotifications?: { + /** + * Set the default icon for the local notification. + * + * @since 1.0.0 + */ + smallIcon?: string; + + /** + * Set the default color for local notification icons. + * + * @since 1.0.0 + */ + iconColor?: string; + + /** + * Set the default notification sound on Android. + * + * On Android 26+ it sets the default channel sound and can't be + * changed unless the app is uninstalled. + * + * @since 1.0.0 + */ + sound?: string; + }; + + PushNotifications?: { + /** + * Configure the way notifications are displayed when the app is in foreground on iOS. + * + * Provide an array of strings that you combine to configure what + * happens when push notifications arrive while the app is in the + * foreground. + * + * An empty Array can be provided if none of the previous options are + * desired. + * + * @since 1.0.0 + * @default ['badge'] + */ + presentationOptions?: ('badge' | 'sound' | 'alert')[]; + }; + + SplashScreen?: { + /** + * Set a duration in milliseconds for which the splash screen is shown. + * + * For best results, this should be set to `0` and then the splash + * screen should be programmatically hidden using `hide()` whenever + * your app is fully bootstrapped. + * + * @since 1.0.0 + * @default 3000 + */ + launchShowDuration?: number; + + /** + * Automatically hide the splash screen. + * + * Set to `false` to make sure the splash never hides before the app + * is fully loaded. + * + * @since 1.0.0 + * @default true + */ + launchAutoHide?: boolean; + + /** + * Show a spinner on the splash screen. + * + * @since 1.0.0 + * @default false + */ + showSpinner?: boolean; + + /** + * Customize the appearance of the spinner on Android. + * + * @since 1.0.0 + * @default large + */ + androidSpinnerStyle?: + | 'horizontal' + | 'small' + | 'large' + | 'inverse' + | 'smallInverse' + | 'largeInverse'; + + /** + * Customize the appearance of the spinner on iOS. + * + * @since 1.0.0 + * @default large + */ + iosSpinnerStyle?: 'small' | 'large'; + + /** + * Set the color of the spinner. + * + * Use #RRGGBB or #AARRGGBB format. + * + * @since 1.0.0 + */ + spinnerColor?: string; + + /** + * Set the background color of the splash screen. + * + * Use #RRGGBB or #AARRGGBB format. + * + * @since 1.0.0 + */ + backgroundColor?: string; + + /** + * Use a custom resource for the splash screen on Android. + * + * @since 1.0.0 + */ + androidSplashResourceName?: string; + + /** + * Set a custom scaling type for the splash screen on Android. + * + * This will set the splash screen's + * [`ImageView.ScaleType`](https://developer.android.com/reference/android/widget/ImageView.ScaleType). + * + * @since 1.0.0 + */ + androidScaleType?: + | 'CENTER' + | 'CENTER_CROP' + | 'CENTER_INSIDE' + | 'FIT_CENTER' + | 'FIT_END' + | 'FIT_START' + | 'FIT_XY' + | 'MATRIX'; + + /** + * @since 1.0.0 + */ + splashFullScreen?: boolean; + + /** + * @since 1.0.0 + */ + splashImmersive?: boolean; + }; + + /** + * Additional plugins configured by class name. + * + * @since 1.0.0 + */ + [key: string]: + | { + [key: string]: any; + } + | undefined; + }; } From 17107c4f366b14fc814de46e31fefe0e12e76d16 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Sun, 29 Nov 2020 11:04:42 -0800 Subject: [PATCH 2/2] allow module augmentation from plugins --- cli/src/declarations.ts | 192 +++------------------------------------- 1 file changed, 13 insertions(+), 179 deletions(-) diff --git a/cli/src/declarations.ts b/cli/src/declarations.ts index eeecbdd24..3905001ac 100644 --- a/cli/src/declarations.ts +++ b/cli/src/declarations.ts @@ -360,184 +360,18 @@ export interface CapacitorConfig { * * @since 1.0.0 */ - plugins?: { - Keyboard?: { - /** - * Configure the way the app is resized when the Keyboard appears. - * - * @since 1.0.0 - * @default native - */ - resize?: 'none' | 'native' | 'body' | 'ionic'; - - /** - * Use the dark style keyboard instead of the regular one. - * - * @since 1.0.0 - */ - style?: 'dark'; - }; - - LocalNotifications?: { - /** - * Set the default icon for the local notification. - * - * @since 1.0.0 - */ - smallIcon?: string; - - /** - * Set the default color for local notification icons. - * - * @since 1.0.0 - */ - iconColor?: string; - - /** - * Set the default notification sound on Android. - * - * On Android 26+ it sets the default channel sound and can't be - * changed unless the app is uninstalled. - * - * @since 1.0.0 - */ - sound?: string; - }; - - PushNotifications?: { - /** - * Configure the way notifications are displayed when the app is in foreground on iOS. - * - * Provide an array of strings that you combine to configure what - * happens when push notifications arrive while the app is in the - * foreground. - * - * An empty Array can be provided if none of the previous options are - * desired. - * - * @since 1.0.0 - * @default ['badge'] - */ - presentationOptions?: ('badge' | 'sound' | 'alert')[]; - }; - - SplashScreen?: { - /** - * Set a duration in milliseconds for which the splash screen is shown. - * - * For best results, this should be set to `0` and then the splash - * screen should be programmatically hidden using `hide()` whenever - * your app is fully bootstrapped. - * - * @since 1.0.0 - * @default 3000 - */ - launchShowDuration?: number; - - /** - * Automatically hide the splash screen. - * - * Set to `false` to make sure the splash never hides before the app - * is fully loaded. - * - * @since 1.0.0 - * @default true - */ - launchAutoHide?: boolean; - - /** - * Show a spinner on the splash screen. - * - * @since 1.0.0 - * @default false - */ - showSpinner?: boolean; - - /** - * Customize the appearance of the spinner on Android. - * - * @since 1.0.0 - * @default large - */ - androidSpinnerStyle?: - | 'horizontal' - | 'small' - | 'large' - | 'inverse' - | 'smallInverse' - | 'largeInverse'; - - /** - * Customize the appearance of the spinner on iOS. - * - * @since 1.0.0 - * @default large - */ - iosSpinnerStyle?: 'small' | 'large'; - - /** - * Set the color of the spinner. - * - * Use #RRGGBB or #AARRGGBB format. - * - * @since 1.0.0 - */ - spinnerColor?: string; - - /** - * Set the background color of the splash screen. - * - * Use #RRGGBB or #AARRGGBB format. - * - * @since 1.0.0 - */ - backgroundColor?: string; - - /** - * Use a custom resource for the splash screen on Android. - * - * @since 1.0.0 - */ - androidSplashResourceName?: string; - - /** - * Set a custom scaling type for the splash screen on Android. - * - * This will set the splash screen's - * [`ImageView.ScaleType`](https://developer.android.com/reference/android/widget/ImageView.ScaleType). - * - * @since 1.0.0 - */ - androidScaleType?: - | 'CENTER' - | 'CENTER_CROP' - | 'CENTER_INSIDE' - | 'FIT_CENTER' - | 'FIT_END' - | 'FIT_START' - | 'FIT_XY' - | 'MATRIX'; - - /** - * @since 1.0.0 - */ - splashFullScreen?: boolean; - - /** - * @since 1.0.0 - */ - splashImmersive?: boolean; - }; + plugins?: PluginsConfig; +} - /** - * Additional plugins configured by class name. - * - * @since 1.0.0 - */ - [key: string]: - | { - [key: string]: any; - } - | undefined; - }; +export interface PluginsConfig { + /** + * Plugin configuration by class name. + * + * @since 1.0.0 + */ + [key: string]: + | { + [key: string]: any; + } + | undefined; }