Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update plugin registration from runtime refactor #93

Merged
merged 9 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions action-sheet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@capacitor/action-sheet",
"version": "0.1.1",
"description": "The Action Sheet API provides access to native Action Sheets, which come up from the bottom of the screen and display actions a user can take.",
"main": "dist/plugin.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
Expand Down Expand Up @@ -50,7 +50,6 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
Expand Down
11 changes: 2 additions & 9 deletions action-sheet/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nodeResolve from '@rollup/plugin-node-resolve';

export default {
input: 'dist/esm/index.js',
output: {
Expand All @@ -10,12 +8,7 @@ export default {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
plugins: [
nodeResolve({
// allowlist of dependencies to bundle in
// @see https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve#resolveonly
resolveOnly: ['lodash'],
}),
],
external: ['@capacitor/core'],
};
17 changes: 4 additions & 13 deletions action-sheet/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import type { PluginImplementations } from '@capacitor/core';
import { Plugins, registerPlugin } from '@capacitor/core';
import { registerPlugin } from '@capacitor/core';

import type { ActionSheetPlugin } from './definitions';
import { ActionSheetOptionStyle } from './definitions';
import { ActionSheetWeb } from './web';

const implementations: PluginImplementations<ActionSheetPlugin> = {
android: Plugins.ActionSheet,
ios: Plugins.ActionSheet,
web: new ActionSheetWeb(),
};

const ActionSheet = registerPlugin(
'ActionSheet',
implementations,
).getImplementation();
const ActionSheet = registerPlugin<ActionSheetPlugin>('ActionSheet', {
web: () => import('./web').then(m => new m.ActionSheetWeb()),
});

export { ActionSheet, ActionSheetOptionStyle };
4 changes: 0 additions & 4 deletions action-sheet/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import type {
} from './definitions';

export class ActionSheetWeb extends WebPlugin implements ActionSheetPlugin {
constructor() {
super({ name: 'ActionSheet' });
}

async showActions(options: ActionSheetOptions): Promise<ActionSheetResult> {
return new Promise<ActionSheetResult>((resolve, _reject) => {
let actionSheet: any = document.querySelector('pwa-action-sheet');
Expand Down
10 changes: 3 additions & 7 deletions action-sheet/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"allowUnreachableCode": false,
"declaration": true,
"esModuleInterop": true,
"lib": [
"dom"
],
"module": "es2015",
"lib": ["dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
Expand All @@ -17,7 +15,5 @@
"strict": true,
"target": "es2017"
},
"files": [
"src/index.ts"
]
"files": ["src/index.ts"]
}
5 changes: 2 additions & 3 deletions app-launcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@capacitor/app-launcher",
"version": "0.1.0",
"description": "The AppLauncher API allows to open other apps",
"main": "dist/plugin.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
Expand Down Expand Up @@ -50,7 +50,6 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
Expand Down
11 changes: 2 additions & 9 deletions app-launcher/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nodeResolve from '@rollup/plugin-node-resolve';

export default {
input: 'dist/esm/index.js',
output: {
Expand All @@ -10,12 +8,7 @@ export default {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
plugins: [
nodeResolve({
// allowlist of dependencies to bundle in
// @see https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve#resolveonly
resolveOnly: ['lodash'],
}),
],
external: ['@capacitor/core'],
};
17 changes: 4 additions & 13 deletions app-launcher/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import type { PluginImplementations } from '@capacitor/core';
import { Plugins, registerPlugin } from '@capacitor/core';
import { registerPlugin } from '@capacitor/core';

import type { AppLauncherPlugin } from './definitions';
import { AppLauncherWeb } from './web';

const implementations: PluginImplementations<AppLauncherPlugin> = {
android: Plugins.AppLauncher,
ios: Plugins.AppLauncher,
web: new AppLauncherWeb(),
};

const AppLauncher = registerPlugin(
'AppLauncher',
implementations,
).getImplementation();
const AppLauncher = registerPlugin<AppLauncherPlugin>('AppLauncher', {
web: () => import('./web').then(m => new m.AppLauncherWeb()),
});

export { AppLauncher };
4 changes: 0 additions & 4 deletions app-launcher/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { WebPlugin } from '@capacitor/core';
import type { AppLauncherPlugin } from './definitions';

export class AppLauncherWeb extends WebPlugin implements AppLauncherPlugin {
constructor() {
super({ name: 'AppLauncher' });
}

async canOpenUrl(_options: { url: string }): Promise<{ value: boolean }> {
return { value: true };
}
Expand Down
10 changes: 3 additions & 7 deletions app-launcher/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"allowUnreachableCode": false,
"declaration": true,
"esModuleInterop": true,
"lib": [
"dom"
],
"module": "es2015",
"lib": ["dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
Expand All @@ -17,7 +15,5 @@
"strict": true,
"target": "es2017"
},
"files": [
"src/index.ts"
]
"files": ["src/index.ts"]
}
5 changes: 2 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@capacitor/app",
"version": "0.0.1",
"description": "The App API handles high level App state and events.For example, this API emits events when the app enters and leaves the foreground, handles deeplinks, opens other apps, and manages persisted plugin state.",
"main": "dist/plugin.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
Expand Down Expand Up @@ -50,7 +50,6 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
Expand Down
11 changes: 2 additions & 9 deletions app/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nodeResolve from '@rollup/plugin-node-resolve';

export default {
input: 'dist/esm/index.js',
output: {
Expand All @@ -10,12 +8,7 @@ export default {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
plugins: [
nodeResolve({
// allowlist of dependencies to bundle in
// @see https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve#resolveonly
resolveOnly: ['lodash'],
}),
],
external: ['@capacitor/core'],
};
14 changes: 4 additions & 10 deletions app/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { PluginImplementations } from '@capacitor/core';
import { Plugins, registerPlugin } from '@capacitor/core';
import { registerPlugin } from '@capacitor/core';

import type { AppPlugin } from './definitions';
import { AppWeb } from './web';

const implementations: PluginImplementations<AppPlugin> = {
android: Plugins.App,
ios: Plugins.App,
web: new AppWeb(),
};

const App = registerPlugin('App', implementations).getImplementation();
const App = registerPlugin<AppPlugin>('App', {
web: () => import('./web').then(m => new m.AppWeb()),
});

export { App };
2 changes: 1 addition & 1 deletion app/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { AppInfo, AppPlugin, AppLaunchUrl, AppState } from './definitions';

export class AppWeb extends WebPlugin implements AppPlugin {
constructor() {
super({ name: 'App' });
super();
if (typeof document !== 'undefined') {
document.addEventListener(
'visibilitychange',
Expand Down
10 changes: 3 additions & 7 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"allowUnreachableCode": false,
"declaration": true,
"esModuleInterop": true,
"lib": [
"dom"
],
"module": "es2015",
"lib": ["dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
Expand All @@ -17,7 +15,5 @@
"strict": true,
"target": "es2017"
},
"files": [
"src/index.ts"
]
"files": ["src/index.ts"]
}
5 changes: 2 additions & 3 deletions browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@capacitor/browser",
"version": "0.1.0",
"description": "The Browser API provides the ability to open an in-app browser and subscribe to browser events.",
"main": "dist/plugin.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
Expand Down Expand Up @@ -50,7 +50,6 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
Expand Down
11 changes: 2 additions & 9 deletions browser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nodeResolve from '@rollup/plugin-node-resolve';

export default {
input: 'dist/esm/index.js',
output: {
Expand All @@ -10,12 +8,7 @@ export default {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
plugins: [
nodeResolve({
// allowlist of dependencies to bundle in
// @see https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve#resolveonly
resolveOnly: ['lodash'],
}),
],
external: ['@capacitor/core'],
};
14 changes: 4 additions & 10 deletions browser/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import type { PluginImplementations } from '@capacitor/core';
import { Plugins, registerPlugin } from '@capacitor/core';
import { registerPlugin } from '@capacitor/core';

import type { BrowserPlugin } from './definitions';
import { BrowserWeb } from './web';

const implementations: PluginImplementations<BrowserPlugin> = {
android: Plugins.Browser,
ios: Plugins.Browser,
web: new BrowserWeb(),
};

const Browser = registerPlugin('Browser', implementations).getImplementation();
const Browser = registerPlugin<BrowserPlugin>('Browser', {
web: () => import('./web').then(m => new m.BrowserWeb()),
});

export { Browser };
2 changes: 1 addition & 1 deletion browser/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class BrowserWeb extends WebPlugin implements BrowserPlugin {
_lastWindow: Window | null;

constructor() {
super({ name: 'Browser' });
super();
this._lastWindow = null;
}

Expand Down
10 changes: 3 additions & 7 deletions browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"allowUnreachableCode": false,
"declaration": true,
"esModuleInterop": true,
"lib": [
"dom"
],
"module": "es2015",
"lib": ["dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
Expand All @@ -17,7 +15,5 @@
"strict": true,
"target": "es2017"
},
"files": [
"src/index.ts"
]
"files": ["src/index.ts"]
}
5 changes: 2 additions & 3 deletions clipboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "@capacitor/clipboard",
"version": "0.1.1",
"description": "The Clipboard API enables copy and pasting to/from the system clipboard.",
"main": "dist/plugin.js",
"module": "dist/esm/index.js",
"main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"unpkg": "dist/plugin.js",
"files": [
"android/src/main/",
"android/build.gradle",
Expand Down Expand Up @@ -50,7 +50,6 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "~1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^9.0.0",
"eslint": "^7.11.0",
"prettier": "~2.2.0",
"prettier-plugin-java": "~1.0.0",
Expand Down
Loading