@dxos/app-framework 0.3.6 → 0.3.7-main.645bcb5

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 (63) 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-WDA7VA54.mjs +26 -0
  6. package/dist/lib/browser/chunk-WDA7VA54.mjs.map +7 -0
  7. package/dist/lib/browser/index.mjs +141 -190
  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-XEJ5RYCP.mjs +39 -0
  13. package/dist/lib/browser/plugin-XEJ5RYCP.mjs.map +7 -0
  14. package/dist/lib/node/index.cjs +333 -188
  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 +9 -4
  34. package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +1 -1
  35. package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts +8 -2
  36. package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts.map +1 -1
  37. package/dist/types/src/plugins/SurfacePlugin/index.d.ts +1 -1
  38. package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +1 -1
  39. package/dist/types/src/plugins/SurfacePlugin/meta.d.ts +5 -0
  40. package/dist/types/src/plugins/SurfacePlugin/meta.d.ts.map +1 -0
  41. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts +8 -0
  42. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts.map +1 -0
  43. package/dist/types/src/plugins/SurfacePlugin/{SurfacePlugin.d.ts → provides.d.ts} +2 -6
  44. package/dist/types/src/plugins/SurfacePlugin/provides.d.ts.map +1 -0
  45. package/package.json +8 -6
  46. package/src/App.tsx +24 -6
  47. package/src/plugins/IntentPlugin/index.ts +2 -1
  48. package/src/plugins/IntentPlugin/meta.ts +9 -0
  49. package/src/plugins/IntentPlugin/{IntentPlugin.tsx → plugin.tsx} +8 -22
  50. package/src/plugins/IntentPlugin/provides.ts +23 -0
  51. package/src/plugins/PluginHost/PluginContext.tsx +36 -5
  52. package/src/plugins/PluginHost/PluginHost.tsx +58 -98
  53. package/src/plugins/PluginHost/plugin.ts +31 -1
  54. package/src/plugins/SurfacePlugin/Surface.tsx +34 -27
  55. package/src/plugins/SurfacePlugin/SurfaceRootContext.tsx +11 -2
  56. package/src/plugins/SurfacePlugin/index.ts +2 -1
  57. package/src/plugins/SurfacePlugin/meta.ts +9 -0
  58. package/src/plugins/SurfacePlugin/plugin.tsx +36 -0
  59. package/src/plugins/SurfacePlugin/provides.ts +25 -0
  60. package/tsconfig.json +3 -0
  61. package/dist/types/src/plugins/IntentPlugin/IntentPlugin.d.ts.map +0 -1
  62. package/dist/types/src/plugins/SurfacePlugin/SurfacePlugin.d.ts.map +0 -1
  63. package/src/plugins/SurfacePlugin/SurfacePlugin.tsx +0 -53
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,21 +30,215 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // packages/sdk/app-framework/src/plugins/helpers.ts
34
+ var import_debug, findPlugin, getPlugin, filterPlugins, resolvePlugin;
35
+ var init_helpers = __esm({
36
+ "packages/sdk/app-framework/src/plugins/helpers.ts"() {
37
+ "use strict";
38
+ import_debug = require("@dxos/debug");
39
+ findPlugin = (plugins, id) => {
40
+ return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
41
+ };
42
+ getPlugin = (plugins, id) => {
43
+ return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
44
+ };
45
+ filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
46
+ resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
47
+ }
48
+ });
49
+
50
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts
51
+ var parseIntentPlugin, parseIntentResolverPlugin;
52
+ var init_provides = __esm({
53
+ "packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts"() {
54
+ "use strict";
55
+ parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
56
+ parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
57
+ }
58
+ });
59
+
60
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
61
+ var import_react, IntentContext, useIntent, IntentProvider;
62
+ var init_IntentContext = __esm({
63
+ "packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx"() {
64
+ "use strict";
65
+ import_react = require("react");
66
+ IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
67
+ dispatch: async () => {
68
+ }
69
+ });
70
+ useIntent = () => (0, import_react.useContext)(IntentContext);
71
+ IntentProvider = IntentContext.Provider;
72
+ }
73
+ });
74
+
75
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
76
+ var parseRootSurfacePlugin, parseSurfacePlugin;
77
+ var init_provides2 = __esm({
78
+ "packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts"() {
79
+ "use strict";
80
+ parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
81
+ parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
82
+ }
83
+ });
84
+
85
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
86
+ var import_react6, SurfaceRootContext, useSurface, SurfaceProvider;
87
+ var init_SurfaceRootContext = __esm({
88
+ "packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx"() {
89
+ "use strict";
90
+ import_react6 = require("react");
91
+ SurfaceRootContext = /* @__PURE__ */ (0, import_react6.createContext)({
92
+ components: {}
93
+ });
94
+ useSurface = () => (0, import_react6.useContext)(SurfaceRootContext);
95
+ SurfaceProvider = SurfaceRootContext.Provider;
96
+ }
97
+ });
98
+
99
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts
100
+ var IntentMeta, meta_default;
101
+ var init_meta = __esm({
102
+ "packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts"() {
103
+ "use strict";
104
+ IntentMeta = {
105
+ id: "dxos.org/plugin/intent"
106
+ };
107
+ meta_default = IntentMeta;
108
+ }
109
+ });
110
+
111
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
112
+ var SurfaceMeta, meta_default2;
113
+ var init_meta2 = __esm({
114
+ "packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts"() {
115
+ "use strict";
116
+ SurfaceMeta = {
117
+ id: "dxos.org/plugin/surface"
118
+ };
119
+ meta_default2 = SurfaceMeta;
120
+ }
121
+ });
122
+
123
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/plugin.tsx
124
+ var plugin_exports = {};
125
+ __export(plugin_exports, {
126
+ default: () => plugin_default
127
+ });
128
+ var import_react9, import_react10, SurfacePlugin, plugin_default;
129
+ var init_plugin = __esm({
130
+ "packages/sdk/app-framework/src/plugins/SurfacePlugin/plugin.tsx"() {
131
+ "use strict";
132
+ import_react9 = require("deepsignal/react");
133
+ import_react10 = __toESM(require("react"));
134
+ init_SurfaceRootContext();
135
+ init_meta2();
136
+ init_provides2();
137
+ init_helpers();
138
+ SurfacePlugin = () => {
139
+ const state = (0, import_react9.deepSignal)({
140
+ components: {}
141
+ });
142
+ return {
143
+ meta: meta_default2,
144
+ ready: async (plugins) => {
145
+ state.components = (0, import_react9.shallow)(filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
146
+ return {
147
+ ...acc,
148
+ [plugin.meta.id]: plugin.provides.surface.component
149
+ };
150
+ }, {}));
151
+ },
152
+ provides: {
153
+ surface: state,
154
+ context: ({ children }) => /* @__PURE__ */ import_react10.default.createElement(SurfaceProvider, {
155
+ value: state
156
+ }, children)
157
+ }
158
+ };
159
+ };
160
+ plugin_default = SurfacePlugin;
161
+ }
162
+ });
163
+
164
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/plugin.tsx
165
+ var plugin_exports2 = {};
166
+ __export(plugin_exports2, {
167
+ default: () => plugin_default2
168
+ });
169
+ var import_react11, import_react12, IntentPlugin, plugin_default2;
170
+ var init_plugin2 = __esm({
171
+ "packages/sdk/app-framework/src/plugins/IntentPlugin/plugin.tsx"() {
172
+ "use strict";
173
+ import_react11 = require("deepsignal/react");
174
+ import_react12 = __toESM(require("react"));
175
+ init_IntentContext();
176
+ init_meta();
177
+ init_provides();
178
+ init_helpers();
179
+ IntentPlugin = () => {
180
+ const state = (0, import_react11.deepSignal)({
181
+ dispatch: async () => {
182
+ }
183
+ });
184
+ return {
185
+ meta: meta_default,
186
+ ready: async (plugins) => {
187
+ const dispatch = async (intent) => {
188
+ if (intent.plugin) {
189
+ const plugin = findPlugin(plugins, intent.plugin);
190
+ return plugin?.provides.intent.resolver(intent, plugins);
191
+ }
192
+ for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {
193
+ const result = await plugin.provides.intent.resolver(intent, plugins);
194
+ if (result) {
195
+ return result;
196
+ }
197
+ }
198
+ };
199
+ state.dispatch = async (intentOrArray) => {
200
+ let result = null;
201
+ for (const intent of Array.isArray(intentOrArray) ? intentOrArray : [
202
+ intentOrArray
203
+ ]) {
204
+ const data = intent.data ? {
205
+ ...result,
206
+ ...intent.data
207
+ } : result;
208
+ result = await dispatch({
209
+ ...intent,
210
+ data
211
+ });
212
+ }
213
+ return result;
214
+ };
215
+ },
216
+ provides: {
217
+ intent: state,
218
+ context: ({ children }) => /* @__PURE__ */ import_react12.default.createElement(IntentProvider, {
219
+ value: state
220
+ }, children)
221
+ }
222
+ };
223
+ };
224
+ plugin_default2 = IntentPlugin;
225
+ }
226
+ });
227
+
30
228
  // packages/sdk/app-framework/src/index.ts
31
229
  var src_exports = {};
32
230
  __export(src_exports, {
33
231
  ErrorBoundary: () => ErrorBoundary,
34
- IntentPlugin: () => IntentPlugin,
35
232
  IntentProvider: () => IntentProvider,
36
233
  Layout: () => Layout,
37
234
  LayoutAction: () => LayoutAction,
235
+ Plugin: () => Plugin,
38
236
  PluginHost: () => PluginHost,
39
237
  PluginProvider: () => PluginProvider,
40
238
  Resource: () => Resource,
41
239
  ResourceKey: () => ResourceKey,
42
240
  ResourceLanguage: () => ResourceLanguage,
43
241
  Surface: () => Surface,
44
- SurfacePlugin: () => SurfacePlugin,
45
242
  SurfaceProvider: () => SurfaceProvider,
46
243
  createApp: () => createApp,
47
244
  filterPlugins: () => filterPlugins,
@@ -59,6 +256,7 @@ __export(src_exports, {
59
256
  parseRootSurfacePlugin: () => parseRootSurfacePlugin,
60
257
  parseSurfacePlugin: () => parseSurfacePlugin,
61
258
  parseTranslationsPlugin: () => parseTranslationsPlugin,
259
+ pluginMeta: () => pluginMeta,
62
260
  resolvePlugin: () => resolvePlugin,
63
261
  useIntent: () => useIntent,
64
262
  usePlugin: () => usePlugin,
@@ -126,88 +324,38 @@ var parseTranslationsPlugin = (plugin) => {
126
324
  return success ? plugin : void 0;
127
325
  };
128
326
 
129
- // packages/sdk/app-framework/src/plugins/helpers.ts
130
- var import_debug = require("@dxos/debug");
131
- var findPlugin = (plugins, id) => {
132
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
133
- };
134
- var getPlugin = (plugins, id) => {
135
- return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
136
- };
137
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
138
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
327
+ // packages/sdk/app-framework/src/plugins/index.ts
328
+ init_helpers();
139
329
 
140
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
141
- var import_react = require("react");
142
- var IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
143
- dispatch: async () => {
144
- }
145
- });
146
- var useIntent = () => (0, import_react.useContext)(IntentContext);
147
- var IntentProvider = IntentContext.Provider;
330
+ // packages/sdk/app-framework/src/plugins/IntentPlugin/index.ts
331
+ init_provides();
332
+ init_IntentContext();
148
333
 
149
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentPlugin.tsx
150
- var import_react2 = require("deepsignal/react");
151
- var import_react3 = __toESM(require("react"));
152
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
153
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
154
- var IntentPlugin = () => {
155
- const state = (0, import_react2.deepSignal)({
156
- dispatch: async () => {
157
- }
158
- });
159
- return {
160
- meta: {
161
- id: "dxos.org/plugin/intent"
162
- },
163
- ready: async (plugins) => {
164
- const dispatch = async (intent) => {
165
- if (intent.plugin) {
166
- const plugin = findPlugin(plugins, intent.plugin);
167
- return plugin?.provides.intent.resolver(intent, plugins);
168
- }
169
- for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {
170
- const result = await plugin.provides.intent.resolver(intent, plugins);
171
- if (result) {
172
- return result;
173
- }
174
- }
175
- };
176
- state.dispatch = async (intentOrArray) => {
177
- let result = null;
178
- for (const intent of Array.isArray(intentOrArray) ? intentOrArray : [
179
- intentOrArray
180
- ]) {
181
- const data = intent.data ? {
182
- ...result,
183
- ...intent.data
184
- } : result;
185
- result = await dispatch({
186
- ...intent,
187
- data
188
- });
189
- }
190
- return result;
191
- };
192
- },
193
- provides: {
194
- intent: state,
195
- context: ({ children }) => /* @__PURE__ */ import_react3.default.createElement(IntentProvider, {
196
- value: state
197
- }, children)
198
- }
334
+ // packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
335
+ var pluginMeta = (meta) => meta;
336
+ var Plugin;
337
+ (function(Plugin2) {
338
+ var lazy = Plugin2.lazy = (p, props) => {
339
+ return () => p().then(({ default: definition }) => {
340
+ return definition(props);
341
+ });
199
342
  };
200
- };
343
+ })(Plugin || (Plugin = {}));
201
344
 
202
345
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
203
- var import_react4 = require("react");
204
- var PluginContext = /* @__PURE__ */ (0, import_react4.createContext)({
346
+ var import_react2 = require("react");
347
+ init_helpers();
348
+ var PluginContext = /* @__PURE__ */ (0, import_react2.createContext)({
205
349
  ready: false,
206
- initializing: [],
207
- loading: [],
208
- plugins: []
350
+ enabled: [],
351
+ plugins: [],
352
+ available: [],
353
+ enablePlugin: () => {
354
+ },
355
+ disablePlugin: () => {
356
+ }
209
357
  });
210
- var usePlugins = () => (0, import_react4.useContext)(PluginContext);
358
+ var usePlugins = () => (0, import_react2.useContext)(PluginContext);
211
359
  var usePlugin = (id) => {
212
360
  const { plugins } = usePlugins();
213
361
  return findPlugin(plugins, id);
@@ -219,90 +367,100 @@ var useResolvePlugin = (predicate) => {
219
367
  var PluginProvider = PluginContext.Provider;
220
368
 
221
369
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
222
- var import_react5 = require("deepsignal/react");
223
- var import_react6 = __toESM(require("react"));
370
+ var import_react3 = require("deepsignal/react");
371
+ var import_react4 = __toESM(require("react"));
372
+ var import_local_storage = require("@dxos/local-storage");
224
373
  var import_log = require("@dxos/log");
225
- var __dxlog_file = "/home/circleci/project/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
374
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
226
375
  var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
227
- var PluginHost = ({ plugins: definitions, fallback }) => {
228
- const state = (0, import_react5.deepSignal)({
376
+ var PLUGIN_HOST = "dxos.org/plugin/host";
377
+ var PluginHost = ({ order, plugins: definitions, core = order.map(({ id }) => id), defaults = [], fallback = null }) => {
378
+ const state = new import_local_storage.LocalStorageStore(PLUGIN_HOST, {
229
379
  ready: false,
230
- initializing: [],
231
- loading: [],
232
- plugins: []
380
+ enabled: [
381
+ ...defaults
382
+ ],
383
+ plugins: [],
384
+ available: order.filter(({ id }) => !core.includes(id)),
385
+ enablePlugin: (id) => {
386
+ state.values.enabled = [
387
+ ...state.values.enabled,
388
+ id
389
+ ];
390
+ },
391
+ disablePlugin: (id) => {
392
+ state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);
393
+ }
233
394
  });
395
+ state.prop(state.values.$enabled, "enabled", import_local_storage.LocalStorageStore.json);
234
396
  return {
235
397
  meta: {
236
- id: "dxos.org/plugin/host"
398
+ id: PLUGIN_HOST
237
399
  },
238
400
  provides: {
239
- plugins: state,
240
- context: ({ children }) => /* @__PURE__ */ import_react6.default.createElement(PluginProvider, {
241
- value: state
401
+ plugins: state.values,
402
+ context: ({ children }) => /* @__PURE__ */ import_react4.default.createElement(PluginProvider, {
403
+ value: state.values
242
404
  }, children),
243
405
  root: () => {
244
- (0, import_react6.useEffect)(() => {
406
+ (0, import_react4.useEffect)(() => {
245
407
  (0, import_log.log)("initializing plugins", {
246
- definitions
408
+ enabled: state.values.enabled
247
409
  }, {
248
410
  F: __dxlog_file,
249
- L: 43,
411
+ L: 65,
250
412
  S: void 0,
251
413
  C: (f, a) => f(...a)
252
414
  });
253
415
  const timeout = setTimeout(async () => {
254
- state.initializing = (0, import_react5.shallow)(definitions);
255
- const plugins = await Promise.all(definitions.map(async (definition) => {
416
+ const enabledIds = [
417
+ ...core,
418
+ ...state.values.enabled
419
+ ].sort((a, b) => {
420
+ const indexA = order.findIndex(({ id }) => id === a);
421
+ const indexB = order.findIndex(({ id }) => id === b);
422
+ return indexA - indexB;
423
+ });
424
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
425
+ const plugins = await Promise.all(enabled.map(async (definition) => {
256
426
  const plugin = await initializePlugin(definition).catch((err) => {
257
427
  console.error("Failed to initialize plugin:", definition.meta.id, err);
258
428
  return void 0;
259
429
  });
260
- state.initializing = (0, import_react5.shallow)(state.initializing.filter((plugin2) => plugin2 !== definition));
261
430
  return plugin;
262
431
  })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
263
432
  (0, import_log.log)("plugins initialized", {
264
433
  plugins
265
434
  }, {
266
435
  F: __dxlog_file,
267
- L: 57,
436
+ L: 90,
268
437
  S: void 0,
269
438
  C: (f, a) => f(...a)
270
439
  });
271
- state.loading = (0, import_react5.shallow)(definitions);
272
- await Promise.all(definitions.map(async (pluginDefinition) => {
440
+ await Promise.all(enabled.map(async (pluginDefinition) => {
273
441
  await pluginDefinition.ready?.(plugins);
274
- state.loading = (0, import_react5.shallow)(state.loading.filter((plugin) => plugin !== pluginDefinition));
275
442
  }));
276
443
  (0, import_log.log)("plugins ready", {
277
444
  plugins
278
445
  }, {
279
446
  F: __dxlog_file,
280
- L: 66,
447
+ L: 97,
281
448
  S: void 0,
282
449
  C: (f, a) => f(...a)
283
450
  });
284
- state.plugins = (0, import_react5.shallow)(plugins);
285
- state.ready = true;
451
+ state.values.plugins = (0, import_react3.shallow)(plugins);
452
+ state.values.ready = true;
286
453
  });
287
454
  return () => {
288
455
  clearTimeout(timeout);
289
- state.ready = false;
290
- void Promise.all(definitions.map((definition) => definition.unload?.()));
456
+ state.values.ready = false;
291
457
  };
292
458
  }, []);
293
- if (!state.ready) {
294
- if (typeof fallback === "function") {
295
- const FallbackComponent = fallback;
296
- return /* @__PURE__ */ import_react6.default.createElement(FallbackComponent, {
297
- initializing: state.initializing,
298
- loading: state.loading,
299
- plugins: state.plugins
300
- });
301
- }
302
- return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, fallback ?? null);
459
+ if (!state.values.ready) {
460
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, fallback);
303
461
  }
304
- const ComposedContext = composeContext(state.plugins);
305
- return /* @__PURE__ */ import_react6.default.createElement(ComposedContext, null, rootComponents(state.plugins));
462
+ const ComposedContext = composeContext(state.values.plugins);
463
+ return /* @__PURE__ */ import_react4.default.createElement(ComposedContext, null, rootComponents(state.values.plugins));
306
464
  }
307
465
  }
308
466
  };
@@ -321,7 +479,7 @@ var rootComponents = (plugins) => {
321
479
  return plugins.map((plugin) => {
322
480
  const Component2 = plugin.provides.root;
323
481
  if (Component2) {
324
- return /* @__PURE__ */ import_react6.default.createElement(Component2, {
482
+ return /* @__PURE__ */ import_react4.default.createElement(Component2, {
325
483
  key: plugin.meta.id
326
484
  });
327
485
  } else {
@@ -335,12 +493,15 @@ var composeContext = (plugins) => {
335
493
  var compose = (contexts) => {
336
494
  return [
337
495
  ...contexts
338
- ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react6.default.createElement(Acc, null, /* @__PURE__ */ import_react6.default.createElement(Next, null, children)));
496
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react4.default.createElement(Acc, null, /* @__PURE__ */ import_react4.default.createElement(Next, null, children)));
339
497
  };
340
498
 
499
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/index.ts
500
+ init_provides2();
501
+
341
502
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
342
- var import_react7 = __toESM(require("react"));
343
- var ErrorBoundary = class extends import_react7.Component {
503
+ var import_react5 = __toESM(require("react"));
504
+ var ErrorBoundary = class extends import_react5.Component {
344
505
  constructor(props) {
345
506
  super(props);
346
507
  this.state = {
@@ -359,7 +520,7 @@ var ErrorBoundary = class extends import_react7.Component {
359
520
  }
360
521
  render() {
361
522
  if (this.state.error) {
362
- return /* @__PURE__ */ import_react7.default.createElement(this.props.fallback, {
523
+ return /* @__PURE__ */ import_react5.default.createElement(this.props.fallback, {
363
524
  error: this.state.error,
364
525
  reset: this.resetError
365
526
  });
@@ -374,37 +535,34 @@ var ErrorBoundary = class extends import_react7.Component {
374
535
  };
375
536
 
376
537
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
377
- var import_react9 = __toESM(require("react"));
378
- var import_react10 = require("react");
379
-
380
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
538
+ var import_react7 = __toESM(require("react"));
381
539
  var import_react8 = require("react");
382
- var SurfaceRootContext = /* @__PURE__ */ (0, import_react8.createContext)({
383
- components: {}
384
- });
385
- var useSurface = () => (0, import_react8.useContext)(SurfaceRootContext);
386
- var SurfaceProvider = SurfaceRootContext.Provider;
387
-
388
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
389
- var Surface = ({ role, name = role, fallback, ...rest }) => {
540
+ init_SurfaceRootContext();
541
+ var Surface = /* @__PURE__ */ (0, import_react7.forwardRef)(({ role, name = role, fallback, ...rest }, forwardedRef) => {
390
542
  const props = {
391
543
  role,
392
544
  name,
393
545
  fallback,
394
546
  ...rest
395
547
  };
396
- const context = (0, import_react10.useContext)(SurfaceContext);
548
+ const context = (0, import_react8.useContext)(SurfaceContext);
397
549
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
398
- return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, fallback ? /* @__PURE__ */ import_react9.default.createElement(ErrorBoundary, {
550
+ return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, fallback ? /* @__PURE__ */ import_react7.default.createElement(ErrorBoundary, {
399
551
  data,
400
552
  fallback
401
- }, /* @__PURE__ */ import_react9.default.createElement(SurfaceResolver, props)) : /* @__PURE__ */ import_react9.default.createElement(SurfaceResolver, props));
402
- };
403
- var SurfaceContext = /* @__PURE__ */ (0, import_react10.createContext)(null);
404
- var SurfaceResolver = (props) => {
553
+ }, /* @__PURE__ */ import_react7.default.createElement(SurfaceResolver, {
554
+ ...props,
555
+ ref: forwardedRef
556
+ })) : /* @__PURE__ */ import_react7.default.createElement(SurfaceResolver, {
557
+ ...props,
558
+ ref: forwardedRef
559
+ }));
560
+ });
561
+ var SurfaceContext = /* @__PURE__ */ (0, import_react8.createContext)(null);
562
+ var SurfaceResolver = /* @__PURE__ */ (0, import_react7.forwardRef)((props, forwardedRef) => {
405
563
  const { components } = useSurface();
406
- const parent = (0, import_react10.useContext)(SurfaceContext);
407
- const nodes = resolveNodes(components, props, parent);
564
+ const parent = (0, import_react8.useContext)(SurfaceContext);
565
+ const nodes = resolveNodes(components, props, parent, forwardedRef);
408
566
  const currentContext = {
409
567
  ...props,
410
568
  surfaces: {
@@ -412,71 +570,58 @@ var SurfaceResolver = (props) => {
412
570
  ...props.surfaces
413
571
  }
414
572
  };
415
- return /* @__PURE__ */ import_react9.default.createElement(SurfaceContext.Provider, {
573
+ return /* @__PURE__ */ import_react7.default.createElement(SurfaceContext.Provider, {
416
574
  value: currentContext
417
- }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ import_react9.default.createElement(props.contentFallback, null) : null);
418
- };
419
- var resolveNodes = (components, props, context) => {
575
+ }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ import_react7.default.createElement(props.contentFallback, null) : null);
576
+ });
577
+ var resolveNodes = (components, props, context, forwardedRef) => {
420
578
  const data = {
421
579
  ...props.name && context?.surfaces?.[props.name]?.data || {},
422
580
  ...props.data
423
581
  };
424
582
  const nodes = Object.entries(components).map(([key, component]) => {
425
- const result = component(data, props.role);
426
- return result ? /* @__PURE__ */ import_react9.default.createElement(Wrapper, {
583
+ const result = component({
584
+ ...props,
585
+ data
586
+ }, forwardedRef);
587
+ return result ? /* @__PURE__ */ import_react7.default.createElement(import_react7.Fragment, {
427
588
  key
428
589
  }, result) : void 0;
429
590
  }).filter((Component2) => Boolean(Component2));
430
591
  return props.limit ? nodes.slice(0, props.limit) : nodes;
431
592
  };
432
- var Wrapper = ({ children }) => /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, children);
433
593
 
434
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfacePlugin.tsx
435
- var import_react11 = require("deepsignal/react");
436
- var import_react12 = __toESM(require("react"));
437
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
438
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
439
- var SurfacePlugin = () => {
440
- const state = (0, import_react11.deepSignal)({
441
- components: {}
442
- });
443
- return {
444
- meta: {
445
- id: "dxos.org/plugin/surface"
446
- },
447
- ready: async (plugins) => {
448
- state.components = (0, import_react11.shallow)(filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
449
- return {
450
- ...acc,
451
- [plugin.meta.id]: plugin.provides.surface.component
452
- };
453
- }, {}));
454
- },
455
- provides: {
456
- surface: state,
457
- context: ({ children }) => /* @__PURE__ */ import_react12.default.createElement(SurfaceProvider, {
458
- value: state
459
- }, children)
460
- }
461
- };
462
- };
594
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/index.ts
595
+ init_SurfaceRootContext();
463
596
 
464
597
  // packages/sdk/app-framework/src/App.tsx
465
598
  var import_react13 = __toESM(require("react"));
466
599
  var import_invariant = require("@dxos/invariant");
467
- var __dxlog_file2 = "/home/circleci/project/packages/sdk/app-framework/src/App.tsx";
468
- var createApp = ({ plugins, fallback }) => {
600
+ init_meta();
601
+ init_meta2();
602
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
603
+ var createApp = ({ order, plugins, core = [], ...params }) => {
469
604
  const host = PluginHost({
470
- plugins: [
471
- SurfacePlugin(),
472
- IntentPlugin(),
473
- ...plugins
605
+ order: [
606
+ meta_default2,
607
+ meta_default,
608
+ ...order
474
609
  ],
475
- fallback
610
+ plugins: {
611
+ ...plugins,
612
+ [meta_default2.id]: Plugin.lazy(() => Promise.resolve().then(() => (init_plugin(), plugin_exports))),
613
+ [meta_default.id]: Plugin.lazy(() => Promise.resolve().then(() => (init_plugin2(), plugin_exports2)))
614
+ },
615
+ core: [
616
+ meta_default2.id,
617
+ meta_default.id,
618
+ ...core
619
+ ],
620
+ ...params
476
621
  });
477
622
  (0, import_invariant.invariant)(host.provides?.context, void 0, {
478
623
  F: __dxlog_file2,
479
- L: 33,
624
+ L: 51,
480
625
  S: void 0,
481
626
  A: [
482
627
  "host.provides?.context",
@@ -485,7 +630,7 @@ var createApp = ({ plugins, fallback }) => {
485
630
  });
486
631
  (0, import_invariant.invariant)(host.provides?.root, void 0, {
487
632
  F: __dxlog_file2,
488
- L: 34,
633
+ L: 52,
489
634
  S: void 0,
490
635
  A: [
491
636
  "host.provides?.root",
@@ -499,17 +644,16 @@ var createApp = ({ plugins, fallback }) => {
499
644
  // Annotate the CommonJS export names for ESM import in node:
500
645
  0 && (module.exports = {
501
646
  ErrorBoundary,
502
- IntentPlugin,
503
647
  IntentProvider,
504
648
  Layout,
505
649
  LayoutAction,
650
+ Plugin,
506
651
  PluginHost,
507
652
  PluginProvider,
508
653
  Resource,
509
654
  ResourceKey,
510
655
  ResourceLanguage,
511
656
  Surface,
512
- SurfacePlugin,
513
657
  SurfaceProvider,
514
658
  createApp,
515
659
  filterPlugins,
@@ -527,6 +671,7 @@ var createApp = ({ plugins, fallback }) => {
527
671
  parseRootSurfacePlugin,
528
672
  parseSurfacePlugin,
529
673
  parseTranslationsPlugin,
674
+ pluginMeta,
530
675
  resolvePlugin,
531
676
  useIntent,
532
677
  usePlugin,