@dxos/app-framework 0.3.11-main.d7d4c52 → 0.3.11-main.d8f9aa0

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 (33) hide show
  1. package/dist/lib/browser/{chunk-QYIBDGYI.mjs → chunk-7MQ2DVDI.mjs} +2 -3
  2. package/dist/lib/browser/{chunk-QYIBDGYI.mjs.map → chunk-7MQ2DVDI.mjs.map} +2 -2
  3. package/dist/lib/browser/index.mjs +173 -141
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{plugin-YLDDUID4.mjs → plugin-KC4DT4AJ.mjs} +34 -13
  7. package/dist/lib/browser/plugin-KC4DT4AJ.mjs.map +7 -0
  8. package/dist/lib/node/{chunk-YWRBMGDT.cjs → chunk-FETX4EGX.cjs} +5 -6
  9. package/dist/lib/node/{chunk-YWRBMGDT.cjs.map → chunk-FETX4EGX.cjs.map} +2 -2
  10. package/dist/lib/node/index.cjs +169 -139
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/{plugin-NP3IH5Q3.cjs → plugin-RDMDEGRT.cjs} +40 -19
  14. package/dist/lib/node/plugin-RDMDEGRT.cjs.map +7 -0
  15. package/dist/types/src/plugins/IntentPlugin/intent.d.ts +33 -2
  16. package/dist/types/src/plugins/IntentPlugin/intent.d.ts.map +1 -1
  17. package/dist/types/src/plugins/IntentPlugin/plugin.d.ts.map +1 -1
  18. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +4 -2
  19. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
  20. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
  21. package/dist/types/src/plugins/common/layout.d.ts +15 -14
  22. package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
  23. package/package.json +8 -7
  24. package/project.json +3 -1
  25. package/src/plugins/IntentPlugin/IntentContext.tsx +1 -1
  26. package/src/plugins/IntentPlugin/intent.ts +38 -2
  27. package/src/plugins/IntentPlugin/plugin.tsx +34 -9
  28. package/src/plugins/PluginHost/PluginHost.tsx +92 -57
  29. package/src/plugins/PluginHost/plugin.ts +1 -0
  30. package/src/plugins/common/layout.ts +15 -14
  31. package/tsconfig.json +3 -0
  32. package/dist/lib/browser/plugin-YLDDUID4.mjs.map +0 -7
  33. package/dist/lib/node/plugin-NP3IH5Q3.cjs.map +0 -7
@@ -6,8 +6,7 @@ var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? p
6
6
  import { createContext, useContext } from "react";
7
7
  import { useEffect } from "react";
8
8
  var IntentContext = /* @__PURE__ */ createContext({
9
- dispatch: async () => {
10
- },
9
+ dispatch: async () => ({}),
11
10
  registerResolver: () => () => {
12
11
  }
13
12
  });
@@ -42,4 +41,4 @@ export {
42
41
  IntentProvider,
43
42
  meta_default
44
43
  };
45
- //# sourceMappingURL=chunk-QYIBDGYI.mjs.map
44
+ //# sourceMappingURL=chunk-7MQ2DVDI.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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// 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 IntentDispatcher, type IntentResolver } from './intent';\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => {},\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated\n * TODO(burdon): Use useIntentDispatcher.\n */\nexport const useIntent = () => useContext(IntentContext);\n\n// TODO(burdon): Dispatch or Dispatcher?\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": ";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;AACvE,SAASC,iBAAiB;AAW1B,IAAMC,gBAAwCC,8BAA6B;EACzEC,UAAU,YAAA;EAAa;EACvBC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,MAAMC,WAAWL,aAAAA;AAGnC,IAAMM,sBAAsB,MAAA;AACjC,QAAM,EAAEJ,SAAQ,IAAKE,UAAAA;AACrB,SAAOF;AACT;AAEO,IAAMK,oBAAoB,CAACC,QAAgBC,aAAAA;AAChD,QAAM,EAAEN,iBAAgB,IAAKC,UAAAA;AAC7BM,YAAU,MAAA;AACR,WAAOP,iBAAiBK,QAAQC,QAAAA;EAClC,GAAG;IAACD;IAAQC;GAAS;AACvB;AAEO,IAAME,iBAA0CX,cAAcY;;;ACpCrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
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// 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 IntentDispatcher, type IntentResolver } from './intent';\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => ({}),\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated\n * TODO(burdon): Use useIntentDispatcher.\n */\nexport const useIntent = () => useContext(IntentContext);\n\n// TODO(burdon): Dispatch or Dispatcher?\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": ";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;AACvE,SAASC,iBAAiB;AAW1B,IAAMC,gBAAwCC,8BAA6B;EACzEC,UAAU,aAAa,CAAC;EACxBC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,MAAMC,WAAWL,aAAAA;AAGnC,IAAMM,sBAAsB,MAAA;AACjC,QAAM,EAAEJ,SAAQ,IAAKE,UAAAA;AACrB,SAAOF;AACT;AAEO,IAAMK,oBAAoB,CAACC,QAAgBC,aAAAA;AAChD,QAAM,EAAEN,iBAAgB,IAAKC,UAAAA;AAC7BM,YAAU,MAAA;AACR,WAAOP,iBAAiBK,QAAQC,QAAAA;EAClC,GAAG;IAACD;IAAQC;GAAS;AACvB;AAEO,IAAME,iBAA0CX,cAAcY;;;ACpCrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
6
  "names": ["parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "createContext", "useContext", "useEffect", "IntentContext", "createContext", "dispatch", "registerResolver", "useIntent", "useContext", "useIntentDispatcher", "useIntentResolver", "plugin", "resolver", "useEffect", "IntentProvider", "Provider", "IntentMeta", "id"]
7
7
  }
@@ -13,7 +13,7 @@ import {
13
13
  useIntent,
14
14
  useIntentDispatcher,
15
15
  useIntentResolver
16
- } from "./chunk-QYIBDGYI.mjs";
16
+ } from "./chunk-7MQ2DVDI.mjs";
17
17
  import {
18
18
  filterPlugins,
19
19
  findPlugin,
@@ -95,7 +95,7 @@ var parseTranslationsPlugin = (plugin) => {
95
95
  var pluginMeta = (meta) => meta;
96
96
  var Plugin;
97
97
  (function(Plugin2) {
98
- var lazy = Plugin2.lazy = (p, props) => {
98
+ Plugin2.lazy = (p, props) => {
99
99
  return () => p().then(({ default: definition }) => {
100
100
  return definition(props);
101
101
  });
@@ -125,141 +125,15 @@ var PluginProvider = PluginContext.Provider;
125
125
 
126
126
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
127
127
  import { shallow } from "deepsignal/react";
128
- import React, { useEffect } from "react";
128
+ import React3, { useEffect, useState } from "react";
129
129
  import { LocalStorageStore } from "@dxos/local-storage";
130
130
  import { log } from "@dxos/log";
131
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
132
- var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
133
- var PLUGIN_HOST = "dxos.org/plugin/host";
134
- var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = null }) => {
135
- const state = new LocalStorageStore(PLUGIN_HOST, {
136
- ready: false,
137
- enabled: [
138
- ...defaults
139
- ],
140
- plugins: [],
141
- available: order.filter(({ id }) => !core.includes(id)),
142
- setPlugin: (id, enabled) => {
143
- if (enabled) {
144
- state.values.enabled = [
145
- ...state.values.enabled,
146
- id
147
- ];
148
- } else {
149
- state.values.enabled = state.values.enabled.filter((enabled2) => enabled2 !== id);
150
- }
151
- }
152
- });
153
- state.prop(state.values.$enabled, "enabled", LocalStorageStore.json);
154
- return {
155
- meta: {
156
- id: PLUGIN_HOST,
157
- name: "Plugin host"
158
- },
159
- provides: {
160
- plugins: state.values,
161
- context: ({ children }) => /* @__PURE__ */ React.createElement(PluginProvider, {
162
- value: state.values
163
- }, children),
164
- root: () => {
165
- useEffect(() => {
166
- log("initializing plugins", {
167
- enabled: state.values.enabled
168
- }, {
169
- F: __dxlog_file,
170
- L: 67,
171
- S: void 0,
172
- C: (f, a) => f(...a)
173
- });
174
- const timeout = setTimeout(async () => {
175
- const enabledIds = [
176
- ...core,
177
- ...state.values.enabled
178
- ].sort((a, b) => {
179
- const indexA = order.findIndex(({ id }) => id === a);
180
- const indexB = order.findIndex(({ id }) => id === b);
181
- return indexA - indexB;
182
- });
183
- const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
184
- const plugins = await Promise.all(enabled.map(async (definition) => {
185
- const plugin = await initializePlugin(definition).catch((err) => {
186
- console.error("Failed to initialize plugin:", definition.meta.id, err);
187
- return void 0;
188
- });
189
- return plugin;
190
- })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
191
- log("plugins initialized", {
192
- plugins
193
- }, {
194
- F: __dxlog_file,
195
- L: 92,
196
- S: void 0,
197
- C: (f, a) => f(...a)
198
- });
199
- await Promise.all(enabled.map(async (pluginDefinition) => {
200
- await pluginDefinition.ready?.(plugins);
201
- }));
202
- log("plugins ready", {
203
- plugins
204
- }, {
205
- F: __dxlog_file,
206
- L: 99,
207
- S: void 0,
208
- C: (f, a) => f(...a)
209
- });
210
- state.values.plugins = shallow(plugins);
211
- state.values.ready = true;
212
- });
213
- return () => {
214
- clearTimeout(timeout);
215
- state.values.ready = false;
216
- };
217
- }, []);
218
- if (!state.values.ready) {
219
- return /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
220
- }
221
- const ComposedContext = composeContext(state.values.plugins);
222
- return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.values.plugins));
223
- }
224
- }
225
- };
226
- };
227
- var initializePlugin = async (pluginDefinition) => {
228
- const provides = await pluginDefinition.initialize?.();
229
- return {
230
- ...pluginDefinition,
231
- provides: {
232
- ...pluginDefinition.provides,
233
- ...provides
234
- }
235
- };
236
- };
237
- var rootComponents = (plugins) => {
238
- return plugins.map((plugin) => {
239
- const Component2 = plugin.provides.root;
240
- if (Component2) {
241
- return /* @__PURE__ */ React.createElement(Component2, {
242
- key: plugin.meta.id
243
- });
244
- } else {
245
- return null;
246
- }
247
- }).filter((node) => Boolean(node));
248
- };
249
- var composeContext = (plugins) => {
250
- return compose(plugins.map((p) => p.provides.context).filter(Boolean));
251
- };
252
- var compose = (contexts) => {
253
- return [
254
- ...contexts
255
- ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
256
- };
257
131
 
258
132
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
259
133
  var isObject = (data) => !!data && typeof data === "object";
260
134
 
261
135
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
262
- import React2, { Component } from "react";
136
+ import React, { Component } from "react";
263
137
  var ErrorBoundary = class extends Component {
264
138
  constructor(props) {
265
139
  super(props);
@@ -279,7 +153,7 @@ var ErrorBoundary = class extends Component {
279
153
  }
280
154
  render() {
281
155
  if (this.state.error) {
282
- return /* @__PURE__ */ React2.createElement(this.props.fallback, {
156
+ return /* @__PURE__ */ React.createElement(this.props.fallback, {
283
157
  error: this.state.error,
284
158
  reset: this.resetError
285
159
  });
@@ -294,7 +168,7 @@ var ErrorBoundary = class extends Component {
294
168
  };
295
169
 
296
170
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
297
- import React3, { forwardRef, Fragment, isValidElement } from "react";
171
+ import React2, { forwardRef, Fragment, isValidElement } from "react";
298
172
  import { createContext as createContext2, useContext as useContext2 } from "react";
299
173
  var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest }, forwardedRef) => {
300
174
  const props = {
@@ -305,13 +179,13 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest
305
179
  };
306
180
  const context = useContext2(SurfaceContext);
307
181
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
308
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
182
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, fallback ? /* @__PURE__ */ React2.createElement(ErrorBoundary, {
309
183
  data,
310
184
  fallback
311
- }, /* @__PURE__ */ React3.createElement(SurfaceResolver, {
185
+ }, /* @__PURE__ */ React2.createElement(SurfaceResolver, {
312
186
  ...props,
313
187
  ref: forwardedRef
314
- })) : /* @__PURE__ */ React3.createElement(SurfaceResolver, {
188
+ })) : /* @__PURE__ */ React2.createElement(SurfaceResolver, {
315
189
  ...props,
316
190
  ref: forwardedRef
317
191
  }));
@@ -328,9 +202,9 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
328
202
  ...props.surfaces
329
203
  }
330
204
  };
331
- return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
205
+ return /* @__PURE__ */ React2.createElement(SurfaceContext.Provider, {
332
206
  value: currentContext
333
- }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React3.createElement(props.contentFallback, null) : null);
207
+ }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React2.createElement(props.contentFallback, null) : null);
334
208
  });
335
209
  var resolveNodes = (components, props, context, forwardedRef) => {
336
210
  const data = {
@@ -365,12 +239,170 @@ var resolveNodes = (components, props, context, forwardedRef) => {
365
239
  return 1;
366
240
  }
367
241
  return 0;
368
- }).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
242
+ }).map(([key, result]) => /* @__PURE__ */ React2.createElement(Fragment, {
369
243
  key
370
244
  }, result.node));
371
245
  return props.limit ? nodes.slice(0, props.limit) : nodes;
372
246
  };
373
247
 
248
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
249
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
250
+ var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
251
+ var PLUGIN_HOST = "dxos.org/plugin/host";
252
+ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = DefaultFallback, placeholder = null }) => {
253
+ const state = new LocalStorageStore(PLUGIN_HOST, {
254
+ ready: false,
255
+ enabled: [
256
+ ...defaults
257
+ ],
258
+ plugins: [],
259
+ available: order.filter(({ id }) => !core.includes(id)),
260
+ setPlugin: (id, enabled) => {
261
+ if (enabled) {
262
+ state.values.enabled = [
263
+ ...state.values.enabled,
264
+ id
265
+ ];
266
+ } else {
267
+ state.values.enabled = state.values.enabled.filter((enabled2) => enabled2 !== id);
268
+ }
269
+ }
270
+ });
271
+ state.prop(state.values.$enabled, "enabled", LocalStorageStore.json);
272
+ return {
273
+ meta: {
274
+ id: PLUGIN_HOST,
275
+ name: "Plugin host"
276
+ },
277
+ provides: {
278
+ plugins: state.values,
279
+ context: ({ children }) => /* @__PURE__ */ React3.createElement(PluginProvider, {
280
+ value: state.values
281
+ }, children),
282
+ root: () => {
283
+ return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
284
+ fallback
285
+ }, /* @__PURE__ */ React3.createElement(Root, {
286
+ order,
287
+ core,
288
+ definitions,
289
+ state: state.values,
290
+ placeholder
291
+ }));
292
+ }
293
+ }
294
+ };
295
+ };
296
+ var DefaultFallback = ({ error }) => {
297
+ return /* @__PURE__ */ React3.createElement("div", {
298
+ style: {
299
+ padding: "1rem"
300
+ }
301
+ }, /* @__PURE__ */ React3.createElement("h1", {
302
+ style: {
303
+ fontSize: "1.2rem",
304
+ fontWeight: 700,
305
+ margin: "0.5rem 0"
306
+ }
307
+ }, error.message), /* @__PURE__ */ React3.createElement("pre", null, error.stack));
308
+ };
309
+ var Root = ({ order, core: corePluginIds, definitions, state, placeholder }) => {
310
+ const [error, setError] = useState();
311
+ useEffect(() => {
312
+ log("initializing plugins", {
313
+ enabled: state.enabled
314
+ }, {
315
+ F: __dxlog_file,
316
+ L: 101,
317
+ S: void 0,
318
+ C: (f, a) => f(...a)
319
+ });
320
+ const timeout = setTimeout(async () => {
321
+ try {
322
+ const enabledIds = [
323
+ ...corePluginIds,
324
+ ...state.enabled
325
+ ].sort((a, b) => {
326
+ const indexA = order.findIndex(({ id }) => id === a);
327
+ const indexB = order.findIndex(({ id }) => id === b);
328
+ return indexA - indexB;
329
+ });
330
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
331
+ const plugins = await Promise.all(enabled.map(async (definition) => {
332
+ const plugin = await initializePlugin(definition).catch((err) => {
333
+ console.error("Failed to initialize plugin:", definition.meta.id, err);
334
+ return void 0;
335
+ });
336
+ return plugin;
337
+ })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
338
+ log("plugins initialized", {
339
+ plugins
340
+ }, {
341
+ F: __dxlog_file,
342
+ L: 127,
343
+ S: void 0,
344
+ C: (f, a) => f(...a)
345
+ });
346
+ await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
347
+ log("plugins ready", {
348
+ plugins
349
+ }, {
350
+ F: __dxlog_file,
351
+ L: 130,
352
+ S: void 0,
353
+ C: (f, a) => f(...a)
354
+ });
355
+ state.plugins = shallow(plugins);
356
+ state.ready = true;
357
+ } catch (err) {
358
+ setError(err);
359
+ }
360
+ });
361
+ return () => {
362
+ clearTimeout(timeout);
363
+ state.ready = false;
364
+ };
365
+ }, []);
366
+ if (error) {
367
+ throw error;
368
+ }
369
+ if (!state.ready) {
370
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, placeholder);
371
+ }
372
+ const ComposedContext = composeContext(state.plugins);
373
+ return /* @__PURE__ */ React3.createElement(ComposedContext, null, rootComponents(state.plugins));
374
+ };
375
+ var initializePlugin = async (pluginDefinition) => {
376
+ const provides = await pluginDefinition.initialize?.();
377
+ return {
378
+ ...pluginDefinition,
379
+ provides: {
380
+ ...pluginDefinition.provides,
381
+ ...provides
382
+ }
383
+ };
384
+ };
385
+ var rootComponents = (plugins) => {
386
+ return plugins.map((plugin) => {
387
+ const Component2 = plugin.provides.root;
388
+ if (Component2) {
389
+ return /* @__PURE__ */ React3.createElement(Component2, {
390
+ key: plugin.meta.id
391
+ });
392
+ } else {
393
+ return null;
394
+ }
395
+ }).filter((node) => Boolean(node));
396
+ };
397
+ var composeContext = (plugins) => {
398
+ return compose(plugins.map((p) => p.provides.context).filter(Boolean));
399
+ };
400
+ var compose = (contexts) => {
401
+ return [
402
+ ...contexts
403
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React3.createElement(Acc, null, /* @__PURE__ */ React3.createElement(Next, null, children)));
404
+ };
405
+
374
406
  // packages/sdk/app-framework/src/App.tsx
375
407
  import React4 from "react";
376
408
  import { invariant } from "@dxos/invariant";
@@ -385,7 +417,7 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
385
417
  plugins: {
386
418
  ...plugins,
387
419
  [meta_default2.id]: Plugin.lazy(() => import("./plugin-JDIMDLDU.mjs")),
388
- [meta_default.id]: Plugin.lazy(() => import("./plugin-YLDDUID4.mjs"))
420
+ [meta_default.id]: Plugin.lazy(() => import("./plugin-KC4DT4AJ.mjs"))
389
421
  },
390
422
  core: [
391
423
  meta_default2.id,
@@ -413,8 +445,8 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
413
445
  ]
414
446
  });
415
447
  const Context = host.provides.context;
416
- const Root = host.provides.root;
417
- return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root, null));
448
+ const Root2 = host.provides.root;
449
+ return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root2, null));
418
450
  };
419
451
  export {
420
452
  ErrorBoundary,