@dxos/app-framework 0.6.12 → 0.6.13-main.548ca8d
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 +169 -163
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +183 -182
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/chunk-ERPIGFBI.mjs +28 -0
- package/dist/lib/node-esm/chunk-ERPIGFBI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IY7HCP4K.mjs +22 -0
- package/dist/lib/node-esm/chunk-IY7HCP4K.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-P2TQLXZR.mjs +54 -0
- package/dist/lib/node-esm/chunk-P2TQLXZR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +683 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/plugin-24ZP3LDU.mjs +40 -0
- package/dist/lib/node-esm/plugin-24ZP3LDU.mjs.map +7 -0
- package/dist/lib/node-esm/plugin-5AAUGDB3.mjs +168 -0
- package/dist/lib/node-esm/plugin-5AAUGDB3.mjs.map +7 -0
- 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 -83
- package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +1 -1
- package/dist/types/src/plugins/common/navigation.d.ts +1 -12
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/package.json +14 -11
- package/project.json +3 -8
- 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.test.ts +1 -2
- package/src/plugins/PluginHost/plugin.ts +45 -52
- package/src/plugins/common/navigation.ts +4 -12
- package/tsconfig.json +1 -29
- package/vitest.config.ts +9 -0
|
@@ -119,8 +119,8 @@ var parseMetadataResolverPlugin = (plugin) => {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
// packages/sdk/app-framework/src/plugins/common/navigation.ts
|
|
122
|
+
import { Schema as S } from "@effect/schema";
|
|
122
123
|
import { z as z2 } from "zod";
|
|
123
|
-
import { S } from "@dxos/echo-schema";
|
|
124
124
|
var SLUG_LIST_SEPARATOR = "+";
|
|
125
125
|
var SLUG_ENTRY_SEPARATOR = "_";
|
|
126
126
|
var SLUG_KEY_VALUE_SEPARATOR = "-";
|
|
@@ -131,7 +131,10 @@ var LayoutEntrySchema = S.mutable(S.Struct({
|
|
|
131
131
|
path: S.optional(S.String)
|
|
132
132
|
}));
|
|
133
133
|
var LayoutPartSchema = S.Union(S.Literal("sidebar"), S.Literal("main"), S.Literal("solo"), S.Literal("complementary"), S.Literal("fullScreen"));
|
|
134
|
-
var LayoutPartsSchema = S.partial(S.mutable(S.Record(
|
|
134
|
+
var LayoutPartsSchema = S.partial(S.mutable(S.Record({
|
|
135
|
+
key: LayoutPartSchema,
|
|
136
|
+
value: S.mutable(S.Array(LayoutEntrySchema))
|
|
137
|
+
})));
|
|
135
138
|
var LayoutCoordinateSchema = S.mutable(S.Struct({
|
|
136
139
|
part: LayoutPartSchema,
|
|
137
140
|
entryId: S.String
|
|
@@ -145,9 +148,6 @@ var ActiveParts = z2.record(z2.string(), z2.union([
|
|
|
145
148
|
z2.string(),
|
|
146
149
|
z2.array(z2.string())
|
|
147
150
|
]));
|
|
148
|
-
var Attention = z2.object({
|
|
149
|
-
attended: z2.set(z2.string()).optional().describe("Ids of items which have focus.")
|
|
150
|
-
});
|
|
151
151
|
var LocationProvidesSchema = S.mutable(S.Struct({
|
|
152
152
|
location: S.Struct({
|
|
153
153
|
active: LayoutPartsSchema,
|
|
@@ -229,7 +229,6 @@ var parseTranslationsPlugin = (plugin) => {
|
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
// packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
|
|
232
|
-
var pluginMeta = (meta) => meta;
|
|
233
232
|
var Plugin;
|
|
234
233
|
(function(Plugin2) {
|
|
235
234
|
Plugin2.lazy = (p, props) => {
|
|
@@ -241,17 +240,10 @@ var Plugin;
|
|
|
241
240
|
|
|
242
241
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
|
|
243
242
|
import { createContext, useContext, useMemo } from "react";
|
|
243
|
+
import { raise } from "@dxos/debug";
|
|
244
244
|
import { nonNullable } from "@dxos/util";
|
|
245
|
-
var PluginContext = /* @__PURE__ */ createContext(
|
|
246
|
-
|
|
247
|
-
core: [],
|
|
248
|
-
enabled: [],
|
|
249
|
-
plugins: [],
|
|
250
|
-
available: [],
|
|
251
|
-
setPlugin: () => {
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
var usePlugins = () => useContext(PluginContext);
|
|
245
|
+
var PluginContext = /* @__PURE__ */ createContext(void 0);
|
|
246
|
+
var usePlugins = () => useContext(PluginContext) ?? raise(new Error("Missing PluginContext"));
|
|
255
247
|
var usePlugin = (id) => {
|
|
256
248
|
const { plugins } = usePlugins();
|
|
257
249
|
return findPlugin(plugins, id);
|
|
@@ -270,15 +262,127 @@ var useResolvePlugins = (predicate) => {
|
|
|
270
262
|
var PluginProvider = PluginContext.Provider;
|
|
271
263
|
|
|
272
264
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
|
|
273
|
-
import
|
|
265
|
+
import React4 from "react";
|
|
274
266
|
import { LocalStorageStore } from "@dxos/local-storage";
|
|
267
|
+
|
|
268
|
+
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx
|
|
269
|
+
import React, { useEffect, useState } from "react";
|
|
275
270
|
import { log } from "@dxos/log";
|
|
271
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx";
|
|
272
|
+
var PluginContainer = ({ plugins: definitions, core, state, placeholder }) => {
|
|
273
|
+
const [error, setError] = useState();
|
|
274
|
+
useEffect(() => {
|
|
275
|
+
log("initializing plugins", {
|
|
276
|
+
enabled: state.enabled
|
|
277
|
+
}, {
|
|
278
|
+
F: __dxlog_file,
|
|
279
|
+
L: 26,
|
|
280
|
+
S: void 0,
|
|
281
|
+
C: (f, a) => f(...a)
|
|
282
|
+
});
|
|
283
|
+
const t = setTimeout(async () => {
|
|
284
|
+
try {
|
|
285
|
+
const enabledIds = [
|
|
286
|
+
...core,
|
|
287
|
+
...state.enabled
|
|
288
|
+
];
|
|
289
|
+
const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
|
|
290
|
+
const plugins = await Promise.all(enabled.map(async (definition) => {
|
|
291
|
+
const plugin = await initializePlugin(definition).catch((err) => {
|
|
292
|
+
log.error("Failed to initialize plugin:", {
|
|
293
|
+
id: definition.meta.id,
|
|
294
|
+
err
|
|
295
|
+
}, {
|
|
296
|
+
F: __dxlog_file,
|
|
297
|
+
L: 41,
|
|
298
|
+
S: void 0,
|
|
299
|
+
C: (f, a) => f(...a)
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
log("initialized", {
|
|
303
|
+
plugin: definition.meta.id
|
|
304
|
+
}, {
|
|
305
|
+
F: __dxlog_file,
|
|
306
|
+
L: 44,
|
|
307
|
+
S: void 0,
|
|
308
|
+
C: (f, a) => f(...a)
|
|
309
|
+
});
|
|
310
|
+
return plugin;
|
|
311
|
+
}));
|
|
312
|
+
const initialized = plugins.filter((plugin) => Boolean(plugin));
|
|
313
|
+
log("plugins initialized", {
|
|
314
|
+
plugins: initialized
|
|
315
|
+
}, {
|
|
316
|
+
F: __dxlog_file,
|
|
317
|
+
L: 50,
|
|
318
|
+
S: void 0,
|
|
319
|
+
C: (f, a) => f(...a)
|
|
320
|
+
});
|
|
321
|
+
await Promise.all(enabled.map((plugin) => plugin.ready?.(initialized)));
|
|
322
|
+
log("plugins ready", {
|
|
323
|
+
plugins: initialized
|
|
324
|
+
}, {
|
|
325
|
+
F: __dxlog_file,
|
|
326
|
+
L: 53,
|
|
327
|
+
S: void 0,
|
|
328
|
+
C: (f, a) => f(...a)
|
|
329
|
+
});
|
|
330
|
+
state.plugins = initialized;
|
|
331
|
+
state.ready = true;
|
|
332
|
+
} catch (err) {
|
|
333
|
+
setError(err);
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
return () => {
|
|
337
|
+
clearTimeout(t);
|
|
338
|
+
state.ready = false;
|
|
339
|
+
};
|
|
340
|
+
}, []);
|
|
341
|
+
if (error) {
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
if (!state.ready) {
|
|
345
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, placeholder);
|
|
346
|
+
}
|
|
347
|
+
const ComposedContext = composeContext(state.plugins);
|
|
348
|
+
return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.plugins));
|
|
349
|
+
};
|
|
350
|
+
var initializePlugin = async (pluginDefinition) => {
|
|
351
|
+
const provides = await pluginDefinition.initialize?.();
|
|
352
|
+
return {
|
|
353
|
+
...pluginDefinition,
|
|
354
|
+
provides: {
|
|
355
|
+
...pluginDefinition.provides,
|
|
356
|
+
...provides
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
var rootComponents = (plugins) => {
|
|
361
|
+
return plugins.map((plugin) => {
|
|
362
|
+
const Component2 = plugin.provides.root;
|
|
363
|
+
if (Component2) {
|
|
364
|
+
return /* @__PURE__ */ React.createElement(Component2, {
|
|
365
|
+
key: plugin.meta.id
|
|
366
|
+
});
|
|
367
|
+
} else {
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
}).filter((node) => Boolean(node));
|
|
371
|
+
};
|
|
372
|
+
var composeContext = (plugins) => {
|
|
373
|
+
return compose(plugins.map((p) => p.provides.context).filter(Boolean));
|
|
374
|
+
};
|
|
375
|
+
var compose = (contexts) => {
|
|
376
|
+
return [
|
|
377
|
+
...contexts
|
|
378
|
+
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
|
|
379
|
+
};
|
|
276
380
|
|
|
277
381
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
|
|
278
382
|
var isObject = (data) => !!data && typeof data === "object";
|
|
279
383
|
|
|
280
384
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
|
|
281
|
-
import
|
|
385
|
+
import React2, { Component } from "react";
|
|
282
386
|
var ErrorBoundary = class extends Component {
|
|
283
387
|
constructor(props) {
|
|
284
388
|
super(props);
|
|
@@ -298,7 +402,7 @@ var ErrorBoundary = class extends Component {
|
|
|
298
402
|
}
|
|
299
403
|
render() {
|
|
300
404
|
if (this.state.error) {
|
|
301
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React2.createElement(this.props.fallback, {
|
|
302
406
|
data: this.props.data,
|
|
303
407
|
error: this.state.error,
|
|
304
408
|
reset: this.resetError
|
|
@@ -314,9 +418,9 @@ var ErrorBoundary = class extends Component {
|
|
|
314
418
|
};
|
|
315
419
|
|
|
316
420
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
|
|
317
|
-
import
|
|
421
|
+
import React3, { forwardRef, Fragment, isValidElement, Suspense } from "react";
|
|
318
422
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
319
|
-
import { raise } from "@dxos/debug";
|
|
423
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
320
424
|
var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
|
|
321
425
|
const props = {
|
|
322
426
|
role,
|
|
@@ -326,20 +430,20 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeho
|
|
|
326
430
|
};
|
|
327
431
|
const context = useContext2(SurfaceContext);
|
|
328
432
|
const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
|
|
329
|
-
const resolver = /* @__PURE__ */
|
|
433
|
+
const resolver = /* @__PURE__ */ React3.createElement(SurfaceResolver, {
|
|
330
434
|
...props,
|
|
331
435
|
ref: forwardedRef
|
|
332
436
|
});
|
|
333
|
-
const suspense = placeholder ? /* @__PURE__ */
|
|
437
|
+
const suspense = placeholder ? /* @__PURE__ */ React3.createElement(Suspense, {
|
|
334
438
|
fallback: placeholder
|
|
335
439
|
}, resolver) : resolver;
|
|
336
|
-
return fallback ? /* @__PURE__ */
|
|
440
|
+
return fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
337
441
|
data,
|
|
338
442
|
fallback
|
|
339
443
|
}, suspense) : suspense;
|
|
340
444
|
});
|
|
341
445
|
var SurfaceContext = /* @__PURE__ */ createContext2(null);
|
|
342
|
-
var useSurface = () => useContext2(SurfaceContext) ??
|
|
446
|
+
var useSurface = () => useContext2(SurfaceContext) ?? raise2(new Error("Surface context not found"));
|
|
343
447
|
var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
344
448
|
const { components } = useSurfaceRoot();
|
|
345
449
|
const parent = useContext2(SurfaceContext);
|
|
@@ -351,7 +455,7 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
|
351
455
|
...props.surfaces
|
|
352
456
|
}
|
|
353
457
|
};
|
|
354
|
-
return /* @__PURE__ */
|
|
458
|
+
return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
|
|
355
459
|
value: currentContext
|
|
356
460
|
}, nodes);
|
|
357
461
|
});
|
|
@@ -388,17 +492,16 @@ var resolveNodes = (components, props, context, forwardedRef) => {
|
|
|
388
492
|
return 1;
|
|
389
493
|
}
|
|
390
494
|
return 0;
|
|
391
|
-
}).map(([key, result]) => /* @__PURE__ */
|
|
495
|
+
}).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
|
|
392
496
|
key
|
|
393
497
|
}, result.node));
|
|
394
498
|
return props.limit ? nodes.slice(0, props.limit) : nodes;
|
|
395
499
|
};
|
|
396
500
|
|
|
397
501
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
|
|
398
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
|
|
399
502
|
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
400
503
|
var PLUGIN_HOST = "dxos.org/plugin/host";
|
|
401
|
-
var PluginHost = ({
|
|
504
|
+
var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallback, placeholder = null }) => {
|
|
402
505
|
const state = new LocalStorageStore(PLUGIN_HOST, {
|
|
403
506
|
ready: false,
|
|
404
507
|
core,
|
|
@@ -406,7 +509,7 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
406
509
|
...defaults
|
|
407
510
|
],
|
|
408
511
|
plugins: [],
|
|
409
|
-
available:
|
|
512
|
+
available: meta.filter(({ id }) => !core.includes(id)),
|
|
410
513
|
setPlugin: (id, enabled) => {
|
|
411
514
|
if (enabled) {
|
|
412
515
|
state.values.enabled.push(id);
|
|
@@ -427,16 +530,17 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
427
530
|
},
|
|
428
531
|
provides: {
|
|
429
532
|
plugins: state.values,
|
|
430
|
-
context: ({ children }) =>
|
|
431
|
-
|
|
432
|
-
|
|
533
|
+
context: ({ children }) => {
|
|
534
|
+
return /* @__PURE__ */ React4.createElement(PluginProvider, {
|
|
535
|
+
value: state.values
|
|
536
|
+
}, children);
|
|
537
|
+
},
|
|
433
538
|
root: () => {
|
|
434
|
-
return /* @__PURE__ */
|
|
539
|
+
return /* @__PURE__ */ React4.createElement(ErrorBoundary, {
|
|
435
540
|
fallback
|
|
436
|
-
}, /* @__PURE__ */
|
|
437
|
-
|
|
541
|
+
}, /* @__PURE__ */ React4.createElement(PluginContainer, {
|
|
542
|
+
plugins,
|
|
438
543
|
core,
|
|
439
|
-
definitions,
|
|
440
544
|
state: state.values,
|
|
441
545
|
placeholder
|
|
442
546
|
}));
|
|
@@ -445,139 +549,36 @@ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallb
|
|
|
445
549
|
};
|
|
446
550
|
};
|
|
447
551
|
var DefaultFallback = ({ error }) => {
|
|
448
|
-
return /* @__PURE__ */
|
|
552
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
449
553
|
style: {
|
|
450
554
|
padding: "1rem"
|
|
451
555
|
}
|
|
452
|
-
}, /* @__PURE__ */
|
|
556
|
+
}, /* @__PURE__ */ React4.createElement("h1", {
|
|
453
557
|
style: {
|
|
454
558
|
fontSize: "1.2rem",
|
|
455
559
|
fontWeight: 700,
|
|
456
560
|
margin: "0.5rem 0"
|
|
457
561
|
}
|
|
458
|
-
}, error.message), /* @__PURE__ */
|
|
459
|
-
};
|
|
460
|
-
var Root = ({ order, core: corePluginIds, definitions, state, placeholder }) => {
|
|
461
|
-
const [error, setError] = useState();
|
|
462
|
-
useEffect(() => {
|
|
463
|
-
log("initializing plugins", {
|
|
464
|
-
enabled: state.enabled
|
|
465
|
-
}, {
|
|
466
|
-
F: __dxlog_file,
|
|
467
|
-
L: 102,
|
|
468
|
-
S: void 0,
|
|
469
|
-
C: (f, a) => f(...a)
|
|
470
|
-
});
|
|
471
|
-
const timeout = setTimeout(async () => {
|
|
472
|
-
try {
|
|
473
|
-
const enabledIds = [
|
|
474
|
-
...corePluginIds,
|
|
475
|
-
...state.enabled
|
|
476
|
-
].sort((a, b) => {
|
|
477
|
-
const indexA = order.findIndex(({ id }) => id === a);
|
|
478
|
-
const indexB = order.findIndex(({ id }) => id === b);
|
|
479
|
-
return indexA - indexB;
|
|
480
|
-
});
|
|
481
|
-
const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
|
|
482
|
-
const plugins = await Promise.all(enabled.map(async (definition) => {
|
|
483
|
-
const plugin = await initializePlugin(definition).catch((err) => {
|
|
484
|
-
log.error("Failed to initialize plugin:", {
|
|
485
|
-
id: definition.meta.id,
|
|
486
|
-
err
|
|
487
|
-
}, {
|
|
488
|
-
F: __dxlog_file,
|
|
489
|
-
L: 122,
|
|
490
|
-
S: void 0,
|
|
491
|
-
C: (f, a) => f(...a)
|
|
492
|
-
});
|
|
493
|
-
return void 0;
|
|
494
|
-
});
|
|
495
|
-
return plugin;
|
|
496
|
-
})).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
|
|
497
|
-
log("plugins initialized", {
|
|
498
|
-
plugins
|
|
499
|
-
}, {
|
|
500
|
-
F: __dxlog_file,
|
|
501
|
-
L: 128,
|
|
502
|
-
S: void 0,
|
|
503
|
-
C: (f, a) => f(...a)
|
|
504
|
-
});
|
|
505
|
-
await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
|
|
506
|
-
log("plugins ready", {
|
|
507
|
-
plugins
|
|
508
|
-
}, {
|
|
509
|
-
F: __dxlog_file,
|
|
510
|
-
L: 131,
|
|
511
|
-
S: void 0,
|
|
512
|
-
C: (f, a) => f(...a)
|
|
513
|
-
});
|
|
514
|
-
state.plugins = plugins;
|
|
515
|
-
state.ready = true;
|
|
516
|
-
} catch (err) {
|
|
517
|
-
setError(err);
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
return () => {
|
|
521
|
-
clearTimeout(timeout);
|
|
522
|
-
state.ready = false;
|
|
523
|
-
};
|
|
524
|
-
}, []);
|
|
525
|
-
if (error) {
|
|
526
|
-
throw error;
|
|
527
|
-
}
|
|
528
|
-
if (!state.ready) {
|
|
529
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, placeholder);
|
|
530
|
-
}
|
|
531
|
-
const ComposedContext = composeContext(state.plugins);
|
|
532
|
-
return /* @__PURE__ */ React3.createElement(ComposedContext, null, rootComponents(state.plugins));
|
|
533
|
-
};
|
|
534
|
-
var initializePlugin = async (pluginDefinition) => {
|
|
535
|
-
const provides = await pluginDefinition.initialize?.();
|
|
536
|
-
return {
|
|
537
|
-
...pluginDefinition,
|
|
538
|
-
provides: {
|
|
539
|
-
...pluginDefinition.provides,
|
|
540
|
-
...provides
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
};
|
|
544
|
-
var rootComponents = (plugins) => {
|
|
545
|
-
return plugins.map((plugin) => {
|
|
546
|
-
const Component2 = plugin.provides.root;
|
|
547
|
-
if (Component2) {
|
|
548
|
-
return /* @__PURE__ */ React3.createElement(Component2, {
|
|
549
|
-
key: plugin.meta.id
|
|
550
|
-
});
|
|
551
|
-
} else {
|
|
552
|
-
return null;
|
|
553
|
-
}
|
|
554
|
-
}).filter((node) => Boolean(node));
|
|
555
|
-
};
|
|
556
|
-
var composeContext = (plugins) => {
|
|
557
|
-
return compose(plugins.map((p) => p.provides.context).filter(Boolean));
|
|
558
|
-
};
|
|
559
|
-
var compose = (contexts) => {
|
|
560
|
-
return [
|
|
561
|
-
...contexts
|
|
562
|
-
].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React3.createElement(Acc, null, /* @__PURE__ */ React3.createElement(Next, null, children)));
|
|
562
|
+
}, error.message), /* @__PURE__ */ React4.createElement("pre", null, error.stack));
|
|
563
563
|
};
|
|
564
564
|
|
|
565
565
|
// packages/sdk/app-framework/src/App.tsx
|
|
566
|
-
import
|
|
566
|
+
import React5 from "react";
|
|
567
567
|
import { invariant } from "@dxos/invariant";
|
|
568
568
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
|
|
569
|
-
var createApp = ({
|
|
569
|
+
var createApp = ({ meta, plugins, core, ...params }) => {
|
|
570
570
|
const host = PluginHost({
|
|
571
|
-
order: [
|
|
572
|
-
meta_default2,
|
|
573
|
-
meta_default,
|
|
574
|
-
...order
|
|
575
|
-
],
|
|
576
571
|
plugins: {
|
|
577
572
|
...plugins,
|
|
578
573
|
[meta_default2.id]: Plugin.lazy(() => import("./plugin-K3KCPCTJ.mjs")),
|
|
579
574
|
[meta_default.id]: Plugin.lazy(() => import("./plugin-MM66VRCO.mjs"))
|
|
580
575
|
},
|
|
576
|
+
// TODO(burdon): Why not include in core?
|
|
577
|
+
meta: [
|
|
578
|
+
meta_default2,
|
|
579
|
+
meta_default,
|
|
580
|
+
...meta
|
|
581
|
+
],
|
|
581
582
|
core: [
|
|
582
583
|
meta_default2.id,
|
|
583
584
|
meta_default.id,
|
|
@@ -585,31 +586,38 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
|
|
|
585
586
|
],
|
|
586
587
|
...params
|
|
587
588
|
});
|
|
588
|
-
invariant(host.provides
|
|
589
|
+
invariant(host.provides, void 0, {
|
|
589
590
|
F: __dxlog_file2,
|
|
590
|
-
L:
|
|
591
|
+
L: 52,
|
|
591
592
|
S: void 0,
|
|
592
593
|
A: [
|
|
593
|
-
"host.provides
|
|
594
|
+
"host.provides",
|
|
594
595
|
""
|
|
595
596
|
]
|
|
596
597
|
});
|
|
597
|
-
|
|
598
|
+
const { context: Context, root: Root } = host.provides;
|
|
599
|
+
invariant(Context, void 0, {
|
|
598
600
|
F: __dxlog_file2,
|
|
599
|
-
L:
|
|
601
|
+
L: 54,
|
|
602
|
+
S: void 0,
|
|
603
|
+
A: [
|
|
604
|
+
"Context",
|
|
605
|
+
""
|
|
606
|
+
]
|
|
607
|
+
});
|
|
608
|
+
invariant(Root, void 0, {
|
|
609
|
+
F: __dxlog_file2,
|
|
610
|
+
L: 55,
|
|
600
611
|
S: void 0,
|
|
601
612
|
A: [
|
|
602
|
-
"
|
|
613
|
+
"Root",
|
|
603
614
|
""
|
|
604
615
|
]
|
|
605
616
|
});
|
|
606
|
-
|
|
607
|
-
const Root2 = host.provides.root;
|
|
608
|
-
return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root2, null));
|
|
617
|
+
return () => /* @__PURE__ */ React5.createElement(Context, null, /* @__PURE__ */ React5.createElement(Root, null));
|
|
609
618
|
};
|
|
610
619
|
export {
|
|
611
620
|
ActiveParts,
|
|
612
|
-
Attention,
|
|
613
621
|
ErrorBoundary,
|
|
614
622
|
IntentAction,
|
|
615
623
|
IntentProvider,
|
|
@@ -639,7 +647,6 @@ export {
|
|
|
639
647
|
firstIdInPart,
|
|
640
648
|
getPlugin,
|
|
641
649
|
indexInPart,
|
|
642
|
-
initializePlugin,
|
|
643
650
|
isLayoutAdjustment,
|
|
644
651
|
isLayoutMode,
|
|
645
652
|
isLayoutParts,
|
|
@@ -661,7 +668,6 @@ export {
|
|
|
661
668
|
parseSurfacePlugin,
|
|
662
669
|
parseTranslationsPlugin,
|
|
663
670
|
partLength,
|
|
664
|
-
pluginMeta,
|
|
665
671
|
resolvePlugin,
|
|
666
672
|
useIntent,
|
|
667
673
|
useIntentDispatcher,
|