@dxos/plugin-native 0.7.4 → 0.7.5-main.9d26e3a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-FIFLINF5.mjs";
|
|
4
4
|
|
|
5
5
|
// packages/plugins/experimental/plugin-native/src/NativePlugin.tsx
|
|
6
|
-
import { NavigationAction, SettingsAction, LayoutAction, parseIntentPlugin, resolvePlugin } from "@dxos/app-framework";
|
|
6
|
+
import { NavigationAction, SettingsAction, LayoutAction, parseIntentPlugin, resolvePlugin, createIntent } from "@dxos/app-framework";
|
|
7
7
|
import { HELP_PLUGIN } from "@dxos/plugin-help/meta";
|
|
8
|
-
import {
|
|
8
|
+
import { COMMANDS_DIALOG } from "@dxos/plugin-navtree/meta";
|
|
9
9
|
import { safeParseJson } from "@dxos/util";
|
|
10
10
|
var KEY_WINDOW_SIZE = "dxos.org/plugin/native/window-size";
|
|
11
11
|
var loadSocketSupplyModules = async () => {
|
|
@@ -80,29 +80,22 @@ var setupMenuItemListener = (intentPlugin, app) => {
|
|
|
80
80
|
const id = `${event.detail.parent}:${event.detail.title}`;
|
|
81
81
|
switch (id) {
|
|
82
82
|
case "App Name:Search commands": {
|
|
83
|
-
void intentPlugin?.provides.intent.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
});
|
|
83
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(LayoutAction.SetLayout, {
|
|
84
|
+
element: "dialog",
|
|
85
|
+
component: COMMANDS_DIALOG,
|
|
86
|
+
dialogBlockAlign: "start"
|
|
87
|
+
}));
|
|
90
88
|
break;
|
|
91
89
|
}
|
|
92
90
|
case "App Name:Settings...": {
|
|
93
|
-
void intentPlugin?.provides.intent.
|
|
94
|
-
action: SettingsAction.OPEN
|
|
95
|
-
});
|
|
91
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(SettingsAction.Open));
|
|
96
92
|
break;
|
|
97
93
|
}
|
|
98
94
|
case "App Name:Show shortcuts": {
|
|
99
|
-
void intentPlugin?.provides.intent.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
component: `${HELP_PLUGIN}/Shortcuts`
|
|
104
|
-
}
|
|
105
|
-
});
|
|
95
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(LayoutAction.SetLayout, {
|
|
96
|
+
element: "dialog",
|
|
97
|
+
component: `${HELP_PLUGIN}/Shortcuts`
|
|
98
|
+
}));
|
|
106
99
|
break;
|
|
107
100
|
}
|
|
108
101
|
case "App Name:Quit": {
|
|
@@ -120,17 +113,17 @@ var setupApplicationUrlListener = (app, intentPlugin) => {
|
|
|
120
113
|
if (location.includes("InvitationCode")) {
|
|
121
114
|
window.location.href = location;
|
|
122
115
|
} else {
|
|
123
|
-
void intentPlugin?.provides.intent.
|
|
124
|
-
|
|
116
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(
|
|
117
|
+
NavigationAction.Open,
|
|
125
118
|
// TODO(thure): what is `location` and is this right?
|
|
126
|
-
|
|
119
|
+
{
|
|
127
120
|
activeParts: {
|
|
128
121
|
main: [
|
|
129
122
|
location
|
|
130
123
|
]
|
|
131
124
|
}
|
|
132
125
|
}
|
|
133
|
-
|
|
126
|
+
));
|
|
134
127
|
}
|
|
135
128
|
});
|
|
136
129
|
};
|
|
@@ -138,13 +131,11 @@ var setupGlobalHotkey = async (socketWindow, appWindow, intentPlugin) => {
|
|
|
138
131
|
const binding = await socketWindow.hotkey.bind("cmd + k");
|
|
139
132
|
binding.addEventListener("hotkey", () => {
|
|
140
133
|
appWindow.restore();
|
|
141
|
-
void intentPlugin?.provides.intent.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
});
|
|
134
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(LayoutAction.SetLayout, {
|
|
135
|
+
element: "dialog",
|
|
136
|
+
component: COMMANDS_DIALOG,
|
|
137
|
+
dialogBlockAlign: "start"
|
|
138
|
+
}));
|
|
148
139
|
});
|
|
149
140
|
};
|
|
150
141
|
var initializeNativeApp = async (plugins) => {
|
|
@@ -160,7 +151,7 @@ var initializeNativeApp = async (plugins) => {
|
|
|
160
151
|
};
|
|
161
152
|
var NativePlugin = () => ({
|
|
162
153
|
meta: meta_default,
|
|
163
|
-
ready: async (plugins) => {
|
|
154
|
+
ready: async ({ plugins }) => {
|
|
164
155
|
await initializeNativeApp(plugins);
|
|
165
156
|
}
|
|
166
157
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/NativePlugin.tsx", "../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Plugin, PluginDefinition } from '@dxos/app-framework';\nimport {
|
|
5
|
-
"mappings": ";;;;;AAKA,
|
|
6
|
-
"names": ["NavigationAction", "SettingsAction", "LayoutAction", "parseIntentPlugin", "resolvePlugin", "HELP_PLUGIN", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Plugin, PluginDefinition } from '@dxos/app-framework';\nimport {\n NavigationAction,\n SettingsAction,\n LayoutAction,\n parseIntentPlugin,\n resolvePlugin,\n createIntent,\n} from '@dxos/app-framework';\nimport { HELP_PLUGIN } from '@dxos/plugin-help/meta';\nimport { COMMANDS_DIALOG } from '@dxos/plugin-navtree/meta';\nimport { safeParseJson } from '@dxos/util';\n\nimport meta from './meta';\n\n// TODO(burdon): Reconcile with other properties.\nconst KEY_WINDOW_SIZE = 'dxos.org/plugin/native/window-size';\n\n/**\n * Native code for socketsupply app.\n * https://www.npmjs.com/package/@socketsupply/socket\n * https://github.com/socketsupply/socket-examples\n */\n\nconst loadSocketSupplyModules = async () => {\n // SocketSupply implements the dynamic import.\n const module = 'socket:application';\n const app = await import(/* @vite-ignore */ module);\n const windowModule = 'socket:window';\n const socketWindow = await import(/* @vite-ignore */ windowModule);\n const { meta_title: appName } = app.config;\n\n return { app, socketWindow, appName };\n};\n\nconst configureDesktopWindowSizing = async (app: any) => {\n const { width, height } = safeParseJson<{ width?: number; height?: number }>(\n localStorage.getItem(KEY_WINDOW_SIZE),\n {},\n );\n\n if (width && height) {\n const appWindow = await app.getCurrentWindow();\n await appWindow.setSize({ width, height });\n }\n\n window.addEventListener('resize', async () => {\n const appWindow = await app.getCurrentWindow();\n const { width, height } = appWindow.getSize();\n localStorage.setItem(KEY_WINDOW_SIZE, JSON.stringify({ width, height }));\n });\n};\n\nconst configureSystemMenu = async (app: any, appName: string) => {\n const itemsMac = `\n Hide ${appName}: h + CommandOrControl\n Hide Others: h + Control + Meta\n ---\n `;\n\n // TODO(mjamesderocher) Change menu names to use translations\n const menu = `\n App Name:\n About ${appName}: _\n Settings...: , + CommandOrControl\n ---\n Show shortcuts: / + CommandOrControl\n Search commands: k + CommandOrControl\n ---\n ${itemsMac}\n Quit: q + CommandOrControl\n ;\n\n Edit:\n Cut: x + CommandOrControl\n Copy: c + CommandOrControl\n Paste: v + CommandOrControl\n Delete: _\n Select All: a + CommandOrControl\n ;\n `;\n\n void app.setSystemMenu({ index: 0, value: menu });\n};\n\nconst setupMenuItemListener = (intentPlugin: any, app: any) => {\n window.addEventListener('menuItemSelected', async (event: any) => {\n const id = `${event.detail.parent}:${event.detail.title}`;\n switch (id) {\n case 'App Name:Search commands': {\n void intentPlugin?.provides.intent.dispatchPromise(\n createIntent(LayoutAction.SetLayout, {\n element: 'dialog',\n component: COMMANDS_DIALOG,\n dialogBlockAlign: 'start',\n }),\n );\n break;\n }\n case 'App Name:Settings...': {\n void intentPlugin?.provides.intent.dispatchPromise(createIntent(SettingsAction.Open));\n break;\n }\n case 'App Name:Show shortcuts': {\n void intentPlugin?.provides.intent.dispatchPromise(\n createIntent(LayoutAction.SetLayout, {\n element: 'dialog',\n component: `${HELP_PLUGIN}/Shortcuts`,\n }),\n );\n break;\n }\n case 'App Name:Quit': {\n await app.exit();\n break;\n }\n }\n });\n};\n\nconst setupApplicationUrlListener = (app: any, intentPlugin: any) => {\n const appWindow = app.getCurrentWindow();\n\n // applicationurl is a custom event fired by the Socket Supply Runtime:\n // https://github.com/socketsupply/socket/blob/ef7fb5559876e41062d5896aafb7b79989fc96e5/api/internal/events.js#L6\n window.addEventListener('applicationurl', ({ url }: any) => {\n appWindow.restore();\n const location = url.toString().replace('composer://', '');\n if (location.includes('InvitationCode')) {\n // TODO(mjamesderocher): Integrate this with app routing.\n // Currently, the dialogs are controlled by Client Plugin and not the Layout Plugin.\n window.location.href = location;\n } else {\n void intentPlugin?.provides.intent.dispatchPromise(\n createIntent(\n NavigationAction.Open,\n // TODO(thure): what is `location` and is this right?\n { activeParts: { main: [location] } },\n ),\n );\n }\n });\n};\n\nconst setupGlobalHotkey = async (socketWindow: any, appWindow: any, intentPlugin: any) => {\n const binding = await socketWindow.hotkey.bind('cmd + k');\n\n // Global hotkey listener\n binding.addEventListener('hotkey', () => {\n appWindow.restore();\n void intentPlugin?.provides.intent.dispatchPromise(\n createIntent(LayoutAction.SetLayout, {\n element: 'dialog',\n component: COMMANDS_DIALOG,\n dialogBlockAlign: 'start',\n }),\n );\n });\n};\n\nconst initializeNativeApp = async (plugins: Plugin[]) => {\n const { app, socketWindow, appName } = await loadSocketSupplyModules();\n const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n\n if (process.platform === 'darwin' || process.platform === 'win32') {\n await configureDesktopWindowSizing(app);\n await configureSystemMenu(app, appName);\n setupMenuItemListener(intentPlugin, app);\n setupApplicationUrlListener(app, intentPlugin);\n await setupGlobalHotkey(socketWindow, app, intentPlugin);\n }\n};\n\n// TODO(burdon): Initial url has index.html, which must be caught/redirected.\nexport const NativePlugin = (): PluginDefinition => ({\n meta,\n ready: async ({ plugins }) => {\n await initializeNativeApp(plugins);\n },\n});\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { NativePlugin } from './NativePlugin';\n\nexport default NativePlugin;\n\nexport * from './NativePlugin';\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["NavigationAction", "SettingsAction", "LayoutAction", "parseIntentPlugin", "resolvePlugin", "createIntent", "HELP_PLUGIN", "COMMANDS_DIALOG", "safeParseJson", "KEY_WINDOW_SIZE", "loadSocketSupplyModules", "module", "app", "windowModule", "socketWindow", "meta_title", "appName", "config", "configureDesktopWindowSizing", "width", "height", "safeParseJson", "localStorage", "getItem", "appWindow", "getCurrentWindow", "setSize", "window", "addEventListener", "getSize", "setItem", "JSON", "stringify", "configureSystemMenu", "itemsMac", "menu", "setSystemMenu", "index", "value", "setupMenuItemListener", "intentPlugin", "event", "id", "detail", "parent", "title", "provides", "intent", "dispatchPromise", "createIntent", "LayoutAction", "SetLayout", "element", "component", "COMMANDS_DIALOG", "dialogBlockAlign", "SettingsAction", "Open", "HELP_PLUGIN", "exit", "setupApplicationUrlListener", "url", "restore", "location", "toString", "replace", "includes", "href", "NavigationAction", "activeParts", "main", "setupGlobalHotkey", "binding", "hotkey", "bind", "initializeNativeApp", "plugins", "resolvePlugin", "parseIntentPlugin", "process", "platform", "NativePlugin", "meta", "ready", "NativePlugin"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/plugins/experimental/plugin-native/src/meta.ts":{"bytes":707,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-native/src/NativePlugin.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/plugins/experimental/plugin-native/src/meta.ts":{"bytes":707,"imports":[],"format":"esm"},"packages/plugins/experimental/plugin-native/src/NativePlugin.tsx":{"bytes":19592,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-help/meta","kind":"import-statement","external":true},{"path":"@dxos/plugin-navtree/meta","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/plugins/experimental/plugin-native/src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"packages/plugins/experimental/plugin-native/src/index.ts":{"bytes":795,"imports":[{"path":"packages/plugins/experimental/plugin-native/src/NativePlugin.tsx","kind":"import-statement","original":"./NativePlugin"},{"path":"packages/plugins/experimental/plugin-native/src/NativePlugin.tsx","kind":"import-statement","original":"./NativePlugin"}],"format":"esm"}},"outputs":{"packages/plugins/experimental/plugin-native/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10013},"packages/plugins/experimental/plugin-native/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/plugins/experimental/plugin-native/dist/lib/browser/chunk-FIFLINF5.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-help/meta","kind":"import-statement","external":true},{"path":"@dxos/plugin-navtree/meta","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["NativePlugin","default"],"entryPoint":"packages/plugins/experimental/plugin-native/src/index.ts","inputs":{"packages/plugins/experimental/plugin-native/src/NativePlugin.tsx":{"bytesInOutput":4655},"packages/plugins/experimental/plugin-native/src/index.ts":{"bytesInOutput":32}},"bytes":4960},"packages/plugins/experimental/plugin-native/dist/lib/browser/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/plugins/experimental/plugin-native/dist/lib/browser/meta.mjs":{"imports":[{"path":"packages/plugins/experimental/plugin-native/dist/lib/browser/chunk-FIFLINF5.mjs","kind":"import-statement"}],"exports":["default"],"entryPoint":"packages/plugins/experimental/plugin-native/src/meta.ts","inputs":{},"bytes":127},"packages/plugins/experimental/plugin-native/dist/lib/browser/chunk-FIFLINF5.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":325},"packages/plugins/experimental/plugin-native/dist/lib/browser/chunk-FIFLINF5.mjs":{"imports":[],"exports":["meta_default"],"inputs":{"packages/plugins/experimental/plugin-native/src/meta.ts":{"bytesInOutput":55}},"bytes":186}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativePlugin.d.ts","sourceRoot":"","sources":["../../../src/NativePlugin.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAU,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"NativePlugin.d.ts","sourceRoot":"","sources":["../../../src/NativePlugin.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAU,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA8KpE,eAAO,MAAM,YAAY,QAAO,gBAK9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-native",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-main.9d26e3a",
|
|
4
4
|
"description": "Composer plugin that runs when on a native device.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dxos/app-framework": "0.7.
|
|
34
|
-
"@dxos/log": "0.7.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/plugin-navtree": "0.7.
|
|
37
|
-
"@dxos/
|
|
33
|
+
"@dxos/app-framework": "0.7.5-main.9d26e3a",
|
|
34
|
+
"@dxos/log": "0.7.5-main.9d26e3a",
|
|
35
|
+
"@dxos/util": "0.7.5-main.9d26e3a",
|
|
36
|
+
"@dxos/plugin-navtree": "0.7.5-main.9d26e3a",
|
|
37
|
+
"@dxos/plugin-help": "0.7.5-main.9d26e3a"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"vite": "5.4.7"
|
package/src/NativePlugin.tsx
CHANGED
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import type { Plugin, PluginDefinition } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
NavigationAction,
|
|
8
|
+
SettingsAction,
|
|
9
|
+
LayoutAction,
|
|
10
|
+
parseIntentPlugin,
|
|
11
|
+
resolvePlugin,
|
|
12
|
+
createIntent,
|
|
13
|
+
} from '@dxos/app-framework';
|
|
7
14
|
import { HELP_PLUGIN } from '@dxos/plugin-help/meta';
|
|
8
|
-
import {
|
|
15
|
+
import { COMMANDS_DIALOG } from '@dxos/plugin-navtree/meta';
|
|
9
16
|
import { safeParseJson } from '@dxos/util';
|
|
10
17
|
|
|
11
18
|
import meta from './meta';
|
|
@@ -85,26 +92,26 @@ const setupMenuItemListener = (intentPlugin: any, app: any) => {
|
|
|
85
92
|
const id = `${event.detail.parent}:${event.detail.title}`;
|
|
86
93
|
switch (id) {
|
|
87
94
|
case 'App Name:Search commands': {
|
|
88
|
-
void intentPlugin?.provides.intent.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
void intentPlugin?.provides.intent.dispatchPromise(
|
|
96
|
+
createIntent(LayoutAction.SetLayout, {
|
|
97
|
+
element: 'dialog',
|
|
98
|
+
component: COMMANDS_DIALOG,
|
|
99
|
+
dialogBlockAlign: 'start',
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
92
102
|
break;
|
|
93
103
|
}
|
|
94
104
|
case 'App Name:Settings...': {
|
|
95
|
-
void intentPlugin?.provides.intent.
|
|
96
|
-
action: SettingsAction.OPEN,
|
|
97
|
-
});
|
|
105
|
+
void intentPlugin?.provides.intent.dispatchPromise(createIntent(SettingsAction.Open));
|
|
98
106
|
break;
|
|
99
107
|
}
|
|
100
108
|
case 'App Name:Show shortcuts': {
|
|
101
|
-
void intentPlugin?.provides.intent.
|
|
102
|
-
|
|
103
|
-
data: {
|
|
109
|
+
void intentPlugin?.provides.intent.dispatchPromise(
|
|
110
|
+
createIntent(LayoutAction.SetLayout, {
|
|
104
111
|
element: 'dialog',
|
|
105
112
|
component: `${HELP_PLUGIN}/Shortcuts`,
|
|
106
|
-
},
|
|
107
|
-
|
|
113
|
+
}),
|
|
114
|
+
);
|
|
108
115
|
break;
|
|
109
116
|
}
|
|
110
117
|
case 'App Name:Quit': {
|
|
@@ -128,11 +135,13 @@ const setupApplicationUrlListener = (app: any, intentPlugin: any) => {
|
|
|
128
135
|
// Currently, the dialogs are controlled by Client Plugin and not the Layout Plugin.
|
|
129
136
|
window.location.href = location;
|
|
130
137
|
} else {
|
|
131
|
-
void intentPlugin?.provides.intent.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
void intentPlugin?.provides.intent.dispatchPromise(
|
|
139
|
+
createIntent(
|
|
140
|
+
NavigationAction.Open,
|
|
141
|
+
// TODO(thure): what is `location` and is this right?
|
|
142
|
+
{ activeParts: { main: [location] } },
|
|
143
|
+
),
|
|
144
|
+
);
|
|
136
145
|
}
|
|
137
146
|
});
|
|
138
147
|
};
|
|
@@ -143,10 +152,13 @@ const setupGlobalHotkey = async (socketWindow: any, appWindow: any, intentPlugin
|
|
|
143
152
|
// Global hotkey listener
|
|
144
153
|
binding.addEventListener('hotkey', () => {
|
|
145
154
|
appWindow.restore();
|
|
146
|
-
void intentPlugin?.provides.intent.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
void intentPlugin?.provides.intent.dispatchPromise(
|
|
156
|
+
createIntent(LayoutAction.SetLayout, {
|
|
157
|
+
element: 'dialog',
|
|
158
|
+
component: COMMANDS_DIALOG,
|
|
159
|
+
dialogBlockAlign: 'start',
|
|
160
|
+
}),
|
|
161
|
+
);
|
|
150
162
|
});
|
|
151
163
|
};
|
|
152
164
|
|
|
@@ -166,7 +178,7 @@ const initializeNativeApp = async (plugins: Plugin[]) => {
|
|
|
166
178
|
// TODO(burdon): Initial url has index.html, which must be caught/redirected.
|
|
167
179
|
export const NativePlugin = (): PluginDefinition => ({
|
|
168
180
|
meta,
|
|
169
|
-
ready: async (plugins) => {
|
|
181
|
+
ready: async ({ plugins }) => {
|
|
170
182
|
await initializeNativeApp(plugins);
|
|
171
183
|
},
|
|
172
184
|
});
|