@dxos/app-framework 0.7.2 → 0.7.3-staging.0905f03

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 (49) hide show
  1. package/dist/lib/browser/{chunk-EQTQGGE6.mjs → chunk-FRXJ25VI.mjs} +2 -2
  2. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-CDLQO5K2.mjs → chunk-YXM35XRE.mjs} +2 -2
  4. package/dist/lib/browser/{chunk-CDLQO5K2.mjs.map → chunk-YXM35XRE.mjs.map} +1 -1
  5. package/dist/lib/browser/index.mjs +11 -6
  6. package/dist/lib/browser/index.mjs.map +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/{plugin-intent-Q5KFPKFA.mjs → plugin-intent-LU4KL2RO.mjs} +2 -2
  9. package/dist/lib/browser/{plugin-surface-ZQXFAL46.mjs → plugin-surface-LECZMKSQ.mjs} +2 -2
  10. package/dist/lib/node/{chunk-VOKMWTKO.cjs → chunk-QSVP5HOW.cjs} +6 -6
  11. package/dist/lib/node/{chunk-VOKMWTKO.cjs.map → chunk-QSVP5HOW.cjs.map} +1 -1
  12. package/dist/lib/node/{chunk-EF67TRWJ.cjs → chunk-SOVLKUWI.cjs} +6 -6
  13. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +7 -0
  14. package/dist/lib/node/index.cjs +33 -28
  15. package/dist/lib/node/index.cjs.map +3 -3
  16. package/dist/lib/node/meta.json +1 -1
  17. package/dist/lib/node/{plugin-intent-FMC4SDI3.cjs → plugin-intent-FVFR2LKB.cjs} +13 -13
  18. package/dist/lib/node/{plugin-intent-FMC4SDI3.cjs.map → plugin-intent-FVFR2LKB.cjs.map} +2 -2
  19. package/dist/lib/node/{plugin-surface-B5NHOBSW.cjs → plugin-surface-YWDRXQTD.cjs} +14 -14
  20. package/dist/lib/node/{plugin-surface-B5NHOBSW.cjs.map → plugin-surface-YWDRXQTD.cjs.map} +2 -2
  21. package/dist/lib/node-esm/{chunk-3FCLBEOX.mjs → chunk-2R4GVK7O.mjs} +2 -2
  22. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +7 -0
  23. package/dist/lib/node-esm/{chunk-MYNXI5VG.mjs → chunk-YFMFQBB4.mjs} +2 -2
  24. package/dist/lib/node-esm/{chunk-MYNXI5VG.mjs.map → chunk-YFMFQBB4.mjs.map} +1 -1
  25. package/dist/lib/node-esm/index.mjs +11 -6
  26. package/dist/lib/node-esm/index.mjs.map +3 -3
  27. package/dist/lib/node-esm/meta.json +1 -1
  28. package/dist/lib/node-esm/{plugin-intent-KETLP7UL.mjs → plugin-intent-V7ER24Y6.mjs} +2 -2
  29. package/dist/lib/node-esm/{plugin-surface-QXQRR534.mjs → plugin-surface-TEU42XQN.mjs} +2 -2
  30. package/dist/types/src/plugins/common/layout.d.ts +7 -0
  31. package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
  32. package/dist/types/src/plugins/common/navigation.d.ts +1 -1
  33. package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
  34. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +1 -1
  35. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +1 -2
  36. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +1 -1
  37. package/package.json +12 -11
  38. package/src/plugins/common/layout.ts +6 -0
  39. package/src/plugins/common/navigation.ts +4 -2
  40. package/src/plugins/plugin-intent/IntentPlugin.tsx +3 -3
  41. package/src/plugins/plugin-surface/SurfacePlugin.tsx +1 -1
  42. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +1 -2
  43. package/dist/lib/browser/chunk-EQTQGGE6.mjs.map +0 -7
  44. package/dist/lib/node/chunk-EF67TRWJ.cjs.map +0 -7
  45. package/dist/lib/node-esm/chunk-3FCLBEOX.mjs.map +0 -7
  46. /package/dist/lib/browser/{plugin-intent-Q5KFPKFA.mjs.map → plugin-intent-LU4KL2RO.mjs.map} +0 -0
  47. /package/dist/lib/browser/{plugin-surface-ZQXFAL46.mjs.map → plugin-surface-LECZMKSQ.mjs.map} +0 -0
  48. /package/dist/lib/node-esm/{plugin-intent-KETLP7UL.mjs.map → plugin-intent-V7ER24Y6.mjs.map} +0 -0
  49. /package/dist/lib/node-esm/{plugin-surface-QXQRR534.mjs.map → plugin-surface-TEU42XQN.mjs.map} +0 -0
@@ -54,6 +54,7 @@ export declare const Layout: z.ZodObject<{
54
54
  dialogOpen: z.ZodBoolean;
55
55
  dialogContent: z.ZodOptional<z.ZodAny>;
56
56
  dialogBlockAlign: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"start">, z.ZodLiteral<"center">]>>;
57
+ dialogType: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"default">, z.ZodLiteral<"alert">]>>;
57
58
  popoverOpen: z.ZodBoolean;
58
59
  popoverContent: z.ZodOptional<z.ZodAny>;
59
60
  popoverAnchorId: z.ZodOptional<z.ZodString>;
@@ -109,6 +110,7 @@ export declare const Layout: z.ZodObject<{
109
110
  complementarySidebarContent?: any;
110
111
  dialogContent?: any;
111
112
  dialogBlockAlign?: "center" | "start" | undefined;
113
+ dialogType?: "default" | "alert" | undefined;
112
114
  popoverContent?: any;
113
115
  popoverAnchorId?: string | undefined;
114
116
  scrollIntoView?: string | undefined;
@@ -132,6 +134,7 @@ export declare const Layout: z.ZodObject<{
132
134
  complementarySidebarContent?: any;
133
135
  dialogContent?: any;
134
136
  dialogBlockAlign?: "center" | "start" | undefined;
137
+ dialogType?: "default" | "alert" | undefined;
135
138
  popoverContent?: any;
136
139
  popoverAnchorId?: string | undefined;
137
140
  scrollIntoView?: string | undefined;
@@ -189,6 +192,10 @@ export declare namespace LayoutAction {
189
192
  * Block alignment for the dialog.
190
193
  */
191
194
  dialogBlockAlign?: 'start' | 'center';
195
+ /**
196
+ * Type of dialog.
197
+ */
198
+ dialogType?: 'default' | 'alert';
192
199
  }>;
193
200
  }
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;;;;;;;;;;;;;;;;;;;EAsBH,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAAY,MAAM,uCAG/C,CAAC;AAUF,oBAAY,YAAY;IACtB,UAAU,6CAAgC;IAC1C,eAAe,kDAAqC;IACpD,gBAAgB,mDAAsC;IACtD,iBAAiB,oDAAuC;CACzD;AAED;;GAEG;AACH,yBAAiB,YAAY,CAAC;IAC5B,KAAY,aAAa,GAAG,UAAU,CAAC;QACrC,UAAU,CAAC,EAAE,UAAU,CAAC;QACxB,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC,CAAC;IAEH,KAAY,SAAS,GAAG,UAAU,CAAC;QACjC;;WAEG;QACH,OAAO,EAAE,YAAY,GAAG,SAAS,GAAG,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;QAErF;;;;;WAKG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;QAEhB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,OAAO,CAAC,EAAE,GAAG,CAAC;QAEd;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAIlB;;WAEG;QACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;QAEtC;;WAEG;QACH,UAAU,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;KAClC,CAAC,CAAC;CACJ"}
@@ -142,7 +142,7 @@ export declare const parseNavigationPlugin: (plugin: Plugin) => Plugin<LocationP
142
142
  * Utilities.
143
143
  */
144
144
  /** Extracts all unique IDs from the layout parts. */
145
- export declare const openIds: (layout: LayoutParts) => string[];
145
+ export declare const openIds: (layout: LayoutParts, parts?: LayoutPart[]) => string[];
146
146
  export declare const firstIdInPart: (layout: LayoutParts | undefined, part: LayoutPart) => string | undefined;
147
147
  export declare const indexInPart: (layout: LayoutParts | undefined, layoutCoordinate: LayoutCoordinate | undefined) => number | undefined;
148
148
  export declare const partLength: (layout: LayoutParts | undefined, part: LayoutPart | undefined) => number;
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/common/navigation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,QAAA,MAAM,iBAAiB;;;GAAoE,CAAC;AAC5F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAIlE,QAAA,MAAM,gBAAgB,sIAMrB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAEtB,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,QAAA,MAAM,sBAAsB;;;GAAqE,CAAC;AAClG,MAAM,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AAgC;CACvC;AAED;;GAEG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;OAEG;IACH,KAAY,IAAI,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAE5D;;OAEG;IACH,KAAY,WAAW,GAAG,UAAU,CAAC;QACnC,IAAI,EAAE,UAAU,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;KAC/B,CAAC,CAAC;IAEH;;OAEG;IACH,KAAY,KAAK,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAEjF;;OAEG;IACH,KAAY,GAAG,GAAG,UAAU,CAAC;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAE3D;;OAEG;IACH,KAAY,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;CACnD"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntentPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/plugin-intent/IntentPlugin.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,gBAAgB,CAAC,oBAAoB,CAyHpE,CAAC"}
1
+ {"version":3,"file":"IntentPlugin.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/plugin-intent/IntentPlugin.tsx"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAO,gBAAgB,CAAC,oBAAoB,CAyHpE,CAAC"}
@@ -22,8 +22,7 @@ export type SurfaceResult = {
22
22
  disposition?: SurfaceDisposition;
23
23
  };
24
24
  /**
25
- * Function which resolves a Surface.
26
- *
25
+ * Function that resolves a Surface.
27
26
  * If a null value is returned, the rendering is deferred to other plugins.
28
27
  */
29
28
  export type SurfaceComponent = (props: SurfaceComponentProps, forwardedRef: ForwardedRef<HTMLElement>) => JSX.Element | SurfaceResult | null;
@@ -1 +1 @@
1
- {"version":3,"file":"SurfaceRootContext.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/plugin-surface/SurfaceRootContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA6B,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAI/E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAG9C,KAAK,oBAAoB,CAAC,IAAI,EAAE,GAAG,SAAS,MAAM,IAAI,IAAI,IAAI,GAAG;KAC9D,QAAQ,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;CACpC,CAAC;AAEF,KAAK,qBAAqB,GAAG,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,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,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,KAAK,EAAE,qBAAqB,EAC5B,YAAY,EAAE,YAAY,CAAC,WAAW,CAAC,KACpC,GAAG,CAAC,OAAO,GAAG,aAAa,GAAG,IAAI,CAAC;AAExC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE7C;;OAEG;IACH,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACpC,CAAC;AAIF,eAAO,MAAM,cAAc,0BAAyF,CAAC;AAErH,eAAO,MAAM,eAAe,0DAA8B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/app-framework",
3
- "version": "0.7.2",
3
+ "version": "0.7.3-staging.0905f03",
4
4
  "description": "A framework for building applications from composible plugins.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -23,16 +23,17 @@
23
23
  "@phosphor-icons/react": "^2.1.5",
24
24
  "@preact/signals-core": "^1.6.0",
25
25
  "zod": "^3.22.4",
26
- "@dxos/app-graph": "0.7.2",
27
- "@dxos/async": "0.7.2",
28
- "@dxos/context": "0.7.2",
29
- "@dxos/client-protocol": "0.7.2",
30
- "@dxos/echo-schema": "0.7.2",
31
- "@dxos/invariant": "0.7.2",
32
- "@dxos/debug": "0.7.2",
33
- "@dxos/local-storage": "0.7.2",
34
- "@dxos/log": "0.7.2",
35
- "@dxos/util": "0.7.2"
26
+ "@dxos/async": "0.7.3-staging.0905f03",
27
+ "@dxos/client-protocol": "0.7.3-staging.0905f03",
28
+ "@dxos/app-graph": "0.7.3-staging.0905f03",
29
+ "@dxos/context": "0.7.3-staging.0905f03",
30
+ "@dxos/debug": "0.7.3-staging.0905f03",
31
+ "@dxos/echo-schema": "0.7.3-staging.0905f03",
32
+ "@dxos/invariant": "0.7.3-staging.0905f03",
33
+ "@dxos/live-object": "0.7.3-staging.0905f03",
34
+ "@dxos/local-storage": "0.7.3-staging.0905f03",
35
+ "@dxos/log": "0.7.3-staging.0905f03",
36
+ "@dxos/util": "0.7.3-staging.0905f03"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/react": "~18.2.0",
@@ -56,6 +56,7 @@ export const Layout = z.object({
56
56
  dialogContent: z.any().optional().describe('Data to be passed to the dialog Surface.'),
57
57
  // TODO(wittjosiah): Custom properties?
58
58
  dialogBlockAlign: z.union([z.literal('start'), z.literal('center')]).optional(),
59
+ dialogType: z.union([z.literal('default'), z.literal('alert')]).optional(),
59
60
 
60
61
  popoverOpen: z.boolean(),
61
62
  popoverContent: z.any().optional().describe('Data to be passed to the popover Surface.'),
@@ -145,5 +146,10 @@ export namespace LayoutAction {
145
146
  * Block alignment for the dialog.
146
147
  */
147
148
  dialogBlockAlign?: 'start' | 'center';
149
+
150
+ /**
151
+ * Type of dialog.
152
+ */
153
+ dialogType?: 'default' | 'alert';
148
154
  }>;
149
155
  }
@@ -5,6 +5,8 @@
5
5
  import { Schema as S } from '@effect/schema';
6
6
  import { z } from 'zod';
7
7
 
8
+ import { pick } from '@dxos/util';
9
+
8
10
  import { type Plugin } from '../plugin-host';
9
11
  import { type IntentData } from '../plugin-intent';
10
12
 
@@ -95,8 +97,8 @@ export const parseNavigationPlugin = (plugin: Plugin): Plugin<LocationProvides>
95
97
  */
96
98
 
97
99
  /** Extracts all unique IDs from the layout parts. */
98
- export const openIds = (layout: LayoutParts): string[] => {
99
- return Object.values(layout)
100
+ export const openIds = (layout: LayoutParts, parts?: LayoutPart[]): string[] => {
101
+ return Object.values(parts ? pick(layout, parts) : layout)
100
102
  .flatMap((part) => part?.map((entry) => entry.id) ?? [])
101
103
  .filter((id): id is string => id !== undefined);
102
104
  };
@@ -4,18 +4,18 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { create } from '@dxos/echo-schema';
7
+ import { create } from '@dxos/live-object';
8
8
  import { log } from '@dxos/log';
9
9
 
10
- import { type IntentContext, IntentProvider, type IntentExecution } from './IntentContext';
10
+ import { type IntentContext, type IntentExecution, IntentProvider } from './IntentContext';
11
11
  import { isUndoable } from './helpers';
12
12
  import type { Intent, IntentResolver } from './intent';
13
13
  import IntentMeta from './meta';
14
14
  import {
15
+ IntentAction,
15
16
  type IntentPluginProvides,
16
17
  type IntentResolverProvides,
17
18
  parseIntentResolverPlugin,
18
- IntentAction,
19
19
  } from './provides';
20
20
  import { filterPlugins, findPlugin } from '../helpers';
21
21
  import { type PluginDefinition } from '../plugin-host';
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { create } from '@dxos/echo-schema';
7
+ import { create } from '@dxos/live-object';
8
8
 
9
9
  import { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';
10
10
  import SurfaceMeta from './meta';
@@ -36,8 +36,7 @@ export type SurfaceResult = {
36
36
  };
37
37
 
38
38
  /**
39
- * Function which resolves a Surface.
40
- *
39
+ * Function that resolves a Surface.
41
40
  * If a null value is returned, the rendering is deferred to other plugins.
42
41
  */
43
42
  export type SurfaceComponent = (
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-surface/SurfacePlugin.tsx", "../../../src/plugins/plugin-surface/SurfaceRootContext.tsx", "../../../src/plugins/plugin-surface/meta.ts", "../../../src/plugins/plugin-surface/provides.ts", "../../../src/plugins/plugin-surface/helpers.ts", "../../../src/plugins/plugin-surface/ErrorBoundary.tsx", "../../../src/plugins/plugin-surface/Surface.tsx", "../../../src/plugins/plugin-surface/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\n/**\n * Provides a registry of surface components.\n */\nexport const SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\n\n/**\n * Surface debug info.\n * NOTE: Short-term measure to track perf issues.\n */\nexport type DebugInfo = {\n id: string;\n created: number;\n renderCount: number;\n} & Pick<SurfaceProps, 'role' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../plugin-host';\n\n// TODO(burdon): Predicate based providers?\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\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<{ data?: any; 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 data={this.props.data} 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 Fragment,\n type ForwardedRef,\n type PropsWithChildren,\n type ReactNode,\n Suspense,\n createContext,\n forwardRef,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useState,\n} from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceComponent, type SurfaceResult, useSurfaceRoot } from './SurfaceRootContext';\n\n/**\n * Direction determines how multiple components are laid out.\n */\nexport type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';\n\n/**\n * SurfaceProps are the props that are passed to the Surface component.\n */\nexport type SurfaceProps = PropsWithChildren<{\n /**\n * Optional ID for debugging.\n */\n id?: string;\n\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, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\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\nlet count = 0;\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = memo(\n forwardRef<HTMLElement, SurfaceProps>(\n ({ id: _id, role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {\n const props = { role, name, fallback, ...rest };\n const { debugInfo } = useSurfaceRoot();\n\n // Track debug info.\n const [id] = useState<string>(() => _id ?? `surface-${++count}`);\n useEffect(() => {\n debugInfo?.set(id, { id, created: Date.now(), name, role, renderCount: 0 });\n return () => {\n debugInfo?.delete(id);\n };\n }, [id]);\n\n if (debugInfo?.get(id)) {\n debugInfo.get(id)!.renderCount++;\n }\n\n const context = useContext(SurfaceContext);\n const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});\n\n const resolver = <SurfaceResolver {...props} id={id} ref={forwardedRef} />;\n const suspense = placeholder ? <Suspense fallback={placeholder}>{resolver}</Suspense> : resolver;\n\n return fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n {suspense}\n </ErrorBoundary>\n ) : (\n suspense\n );\n },\n ),\n);\n\nconst SurfaceContext = createContext<SurfaceProps | undefined>(undefined);\n\nexport const useSurface = (): SurfaceProps =>\n useContext(SurfaceContext) ?? raise(new Error('Surface context not found'));\n\n/**\n * Root surface component.\n */\nconst SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {\n const { components } = useSurfaceRoot();\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 <SurfaceContext.Provider value={currentContext}>{nodes}</SurfaceContext.Provider>;\n});\n\n/**\n * Resolve surface nodes from across all component.\n */\nconst resolveNodes = (\n components: Record<string, SurfaceComponent>,\n props: SurfaceProps,\n context: SurfaceProps | undefined,\n forwardedRef: ForwardedRef<HTMLElement>,\n): ReactNode[] => {\n const data = {\n ...((props.name && context?.surfaces?.[props.name]?.data) || {}),\n ...props.data,\n };\n\n const candidates = Object.entries(components)\n .map(([key, component]): [string, SurfaceResult] | undefined => {\n // TODO(burdon): Avoid variable return types in plugin contract.\n const result = component({ ...props, data }, forwardedRef);\n if (!result || typeof result !== 'object') {\n return undefined;\n }\n\n // Normalize tuple.\n if ('node' in result) {\n return [key, result];\n } else if (isValidElement(result)) {\n return [key, { node: result }];\n } else {\n log.warn('invalid result', { result });\n return undefined;\n }\n })\n .filter((result): result is [string, SurfaceResult] => Boolean(result))\n .sort(([, { disposition: a = 'default' }], [, { disposition: b = 'default' }]) => {\n return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;\n });\n\n // TODO(burdon): Does this prematurely process the node?\n const nodes = candidates.map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);\n return props.limit ? nodes.slice(0, props.limit) : nodes;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SurfacePlugin } from './SurfacePlugin';\n\nexport * from './helpers';\nexport * from './provides';\n\nexport * from './ErrorBoundary';\nexport * from './Surface';\nexport * from './SurfaceRootContext';\n\nexport default SurfacePlugin;\n"],
5
- "mappings": ";;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAc;;;ACFvB,SAASC,eAAeC,kBAA+C;AAEvE,SAASC,aAAa;AAkDtB,IAAMC,qBAAqBC,8BAA8CC,MAAAA;AAElE,IAAMC,iBAAiB,MAAMC,WAAWJ,kBAAAA,KAAuBK,MAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBP,mBAAmBQ;;;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;;;ACaR,IAAME,yBAAyB,CAACC,WACpCA,QAAQC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AAAA,CAAAA,EAC9DO,KAAK,CAAC,CAAA,EAAG,EAAEC,aAAaC,IAAI,UAAS,CAAE,GAAG,CAAA,EAAG,EAAED,aAAaE,IAAI,UAAS,CAAE,MAAC;AAC3E,WAAOD,MAAMC,IAAI,IAAID,MAAM,WAAWC,MAAM,aAAa,KAAKA,MAAM,WAAWD,MAAM,aAAa,IAAI;EACxG,CAAA;AAGF,QAAMpB,QAAQK,WAAWG,IAAI,CAAC,CAACC,KAAKE,MAAAA,MAAY,gBAAAxB,OAAA,cAACmC,UAAAA;IAASb;KAAWE,OAAOE,IAAI,CAAA;AAChF,SAAO5C,MAAMsD,QAAQvB,MAAMwB,MAAM,GAAGvD,MAAMsD,KAAK,IAAIvB;AACrD;;;ACrLA,IAAA,yBAAeyB;",
6
- "names": ["React", "create", "createContext", "useContext", "raise", "SurfaceRootContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id", "parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfacePlugin", "state", "create", "components", "debugInfo", "Map", "meta", "SurfaceMeta", "ready", "plugins", "filterPlugins", "parseSurfacePlugin", "reduce", "acc", "plugin", "id", "provides", "surface", "component", "context", "children", "SurfaceProvider", "value", "isObject", "data", "React", "Component", "ErrorBoundary", "Component", "constructor", "props", "state", "error", "undefined", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "data", "resetError", "render", "React", "this", "fallback", "reset", "children", "setState", "React", "Fragment", "Suspense", "createContext", "forwardRef", "isValidElement", "memo", "useContext", "useEffect", "useState", "raise", "log", "count", "Surface", "memo", "forwardRef", "id", "_id", "role", "name", "fallback", "placeholder", "rest", "forwardedRef", "props", "debugInfo", "useSurfaceRoot", "useState", "useEffect", "set", "created", "Date", "now", "renderCount", "delete", "get", "context", "useContext", "SurfaceContext", "data", "surfaces", "resolver", "React", "SurfaceResolver", "ref", "suspense", "Suspense", "ErrorBoundary", "createContext", "undefined", "useSurface", "raise", "Error", "components", "parent", "nodes", "resolveNodes", "currentContext", "Provider", "value", "candidates", "Object", "entries", "map", "key", "component", "result", "isValidElement", "node", "log", "warn", "filter", "Boolean", "sort", "disposition", "a", "b", "Fragment", "limit", "slice", "SurfacePlugin"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-surface/SurfacePlugin.tsx", "../../../src/plugins/plugin-surface/SurfaceRootContext.tsx", "../../../src/plugins/plugin-surface/meta.ts", "../../../src/plugins/plugin-surface/provides.ts", "../../../src/plugins/plugin-surface/helpers.ts", "../../../src/plugins/plugin-surface/ErrorBoundary.tsx", "../../../src/plugins/plugin-surface/Surface.tsx", "../../../src/plugins/plugin-surface/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\n/**\n * Provides a registry of surface components.\n */\nexport const SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\n\n/**\n * Surface debug info.\n * NOTE: Short-term measure to track perf issues.\n */\nexport type DebugInfo = {\n id: string;\n created: number;\n renderCount: number;\n} & Pick<SurfaceProps, 'role' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../plugin-host';\n\n// TODO(burdon): Predicate based providers?\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\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<{ data?: any; 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 data={this.props.data} 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 Fragment,\n type ForwardedRef,\n type PropsWithChildren,\n type ReactNode,\n Suspense,\n createContext,\n forwardRef,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useState,\n} from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceComponent, type SurfaceResult, useSurfaceRoot } from './SurfaceRootContext';\n\n/**\n * Direction determines how multiple components are laid out.\n */\nexport type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';\n\n/**\n * SurfaceProps are the props that are passed to the Surface component.\n */\nexport type SurfaceProps = PropsWithChildren<{\n /**\n * Optional ID for debugging.\n */\n id?: string;\n\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, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\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\nlet count = 0;\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = memo(\n forwardRef<HTMLElement, SurfaceProps>(\n ({ id: _id, role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {\n const props = { role, name, fallback, ...rest };\n const { debugInfo } = useSurfaceRoot();\n\n // Track debug info.\n const [id] = useState<string>(() => _id ?? `surface-${++count}`);\n useEffect(() => {\n debugInfo?.set(id, { id, created: Date.now(), name, role, renderCount: 0 });\n return () => {\n debugInfo?.delete(id);\n };\n }, [id]);\n\n if (debugInfo?.get(id)) {\n debugInfo.get(id)!.renderCount++;\n }\n\n const context = useContext(SurfaceContext);\n const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});\n\n const resolver = <SurfaceResolver {...props} id={id} ref={forwardedRef} />;\n const suspense = placeholder ? <Suspense fallback={placeholder}>{resolver}</Suspense> : resolver;\n\n return fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n {suspense}\n </ErrorBoundary>\n ) : (\n suspense\n );\n },\n ),\n);\n\nconst SurfaceContext = createContext<SurfaceProps | undefined>(undefined);\n\nexport const useSurface = (): SurfaceProps =>\n useContext(SurfaceContext) ?? raise(new Error('Surface context not found'));\n\n/**\n * Root surface component.\n */\nconst SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {\n const { components } = useSurfaceRoot();\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 <SurfaceContext.Provider value={currentContext}>{nodes}</SurfaceContext.Provider>;\n});\n\n/**\n * Resolve surface nodes from across all component.\n */\nconst resolveNodes = (\n components: Record<string, SurfaceComponent>,\n props: SurfaceProps,\n context: SurfaceProps | undefined,\n forwardedRef: ForwardedRef<HTMLElement>,\n): ReactNode[] => {\n const data = {\n ...((props.name && context?.surfaces?.[props.name]?.data) || {}),\n ...props.data,\n };\n\n const candidates = Object.entries(components)\n .map(([key, component]): [string, SurfaceResult] | undefined => {\n // TODO(burdon): Avoid variable return types in plugin contract.\n const result = component({ ...props, data }, forwardedRef);\n if (!result || typeof result !== 'object') {\n return undefined;\n }\n\n // Normalize tuple.\n if ('node' in result) {\n return [key, result];\n } else if (isValidElement(result)) {\n return [key, { node: result }];\n } else {\n log.warn('invalid result', { result });\n return undefined;\n }\n })\n .filter((result): result is [string, SurfaceResult] => Boolean(result))\n .sort(([, { disposition: a = 'default' }], [, { disposition: b = 'default' }]) => {\n return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;\n });\n\n // TODO(burdon): Does this prematurely process the node?\n const nodes = candidates.map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);\n return props.limit ? nodes.slice(0, props.limit) : nodes;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SurfacePlugin } from './SurfacePlugin';\n\nexport * from './helpers';\nexport * from './provides';\n\nexport * from './ErrorBoundary';\nexport * from './Surface';\nexport * from './SurfaceRootContext';\n\nexport default SurfacePlugin;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,yBAAuB;ACFvB,IAAAA,gBAAuE;AAEvE,mBAAsB;AIFtB,IAAAA,gBAAkE;ACAlE,IAAAA,gBAaO;AAEP,IAAAC,gBAAsB;AACtB,iBAAoB;ALoCpB,IAAMC,qBAAqBC,iDAA8CC,MAAAA;AAElE,IAAMC,iBAAiB,UAAMC,0BAAWJ,kBAAAA,SAAuBK,oBAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBP,mBAAmBQ;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;ACaR,IAAME,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CV;AAExF,IAAMc,qBAAqB,CAACJ,WAChCA,QAAQC,UAAkBC,SAASG,YAAaL,SAAqCV;AHRjF,IAAMgB,gBAAgB,MAAA;AAC3B,QAAMC,YAAQC,2BAA2B;IAAEL,YAAY,CAAC;IAAGM,WAAW,oBAAIC,IAAAA;EAAM,CAAA;AAEhF,SAAO;IACLC,MAAMd;IACNe,OAAO,OAAOC,YAAAA;AACZN,YAAMJ,iBAAaW,qCAAcD,SAAST,kBAAAA,EAAoBW,OAAO,CAACC,KAAKhB,WAAAA;AACzE,eAAO;UAAE,GAAGgB;UAAK,CAAChB,OAAOW,KAAKb,EAAE,GAAGE,OAAOC,SAASC,QAAQG;QAAU;MACvE,GAAG,CAAC,CA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RootContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id", "parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "parseSurfacePlugin", "component", "SurfacePlugin", "state", "create", "debugInfo", "Map", "meta", "ready", "plugins", "filterPlugins", "reduce", "acc", "context", "children", "React", "value", "isObject", "data", "ErrorBoundary", "Component", "constructor", "props", "error", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "resetError", "render", "this", "fallback", "reset", "setState", "count", "Surface", "memo", "forwardRef", "_id", "role", "name", "placeholder", "rest", "forwardedRef", "useState", "useEffect", "set", "created", "Date", "now", "renderCount", "delete", "get", "SurfaceContext", "surfaces", "resolver", "SurfaceResolver", "ref", "suspense", "Suspense", "useSurface", "parent", "nodes", "resolveNodes", "currentContext", "candidates", "Object", "entries", "map", "key", "result", "isValidElement", "node", "log", "warn", "filter", "Boolean", "sort", "disposition", "a", "b", "Fragment", "limit", "slice"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-surface/SurfacePlugin.tsx", "../../../src/plugins/plugin-surface/SurfaceRootContext.tsx", "../../../src/plugins/plugin-surface/meta.ts", "../../../src/plugins/plugin-surface/provides.ts", "../../../src/plugins/plugin-surface/helpers.ts", "../../../src/plugins/plugin-surface/ErrorBoundary.tsx", "../../../src/plugins/plugin-surface/Surface.tsx", "../../../src/plugins/plugin-surface/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\n/**\n * Provides a registry of surface components.\n */\nexport const SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\n\n/**\n * Surface debug info.\n * NOTE: Short-term measure to track perf issues.\n */\nexport type DebugInfo = {\n id: string;\n created: number;\n renderCount: number;\n} & Pick<SurfaceProps, 'role' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../plugin-host';\n\n// TODO(burdon): Predicate based providers?\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\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<{ data?: any; 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 data={this.props.data} 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 Fragment,\n type ForwardedRef,\n type PropsWithChildren,\n type ReactNode,\n Suspense,\n createContext,\n forwardRef,\n isValidElement,\n memo,\n useContext,\n useEffect,\n useState,\n} from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { log } from '@dxos/log';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceComponent, type SurfaceResult, useSurfaceRoot } from './SurfaceRootContext';\n\n/**\n * Direction determines how multiple components are laid out.\n */\nexport type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';\n\n/**\n * SurfaceProps are the props that are passed to the Surface component.\n */\nexport type SurfaceProps = PropsWithChildren<{\n /**\n * Optional ID for debugging.\n */\n id?: string;\n\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, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\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\nlet count = 0;\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = memo(\n forwardRef<HTMLElement, SurfaceProps>(\n ({ id: _id, role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {\n const props = { role, name, fallback, ...rest };\n const { debugInfo } = useSurfaceRoot();\n\n // Track debug info.\n const [id] = useState<string>(() => _id ?? `surface-${++count}`);\n useEffect(() => {\n debugInfo?.set(id, { id, created: Date.now(), name, role, renderCount: 0 });\n return () => {\n debugInfo?.delete(id);\n };\n }, [id]);\n\n if (debugInfo?.get(id)) {\n debugInfo.get(id)!.renderCount++;\n }\n\n const context = useContext(SurfaceContext);\n const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});\n\n const resolver = <SurfaceResolver {...props} id={id} ref={forwardedRef} />;\n const suspense = placeholder ? <Suspense fallback={placeholder}>{resolver}</Suspense> : resolver;\n\n return fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n {suspense}\n </ErrorBoundary>\n ) : (\n suspense\n );\n },\n ),\n);\n\nconst SurfaceContext = createContext<SurfaceProps | undefined>(undefined);\n\nexport const useSurface = (): SurfaceProps =>\n useContext(SurfaceContext) ?? raise(new Error('Surface context not found'));\n\n/**\n * Root surface component.\n */\nconst SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {\n const { components } = useSurfaceRoot();\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 <SurfaceContext.Provider value={currentContext}>{nodes}</SurfaceContext.Provider>;\n});\n\n/**\n * Resolve surface nodes from across all component.\n */\nconst resolveNodes = (\n components: Record<string, SurfaceComponent>,\n props: SurfaceProps,\n context: SurfaceProps | undefined,\n forwardedRef: ForwardedRef<HTMLElement>,\n): ReactNode[] => {\n const data = {\n ...((props.name && context?.surfaces?.[props.name]?.data) || {}),\n ...props.data,\n };\n\n const candidates = Object.entries(components)\n .map(([key, component]): [string, SurfaceResult] | undefined => {\n // TODO(burdon): Avoid variable return types in plugin contract.\n const result = component({ ...props, data }, forwardedRef);\n if (!result || typeof result !== 'object') {\n return undefined;\n }\n\n // Normalize tuple.\n if ('node' in result) {\n return [key, result];\n } else if (isValidElement(result)) {\n return [key, { node: result }];\n } else {\n log.warn('invalid result', { result });\n return undefined;\n }\n })\n .filter((result): result is [string, SurfaceResult] => Boolean(result))\n .sort(([, { disposition: a = 'default' }], [, { disposition: b = 'default' }]) => {\n return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;\n });\n\n // TODO(burdon): Does this prematurely process the node?\n const nodes = candidates.map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);\n return props.limit ? nodes.slice(0, props.limit) : nodes;\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SurfacePlugin } from './SurfacePlugin';\n\nexport * from './helpers';\nexport * from './provides';\n\nexport * from './ErrorBoundary';\nexport * from './Surface';\nexport * from './SurfaceRootContext';\n\nexport default SurfacePlugin;\n"],
5
- "mappings": ";;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAc;;;ACFvB,SAASC,eAAeC,kBAA+C;AAEvE,SAASC,aAAa;AAkDtB,IAAMC,qBAAqBC,8BAA8CC,MAAAA;AAElE,IAAMC,iBAAiB,MAAMC,WAAWJ,kBAAAA,KAAuBK,MAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBP,mBAAmBQ;;;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;;;ACaR,IAAME,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;;;AHRjF,IAAMG,gBAAgB,MAAA;AAC3B,QAAMC,Q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AMC,IAAI,IAAID,MAAM,WAAWC,MAAM,aAAa,KAAKA,MAAM,WAAWD,MAAM,aAAa,IAAI;EACxG,CAAA;AAGF,QAAMpB,QAAQK,WAAWG,IAAI,CAAC,CAACC,KAAKE,MAAAA,MAAY,gBAAAxB,OAAA,cAACmC,UAAAA;IAASb;KAAWE,OAAOE,IAAI,CAAA;AAChF,SAAO5C,MAAMsD,QAAQvB,MAAMwB,MAAM,GAAGvD,MAAMsD,KAAK,IAAIvB;AACrD;;;ACrLA,IAAA,yBAAeyB;",
6
- "names": ["React", "create", "createContext", "useContext", "raise", "SurfaceRootContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id", "parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfacePlugin", "state", "create", "components", "debugInfo", "Map", "meta", "SurfaceMeta", "ready", "plugins", "filterPlugins", "parseSurfacePlugin", "reduce", "acc", "plugin", "id", "provides", "surface", "component", "context", "children", "SurfaceProvider", "value", "isObject", "data", "React", "Component", "ErrorBoundary", "Component", "constructor", "props", "state", "error", "undefined", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "data", "resetError", "render", "React", "this", "fallback", "reset", "children", "setState", "React", "Fragment", "Suspense", "createContext", "forwardRef", "isValidElement", "memo", "useContext", "useEffect", "useState", "raise", "log", "count", "Surface", "memo", "forwardRef", "id", "_id", "role", "name", "fallback", "placeholder", "rest", "forwardedRef", "props", "debugInfo", "useSurfaceRoot", "useState", "useEffect", "set", "created", "Date", "now", "renderCount", "delete", "get", "context", "useContext", "SurfaceContext", "data", "surfaces", "resolver", "React", "SurfaceResolver", "ref", "suspense", "Suspense", "ErrorBoundary", "createContext", "undefined", "useSurface", "raise", "Error", "components", "parent", "nodes", "resolveNodes", "currentContext", "Provider", "value", "candidates", "Object", "entries", "map", "key", "component", "result", "isValidElement", "node", "log", "warn", "filter", "Boolean", "sort", "disposition", "a", "b", "Fragment", "limit", "slice", "SurfacePlugin"]
7
- }