@dxos/app-framework 0.6.13-main.ed424a1 → 0.6.13
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 +163 -169
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +182 -183
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/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/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 +8 -4
- package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
- package/dist/types/src/plugins/PluginHost/plugin.d.ts +83 -37
- 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 +12 -1
- package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
- package/package.json +11 -14
- package/project.json +8 -3
- package/src/App.tsx +9 -10
- package/src/plugins/PluginHost/PluginContext.tsx +14 -8
- package/src/plugins/PluginHost/PluginHost.tsx +121 -18
- package/src/plugins/PluginHost/plugin.test.ts +2 -1
- package/src/plugins/PluginHost/plugin.ts +52 -45
- package/src/plugins/common/navigation.ts +12 -4
- package/tsconfig.json +29 -1
- package/dist/lib/node-esm/chunk-ERPIGFBI.mjs +0 -28
- package/dist/lib/node-esm/chunk-ERPIGFBI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IY7HCP4K.mjs +0 -22
- package/dist/lib/node-esm/chunk-IY7HCP4K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-P2TQLXZR.mjs +0 -54
- package/dist/lib/node-esm/chunk-P2TQLXZR.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -683
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/plugin-24ZP3LDU.mjs +0 -40
- package/dist/lib/node-esm/plugin-24ZP3LDU.mjs.map +0 -7
- package/dist/lib/node-esm/plugin-5AAUGDB3.mjs +0 -168
- package/dist/lib/node-esm/plugin-5AAUGDB3.mjs.map +0 -7
- package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts +0 -14
- package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts.map +0 -1
- package/src/plugins/PluginHost/PluginContainer.tsx +0 -120
- package/vitest.config.ts +0 -9
|
@@ -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";
|
|
123
122
|
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,10 +131,7 @@ 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(
|
|
135
|
-
key: LayoutPartSchema,
|
|
136
|
-
value: S.mutable(S.Array(LayoutEntrySchema))
|
|
137
|
-
})));
|
|
134
|
+
var LayoutPartsSchema = S.partial(S.mutable(S.Record(LayoutPartSchema, S.mutable(S.Array(LayoutEntrySchema)))));
|
|
138
135
|
var LayoutCoordinateSchema = S.mutable(S.Struct({
|
|
139
136
|
part: LayoutPartSchema,
|
|
140
137
|
entryId: S.String
|
|
@@ -148,6 +145,9 @@ var ActiveParts = z2.record(z2.string(), z2.union([
|
|
|
148
145
|
z2.string(),
|
|
149
146
|
z2.array(z2.string())
|
|
150
147
|
]));
|
|
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,6 +229,7 @@ var parseTranslationsPlugin = (plugin) => {
|
|
|
229
229
|
};
|
|
230
230
|
|
|
231
231
|
// packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
|
|
232
|
+
var pluginMeta = (meta) => meta;
|
|
232
233
|
var Plugin;
|
|
233
234
|
(function(Plugin2) {
|
|
234
235
|
Plugin2.lazy = (p, props) => {
|
|
@@ -240,10 +241,17 @@ var Plugin;
|
|
|
240
241
|
|
|
241
242
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
|
|
242
243
|
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
|
-
|
|
245
|
+
var PluginContext = /* @__PURE__ */ createContext({
|
|
246
|
+
ready: false,
|
|
247
|
+
core: [],
|
|
248
|
+
enabled: [],
|
|
249
|
+
plugins: [],
|
|
250
|
+
available: [],
|
|
251
|
+
setPlugin: () => {
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
var usePlugins = () => useContext(PluginContext);
|
|
247
255
|
var usePlugin = (id) => {
|
|
248
256
|
const { plugins } = usePlugins();
|
|
249
257
|
return findPlugin(plugins, id);
|
|
@@ -262,127 +270,15 @@ var useResolvePlugins = (predicate) => {
|
|
|
262
270
|
var PluginProvider = PluginContext.Provider;
|
|
263
271
|
|
|
264
272
|
// packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
|
|
265
|
-
import
|
|
273
|
+
import React3, { useEffect, useState } from "react";
|
|
266
274
|
import { LocalStorageStore } from "@dxos/local-storage";
|
|
267
|
-
|
|
268
|
-
// packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx
|
|
269
|
-
import React, { useEffect, useState } from "react";
|
|
270
275
|
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
|
-
};
|
|
380
276
|
|
|
381
277
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
|
|
382
278
|
var isObject = (data) => !!data && typeof data === "object";
|
|
383
279
|
|
|
384
280
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
|
|
385
|
-
import
|
|
281
|
+
import React, { Component } from "react";
|
|
386
282
|
var ErrorBoundary = class extends Component {
|
|
387
283
|
constructor(props) {
|
|
388
284
|
super(props);
|
|
@@ -402,7 +298,7 @@ var ErrorBoundary = class extends Component {
|
|
|
402
298
|
}
|
|
403
299
|
render() {
|
|
404
300
|
if (this.state.error) {
|
|
405
|
-
return /* @__PURE__ */
|
|
301
|
+
return /* @__PURE__ */ React.createElement(this.props.fallback, {
|
|
406
302
|
data: this.props.data,
|
|
407
303
|
error: this.state.error,
|
|
408
304
|
reset: this.resetError
|
|
@@ -418,9 +314,9 @@ var ErrorBoundary = class extends Component {
|
|
|
418
314
|
};
|
|
419
315
|
|
|
420
316
|
// packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
|
|
421
|
-
import
|
|
317
|
+
import React2, { forwardRef, Fragment, isValidElement, Suspense } from "react";
|
|
422
318
|
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
423
|
-
import { raise
|
|
319
|
+
import { raise } from "@dxos/debug";
|
|
424
320
|
var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
|
|
425
321
|
const props = {
|
|
426
322
|
role,
|
|
@@ -430,20 +326,20 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeho
|
|
|
430
326
|
};
|
|
431
327
|
const context = useContext2(SurfaceContext);
|
|
432
328
|
const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
|
|
433
|
-
const resolver = /* @__PURE__ */
|
|
329
|
+
const resolver = /* @__PURE__ */ React2.createElement(SurfaceResolver, {
|
|
434
330
|
...props,
|
|
435
331
|
ref: forwardedRef
|
|
436
332
|
});
|
|
437
|
-
const suspense = placeholder ? /* @__PURE__ */
|
|
333
|
+
const suspense = placeholder ? /* @__PURE__ */ React2.createElement(Suspense, {
|
|
438
334
|
fallback: placeholder
|
|
439
335
|
}, resolver) : resolver;
|
|
440
|
-
return fallback ? /* @__PURE__ */
|
|
336
|
+
return fallback ? /* @__PURE__ */ React2.createElement(ErrorBoundary, {
|
|
441
337
|
data,
|
|
442
338
|
fallback
|
|
443
339
|
}, suspense) : suspense;
|
|
444
340
|
});
|
|
445
341
|
var SurfaceContext = /* @__PURE__ */ createContext2(null);
|
|
446
|
-
var useSurface = () => useContext2(SurfaceContext) ??
|
|
342
|
+
var useSurface = () => useContext2(SurfaceContext) ?? raise(new Error("Surface context not found"));
|
|
447
343
|
var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
448
344
|
const { components } = useSurfaceRoot();
|
|
449
345
|
const parent = useContext2(SurfaceContext);
|
|
@@ -455,7 +351,7 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
|
455
351
|
...props.surfaces
|
|
456
352
|
}
|
|
457
353
|
};
|
|
458
|
-
return /* @__PURE__ */
|
|
354
|
+
return /* @__PURE__ */ React2.createElement(SurfaceContext.Provider, {
|
|
459
355
|
value: currentContext
|
|
460
356
|
}, nodes);
|
|
461
357
|
});
|
|
@@ -492,16 +388,17 @@ var resolveNodes = (components, props, context, forwardedRef) => {
|
|
|
492
388
|
return 1;
|
|
493
389
|
}
|
|
494
390
|
return 0;
|
|
495
|
-
}).map(([key, result]) => /* @__PURE__ */
|
|
391
|
+
}).map(([key, result]) => /* @__PURE__ */ React2.createElement(Fragment, {
|
|
496
392
|
key
|
|
497
393
|
}, result.node));
|
|
498
394
|
return props.limit ? nodes.slice(0, props.limit) : nodes;
|
|
499
395
|
};
|
|
500
396
|
|
|
501
397
|
// 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";
|
|
502
399
|
var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
|
|
503
400
|
var PLUGIN_HOST = "dxos.org/plugin/host";
|
|
504
|
-
var PluginHost = ({
|
|
401
|
+
var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = DefaultFallback, placeholder = null }) => {
|
|
505
402
|
const state = new LocalStorageStore(PLUGIN_HOST, {
|
|
506
403
|
ready: false,
|
|
507
404
|
core,
|
|
@@ -509,7 +406,7 @@ var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallba
|
|
|
509
406
|
...defaults
|
|
510
407
|
],
|
|
511
408
|
plugins: [],
|
|
512
|
-
available:
|
|
409
|
+
available: order.filter(({ id }) => !core.includes(id)),
|
|
513
410
|
setPlugin: (id, enabled) => {
|
|
514
411
|
if (enabled) {
|
|
515
412
|
state.values.enabled.push(id);
|
|
@@ -530,17 +427,16 @@ var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallba
|
|
|
530
427
|
},
|
|
531
428
|
provides: {
|
|
532
429
|
plugins: state.values,
|
|
533
|
-
context: ({ children }) => {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}, children);
|
|
537
|
-
},
|
|
430
|
+
context: ({ children }) => /* @__PURE__ */ React3.createElement(PluginProvider, {
|
|
431
|
+
value: state.values
|
|
432
|
+
}, children),
|
|
538
433
|
root: () => {
|
|
539
|
-
return /* @__PURE__ */
|
|
434
|
+
return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
|
|
540
435
|
fallback
|
|
541
|
-
}, /* @__PURE__ */
|
|
542
|
-
|
|
436
|
+
}, /* @__PURE__ */ React3.createElement(Root, {
|
|
437
|
+
order,
|
|
543
438
|
core,
|
|
439
|
+
definitions,
|
|
544
440
|
state: state.values,
|
|
545
441
|
placeholder
|
|
546
442
|
}));
|
|
@@ -549,36 +445,139 @@ var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallba
|
|
|
549
445
|
};
|
|
550
446
|
};
|
|
551
447
|
var DefaultFallback = ({ error }) => {
|
|
552
|
-
return /* @__PURE__ */
|
|
448
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
553
449
|
style: {
|
|
554
450
|
padding: "1rem"
|
|
555
451
|
}
|
|
556
|
-
}, /* @__PURE__ */
|
|
452
|
+
}, /* @__PURE__ */ React3.createElement("h1", {
|
|
557
453
|
style: {
|
|
558
454
|
fontSize: "1.2rem",
|
|
559
455
|
fontWeight: 700,
|
|
560
456
|
margin: "0.5rem 0"
|
|
561
457
|
}
|
|
562
|
-
}, error.message), /* @__PURE__ */
|
|
458
|
+
}, error.message), /* @__PURE__ */ React3.createElement("pre", null, error.stack));
|
|
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)));
|
|
563
563
|
};
|
|
564
564
|
|
|
565
565
|
// packages/sdk/app-framework/src/App.tsx
|
|
566
|
-
import
|
|
566
|
+
import React4 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 = ({ order, plugins, core = order.map(({ id }) => id), ...params }) => {
|
|
570
570
|
const host = PluginHost({
|
|
571
|
+
order: [
|
|
572
|
+
meta_default2,
|
|
573
|
+
meta_default,
|
|
574
|
+
...order
|
|
575
|
+
],
|
|
571
576
|
plugins: {
|
|
572
577
|
...plugins,
|
|
573
578
|
[meta_default2.id]: Plugin.lazy(() => import("./plugin-K3KCPCTJ.mjs")),
|
|
574
579
|
[meta_default.id]: Plugin.lazy(() => import("./plugin-MM66VRCO.mjs"))
|
|
575
580
|
},
|
|
576
|
-
// TODO(burdon): Why not include in core?
|
|
577
|
-
meta: [
|
|
578
|
-
meta_default2,
|
|
579
|
-
meta_default,
|
|
580
|
-
...meta
|
|
581
|
-
],
|
|
582
581
|
core: [
|
|
583
582
|
meta_default2.id,
|
|
584
583
|
meta_default.id,
|
|
@@ -586,38 +585,31 @@ var createApp = ({ meta, plugins, core, ...params }) => {
|
|
|
586
585
|
],
|
|
587
586
|
...params
|
|
588
587
|
});
|
|
589
|
-
invariant(host.provides, void 0, {
|
|
588
|
+
invariant(host.provides?.context, void 0, {
|
|
590
589
|
F: __dxlog_file2,
|
|
591
|
-
L:
|
|
590
|
+
L: 51,
|
|
592
591
|
S: void 0,
|
|
593
592
|
A: [
|
|
594
|
-
"host.provides",
|
|
593
|
+
"host.provides?.context",
|
|
595
594
|
""
|
|
596
595
|
]
|
|
597
596
|
});
|
|
598
|
-
|
|
599
|
-
invariant(Context, void 0, {
|
|
597
|
+
invariant(host.provides?.root, void 0, {
|
|
600
598
|
F: __dxlog_file2,
|
|
601
|
-
L:
|
|
602
|
-
S: void 0,
|
|
603
|
-
A: [
|
|
604
|
-
"Context",
|
|
605
|
-
""
|
|
606
|
-
]
|
|
607
|
-
});
|
|
608
|
-
invariant(Root, void 0, {
|
|
609
|
-
F: __dxlog_file2,
|
|
610
|
-
L: 55,
|
|
599
|
+
L: 52,
|
|
611
600
|
S: void 0,
|
|
612
601
|
A: [
|
|
613
|
-
"
|
|
602
|
+
"host.provides?.root",
|
|
614
603
|
""
|
|
615
604
|
]
|
|
616
605
|
});
|
|
617
|
-
|
|
606
|
+
const Context = host.provides.context;
|
|
607
|
+
const Root2 = host.provides.root;
|
|
608
|
+
return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root2, null));
|
|
618
609
|
};
|
|
619
610
|
export {
|
|
620
611
|
ActiveParts,
|
|
612
|
+
Attention,
|
|
621
613
|
ErrorBoundary,
|
|
622
614
|
IntentAction,
|
|
623
615
|
IntentProvider,
|
|
@@ -647,6 +639,7 @@ export {
|
|
|
647
639
|
firstIdInPart,
|
|
648
640
|
getPlugin,
|
|
649
641
|
indexInPart,
|
|
642
|
+
initializePlugin,
|
|
650
643
|
isLayoutAdjustment,
|
|
651
644
|
isLayoutMode,
|
|
652
645
|
isLayoutParts,
|
|
@@ -668,6 +661,7 @@ export {
|
|
|
668
661
|
parseSurfacePlugin,
|
|
669
662
|
parseTranslationsPlugin,
|
|
670
663
|
partLength,
|
|
664
|
+
pluginMeta,
|
|
671
665
|
resolvePlugin,
|
|
672
666
|
useIntent,
|
|
673
667
|
useIntentDispatcher,
|