@dxos/app-framework 0.3.11-main.b929e1d → 0.3.11-main.bc6b68b

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.
@@ -95,7 +95,7 @@ var parseTranslationsPlugin = (plugin) => {
95
95
  var pluginMeta = (meta) => meta;
96
96
  var Plugin;
97
97
  (function(Plugin2) {
98
- var lazy = Plugin2.lazy = (p, props) => {
98
+ Plugin2.lazy = (p, props) => {
99
99
  return () => p().then(({ default: definition }) => {
100
100
  return definition(props);
101
101
  });
@@ -125,141 +125,15 @@ var PluginProvider = PluginContext.Provider;
125
125
 
126
126
  // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
127
127
  import { shallow } from "deepsignal/react";
128
- import React, { useEffect } from "react";
128
+ import React3, { useEffect, useState } from "react";
129
129
  import { LocalStorageStore } from "@dxos/local-storage";
130
130
  import { log } from "@dxos/log";
131
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
132
- var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
133
- var PLUGIN_HOST = "dxos.org/plugin/host";
134
- var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = null }) => {
135
- const state = new LocalStorageStore(PLUGIN_HOST, {
136
- ready: false,
137
- enabled: [
138
- ...defaults
139
- ],
140
- plugins: [],
141
- available: order.filter(({ id }) => !core.includes(id)),
142
- setPlugin: (id, enabled) => {
143
- if (enabled) {
144
- state.values.enabled = [
145
- ...state.values.enabled,
146
- id
147
- ];
148
- } else {
149
- state.values.enabled = state.values.enabled.filter((enabled2) => enabled2 !== id);
150
- }
151
- }
152
- });
153
- state.prop(state.values.$enabled, "enabled", LocalStorageStore.json);
154
- return {
155
- meta: {
156
- id: PLUGIN_HOST,
157
- name: "Plugin host"
158
- },
159
- provides: {
160
- plugins: state.values,
161
- context: ({ children }) => /* @__PURE__ */ React.createElement(PluginProvider, {
162
- value: state.values
163
- }, children),
164
- root: () => {
165
- useEffect(() => {
166
- log("initializing plugins", {
167
- enabled: state.values.enabled
168
- }, {
169
- F: __dxlog_file,
170
- L: 67,
171
- S: void 0,
172
- C: (f, a) => f(...a)
173
- });
174
- const timeout = setTimeout(async () => {
175
- const enabledIds = [
176
- ...core,
177
- ...state.values.enabled
178
- ].sort((a, b) => {
179
- const indexA = order.findIndex(({ id }) => id === a);
180
- const indexB = order.findIndex(({ id }) => id === b);
181
- return indexA - indexB;
182
- });
183
- const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
184
- const plugins = await Promise.all(enabled.map(async (definition) => {
185
- const plugin = await initializePlugin(definition).catch((err) => {
186
- console.error("Failed to initialize plugin:", definition.meta.id, err);
187
- return void 0;
188
- });
189
- return plugin;
190
- })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
191
- log("plugins initialized", {
192
- plugins
193
- }, {
194
- F: __dxlog_file,
195
- L: 92,
196
- S: void 0,
197
- C: (f, a) => f(...a)
198
- });
199
- await Promise.all(enabled.map(async (pluginDefinition) => {
200
- await pluginDefinition.ready?.(plugins);
201
- }));
202
- log("plugins ready", {
203
- plugins
204
- }, {
205
- F: __dxlog_file,
206
- L: 99,
207
- S: void 0,
208
- C: (f, a) => f(...a)
209
- });
210
- state.values.plugins = shallow(plugins);
211
- state.values.ready = true;
212
- });
213
- return () => {
214
- clearTimeout(timeout);
215
- state.values.ready = false;
216
- };
217
- }, []);
218
- if (!state.values.ready) {
219
- return /* @__PURE__ */ React.createElement(React.Fragment, null, fallback);
220
- }
221
- const ComposedContext = composeContext(state.values.plugins);
222
- return /* @__PURE__ */ React.createElement(ComposedContext, null, rootComponents(state.values.plugins));
223
- }
224
- }
225
- };
226
- };
227
- var initializePlugin = async (pluginDefinition) => {
228
- const provides = await pluginDefinition.initialize?.();
229
- return {
230
- ...pluginDefinition,
231
- provides: {
232
- ...pluginDefinition.provides,
233
- ...provides
234
- }
235
- };
236
- };
237
- var rootComponents = (plugins) => {
238
- return plugins.map((plugin) => {
239
- const Component2 = plugin.provides.root;
240
- if (Component2) {
241
- return /* @__PURE__ */ React.createElement(Component2, {
242
- key: plugin.meta.id
243
- });
244
- } else {
245
- return null;
246
- }
247
- }).filter((node) => Boolean(node));
248
- };
249
- var composeContext = (plugins) => {
250
- return compose(plugins.map((p) => p.provides.context).filter(Boolean));
251
- };
252
- var compose = (contexts) => {
253
- return [
254
- ...contexts
255
- ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React.createElement(Acc, null, /* @__PURE__ */ React.createElement(Next, null, children)));
256
- };
257
131
 
258
132
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/helpers.ts
259
133
  var isObject = (data) => !!data && typeof data === "object";
260
134
 
261
135
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/ErrorBoundary.tsx
262
- import React2, { Component } from "react";
136
+ import React, { Component } from "react";
263
137
  var ErrorBoundary = class extends Component {
264
138
  constructor(props) {
265
139
  super(props);
@@ -279,7 +153,7 @@ var ErrorBoundary = class extends Component {
279
153
  }
280
154
  render() {
281
155
  if (this.state.error) {
282
- return /* @__PURE__ */ React2.createElement(this.props.fallback, {
156
+ return /* @__PURE__ */ React.createElement(this.props.fallback, {
283
157
  error: this.state.error,
284
158
  reset: this.resetError
285
159
  });
@@ -294,7 +168,7 @@ var ErrorBoundary = class extends Component {
294
168
  };
295
169
 
296
170
  // packages/sdk/app-framework/src/plugins/SurfacePlugin/Surface.tsx
297
- import React3, { forwardRef, Fragment, isValidElement } from "react";
171
+ import React2, { forwardRef, Fragment, isValidElement } from "react";
298
172
  import { createContext as createContext2, useContext as useContext2 } from "react";
299
173
  var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest }, forwardedRef) => {
300
174
  const props = {
@@ -305,13 +179,13 @@ var Surface = /* @__PURE__ */ forwardRef(({ role, name = role, fallback, ...rest
305
179
  };
306
180
  const context = useContext2(SurfaceContext);
307
181
  const data = props.data ?? (name && context?.surfaces?.[name]?.data || {});
308
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
182
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, fallback ? /* @__PURE__ */ React2.createElement(ErrorBoundary, {
309
183
  data,
310
184
  fallback
311
- }, /* @__PURE__ */ React3.createElement(SurfaceResolver, {
185
+ }, /* @__PURE__ */ React2.createElement(SurfaceResolver, {
312
186
  ...props,
313
187
  ref: forwardedRef
314
- })) : /* @__PURE__ */ React3.createElement(SurfaceResolver, {
188
+ })) : /* @__PURE__ */ React2.createElement(SurfaceResolver, {
315
189
  ...props,
316
190
  ref: forwardedRef
317
191
  }));
@@ -328,9 +202,9 @@ var SurfaceResolver = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
328
202
  ...props.surfaces
329
203
  }
330
204
  };
331
- return /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
205
+ return /* @__PURE__ */ React2.createElement(SurfaceContext.Provider, {
332
206
  value: currentContext
333
- }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React3.createElement(props.contentFallback, null) : null);
207
+ }, nodes.length > 0 ? nodes : props.contentFallback ? /* @__PURE__ */ React2.createElement(props.contentFallback, null) : null);
334
208
  });
335
209
  var resolveNodes = (components, props, context, forwardedRef) => {
336
210
  const data = {
@@ -365,12 +239,170 @@ var resolveNodes = (components, props, context, forwardedRef) => {
365
239
  return 1;
366
240
  }
367
241
  return 0;
368
- }).map(([key, result]) => /* @__PURE__ */ React3.createElement(Fragment, {
242
+ }).map(([key, result]) => /* @__PURE__ */ React2.createElement(Fragment, {
369
243
  key
370
244
  }, result.node));
371
245
  return props.limit ? nodes.slice(0, props.limit) : nodes;
372
246
  };
373
247
 
248
+ // packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx
249
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/PluginHost/PluginHost.tsx";
250
+ var parsePluginHost = (plugin) => plugin.provides.plugins ? plugin : void 0;
251
+ var PLUGIN_HOST = "dxos.org/plugin/host";
252
+ var PluginHost = ({ order, plugins: definitions, core = [], defaults = [], fallback = DefaultFallback, placeholder = null }) => {
253
+ const state = new LocalStorageStore(PLUGIN_HOST, {
254
+ ready: false,
255
+ enabled: [
256
+ ...defaults
257
+ ],
258
+ plugins: [],
259
+ available: order.filter(({ id }) => !core.includes(id)),
260
+ setPlugin: (id, enabled) => {
261
+ if (enabled) {
262
+ state.values.enabled = [
263
+ ...state.values.enabled,
264
+ id
265
+ ];
266
+ } else {
267
+ state.values.enabled = state.values.enabled.filter((enabled2) => enabled2 !== id);
268
+ }
269
+ }
270
+ });
271
+ state.prop(state.values.$enabled, "enabled", LocalStorageStore.json);
272
+ return {
273
+ meta: {
274
+ id: PLUGIN_HOST,
275
+ name: "Plugin host"
276
+ },
277
+ provides: {
278
+ plugins: state.values,
279
+ context: ({ children }) => /* @__PURE__ */ React3.createElement(PluginProvider, {
280
+ value: state.values
281
+ }, children),
282
+ root: () => {
283
+ return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
284
+ fallback
285
+ }, /* @__PURE__ */ React3.createElement(Root, {
286
+ order,
287
+ core,
288
+ definitions,
289
+ state: state.values,
290
+ placeholder
291
+ }));
292
+ }
293
+ }
294
+ };
295
+ };
296
+ var DefaultFallback = ({ error }) => {
297
+ return /* @__PURE__ */ React3.createElement("div", {
298
+ style: {
299
+ padding: "1rem"
300
+ }
301
+ }, /* @__PURE__ */ React3.createElement("h1", {
302
+ style: {
303
+ fontSize: "1.2rem",
304
+ fontWeight: 700,
305
+ margin: "0.5rem 0"
306
+ }
307
+ }, error.message), /* @__PURE__ */ React3.createElement("pre", null, error.stack));
308
+ };
309
+ var Root = ({ order, core: corePluginIds, definitions, state, placeholder }) => {
310
+ const [error, setError] = useState();
311
+ useEffect(() => {
312
+ log("initializing plugins", {
313
+ enabled: state.enabled
314
+ }, {
315
+ F: __dxlog_file,
316
+ L: 101,
317
+ S: void 0,
318
+ C: (f, a) => f(...a)
319
+ });
320
+ const timeout = setTimeout(async () => {
321
+ try {
322
+ const enabledIds = [
323
+ ...corePluginIds,
324
+ ...state.enabled
325
+ ].sort((a, b) => {
326
+ const indexA = order.findIndex(({ id }) => id === a);
327
+ const indexB = order.findIndex(({ id }) => id === b);
328
+ return indexA - indexB;
329
+ });
330
+ const enabled = await Promise.all(enabledIds.map((id) => definitions[id]).filter((definition) => Boolean(definition)).map((definition) => definition()));
331
+ const plugins = await Promise.all(enabled.map(async (definition) => {
332
+ const plugin = await initializePlugin(definition).catch((err) => {
333
+ console.error("Failed to initialize plugin:", definition.meta.id, err);
334
+ return void 0;
335
+ });
336
+ return plugin;
337
+ })).then((plugins2) => plugins2.filter((plugin) => Boolean(plugin)));
338
+ log("plugins initialized", {
339
+ plugins
340
+ }, {
341
+ F: __dxlog_file,
342
+ L: 127,
343
+ S: void 0,
344
+ C: (f, a) => f(...a)
345
+ });
346
+ await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));
347
+ log("plugins ready", {
348
+ plugins
349
+ }, {
350
+ F: __dxlog_file,
351
+ L: 130,
352
+ S: void 0,
353
+ C: (f, a) => f(...a)
354
+ });
355
+ state.plugins = shallow(plugins);
356
+ state.ready = true;
357
+ } catch (err) {
358
+ setError(err);
359
+ }
360
+ });
361
+ return () => {
362
+ clearTimeout(timeout);
363
+ state.ready = false;
364
+ };
365
+ }, []);
366
+ if (error) {
367
+ throw error;
368
+ }
369
+ if (!state.ready) {
370
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, placeholder);
371
+ }
372
+ const ComposedContext = composeContext(state.plugins);
373
+ return /* @__PURE__ */ React3.createElement(ComposedContext, null, rootComponents(state.plugins));
374
+ };
375
+ var initializePlugin = async (pluginDefinition) => {
376
+ const provides = await pluginDefinition.initialize?.();
377
+ return {
378
+ ...pluginDefinition,
379
+ provides: {
380
+ ...pluginDefinition.provides,
381
+ ...provides
382
+ }
383
+ };
384
+ };
385
+ var rootComponents = (plugins) => {
386
+ return plugins.map((plugin) => {
387
+ const Component2 = plugin.provides.root;
388
+ if (Component2) {
389
+ return /* @__PURE__ */ React3.createElement(Component2, {
390
+ key: plugin.meta.id
391
+ });
392
+ } else {
393
+ return null;
394
+ }
395
+ }).filter((node) => Boolean(node));
396
+ };
397
+ var composeContext = (plugins) => {
398
+ return compose(plugins.map((p) => p.provides.context).filter(Boolean));
399
+ };
400
+ var compose = (contexts) => {
401
+ return [
402
+ ...contexts
403
+ ].reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React3.createElement(Acc, null, /* @__PURE__ */ React3.createElement(Next, null, children)));
404
+ };
405
+
374
406
  // packages/sdk/app-framework/src/App.tsx
375
407
  import React4 from "react";
376
408
  import { invariant } from "@dxos/invariant";
@@ -413,8 +445,8 @@ var createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }
413
445
  ]
414
446
  });
415
447
  const Context = host.provides.context;
416
- const Root = host.provides.root;
417
- return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root, null));
448
+ const Root2 = host.provides.root;
449
+ return () => /* @__PURE__ */ React4.createElement(Context, null, /* @__PURE__ */ React4.createElement(Root2, null));
418
450
  };
419
451
  export {
420
452
  ErrorBoundary,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/common/graph.ts", "../../../src/plugins/common/layout.ts", "../../../src/plugins/common/metadata.ts", "../../../src/plugins/common/settings.ts", "../../../src/plugins/common/translations.ts", "../../../src/plugins/PluginHost/plugin.ts", "../../../src/plugins/PluginHost/PluginContext.tsx", "../../../src/plugins/PluginHost/PluginHost.tsx", "../../../src/plugins/SurfacePlugin/helpers.ts", "../../../src/plugins/SurfacePlugin/ErrorBoundary.tsx", "../../../src/plugins/SurfacePlugin/Surface.tsx", "../../../src/App.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Graph, Node } from '@dxos/app-graph';\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Plugin } from '../PluginHost';\n\n/**\n * Provides for a plugin that exposes the application graph.\n */\nexport type GraphProvides = {\n graph: Graph;\n};\n\nexport type GraphBuilderProvides = {\n graph: {\n builder: (params: { parent: Node; plugins: Plugin[] }) => UnsubscribeCallback | void;\n };\n};\n\n/**\n * Type guard for graph plugins.\n */\nexport const parseGraphPlugin = (plugin: Plugin) =>\n (plugin.provides as any).graph?.root ? (plugin as Plugin<GraphProvides>) : undefined;\n\n/**\n * Type guard for graph builder plugins.\n */\nexport const parseGraphBuilderPlugin = (plugin: Plugin) =>\n (plugin.provides as any).graph?.builder ? (plugin as Plugin<GraphBuilderProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { z } from 'zod';\n\nimport type { Plugin } from '../PluginHost';\n\n//\n// Provides\n//\n\n/**\n * Basic state provided by a layout plugin.\n */\n// TODO(burdon): Josiah: why do we use zod here?\nexport const Layout = z.object({\n fullscreen: z.boolean(),\n sidebarOpen: z.boolean(),\n complementarySidebarOpen: z.boolean(),\n\n // TODO(burdon): Why do we have a single root?\n dialogOpen: z.boolean(),\n dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),\n\n popoverOpen: z.boolean(),\n popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),\n popoverAnchorId: z.string().optional(),\n\n // TODO(wittjosiah): Array?\n active: z.string().optional().describe('Id of the currently active item.'),\n // TODO(wittjosiah): History?\n previous: z.string().optional(),\n});\n\nexport type Layout = z.infer<typeof Layout>;\n\n/**\n * Provides for a plugin that can manage the app layout.\n */\nexport type LayoutProvides = {\n layout: Readonly<Layout>;\n};\n\n/**\n * Type guard for layout plugins.\n */\nexport const parseLayoutPlugin = (plugin: Plugin) => {\n const { success } = Layout.safeParse((plugin.provides as any).layout);\n return success ? (plugin as Plugin<LayoutProvides>) : undefined;\n};\n\n//\n// Intents\n//\n\nconst LAYOUT_ACTION = 'dxos.org/plugin/layout';\n// TODO(wittjosiah): Consider consolidating some action types (e.g. toggle).\nexport enum LayoutAction {\n TOGGLE_FULLSCREEN = `${LAYOUT_ACTION}/toggle-fullscreen`,\n TOGGLE_SIDEBAR = `${LAYOUT_ACTION}/toggle-sidebar`,\n TOGGLE_COMPLEMENTARY_SIDEBAR = `${LAYOUT_ACTION}/toggle-complementary-sidebar`,\n OPEN_DIALOG = `${LAYOUT_ACTION}/open-dialog`,\n CLOSE_DIALOG = `${LAYOUT_ACTION}/close-dialog`,\n OPEN_POPOVER = `${LAYOUT_ACTION}/open-popover`,\n CLOSE_POPOVER = `${LAYOUT_ACTION}/close-popover`,\n ACTIVATE = `${LAYOUT_ACTION}/activate`,\n FOCUS = `${LAYOUT_ACTION}/focus`,\n}\n\n/**\n * Expected payload for layout actions.\n */\nexport namespace LayoutAction {\n export type ToggleFullscreen = {\n state?: boolean;\n };\n\n export type ToggleSidebar = {\n state?: boolean;\n };\n\n export type ToggleComplementarySidebar = {\n state?: boolean;\n };\n\n export type OpenDialog = {\n component: string;\n subject: any;\n };\n\n export type CloseDialog = {};\n\n export type OpenPopover = {\n anchorId: string;\n component: string;\n subject: any;\n };\n\n export type ClosePopover = {};\n\n export type Activate = {\n id: string;\n };\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Plugin } from '../PluginHost';\n\nexport type Metadata = Record<string, any>;\n\nexport type MetadataRecordsProvides = {\n metadata: {\n records: Record<string, Metadata>;\n };\n};\n\nexport type MetadataResolver = (type: string) => Metadata;\n\nexport type MetadataResolverProvides = {\n metadata: {\n resolver: MetadataResolver;\n };\n};\n\nexport const parseMetadataRecordsPlugin = (plugin: Plugin) => {\n return (plugin.provides as any).metadata?.records ? (plugin as Plugin<MetadataRecordsProvides>) : undefined;\n};\n\nexport const parseMetadataResolverPlugin = (plugin: Plugin) => {\n return (plugin.provides as any).metadata?.resolver ? (plugin as Plugin<MetadataResolverProvides>) : undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '../PluginHost';\n\n// TODO(burdon): Plugins should export ts-effect object (see local-storage).\n// TODO(burdon): Auto generate form.\n// TODO(burdon): Set surface's data.type to plugin id (allow custom settings surface).\n\nexport type SettingsProvides<T extends Record<string, any> = Record<string, any>> = {\n settings: T; // TODO(burdon): Read-only.\n};\n\nexport const parseSettingsPlugin = (plugin: Plugin) => {\n return typeof (plugin.provides as any).settings === 'object' ? (plugin as Plugin<SettingsProvides>) : undefined;\n};\n\nconst SETTINGS_ACTION = 'dxos.org/plugin/settings';\nexport enum SettingsAction {\n OPEN = `${SETTINGS_ACTION}/open`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { z } from 'zod';\n\nimport type { Plugin } from '../PluginHost';\n\nexport const ResourceKey = z.union([z.string(), z.record(z.any())]);\nexport type ResourceKey = z.infer<typeof ResourceKey>;\n\nexport const ResourceLanguage = z.record(ResourceKey);\nexport type ResourceLanguage = z.infer<typeof ResourceLanguage>;\n\n/**\n * A resource is a collection of translations for a language.\n */\nexport const Resource = z.record(ResourceLanguage);\nexport type Resource = z.infer<typeof Resource>;\n\n/**\n * Provides for a plugin that exposes translations.\n */\n// TODO(wittjosiah): Rename to TranslationResourcesProvides.\nexport type TranslationsProvides = {\n translations: Readonly<Resource[]>;\n};\n\n// TODO(wittjosiah): Add TranslationsProvides.\n// export type TranslationsProvides = {\n// translations: {\n// t: TFunction;\n// };\n// };\n\n/**\n * Type guard for translation plugins.\n */\nexport const parseTranslationsPlugin = (plugin: Plugin) => {\n const { success } = z.array(Resource).safeParse((plugin.provides as any).translations);\n return success ? (plugin as Plugin<TranslationsProvides>) : undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { IconProps } from '@phosphor-icons/react';\nimport type { FC, PropsWithChildren } from 'react';\n\n/**\n * Capabilities provided by a plugin.\n * The base surface capabilities are always included.\n */\nexport type PluginProvides<TProvides> = TProvides & {\n /**\n * React Context which is wrapped around the application to enable any hooks the plugin may provide.\n */\n context?: FC<PropsWithChildren>;\n\n /*\n * React component which is rendered at the root of the application.\n */\n root?: FC<PropsWithChildren>;\n};\n\n/**\n * A unit of containment of modular functionality that can be provided to an application.\n * Plugins provide things like components, state, actions, etc. to the application.\n */\nexport type Plugin<TProvides = {}> = {\n meta: {\n /**\n * Globally unique ID.\n *\n * Expected to be in the form of a valid URL.\n *\n * @example dxos.org/plugin/example\n */\n id: string;\n\n /**\n * Short ID for use in URLs.\n *\n * NOTE: This is especially experimental and likely to change.\n */\n // TODO(wittjosiah): How should these be managed?\n shortId?: string;\n\n /**\n * Human-readable name.\n */\n name?: string;\n\n /**\n * Short description of plugin functionality.\n */\n description?: string;\n\n /**\n * URL of home page.\n */\n homePage?: string;\n\n /**\n * Tags to help categorize the plugin.\n */\n tags?: string[];\n\n /**\n * Component to render icon for the plugin when displayed in a list.\n */\n // TODO(wittjosiah): Convert to `icon` and make serializable.\n iconComponent?: FC<IconProps>;\n };\n\n /**\n * Capabilities provided by the plugin.\n */\n provides: PluginProvides<TProvides>;\n};\n\n/**\n * Plugin definitions extend the base `Plugin` interface with additional lifecycle methods.\n */\nexport type PluginDefinition<TProvides = {}, TInitializeProvides = {}> = Omit<Plugin, 'provides'> & {\n /**\n * Capabilities provided by the plugin.\n */\n provides?: Plugin<TProvides>['provides'];\n\n /**\n * Initialize any async behavior required by the plugin.\n *\n * @return Capabilities provided by the plugin which are merged with base capabilities.\n */\n initialize?: () => Promise<PluginProvides<TInitializeProvides>>;\n\n /**\n * Called once all plugins have been initialized.\n * This is the place to do any initialization which requires other plugins to be ready.\n *\n * @param plugins All plugins which successfully initialized.\n */\n ready?: (plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the plugin is unloaded.\n * This is the place to do any cleanup required by the plugin.\n */\n unload?: () => Promise<void>;\n};\n\nexport const pluginMeta = (meta: Plugin['meta']) => meta;\n\ntype LazyPlugin<T> = () => Promise<{ default: (props: T) => PluginDefinition }>;\n\nexport namespace Plugin {\n export const lazy = <T>(p: LazyPlugin<T>, props?: T) => {\n return () =>\n p().then(({ default: definition }) => {\n return definition(props as T);\n });\n };\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, type Provider, createContext, useContext } from 'react';\n\nimport { type Plugin } from './plugin';\nimport { findPlugin, resolvePlugin } from '../helpers';\n\nexport type PluginContext = {\n /**\n * All plugins are ready.\n */\n ready: boolean;\n\n /**\n * Ids of plugins which are enabled on this device.\n */\n enabled: string[];\n\n /**\n * Initialized and ready plugins.\n */\n plugins: Plugin[];\n\n /**\n * All available plugins.\n */\n available: Plugin['meta'][];\n\n /**\n * Mark plugin as enabled.\n * Requires reload to take effect.\n */\n setPlugin: (id: string, enabled: boolean) => void;\n};\n\nconst PluginContext: Context<PluginContext> = createContext<PluginContext>({\n ready: false,\n enabled: [],\n plugins: [],\n available: [],\n setPlugin: () => {},\n});\n\n/**\n * Get all plugins.\n */\nexport const usePlugins = (): PluginContext => useContext(PluginContext);\n\n/**\n * Get a plugin by ID.\n */\nexport const usePlugin = <T,>(id: string): Plugin<T> | undefined => {\n const { plugins } = usePlugins();\n return findPlugin<T>(plugins, id);\n};\n\n/**\n * Resolve a plugin by predicate.\n */\nexport const useResolvePlugin = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T> | undefined => {\n const { plugins } = usePlugins();\n return resolvePlugin(plugins, predicate);\n};\n\nexport const PluginProvider: Provider<PluginContext> = PluginContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { shallow } from 'deepsignal/react';\nimport React, { useEffect, type FC, type PropsWithChildren, type ReactNode } from 'react';\n\nimport { LocalStorageStore } from '@dxos/local-storage';\nimport { log } from '@dxos/log';\n\nimport { type PluginContext, PluginProvider } from './PluginContext';\nimport { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';\n\nexport type BootstrapPluginsParams = {\n order: PluginDefinition['meta'][];\n plugins: Record<string, () => Promise<PluginDefinition>>;\n core?: string[];\n defaults?: string[];\n fallback?: ReactNode;\n};\n\nexport type PluginHostProvides = {\n plugins: PluginContext;\n};\n\nexport const parsePluginHost = (plugin: Plugin) =>\n (plugin.provides as PluginHostProvides).plugins ? (plugin as Plugin<PluginHostProvides>) : undefined;\n\nconst PLUGIN_HOST = 'dxos.org/plugin/host';\n\n/**\n * Bootstraps an application by initializing plugins and rendering root components.\n */\nexport const PluginHost = ({\n order,\n plugins: definitions,\n core = [],\n defaults = [],\n fallback = null,\n}: BootstrapPluginsParams): PluginDefinition<PluginHostProvides> => {\n const state = new LocalStorageStore<PluginContext>(PLUGIN_HOST, {\n ready: false,\n enabled: [...defaults],\n plugins: [],\n available: order.filter(({ id }) => !core.includes(id)),\n setPlugin: (id: string, enabled: boolean) => {\n if (enabled) {\n state.values.enabled = [...state.values.enabled, id];\n } else {\n state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);\n }\n },\n });\n\n state.prop(state.values.$enabled!, 'enabled', LocalStorageStore.json);\n\n return {\n meta: {\n id: PLUGIN_HOST,\n name: 'Plugin host',\n },\n provides: {\n plugins: state.values,\n context: ({ children }) => <PluginProvider value={state.values}>{children}</PluginProvider>,\n root: () => {\n useEffect(() => {\n log('initializing plugins', { enabled: state.values.enabled });\n const timeout = setTimeout(async () => {\n const enabledIds = [...core, ...state.values.enabled].sort((a, b) => {\n const indexA = order.findIndex(({ id }) => id === a);\n const indexB = order.findIndex(({ id }) => id === b);\n return indexA - indexB;\n });\n\n const enabled = await Promise.all(\n enabledIds\n .map((id) => definitions[id])\n // If local storage indicates a plugin is enabled, but it is not available, ignore it.\n .filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))\n .map((definition) => definition()),\n );\n\n const plugins = await Promise.all(\n enabled.map(async (definition) => {\n const plugin = await initializePlugin(definition).catch((err) => {\n console.error('Failed to initialize plugin:', definition.meta.id, err);\n return undefined;\n });\n return plugin;\n }),\n ).then((plugins) => plugins.filter((plugin): plugin is Plugin => Boolean(plugin)));\n log('plugins initialized', { plugins });\n\n await Promise.all(\n enabled.map(async (pluginDefinition) => {\n await pluginDefinition.ready?.(plugins);\n }),\n );\n log('plugins ready', { plugins });\n\n state.values.plugins = shallow(plugins);\n state.values.ready = true;\n });\n\n return () => {\n clearTimeout(timeout);\n state.values.ready = false;\n // TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?\n // void Promise.all(enabled.map((definition) => definition.unload?.()));\n };\n }, []);\n\n if (!state.values.ready) {\n return <>{fallback}</>;\n }\n\n const ComposedContext = composeContext(state.values.plugins);\n\n return <ComposedContext>{rootComponents(state.values.plugins)}</ComposedContext>;\n },\n },\n };\n};\n\n/**\n * Resolve a `PluginDefinition` into a fully initialized `Plugin`.\n */\nexport const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {\n const provides = await pluginDefinition.initialize?.();\n return {\n ...pluginDefinition,\n provides: {\n ...pluginDefinition.provides,\n ...provides,\n } as PluginProvides<T & U>,\n };\n};\n\nconst rootComponents = (plugins: Plugin[]) => {\n return plugins\n .map((plugin) => {\n const Component = plugin.provides.root;\n if (Component) {\n return <Component key={plugin.meta.id} />;\n } else {\n return null;\n }\n })\n .filter((node): node is JSX.Element => Boolean(node));\n};\n\nconst composeContext = (plugins: Plugin[]) => {\n return compose(plugins.map((p) => p.provides.context!).filter(Boolean));\n};\n\nconst compose = (contexts: FC<PropsWithChildren>[]) => {\n return [...contexts].reduce((Acc, Next) => ({ children }) => (\n <Acc>\n <Next>{children}</Next>\n </Acc>\n ));\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Checks if the given data is an object and not null.\n *\n * Useful inside surface component resolvers as a type guard.\n *\n * @example\n * ```ts\n * const old =\n * data.content &&\n * typeof data.content === 'object' &&\n * 'id' in data.content &&\n * typeof data.content.id === 'string';\n *\n * // becomes\n * const new = isObject(data.content) && typeof data.content.id === 'string';\n * ```\n */\nexport const isObject = (data: unknown): data is { [key: string]: unknown } => !!data && typeof data === 'object';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { Component, type FC, type PropsWithChildren } from 'react';\n\ntype Props = PropsWithChildren<{ data?: any; fallback: FC<{ error: Error; reset: () => void }> }>;\ntype State = { error: Error | undefined };\n\n/**\n * Surface error boundary.\n *\n * For basic usage prefer providing a fallback component to `Surface`.\n *\n * For more information on error boundaries, see:\n * https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n */\nexport class ErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { error: undefined };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n override componentDidUpdate(prevProps: Props): void {\n if (prevProps.data !== this.props.data) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return <this.props.fallback error={this.state.error} reset={this.resetError} />;\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, {\n forwardRef,\n type FC,\n type ReactNode,\n Fragment,\n type ForwardedRef,\n type PropsWithChildren,\n isValidElement,\n} from 'react';\nimport { createContext, useContext } from 'react';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceComponent, useSurface, type SurfaceResult } from './SurfaceRootContext';\n\n/**\n * Direction determines how multiple components are laid out.\n */\nexport type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';\n\nexport type SurfaceProps = PropsWithChildren<{\n /**\n * Role defines how the data should be rendered.\n */\n role?: string;\n\n /**\n * Names allow nested surfaces to be specified in the parent context, similar to a slot.\n * Defaults to the value of `role` if not specified.\n */\n name?: string;\n\n /**\n * The data to be rendered by the surface.\n */\n data?: Record<string, unknown>;\n\n /**\n * Configure nested surfaces (indexed by the surface's `name`).\n */\n surfaces?: Record<string, Pick<SurfaceProps, 'data' | 'surfaces'>>;\n\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: ErrorBoundary['props']['fallback'];\n\n /**\n * If specified, this will render if no plugin can offer renderable content for the surface.\n *\n * @deprecated Provide a component with `disposition: 'fallback'` instead.\n */\n contentFallback?: FC<{}>;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n\n /**\n * If more than one component is resolved, the direction determines how they are laid out.\n * NOTE: This is not yet implemented.\n */\n direction?: Direction;\n\n /**\n * Additional props to pass to the component.\n * These props are not used by Surface itself but may be used by components which resolve the surface.\n */\n [key: string]: unknown;\n}>;\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = forwardRef<HTMLElement, SurfaceProps>(\n ({ role, name = role, fallback, ...rest }, forwardedRef) => {\n const props = { role, name, fallback, ...rest };\n const context = useContext(SurfaceContext);\n const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});\n\n return (\n <>\n {fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n <SurfaceResolver {...props} ref={forwardedRef} />\n </ErrorBoundary>\n ) : (\n <SurfaceResolver {...props} ref={forwardedRef} />\n )}\n </>\n );\n },\n);\n\nconst SurfaceContext = createContext<SurfaceProps | null>(null);\n\nconst SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {\n const { components } = useSurface();\n const parent = useContext(SurfaceContext);\n const nodes = resolveNodes(components, props, parent, forwardedRef);\n const currentContext: SurfaceProps = {\n ...props,\n surfaces: {\n ...((props.name && parent?.surfaces?.[props.name]?.surfaces) || {}),\n ...props.surfaces,\n },\n };\n\n return (\n <SurfaceContext.Provider value={currentContext}>\n {nodes.length > 0 ? nodes : props.contentFallback ? <props.contentFallback /> : null}\n </SurfaceContext.Provider>\n );\n});\n\nconst resolveNodes = (\n components: Record<string, SurfaceComponent>,\n props: SurfaceProps,\n context: SurfaceProps | null,\n forwardedRef: ForwardedRef<HTMLElement>,\n): ReactNode[] => {\n const data = {\n ...((props.name && context?.surfaces?.[props.name]?.data) || {}),\n ...props.data,\n };\n\n const nodes = Object.entries(components)\n .map(([key, component]): [string, SurfaceResult] | undefined => {\n const result = component({ ...props, data }, forwardedRef);\n if (!result || typeof result !== 'object') {\n return undefined;\n }\n\n return 'node' in result ? [key, result] : isValidElement(result) ? [key, { node: result }] : undefined;\n })\n .filter((result): result is [string, SurfaceResult] => Boolean(result))\n .sort(([, a], [, b]) => {\n const aDisposition = a.disposition ?? 'default';\n const bDisposition = b.disposition ?? 'default';\n\n if (aDisposition === bDisposition) {\n return 0;\n } else if (aDisposition === 'hoist' || bDisposition === 'fallback') {\n return -1;\n } else if (bDisposition === 'hoist' || aDisposition === 'fallback') {\n return 1;\n }\n\n return 0;\n })\n .map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);\n\n return props.limit ? nodes.slice(0, props.limit) : nodes;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { type BootstrapPluginsParams, PluginHost, Plugin } from './plugins';\nimport IntentMeta from './plugins/IntentPlugin/meta';\nimport SurfaceMeta from './plugins/SurfacePlugin/meta';\n\n/**\n * Expected usage is for this to be the entrypoint of the application.\n * Initializes plugins and renders the root components.\n *\n * @example\n * const order = [LayoutMeta, MyPluginMeta];\n * const plugins = {\n * [LayoutMeta.id]: Plugin.lazy(() => import('./plugins/LayoutPlugin/plugin')),\n * [MyPluginMeta.id]: Plugin.lazy(() => import('./plugins/MyPlugin/plugin')),\n * };\n * const core = [LayoutMeta.id];\n * const default = [MyPluginMeta.id];\n * const fallback = <div>Initializing Plugins...</div>;\n * const App = createApp({ order, plugins, core, default, fallback });\n * createRoot(document.getElementById('root')!).render(\n * <StrictMode>\n * <App />\n * </StrictMode>,\n * );\n *\n * @param params.order Total ordering of plugins.\n * @param params.plugins All plugins available to the application.\n * @param params.core Core plugins which will always be enabled.\n * @param params.default Default plugins are enabled by default but can be disabled by the user.\n * @param params.fallback Fallback component to render while plugins are initializing.\n */\nexport const createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }: BootstrapPluginsParams) => {\n const host = PluginHost({\n order: [SurfaceMeta, IntentMeta, ...order],\n plugins: {\n ...plugins,\n [SurfaceMeta.id]: Plugin.lazy(() => import('./plugins/SurfacePlugin/plugin')),\n [IntentMeta.id]: Plugin.lazy(() => import('./plugins/IntentPlugin/plugin')),\n },\n core: [SurfaceMeta.id, IntentMeta.id, ...core],\n ...params,\n });\n\n invariant(host.provides?.context);\n invariant(host.provides?.root);\n const Context = host.provides.context;\n const Root = host.provides.root;\n\n return () => (\n <Context>\n <Root />\n </Context>\n );\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAMA,mBAAmB,CAACC,WAC9BA,OAAOC,SAAiBC,OAAOC,OAAQH,SAAmCI;AAKtE,IAAMC,0BAA0B,CAACL,WACrCA,OAAOC,SAAiBC,OAAOI,UAAWN,SAA0CI;;;AC5BvF,SAASG,SAAS;AAYX,IAAMC,SAASC,EAAEC,OAAO;EAC7BC,YAAYF,EAAEG,QAAO;EACrBC,aAAaJ,EAAEG,QAAO;EACtBE,0BAA0BL,EAAEG,QAAO;;EAGnCG,YAAYN,EAAEG,QAAO;EACrBI,eAAeP,EAAEQ,IAAG,EAAGC,SAAQ,EAAGC,SAAS,0CAAA;EAE3CC,aAAaX,EAAEG,QAAO;EACtBS,gBAAgBZ,EAAEQ,IAAG,EAAGC,SAAQ,EAAGC,SAAS,2CAAA;EAC5CG,iBAAiBb,EAAEc,OAAM,EAAGL,SAAQ;;EAGpCM,QAAQf,EAAEc,OAAM,EAAGL,SAAQ,EAAGC,SAAS,kCAAA;;EAEvCM,UAAUhB,EAAEc,OAAM,EAAGL,SAAQ;AAC/B,CAAA;AAcO,IAAMQ,oBAAoB,CAACC,WAAAA;AAChC,QAAM,EAAEC,QAAO,IAAKpB,OAAOqB,UAAWF,OAAOG,SAAiBC,MAAM;AACpE,SAAOH,UAAWD,SAAoCK;AACxD;AAMA,IAAMC,gBAAgB;IAEf;UA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AAY,CAAC,EAAEC,OAAOC,SAASC,OAAOF,MAAMG,IAAI,CAAC,EAAEC,GAAE,MAAOA,EAAAA,GAAK,GAAGC,OAAAA,MAAgC;AAC/G,QAAMC,OAAOC,WAAW;IACtBP,OAAO;MAACQ;MAAaC;SAAeT;;IACpCC,SAAS;MACP,GAAGA;MACH,CAACO,cAAYJ,EAAE,GAAGM,OAAOC,KAAK,MAAM,OAAO,uBAAA,CAAA;MAC3C,CAACF,aAAWL,EAAE,GAAGM,OAAOC,KAAK,MAAM,OAAO,uBAAA,CAAA;IAC5C;IACAT,MAAM;MAACM,cAAYJ;MAAIK,aAAWL;SAAOF;;IACzC,GAAGG;EACL,CAAA;AAEAO,YAAUN,KAAKO,UAAUC,SAAAA,QAAAA;;;;;;;;;AACzBF,YAAUN,KAAKO,UAAUE,MAAAA,QAAAA;;;;;;;;;AACzB,QAAMC,UAAUV,KAAKO,SAASC;AAC9B,QAAMG,OAAOX,KAAKO,SAASE;AAE3B,SAAO,MACL,gBAAAG,OAAA,cAACF,SAAAA,MACC,gBAAAE,OAAA,cAACD,MAAAA,IAAAA,CAAAA;AAGP;",
6
- "names": ["parseGraphPlugin", "plugin", "provides", "graph", "root", "undefined", "parseGraphBuilderPlugin", "builder", "z", "Layout", "z", "object", "fullscreen", "boolean", "sidebarOpen", "complementarySidebarOpen", "dialogOpen", "dialogContent", "any", "optional", "describe", "popoverOpen", "popoverContent", "popoverAnchorId", "string", "active", "previous", "parseLayoutPlugin", "plugin", "success", "safeParse", "provides", "layout", "undefined", "LAYOUT_ACTION", "LayoutAction", "TOGGLE_FULLSCREEN", "TOGGLE_SIDEBAR", "TOGGLE_COMPLEMENTARY_SIDEBAR", "OPEN_DIALOG", "CLOSE_DIALOG", "OPEN_POPOVER", "CLOSE_POPOVER", "ACTIVATE", "FOCUS", "parseMetadataRecordsPlugin", "plugin", "provides", "metadata", "records", "undefined", "parseMetadataResolverPlugin", "resolver", "parseSettingsPlugin", "plugin", "provides", "settings", "undefined", "SETTINGS_ACTION", "SettingsAction", "OPEN", "z", "ResourceKey", "z", "union", "string", "record", "any", "ResourceLanguage", "Resource", "parseTranslationsPlugin", "plugin", "success", "array", "safeParse", "provides", "translations", "undefined", "pluginMeta", "meta", "Plugin", "lazy", "p", "props", "then", "default", "definition", "createContext", "useContext", "PluginContext", "createContext", "ready", "enabled", "plugins", "available", "setPlugin", "usePlugins", "useContext", "usePlugin", "id", "findPlugin", "useResolvePlugin", "predicate", "resolvePlugin", "PluginProvider", "Provider", "shallow", "React", "useEffect", "LocalStorageStore", "log", "parsePluginHost", "plugin", "provides", "plugins", "undefined", "PLUGIN_HOST", "PluginHost", "order", "definitions", "core", "defaults", "fallback", "state", "LocalStorageStore", "ready", "enabled", "available", "filter", "id", "includes", "setPlugin", "values", "prop", "$enabled", "json", "meta", "name", "context", "children", "PluginProvider", "value", "root", "useEffect", "log", "timeout", "setTimeout", "enabledIds", "sort", "a", "b", "indexA", "findIndex", "indexB", "Promise", "all", "map", "definition", "Boolean", "initializePlugin", "catch", "err", "console", "error", "then", "pluginDefinition", "shallow", "clearTimeout", "ComposedContext", "composeContext", "rootComponents", "initialize", "Component", "key", "node", "compose", "p", "contexts", "reduce", "Acc", "Next", "isObject", "data", "React", "Component", "ErrorBoundary", "Component", "constructor", "props", "state", "error", "undefined", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "data", "resetError", "render", "React", "this", "fallback", "reset", "children", "setState", "React", "forwardRef", "Fragment", "isValidElement", "createContext", "useContext", "Surface", "forwardRef", "role", "name", "fallback", "rest", "forwardedRef", "props", "context", "useContext", "SurfaceContext", "data", "surfaces", "React", "ErrorBoundary", "SurfaceResolver", "ref", "createContext", "components", "useSurface", "parent", "nodes", "resolveNodes", "currentContext", "Provider", "value", "length", "contentFallback", "Object", "entries", "map", "key", "component", "result", "undefined", "isValidElement", "node", "filter", "Boolean", "sort", "a", "b", "aDisposition", "disposition", "bDisposition", "Fragment", "limit", "slice", "React", "invariant", "createApp", "order", "plugins", "core", "map", "id", "params", "host", "PluginHost", "SurfaceMeta", "IntentMeta", "Plugin", "lazy", "invariant", "provides", "context", "root", "Context", "Root", "React"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Graph, Node } from '@dxos/app-graph';\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Plugin } from '../PluginHost';\n\n/**\n * Provides for a plugin that exposes the application graph.\n */\nexport type GraphProvides = {\n graph: Graph;\n};\n\nexport type GraphBuilderProvides = {\n graph: {\n builder: (params: { parent: Node; plugins: Plugin[] }) => UnsubscribeCallback | void;\n };\n};\n\n/**\n * Type guard for graph plugins.\n */\nexport const parseGraphPlugin = (plugin: Plugin) =>\n (plugin.provides as any).graph?.root ? (plugin as Plugin<GraphProvides>) : undefined;\n\n/**\n * Type guard for graph builder plugins.\n */\nexport const parseGraphBuilderPlugin = (plugin: Plugin) =>\n (plugin.provides as any).graph?.builder ? (plugin as Plugin<GraphBuilderProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { z } from 'zod';\n\nimport type { Plugin } from '../PluginHost';\n\n//\n// Provides\n//\n\n/**\n * Basic state provided by a layout plugin.\n */\n// TODO(burdon): Josiah: why do we use zod here?\nexport const Layout = z.object({\n fullscreen: z.boolean(),\n sidebarOpen: z.boolean(),\n complementarySidebarOpen: z.boolean(),\n\n // TODO(burdon): Why do we have a single root?\n dialogOpen: z.boolean(),\n dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),\n\n popoverOpen: z.boolean(),\n popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),\n popoverAnchorId: z.string().optional(),\n\n // TODO(wittjosiah): Array?\n active: z.string().optional().describe('Id of the currently active item.'),\n // TODO(wittjosiah): History?\n previous: z.string().optional(),\n});\n\nexport type Layout = z.infer<typeof Layout>;\n\n/**\n * Provides for a plugin that can manage the app layout.\n */\nexport type LayoutProvides = {\n layout: Readonly<Layout>;\n};\n\n/**\n * Type guard for layout plugins.\n */\nexport const parseLayoutPlugin = (plugin: Plugin) => {\n const { success } = Layout.safeParse((plugin.provides as any).layout);\n return success ? (plugin as Plugin<LayoutProvides>) : undefined;\n};\n\n//\n// Intents\n//\n\nconst LAYOUT_ACTION = 'dxos.org/plugin/layout';\n// TODO(wittjosiah): Consider consolidating some action types (e.g. toggle).\nexport enum LayoutAction {\n TOGGLE_FULLSCREEN = `${LAYOUT_ACTION}/toggle-fullscreen`,\n TOGGLE_SIDEBAR = `${LAYOUT_ACTION}/toggle-sidebar`,\n TOGGLE_COMPLEMENTARY_SIDEBAR = `${LAYOUT_ACTION}/toggle-complementary-sidebar`,\n OPEN_DIALOG = `${LAYOUT_ACTION}/open-dialog`,\n CLOSE_DIALOG = `${LAYOUT_ACTION}/close-dialog`,\n OPEN_POPOVER = `${LAYOUT_ACTION}/open-popover`,\n CLOSE_POPOVER = `${LAYOUT_ACTION}/close-popover`,\n ACTIVATE = `${LAYOUT_ACTION}/activate`,\n FOCUS = `${LAYOUT_ACTION}/focus`,\n}\n\n/**\n * Expected payload for layout actions.\n */\nexport namespace LayoutAction {\n export type ToggleFullscreen = {\n state?: boolean;\n };\n\n export type ToggleSidebar = {\n state?: boolean;\n };\n\n export type ToggleComplementarySidebar = {\n state?: boolean;\n };\n\n export type OpenDialog = {\n component: string;\n subject: any;\n };\n\n export type CloseDialog = {};\n\n export type OpenPopover = {\n anchorId: string;\n component: string;\n subject: any;\n };\n\n export type ClosePopover = {};\n\n export type Activate = {\n id: string;\n };\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { Plugin } from '../PluginHost';\n\nexport type Metadata = Record<string, any>;\n\nexport type MetadataRecordsProvides = {\n metadata: {\n records: Record<string, Metadata>;\n };\n};\n\nexport type MetadataResolver = (type: string) => Metadata;\n\nexport type MetadataResolverProvides = {\n metadata: {\n resolver: MetadataResolver;\n };\n};\n\nexport const parseMetadataRecordsPlugin = (plugin: Plugin) => {\n return (plugin.provides as any).metadata?.records ? (plugin as Plugin<MetadataRecordsProvides>) : undefined;\n};\n\nexport const parseMetadataResolverPlugin = (plugin: Plugin) => {\n return (plugin.provides as any).metadata?.resolver ? (plugin as Plugin<MetadataResolverProvides>) : undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '../PluginHost';\n\n// TODO(burdon): Plugins should export ts-effect object (see local-storage).\n// TODO(burdon): Auto generate form.\n// TODO(burdon): Set surface's data.type to plugin id (allow custom settings surface).\n\nexport type SettingsProvides<T extends Record<string, any> = Record<string, any>> = {\n settings: T; // TODO(burdon): Read-only.\n};\n\nexport const parseSettingsPlugin = (plugin: Plugin) => {\n return typeof (plugin.provides as any).settings === 'object' ? (plugin as Plugin<SettingsProvides>) : undefined;\n};\n\nconst SETTINGS_ACTION = 'dxos.org/plugin/settings';\nexport enum SettingsAction {\n OPEN = `${SETTINGS_ACTION}/open`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { z } from 'zod';\n\nimport type { Plugin } from '../PluginHost';\n\nexport const ResourceKey = z.union([z.string(), z.record(z.any())]);\nexport type ResourceKey = z.infer<typeof ResourceKey>;\n\nexport const ResourceLanguage = z.record(ResourceKey);\nexport type ResourceLanguage = z.infer<typeof ResourceLanguage>;\n\n/**\n * A resource is a collection of translations for a language.\n */\nexport const Resource = z.record(ResourceLanguage);\nexport type Resource = z.infer<typeof Resource>;\n\n/**\n * Provides for a plugin that exposes translations.\n */\n// TODO(wittjosiah): Rename to TranslationResourcesProvides.\nexport type TranslationsProvides = {\n translations: Readonly<Resource[]>;\n};\n\n// TODO(wittjosiah): Add TranslationsProvides.\n// export type TranslationsProvides = {\n// translations: {\n// t: TFunction;\n// };\n// };\n\n/**\n * Type guard for translation plugins.\n */\nexport const parseTranslationsPlugin = (plugin: Plugin) => {\n const { success } = z.array(Resource).safeParse((plugin.provides as any).translations);\n return success ? (plugin as Plugin<TranslationsProvides>) : undefined;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { IconProps } from '@phosphor-icons/react';\nimport type { FC, PropsWithChildren } from 'react';\n\n/**\n * Capabilities provided by a plugin.\n * The base surface capabilities are always included.\n */\nexport type PluginProvides<TProvides> = TProvides & {\n /**\n * React Context which is wrapped around the application to enable any hooks the plugin may provide.\n */\n context?: FC<PropsWithChildren>;\n\n /*\n * React component which is rendered at the root of the application.\n */\n root?: FC<PropsWithChildren>;\n};\n\n/**\n * A unit of containment of modular functionality that can be provided to an application.\n * Plugins provide things like components, state, actions, etc. to the application.\n */\nexport type Plugin<TProvides = {}> = {\n meta: {\n /**\n * Globally unique ID.\n *\n * Expected to be in the form of a valid URL.\n *\n * @example dxos.org/plugin/example\n */\n id: string;\n\n /**\n * Short ID for use in URLs.\n *\n * NOTE: This is especially experimental and likely to change.\n */\n // TODO(wittjosiah): How should these be managed?\n shortId?: string;\n\n /**\n * Human-readable name.\n */\n name?: string;\n\n /**\n * Short description of plugin functionality.\n */\n description?: string;\n\n /**\n * URL of home page.\n */\n homePage?: string;\n\n /**\n * Tags to help categorize the plugin.\n */\n tags?: string[];\n\n /**\n * Component to render icon for the plugin when displayed in a list.\n */\n // TODO(wittjosiah): Convert to `icon` and make serializable.\n iconComponent?: FC<IconProps>;\n };\n\n /**\n * Capabilities provided by the plugin.\n */\n provides: PluginProvides<TProvides>;\n};\n\n/**\n * Plugin definitions extend the base `Plugin` interface with additional lifecycle methods.\n */\nexport type PluginDefinition<TProvides = {}, TInitializeProvides = {}> = Omit<Plugin, 'provides'> & {\n /**\n * Capabilities provided by the plugin.\n */\n provides?: Plugin<TProvides>['provides'];\n\n /**\n * Initialize any async behavior required by the plugin.\n *\n * @return Capabilities provided by the plugin which are merged with base capabilities.\n */\n initialize?: () => Promise<PluginProvides<TInitializeProvides>>;\n\n /**\n * Called once all plugins have been initialized.\n * This is the place to do any initialization which requires other plugins to be ready.\n *\n * @param plugins All plugins which successfully initialized.\n */\n // TODO(wittjosiah): Rename `ready` to a verb?\n ready?: (plugins: Plugin[]) => Promise<void>;\n\n /**\n * Called when the plugin is unloaded.\n * This is the place to do any cleanup required by the plugin.\n */\n unload?: () => Promise<void>;\n};\n\nexport const pluginMeta = (meta: Plugin['meta']) => meta;\n\ntype LazyPlugin<T> = () => Promise<{ default: (props: T) => PluginDefinition }>;\n\nexport namespace Plugin {\n export const lazy = <T>(p: LazyPlugin<T>, props?: T) => {\n return () =>\n p().then(({ default: definition }) => {\n return definition(props as T);\n });\n };\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, type Provider, createContext, useContext } from 'react';\n\nimport { type Plugin } from './plugin';\nimport { findPlugin, resolvePlugin } from '../helpers';\n\nexport type PluginContext = {\n /**\n * All plugins are ready.\n */\n ready: boolean;\n\n /**\n * Ids of plugins which are enabled on this device.\n */\n enabled: string[];\n\n /**\n * Initialized and ready plugins.\n */\n plugins: Plugin[];\n\n /**\n * All available plugins.\n */\n available: Plugin['meta'][];\n\n /**\n * Mark plugin as enabled.\n * Requires reload to take effect.\n */\n setPlugin: (id: string, enabled: boolean) => void;\n};\n\nconst PluginContext: Context<PluginContext> = createContext<PluginContext>({\n ready: false,\n enabled: [],\n plugins: [],\n available: [],\n setPlugin: () => {},\n});\n\n/**\n * Get all plugins.\n */\nexport const usePlugins = (): PluginContext => useContext(PluginContext);\n\n/**\n * Get a plugin by ID.\n */\nexport const usePlugin = <T,>(id: string): Plugin<T> | undefined => {\n const { plugins } = usePlugins();\n return findPlugin<T>(plugins, id);\n};\n\n/**\n * Resolve a plugin by predicate.\n */\nexport const useResolvePlugin = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T> | undefined => {\n const { plugins } = usePlugins();\n return resolvePlugin(plugins, predicate);\n};\n\nexport const PluginProvider: Provider<PluginContext> = PluginContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { shallow } from 'deepsignal/react';\nimport React, { useEffect, type FC, type PropsWithChildren, type ReactNode, useState } from 'react';\n\nimport { LocalStorageStore } from '@dxos/local-storage';\nimport { log } from '@dxos/log';\n\nimport { type PluginContext, PluginProvider } from './PluginContext';\nimport { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';\nimport { ErrorBoundary } from '../SurfacePlugin';\n\nexport type BootstrapPluginsParams = {\n order: PluginDefinition['meta'][];\n plugins: Record<string, () => Promise<PluginDefinition>>;\n core?: string[];\n defaults?: string[];\n fallback?: ErrorBoundary['props']['fallback'];\n placeholder?: ReactNode;\n};\n\nexport type PluginHostProvides = {\n plugins: PluginContext;\n};\n\nexport const parsePluginHost = (plugin: Plugin) =>\n (plugin.provides as PluginHostProvides).plugins ? (plugin as Plugin<PluginHostProvides>) : undefined;\n\nconst PLUGIN_HOST = 'dxos.org/plugin/host';\n\n/**\n * Bootstraps an application by initializing plugins and rendering root components.\n */\nexport const PluginHost = ({\n order,\n plugins: definitions,\n core = [],\n defaults = [],\n fallback = DefaultFallback,\n placeholder = null,\n}: BootstrapPluginsParams): PluginDefinition<PluginHostProvides> => {\n const state = new LocalStorageStore<PluginContext>(PLUGIN_HOST, {\n ready: false,\n enabled: [...defaults],\n plugins: [],\n available: order.filter(({ id }) => !core.includes(id)),\n setPlugin: (id: string, enabled: boolean) => {\n if (enabled) {\n state.values.enabled = [...state.values.enabled, id];\n } else {\n state.values.enabled = state.values.enabled.filter((enabled) => enabled !== id);\n }\n },\n });\n\n state.prop(state.values.$enabled!, 'enabled', LocalStorageStore.json);\n\n return {\n meta: {\n id: PLUGIN_HOST,\n name: 'Plugin host',\n },\n provides: {\n plugins: state.values,\n context: ({ children }) => <PluginProvider value={state.values}>{children}</PluginProvider>,\n root: () => {\n return (\n <ErrorBoundary fallback={fallback}>\n <Root order={order} core={core} definitions={definitions} state={state.values} placeholder={placeholder} />\n </ErrorBoundary>\n );\n },\n },\n };\n};\n\nconst DefaultFallback = ({ error }: { error: Error }) => {\n return (\n <div style={{ padding: '1rem' }}>\n {/* TODO(wittjosiah): Link to docs for replacing default. */}\n <h1 style={{ fontSize: '1.2rem', fontWeight: 700, margin: '0.5rem 0' }}>{error.message}</h1>\n <pre>{error.stack}</pre>\n </div>\n );\n};\n\ntype RootProps = {\n order: PluginDefinition['meta'][];\n state: PluginContext;\n definitions: Record<string, () => Promise<PluginDefinition>>;\n core: string[];\n placeholder: ReactNode;\n};\n\nconst Root = ({ order, core: corePluginIds, definitions, state, placeholder }: RootProps) => {\n const [error, setError] = useState<unknown>();\n\n useEffect(() => {\n log('initializing plugins', { enabled: state.enabled });\n const timeout = setTimeout(async () => {\n try {\n const enabledIds = [...corePluginIds, ...state.enabled].sort((a, b) => {\n const indexA = order.findIndex(({ id }) => id === a);\n const indexB = order.findIndex(({ id }) => id === b);\n return indexA - indexB;\n });\n\n const enabled = await Promise.all(\n enabledIds\n .map((id) => definitions[id])\n // If local storage indicates a plugin is enabled, but it is not available, ignore it.\n .filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))\n .map((definition) => definition()),\n );\n\n const plugins = await Promise.all(\n enabled.map(async (definition) => {\n const plugin = await initializePlugin(definition).catch((err) => {\n console.error('Failed to initialize plugin:', definition.meta.id, err);\n return undefined;\n });\n return plugin;\n }),\n ).then((plugins) => plugins.filter((plugin): plugin is Plugin => Boolean(plugin)));\n log('plugins initialized', { plugins });\n\n await Promise.all(enabled.map((pluginDefinition) => pluginDefinition.ready?.(plugins)));\n log('plugins ready', { plugins });\n\n state.plugins = shallow(plugins);\n state.ready = true;\n } catch (err) {\n setError(err);\n }\n });\n\n return () => {\n clearTimeout(timeout);\n state.ready = false;\n // TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?\n // void Promise.all(enabled.map((definition) => definition.unload?.()));\n };\n }, []);\n\n if (error) {\n throw error;\n }\n\n if (!state.ready) {\n return <>{placeholder}</>;\n }\n\n const ComposedContext = composeContext(state.plugins);\n\n return <ComposedContext>{rootComponents(state.plugins)}</ComposedContext>;\n};\n\n/**\n * Resolve a `PluginDefinition` into a fully initialized `Plugin`.\n */\nexport const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {\n const provides = await pluginDefinition.initialize?.();\n return {\n ...pluginDefinition,\n provides: {\n ...pluginDefinition.provides,\n ...provides,\n } as PluginProvides<T & U>,\n };\n};\n\nconst rootComponents = (plugins: Plugin[]) => {\n return plugins\n .map((plugin) => {\n const Component = plugin.provides.root;\n if (Component) {\n return <Component key={plugin.meta.id} />;\n } else {\n return null;\n }\n })\n .filter((node): node is JSX.Element => Boolean(node));\n};\n\nconst composeContext = (plugins: Plugin[]) => {\n return compose(plugins.map((p) => p.provides.context!).filter(Boolean));\n};\n\nconst compose = (contexts: FC<PropsWithChildren>[]) => {\n return [...contexts].reduce((Acc, Next) => ({ children }) => (\n <Acc>\n <Next>{children}</Next>\n </Acc>\n ));\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Checks if the given data is an object and not null.\n *\n * Useful inside surface component resolvers as a type guard.\n *\n * @example\n * ```ts\n * const old =\n * data.content &&\n * typeof data.content === 'object' &&\n * 'id' in data.content &&\n * typeof data.content.id === 'string';\n *\n * // becomes\n * const new = isObject(data.content) && typeof data.content.id === 'string';\n * ```\n */\nexport const isObject = (data: unknown): data is { [key: string]: unknown } => !!data && typeof data === 'object';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { Component, type FC, type PropsWithChildren } from 'react';\n\ntype Props = PropsWithChildren<{ data?: any; fallback: FC<{ error: Error; reset: () => void }> }>;\ntype State = { error: Error | undefined };\n\n/**\n * Surface error boundary.\n *\n * For basic usage prefer providing a fallback component to `Surface`.\n *\n * For more information on error boundaries, see:\n * https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n */\nexport class ErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { error: undefined };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n override componentDidUpdate(prevProps: Props): void {\n if (prevProps.data !== this.props.data) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return <this.props.fallback error={this.state.error} reset={this.resetError} />;\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, {\n forwardRef,\n type FC,\n type ReactNode,\n Fragment,\n type ForwardedRef,\n type PropsWithChildren,\n isValidElement,\n} from 'react';\nimport { createContext, useContext } from 'react';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceComponent, useSurface, type SurfaceResult } from './SurfaceRootContext';\n\n/**\n * Direction determines how multiple components are laid out.\n */\nexport type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';\n\nexport type SurfaceProps = PropsWithChildren<{\n /**\n * Role defines how the data should be rendered.\n */\n role?: string;\n\n /**\n * Names allow nested surfaces to be specified in the parent context, similar to a slot.\n * Defaults to the value of `role` if not specified.\n */\n name?: string;\n\n /**\n * The data to be rendered by the surface.\n */\n data?: Record<string, unknown>;\n\n /**\n * Configure nested surfaces (indexed by the surface's `name`).\n */\n surfaces?: Record<string, Pick<SurfaceProps, 'data' | 'surfaces'>>;\n\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: ErrorBoundary['props']['fallback'];\n\n /**\n * If specified, this will render if no plugin can offer renderable content for the surface.\n *\n * @deprecated Provide a component with `disposition: 'fallback'` instead.\n */\n contentFallback?: FC<{}>;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n\n /**\n * If more than one component is resolved, the direction determines how they are laid out.\n * NOTE: This is not yet implemented.\n */\n direction?: Direction;\n\n /**\n * Additional props to pass to the component.\n * These props are not used by Surface itself but may be used by components which resolve the surface.\n */\n [key: string]: unknown;\n}>;\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = forwardRef<HTMLElement, SurfaceProps>(\n ({ role, name = role, fallback, ...rest }, forwardedRef) => {\n const props = { role, name, fallback, ...rest };\n const context = useContext(SurfaceContext);\n const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});\n\n return (\n <>\n {fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n <SurfaceResolver {...props} ref={forwardedRef} />\n </ErrorBoundary>\n ) : (\n <SurfaceResolver {...props} ref={forwardedRef} />\n )}\n </>\n );\n },\n);\n\nconst SurfaceContext = createContext<SurfaceProps | null>(null);\n\nconst SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {\n const { components } = useSurface();\n const parent = useContext(SurfaceContext);\n const nodes = resolveNodes(components, props, parent, forwardedRef);\n const currentContext: SurfaceProps = {\n ...props,\n surfaces: {\n ...((props.name && parent?.surfaces?.[props.name]?.surfaces) || {}),\n ...props.surfaces,\n },\n };\n\n return (\n <SurfaceContext.Provider value={currentContext}>\n {nodes.length > 0 ? nodes : props.contentFallback ? <props.contentFallback /> : null}\n </SurfaceContext.Provider>\n );\n});\n\nconst resolveNodes = (\n components: Record<string, SurfaceComponent>,\n props: SurfaceProps,\n context: SurfaceProps | null,\n forwardedRef: ForwardedRef<HTMLElement>,\n): ReactNode[] => {\n const data = {\n ...((props.name && context?.surfaces?.[props.name]?.data) || {}),\n ...props.data,\n };\n\n const nodes = Object.entries(components)\n .map(([key, component]): [string, SurfaceResult] | undefined => {\n const result = component({ ...props, data }, forwardedRef);\n if (!result || typeof result !== 'object') {\n return undefined;\n }\n\n return 'node' in result ? [key, result] : isValidElement(result) ? [key, { node: result }] : undefined;\n })\n .filter((result): result is [string, SurfaceResult] => Boolean(result))\n .sort(([, a], [, b]) => {\n const aDisposition = a.disposition ?? 'default';\n const bDisposition = b.disposition ?? 'default';\n\n if (aDisposition === bDisposition) {\n return 0;\n } else if (aDisposition === 'hoist' || bDisposition === 'fallback') {\n return -1;\n } else if (bDisposition === 'hoist' || aDisposition === 'fallback') {\n return 1;\n }\n\n return 0;\n })\n .map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);\n\n return props.limit ? nodes.slice(0, props.limit) : nodes;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { type BootstrapPluginsParams, PluginHost, Plugin } from './plugins';\nimport IntentMeta from './plugins/IntentPlugin/meta';\nimport SurfaceMeta from './plugins/SurfacePlugin/meta';\n\n/**\n * Expected usage is for this to be the entrypoint of the application.\n * Initializes plugins and renders the root components.\n *\n * @example\n * const order = [LayoutMeta, MyPluginMeta];\n * const plugins = {\n * [LayoutMeta.id]: Plugin.lazy(() => import('./plugins/LayoutPlugin/plugin')),\n * [MyPluginMeta.id]: Plugin.lazy(() => import('./plugins/MyPlugin/plugin')),\n * };\n * const core = [LayoutMeta.id];\n * const default = [MyPluginMeta.id];\n * const fallback = <div>Initializing Plugins...</div>;\n * const App = createApp({ order, plugins, core, default, fallback });\n * createRoot(document.getElementById('root')!).render(\n * <StrictMode>\n * <App />\n * </StrictMode>,\n * );\n *\n * @param params.order Total ordering of plugins.\n * @param params.plugins All plugins available to the application.\n * @param params.core Core plugins which will always be enabled.\n * @param params.default Default plugins are enabled by default but can be disabled by the user.\n * @param params.fallback Fallback component to render while plugins are initializing.\n */\nexport const createApp = ({ order, plugins, core = order.map(({ id }) => id), ...params }: BootstrapPluginsParams) => {\n const host = PluginHost({\n order: [SurfaceMeta, IntentMeta, ...order],\n plugins: {\n ...plugins,\n [SurfaceMeta.id]: Plugin.lazy(() => import('./plugins/SurfacePlugin/plugin')),\n [IntentMeta.id]: Plugin.lazy(() => import('./plugins/IntentPlugin/plugin')),\n },\n core: [SurfaceMeta.id, IntentMeta.id, ...core],\n ...params,\n });\n\n invariant(host.provides?.context);\n invariant(host.provides?.root);\n const Context = host.provides.context;\n const Root = host.provides.root;\n\n return () => (\n <Context>\n <Root />\n </Context>\n );\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,IAAMA,mBAAmB,CAACC,WAC9BA,OAAOC,SAAiBC,OAAOC,OAAQH,SAAmCI;AAKtE,IAAMC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OC,KAAK,MAAM,OAAO,uBAAA,CAAA;MAC3C,CAACF,aAAWL,EAAE,GAAGM,OAAOC,KAAK,MAAM,OAAO,uBAAA,CAAA;IAC5C;IACAT,MAAM;MAACM,cAAYJ;MAAIK,aAAWL;SAAOF;;IACzC,GAAGG;EACL,CAAA;AAEAO,YAAUN,KAAKO,UAAUC,SAAAA,QAAAA;;;;;;;;;AACzBF,YAAUN,KAAKO,UAAUE,MAAAA,QAAAA;;;;;;;;;AACzB,QAAMC,UAAUV,KAAKO,SAASC;AAC9B,QAAMG,QAAOX,KAAKO,SAASE;AAE3B,SAAO,MACL,gBAAAG,OAAA,cAACF,SAAAA,MACC,gBAAAE,OAAA,cAACD,OAAAA,IAAAA,CAAAA;AAGP;",
6
+ "names": ["parseGraphPlugin", "plugin", "provides", "graph", "root", "undefined", "parseGraphBuilderPlugin", "builder", "z", "Layout", "z", "object", "fullscreen", "boolean", "sidebarOpen", "complementarySidebarOpen", "dialogOpen", "dialogContent", "any", "optional", "describe", "popoverOpen", "popoverContent", "popoverAnchorId", "string", "active", "previous", "parseLayoutPlugin", "plugin", "success", "safeParse", "provides", "layout", "undefined", "LAYOUT_ACTION", "LayoutAction", "parseMetadataRecordsPlugin", "plugin", "provides", "metadata", "records", "undefined", "parseMetadataResolverPlugin", "resolver", "parseSettingsPlugin", "plugin", "provides", "settings", "undefined", "SETTINGS_ACTION", "SettingsAction", "z", "ResourceKey", "z", "union", "string", "record", "any", "ResourceLanguage", "Resource", "parseTranslationsPlugin", "plugin", "success", "array", "safeParse", "provides", "translations", "undefined", "pluginMeta", "meta", "Plugin", "lazy", "p", "props", "then", "default", "definition", "createContext", "useContext", "PluginContext", "createContext", "ready", "enabled", "plugins", "available", "setPlugin", "usePlugins", "useContext", "usePlugin", "id", "findPlugin", "useResolvePlugin", "predicate", "resolvePlugin", "PluginProvider", "Provider", "shallow", "React", "useEffect", "useState", "LocalStorageStore", "log", "isObject", "data", "React", "Component", "ErrorBoundary", "Component", "constructor", "props", "state", "error", "undefined", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "data", "resetError", "render", "this", "fallback", "reset", "children", "setState", "React", "forwardRef", "Fragment", "isValidElement", "createContext", "useContext", "Surface", "forwardRef", "role", "name", "fallback", "rest", "forwardedRef", "props", "context", "useContext", "SurfaceContext", "data", "surfaces", "React", "ErrorBoundary", "SurfaceResolver", "ref", "createContext", "components", "useSurface", "parent", "nodes", "resolveNodes", "currentContext", "Provider", "value", "length", "contentFallback", "Object", "entries", "map", "key", "component", "result", "undefined", "isValidElement", "node", "filter", "Boolean", "sort", "a", "b", "aDisposition", "disposition", "bDisposition", "Fragment", "limit", "slice", "parsePluginHost", "plugin", "provides", "plugins", "undefined", "PLUGIN_HOST", "PluginHost", "order", "definitions", "core", "defaults", "fallback", "DefaultFallback", "placeholder", "state", "LocalStorageStore", "ready", "enabled", "available", "filter", "id", "includes", "setPlugin", "values", "prop", "$enabled", "json", "meta", "name", "context", "children", "React", "PluginProvider", "value", "root", "ErrorBoundary", "Root", "error", "div", "style", "padding", "h1", "fontSize", "fontWeight", "margin", "message", "pre", "stack", "corePluginIds", "setError", "useState", "useEffect", "log", "timeout", "setTimeout", "enabledIds", "sort", "a", "b", "indexA", "findIndex", "indexB", "Promise", "all", "map", "definition", "Boolean", "initializePlugin", "catch", "err", "console", "then", "pluginDefinition", "shallow", "clearTimeout", "ComposedContext", "composeContext", "rootComponents", "initialize", "Component", "key", "node", "compose", "p", "contexts", "reduce", "Acc", "Next", "React", "invariant", "createApp", "order", "plugins", "core", "map", "id", "params", "host", "PluginHost", "SurfaceMeta", "IntentMeta", "Plugin", "lazy", "invariant", "provides", "context", "root", "Context", "Root", "React"]
7
7
  }