@dxos/app-framework 0.6.13 → 0.6.14-main.69511f5
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.
- package/dist/lib/browser/chunk-3E7RY3CE.mjs +72 -0
- package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +7 -0
- package/dist/lib/browser/chunk-653Y45CL.mjs +41 -0
- package/dist/lib/browser/chunk-653Y45CL.mjs.map +7 -0
- package/dist/lib/browser/{plugin-MM66VRCO.mjs → chunk-CDLQO5K2.mjs} +66 -20
- package/dist/lib/browser/chunk-CDLQO5K2.mjs.map +7 -0
- package/dist/lib/browser/chunk-EQTQGGE6.mjs +214 -0
- package/dist/lib/browser/chunk-EQTQGGE6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +183 -293
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/plugin-intent-Q5KFPKFA.mjs +22 -0
- package/dist/lib/browser/plugin-intent-Q5KFPKFA.mjs.map +7 -0
- package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +11 -0
- package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +7 -0
- package/dist/lib/browser/plugin-surface-ZQXFAL46.mjs +24 -0
- package/dist/lib/browser/plugin-surface-ZQXFAL46.mjs.map +7 -0
- package/dist/lib/node/chunk-EF67TRWJ.cjs +236 -0
- package/dist/lib/node/chunk-EF67TRWJ.cjs.map +7 -0
- package/dist/lib/node/chunk-JZ2JVKRY.cjs +58 -0
- package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +7 -0
- package/dist/lib/node/{chunk-62W6CMGM.cjs → chunk-QBM42OQ6.cjs} +56 -5
- package/dist/lib/node/chunk-QBM42OQ6.cjs.map +7 -0
- package/dist/lib/node/{plugin-QV7ESETI.cjs → chunk-VOKMWTKO.cjs} +74 -20
- package/dist/lib/node/chunk-VOKMWTKO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +195 -310
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/plugin-intent-FMC4SDI3.cjs +43 -0
- package/dist/lib/node/plugin-intent-FMC4SDI3.cjs.map +7 -0
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +32 -0
- package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +7 -0
- package/dist/lib/node/{chunk-P5GRB4XF.cjs → plugin-surface-B5NHOBSW.cjs} +19 -22
- package/dist/lib/node/plugin-surface-B5NHOBSW.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-3FCLBEOX.mjs +215 -0
- package/dist/lib/node-esm/chunk-3FCLBEOX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +74 -0
- package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MYNXI5VG.mjs +214 -0
- package/dist/lib/node-esm/chunk-MYNXI5VG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +43 -0
- package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +567 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/plugin-intent-KETLP7UL.mjs +23 -0
- package/dist/lib/node-esm/plugin-intent-KETLP7UL.mjs.map +7 -0
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +12 -0
- package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +7 -0
- package/dist/lib/node-esm/plugin-surface-QXQRR534.mjs +25 -0
- package/dist/lib/node-esm/plugin-surface-QXQRR534.mjs.map +7 -0
- package/dist/types/src/App.d.ts +5 -5
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/plugins/common/file.d.ts +1 -1
- package/dist/types/src/plugins/common/file.d.ts.map +1 -1
- package/dist/types/src/plugins/common/graph.d.ts +1 -1
- package/dist/types/src/plugins/common/graph.d.ts.map +1 -1
- package/dist/types/src/plugins/common/index.d.ts +0 -1
- package/dist/types/src/plugins/common/index.d.ts.map +1 -1
- package/dist/types/src/plugins/common/layout.d.ts +6 -6
- package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
- package/dist/types/src/plugins/common/metadata.d.ts +1 -1
- package/dist/types/src/plugins/common/metadata.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts +9 -20
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/dist/types/src/plugins/common/translations.d.ts +1 -1
- package/dist/types/src/plugins/common/translations.d.ts.map +1 -1
- package/dist/types/src/plugins/helpers.d.ts +20 -5
- package/dist/types/src/plugins/helpers.d.ts.map +1 -1
- package/dist/types/src/plugins/index.d.ts +4 -3
- package/dist/types/src/plugins/index.d.ts.map +1 -1
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +21 -0
- package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +14 -0
- package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +1 -0
- package/dist/types/src/plugins/{PluginHost → plugin-host}/PluginContext.d.ts +4 -4
- package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-host/index.d.ts +4 -0
- package/dist/types/src/plugins/plugin-host/index.d.ts.map +1 -0
- package/dist/types/src/plugins/{PluginHost → plugin-host}/plugin.d.ts +37 -83
- package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +1 -0
- package/dist/types/src/plugins/{IntentPlugin/plugin.d.ts → plugin-intent/IntentPlugin.d.ts} +3 -4
- package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/index.d.ts +6 -0
- package/dist/types/src/plugins/plugin-intent/index.d.ts.map +1 -0
- package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/intent.d.ts +1 -1
- package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +1 -0
- package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/provides.d.ts +2 -2
- package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +4 -0
- package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-settings/index.d.ts +4 -0
- package/dist/types/src/plugins/plugin-settings/index.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-settings/meta.d.ts +5 -0
- package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-settings/provides.d.ts +13 -0
- package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +1 -0
- package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/Surface.d.ts +6 -2
- package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +7 -0
- package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +1 -0
- package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/SurfaceRootContext.d.ts +15 -2
- package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +1 -0
- package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/index.d.ts +2 -0
- package/dist/types/src/plugins/plugin-surface/index.d.ts.map +1 -0
- package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +1 -0
- package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/provides.d.ts +1 -1
- package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +1 -0
- package/package.json +16 -14
- package/project.json +3 -8
- package/src/App.tsx +18 -16
- package/src/plugins/common/file.ts +1 -1
- package/src/plugins/common/graph.ts +1 -1
- package/src/plugins/common/index.ts +0 -1
- package/src/plugins/common/layout.ts +6 -3
- package/src/plugins/common/metadata.ts +1 -1
- package/src/plugins/common/navigation.ts +10 -15
- package/src/plugins/common/translations.ts +2 -8
- package/src/plugins/helpers.ts +55 -11
- package/src/plugins/index.ts +4 -3
- package/src/plugins/plugin-host/HostPlugin.tsx +96 -0
- package/src/plugins/plugin-host/PluginContainer.tsx +120 -0
- package/src/plugins/{PluginHost → plugin-host}/PluginContext.tsx +9 -14
- package/src/plugins/{PluginHost → plugin-host}/index.ts +2 -1
- package/src/plugins/{PluginHost → plugin-host}/plugin.test.ts +1 -2
- package/src/plugins/{PluginHost → plugin-host}/plugin.ts +45 -52
- package/src/plugins/{IntentPlugin/plugin.tsx → plugin-intent/IntentPlugin.tsx} +3 -6
- package/src/plugins/{IntentPlugin → plugin-intent}/index.ts +4 -0
- package/src/plugins/{IntentPlugin → plugin-intent}/intent.ts +1 -1
- package/src/plugins/{IntentPlugin → plugin-intent}/provides.ts +5 -2
- package/src/plugins/plugin-settings/SettingsPlugin.tsx +22 -0
- package/src/plugins/plugin-settings/index.ts +9 -0
- package/src/plugins/plugin-settings/meta.ts +9 -0
- package/src/plugins/plugin-settings/provides.ts +29 -0
- package/src/plugins/{SurfacePlugin → plugin-surface}/Surface.tsx +74 -40
- package/src/plugins/{SurfacePlugin/plugin.tsx → plugin-surface/SurfacePlugin.tsx} +3 -5
- package/src/plugins/{SurfacePlugin → plugin-surface}/SurfaceRootContext.tsx +21 -4
- package/src/plugins/{SurfacePlugin → plugin-surface}/index.ts +4 -0
- package/src/plugins/{SurfacePlugin → plugin-surface}/provides.ts +2 -1
- package/tsconfig.json +2 -30
- package/vitest.config.ts +9 -0
- package/dist/lib/browser/chunk-J45KR4DI.mjs +0 -52
- package/dist/lib/browser/chunk-J45KR4DI.mjs.map +0 -7
- package/dist/lib/browser/chunk-S5CI6EUQ.mjs +0 -20
- package/dist/lib/browser/chunk-S5CI6EUQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-YYV26N3W.mjs +0 -26
- package/dist/lib/browser/chunk-YYV26N3W.mjs.map +0 -7
- package/dist/lib/browser/plugin-K3KCPCTJ.mjs +0 -39
- package/dist/lib/browser/plugin-K3KCPCTJ.mjs.map +0 -7
- package/dist/lib/browser/plugin-MM66VRCO.mjs.map +0 -7
- package/dist/lib/node/chunk-62W6CMGM.cjs.map +0 -7
- package/dist/lib/node/chunk-DFST5IG5.cjs +0 -77
- package/dist/lib/node/chunk-DFST5IG5.cjs.map +0 -7
- package/dist/lib/node/chunk-P5GRB4XF.cjs.map +0 -7
- package/dist/lib/node/plugin-QV7ESETI.cjs.map +0 -7
- package/dist/lib/node/plugin-RUJ5PEXB.cjs +0 -61
- package/dist/lib/node/plugin-RUJ5PEXB.cjs.map +0 -7
- package/dist/types/src/plugins/IntentPlugin/IntentContext.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/index.d.ts +0 -4
- package/dist/types/src/plugins/IntentPlugin/index.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/intent.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/IntentPlugin/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +0 -1
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +0 -25
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +0 -1
- package/dist/types/src/plugins/PluginHost/index.d.ts +0 -4
- package/dist/types/src/plugins/PluginHost/index.d.ts.map +0 -1
- package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/ErrorBoundary.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/meta.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts +0 -8
- package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts.map +0 -1
- package/dist/types/src/plugins/SurfacePlugin/provides.d.ts.map +0 -1
- package/dist/types/src/plugins/common/settings.d.ts +0 -9
- package/dist/types/src/plugins/common/settings.d.ts.map +0 -1
- package/src/plugins/PluginHost/PluginHost.tsx +0 -198
- package/src/plugins/common/settings.ts +0 -22
- /package/dist/types/src/plugins/{PluginHost → plugin-host}/plugin.test.d.ts +0 -0
- /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/IntentContext.d.ts +0 -0
- /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/helpers.d.ts +0 -0
- /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/meta.d.ts +0 -0
- /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/ErrorBoundary.d.ts +0 -0
- /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/helpers.d.ts +0 -0
- /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/meta.d.ts +0 -0
- /package/src/plugins/{IntentPlugin → plugin-intent}/IntentContext.tsx +0 -0
- /package/src/plugins/{IntentPlugin → plugin-intent}/helpers.ts +0 -0
- /package/src/plugins/{IntentPlugin → plugin-intent}/meta.ts +0 -0
- /package/src/plugins/{SurfacePlugin → plugin-surface}/ErrorBoundary.tsx +0 -0
- /package/src/plugins/{SurfacePlugin → plugin-surface}/helpers.ts +0 -0
- /package/src/plugins/{SurfacePlugin → plugin-surface}/meta.ts +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var chunk_DFST5IG5_exports = {};
|
|
20
|
-
__export(chunk_DFST5IG5_exports, {
|
|
21
|
-
IntentAction: () => IntentAction,
|
|
22
|
-
IntentProvider: () => IntentProvider,
|
|
23
|
-
meta_default: () => meta_default,
|
|
24
|
-
parseIntentPlugin: () => parseIntentPlugin,
|
|
25
|
-
parseIntentResolverPlugin: () => parseIntentResolverPlugin,
|
|
26
|
-
useIntent: () => useIntent,
|
|
27
|
-
useIntentDispatcher: () => useIntentDispatcher,
|
|
28
|
-
useIntentResolver: () => useIntentResolver
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(chunk_DFST5IG5_exports);
|
|
31
|
-
var import_react = require("react");
|
|
32
|
-
var import_react2 = require("react");
|
|
33
|
-
var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
|
|
34
|
-
var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
|
|
35
|
-
var INTENT_ACTION = "dxos.org/plugin/intent";
|
|
36
|
-
var IntentAction;
|
|
37
|
-
(function(IntentAction2) {
|
|
38
|
-
IntentAction2[IntentAction2["SHOW_UNDO"] = `${INTENT_ACTION}/show-undo`] = "SHOW_UNDO";
|
|
39
|
-
})(IntentAction || (IntentAction = {}));
|
|
40
|
-
var IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
41
|
-
dispatch: async () => ({}),
|
|
42
|
-
undo: async () => ({}),
|
|
43
|
-
history: [],
|
|
44
|
-
registerResolver: () => () => {
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
var useIntent = () => (0, import_react.useContext)(IntentContext);
|
|
48
|
-
var useIntentDispatcher = () => {
|
|
49
|
-
const { dispatch } = useIntent();
|
|
50
|
-
return dispatch;
|
|
51
|
-
};
|
|
52
|
-
var useIntentResolver = (plugin, resolver) => {
|
|
53
|
-
const { registerResolver } = useIntent();
|
|
54
|
-
(0, import_react2.useEffect)(() => {
|
|
55
|
-
return registerResolver(plugin, resolver);
|
|
56
|
-
}, [
|
|
57
|
-
plugin,
|
|
58
|
-
resolver
|
|
59
|
-
]);
|
|
60
|
-
};
|
|
61
|
-
var IntentProvider = IntentContext.Provider;
|
|
62
|
-
var IntentMeta = {
|
|
63
|
-
id: "dxos.org/plugin/intent"
|
|
64
|
-
};
|
|
65
|
-
var meta_default = IntentMeta;
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
IntentAction,
|
|
69
|
-
IntentProvider,
|
|
70
|
-
meta_default,
|
|
71
|
-
parseIntentPlugin,
|
|
72
|
-
parseIntentResolverPlugin,
|
|
73
|
-
useIntent,
|
|
74
|
-
useIntentDispatcher,
|
|
75
|
-
useIntentResolver
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=chunk-DFST5IG5.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/IntentPlugin/provides.ts", "../../../src/plugins/IntentPlugin/IntentContext.tsx", "../../../src/plugins/IntentPlugin/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext } from './IntentContext';\nimport { type IntentResolver } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: IntentResolver;\n };\n};\n\nexport type IntentPluginProvides = {\n intent: IntentContext;\n};\n\nexport const parseIntentPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.dispatch ? (plugin as Plugin<IntentPluginProvides>) : undefined;\n\nexport const parseIntentResolverPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.resolver ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n\n//\n// Intents\n//\n\nconst INTENT_ACTION = 'dxos.org/plugin/intent';\nexport enum IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n SHOW_UNDO = `${INTENT_ACTION}/show-undo`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\nimport { useEffect } from 'react';\n\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Intent, IntentDispatcher, IntentResolver, IntentResult } from './intent';\n\nexport type IntentExecution = {\n intent: Intent;\n result: IntentResult;\n};\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n undo: () => Promise<IntentResult | void>;\n history: IntentExecution[][];\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated Prefer granular hooks.\n */\n// TODO(burdon): Remove. Use useIntentDispatcher.\nexport const useIntent = () => useContext(IntentContext);\n\nexport const useIntentDispatcher = (): IntentDispatcher => {\n const { dispatch } = useIntent();\n return dispatch;\n};\n\nexport const useIntentResolver = (plugin: string, resolver: IntentResolver) => {\n const { registerResolver } = useIntent();\n useEffect(() => {\n return registerResolver(plugin, resolver);\n }, [plugin, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext> = IntentContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst IntentMeta = {\n id: 'dxos.org/plugin/intent',\n};\n\nexport default IntentMeta;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAuE;AACvE,IAAAA,gBAA0B;ADanB,IAAMC,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;AAM3F,IAAMG,gBAAgB;;UACVC,eAAAA;AAGTA,gBAAAA,cAAA,WAAA,IACW,GAAGD,aAAAA,YAAyB,IAAA;GAJ9BC,iBAAAA,eAAAA,CAAAA,EAAAA;ACNZ,IAAMC,gBAAwCC,gDAA6B;EACzEP,UAAU,aAAa,CAAC;EACxBQ,MAAM,aAAa,CAAC;EACpBC,SAAS,CAAA;EACTC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,UAAMC,yBAAWN,aAAAA;AAEnC,IAAMO,sBAAsB,MAAA;AACjC,QAAM,EAAEb,SAAQ,IAAKW,UAAAA;AACrB,SAAOX;AACT;AAEO,IAAMc,oBAAoB,CAACjB,QAAgBM,aAAAA;AAChD,QAAM,EAAEO,iBAAgB,IAAKC,UAAAA;AAC7BI,+BAAU,MAAA;AACR,WAAOL,iBAAiBb,QAAQM,QAAAA;EAClC,GAAG;IAACN;IAAQM;GAAS;AACvB;AAEO,IAAMa,iBAA0CV,cAAcW;AC5CrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
|
|
6
|
-
"names": ["import_react", "parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "INTENT_ACTION", "IntentAction", "IntentContext", "createContext", "undo", "history", "registerResolver", "useIntent", "useContext", "useIntentDispatcher", "useIntentResolver", "useEffect", "IntentProvider", "Provider", "IntentMeta", "id"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type Context, type JSX, type Provider, type ForwardedRef } from 'react';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n};\n\nconst SurfaceRootContext: Context<SurfaceRootContext> = createContext<SurfaceRootContext>({ components: {} });\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext);\n\nexport const SurfaceProvider: Provider<SurfaceRootContext> = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAoG;ADgB7F,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;ACexF,IAAMG,qBAAkDC,gDAAkC;EAAEL,YAAY,CAAC;AAAE,CAAA;AAEpG,IAAMM,iBAAiB,UAAMC,yBAAWH,kBAAAA;AAExC,IAAMI,kBAAgDJ,mBAAmBK;ACvChF,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
|
|
6
|
-
"names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfaceRootContext", "createContext", "useSurfaceRoot", "useContext", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/IntentPlugin/plugin.tsx", "../../../src/plugins/IntentPlugin/helpers.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { type IntentContext, IntentProvider, type IntentExecution } from './IntentContext';\nimport { isUndoable } from './helpers';\nimport type { Intent, IntentResolver } from './intent';\nimport IntentMeta from './meta';\nimport {\n type IntentPluginProvides,\n type IntentResolverProvides,\n parseIntentResolverPlugin,\n IntentAction,\n} from './provides';\nimport type { PluginDefinition } from '../PluginHost';\nimport { filterPlugins, findPlugin } from '../helpers';\n\nconst EXECUTION_LIMIT = 1000;\nconst HISTORY_LIMIT = 100;\n\n/**\n * Allows plugins to register intent handlers and routes sent intents to the appropriate plugin.\n * Inspired by https://developer.android.com/reference/android/content/Intent.\n */\nconst IntentPlugin = (): PluginDefinition<IntentPluginProvides> => {\n const state = create<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n });\n\n const dynamicResolvers = new Set<{ plugin: string; resolver: IntentResolver }>();\n\n return {\n meta: IntentMeta,\n ready: async (plugins) => {\n // Dispatch intent to associated plugin.\n const dispatch = async (intent: Intent) => {\n log('dispatch', { action: intent.action, intent });\n if (intent.plugin) {\n for (const entry of dynamicResolvers) {\n if (entry.plugin === intent.plugin) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n }\n\n const plugin = findPlugin<IntentResolverProvides>(plugins, intent.plugin);\n const result = plugin?.provides.intent.resolver(intent, plugins);\n return result;\n }\n\n for (const entry of dynamicResolvers) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // Return resolved value from first plugin that handles the intent.\n for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {\n const result = await plugin.provides.intent.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // https://vitejs.dev/guide/env-and-mode#env-variables\n // TODO(wittjosiah): How to handle this more generically?\n if (import.meta?.env?.DEV) {\n log.warn('No plugin found to handle intent', intent);\n }\n };\n\n // Sequentially dispatch array of invents.\n const dispatchChain = async (intentOrArray: Intent | Intent[], depth = 0) => {\n if (depth > EXECUTION_LIMIT) {\n return {\n error: new Error(\n `Intent execution limit exceeded (${EXECUTION_LIMIT} iterations). This is likely due to an infinite loop within intent resolvers.`,\n ),\n };\n }\n\n const executionResults: IntentExecution[] = [];\n const chain = Array.isArray(intentOrArray) ? intentOrArray : [intentOrArray];\n for (const intent of chain) {\n const { result: prevResult } = executionResults.at(-1) ?? {};\n const data = intent.data ? { result: prevResult?.data, ...intent.data } : prevResult?.data;\n const result = await dispatch({ ...intent, data });\n\n if (!result || result?.error) {\n break;\n }\n\n executionResults.push({ intent, result });\n\n // TODO(wittjosiah): How does undo work with returned intents?\n result?.intents?.forEach((intents) => {\n void dispatchChain(intents, depth + 1);\n });\n }\n\n state.history.push(executionResults);\n if (state.history.length > HISTORY_LIMIT) {\n state.history.splice(0, state.history.length - HISTORY_LIMIT);\n }\n\n if (isUndoable(executionResults)) {\n void dispatch({ action: IntentAction.SHOW_UNDO, data: { results: executionResults } });\n }\n\n return executionResults.at(-1)?.result;\n };\n\n const undo = async () => {\n const last = state.history.findLastIndex(isUndoable);\n const chain =\n last !== -1 &&\n state.history[last]?.map(({ intent, result }): Intent => {\n const data = result.undoable?.data ? { ...intent.data, ...result.undoable.data } : intent.data;\n return { ...intent, data, undo: true };\n });\n if (chain) {\n const result = await dispatchChain(chain);\n state.history = state.history.filter((_, index) => index !== last);\n return result;\n }\n };\n\n state.dispatch = dispatchChain;\n state.undo = undo;\n state.registerResolver = (plugin, resolver) => {\n const entry = { plugin, resolver };\n dynamicResolvers.add(entry);\n return () => dynamicResolvers.delete(entry);\n };\n },\n provides: {\n intent: state,\n context: ({ children }) => <IntentProvider value={state}>{children}</IntentProvider>,\n },\n };\n};\n\nexport default IntentPlugin;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type IntentExecution } from './IntentContext';\n\n/**\n * Check if the chain of intents is undoable.\n */\nexport const isUndoable = (chain: IntentExecution[]): boolean =>\n chain.length > 0 && chain.every(({ result }) => result.undoable);\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,yBAAuB;AACvB,iBAAoB;;ACEb,IAAMA,aAAa,CAACC,UACzBA,MAAMC,SAAS,KAAKD,MAAME,MAAM,CAAC,EAAEC,OAAM,MAAOA,OAAOC,QAAQ;;ADYjE,IAAMC,kBAAkB;AACxB,IAAMC,gBAAgB;AAMtB,IAAMC,eAAe,MAAA;AACnB,QAAMC,YAAQC,2BAAsB;IAClCC,UAAU,aAAa,CAAC;IACxBC,MAAM,aAAa,CAAC;IACpBC,SAAS,CAAA;IACTC,kBAAkB,MAAM,MAAA;IAAO;EACjC,CAAA;AAEA,QAAMC,mBAAmB,oBAAIC,IAAAA;AAE7B,SAAO;IACLC,MAAMC;IACNC,OAAO,OAAOC,YAAAA;AAEZ,YAAMT,WAAW,OAAOU,WAAAA;AACtBC,4BAAI,YAAY;UAAEC,QAAQF,OAAOE;UAAQF;QAAO,GAAA;;;;;;AAChD,YAAIA,OAAOG,QAAQ;AACjB,qBAAWC,SAASV,kBAAkB;AACpC,gBAAIU,MAAMD,WAAWH,OAAOG,QAAQ;AAClC,oBAAMpB,UAAS,MAAMqB,MAAMC,SAASL,QAAQD,OAAAA;AAC5C,kBAAIhB,SAAQ;AACV,uBAAOA;cACT;YACF;UACF;AAEA,gBAAMoB,aAASG,kCAAmCP,SAASC,OAAOG,MAAM;AACxE,gBAAMpB,SAASoB,QAAQI,SAASP,OAAOK,SAASL,QAAQD,OAAAA;AACxD,iBAAOhB;QACT;AAEA,mBAAWqB,SAASV,kBAAkB;AACpC,gBAAMX,SAAS,MAAMqB,MAAMC,SAASL,QAAQD,OAAAA;AAC5C,cAAIhB,QAAQ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AK5B,SAAS;YAAEY,QAAQ0B,mCAAaC;YAAWN,MAAM;cAAEO,SAASZ;YAAiB;UAAE,CAAA;QACtF;AAEA,eAAOA,iBAAiBI,GAAG,EAAC,GAAIvC;MAClC;AAEA,YAAMQ,OAAO,YAAA;AACX,cAAMwC,OAAO3C,MAAMI,QAAQwC,cAAcrD,UAAAA;AACzC,cAAMC,QACJmD,SAAS,MACT3C,MAAMI,QAAQuC,IAAAA,GAAOE,IAAI,CAAC,EAAEjC,QAAQjB,OAAM,MAAE;AAC1C,gBAAMwC,OAAOxC,OAAOC,UAAUuC,OAAO;YAAE,GAAGvB,OAAOuB;YAAM,GAAGxC,OAAOC,SAASuC;UAAK,IAAIvB,OAAOuB;AAC1F,iBAAO;YAAE,GAAGvB;YAAQuB;YAAMhC,MAAM;UAAK;QACvC,CAAA;AACF,YAAIX,OAAO;AACT,gBAAMG,SAAS,MAAM8B,cAAcjC,KAAAA;AACnCQ,gBAAMI,UAAUJ,MAAMI,QAAQ0C,OAAO,CAACC,GAAGC,UAAUA,UAAUL,IAAAA;AAC7D,iBAAOhD;QACT;MACF;AAEAK,YAAME,WAAWuB;AACjBzB,YAAMG,OAAOA;AACbH,YAAMK,mBAAmB,CAACU,QAAQE,aAAAA;AAChC,cAAMD,QAAQ;UAAED;UAAQE;QAAS;AACjCX,yBAAiB2C,IAAIjC,KAAAA;AACrB,eAAO,MAAMV,iBAAiB4C,OAAOlC,KAAAA;MACvC;IACF;IACAG,UAAU;MACRP,QAAQZ;MACRmD,SAAS,CAAC,EAAEC,SAAQ,MAAO,6BAAAC,QAAA,cAACC,sCAAAA;QAAeC,OAAOvD;SAAQoD,QAAAA;IAC5D;EACF;AACF;AAEA,IAAA,iBAAerD;",
|
|
6
|
-
"names": ["isUndoable", "chain", "length", "every", "result", "undoable", "EXECUTION_LIMIT", "HISTORY_LIMIT", "IntentPlugin", "state", "create", "dispatch", "undo", "history", "registerResolver", "dynamicResolvers", "Set", "meta", "IntentMeta", "ready", "plugins", "intent", "log", "action", "plugin", "entry", "resolver", "findPlugin", "provides", "filterPlugins", "parseIntentResolverPlugin", "env", "DEV", "warn", "dispatchChain", "intentOrArray", "depth", "error", "Error", "executionResults", "Array", "isArray", "prevResult", "at", "data", "push", "intents", "forEach", "splice", "IntentAction", "SHOW_UNDO", "results", "last", "findLastIndex", "map", "filter", "_", "index", "add", "delete", "context", "children", "React", "IntentProvider", "value"]
|
|
7
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var plugin_RUJ5PEXB_exports = {};
|
|
30
|
-
__export(plugin_RUJ5PEXB_exports, {
|
|
31
|
-
default: () => plugin_default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(plugin_RUJ5PEXB_exports);
|
|
34
|
-
var import_chunk_P5GRB4XF = require("./chunk-P5GRB4XF.cjs");
|
|
35
|
-
var import_chunk_62W6CMGM = require("./chunk-62W6CMGM.cjs");
|
|
36
|
-
var import_react = __toESM(require("react"));
|
|
37
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
38
|
-
var SurfacePlugin = () => {
|
|
39
|
-
const state = (0, import_echo_schema.create)({
|
|
40
|
-
components: {}
|
|
41
|
-
});
|
|
42
|
-
return {
|
|
43
|
-
meta: import_chunk_P5GRB4XF.meta_default,
|
|
44
|
-
ready: async (plugins) => {
|
|
45
|
-
state.components = (0, import_chunk_62W6CMGM.filterPlugins)(plugins, import_chunk_P5GRB4XF.parseSurfacePlugin).reduce((acc, plugin) => {
|
|
46
|
-
return {
|
|
47
|
-
...acc,
|
|
48
|
-
[plugin.meta.id]: plugin.provides.surface.component
|
|
49
|
-
};
|
|
50
|
-
}, {});
|
|
51
|
-
},
|
|
52
|
-
provides: {
|
|
53
|
-
surface: state,
|
|
54
|
-
context: ({ children }) => /* @__PURE__ */ import_react.default.createElement(import_chunk_P5GRB4XF.SurfaceProvider, {
|
|
55
|
-
value: state
|
|
56
|
-
}, children)
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
var plugin_default = SurfacePlugin;
|
|
61
|
-
//# sourceMappingURL=plugin-RUJ5PEXB.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/SurfacePlugin/plugin.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport type { PluginDefinition } from '../PluginHost';\nimport { filterPlugins } from '../helpers';\n\n/**\n * Provides a registry of surface components.\n */\nconst SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {} });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n\nexport default SurfacePlugin;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,yBAAuB;AAWvB,IAAMA,gBAAgB,MAAA;AACpB,QAAMC,YAAQC,2BAA2B;IAAEC,YAAY,CAAC;EAAE,CAAA;AAE1D,SAAO;IACLC,MAAMC;IACNC,OAAO,OAAOC,YAAAA;AACZN,YAAME,iBAAaK,qCAAcD,SAASE,wCAAAA,EAAoBC,OAAO,CAACC,KAAKC,WAAAA;AACzE,eAAO;UAAE,GAAGD;UAAK,CAACC,OAAOR,KAAKS,EAAE,GAAGD,OAAOE,SAASC,QAAQC;QAAU;MACvE,GAAG,CAAC,CAAA;IACN;IACAF,UAAU;MACRC,SAASd;MACTgB,SAAS,CAAC,EAAEC,SAAQ,MAAO,6BAAAC,QAAA,cAACC,uCAAAA;QAAgBC,OAAOpB;SAAQiB,QAAAA;IAC7D;EACF;AACF;AAEA,IAAA,iBAAelB;",
|
|
6
|
-
"names": ["SurfacePlugin", "state", "create", "components", "meta", "SurfaceMeta", "ready", "plugins", "filterPlugins", "parseSurfacePlugin", "reduce", "acc", "plugin", "id", "provides", "surface", "component", "context", "children", "React", "SurfaceProvider", "value"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IntentContext.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/IntentContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA2C,KAAK,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEvF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,IAAI,EAAE,MAAM,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACzC,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC;IAC7B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,KAAK,mBAAmB,CAAC;CACvF,CAAC;AASF;;GAEG;AAEH,eAAO,MAAM,SAAS,qBAAkC,CAAC;AAEzD,eAAO,MAAM,mBAAmB,QAAO,gBAGtC,CAAC;AAEF,eAAO,MAAM,iBAAiB,WAAY,MAAM,YAAY,cAAc,SAKzE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,aAAa,CAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,UAAU,UAAW,eAAe,EAAE,KAAG,OACY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/intent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG;IAChF;;OAEG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IAEH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,GAAG,CAAC;IAEX;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,MAAM,CAAC;QAEhB;;WAEG;QACH,IAAI,CAAC,EAAE,UAAU,CAAC;KACnB,CAAC;IAEF;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/meta.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU;;CAEf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/plugin.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMtD;;;GAGG;AACH,QAAA,MAAM,YAAY,QAAO,gBAAgB,CAAC,oBAAoB,CA0H7D,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provides.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/IntentPlugin/provides.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE;QACN,QAAQ,EAAE,cAAc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SAGvG,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,aAAc,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,KAAG,MAAM,CAAC,CAAC,CAAC,EAGrG,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,aAAa,CAA0B,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import { type PluginContext } from './PluginContext';
|
|
3
|
-
import { type Plugin, type PluginDefinition } from './plugin';
|
|
4
|
-
import { ErrorBoundary } from '../SurfacePlugin';
|
|
5
|
-
export type BootstrapPluginsParams = {
|
|
6
|
-
order: PluginDefinition['meta'][];
|
|
7
|
-
plugins: Record<string, () => Promise<PluginDefinition>>;
|
|
8
|
-
core?: string[];
|
|
9
|
-
defaults?: string[];
|
|
10
|
-
fallback?: ErrorBoundary['props']['fallback'];
|
|
11
|
-
placeholder?: ReactNode;
|
|
12
|
-
};
|
|
13
|
-
export type PluginHostProvides = {
|
|
14
|
-
plugins: PluginContext;
|
|
15
|
-
};
|
|
16
|
-
export declare const parsePluginHost: (plugin: Plugin) => Plugin<PluginHostProvides> | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Bootstraps an application by initializing plugins and rendering root components.
|
|
19
|
-
*/
|
|
20
|
-
export declare const PluginHost: ({ order, plugins: definitions, core, defaults, fallback, placeholder, }: BootstrapPluginsParams) => PluginDefinition<PluginHostProvides>;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve a `PluginDefinition` into a fully initialized `Plugin`.
|
|
23
|
-
*/
|
|
24
|
-
export declare const initializePlugin: <T, U>(pluginDefinition: PluginDefinition<T, U>) => Promise<Plugin<T & U>>;
|
|
25
|
-
//# sourceMappingURL=PluginHost.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginHost.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/PluginHost/PluginHost.tsx"],"names":[],"mappings":"AAIA,OAAc,EAA6C,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAK9G,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,gBAAgB,EAAuB,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,eAAe,WAAY,MAAM,2CACwD,CAAC;AAIvG;;GAEG;AACH,eAAO,MAAM,UAAU,4EAOpB,sBAAsB,KAAG,gBAAgB,CAAC,kBAAkB,CAoC9D,CAAC;AAmFF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAU,CAAC,EAAE,CAAC,oBAAoB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAS5G,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/PluginHost/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC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1B,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,KAAK,EAAE,qBAAqB,EAC5B,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,KACpC,GAAG,CAAC,OAAO,GAAG,aAAa,GAAG,IAAI,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C,CAAC;AAIF,eAAO,MAAM,cAAc,0BAAuC,CAAC;AAEnE,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,kBAAkB,CAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/SurfacePlugin/helpers.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,QAAQ,SAAU,OAAO,KAAG,IAAI,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAwC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/SurfacePlugin/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAE3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/SurfacePlugin/meta.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,WAAW;;CAEhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type SurfacePluginProvides } from './provides';
|
|
2
|
-
import type { PluginDefinition } from '../PluginHost';
|
|
3
|
-
/**
|
|
4
|
-
* Provides a registry of surface components.
|
|
5
|
-
*/
|
|
6
|
-
declare const SurfacePlugin: () => PluginDefinition<SurfacePluginProvides>;
|
|
7
|
-
export default SurfacePlugin;
|
|
8
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/SurfacePlugin/plugin.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAsB,KAAK,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD;;GAEG;AACH,QAAA,MAAM,aAAa,QAAO,gBAAgB,CAAC,qBAAqB,CAe/D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provides.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/SurfacePlugin/provides.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE;QACP;;WAEG;QACH,SAAS,EAAE,gBAAgB,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAa,MAAM,8CACkD,CAAC;AAEzG,eAAO,MAAM,kBAAkB,YAAa,MAAM,wCAC+C,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from '../PluginHost';
|
|
2
|
-
export type SettingsProvides<T extends Record<string, any> = Record<string, any>> = {
|
|
3
|
-
settings: T;
|
|
4
|
-
};
|
|
5
|
-
export declare const parseSettingsPlugin: (plugin: Plugin) => Plugin<SettingsProvides<Record<string, any>>> | undefined;
|
|
6
|
-
export declare enum SettingsAction {
|
|
7
|
-
OPEN = "dxos.org/plugin/settings/open"
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/settings.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IAClF,QAAQ,EAAE,CAAC,CAAC;CACb,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAAY,MAAM,8DAEjD,CAAC;AAGF,oBAAY,cAAc;IACxB,IAAI,kCAA4B;CACjC"}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type JSX, type FC, type PropsWithChildren, type ReactNode, useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { LocalStorageStore } from '@dxos/local-storage';
|
|
8
|
-
import { log } from '@dxos/log';
|
|
9
|
-
|
|
10
|
-
import { type PluginContext, PluginProvider } from './PluginContext';
|
|
11
|
-
import { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';
|
|
12
|
-
import { ErrorBoundary } from '../SurfacePlugin';
|
|
13
|
-
|
|
14
|
-
export type BootstrapPluginsParams = {
|
|
15
|
-
order: PluginDefinition['meta'][];
|
|
16
|
-
plugins: Record<string, () => Promise<PluginDefinition>>;
|
|
17
|
-
core?: string[];
|
|
18
|
-
defaults?: string[];
|
|
19
|
-
fallback?: ErrorBoundary['props']['fallback'];
|
|
20
|
-
placeholder?: ReactNode;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type PluginHostProvides = {
|
|
24
|
-
plugins: PluginContext;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const parsePluginHost = (plugin: Plugin) =>
|
|
28
|
-
(plugin.provides as PluginHostProvides).plugins ? (plugin as Plugin<PluginHostProvides>) : undefined;
|
|
29
|
-
|
|
30
|
-
const PLUGIN_HOST = 'dxos.org/plugin/host';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Bootstraps an application by initializing plugins and rendering root components.
|
|
34
|
-
*/
|
|
35
|
-
export const PluginHost = ({
|
|
36
|
-
order,
|
|
37
|
-
plugins: definitions,
|
|
38
|
-
core = [],
|
|
39
|
-
defaults = [],
|
|
40
|
-
fallback = DefaultFallback,
|
|
41
|
-
placeholder = null,
|
|
42
|
-
}: BootstrapPluginsParams): PluginDefinition<PluginHostProvides> => {
|
|
43
|
-
const state = new LocalStorageStore<PluginContext>(PLUGIN_HOST, {
|
|
44
|
-
ready: false,
|
|
45
|
-
core,
|
|
46
|
-
enabled: [...defaults],
|
|
47
|
-
plugins: [],
|
|
48
|
-
available: order.filter(({ id }) => !core.includes(id)),
|
|
49
|
-
setPlugin: (id: string, enabled: boolean) => {
|
|
50
|
-
if (enabled) {
|
|
51
|
-
state.values.enabled.push(id);
|
|
52
|
-
} else {
|
|
53
|
-
const index = state.values.enabled.findIndex((enabled) => enabled === id);
|
|
54
|
-
index !== -1 && state.values.enabled.splice(index, 1);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
state.prop({ key: 'enabled', type: LocalStorageStore.json<string[]>() });
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
meta: {
|
|
63
|
-
id: PLUGIN_HOST,
|
|
64
|
-
name: 'Plugin host',
|
|
65
|
-
},
|
|
66
|
-
provides: {
|
|
67
|
-
plugins: state.values,
|
|
68
|
-
context: ({ children }) => <PluginProvider value={state.values}>{children}</PluginProvider>,
|
|
69
|
-
root: () => {
|
|
70
|
-
return (
|
|
71
|
-
<ErrorBoundary fallback={fallback}>
|
|
72
|
-
<Root order={order} core={core} definitions={definitions} state={state.values} placeholder={placeholder} />
|
|
73
|
-
</ErrorBoundary>
|
|
74
|
-
);
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const DefaultFallback = ({ error }: { error: Error }) => {
|
|
81
|
-
return (
|
|
82
|
-
<div style={{ padding: '1rem' }}>
|
|
83
|
-
{/* TODO(wittjosiah): Link to docs for replacing default. */}
|
|
84
|
-
<h1 style={{ fontSize: '1.2rem', fontWeight: 700, margin: '0.5rem 0' }}>{error.message}</h1>
|
|
85
|
-
<pre>{error.stack}</pre>
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
type RootProps = {
|
|
91
|
-
order: PluginDefinition['meta'][];
|
|
92
|
-
state: PluginContext;
|
|
93
|
-
definitions: Record<string, () => Promise<PluginDefinition>>;
|
|
94
|
-
core: string[];
|
|
95
|
-
placeholder: ReactNode;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const Root = ({ order, core: corePluginIds, definitions, state, placeholder }: RootProps) => {
|
|
99
|
-
const [error, setError] = useState<unknown>();
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
log('initializing plugins', { enabled: state.enabled });
|
|
103
|
-
const timeout = setTimeout(async () => {
|
|
104
|
-
try {
|
|
105
|
-
const enabledIds = [...corePluginIds, ...state.enabled].sort((a, b) => {
|
|
106
|
-
const indexA = order.findIndex(({ id }) => id === a);
|
|
107
|
-
const indexB = order.findIndex(({ id }) => id === b);
|
|
108
|
-
return indexA - indexB;
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const enabled = await Promise.all(
|
|
112
|
-
enabledIds
|
|
113
|
-
.map((id) => definitions[id])
|
|
114
|
-
// If local storage indicates a plugin is enabled, but it is not available, ignore it.
|
|
115
|
-
.filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))
|
|
116
|
-
.map((definition) => definition()),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const plugins = await Promise.all(
|
|
120
|
-
enabled.map(async (definition) => {
|
|
121
|
-
const plugin = await initializePlugin(definition).catch((err) => {
|
|
122
|
-
log.error('Failed to initialize plugin:', { id: definition.meta.id, err });
|
|
123
|
-
return undefined;
|
|
124
|
-
});
|
|
125
|
-
return plugin;
|
|
126
|
-
}),
|
|
127
|
-
).then((plugins) => plugins.filter((plugin): plugin is Plugin => Boolean(plugin)));
|
|
128
|
-
log('plugins initialized', { plugins });
|
|
129
|
-
|
|
130
|
-
await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
|
|
131
|
-
log('plugins ready', { plugins });
|
|
132
|
-
|
|
133
|
-
state.plugins = plugins;
|
|
134
|
-
state.ready = true;
|
|
135
|
-
} catch (err) {
|
|
136
|
-
setError(err);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
return () => {
|
|
141
|
-
clearTimeout(timeout);
|
|
142
|
-
state.ready = false;
|
|
143
|
-
// TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?
|
|
144
|
-
// void Promise.all(enabled.map((definition) => definition.unload?.()));
|
|
145
|
-
};
|
|
146
|
-
}, []);
|
|
147
|
-
|
|
148
|
-
if (error) {
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!state.ready) {
|
|
153
|
-
return <>{placeholder}</>;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const ComposedContext = composeContext(state.plugins);
|
|
157
|
-
|
|
158
|
-
return <ComposedContext>{rootComponents(state.plugins)}</ComposedContext>;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Resolve a `PluginDefinition` into a fully initialized `Plugin`.
|
|
163
|
-
*/
|
|
164
|
-
export const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {
|
|
165
|
-
const provides = await pluginDefinition.initialize?.();
|
|
166
|
-
return {
|
|
167
|
-
...pluginDefinition,
|
|
168
|
-
provides: {
|
|
169
|
-
...pluginDefinition.provides,
|
|
170
|
-
...provides,
|
|
171
|
-
} as PluginProvides<T & U>,
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const rootComponents = (plugins: Plugin[]) => {
|
|
176
|
-
return plugins
|
|
177
|
-
.map((plugin) => {
|
|
178
|
-
const Component = plugin.provides.root;
|
|
179
|
-
if (Component) {
|
|
180
|
-
return <Component key={plugin.meta.id} />;
|
|
181
|
-
} else {
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
.filter((node): node is JSX.Element => Boolean(node));
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const composeContext = (plugins: Plugin[]) => {
|
|
189
|
-
return compose(plugins.map((p) => p.provides.context!).filter(Boolean));
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const compose = (contexts: FC<PropsWithChildren>[]) => {
|
|
193
|
-
return [...contexts].reduce((Acc, Next) => ({ children }) => (
|
|
194
|
-
<Acc>
|
|
195
|
-
<Next>{children}</Next>
|
|
196
|
-
</Acc>
|
|
197
|
-
));
|
|
198
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Plugin } from '../PluginHost';
|
|
6
|
-
|
|
7
|
-
// TODO(burdon): Plugins should export ts-effect object (see local-storage).
|
|
8
|
-
// TODO(burdon): Auto generate form.
|
|
9
|
-
// TODO(burdon): Set surface's data.type to plugin id (allow custom settings surface).
|
|
10
|
-
|
|
11
|
-
export type SettingsProvides<T extends Record<string, any> = Record<string, any>> = {
|
|
12
|
-
settings: T; // TODO(burdon): Read-only.
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const parseSettingsPlugin = (plugin: Plugin) => {
|
|
16
|
-
return typeof (plugin.provides as any).settings === 'object' ? (plugin as Plugin<SettingsProvides>) : undefined;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const SETTINGS_ACTION = 'dxos.org/plugin/settings';
|
|
20
|
-
export enum SettingsAction {
|
|
21
|
-
OPEN = `${SETTINGS_ACTION}/open`,
|
|
22
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|