@dxos/app-framework 0.6.12-staging.e11e696 → 0.6.13-main.09887cd
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/index.mjs +168 -158
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +168 -162
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +168 -158
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/App.d.ts +4 -4
- package/dist/types/src/App.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts +14 -0
- package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts.map +1 -0
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +4 -4
- package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +4 -8
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/plugin.d.ts +37 -72
- package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/App.tsx +10 -9
- package/src/plugins/PluginHost/PluginContainer.tsx +120 -0
- package/src/plugins/PluginHost/PluginContext.tsx +8 -14
- package/src/plugins/PluginHost/PluginHost.tsx +18 -121
- package/src/plugins/PluginHost/plugin.ts +45 -45
- package/src/plugins/common/navigation.ts +3 -1
- package/tsconfig.json +1 -29
package/dist/lib/node/index.cjs
CHANGED
|
@@ -58,7 +58,6 @@ __export(node_exports, {
|
|
|
58
58
|
firstIdInPart: () => firstIdInPart,
|
|
59
59
|
getPlugin: () => import_chunk_62W6CMGM.getPlugin,
|
|
60
60
|
indexInPart: () => indexInPart,
|
|
61
|
-
initializePlugin: () => initializePlugin,
|
|
62
61
|
isLayoutAdjustment: () => isLayoutAdjustment,
|
|
63
62
|
isLayoutMode: () => isLayoutMode,
|
|
64
63
|
isLayoutParts: () => isLayoutParts,
|
|
@@ -80,7 +79,6 @@ __export(node_exports, {
|
|
|
80
79
|
parseSurfacePlugin: () => import_chunk_P5GRB4XF.parseSurfacePlugin,
|
|
81
80
|
parseTranslationsPlugin: () => parseTranslationsPlugin,
|
|
82
81
|
partLength: () => partLength,
|
|
83
|
-
pluginMeta: () => pluginMeta,
|
|
84
82
|
resolvePlugin: () => import_chunk_62W6CMGM.resolvePlugin,
|
|
85
83
|
useIntent: () => import_chunk_DFST5IG5.useIntent,
|
|
86
84
|
useIntentDispatcher: () => import_chunk_DFST5IG5.useIntentDispatcher,
|
|
@@ -101,15 +99,17 @@ var import_schema = require("@effect/schema");
|
|
|
101
99
|
var import_zod2 = require("zod");
|
|
102
100
|
var import_zod3 = require("zod");
|
|
103
101
|
var import_react = require("react");
|
|
102
|
+
var import_debug = require("@dxos/debug");
|
|
104
103
|
var import_util = require("@dxos/util");
|
|
105
104
|
var import_react2 = __toESM(require("react"));
|
|
106
105
|
var import_local_storage = require("@dxos/local-storage");
|
|
107
|
-
var import_log = require("@dxos/log");
|
|
108
106
|
var import_react3 = __toESM(require("react"));
|
|
107
|
+
var import_log = require("@dxos/log");
|
|
109
108
|
var import_react4 = __toESM(require("react"));
|
|
110
|
-
var import_react5 = require("react");
|
|
111
|
-
var
|
|
112
|
-
var
|
|
109
|
+
var import_react5 = __toESM(require("react"));
|
|
110
|
+
var import_react6 = require("react");
|
|
111
|
+
var import_debug2 = require("@dxos/debug");
|
|
112
|
+
var import_react7 = __toESM(require("react"));
|
|
113
113
|
var import_invariant = require("@dxos/invariant");
|
|
114
114
|
var defaultFileTypes = {
|
|
115
115
|
images: [
|
|
@@ -207,7 +207,10 @@ var LayoutEntrySchema = import_schema.Schema.mutable(import_schema.Schema.Struct
|
|
|
207
207
|
path: import_schema.Schema.optional(import_schema.Schema.String)
|
|
208
208
|
}));
|
|
209
209
|
var LayoutPartSchema = import_schema.Schema.Union(import_schema.Schema.Literal("sidebar"), import_schema.Schema.Literal("main"), import_schema.Schema.Literal("solo"), import_schema.Schema.Literal("complementary"), import_schema.Schema.Literal("fullScreen"));
|
|
210
|
-
var LayoutPartsSchema = import_schema.Schema.partial(import_schema.Schema.mutable(import_schema.Schema.Record(
|
|
210
|
+
var LayoutPartsSchema = import_schema.Schema.partial(import_schema.Schema.mutable(import_schema.Schema.Record({
|
|
211
|
+
key: LayoutPartSchema,
|
|
212
|
+
value: import_schema.Schema.mutable(import_schema.Schema.Array(LayoutEntrySchema))
|
|
213
|
+
})));
|
|
211
214
|
var LayoutCoordinateSchema = import_schema.Schema.mutable(import_schema.Schema.Struct({
|
|
212
215
|
part: LayoutPartSchema,
|
|
213
216
|
entryId: import_schema.Schema.String
|
|
@@ -295,7 +298,6 @@ var parseTranslationsPlugin = (plugin) => {
|
|
|
295
298
|
const { success } = import_zod3.z.array(Resource).safeParse(plugin.provides.translations);
|
|
296
299
|
return success ? plugin : void 0;
|
|
297
300
|
};
|
|
298
|
-
var pluginMeta = (meta) => meta;
|
|
299
301
|
var Plugin;
|
|
300
302
|
(function(Plugin2) {
|
|
301
303
|
Plugin2.lazy = (p, props) => {
|
|
@@ -304,16 +306,8 @@ var Plugin;
|
|
|
304
306
|
});
|
|
305
307
|
};
|
|
306
308
|
})(Plugin || (Plugin = {}));
|
|
307
|
-
var PluginContext = /* @__PURE__ */ (0, import_react.createContext)(
|
|
308
|
-
|
|
309
|
-
core: [],
|
|
310
|
-
enabled: [],
|
|
311
|
-
plugins: [],
|
|
312
|
-
available: [],
|
|
313
|
-
setPlugin: () => {
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
var usePlugins = () => (0, import_react.useContext)(PluginContext);
|
|
309
|
+
var PluginContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
|
|
310
|
+
var usePlugins = () => (0, import_react.useContext)(PluginContext) ?? (0, import_debug.raise)(new Error("Missing PluginContext"));
|
|
317
311
|
var usePlugin = (id) => {
|
|
318
312
|
const { plugins } = usePlugins();
|
|
319
313
|
return (0, import_chunk_62W6CMGM.findPlugin)(plugins, id);
|
|
@@ -330,8 +324,117 @@ var useResolvePlugins = (predicate) => {
|
|
|
330
324
|
]);
|
|
331
325
|
};
|
|
332
326
|
var PluginProvider = PluginContext.Provider;
|
|
327
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx";
|
|
328
|
+
var PluginContainer = ({ plugins: definitions, core, state, placeholder }) => {
|
|
329
|
+
const [error, setError] = (0, import_react3.useState)();
|
|
330
|
+
(0, import_react3.useEffect)(() => {
|
|
331
|
+
(0, import_log.log)("initializing plugins", {
|
|
332
|
+
enabled: state.enabled
|
|
333
|
+
}, {
|
|
334
|
+
F: __dxlog_file,
|
|
335
|
+
L: 26,
|
|
336
|
+
S: void 0,
|
|
337
|
+
C: (f, a) => f(...a)
|
|
338
|
+
});
|
|
339
|
+
const t = setTimeout(async () => {
|
|
340
|
+
try {
|
|
341
|
+
const enabledIds = [
|
|
342
|
+
...core,
|
|
343
|
+
...state.enabled
|
|
344
|
+
];
|
|
345
|
+
const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
|
|
346
|
+
const plugins = await Promise.all(enabled.map(async (definition) => {
|
|
347
|
+
const plugin = await initializePlugin(definition).catch((err) => {
|
|
348
|
+
import_log.log.error("Failed to initialize plugin:", {
|
|
349
|
+
id: definition.meta.id,
|
|
350
|
+
err
|
|
351
|
+
}, {
|
|
352
|
+
F: __dxlog_file,
|
|
353
|
+
L: 41,
|
|
354
|
+
S: void 0,
|
|
355
|
+
C: (f, a) => f(...a)
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
(0, import_log.log)("initialized", {
|
|
359
|
+
plugin: definition.meta.id
|
|
360
|
+
}, {
|
|
361
|
+
F: __dxlog_file,
|
|
362
|
+
L: 44,
|
|
363
|
+
S: void 0,
|
|
364
|
+
C: (f, a) => f(...a)
|
|
365
|
+
});
|
|
366
|
+
return plugin;
|
|
367
|
+
}));
|
|
368
|
+
const initialized = plugins.filter((plugin) => Boolean(plugin));
|
|
369
|
+
(0, import_log.log)("plugins initialized", {
|
|
370
|
+
plugins: initialized
|
|
371
|
+
}, {
|
|
372
|
+
F: __dxlog_file,
|
|
373
|
+
L: 50,
|
|
374
|
+
S: void 0,
|
|
375
|
+
C: (f, a) => f(...a)
|
|
376
|
+
});
|
|
377
|
+
await Promise.all(enabled.map((plugin) => plugin.ready?.(initialized)));
|
|
378
|
+
(0, import_log.log)("plugins ready", {
|
|
379
|
+
plugins: initialized
|
|
380
|
+
}, {
|
|
381
|
+
F: __dxlog_file,
|
|
382
|
+
L: 53,
|
|
383
|
+
S: void 0,
|
|
384
|
+
C: (f, a) => f(...a)
|
|
385
|
+
});
|
|
386
|
+
state.plugins = initialized;
|
|
387
|
+
state.ready = true;
|
|
388
|
+
} catch (err) {
|
|
389
|
+
setError(err);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
return () => {
|
|
393
|
+
clearTimeout(t);
|
|
394
|
+
state.ready = false;
|
|
395
|
+
};
|
|
396
|
+
}, []);
|
|
397
|
+
if (error) {
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
if (!state.ready) {
|
|
401
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, placeholder);
|
|
402
|
+
}
|
|
403
|
+
const ComposedContext = composeContext(state.plugins);
|
|
404
|
+
return /* @__PURE__ */ import_react3.default.createElement(ComposedContext, null, rootComponents(state.plugins));
|
|
405
|
+
};
|
|
406
|
+
var initializePlugin = async (pluginDefinition) => {
|
|
407
|
+
const provides = await pluginDefinition.initialize?.();
|
|
408
|
+
return {
|
|
409
|
+
...pluginDefinition,
|
|
410
|
+
provides: {
|
|
411
|
+
...pluginDefinition.provides,
|
|
412
|
+
...provides
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
var rootComponents = (plugins) => {
|
|
417
|
+
return plugins.map((plugin) => {
|
|
418
|
+
const Component2 = plugin.provides.root;
|
|
419
|
+
if (Component2) {
|
|
420
|
+
return /* @__PURE__ */ import_react3.default.createElement(Component2, {
|
|
421
|
+
key: plugin.meta.id
|
|
422
|
+
});
|
|
423
|
+
} else {
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
}).filter((node) => Boolean(node));
|
|
427
|
+
};
|
|
428
|
+
var composeContext = (plugins) => {
|
|
429
|
+
return compose(plugins.map((p) => p.provides.context).filter(Boolean));
|
|
430
|
+
};
|
|
431
|
+
var compose = (contexts) => {
|
|
432
|
+
return [
|
|
433
|
+
...contexts
|
|
434
|
+
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react3.default.createElement(Acc, null, /* @__PURE__ */ import_react3.default.createElement(Next, null, children)));
|
|
435
|
+
};
|
|
333
436
|
var isObject = (data) => !!data && typeof data === "object";
|
|
334
|
-
var ErrorBoundary = class extends
|
|
437
|
+
var ErrorBoundary = class extends import_react4.Component {
|
|
335
438
|
constructor(props) {
|
|
336
439
|
super(props);
|
|
337
440
|
this.state = {
|
|
@@ -350,7 +453,7 @@ var ErrorBoundary = class extends import_react3.Component {
|
|
|
350
453
|
}
|
|
351
454
|
render() {
|
|
352
455
|
if (this.state.error) {
|
|
353
|
-
return /* @__PURE__ */
|
|
456
|
+
return /* @__PURE__ */ import_react4.default.createElement(this.props.fallback, {
|
|
354
457
|
data: this.props.data,
|
|
355
458
|
error: this.state.error,
|
|
356
459
|
reset: this.resetError
|
|
@@ -364,32 +467,32 @@ var ErrorBoundary = class extends import_react3.Component {
|
|
|
364
467
|
});
|
|
365
468
|
}
|
|
366
469
|
};
|
|
367
|
-
var Surface = /* @__PURE__ */ (0,
|
|
470
|
+
var Surface = /* @__PURE__ */ (0, import_react5.forwardRef)(({ role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
|
|
368
471
|
const props = {
|
|
369
472
|
role,
|
|
370
473
|
name,
|
|
371
474
|
fallback,
|
|
372
475
|
...rest
|
|
373
476
|
};
|
|
374
|
-
const context = (0,
|
|
477
|
+
const context = (0, import_react6.useContext)(SurfaceContext);
|
|
375
478
|
const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
|
|
376
|
-
const resolver = /* @__PURE__ */
|
|
479
|
+
const resolver = /* @__PURE__ */ import_react5.default.createElement(SurfaceResolver, {
|
|
377
480
|
...props,
|
|
378
481
|
ref: forwardedRef
|
|
379
482
|
});
|
|
380
|
-
const suspense = placeholder ? /* @__PURE__ */
|
|
483
|
+
const suspense = placeholder ? /* @__PURE__ */ import_react5.default.createElement(import_react5.Suspense, {
|
|
381
484
|
fallback: placeholder
|
|
382
485
|
}, resolver) : resolver;
|
|
383
|
-
return fallback ? /* @__PURE__ */
|
|
486
|
+
return fallback ? /* @__PURE__ */ import_react5.default.createElement(ErrorBoundary, {
|
|
384
487
|
data,
|
|
385
488
|
fallback
|
|
386
489
|
}, suspense) : suspense;
|
|
387
490
|
});
|
|
388
|
-
var SurfaceContext = /* @__PURE__ */ (0,
|
|
389
|
-
var useSurface = () => (0,
|
|
390
|
-
var SurfaceResolver = /* @__PURE__ */ (0,
|
|
491
|
+
var SurfaceContext = /* @__PURE__ */ (0, import_react6.createContext)(null);
|
|
492
|
+
var useSurface = () => (0, import_react6.useContext)(SurfaceContext) ?? (0, import_debug2.raise)(new Error("Surface context not found"));
|
|
493
|
+
var SurfaceResolver = /* @__PURE__ */ (0, import_react5.forwardRef)((props, forwardedRef) => {
|
|
391
494
|
const { components } = (0, import_chunk_P5GRB4XF.useSurfaceRoot)();
|
|
392
|
-
const parent = (0,
|
|
495
|
+
const parent = (0, import_react6.useContext)(SurfaceContext);
|
|
393
496
|
const nodes = resolveNodes(components, props, parent, forwardedRef);
|
|
394
497
|
const currentContext = {
|
|
395
498
|
...props,
|
|
@@ -398,7 +501,7 @@ var SurfaceResolver = /* @__PURE__ */ (0, import_react4.forwardRef)((props, forw
|
|
|
398
501
|
...props.surfaces
|
|
399
502
|
}
|
|
400
503
|
};
|
|
401
|
-
return /* @__PURE__ */
|
|
504
|
+
return /* @__PURE__ */ import_react5.default.createElement(SurfaceContext.Provider, {
|
|
402
505
|
value: currentContext
|
|
403
506
|
}, nodes);
|
|
404
507
|
});
|
|
@@ -418,7 +521,7 @@ var resolveNodes = (components, props, context, forwardedRef) => {
|
|
|
418
521
|
return "node" in result ? [
|
|
419
522
|
key,
|
|
420
523
|
result
|
|
421
|
-
] : /* @__PURE__ */ (0,
|
|
524
|
+
] : /* @__PURE__ */ (0, import_react5.isValidElement)(result) ? [
|
|
422
525
|
key,
|
|
423
526
|
{
|
|
424
527
|
node: result
|
|
@@ -435,15 +538,14 @@ var resolveNodes = (components, props, context, forwardedRef) => {
|
|
|
435
538
|
return 1;
|
|
436
539
|
}
|
|
437
540
|
return 0;
|
|
438
|
-
}).map(([key, result]) => /* @__PURE__ */
|
|
541
|
+
}).map(([key, result]) => /* @__PURE__ */ import_react5.default.createElement(import_react5.Fragment, {
|
|
439
542
|
key
|
|
440
543
|
}, result.node));
|
|
441
544
|
return props.limit ? nodes.slice(0, props.limit) : nodes;
|
|
442
545
|
};
|
|
443
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
|
|
444
546
|
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
445
547
|
var PLUGIN_HOST = "dxos.org/plugin/host";
|
|
446
|
-
var PluginHost = ({
|
|
548
|
+
var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallback, placeholder = null }) => {
|
|
447
549
|
const state = new import_local_storage.LocalStorageStore(PLUGIN_HOST, {
|
|
448
550
|
ready: false,
|
|
449
551
|
core,
|
|
@@ -451,7 +553,7 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
451
553
|
...defaults
|
|
452
554
|
],
|
|
453
555
|
plugins: [],
|
|
454
|
-
available:
|
|
556
|
+
available: meta.filter(({ id }) => !core.includes(id)),
|
|
455
557
|
setPlugin: (id, enabled) => {
|
|
456
558
|
if (enabled) {
|
|
457
559
|
state.values.enabled.push(id);
|
|
@@ -472,16 +574,17 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
472
574
|
},
|
|
473
575
|
provides: {
|
|
474
576
|
plugins: state.values,
|
|
475
|
-
context: ({ children }) =>
|
|
476
|
-
|
|
477
|
-
|
|
577
|
+
context: ({ children }) => {
|
|
578
|
+
return /* @__PURE__ */ import_react2.default.createElement(PluginProvider, {
|
|
579
|
+
value: state.values
|
|
580
|
+
}, children);
|
|
581
|
+
},
|
|
478
582
|
root: () => {
|
|
479
583
|
return /* @__PURE__ */ import_react2.default.createElement(ErrorBoundary, {
|
|
480
584
|
fallback
|
|
481
|
-
}, /* @__PURE__ */ import_react2.default.createElement(
|
|
482
|
-
|
|
585
|
+
}, /* @__PURE__ */ import_react2.default.createElement(PluginContainer, {
|
|
586
|
+
plugins,
|
|
483
587
|
core,
|
|
484
|
-
definitions,
|
|
485
588
|
state: state.values,
|
|
486
589
|
placeholder
|
|
487
590
|
}));
|
|
@@ -502,123 +605,20 @@ var DefaultFallback = ({ error }) => {
|
|
|
502
605
|
}
|
|
503
606
|
}, error.message), /* @__PURE__ */ import_react2.default.createElement("pre", null, error.stack));
|
|
504
607
|
};
|
|
505
|
-
var Root = ({ order, core: corePluginIds, definitions, state, placeholder }) => {
|
|
506
|
-
const [error, setError] = (0, import_react2.useState)();
|
|
507
|
-
(0, import_react2.useEffect)(() => {
|
|
508
|
-
(0, import_log.log)("initializing plugins", {
|
|
509
|
-
enabled: state.enabled
|
|
510
|
-
}, {
|
|
511
|
-
F: __dxlog_file,
|
|
512
|
-
L: 102,
|
|
513
|
-
S: void 0,
|
|
514
|
-
C: (f, a) => f(...a)
|
|
515
|
-
});
|
|
516
|
-
const timeout = setTimeout(async () => {
|
|
517
|
-
try {
|
|
518
|
-
const enabledIds = [
|
|
519
|
-
...corePluginIds,
|
|
520
|
-
...state.enabled
|
|
521
|
-
].sort((a, b) => {
|
|
522
|
-
const indexA = order.findIndex(({ id }) => id === a);
|
|
523
|
-
const indexB = order.findIndex(({ id }) => id === b);
|
|
524
|
-
return indexA - indexB;
|
|
525
|
-
});
|
|
526
|
-
const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
|
|
527
|
-
const plugins = await Promise.all(enabled.map(async (definition) => {
|
|
528
|
-
const plugin = await initializePlugin(definition).catch((err) => {
|
|
529
|
-
import_log.log.error("Failed to initialize plugin:", {
|
|
530
|
-
id: definition.meta.id,
|
|
531
|
-
err
|
|
532
|
-
}, {
|
|
533
|
-
F: __dxlog_file,
|
|
534
|
-
L: 122,
|
|
535
|
-
S: void 0,
|
|
536
|
-
C: (f, a) => f(...a)
|
|
537
|
-
});
|
|
538
|
-
return void 0;
|
|
539
|
-
});
|
|
540
|
-
return plugin;
|
|
541
|
-
})).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
|
|
542
|
-
(0, import_log.log)("plugins initialized", {
|
|
543
|
-
plugins
|
|
544
|
-
}, {
|
|
545
|
-
F: __dxlog_file,
|
|
546
|
-
L: 128,
|
|
547
|
-
S: void 0,
|
|
548
|
-
C: (f, a) => f(...a)
|
|
549
|
-
});
|
|
550
|
-
await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
|
|
551
|
-
(0, import_log.log)("plugins ready", {
|
|
552
|
-
plugins
|
|
553
|
-
}, {
|
|
554
|
-
F: __dxlog_file,
|
|
555
|
-
L: 131,
|
|
556
|
-
S: void 0,
|
|
557
|
-
C: (f, a) => f(...a)
|
|
558
|
-
});
|
|
559
|
-
state.plugins = plugins;
|
|
560
|
-
state.ready = true;
|
|
561
|
-
} catch (err) {
|
|
562
|
-
setError(err);
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
return () => {
|
|
566
|
-
clearTimeout(timeout);
|
|
567
|
-
state.ready = false;
|
|
568
|
-
};
|
|
569
|
-
}, []);
|
|
570
|
-
if (error) {
|
|
571
|
-
throw error;
|
|
572
|
-
}
|
|
573
|
-
if (!state.ready) {
|
|
574
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, placeholder);
|
|
575
|
-
}
|
|
576
|
-
const ComposedContext = composeContext(state.plugins);
|
|
577
|
-
return /* @__PURE__ */ import_react2.default.createElement(ComposedContext, null, rootComponents(state.plugins));
|
|
578
|
-
};
|
|
579
|
-
var initializePlugin = async (pluginDefinition) => {
|
|
580
|
-
const provides = await pluginDefinition.initialize?.();
|
|
581
|
-
return {
|
|
582
|
-
...pluginDefinition,
|
|
583
|
-
provides: {
|
|
584
|
-
...pluginDefinition.provides,
|
|
585
|
-
...provides
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
var rootComponents = (plugins) => {
|
|
590
|
-
return plugins.map((plugin) => {
|
|
591
|
-
const Component2 = plugin.provides.root;
|
|
592
|
-
if (Component2) {
|
|
593
|
-
return /* @__PURE__ */ import_react2.default.createElement(Component2, {
|
|
594
|
-
key: plugin.meta.id
|
|
595
|
-
});
|
|
596
|
-
} else {
|
|
597
|
-
return null;
|
|
598
|
-
}
|
|
599
|
-
}).filter((node) => Boolean(node));
|
|
600
|
-
};
|
|
601
|
-
var composeContext = (plugins) => {
|
|
602
|
-
return compose(plugins.map((p) => p.provides.context).filter(Boolean));
|
|
603
|
-
};
|
|
604
|
-
var compose = (contexts) => {
|
|
605
|
-
return [
|
|
606
|
-
...contexts
|
|
607
|
-
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ import_react2.default.createElement(Acc, null, /* @__PURE__ */ import_react2.default.createElement(Next, null, children)));
|
|
608
|
-
};
|
|
609
608
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
|
|
610
|
-
var createApp = ({
|
|
609
|
+
var createApp = ({ meta, plugins, core, ...params }) => {
|
|
611
610
|
const host = PluginHost({
|
|
612
|
-
order: [
|
|
613
|
-
import_chunk_P5GRB4XF.meta_default,
|
|
614
|
-
import_chunk_DFST5IG5.meta_default,
|
|
615
|
-
...order
|
|
616
|
-
],
|
|
617
611
|
plugins: {
|
|
618
612
|
...plugins,
|
|
619
613
|
[import_chunk_P5GRB4XF.meta_default.id]: Plugin.lazy(() => import("./plugin-RUJ5PEXB.cjs")),
|
|
620
614
|
[import_chunk_DFST5IG5.meta_default.id]: Plugin.lazy(() => import("./plugin-QV7ESETI.cjs"))
|
|
621
615
|
},
|
|
616
|
+
// TODO(burdon): Why not include in core?
|
|
617
|
+
meta: [
|
|
618
|
+
import_chunk_P5GRB4XF.meta_default,
|
|
619
|
+
import_chunk_DFST5IG5.meta_default,
|
|
620
|
+
...meta
|
|
621
|
+
],
|
|
622
622
|
core: [
|
|
623
623
|
import_chunk_P5GRB4XF.meta_default.id,
|
|
624
624
|
import_chunk_DFST5IG5.meta_default.id,
|
|
@@ -626,27 +626,35 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
626
626
|
],
|
|
627
627
|
...params
|
|
628
628
|
});
|
|
629
|
-
(0, import_invariant.invariant)(host.provides
|
|
629
|
+
(0, import_invariant.invariant)(host.provides, void 0, {
|
|
630
630
|
F: __dxlog_file2,
|
|
631
|
-
L:
|
|
631
|
+
L: 52,
|
|
632
632
|
S: void 0,
|
|
633
633
|
A: [
|
|
634
|
-
"host.provides
|
|
634
|
+
"host.provides",
|
|
635
635
|
""
|
|
636
636
|
]
|
|
637
637
|
});
|
|
638
|
-
|
|
638
|
+
const { context: Context, root: Root } = host.provides;
|
|
639
|
+
(0, import_invariant.invariant)(Context, void 0, {
|
|
639
640
|
F: __dxlog_file2,
|
|
640
|
-
L:
|
|
641
|
+
L: 54,
|
|
642
|
+
S: void 0,
|
|
643
|
+
A: [
|
|
644
|
+
"Context",
|
|
645
|
+
""
|
|
646
|
+
]
|
|
647
|
+
});
|
|
648
|
+
(0, import_invariant.invariant)(Root, void 0, {
|
|
649
|
+
F: __dxlog_file2,
|
|
650
|
+
L: 55,
|
|
641
651
|
S: void 0,
|
|
642
652
|
A: [
|
|
643
|
-
"
|
|
653
|
+
"Root",
|
|
644
654
|
""
|
|
645
655
|
]
|
|
646
656
|
});
|
|
647
|
-
|
|
648
|
-
const Root2 = host.provides.root;
|
|
649
|
-
return () => /* @__PURE__ */ import_react6.default.createElement(Context, null, /* @__PURE__ */ import_react6.default.createElement(Root2, null));
|
|
657
|
+
return () => /* @__PURE__ */ import_react7.default.createElement(Context, null, /* @__PURE__ */ import_react7.default.createElement(Root, null));
|
|
650
658
|
};
|
|
651
659
|
// Annotate the CommonJS export names for ESM import in node:
|
|
652
660
|
0 && (module.exports = {
|
|
@@ -680,7 +688,6 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
680
688
|
firstIdInPart,
|
|
681
689
|
getPlugin,
|
|
682
690
|
indexInPart,
|
|
683
|
-
initializePlugin,
|
|
684
691
|
isLayoutAdjustment,
|
|
685
692
|
isLayoutMode,
|
|
686
693
|
isLayoutParts,
|
|
@@ -702,7 +709,6 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
702
709
|
parseSurfacePlugin,
|
|
703
710
|
parseTranslationsPlugin,
|
|
704
711
|
partLength,
|
|
705
|
-
pluginMeta,
|
|
706
712
|
resolvePlugin,
|
|
707
713
|
useIntent,
|
|
708
714
|
useIntentDispatcher,
|