@dxos/app-framework 0.6.11 → 0.6.12-main.568932b

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 (30) hide show
  1. package/dist/lib/browser/index.mjs +5 -6
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +19 -21
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/chunk-ERPIGFBI.mjs +28 -0
  8. package/dist/lib/node-esm/chunk-ERPIGFBI.mjs.map +7 -0
  9. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs +22 -0
  10. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs.map +7 -0
  11. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs +54 -0
  12. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +676 -0
  14. package/dist/lib/node-esm/index.mjs.map +7 -0
  15. package/dist/lib/node-esm/meta.json +1 -0
  16. package/dist/lib/node-esm/plugin-24ZP3LDU.mjs +40 -0
  17. package/dist/lib/node-esm/plugin-24ZP3LDU.mjs.map +7 -0
  18. package/dist/lib/node-esm/plugin-5AAUGDB3.mjs +168 -0
  19. package/dist/lib/node-esm/plugin-5AAUGDB3.mjs.map +7 -0
  20. package/dist/types/src/plugins/PluginHost/plugin.d.ts +2 -13
  21. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
  22. package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +1 -1
  23. package/dist/types/src/plugins/common/navigation.d.ts +1 -12
  24. package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
  25. package/package.json +14 -11
  26. package/project.json +3 -8
  27. package/src/plugins/PluginHost/plugin.test.ts +1 -2
  28. package/src/plugins/PluginHost/plugin.ts +1 -8
  29. package/src/plugins/common/navigation.ts +4 -12
  30. package/vitest.config.ts +9 -0
@@ -0,0 +1,676 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ SurfaceProvider,
4
+ meta_default as meta_default2,
5
+ parseRootSurfacePlugin,
6
+ parseSurfacePlugin,
7
+ useSurfaceRoot
8
+ } from "./chunk-ERPIGFBI.mjs";
9
+ import {
10
+ IntentAction,
11
+ IntentProvider,
12
+ meta_default,
13
+ parseIntentPlugin,
14
+ parseIntentResolverPlugin,
15
+ useIntent,
16
+ useIntentDispatcher,
17
+ useIntentResolver
18
+ } from "./chunk-P2TQLXZR.mjs";
19
+ import {
20
+ definePlugin,
21
+ filterPlugins,
22
+ findPlugin,
23
+ getPlugin,
24
+ resolvePlugin
25
+ } from "./chunk-IY7HCP4K.mjs";
26
+
27
+ // packages/sdk/app-framework/src/plugins/common/file.ts
28
+ var defaultFileTypes = {
29
+ images: [
30
+ "png",
31
+ "jpg",
32
+ "jpeg",
33
+ "gif"
34
+ ],
35
+ media: [
36
+ "mp3",
37
+ "mp4",
38
+ "mov",
39
+ "avi"
40
+ ],
41
+ text: [
42
+ "pdf",
43
+ "txt",
44
+ "md"
45
+ ]
46
+ };
47
+ var parseFileManagerPlugin = (plugin) => {
48
+ return plugin.provides.file ? plugin : void 0;
49
+ };
50
+
51
+ // packages/sdk/app-framework/src/plugins/common/graph.ts
52
+ var parseGraphPlugin = (plugin) => plugin.provides.graph?.root ? plugin : void 0;
53
+ var parseGraphBuilderPlugin = (plugin) => plugin.provides.graph?.builder ? plugin : void 0;
54
+ var parseGraphSerializerPlugin = (plugin) => plugin.provides.graph?.serializer ? plugin : void 0;
55
+
56
+ // packages/sdk/app-framework/src/plugins/common/layout.ts
57
+ import { z } from "zod";
58
+ var Toast = z.object({
59
+ id: z.string(),
60
+ title: z.string().optional(),
61
+ description: z.string().optional(),
62
+ // TODO(wittjosiah): `icon` should be string to be parsed by an `Icon` component.
63
+ icon: z.any().optional(),
64
+ duration: z.number().optional(),
65
+ closeLabel: z.string().optional(),
66
+ actionLabel: z.string().optional(),
67
+ actionAlt: z.string().optional(),
68
+ onAction: z.function().optional()
69
+ });
70
+ var LayoutMode = z.union([
71
+ z.literal("deck"),
72
+ z.literal("solo"),
73
+ z.literal("fullscreen")
74
+ ]);
75
+ var isLayoutMode = (value) => LayoutMode.safeParse(value).success;
76
+ var Layout = z.object({
77
+ layoutMode: z.union([
78
+ z.literal("deck"),
79
+ z.literal("solo"),
80
+ z.literal("fullscreen")
81
+ ]),
82
+ sidebarOpen: z.boolean(),
83
+ complementarySidebarOpen: z.boolean(),
84
+ /**
85
+ * @deprecated
86
+ */
87
+ complementarySidebarContent: z.any().optional().describe("DEPRECATED. Data to be passed to the complementary sidebar Surface."),
88
+ dialogOpen: z.boolean(),
89
+ dialogContent: z.any().optional().describe("Data to be passed to the dialog Surface."),
90
+ // TODO(wittjosiah): Custom properties?
91
+ dialogBlockAlign: z.union([
92
+ z.literal("start"),
93
+ z.literal("center")
94
+ ]).optional(),
95
+ popoverOpen: z.boolean(),
96
+ popoverContent: z.any().optional().describe("Data to be passed to the popover Surface."),
97
+ popoverAnchorId: z.string().optional(),
98
+ toasts: z.array(Toast),
99
+ scrollIntoView: z.string().optional().describe("The identifier of a component to scroll into view when it is mounted.")
100
+ });
101
+ var parseLayoutPlugin = (plugin) => {
102
+ const { success } = Layout.safeParse(plugin.provides.layout);
103
+ return success ? plugin : void 0;
104
+ };
105
+ var LAYOUT_ACTION = "dxos.org/plugin/layout";
106
+ var LayoutAction;
107
+ (function(LayoutAction2) {
108
+ LayoutAction2[LayoutAction2["SET_LAYOUT"] = `${LAYOUT_ACTION}/set-layout`] = "SET_LAYOUT";
109
+ LayoutAction2[LayoutAction2["SET_LAYOUT_MODE"] = `${LAYOUT_ACTION}/set-layout-mode`] = "SET_LAYOUT_MODE";
110
+ LayoutAction2[LayoutAction2["SCROLL_INTO_VIEW"] = `${LAYOUT_ACTION}/scroll-into-view`] = "SCROLL_INTO_VIEW";
111
+ LayoutAction2[LayoutAction2["UPDATE_PLANK_SIZE"] = `${LAYOUT_ACTION}/update-plank-size`] = "UPDATE_PLANK_SIZE";
112
+ })(LayoutAction || (LayoutAction = {}));
113
+
114
+ // packages/sdk/app-framework/src/plugins/common/metadata.ts
115
+ var parseMetadataRecordsPlugin = (plugin) => {
116
+ return plugin.provides.metadata?.records ? plugin : void 0;
117
+ };
118
+ var parseMetadataResolverPlugin = (plugin) => {
119
+ return plugin.provides.metadata?.resolver ? plugin : void 0;
120
+ };
121
+
122
+ // packages/sdk/app-framework/src/plugins/common/navigation.ts
123
+ import { Schema as S } from "@effect/schema";
124
+ import { z as z2 } from "zod";
125
+ var SLUG_LIST_SEPARATOR = "+";
126
+ var SLUG_ENTRY_SEPARATOR = "_";
127
+ var SLUG_KEY_VALUE_SEPARATOR = "-";
128
+ var SLUG_PATH_SEPARATOR = "~";
129
+ var SLUG_COLLECTION_INDICATOR = "";
130
+ var LayoutEntrySchema = S.mutable(S.Struct({
131
+ id: S.String,
132
+ path: S.optional(S.String)
133
+ }));
134
+ var LayoutPartSchema = S.Union(S.Literal("sidebar"), S.Literal("main"), S.Literal("solo"), S.Literal("complementary"), S.Literal("fullScreen"));
135
+ var LayoutPartsSchema = S.partial(S.mutable(S.Record({
136
+ key: LayoutPartSchema,
137
+ value: S.mutable(S.Array(LayoutEntrySchema))
138
+ })));
139
+ var LayoutCoordinateSchema = S.mutable(S.Struct({
140
+ part: LayoutPartSchema,
141
+ entryId: S.String
142
+ }));
143
+ var PartAdjustmentSchema = S.Union(S.Literal("increment-start"), S.Literal("increment-end"), S.Literal("solo"));
144
+ var LayoutAdjustmentSchema = S.mutable(S.Struct({
145
+ layoutCoordinate: LayoutCoordinateSchema,
146
+ type: PartAdjustmentSchema
147
+ }));
148
+ var ActiveParts = z2.record(z2.string(), z2.union([
149
+ z2.string(),
150
+ z2.array(z2.string())
151
+ ]));
152
+ var LocationProvidesSchema = S.mutable(S.Struct({
153
+ location: S.Struct({
154
+ active: LayoutPartsSchema,
155
+ closed: S.Array(S.String)
156
+ })
157
+ }));
158
+ var isLayoutParts = (value) => {
159
+ return S.is(LayoutPartsSchema)(value);
160
+ };
161
+ var isLayoutAdjustment = (value) => {
162
+ return S.is(LayoutAdjustmentSchema)(value);
163
+ };
164
+ var parseNavigationPlugin = (plugin) => {
165
+ const location = plugin.provides?.location;
166
+ if (!location) {
167
+ return void 0;
168
+ }
169
+ if (S.is(LocationProvidesSchema)({
170
+ location
171
+ })) {
172
+ return plugin;
173
+ }
174
+ return void 0;
175
+ };
176
+ var openIds = (layout) => {
177
+ return Object.values(layout).flatMap((part) => part?.map((entry) => entry.id) ?? []).filter((id) => id !== void 0);
178
+ };
179
+ var firstIdInPart = (layout, part) => {
180
+ if (!layout) {
181
+ return void 0;
182
+ }
183
+ return layout[part]?.at(0)?.id;
184
+ };
185
+ var indexInPart = (layout, layoutCoordinate) => {
186
+ if (!layout || !layoutCoordinate) {
187
+ return void 0;
188
+ }
189
+ const { part, entryId } = layoutCoordinate;
190
+ return layout[part]?.findIndex((entry) => entry.id === entryId);
191
+ };
192
+ var partLength = (layout, part) => {
193
+ if (!layout || !part) {
194
+ return 0;
195
+ }
196
+ return layout[part]?.length ?? 0;
197
+ };
198
+ var NAVIGATION_ACTION = "dxos.org/plugin/navigation";
199
+ var NavigationAction;
200
+ (function(NavigationAction2) {
201
+ NavigationAction2[NavigationAction2["OPEN"] = `${NAVIGATION_ACTION}/open`] = "OPEN";
202
+ NavigationAction2[NavigationAction2["ADD_TO_ACTIVE"] = `${NAVIGATION_ACTION}/add-to-active`] = "ADD_TO_ACTIVE";
203
+ NavigationAction2[NavigationAction2["SET"] = `${NAVIGATION_ACTION}/set`] = "SET";
204
+ NavigationAction2[NavigationAction2["ADJUST"] = `${NAVIGATION_ACTION}/adjust`] = "ADJUST";
205
+ NavigationAction2[NavigationAction2["CLOSE"] = `${NAVIGATION_ACTION}/close`] = "CLOSE";
206
+ NavigationAction2[NavigationAction2["EXPOSE"] = `${NAVIGATION_ACTION}/expose`] = "EXPOSE";
207
+ })(NavigationAction || (NavigationAction = {}));
208
+
209
+ // packages/sdk/app-framework/src/plugins/common/settings.ts
210
+ var parseSettingsPlugin = (plugin) => {
211
+ return typeof plugin.provides.settings === "object" ? plugin : void 0;
212
+ };
213
+ var SETTINGS_ACTION = "dxos.org/plugin/settings";
214
+ var SettingsAction;
215
+ (function(SettingsAction2) {
216
+ SettingsAction2[SettingsAction2["OPEN"] = `${SETTINGS_ACTION}/open`] = "OPEN";
217
+ })(SettingsAction || (SettingsAction = {}));
218
+
219
+ // packages/sdk/app-framework/src/plugins/common/translations.ts
220
+ import { z as z3 } from "zod";
221
+ var ResourceKey = z3.union([
222
+ z3.string(),
223
+ z3.record(z3.any())
224
+ ]);
225
+ var ResourceLanguage = z3.record(ResourceKey);
226
+ var Resource = z3.record(ResourceLanguage);
227
+ var parseTranslationsPlugin = (plugin) => {
228
+ const { success } = z3.array(Resource).safeParse(plugin.provides.translations);
229
+ return success ? plugin : void 0;
230
+ };
231
+
232
+ // packages/sdk/app-framework/src/plugins/PluginHost/plugin.ts
233
+ var pluginMeta = (meta) => meta;
234
+ var Plugin;
235
+ (function(Plugin2) {
236
+ Plugin2.lazy = (p, props) => {
237
+ return () => p().then(({ default: definition }) => {
238
+ return definition(props);
239
+ });
240
+ };
241
+ })(Plugin || (Plugin = {}));
242
+
243
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
244
+ import { createContext, useContext, useMemo } from "react";
245
+ import { nonNullable } from "@dxos/util";
246
+ var PluginContext = /* @__PURE__ */ createContext({
247
+ ready: false,
248
+ core: [],
249
+ enabled: [],
250
+ plugins: [],
251
+ available: [],
252
+ setPlugin: () => {
253
+ }
254
+ });
255
+ var usePlugins = () => useContext(PluginContext);
256
+ var usePlugin = (id) => {
257
+ const { plugins } = usePlugins();
258
+ return findPlugin(plugins, id);
259
+ };
260
+ var useResolvePlugin = (predicate) => {
261
+ const { plugins } = usePlugins();
262
+ return resolvePlugin(plugins, predicate);
263
+ };
264
+ var useResolvePlugins = (predicate) => {
265
+ const { plugins } = usePlugins();
266
+ return useMemo(() => plugins.map(predicate).filter(nonNullable), [
267
+ plugins,
268
+ predicate
269
+ ]);
270
+ };
271
+ var PluginProvider = PluginContext.Provider;
272
+
273
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
274
+ import React3, { useEffect, useState } from "react";
275
+ import { LocalStorageStore } from "@dxos/local-storage";
276
+ import { log } from "@dxos/log";
277
+
278
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
279
+ var isObject = (data) => !!data && typeof data === "object";
280
+
281
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
282
+ import React, { Component } from "react";
283
+ var ErrorBoundary = class extends Component {
284
+ constructor(props) {
285
+ super(props);
286
+ this.state = {
287
+ error: void 0
288
+ };
289
+ }
290
+ static getDerivedStateFromError(error) {
291
+ return {
292
+ error
293
+ };
294
+ }
295
+ componentDidUpdate(prevProps) {
296
+ if (prevProps.data !== this.props.data) {
297
+ this.resetError();
298
+ }
299
+ }
300
+ render() {
301
+ if (this.state.error) {
302
+ return /* @__PURE__ */ React.createElement(this.props.fallback, {
303
+ data: this.props.data,
304
+ error: this.state.error,
305
+ reset: this.resetError
306
+ });
307
+ }
308
+ return this.props.children;
309
+ }
310
+ resetError() {
311
+ this.setState({
312
+ error: void 0
313
+ });
314
+ }
315
+ };
316
+
317
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
318
+ import React2, { forwardRef, Fragment, isValidElement, Suspense } from "react";
319
+ import { createContext as createContext2, useContext as useContext2 } from "react";
320
+ import { raise } from "@dxos/debug";
321
+ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
322
+ const props = {
323
+ role,
324
+ name,
325
+ fallback,
326
+ ...rest
327
+ };
328
+ const context = useContext2(SurfaceContext);
329
+ const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
330
+ const resolver = /* @__PURE__ */ React2.createElement(SurfaceResolver, {
331
+ ...props,
332
+ ref: forwardedRef
333
+ });
334
+ const suspense = placeholder ? /* @__PURE__ */ React2.createElement(Suspense, {
335
+ fallback: placeholder
336
+ }, resolver) : resolver;
337
+ return fallback ? /* @__PURE__ */ React2.createElement(ErrorBoundary, {
338
+ data,
339
+ fallback
340
+ }, suspense) : suspense;
341
+ });
342
+ var SurfaceContext = /* @__PURE__ */ createContext2(null);
343
+ var useSurface = () => useContext2(SurfaceContext) ?? raise(new Error("Surface context not found"));
344
+ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
345
+ const { components } = useSurfaceRoot();
346
+ const parent = useContext2(SurfaceContext);
347
+ const nodes = resolveNodes(components, props, parent, forwardedRef);
348
+ const currentContext = {
349
+ ...props,
350
+ surfaces: {
351
+ ...props.name && parent?.surfaces?.[props.name]?.surfaces || {},
352
+ ...props.surfaces
353
+ }
354
+ };
355
+ return /* @__PURE__ */ React2.createElement(SurfaceContext.Provider, {
356
+ value: currentContext
357
+ }, nodes);
358
+ });
359
+ var resolveNodes = (components, props, context, forwardedRef) => {
360
+ const data = {
361
+ ...props.name && context?.surfaces?.[props.name]?.data || {},
362
+ ...props.data
363
+ };
364
+ const nodes = Object.entries(components).map(([key, component]) => {
365
+ const result = component({
366
+ ...props,
367
+ data
368
+ }, forwardedRef);
369
+ if (!result || typeof result !== "object") {
370
+ return void 0;
371
+ }
372
+ return "node" in result ? [
373
+ key,
374
+ result
375
+ ] : /* @__PURE__ */ isValidElement(result) ? [
376
+ key,
377
+ {
378
+ node: result
379
+ }
380
+ ] : void 0;
381
+ }).filter((result) => Boolean(result)).sort(([, a], [, b]) => {
382
+ const aDisposition = a.disposition ?? "default";
383
+ const bDisposition = b.disposition ?? "default";
384
+ if (aDisposition === bDisposition) {
385
+ return 0;
386
+ } else if (aDisposition === "hoist" || bDisposition === "fallback") {
387
+ return -1;
388
+ } else if (bDisposition === "hoist" || aDisposition === "fallback") {
389
+ return 1;
390
+ }
391
+ return 0;
392
+ }).map(([key, result]) => /* @__PURE__ */ React2.createElement(Fragment, {
393
+ key
394
+ }, result.node));
395
+ return props.limit ? nodes.slice(0, props.limit) : nodes;
396
+ };
397
+
398
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
399
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
400
+ var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
401
+ var PLUGIN_HOST = "dxos.org/plugin/host";
402
+ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = DefaultFallback, placeholder = null }) => {
403
+ const state = new LocalStorageStore(PLUGIN_HOST, {
404
+ ready: false,
405
+ core,
406
+ enabled: [
407
+ ...defaults
408
+ ],
409
+ plugins: [],
410
+ available: order.filter(({ id }) => !core.includes(id)),
411
+ setPlugin: (id, enabled) => {
412
+ if (enabled) {
413
+ state.values.enabled.push(id);
414
+ } else {
415
+ const index = state.values.enabled.findIndex((enabled2) => enabled2 === id);
416
+ index !== -1 && state.values.enabled.splice(index, 1);
417
+ }
418
+ }
419
+ });
420
+ state.prop({
421
+ key: "enabled",
422
+ type: LocalStorageStore.json()
423
+ });
424
+ return {
425
+ meta: {
426
+ id: PLUGIN_HOST,
427
+ name: "Plugin host"
428
+ },
429
+ provides: {
430
+ plugins: state.values,
431
+ context: ({ children }) => /* @__PURE__ */ React3.createElement(PluginProvider, {
432
+ value: state.values
433
+ }, children),
434
+ root: () => {
435
+ return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
436
+ fallback
437
+ }, /* @__PURE__ */ React3.createElement(Root, {
438
+ order,
439
+ core,
440
+ definitions,
441
+ state: state.values,
442
+ placeholder
443
+ }));
444
+ }
445
+ }
446
+ };
447
+ };
448
+ var DefaultFallback = ({ error }) => {
449
+ return /* @__PURE__ */ React3.createElement("div", {
450
+ style: {
451
+ padding: "1rem"
452
+ }
453
+ }, /* @__PURE__ */ React3.createElement("h1", {
454
+ style: {
455
+ fontSize: "1.2rem",
456
+ fontWeight: 700,
457
+ margin: "0.5rem 0"
458
+ }
459
+ }, error.message), /* @__PURE__ */ React3.createElement("pre", null, error.stack));
460
+ };
461
+ var Root = ({ order, core: corePluginIds, definitions, state, placeholder }) => {
462
+ const [error, setError] = useState();
463
+ useEffect(() => {
464
+ log("initializing plugins", {
465
+ enabled: state.enabled
466
+ }, {
467
+ F: __dxlog_file,
468
+ L: 102,
469
+ S: void 0,
470
+ C: (f, a) => f(...a)
471
+ });
472
+ const timeout = setTimeout(async () => {
473
+ try {
474
+ const enabledIds = [
475
+ ...corePluginIds,
476
+ ...state.enabled
477
+ ].sort((a, b) => {
478
+ const indexA = order.findIndex(({ id }) => id === a);
479
+ const indexB = order.findIndex(({ id }) => id === b);
480
+ return indexA - indexB;
481
+ });
482
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
483
+ const plugins = await Promise.all(enabled.map(async (definition) => {
484
+ const plugin = await initializePlugin(definition).catch((err) => {
485
+ log.error("Failed to initialize plugin:", {
486
+ id: definition.meta.id,
487
+ err
488
+ }, {
489
+ F: __dxlog_file,
490
+ L: 122,
491
+ S: void 0,
492
+ C: (f, a) => f(...a)
493
+ });
494
+ return void 0;
495
+ });
496
+ return plugin;
497
+ })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
498
+ log("plugins initialized", {
499
+ plugins
500
+ }, {
501
+ F: __dxlog_file,
502
+ L: 128,
503
+ S: void 0,
504
+ C: (f, a) => f(...a)
505
+ });
506
+ await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
507
+ log("plugins ready", {
508
+ plugins
509
+ }, {
510
+ F: __dxlog_file,
511
+ L: 131,
512
+ S: void 0,
513
+ C: (f, a) => f(...a)
514
+ });
515
+ state.plugins = plugins;
516
+ state.ready = true;
517
+ } catch (err) {
518
+ setError(err);
519
+ }
520
+ });
521
+ return () => {
522
+ clearTimeout(timeout);
523
+ state.ready = false;
524
+ };
525
+ }, []);
526
+ if (error) {
527
+ throw error;
528
+ }
529
+ if (!state.ready) {
530
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, placeholder);
531
+ }
532
+ const ComposedContext = composeContext(state.plugins);
533
+ return /* @__PURE__ */ React3.createElement(ComposedContext, null, rootComponents(state.plugins));
534
+ };
535
+ var initializePlugin = async (pluginDefinition) => {
536
+ const provides = await pluginDefinition.initialize?.();
537
+ return {
538
+ ...pluginDefinition,
539
+ provides: {
540
+ ...pluginDefinition.provides,
541
+ ...provides
542
+ }
543
+ };
544
+ };
545
+ var rootComponents = (plugins) => {
546
+ return plugins.map((plugin) => {
547
+ const Component2 = plugin.provides.root;
548
+ if (Component2) {
549
+ return /* @__PURE__ */ React3.createElement(Component2, {
550
+ key: plugin.meta.id
551
+ });
552
+ } else {
553
+ return null;
554
+ }
555
+ }).filter((node) => Boolean(node));
556
+ };
557
+ var composeContext = (plugins) => {
558
+ return compose(plugins.map((p) => p.provides.context).filter(Boolean));
559
+ };
560
+ var compose = (contexts) => {
561
+ return [
562
+ ...contexts
563
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React3.createElement(Acc, null, /* @__PURE__ */ React3.createElement(Next, null, children)));
564
+ };
565
+
566
+ // packages/sdk/app-framework/src/App.tsx
567
+ import React4 from "react";
568
+ import { invariant } from "@dxos/invariant";
569
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/App.tsx";
570
+ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }) => {
571
+ const host = PluginHost({
572
+ order: [
573
+ meta_default2,
574
+ meta_default,
575
+ ...order
576
+ ],
577
+ plugins: {
578
+ ...plugins,
579
+ [meta_default2.id]: Plugin.lazy(() => import("./plugin-24ZP3LDU.mjs")),
580
+ [meta_default.id]: Plugin.lazy(() => import("./plugin-5AAUGDB3.mjs"))
581
+ },
582
+ core: [
583
+ meta_default2.id,
584
+ meta_default.id,
585
+ ...core
586
+ ],
587
+ ...params
588
+ });
589
+ invariant(host.provides?.context, void 0, {
590
+ F: __dxlog_file2,
591
+ L: 51,
592
+ S: void 0,
593
+ A: [
594
+ "host.provides?.context",
595
+ ""
596
+ ]
597
+ });
598
+ invariant(host.provides?.root, void 0, {
599
+ F: __dxlog_file2,
600
+ L: 52,
601
+ S: void 0,
602
+ A: [
603
+ "host.provides?.root",
604
+ ""
605
+ ]
606
+ });
607
+ const Context = host.provides.context;
608
+ const Root2 = host.provides.root;
609
+ return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root2, null));
610
+ };
611
+ export {
612
+ ActiveParts,
613
+ ErrorBoundary,
614
+ IntentAction,
615
+ IntentProvider,
616
+ Layout,
617
+ LayoutAction,
618
+ NavigationAction,
619
+ Plugin,
620
+ PluginHost,
621
+ PluginProvider,
622
+ Resource,
623
+ ResourceKey,
624
+ ResourceLanguage,
625
+ SLUG_COLLECTION_INDICATOR,
626
+ SLUG_ENTRY_SEPARATOR,
627
+ SLUG_KEY_VALUE_SEPARATOR,
628
+ SLUG_LIST_SEPARATOR,
629
+ SLUG_PATH_SEPARATOR,
630
+ SettingsAction,
631
+ Surface,
632
+ SurfaceProvider,
633
+ Toast,
634
+ createApp,
635
+ defaultFileTypes,
636
+ definePlugin,
637
+ filterPlugins,
638
+ findPlugin,
639
+ firstIdInPart,
640
+ getPlugin,
641
+ indexInPart,
642
+ initializePlugin,
643
+ isLayoutAdjustment,
644
+ isLayoutMode,
645
+ isLayoutParts,
646
+ isObject,
647
+ openIds,
648
+ parseFileManagerPlugin,
649
+ parseGraphBuilderPlugin,
650
+ parseGraphPlugin,
651
+ parseGraphSerializerPlugin,
652
+ parseIntentPlugin,
653
+ parseIntentResolverPlugin,
654
+ parseLayoutPlugin,
655
+ parseMetadataRecordsPlugin,
656
+ parseMetadataResolverPlugin,
657
+ parseNavigationPlugin,
658
+ parsePluginHost,
659
+ parseRootSurfacePlugin,
660
+ parseSettingsPlugin,
661
+ parseSurfacePlugin,
662
+ parseTranslationsPlugin,
663
+ partLength,
664
+ pluginMeta,
665
+ resolvePlugin,
666
+ useIntent,
667
+ useIntentDispatcher,
668
+ useIntentResolver,
669
+ usePlugin,
670
+ usePlugins,
671
+ useResolvePlugin,
672
+ useResolvePlugins,
673
+ useSurface,
674
+ useSurfaceRoot
675
+ };
676
+ //# sourceMappingURL=index.mjs.map