@dxos/plugin-preview 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced

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 (123) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/neutral/PreviewPlugin.mjs +9 -0
  3. package/dist/lib/neutral/PreviewPlugin.mjs.map +7 -0
  4. package/dist/lib/neutral/PreviewPlugin.node.mjs +17 -0
  5. package/dist/lib/neutral/PreviewPlugin.node.mjs.map +7 -0
  6. package/dist/lib/neutral/PreviewPlugin.workerd.mjs +17 -0
  7. package/dist/lib/neutral/PreviewPlugin.workerd.mjs.map +7 -0
  8. package/dist/lib/neutral/capabilities/index.mjs +9 -0
  9. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  10. package/dist/lib/neutral/chunk-3SWUVHXJ.mjs +28 -0
  11. package/dist/lib/neutral/chunk-3SWUVHXJ.mjs.map +7 -0
  12. package/dist/lib/{browser/chunk-KLQDOIFV.mjs → neutral/chunk-XD3EYTHF.mjs} +6 -2
  13. package/dist/lib/neutral/chunk-XD3EYTHF.mjs.map +7 -0
  14. package/dist/lib/neutral/index.mjs +7 -0
  15. package/dist/lib/neutral/index.mjs.map +7 -0
  16. package/dist/lib/neutral/meta.json +1 -0
  17. package/dist/lib/neutral/meta.mjs +7 -0
  18. package/dist/lib/neutral/meta.mjs.map +7 -0
  19. package/dist/lib/neutral/plugin.mjs +11 -0
  20. package/dist/lib/neutral/plugin.mjs.map +7 -0
  21. package/dist/lib/{browser/preview-popover-X2ZJM5MK.mjs → neutral/preview-popover-MPPEMUIA.mjs} +10 -13
  22. package/dist/lib/neutral/preview-popover-MPPEMUIA.mjs.map +7 -0
  23. package/dist/lib/neutral/react-surface-IPTX6ZBX.mjs +418 -0
  24. package/dist/lib/neutral/react-surface-IPTX6ZBX.mjs.map +7 -0
  25. package/dist/lib/neutral/testing.mjs +7 -0
  26. package/dist/lib/neutral/testing.mjs.map +7 -0
  27. package/dist/lib/neutral/translations.mjs +21 -0
  28. package/dist/lib/neutral/translations.mjs.map +7 -0
  29. package/dist/types/src/PreviewPlugin.d.ts +1 -0
  30. package/dist/types/src/PreviewPlugin.d.ts.map +1 -1
  31. package/dist/types/src/PreviewPlugin.node.d.ts +4 -0
  32. package/dist/types/src/PreviewPlugin.node.d.ts.map +1 -0
  33. package/dist/types/src/PreviewPlugin.test.d.ts +2 -0
  34. package/dist/types/src/PreviewPlugin.test.d.ts.map +1 -0
  35. package/dist/types/src/PreviewPlugin.workerd.d.ts +4 -0
  36. package/dist/types/src/PreviewPlugin.workerd.d.ts.map +1 -0
  37. package/dist/types/src/capabilities/index.d.ts +3 -2
  38. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  41. package/dist/types/src/cards/DynamicTypeCard.d.ts +4 -0
  42. package/dist/types/src/cards/DynamicTypeCard.d.ts.map +1 -0
  43. package/dist/types/src/cards/ExpandoCard.d.ts +4 -0
  44. package/dist/types/src/cards/ExpandoCard.d.ts.map +1 -0
  45. package/dist/types/src/cards/FormCard.d.ts +2 -2
  46. package/dist/types/src/cards/FormCard.d.ts.map +1 -1
  47. package/dist/types/src/cards/JsonCard.d.ts +5 -0
  48. package/dist/types/src/cards/JsonCard.d.ts.map +1 -0
  49. package/dist/types/src/cards/OrganizationCard.d.ts +2 -2
  50. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  51. package/dist/types/src/cards/PersonCard.d.ts +2 -2
  52. package/dist/types/src/cards/PersonCard.d.ts.map +1 -1
  53. package/dist/types/src/cards/ProjectCard.d.ts +2 -2
  54. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  55. package/dist/types/src/cards/TaskCard.d.ts +2 -2
  56. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  57. package/dist/types/src/cards/index.d.ts +3 -0
  58. package/dist/types/src/cards/index.d.ts.map +1 -1
  59. package/dist/types/src/index.d.ts +0 -1
  60. package/dist/types/src/index.d.ts.map +1 -1
  61. package/dist/types/src/meta.d.ts.map +1 -1
  62. package/dist/types/src/plugin.d.ts +3 -0
  63. package/dist/types/src/plugin.d.ts.map +1 -0
  64. package/dist/types/src/stories/Card.stories.d.ts +15 -9
  65. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  66. package/dist/types/src/stories/testing.d.ts +4 -2
  67. package/dist/types/src/stories/testing.d.ts.map +1 -1
  68. package/dist/types/src/testing.d.ts +2 -0
  69. package/dist/types/src/testing.d.ts.map +1 -0
  70. package/dist/types/src/translations.d.ts +8 -9
  71. package/dist/types/src/translations.d.ts.map +1 -1
  72. package/dist/types/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +83 -41
  74. package/src/PreviewPlugin.node.ts +16 -0
  75. package/src/PreviewPlugin.test.ts +25 -0
  76. package/src/PreviewPlugin.tsx +6 -4
  77. package/src/PreviewPlugin.workerd.ts +16 -0
  78. package/src/capabilities/index.ts +4 -2
  79. package/src/capabilities/{preview-popover/preview-popover.ts → preview-popover.ts} +10 -4
  80. package/src/capabilities/react-surface.tsx +152 -0
  81. package/src/cards/DynamicTypeCard.tsx +53 -0
  82. package/src/cards/ExpandoCard.tsx +76 -0
  83. package/src/cards/FormCard.tsx +5 -5
  84. package/src/cards/JsonCard.tsx +19 -0
  85. package/src/cards/OrganizationCard.tsx +3 -3
  86. package/src/cards/PersonCard.tsx +27 -9
  87. package/src/cards/ProjectCard.tsx +2 -2
  88. package/src/cards/TaskCard.tsx +15 -11
  89. package/src/cards/index.ts +3 -0
  90. package/src/index.ts +0 -2
  91. package/src/meta.ts +2 -0
  92. package/src/plugin.ts +9 -0
  93. package/src/stories/Card.stories.tsx +50 -5
  94. package/src/stories/testing.tsx +26 -16
  95. package/src/testing.ts +7 -0
  96. package/src/translations.ts +8 -8
  97. package/dist/lib/browser/chunk-KLQDOIFV.mjs.map +0 -7
  98. package/dist/lib/browser/index.mjs +0 -55
  99. package/dist/lib/browser/index.mjs.map +0 -7
  100. package/dist/lib/browser/meta.json +0 -1
  101. package/dist/lib/browser/preview-popover-X2ZJM5MK.mjs.map +0 -7
  102. package/dist/lib/browser/react-surface-L57ORUAL.mjs +0 -244
  103. package/dist/lib/browser/react-surface-L57ORUAL.mjs.map +0 -7
  104. package/dist/lib/node-esm/chunk-GFWHEHC5.mjs +0 -19
  105. package/dist/lib/node-esm/chunk-GFWHEHC5.mjs.map +0 -7
  106. package/dist/lib/node-esm/index.mjs +0 -56
  107. package/dist/lib/node-esm/index.mjs.map +0 -7
  108. package/dist/lib/node-esm/meta.json +0 -1
  109. package/dist/lib/node-esm/preview-popover-6FLDJHHB.mjs +0 -83
  110. package/dist/lib/node-esm/preview-popover-6FLDJHHB.mjs.map +0 -7
  111. package/dist/lib/node-esm/react-surface-RIM4RITC.mjs +0 -245
  112. package/dist/lib/node-esm/react-surface-RIM4RITC.mjs.map +0 -7
  113. package/dist/types/src/capabilities/preview-popover/index.d.ts +0 -3
  114. package/dist/types/src/capabilities/preview-popover/index.d.ts.map +0 -1
  115. package/dist/types/src/capabilities/preview-popover/preview-popover.d.ts.map +0 -1
  116. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  117. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  118. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  119. package/src/capabilities/preview-popover/index.ts +0 -7
  120. package/src/capabilities/react-surface/index.ts +0 -7
  121. package/src/capabilities/react-surface/react-surface.tsx +0 -107
  122. /package/dist/types/src/capabilities/{preview-popover/preview-popover.d.ts → preview-popover.d.ts} +0 -0
  123. /package/dist/types/src/capabilities/{react-surface/react-surface.d.ts → react-surface.d.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.8360d9e660",
3
+ "version": "0.8.4-main.8baae0fced",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,68 +8,110 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": true,
14
14
  "type": "module",
15
+ "imports": {
16
+ "#capabilities": {
17
+ "source": "./src/capabilities/index.ts",
18
+ "types": "./dist/types/src/capabilities/index.d.ts",
19
+ "default": "./dist/lib/neutral/capabilities/index.mjs"
20
+ },
21
+ "#meta": {
22
+ "source": "./src/meta.ts",
23
+ "types": "./dist/types/src/meta.d.ts",
24
+ "default": "./dist/lib/neutral/meta.mjs"
25
+ },
26
+ "#plugin": {
27
+ "source": {
28
+ "workerd": "./src/PreviewPlugin.workerd.ts",
29
+ "node": "./src/PreviewPlugin.node.ts",
30
+ "default": "./src/PreviewPlugin.tsx"
31
+ },
32
+ "types": "./dist/types/src/PreviewPlugin.d.ts",
33
+ "workerd": "./dist/lib/neutral/PreviewPlugin.workerd.mjs",
34
+ "node": "./dist/lib/neutral/PreviewPlugin.node.mjs",
35
+ "default": "./dist/lib/neutral/PreviewPlugin.mjs"
36
+ },
37
+ "#translations": {
38
+ "source": "./src/translations.ts",
39
+ "types": "./dist/types/src/translations.d.ts",
40
+ "default": "./dist/lib/neutral/translations.mjs"
41
+ }
42
+ },
15
43
  "exports": {
16
44
  ".": {
17
45
  "source": "./src/index.ts",
18
46
  "types": "./dist/types/src/index.d.ts",
19
- "browser": "./dist/lib/browser/index.mjs"
47
+ "default": "./dist/lib/neutral/index.mjs"
48
+ },
49
+ "./plugin": {
50
+ "source": "./src/plugin.ts",
51
+ "types": "./dist/types/src/plugin.d.ts",
52
+ "default": "./dist/lib/neutral/plugin.mjs"
53
+ },
54
+ "./testing": {
55
+ "source": "./src/testing.ts",
56
+ "types": "./dist/types/src/testing.d.ts",
57
+ "default": "./dist/lib/neutral/testing.mjs"
58
+ },
59
+ "./translations": {
60
+ "source": "./src/translations.ts",
61
+ "types": "./dist/types/src/translations.d.ts",
62
+ "default": "./dist/lib/neutral/translations.mjs"
20
63
  }
21
64
  },
22
65
  "types": "dist/types/src/index.d.ts",
23
- "typesVersions": {
24
- "*": {}
25
- },
26
66
  "files": [
27
67
  "dist",
28
68
  "src"
29
69
  ],
30
70
  "dependencies": {
31
71
  "@effect-atom/atom-react": "^0.5.0",
32
- "@dxos/app-graph": "0.8.4-main.8360d9e660",
33
- "@dxos/app-framework": "0.8.4-main.8360d9e660",
34
- "@dxos/app-toolkit": "0.8.4-main.8360d9e660",
35
- "@dxos/echo": "0.8.4-main.8360d9e660",
36
- "@dxos/client": "0.8.4-main.8360d9e660",
37
- "@dxos/async": "0.8.4-main.8360d9e660",
38
- "@dxos/keys": "0.8.4-main.8360d9e660",
39
- "@dxos/lit-ui": "0.8.4-main.8360d9e660",
40
- "@dxos/effect": "0.8.4-main.8360d9e660",
41
- "@dxos/log": "0.8.4-main.8360d9e660",
42
- "@dxos/operation": "0.8.4-main.8360d9e660",
43
- "@dxos/plugin-attention": "0.8.4-main.8360d9e660",
44
- "@dxos/plugin-client": "0.8.4-main.8360d9e660",
45
- "@dxos/plugin-deck": "0.8.4-main.8360d9e660",
46
- "@dxos/react-client": "0.8.4-main.8360d9e660",
47
- "@dxos/plugin-space": "0.8.4-main.8360d9e660",
48
- "@dxos/react-ui-editor": "0.8.4-main.8360d9e660",
49
- "@dxos/react-ui": "0.8.4-main.8360d9e660",
50
- "@dxos/react-ui-form": "0.8.4-main.8360d9e660",
51
- "@dxos/react-ui-menu": "0.8.4-main.8360d9e660",
52
- "@dxos/react-ui-mosaic": "0.8.4-main.8360d9e660",
53
- "@dxos/react-ui-table": "0.8.4-main.8360d9e660",
54
- "@dxos/schema": "0.8.4-main.8360d9e660",
55
- "@dxos/types": "0.8.4-main.8360d9e660",
56
- "@dxos/ui-editor": "0.8.4-main.8360d9e660",
57
- "@dxos/util": "0.8.4-main.8360d9e660",
58
- "@dxos/ui-theme": "0.8.4-main.8360d9e660"
72
+ "@dxos/app-framework": "0.8.4-main.8baae0fced",
73
+ "@dxos/app-graph": "0.8.4-main.8baae0fced",
74
+ "@dxos/app-toolkit": "0.8.4-main.8baae0fced",
75
+ "@dxos/client": "0.8.4-main.8baae0fced",
76
+ "@dxos/echo-react": "0.8.4-main.8baae0fced",
77
+ "@dxos/echo": "0.8.4-main.8baae0fced",
78
+ "@dxos/lit-ui": "0.8.4-main.8baae0fced",
79
+ "@dxos/effect": "0.8.4-main.8baae0fced",
80
+ "@dxos/keys": "0.8.4-main.8baae0fced",
81
+ "@dxos/operation": "0.8.4-main.8baae0fced",
82
+ "@dxos/log": "0.8.4-main.8baae0fced",
83
+ "@dxos/plugin-attention": "0.8.4-main.8baae0fced",
84
+ "@dxos/async": "0.8.4-main.8baae0fced",
85
+ "@dxos/plugin-client": "0.8.4-main.8baae0fced",
86
+ "@dxos/plugin-deck": "0.8.4-main.8baae0fced",
87
+ "@dxos/react-client": "0.8.4-main.8baae0fced",
88
+ "@dxos/react-ui": "0.8.4-main.8baae0fced",
89
+ "@dxos/react-ui-form": "0.8.4-main.8baae0fced",
90
+ "@dxos/react-ui-mosaic": "0.8.4-main.8baae0fced",
91
+ "@dxos/react-ui-editor": "0.8.4-main.8baae0fced",
92
+ "@dxos/react-ui-menu": "0.8.4-main.8baae0fced",
93
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.8baae0fced",
94
+ "@dxos/react-ui-table": "0.8.4-main.8baae0fced",
95
+ "@dxos/types": "0.8.4-main.8baae0fced",
96
+ "@dxos/ui-editor": "0.8.4-main.8baae0fced",
97
+ "@dxos/schema": "0.8.4-main.8baae0fced",
98
+ "@dxos/ui-theme": "0.8.4-main.8baae0fced",
99
+ "@dxos/util": "0.8.4-main.8baae0fced"
59
100
  },
60
101
  "devDependencies": {
61
- "effect": "3.19.16",
102
+ "effect": "3.20.0",
62
103
  "react": "~19.2.3",
63
104
  "react-dom": "~19.2.3",
64
- "vite": "^7.1.11",
65
- "@dxos/echo-db": "0.8.4-main.8360d9e660",
66
- "@dxos/plugin-testing": "0.8.4-main.8360d9e660",
67
- "@dxos/random": "0.8.4-main.8360d9e660",
68
- "@dxos/react-ui-components": "0.8.4-main.8360d9e660",
69
- "@dxos/storybook-utils": "0.8.4-main.8360d9e660"
105
+ "vite": "^8.0.13",
106
+ "@dxos/echo-db": "0.8.4-main.8baae0fced",
107
+ "@dxos/echo-react": "0.8.4-main.8baae0fced",
108
+ "@dxos/plugin-testing": "0.8.4-main.8baae0fced",
109
+ "@dxos/random": "0.8.4-main.8baae0fced",
110
+ "@dxos/react-ui-components": "0.8.4-main.8baae0fced",
111
+ "@dxos/storybook-utils": "0.8.4-main.8baae0fced"
70
112
  },
71
113
  "peerDependencies": {
72
- "effect": "3.19.16",
114
+ "effect": "3.20.0",
73
115
  "react": "~19.2.3",
74
116
  "react-dom": "~19.2.3"
75
117
  },
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+ import { Organization, Person } from '@dxos/types';
8
+
9
+ import { meta } from '#meta';
10
+
11
+ export const PreviewPlugin = Plugin.define(meta).pipe(
12
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
13
+ Plugin.make,
14
+ );
15
+
16
+ export default PreviewPlugin;
@@ -0,0 +1,25 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { describe, test } from 'vitest';
6
+
7
+ import { ClientPlugin } from '@dxos/plugin-client/plugin';
8
+ import { createComposerTestApp } from '@dxos/plugin-testing/harness';
9
+
10
+ import { PreviewPlugin } from '#plugin';
11
+
12
+ import { meta } from './meta';
13
+
14
+ const moduleId = (name: string) => `${meta.id}.module.${name}`;
15
+
16
+ describe('PreviewPlugin', () => {
17
+ test('modules activate on the expected events', { timeout: 10_000 }, async ({ expect }) => {
18
+ await using harness = await createComposerTestApp({
19
+ plugins: [ClientPlugin({}), PreviewPlugin()],
20
+ });
21
+
22
+ // After autoStart: schema auto-cascades from ClientPlugin.
23
+ expect(harness.manager.getActive()).toContain(moduleId('schema'));
24
+ });
25
+ });
@@ -6,12 +6,12 @@ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
6
  import { AppPlugin } from '@dxos/app-toolkit';
7
7
  import { Organization, Person } from '@dxos/types';
8
8
 
9
- import { PreviewPopover, ReactSurface } from './capabilities';
10
- import { meta } from './meta';
11
- import { translations } from './translations';
9
+ import { PreviewPopover, ReactSurface } from '#capabilities';
10
+ import { meta } from '#meta';
11
+ import { translations } from '#translations';
12
12
 
13
13
  export const PreviewPlugin = Plugin.define(meta).pipe(
14
- AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization], id: 'schema' }),
14
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
15
15
  AppPlugin.addSurfaceModule({ activate: ReactSurface }),
16
16
  AppPlugin.addTranslationsModule({ translations }),
17
17
  Plugin.addModule({
@@ -21,3 +21,5 @@ export const PreviewPlugin = Plugin.define(meta).pipe(
21
21
  }),
22
22
  Plugin.make,
23
23
  );
24
+
25
+ export default PreviewPlugin;
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
7
+ import { Organization, Person } from '@dxos/types';
8
+
9
+ import { meta } from '#meta';
10
+
11
+ export const PreviewPlugin = Plugin.define(meta).pipe(
12
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
13
+ Plugin.make,
14
+ );
15
+
16
+ export default PreviewPlugin;
@@ -2,5 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './preview-popover';
6
- export * from './react-surface';
5
+ import { Capability } from '@dxos/app-framework';
6
+
7
+ export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
8
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -5,7 +5,7 @@
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
7
  import { Capabilities, Capability } from '@dxos/app-framework';
8
- import { AppCapabilities, LayoutOperation, getSpaceIdFromPath } from '@dxos/app-toolkit';
8
+ import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
9
9
  import { addEventListener } from '@dxos/async';
10
10
  import { type Client } from '@dxos/client';
11
11
  import { type Space } from '@dxos/client/echo';
@@ -49,10 +49,16 @@ export default Capability.makeModule(
49
49
  const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
50
50
  const client = capabilities.get(ClientCapabilities.Client);
51
51
  const registry = capabilities.get(Capabilities.AtomRegistry);
52
+ // Layout is optional: in standalone harnesses (Storybook, tests) no plugin contributes
53
+ // `AppCapabilities.Layout`, and `getAll` returns an empty array. Reading `registry.get(undefined)`
54
+ // would crash inside Atom's identity check (`'~atom/Serializable' in undefined`). When layout
55
+ // isn't available, fall through to the personal-space default.
52
56
  const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
53
- const layout = registry.get(layoutAtom);
54
- const spaceId = getSpaceIdFromPath(layout.workspace);
55
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
57
+ const spaceId = layoutAtom && getSpaceIdFromPath(registry.get(layoutAtom).workspace);
58
+ const space = (spaceId && client.spaces.get(spaceId)) ?? getPersonalSpace(client);
59
+ if (!space) {
60
+ return;
61
+ }
56
62
  const result = await handlePreviewLookup(client, space, { dxn, label });
57
63
  if (!result) {
58
64
  return;
@@ -0,0 +1,152 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+ import React from 'react';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { Surface } from '@dxos/app-framework/ui';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
11
+ import { Obj, Type } from '@dxos/echo';
12
+ import { Card } from '@dxos/react-ui';
13
+ import { Expando, type ProjectionModel } from '@dxos/schema';
14
+ import { Organization, Person, Pipeline, Task } from '@dxos/types';
15
+
16
+ import {
17
+ DynamicTypeCard,
18
+ ExpandoCard,
19
+ FormCard,
20
+ JsonCard,
21
+ OrganizationCard,
22
+ PersonCard,
23
+ ProjectCard,
24
+ TaskCard,
25
+ } from '../cards';
26
+
27
+ export default Capability.makeModule(() =>
28
+ Effect.succeed(
29
+ Capability.contributes(Capabilities.ReactSurface, [
30
+ //
31
+ // Specific schema types.
32
+ // TODO(burdon): Create helpers and factor out.
33
+ //
34
+
35
+ Surface.create<{ subject: Person.Person }>({
36
+ id: 'schema-popover--contact',
37
+ position: 'first',
38
+ filter: AppSurface.object(AppSurface.Card, Person.Person),
39
+ component: ({ data, role }) => {
40
+ return (
41
+ <>
42
+ <PersonCard role={role} subject={data.subject} />
43
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
44
+ </>
45
+ );
46
+ },
47
+ }),
48
+ Surface.create({
49
+ id: 'schema-popover--organization',
50
+ position: 'first',
51
+ filter: AppSurface.object(AppSurface.Card, Organization.Organization),
52
+ component: ({ data, role }) => {
53
+ return (
54
+ <>
55
+ <OrganizationCard role={role} subject={data.subject} />
56
+ <Surface.Surface type={AppSurface.Related} data={data} limit={1} />
57
+ </>
58
+ );
59
+ },
60
+ }),
61
+ Surface.create({
62
+ id: 'schema-popover--project',
63
+ position: 'first',
64
+ filter: AppSurface.object(AppSurface.Card, Pipeline.Pipeline),
65
+ component: ({ data, role }) => {
66
+ return <ProjectCard role={role} subject={data.subject} />;
67
+ },
68
+ }),
69
+ Surface.create({
70
+ id: 'schema-popover--task',
71
+ position: 'first',
72
+ filter: AppSurface.object(AppSurface.Card, Task.Task),
73
+ component: ({ data, role }) => {
74
+ return <TaskCard role={role} subject={data.subject} />;
75
+ },
76
+ }),
77
+ Surface.create<AppSurface.ObjectCardData<Expando.Expando>>({
78
+ id: 'schema-popover--expando',
79
+ filter: AppSurface.object(AppSurface.Card, Expando.Expando),
80
+ component: ({ data, role }) => {
81
+ return <ExpandoCard role={role} subject={data.subject} ignorePaths={data.ignorePaths} />;
82
+ },
83
+ }),
84
+
85
+ Surface.create({
86
+ id: 'schema-popover--dynamic-type',
87
+ role: 'card--content',
88
+ filter: (data): data is { subject: Obj.Unknown } => {
89
+ if (!Obj.isObject(data.subject)) {
90
+ return false;
91
+ }
92
+ const schema = Obj.getSchema(data.subject);
93
+ if (schema) {
94
+ return Type.isMutable(schema);
95
+ }
96
+ // Obj.getSchema fails for database-registered schemas (DXN mismatch); fall back to typename query.
97
+ try {
98
+ const db = Obj.getDatabase(data.subject);
99
+ const typename = Obj.getTypename(data.subject);
100
+ return !!db && !!typename && db.schemaRegistry.query({ typename }).runSync().length > 0;
101
+ } catch {
102
+ return false;
103
+ }
104
+ },
105
+ component: ({ data, role }) => {
106
+ return <DynamicTypeCard role={role} subject={data.subject} />;
107
+ },
108
+ }),
109
+
110
+ //
111
+ // Fallback for any object.
112
+ //
113
+
114
+ Surface.create({
115
+ id: 'fallback-popover',
116
+ role: 'card--content',
117
+ position: 'last',
118
+ filter: (data): data is { subject: Obj.Unknown; projection?: ProjectionModel } => Obj.isObject(data.subject),
119
+ component: ({ data, role }) => {
120
+ return <FormCard role={role} subject={data.subject} projection={data.projection} />;
121
+ },
122
+ }),
123
+
124
+ Surface.create({
125
+ id: 'fallback-json',
126
+ role: 'card--content',
127
+ position: 'last',
128
+ filter: (data): data is Record<string, unknown> => true,
129
+ component: ({ data }) => {
130
+ return <JsonCard data={data} />;
131
+ },
132
+ }),
133
+
134
+ Surface.create({
135
+ id: 'section',
136
+ position: 'last',
137
+ filter: AppSurface.subject(AppSurface.Section, Obj.isObject),
138
+ component: ({ data }) => {
139
+ return (
140
+ <div className='flex w-full justify-center'>
141
+ <div className='py-2 dx-card-min-width dx-card-max-width'>
142
+ <Card.Root>
143
+ <Surface.Surface type={AppSurface.Card} data={data} limit={1} />
144
+ </Card.Root>
145
+ </div>
146
+ </div>
147
+ );
148
+ },
149
+ }),
150
+ ]),
151
+ ),
152
+ );
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo } from 'react';
6
+
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
+ import { Obj } from '@dxos/echo';
9
+ import { useSchema } from '@dxos/echo-react';
10
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
11
+ import { Card, useTranslation } from '@dxos/react-ui';
12
+ import { Form, type FormUpdateMeta, omitId } from '@dxos/react-ui-form';
13
+ import { descriptionMessage, mx } from '@dxos/ui-theme';
14
+
15
+ import { meta } from '#meta';
16
+
17
+ export const DynamicTypeCard = ({ subject }: AppSurface.ObjectCardProps) => {
18
+ const { t } = useTranslation(meta.id);
19
+ const db = Obj.getDatabase(subject);
20
+ const typename = Obj.getTypename(subject);
21
+ const runtimeSchema = useSchema(db, typename);
22
+ const schema = useMemo(() => runtimeSchema && omitId(runtimeSchema), [runtimeSchema]);
23
+
24
+ const handleSave = useCallback(
25
+ (values: Record<string, unknown>, { changed }: FormUpdateMeta<Record<string, unknown>>) => {
26
+ const paths = (Object.keys(changed) as JsonPath[]).filter((path) => changed[path]);
27
+ Obj.update(subject, () => {
28
+ for (const path of paths) {
29
+ const parts = splitJsonPath(path);
30
+ const value = Obj.getValue(values as any, parts);
31
+ Obj.setValue(subject, parts, value);
32
+ }
33
+ });
34
+ },
35
+ [subject],
36
+ );
37
+
38
+ if (!schema) {
39
+ return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
40
+ }
41
+
42
+ return (
43
+ <Card.Content>
44
+ <Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
45
+ <Form.Viewport>
46
+ <Form.Content>
47
+ <Form.FieldSet />
48
+ </Form.Content>
49
+ </Form.Viewport>
50
+ </Form.Root>
51
+ </Card.Content>
52
+ );
53
+ };
@@ -0,0 +1,76 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import React, { useCallback, useMemo } from 'react';
7
+
8
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
9
+ import { Obj } from '@dxos/echo';
10
+ import { type JsonPath, splitJsonPath } from '@dxos/effect';
11
+ import { Card } from '@dxos/react-ui';
12
+ import { Form } from '@dxos/react-ui-form';
13
+
14
+ const schemaForValue = (value: unknown): Schema.Schema.AnyNoContext | undefined => {
15
+ switch (typeof value) {
16
+ case 'string':
17
+ return Schema.String;
18
+ case 'number':
19
+ return Schema.Number;
20
+ case 'boolean':
21
+ return Schema.Boolean;
22
+ default:
23
+ return undefined;
24
+ }
25
+ };
26
+
27
+ /**
28
+ * Reserved keys: `id`, plus any `~`-prefixed key (ECHO uses `~`-prefixed
29
+ * string keys to brand entity instances and schemas — KindId,
30
+ * SchemaKindId, SnapshotKindId, etc. — and the `~` namespace is reserved
31
+ * for that purpose). They show up in `Object.keys` but aren't user data.
32
+ */
33
+ const isInternalKey = (key: string) => key === 'id' || key.startsWith('~');
34
+
35
+ export const ExpandoCard = ({ subject, ignorePaths }: AppSurface.ObjectCardProps) => {
36
+ const schema = useMemo(() => {
37
+ const ignored = new Set(ignorePaths ?? []);
38
+ const fields: Record<string, Schema.Schema.AnyNoContext> = {};
39
+ for (const key of Object.keys(subject)) {
40
+ if (isInternalKey(key) || ignored.has(key)) {
41
+ continue;
42
+ }
43
+ const fieldSchema = schemaForValue((subject as any)[key]);
44
+ if (fieldSchema) {
45
+ fields[key] = fieldSchema;
46
+ }
47
+ }
48
+ return Schema.Struct(fields);
49
+ }, [subject, ignorePaths]);
50
+
51
+ const handleSave = useCallback(
52
+ (values: any, { changed }: { changed: Record<string, boolean> }) => {
53
+ const paths = Object.keys(changed).filter((path) => changed[path]);
54
+ Obj.update(subject, () => {
55
+ for (const path of paths) {
56
+ const value = values[path];
57
+ const parts = splitJsonPath(path as JsonPath);
58
+ Obj.setValue(subject, parts, value);
59
+ }
60
+ });
61
+ },
62
+ [subject],
63
+ );
64
+
65
+ return (
66
+ <Card.Content>
67
+ <Form.Root schema={schema} values={subject} autoSave onSave={handleSave}>
68
+ <Form.Viewport>
69
+ <Form.Content>
70
+ <Form.FieldSet />
71
+ </Form.Content>
72
+ </Form.Viewport>
73
+ </Form.Root>
74
+ </Card.Content>
75
+ );
76
+ };
@@ -4,7 +4,7 @@
4
4
 
5
5
  import React, { useCallback, useMemo } from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
8
  import { Obj } from '@dxos/echo';
9
9
  import { type JsonPath, splitJsonPath } from '@dxos/effect';
10
10
  import { Card, useTranslation } from '@dxos/react-ui';
@@ -12,16 +12,16 @@ import { Form, omitId } from '@dxos/react-ui-form';
12
12
  import { type ProjectionModel } from '@dxos/schema';
13
13
  import { descriptionMessage, mx } from '@dxos/ui-theme';
14
14
 
15
- import { meta } from '../meta';
15
+ import { meta } from '#meta';
16
16
 
17
- export const FormCard = ({ subject, projection }: SurfaceComponentProps & { projection?: ProjectionModel }) => {
17
+ export const FormCard = ({ subject, projection }: AppSurface.ObjectCardProps & { projection?: ProjectionModel }) => {
18
18
  const { t } = useTranslation(meta.id);
19
19
  const echoSchema = Obj.getSchema(subject);
20
20
  const schema = useMemo(() => echoSchema && omitId(echoSchema), [echoSchema]);
21
21
 
22
22
  const handleSave = useCallback((values: any, { changed }: { changed: Record<string, boolean> }) => {
23
23
  const paths = Object.keys(changed).filter((path) => changed[path]);
24
- Obj.change(subject, () => {
24
+ Obj.update(subject, () => {
25
25
  for (const path of paths) {
26
26
  const value = values[path];
27
27
  const parts = splitJsonPath(path as JsonPath);
@@ -31,7 +31,7 @@ export const FormCard = ({ subject, projection }: SurfaceComponentProps & { proj
31
31
  }, []);
32
32
 
33
33
  if (!schema) {
34
- return <p className={mx(descriptionMessage)}>{t('unable to create preview message')}</p>;
34
+ return <p className={mx(descriptionMessage)}>{t('unable-to-create-preview.message')}</p>;
35
35
  }
36
36
 
37
37
  return (
@@ -0,0 +1,19 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Card } from '@dxos/react-ui';
8
+ import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
9
+
10
+ export const JsonCard = ({ data }: { data: unknown }) => {
11
+ return (
12
+ <Card.Content>
13
+ <span />
14
+ {/* TODO(wittjosiah): Span whole row. */}
15
+ <JsonHighlighter data={data} />
16
+ <span />
17
+ </Card.Content>
18
+ );
19
+ };
@@ -4,12 +4,12 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
7
+ import { type AppSurface } from '@dxos/app-toolkit/ui';
8
8
  import { Card } from '@dxos/react-ui';
9
9
  import { type Organization } from '@dxos/types';
10
10
 
11
- export const OrganizationCard = ({ subject }: SurfaceComponentProps<Organization.Organization>) => {
12
- const { image, description, website } = subject;
11
+ export const OrganizationCard = ({ subject }: AppSurface.ObjectCardProps<Organization.Organization>) => {
12
+ const { name, image, description, website } = subject;
13
13
 
14
14
  return (
15
15
  <Card.Content>