@dxos/app-framework 0.3.7-main.8c7953e → 0.3.7-main.fcec8cd

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.
Files changed (59) hide show
  1. package/dist/lib/browser/chunk-C2K6M6WC.mjs +27 -0
  2. package/dist/lib/browser/chunk-C2K6M6WC.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-CFZ5JAJF.mjs +18 -0
  4. package/dist/lib/browser/chunk-CFZ5JAJF.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-T6Z4W7BV.mjs +26 -0
  6. package/dist/lib/browser/chunk-T6Z4W7BV.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +123 -181
  8. package/dist/lib/browser/index.mjs.map +4 -4
  9. package/dist/lib/browser/meta.json +1 -1
  10. package/dist/lib/browser/plugin-CBPJO5NB.mjs +63 -0
  11. package/dist/lib/browser/plugin-CBPJO5NB.mjs.map +7 -0
  12. package/dist/lib/browser/plugin-T5H34MVA.mjs +39 -0
  13. package/dist/lib/browser/plugin-T5H34MVA.mjs.map +7 -0
  14. package/dist/lib/node/index.cjs +315 -179
  15. package/dist/lib/node/index.cjs.map +4 -4
  16. package/dist/lib/node/meta.json +1 -1
  17. package/dist/types/src/App.d.ts +13 -3
  18. package/dist/types/src/App.d.ts.map +1 -1
  19. package/dist/types/src/plugins/IntentPlugin/index.d.ts +1 -1
  20. package/dist/types/src/plugins/IntentPlugin/index.d.ts.map +1 -1
  21. package/dist/types/src/plugins/IntentPlugin/meta.d.ts +5 -0
  22. package/dist/types/src/plugins/IntentPlugin/meta.d.ts.map +1 -0
  23. package/dist/types/src/plugins/IntentPlugin/plugin.d.ts +9 -0
  24. package/dist/types/src/plugins/IntentPlugin/plugin.d.ts.map +1 -0
  25. package/dist/types/src/plugins/IntentPlugin/{IntentPlugin.d.ts → provides.d.ts} +2 -7
  26. package/dist/types/src/plugins/IntentPlugin/provides.d.ts.map +1 -0
  27. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +27 -3
  28. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
  29. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +7 -4
  30. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
  31. package/dist/types/src/plugins/PluginHost/plugin.d.ts +49 -1
  32. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
  33. package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +1 -1
  34. package/dist/types/src/plugins/SurfacePlugin/index.d.ts +1 -1
  35. package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +1 -1
  36. package/dist/types/src/plugins/SurfacePlugin/meta.d.ts +5 -0
  37. package/dist/types/src/plugins/SurfacePlugin/meta.d.ts.map +1 -0
  38. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts +8 -0
  39. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts.map +1 -0
  40. package/dist/types/src/plugins/SurfacePlugin/{SurfacePlugin.d.ts → provides.d.ts} +2 -6
  41. package/dist/types/src/plugins/SurfacePlugin/provides.d.ts.map +1 -0
  42. package/package.json +8 -6
  43. package/src/App.tsx +24 -6
  44. package/src/plugins/IntentPlugin/index.ts +2 -1
  45. package/src/plugins/IntentPlugin/meta.ts +9 -0
  46. package/src/plugins/IntentPlugin/{IntentPlugin.tsx → plugin.tsx} +8 -22
  47. package/src/plugins/IntentPlugin/provides.ts +23 -0
  48. package/src/plugins/PluginHost/PluginContext.tsx +36 -5
  49. package/src/plugins/PluginHost/PluginHost.tsx +58 -98
  50. package/src/plugins/PluginHost/plugin.ts +31 -1
  51. package/src/plugins/SurfacePlugin/Surface.tsx +2 -4
  52. package/src/plugins/SurfacePlugin/index.ts +2 -1
  53. package/src/plugins/SurfacePlugin/meta.ts +9 -0
  54. package/src/plugins/SurfacePlugin/plugin.tsx +36 -0
  55. package/src/plugins/SurfacePlugin/provides.ts +25 -0
  56. package/tsconfig.json +3 -0
  57. package/dist/types/src/plugins/IntentPlugin/IntentPlugin.d.ts.map +0 -1
  58. package/dist/types/src/plugins/SurfacePlugin/SurfacePlugin.d.ts.map +0 -1
  59. package/src/plugins/SurfacePlugin/SurfacePlugin.tsx +0 -53
@@ -0,0 +1,27 @@
1
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts
2
+ var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
3
+ var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
4
+
5
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
6
+ import { createContext, useContext } from "react";
7
+ var IntentContext = /* @__PURE__ */ createContext({
8
+ dispatch: async () => {
9
+ }
10
+ });
11
+ var useIntent = () => useContext(IntentContext);
12
+ var IntentProvider = IntentContext.Provider;
13
+
14
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts
15
+ var IntentMeta = {
16
+ id: "dxos.org/plugin/intent"
17
+ };
18
+ var meta_default = IntentMeta;
19
+
20
+ export {
21
+ parseIntentPlugin,
22
+ parseIntentResolverPlugin,
23
+ useIntent,
24
+ IntentProvider,
25
+ meta_default
26
+ };
27
+ //# sourceMappingURL=chunk-C2K6M6WC.mjs.map
@@ -0,0 +1,7 @@
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 Intent } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: (intent: Intent, plugins: Plugin[]) => any;\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// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\n\nimport { type DispatchIntent } from './intent';\n\nexport type IntentContext = {\n dispatch: DispatchIntent;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({ dispatch: async () => {} });\n\nexport const useIntent = () => useContext(IntentContext);\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": ";AAkBO,IAAMA,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;;;AClB3F,SAAuBG,eAAeC,kBAAiC;AAQvE,IAAMC,gBAAwCC,8BAA6B;EAAEC,UAAU,YAAA;EAAa;AAAE,CAAA;AAE/F,IAAMC,YAAY,MAAMC,WAAWJ,aAAAA;AAEnC,IAAMK,iBAA0CL,cAAcM;;;ACZrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
+ "names": ["parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "createContext", "useContext", "IntentContext", "createContext", "dispatch", "useIntent", "useContext", "IntentProvider", "Provider", "IntentMeta", "id"]
7
+ }
@@ -0,0 +1,18 @@
1
+ // packages/sdk/app-framework/src/plugins/helpers.ts
2
+ import { raise } from "@dxos/debug";
3
+ var findPlugin = (plugins, id) => {
4
+ return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
5
+ };
6
+ var getPlugin = (plugins, id) => {
7
+ return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
8
+ };
9
+ var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
10
+ var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
11
+
12
+ export {
13
+ findPlugin,
14
+ getPlugin,
15
+ filterPlugins,
16
+ resolvePlugin
17
+ };
18
+ //# sourceMappingURL=chunk-CFZ5JAJF.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/helpers.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { raise } from '@dxos/debug';\n\nimport { type Plugin } from './PluginHost';\n\n/**\n * Find a plugin by ID.\n */\nexport const findPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> | undefined => {\n return plugins.find(\n (plugin) => plugin.meta.id === id || (typeof plugin.meta.shortId === 'string' && plugin.meta.shortId === id),\n ) as Plugin<T>;\n};\n\n/**\n * Find a plugin by ID, or raise an error if not found.\n */\nexport const getPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> => {\n return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));\n};\n\n/**\n * Filter a list of plugins to only those that match a predicate.\n */\nexport const filterPlugins = <T>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T>[] => plugins.map((plugin) => predicate(plugin)).filter((plugin): plugin is Plugin<T> => !!plugin);\n\n/**\n * Resolves a plugin by predicate.\n *\n * @example\n * import { parseIntentPlugin, resolvePlugin } from '@dxos/app-framework';\n * const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n */\nexport const resolvePlugin = <T>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T> | undefined => filterPlugins(plugins, predicate)[0];\n"],
5
+ "mappings": ";AAIA,SAASA,aAAa;AAOf,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACC,WAAWA,OAAOC,KAAKH,OAAOA,MAAO,OAAOE,OAAOC,KAAKC,YAAY,YAAYF,OAAOC,KAAKC,YAAYJ,EAAAA;AAE7G;AAKO,IAAMK,YAAY,CAAIN,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,KAAOM,MAAM,IAAIC,MAAM,qBAAqBP,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMQ,gBAAgB,CAC3BT,SACAU,cACgBV,QAAQW,IAAI,CAACR,WAAWO,UAAUP,MAAAA,CAAAA,EAASS,OAAO,CAACT,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMU,gBAAgB,CAC3Bb,SACAU,cAC0BD,cAAcT,SAASU,SAAAA,EAAW,CAAA;",
6
+ "names": ["raise", "findPlugin", "plugins", "id", "find", "plugin", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
+ }
@@ -0,0 +1,26 @@
1
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
2
+ var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
3
+ var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
4
+
5
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
6
+ import { createContext, useContext } from "react";
7
+ var SurfaceRootContext = /* @__PURE__ */ createContext({
8
+ components: {}
9
+ });
10
+ var useSurface = () => useContext(SurfaceRootContext);
11
+ var SurfaceProvider = SurfaceRootContext.Provider;
12
+
13
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
14
+ var SurfaceMeta = {
15
+ id: "dxos.org/plugin/surface"
16
+ };
17
+ var meta_default = SurfaceMeta;
18
+
19
+ export {
20
+ parseRootSurfacePlugin,
21
+ parseSurfacePlugin,
22
+ useSurface,
23
+ SurfaceProvider,
24
+ meta_default
25
+ };
26
+ //# sourceMappingURL=chunk-T6Z4W7BV.mjs.map
@@ -0,0 +1,7 @@
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 Provider, type ReactNode } from 'react';\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 = (data: Record<string, unknown>, role?: string) => ReactNode;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n};\n\nconst SurfaceRootContext: Context<SurfaceRootContext> = createContext<SurfaceRootContext>({ components: {} });\n\nexport const useSurface = () => 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": ";AAoBO,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;;;ACpBxF,SAASG,eAAeC,kBAA+D;AAavF,IAAMC,qBAAkDC,8BAAkC;EAAEC,YAAY,CAAC;AAAE,CAAA;AAEpG,IAAMC,aAAa,MAAMC,WAAWJ,kBAAAA;AAEpC,IAAMK,kBAAgDL,mBAAmBM;;;ACjBhF,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
+ "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "createContext", "useContext", "SurfaceRootContext", "createContext", "components", "useSurface", "useContext", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
+ }
@@ -1,3 +1,24 @@
1
+ import {
2
+ SurfaceProvider,
3
+ meta_default as meta_default2,
4
+ parseRootSurfacePlugin,
5
+ parseSurfacePlugin,
6
+ useSurface
7
+ } from "./chunk-T6Z4W7BV.mjs";
8
+ import {
9
+ IntentProvider,
10
+ meta_default,
11
+ parseIntentPlugin,
12
+ parseIntentResolverPlugin,
13
+ useIntent
14
+ } from "./chunk-C2K6M6WC.mjs";
15
+ import {
16
+ filterPlugins,
17
+ findPlugin,
18
+ getPlugin,
19
+ resolvePlugin
20
+ } from "./chunk-CFZ5JAJF.mjs";
21
+
1
22
  // packages/sdk/app-framework/src/plugins/common/graph.ts
2
23
  var parseGraphPlugin = (plugin) => plugin.provides.graph?.root ? plugin : void 0;
3
24
  var parseGraphBuilderPlugin = (plugin) => plugin.provides.graph?.builder ? plugin : void 0;
@@ -56,88 +77,30 @@ var parseTranslationsPlugin = (plugin) => {
56
77
  return success ? plugin : void 0;
57
78
  };
58
79
 
59
- // packages/sdk/app-framework/src/plugins/helpers.ts
60
- import { raise } from "@dxos/debug";
61
- var findPlugin = (plugins, id) => {
62
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
63
- };
64
- var getPlugin = (plugins, id) => {
65
- return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
66
- };
67
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
68
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
69
-
70
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
71
- import { createContext, useContext } from "react";
72
- var IntentContext = /* @__PURE__ */ createContext({
73
- dispatch: async () => {
74
- }
75
- });
76
- var useIntent = () => useContext(IntentContext);
77
- var IntentProvider = IntentContext.Provider;
78
-
79
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentPlugin.tsx
80
- import { deepSignal } from "deepsignal/react";
81
- import React from "react";
82
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
83
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
84
- var IntentPlugin = () => {
85
- const state = deepSignal({
86
- dispatch: async () => {
87
- }
88
- });
89
- return {
90
- meta: {
91
- id: "dxos.org/plugin/intent"
92
- },
93
- ready: async (plugins) => {
94
- const dispatch = async (intent) => {
95
- if (intent.plugin) {
96
- const plugin = findPlugin(plugins, intent.plugin);
97
- return plugin?.provides.intent.resolver(intent, plugins);
98
- }
99
- for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {
100
- const result = await plugin.provides.intent.resolver(intent, plugins);
101
- if (result) {
102
- return result;
103
- }
104
- }
105
- };
106
- state.dispatch = async (intentOrArray) => {
107
- let result = null;
108
- for (const intent of Array.isArray(intentOrArray) ? intentOrArray : [
109
- intentOrArray
110
- ]) {
111
- const data = intent.data ? {
112
- ...result,
113
- ...intent.data
114
- } : result;
115
- result = await dispatch({
116
- ...intent,
117
- data
118
- });
119
- }
120
- return result;
121
- };
122
- },
123
- provides: {
124
- intent: state,
125
- context: ({ children }) => /* @__PURE__ */ React.createElement(IntentProvider, {
126
- value: state
127
- }, children)
128
- }
80
+ // packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
81
+ var pluginMeta = (meta) => meta;
82
+ var Plugin;
83
+ (function(Plugin2) {
84
+ var lazy = Plugin2.lazy = (p, props) => {
85
+ return () => p().then(({ default: definition }) => {
86
+ return definition(props);
87
+ });
129
88
  };
130
- };
89
+ })(Plugin || (Plugin = {}));
131
90
 
132
91
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
133
- import { createContext as createContext2, useContext as useContext2 } from "react";
134
- var PluginContext = /* @__PURE__ */ createContext2({
92
+ import { createContext, useContext } from "react";
93
+ var PluginContext = /* @__PURE__ */ createContext({
135
94
  ready: false,
136
- initializing: [],
137
- loading: [],
138
- plugins: []
95
+ enabled: [],
96
+ plugins: [],
97
+ available: [],
98
+ enablePlugin: () => {
99
+ },
100
+ disablePlugin: () => {
101
+ }
139
102
  });
140
- var usePlugins = () => useContext2(PluginContext);
103
+ var usePlugins = () => useContext(PluginContext);
141
104
  var usePlugin = (id) => {
142
105
  const { plugins } = usePlugins();
143
106
  return findPlugin(plugins, id);
@@ -149,90 +112,100 @@ var useResolvePlugin = (predicate) => {
149
112
  var PluginProvider = PluginContext.Provider;
150
113
 
151
114
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
152
- import { deepSignal as deepSignal2, shallow } from "deepsignal/react";
153
- import React2, { useEffect } from "react";
115
+ import { shallow } from "deepsignal/react";
116
+ import React, { useEffect } from "react";
117
+ import { LocalStorageStore } from "@dxos/local-storage";
154
118
  import { log } from "@dxos/log";
155
119
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
156
120
  var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
157
- var PluginHost = ({ plugins: definitions, fallback }) => {
158
- const state = deepSignal2({
121
+ var PLUGIN_HOST = "dxos.org/plugin/host";
122
+ var PluginHost = ({ order, plugins: definitions, core = order.map(({ id }) => id), defaults = [], fallback = null }) => {
123
+ const state = new LocalStorageStore(PLUGIN_HOST, {
159
124
  ready: false,
160
- initializing: [],
161
- loading: [],
162
- plugins: []
125
+ enabled: [
126
+ ...defaults
127
+ ],
128
+ plugins: [],
129
+ available: order.filter(({ id }) => !core.includes(id)),
130
+ enablePlugin: (id) => {
131
+ state.values.enabled = [
132
+ ...state.values.enabled,
133
+ id
134
+ ];
135
+ },
136
+ disablePlugin: (id) => {
137
+ state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);
138
+ }
163
139
  });
140
+ state.prop(state.values.$enabled, "enabled", LocalStorageStore.json);
164
141
  return {
165
142
  meta: {
166
- id: "dxos.org/plugin/host"
143
+ id: PLUGIN_HOST
167
144
  },
168
145
  provides: {
169
- plugins: state,
170
- context: ({ children }) => /* @__PURE__ */ React2.createElement(PluginProvider, {
171
- value: state
146
+ plugins: state.values,
147
+ context: ({ children }) => /* @__PURE__ */ React.createElement(PluginProvider, {
148
+ value: state.values
172
149
  }, children),
173
150
  root: () => {
174
151
  useEffect(() => {
175
152
  log("initializing plugins", {
176
- definitions
153
+ enabled: state.values.enabled
177
154
  }, {
178
155
  F: __dxlog_file,
179
- L: 43,
156
+ L: 65,
180
157
  S: void 0,
181
158
  C: (f, a) => f(...a)
182
159
  });
183
160
  const timeout = setTimeout(async () => {
184
- state.initializing = shallow(definitions);
185
- const plugins = await Promise.all(definitions.map(async (definition) => {
161
+ const enabledIds = [
162
+ ...core,
163
+ ...state.values.enabled
164
+ ].sort((a, b) => {
165
+ const indexA = order.findIndex(({ id }) => id === a);
166
+ const indexB = order.findIndex(({ id }) => id === b);
167
+ return indexA - indexB;
168
+ });
169
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
170
+ const plugins = await Promise.all(enabled.map(async (definition) => {
186
171
  const plugin = await initializePlugin(definition).catch((err) => {
187
172
  console.error("Failed to initialize plugin:", definition.meta.id, err);
188
173
  return void 0;
189
174
  });
190
- state.initializing = shallow(state.initializing.filter((plugin2) => plugin2 !== definition));
191
175
  return plugin;
192
176
  })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
193
177
  log("plugins initialized", {
194
178
  plugins
195
179
  }, {
196
180
  F: __dxlog_file,
197
- L: 57,
181
+ L: 90,
198
182
  S: void 0,
199
183
  C: (f, a) => f(...a)
200
184
  });
201
- state.loading = shallow(definitions);
202
- await Promise.all(definitions.map(async (pluginDefinition) => {
185
+ await Promise.all(enabled.map(async (pluginDefinition) => {
203
186
  await pluginDefinition.ready?.(plugins);
204
- state.loading = shallow(state.loading.filter((plugin) => plugin !== pluginDefinition));
205
187
  }));
206
188
  log("plugins ready", {
207
189
  plugins
208
190
  }, {
209
191
  F: __dxlog_file,
210
- L: 66,
192
+ L: 97,
211
193
  S: void 0,
212
194
  C: (f, a) => f(...a)
213
195
  });
214
- state.plugins = shallow(plugins);
215
- state.ready = true;
196
+ state.values.plugins = shallow(plugins);
197
+ state.values.ready = true;
216
198
  });
217
199
  return () => {
218
200
  clearTimeout(timeout);
219
- state.ready = false;
220
- void Promise.all(definitions.map((definition) => definition.unload?.()));
201
+ state.values.ready = false;
221
202
  };
222
203
  }, []);
223
- if (!state.ready) {
224
- if (typeof fallback === "function") {
225
- const FallbackComponent = fallback;
226
- return /* @__PURE__ */ React2.createElement(FallbackComponent, {
227
- initializing: state.initializing,
228
- loading: state.loading,
229
- plugins: state.plugins
230
- });
231
- }
232
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, fallback ?? null);
204
+ if (!state.values.ready) {
205
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
233
206
  }
234
- const ComposedContext = composeContext(state.plugins);
235
- return /* @__PURE__ */ React2.createElement(ComposedContext, null, rootComponents(state.plugins));
207
+ const ComposedContext = composeContext(state.values.plugins);
208
+ return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.values.plugins));
236
209
  }
237
210
  }
238
211
  };
@@ -251,7 +224,7 @@ var rootComponents = (plugins) => {
251
224
  return plugins.map((plugin) => {
252
225
  const Component2 = plugin.provides.root;
253
226
  if (Component2) {
254
- return /* @__PURE__ */ React2.createElement(Component2, {
227
+ return /* @__PURE__ */ React.createElement(Component2, {
255
228
  key: plugin.meta.id
256
229
  });
257
230
  } else {
@@ -265,11 +238,11 @@ var composeContext = (plugins) => {
265
238
  var compose = (contexts) => {
266
239
  return [
267
240
  ...contexts
268
- ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React2.createElement(Acc, null, /* @__PURE__ */ React2.createElement(Next, null, children)));
241
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
269
242
  };
270
243
 
271
244
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
272
- import React3, { Component } from "react";
245
+ import React2, { Component } from "react";
273
246
  var ErrorBoundary = class extends Component {
274
247
  constructor(props) {
275
248
  super(props);
@@ -289,7 +262,7 @@ var ErrorBoundary = class extends Component {
289
262
  }
290
263
  render() {
291
264
  if (this.state.error) {
292
- return /* @__PURE__ */ React3.createElement(this.props.fallback, {
265
+ return /* @__PURE__ */ React2.createElement(this.props.fallback, {
293
266
  error: this.state.error,
294
267
  reset: this.resetError
295
268
  });
@@ -304,18 +277,8 @@ var ErrorBoundary = class extends Component {
304
277
  };
305
278
 
306
279
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
307
- import React4 from "react";
308
- import { createContext as createContext4, useContext as useContext4 } from "react";
309
-
310
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
311
- import { createContext as createContext3, useContext as useContext3 } from "react";
312
- var SurfaceRootContext = /* @__PURE__ */ createContext3({
313
- components: {}
314
- });
315
- var useSurface = () => useContext3(SurfaceRootContext);
316
- var SurfaceProvider = SurfaceRootContext.Provider;
317
-
318
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
280
+ import React3, { Fragment } from "react";
281
+ import { createContext as createContext2, useContext as useContext2 } from "react";
319
282
  var Surface = ({ role, name = role, fallback, ...rest }) => {
320
283
  const props = {
321
284
  role,
@@ -323,17 +286,17 @@ var Surface = ({ role, name = role, fallback, ...rest }) => {
323
286
  fallback,
324
287
  ...rest
325
288
  };
326
- const context = useContext4(SurfaceContext);
289
+ const context = useContext2(SurfaceContext);
327
290
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
328
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, fallback ? /* @__PURE__ */ React4.createElement(ErrorBoundary, {
291
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
329
292
  data,
330
293
  fallback
331
- }, /* @__PURE__ */ React4.createElement(SurfaceResolver, props)) : /* @__PURE__ */ React4.createElement(SurfaceResolver, props));
294
+ }, /* @__PURE__ */ React3.createElement(SurfaceResolver, props)) : /* @__PURE__ */ React3.createElement(SurfaceResolver, props));
332
295
  };
333
- var SurfaceContext = /* @__PURE__ */ createContext4(null);
296
+ var SurfaceContext = /* @__PURE__ */ createContext2(null);
334
297
  var SurfaceResolver = (props) => {
335
298
  const { components } = useSurface();
336
- const parent = useContext4(SurfaceContext);
299
+ const parent = useContext2(SurfaceContext);
337
300
  const nodes = resolveNodes(components, props, parent);
338
301
  const currentContext = {
339
302
  ...props,
@@ -342,9 +305,9 @@ var SurfaceResolver = (props) => {
342
305
  ...props.surfaces
343
306
  }
344
307
  };
345
- return /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
308
+ return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
346
309
  value: currentContext
347
- }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React4.createElement(props.contentFallback, null) : null);
310
+ }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React3.createElement(props.contentFallback, null) : null);
348
311
  };
349
312
  var resolveNodes = (components, props, context) => {
350
313
  const data = {
@@ -353,60 +316,39 @@ var resolveNodes = (components, props, context) => {
353
316
  };
354
317
  const nodes = Object.entries(components).map(([key, component]) => {
355
318
  const result = component(data, props.role);
356
- return result ? /* @__PURE__ */ React4.createElement(Wrapper, {
319
+ return result ? /* @__PURE__ */ React3.createElement(Fragment, {
357
320
  key
358
321
  }, result) : void 0;
359
322
  }).filter((Component2) => Boolean(Component2));
360
323
  return props.limit ? nodes.slice(0, props.limit) : nodes;
361
324
  };
362
- var Wrapper = ({ children }) => /* @__PURE__ */ React4.createElement(React4.Fragment, null, children);
363
-
364
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfacePlugin.tsx
365
- import { deepSignal as deepSignal3, shallow as shallow2 } from "deepsignal/react";
366
- import React5 from "react";
367
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
368
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
369
- var SurfacePlugin = () => {
370
- const state = deepSignal3({
371
- components: {}
372
- });
373
- return {
374
- meta: {
375
- id: "dxos.org/plugin/surface"
376
- },
377
- ready: async (plugins) => {
378
- state.components = shallow2(filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
379
- return {
380
- ...acc,
381
- [plugin.meta.id]: plugin.provides.surface.component
382
- };
383
- }, {}));
384
- },
385
- provides: {
386
- surface: state,
387
- context: ({ children }) => /* @__PURE__ */ React5.createElement(SurfaceProvider, {
388
- value: state
389
- }, children)
390
- }
391
- };
392
- };
393
325
 
394
326
  // packages/sdk/app-framework/src/App.tsx
395
- import React6 from "react";
327
+ import React4 from "react";
396
328
  import { invariant } from "@dxos/invariant";
397
329
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
398
- var createApp = ({ plugins, fallback }) => {
330
+ var createApp = ({ order, plugins, core = [], ...params }) => {
399
331
  const host = PluginHost({
400
- plugins: [
401
- SurfacePlugin(),
402
- IntentPlugin(),
403
- ...plugins
332
+ order: [
333
+ meta_default2,
334
+ meta_default,
335
+ ...order
404
336
  ],
405
- fallback
337
+ plugins: {
338
+ ...plugins,
339
+ [meta_default2.id]: Plugin.lazy(() => import("./plugin-T5H34MVA.mjs")),
340
+ [meta_default.id]: Plugin.lazy(() => import("./plugin-CBPJO5NB.mjs"))
341
+ },
342
+ core: [
343
+ meta_default2.id,
344
+ meta_default.id,
345
+ ...core
346
+ ],
347
+ ...params
406
348
  });
407
349
  invariant(host.provides?.context, void 0, {
408
350
  F: __dxlog_file2,
409
- L: 33,
351
+ L: 51,
410
352
  S: void 0,
411
353
  A: [
412
354
  "host.provides?.context",
@@ -415,7 +357,7 @@ var createApp = ({ plugins, fallback }) => {
415
357
  });
416
358
  invariant(host.provides?.root, void 0, {
417
359
  F: __dxlog_file2,
418
- L: 34,
360
+ L: 52,
419
361
  S: void 0,
420
362
  A: [
421
363
  "host.provides?.root",
@@ -424,21 +366,20 @@ var createApp = ({ plugins, fallback }) => {
424
366
  });
425
367
  const Context = host.provides.context;
426
368
  const Root = host.provides.root;
427
- return () => /* @__PURE__ */ React6.createElement(Context, null, /* @__PURE__ */ React6.createElement(Root, null));
369
+ return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root, null));
428
370
  };
429
371
  export {
430
372
  ErrorBoundary,
431
- IntentPlugin,
432
373
  IntentProvider,
433
374
  Layout,
434
375
  LayoutAction,
376
+ Plugin,
435
377
  PluginHost,
436
378
  PluginProvider,
437
379
  Resource,
438
380
  ResourceKey,
439
381
  ResourceLanguage,
440
382
  Surface,
441
- SurfacePlugin,
442
383
  SurfaceProvider,
443
384
  createApp,
444
385
  filterPlugins,
@@ -456,6 +397,7 @@ export {
456
397
  parseRootSurfacePlugin,
457
398
  parseSurfacePlugin,
458
399
  parseTranslationsPlugin,
400
+ pluginMeta,
459
401
  resolvePlugin,
460
402
  useIntent,
461
403
  usePlugin,