@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.
Files changed (43) hide show
  1. package/dist/lib/browser/index.mjs +169 -163
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +183 -182
  5. package/dist/lib/node/index.cjs.map +4 -4
  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 +683 -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/App.d.ts +4 -4
  21. package/dist/types/src/App.d.ts.map +1 -1
  22. package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts +14 -0
  23. package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts.map +1 -0
  24. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts +4 -4
  25. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +1 -1
  26. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts +4 -8
  27. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +1 -1
  28. package/dist/types/src/plugins/PluginHost/plugin.d.ts +37 -83
  29. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +1 -1
  30. package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +1 -1
  31. package/dist/types/src/plugins/common/navigation.d.ts +1 -12
  32. package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
  33. package/package.json +14 -11
  34. package/project.json +3 -8
  35. package/src/App.tsx +10 -9
  36. package/src/plugins/PluginHost/PluginContainer.tsx +120 -0
  37. package/src/plugins/PluginHost/PluginContext.tsx +8 -14
  38. package/src/plugins/PluginHost/PluginHost.tsx +18 -121
  39. package/src/plugins/PluginHost/plugin.test.ts +1 -2
  40. package/src/plugins/PluginHost/plugin.ts +45 -52
  41. package/src/plugins/common/navigation.ts +4 -12
  42. package/tsconfig.json +1 -29
  43. package/vitest.config.ts +9 -0
@@ -0,0 +1,683 @@
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 Plugin;
234
+ (function(Plugin2) {
235
+ Plugin2.lazy = (p, props) => {
236
+ return () => p().then(({ default: definition }) => {
237
+ return definition(props);
238
+ });
239
+ };
240
+ })(Plugin || (Plugin = {}));
241
+
242
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginContext.tsx
243
+ import { createContext, useContext, useMemo } from "react";
244
+ import { raise } from "@dxos/debug";
245
+ import { nonNullable } from "@dxos/util";
246
+ var PluginContext = /* @__PURE__ */ createContext(void 0);
247
+ var usePlugins = () => useContext(PluginContext) ?? raise(new Error("Missing PluginContext"));
248
+ var usePlugin = (id) => {
249
+ const { plugins } = usePlugins();
250
+ return findPlugin(plugins, id);
251
+ };
252
+ var useResolvePlugin = (predicate) => {
253
+ const { plugins } = usePlugins();
254
+ return resolvePlugin(plugins, predicate);
255
+ };
256
+ var useResolvePlugins = (predicate) => {
257
+ const { plugins } = usePlugins();
258
+ return useMemo(() => plugins.map(predicate).filter(nonNullable), [
259
+ plugins,
260
+ predicate
261
+ ]);
262
+ };
263
+ var PluginProvider = PluginContext.Provider;
264
+
265
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
266
+ import React4 from "react";
267
+ import { LocalStorageStore } from "@dxos/local-storage";
268
+
269
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx
270
+ import React, { useEffect, useState } from "react";
271
+ import { log } from "@dxos/log";
272
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginContainer.tsx";
273
+ var PluginContainer = ({ plugins: definitions, core, state, placeholder }) => {
274
+ const [error, setError] = useState();
275
+ useEffect(() => {
276
+ log("initializing plugins", {
277
+ enabled: state.enabled
278
+ }, {
279
+ F: __dxlog_file,
280
+ L: 26,
281
+ S: void 0,
282
+ C: (f, a) => f(...a)
283
+ });
284
+ const t = setTimeout(async () => {
285
+ try {
286
+ const enabledIds = [
287
+ ...core,
288
+ ...state.enabled
289
+ ];
290
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
291
+ const plugins = await Promise.all(enabled.map(async (definition) => {
292
+ const plugin = await initializePlugin(definition).catch((err) => {
293
+ log.error("Failed to initialize plugin:", {
294
+ id: definition.meta.id,
295
+ err
296
+ }, {
297
+ F: __dxlog_file,
298
+ L: 41,
299
+ S: void 0,
300
+ C: (f, a) => f(...a)
301
+ });
302
+ });
303
+ log("initialized", {
304
+ plugin: definition.meta.id
305
+ }, {
306
+ F: __dxlog_file,
307
+ L: 44,
308
+ S: void 0,
309
+ C: (f, a) => f(...a)
310
+ });
311
+ return plugin;
312
+ }));
313
+ const initialized = plugins.filter((plugin) => Boolean(plugin));
314
+ log("plugins initialized", {
315
+ plugins: initialized
316
+ }, {
317
+ F: __dxlog_file,
318
+ L: 50,
319
+ S: void 0,
320
+ C: (f, a) => f(...a)
321
+ });
322
+ await Promise.all(enabled.map((plugin) => plugin.ready?.(initialized)));
323
+ log("plugins ready", {
324
+ plugins: initialized
325
+ }, {
326
+ F: __dxlog_file,
327
+ L: 53,
328
+ S: void 0,
329
+ C: (f, a) => f(...a)
330
+ });
331
+ state.plugins = initialized;
332
+ state.ready = true;
333
+ } catch (err) {
334
+ setError(err);
335
+ }
336
+ });
337
+ return () => {
338
+ clearTimeout(t);
339
+ state.ready = false;
340
+ };
341
+ }, []);
342
+ if (error) {
343
+ throw error;
344
+ }
345
+ if (!state.ready) {
346
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, placeholder);
347
+ }
348
+ const ComposedContext = composeContext(state.plugins);
349
+ return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.plugins));
350
+ };
351
+ var initializePlugin = async (pluginDefinition) => {
352
+ const provides = await pluginDefinition.initialize?.();
353
+ return {
354
+ ...pluginDefinition,
355
+ provides: {
356
+ ...pluginDefinition.provides,
357
+ ...provides
358
+ }
359
+ };
360
+ };
361
+ var rootComponents = (plugins) => {
362
+ return plugins.map((plugin) => {
363
+ const Component2 = plugin.provides.root;
364
+ if (Component2) {
365
+ return /* @__PURE__ */ React.createElement(Component2, {
366
+ key: plugin.meta.id
367
+ });
368
+ } else {
369
+ return null;
370
+ }
371
+ }).filter((node) => Boolean(node));
372
+ };
373
+ var composeContext = (plugins) => {
374
+ return compose(plugins.map((p) => p.provides.context).filter(Boolean));
375
+ };
376
+ var compose = (contexts) => {
377
+ return [
378
+ ...contexts
379
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
380
+ };
381
+
382
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
383
+ var isObject = (data) => !!data && typeof data === "object";
384
+
385
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
386
+ import React2, { Component } from "react";
387
+ var ErrorBoundary = class extends Component {
388
+ constructor(props) {
389
+ super(props);
390
+ this.state = {
391
+ error: void 0
392
+ };
393
+ }
394
+ static getDerivedStateFromError(error) {
395
+ return {
396
+ error
397
+ };
398
+ }
399
+ componentDidUpdate(prevProps) {
400
+ if (prevProps.data !== this.props.data) {
401
+ this.resetError();
402
+ }
403
+ }
404
+ render() {
405
+ if (this.state.error) {
406
+ return /* @__PURE__ */ React2.createElement(this.props.fallback, {
407
+ data: this.props.data,
408
+ error: this.state.error,
409
+ reset: this.resetError
410
+ });
411
+ }
412
+ return this.props.children;
413
+ }
414
+ resetError() {
415
+ this.setState({
416
+ error: void 0
417
+ });
418
+ }
419
+ };
420
+
421
+ // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
422
+ import React3, { forwardRef, Fragment, isValidElement, Suspense } from "react";
423
+ import { createContext as createContext2, useContext as useContext2 } from "react";
424
+ import { raise as raise2 } from "@dxos/debug";
425
+ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
426
+ const props = {
427
+ role,
428
+ name,
429
+ fallback,
430
+ ...rest
431
+ };
432
+ const context = useContext2(SurfaceContext);
433
+ const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
434
+ const resolver = /* @__PURE__ */ React3.createElement(SurfaceResolver, {
435
+ ...props,
436
+ ref: forwardedRef
437
+ });
438
+ const suspense = placeholder ? /* @__PURE__ */ React3.createElement(Suspense, {
439
+ fallback: placeholder
440
+ }, resolver) : resolver;
441
+ return fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
442
+ data,
443
+ fallback
444
+ }, suspense) : suspense;
445
+ });
446
+ var SurfaceContext = /* @__PURE__ */ createContext2(null);
447
+ var useSurface = () => useContext2(SurfaceContext) ?? raise2(new Error("Surface context not found"));
448
+ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
449
+ const { components } = useSurfaceRoot();
450
+ const parent = useContext2(SurfaceContext);
451
+ const nodes = resolveNodes(components, props, parent, forwardedRef);
452
+ const currentContext = {
453
+ ...props,
454
+ surfaces: {
455
+ ...props.name && parent?.surfaces?.[props.name]?.surfaces || {},
456
+ ...props.surfaces
457
+ }
458
+ };
459
+ return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
460
+ value: currentContext
461
+ }, nodes);
462
+ });
463
+ var resolveNodes = (components, props, context, forwardedRef) => {
464
+ const data = {
465
+ ...props.name && context?.surfaces?.[props.name]?.data || {},
466
+ ...props.data
467
+ };
468
+ const nodes = Object.entries(components).map(([key, component]) => {
469
+ const result = component({
470
+ ...props,
471
+ data
472
+ }, forwardedRef);
473
+ if (!result || typeof result !== "object") {
474
+ return void 0;
475
+ }
476
+ return "node" in result ? [
477
+ key,
478
+ result
479
+ ] : /* @__PURE__ */ isValidElement(result) ? [
480
+ key,
481
+ {
482
+ node: result
483
+ }
484
+ ] : void 0;
485
+ }).filter((result) => Boolean(result)).sort(([, a], [, b]) => {
486
+ const aDisposition = a.disposition ?? "default";
487
+ const bDisposition = b.disposition ?? "default";
488
+ if (aDisposition === bDisposition) {
489
+ return 0;
490
+ } else if (aDisposition === "hoist" || bDisposition === "fallback") {
491
+ return -1;
492
+ } else if (bDisposition === "hoist" || aDisposition === "fallback") {
493
+ return 1;
494
+ }
495
+ return 0;
496
+ }).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
497
+ key
498
+ }, result.node));
499
+ return props.limit ? nodes.slice(0, props.limit) : nodes;
500
+ };
501
+
502
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
503
+ var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
504
+ var PLUGIN_HOST = "dxos.org/plugin/host";
505
+ var PluginHost = ({ plugins, meta, core, defaults = [], fallback = DefaultFallback, placeholder = null }) => {
506
+ const state = new LocalStorageStore(PLUGIN_HOST, {
507
+ ready: false,
508
+ core,
509
+ enabled: [
510
+ ...defaults
511
+ ],
512
+ plugins: [],
513
+ available: meta.filter(({ id }) => !core.includes(id)),
514
+ setPlugin: (id, enabled) => {
515
+ if (enabled) {
516
+ state.values.enabled.push(id);
517
+ } else {
518
+ const index = state.values.enabled.findIndex((enabled2) => enabled2 === id);
519
+ index !== -1 && state.values.enabled.splice(index, 1);
520
+ }
521
+ }
522
+ });
523
+ state.prop({
524
+ key: "enabled",
525
+ type: LocalStorageStore.json()
526
+ });
527
+ return {
528
+ meta: {
529
+ id: PLUGIN_HOST,
530
+ name: "Plugin host"
531
+ },
532
+ provides: {
533
+ plugins: state.values,
534
+ context: ({ children }) => {
535
+ return /* @__PURE__ */ React4.createElement(PluginProvider, {
536
+ value: state.values
537
+ }, children);
538
+ },
539
+ root: () => {
540
+ return /* @__PURE__ */ React4.createElement(ErrorBoundary, {
541
+ fallback
542
+ }, /* @__PURE__ */ React4.createElement(PluginContainer, {
543
+ plugins,
544
+ core,
545
+ state: state.values,
546
+ placeholder
547
+ }));
548
+ }
549
+ }
550
+ };
551
+ };
552
+ var DefaultFallback = ({ error }) => {
553
+ return /* @__PURE__ */ React4.createElement("div", {
554
+ style: {
555
+ padding: "1rem"
556
+ }
557
+ }, /* @__PURE__ */ React4.createElement("h1", {
558
+ style: {
559
+ fontSize: "1.2rem",
560
+ fontWeight: 700,
561
+ margin: "0.5rem 0"
562
+ }
563
+ }, error.message), /* @__PURE__ */ React4.createElement("pre", null, error.stack));
564
+ };
565
+
566
+ // packages/sdk/app-framework/src/App.tsx
567
+ import React5 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 = ({ meta, plugins, core, ...params }) => {
571
+ const host = PluginHost({
572
+ plugins: {
573
+ ...plugins,
574
+ [meta_default2.id]: Plugin.lazy(() => import("./plugin-24ZP3LDU.mjs")),
575
+ [meta_default.id]: Plugin.lazy(() => import("./plugin-5AAUGDB3.mjs"))
576
+ },
577
+ // TODO(burdon): Why not include in core?
578
+ meta: [
579
+ meta_default2,
580
+ meta_default,
581
+ ...meta
582
+ ],
583
+ core: [
584
+ meta_default2.id,
585
+ meta_default.id,
586
+ ...core
587
+ ],
588
+ ...params
589
+ });
590
+ invariant(host.provides, void 0, {
591
+ F: __dxlog_file2,
592
+ L: 52,
593
+ S: void 0,
594
+ A: [
595
+ "host.provides",
596
+ ""
597
+ ]
598
+ });
599
+ const { context: Context, root: Root } = host.provides;
600
+ invariant(Context, void 0, {
601
+ F: __dxlog_file2,
602
+ L: 54,
603
+ S: void 0,
604
+ A: [
605
+ "Context",
606
+ ""
607
+ ]
608
+ });
609
+ invariant(Root, void 0, {
610
+ F: __dxlog_file2,
611
+ L: 55,
612
+ S: void 0,
613
+ A: [
614
+ "Root",
615
+ ""
616
+ ]
617
+ });
618
+ return () => /* @__PURE__ */ React5.createElement(Context, null, /* @__PURE__ */ React5.createElement(Root, null));
619
+ };
620
+ export {
621
+ ActiveParts,
622
+ ErrorBoundary,
623
+ IntentAction,
624
+ IntentProvider,
625
+ Layout,
626
+ LayoutAction,
627
+ NavigationAction,
628
+ Plugin,
629
+ PluginHost,
630
+ PluginProvider,
631
+ Resource,
632
+ ResourceKey,
633
+ ResourceLanguage,
634
+ SLUG_COLLECTION_INDICATOR,
635
+ SLUG_ENTRY_SEPARATOR,
636
+ SLUG_KEY_VALUE_SEPARATOR,
637
+ SLUG_LIST_SEPARATOR,
638
+ SLUG_PATH_SEPARATOR,
639
+ SettingsAction,
640
+ Surface,
641
+ SurfaceProvider,
642
+ Toast,
643
+ createApp,
644
+ defaultFileTypes,
645
+ definePlugin,
646
+ filterPlugins,
647
+ findPlugin,
648
+ firstIdInPart,
649
+ getPlugin,
650
+ indexInPart,
651
+ isLayoutAdjustment,
652
+ isLayoutMode,
653
+ isLayoutParts,
654
+ isObject,
655
+ openIds,
656
+ parseFileManagerPlugin,
657
+ parseGraphBuilderPlugin,
658
+ parseGraphPlugin,
659
+ parseGraphSerializerPlugin,
660
+ parseIntentPlugin,
661
+ parseIntentResolverPlugin,
662
+ parseLayoutPlugin,
663
+ parseMetadataRecordsPlugin,
664
+ parseMetadataResolverPlugin,
665
+ parseNavigationPlugin,
666
+ parsePluginHost,
667
+ parseRootSurfacePlugin,
668
+ parseSettingsPlugin,
669
+ parseSurfacePlugin,
670
+ parseTranslationsPlugin,
671
+ partLength,
672
+ resolvePlugin,
673
+ useIntent,
674
+ useIntentDispatcher,
675
+ useIntentResolver,
676
+ usePlugin,
677
+ usePlugins,
678
+ useResolvePlugin,
679
+ useResolvePlugins,
680
+ useSurface,
681
+ useSurfaceRoot
682
+ };
683
+ //# sourceMappingURL=index.mjs.map