@dxos/plugin-preview 0.8.4-main.ead640a → 0.8.4-main.effb148878

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 (129) 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/neutral/chunk-XD3EYTHF.mjs +21 -0
  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/neutral/preview-popover-F33UBSBM.mjs +80 -0
  22. package/dist/lib/neutral/preview-popover-F33UBSBM.mjs.map +7 -0
  23. package/dist/lib/neutral/react-surface-3UPRCM4X.mjs +408 -0
  24. package/dist/lib/neutral/react-surface-3UPRCM4X.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 +3 -1
  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 +3 -2
  40. package/dist/types/src/capabilities/preview-popover.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  42. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  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 +17 -0
  46. package/dist/types/src/cards/FormCard.d.ts.map +1 -0
  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 +3 -3
  50. package/dist/types/src/cards/OrganizationCard.d.ts.map +1 -1
  51. package/dist/types/src/cards/PersonCard.d.ts +5 -0
  52. package/dist/types/src/cards/PersonCard.d.ts.map +1 -0
  53. package/dist/types/src/cards/ProjectCard.d.ts +3 -3
  54. package/dist/types/src/cards/ProjectCard.d.ts.map +1 -1
  55. package/dist/types/src/cards/TaskCard.d.ts +3 -3
  56. package/dist/types/src/cards/TaskCard.d.ts.map +1 -1
  57. package/dist/types/src/cards/index.d.ts +4 -1
  58. package/dist/types/src/cards/index.d.ts.map +1 -1
  59. package/dist/types/src/index.d.ts +0 -2
  60. package/dist/types/src/index.d.ts.map +1 -1
  61. package/dist/types/src/meta.d.ts +2 -2
  62. package/dist/types/src/meta.d.ts.map +1 -1
  63. package/dist/types/src/plugin.d.ts +3 -0
  64. package/dist/types/src/plugin.d.ts.map +1 -0
  65. package/dist/types/src/stories/Card.stories.d.ts +42 -14
  66. package/dist/types/src/stories/Card.stories.d.ts.map +1 -1
  67. package/dist/types/src/stories/testing.d.ts +52 -12
  68. package/dist/types/src/stories/testing.d.ts.map +1 -1
  69. package/dist/types/src/testing.d.ts +2 -0
  70. package/dist/types/src/testing.d.ts.map +1 -0
  71. package/dist/types/src/translations.d.ts +8 -9
  72. package/dist/types/src/translations.d.ts.map +1 -1
  73. package/dist/types/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +92 -39
  75. package/src/PreviewPlugin.node.ts +16 -0
  76. package/src/PreviewPlugin.test.ts +25 -0
  77. package/src/PreviewPlugin.tsx +17 -26
  78. package/src/PreviewPlugin.workerd.ts +16 -0
  79. package/src/capabilities/index.ts +3 -3
  80. package/src/capabilities/preview-popover.ts +69 -42
  81. package/src/capabilities/react-surface.tsx +132 -120
  82. package/src/cards/ExpandoCard.tsx +76 -0
  83. package/src/cards/FormCard.tsx +115 -0
  84. package/src/cards/JsonCard.tsx +19 -0
  85. package/src/cards/OrganizationCard.tsx +17 -13
  86. package/src/cards/PersonCard.tsx +65 -0
  87. package/src/cards/ProjectCard.tsx +9 -11
  88. package/src/cards/TaskCard.tsx +27 -28
  89. package/src/cards/index.ts +4 -1
  90. package/src/index.ts +0 -3
  91. package/src/meta.ts +10 -3
  92. package/src/plugin.ts +9 -0
  93. package/src/stories/Card.stories.tsx +139 -24
  94. package/src/stories/testing.tsx +117 -77
  95. package/src/testing.ts +7 -0
  96. package/src/translations.ts +8 -8
  97. package/dist/lib/browser/chunk-XKCIQK3C.mjs +0 -12
  98. package/dist/lib/browser/chunk-XKCIQK3C.mjs.map +0 -7
  99. package/dist/lib/browser/index.mjs +0 -64
  100. package/dist/lib/browser/index.mjs.map +0 -7
  101. package/dist/lib/browser/meta.json +0 -1
  102. package/dist/lib/browser/preview-popover-RKHENTFP.mjs +0 -65
  103. package/dist/lib/browser/preview-popover-RKHENTFP.mjs.map +0 -7
  104. package/dist/lib/browser/react-surface-CPGRW3OV.mjs +0 -493
  105. package/dist/lib/browser/react-surface-CPGRW3OV.mjs.map +0 -7
  106. package/dist/lib/node-esm/chunk-L3IZVX56.mjs +0 -14
  107. package/dist/lib/node-esm/chunk-L3IZVX56.mjs.map +0 -7
  108. package/dist/lib/node-esm/index.mjs +0 -65
  109. package/dist/lib/node-esm/index.mjs.map +0 -7
  110. package/dist/lib/node-esm/meta.json +0 -1
  111. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs +0 -67
  112. package/dist/lib/node-esm/preview-popover-TZKX67EY.mjs.map +0 -7
  113. package/dist/lib/node-esm/react-surface-XJKNWCPR.mjs +0 -494
  114. package/dist/lib/node-esm/react-surface-XJKNWCPR.mjs.map +0 -7
  115. package/dist/types/src/cards/ContactCard.d.ts +0 -5
  116. package/dist/types/src/cards/ContactCard.d.ts.map +0 -1
  117. package/dist/types/src/components/CardComponents.d.ts +0 -16
  118. package/dist/types/src/components/CardComponents.d.ts.map +0 -1
  119. package/dist/types/src/components/CardSubjectMenu.d.ts +0 -8
  120. package/dist/types/src/components/CardSubjectMenu.d.ts.map +0 -1
  121. package/dist/types/src/components/index.d.ts +0 -3
  122. package/dist/types/src/components/index.d.ts.map +0 -1
  123. package/dist/types/src/types.d.ts +0 -10
  124. package/dist/types/src/types.d.ts.map +0 -1
  125. package/src/cards/ContactCard.tsx +0 -58
  126. package/src/components/CardComponents.tsx +0 -67
  127. package/src/components/CardSubjectMenu.tsx +0 -91
  128. package/src/components/index.ts +0 -6
  129. package/src/types.ts +0 -15
package/package.json CHANGED
@@ -1,66 +1,119 @@
1
1
  {
2
2
  "name": "@dxos/plugin-preview",
3
- "version": "0.8.4-main.ead640a",
3
+ "version": "0.8.4-main.effb148878",
4
4
  "description": "Preview plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
- "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "FSL-1.1-Apache-2.0",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
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
+ },
11
43
  "exports": {
12
44
  ".": {
13
45
  "source": "./src/index.ts",
14
46
  "types": "./dist/types/src/index.d.ts",
15
- "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"
16
63
  }
17
64
  },
18
65
  "types": "dist/types/src/index.d.ts",
19
- "typesVersions": {
20
- "*": {}
21
- },
22
66
  "files": [
23
67
  "dist",
24
68
  "src"
25
69
  ],
26
70
  "dependencies": {
27
- "@effect-rx/rx-react": "0.42.4",
28
- "@preact-signals/safe-react": "^0.9.0",
29
- "@dxos/app-framework": "0.8.4-main.ead640a",
30
- "@dxos/app-graph": "0.8.4-main.ead640a",
31
- "@dxos/async": "0.8.4-main.ead640a",
32
- "@dxos/echo": "0.8.4-main.ead640a",
33
- "@dxos/keys": "0.8.4-main.ead640a",
34
- "@dxos/lit-ui": "0.8.4-main.ead640a",
35
- "@dxos/plugin-attention": "0.8.4-main.ead640a",
36
- "@dxos/client": "0.8.4-main.ead640a",
37
- "@dxos/plugin-client": "0.8.4-main.ead640a",
38
- "@dxos/log": "0.8.4-main.ead640a",
39
- "@dxos/plugin-deck": "0.8.4-main.ead640a",
40
- "@dxos/plugin-space": "0.8.4-main.ead640a",
41
- "@dxos/react-client": "0.8.4-main.ead640a",
42
- "@dxos/react-ui": "0.8.4-main.ead640a",
43
- "@dxos/react-ui-editor": "0.8.4-main.ead640a",
44
- "@dxos/react-ui-form": "0.8.4-main.ead640a",
45
- "@dxos/react-ui-menu": "0.8.4-main.ead640a",
46
- "@dxos/react-ui-stack": "0.8.4-main.ead640a",
47
- "@dxos/react-ui-table": "0.8.4-main.ead640a",
48
- "@dxos/react-ui-theme": "0.8.4-main.ead640a",
49
- "@dxos/util": "0.8.4-main.ead640a",
50
- "@dxos/schema": "0.8.4-main.ead640a"
71
+ "@effect-atom/atom-react": "^0.5.0",
72
+ "@dxos/app-framework": "0.8.4-main.effb148878",
73
+ "@dxos/app-graph": "0.8.4-main.effb148878",
74
+ "@dxos/client": "0.8.4-main.effb148878",
75
+ "@dxos/echo": "0.8.4-main.effb148878",
76
+ "@dxos/app-toolkit": "0.8.4-main.effb148878",
77
+ "@dxos/echo-react": "0.8.4-main.effb148878",
78
+ "@dxos/keys": "0.8.4-main.effb148878",
79
+ "@dxos/effect": "0.8.4-main.effb148878",
80
+ "@dxos/lit-ui": "0.8.4-main.effb148878",
81
+ "@dxos/log": "0.8.4-main.effb148878",
82
+ "@dxos/operation": "0.8.4-main.effb148878",
83
+ "@dxos/plugin-attention": "0.8.4-main.effb148878",
84
+ "@dxos/plugin-client": "0.8.4-main.effb148878",
85
+ "@dxos/react-client": "0.8.4-main.effb148878",
86
+ "@dxos/plugin-deck": "0.8.4-main.effb148878",
87
+ "@dxos/react-ui": "0.8.4-main.effb148878",
88
+ "@dxos/react-ui-menu": "0.8.4-main.effb148878",
89
+ "@dxos/async": "0.8.4-main.effb148878",
90
+ "@dxos/react-ui-mosaic": "0.8.4-main.effb148878",
91
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.effb148878",
92
+ "@dxos/schema": "0.8.4-main.effb148878",
93
+ "@dxos/react-ui-table": "0.8.4-main.effb148878",
94
+ "@dxos/types": "0.8.4-main.effb148878",
95
+ "@dxos/ui-editor": "0.8.4-main.effb148878",
96
+ "@dxos/ui-theme": "0.8.4-main.effb148878",
97
+ "@dxos/util": "0.8.4-main.effb148878",
98
+ "@dxos/react-ui-editor": "0.8.4-main.effb148878",
99
+ "@dxos/react-ui-form": "0.8.4-main.effb148878"
51
100
  },
52
101
  "devDependencies": {
53
- "effect": "3.18.3",
54
- "react": "~19.2.0",
55
- "react-dom": "~19.2.0",
56
- "vite": "7.1.9",
57
- "@dxos/random": "0.8.4-main.ead640a",
58
- "@dxos/storybook-utils": "0.8.4-main.ead640a"
102
+ "effect": "3.20.0",
103
+ "react": "~19.2.3",
104
+ "react-dom": "~19.2.3",
105
+ "vite": "^8.0.14",
106
+ "@dxos/echo-db": "0.8.4-main.effb148878",
107
+ "@dxos/echo-react": "0.8.4-main.effb148878",
108
+ "@dxos/plugin-testing": "0.8.4-main.effb148878",
109
+ "@dxos/random": "0.8.4-main.effb148878",
110
+ "@dxos/react-ui-components": "0.8.4-main.effb148878",
111
+ "@dxos/storybook-utils": "0.8.4-main.effb148878"
59
112
  },
60
113
  "peerDependencies": {
61
- "effect": "^3.13.3",
62
- "react": "^19.0.0",
63
- "react-dom": "^19.0.0"
114
+ "effect": "3.20.0",
115
+ "react": "~19.2.3",
116
+ "react-dom": "~19.2.3"
64
117
  },
65
118
  "publishConfig": {
66
119
  "access": "public"
@@ -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
+ });
@@ -2,33 +2,24 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
6
- import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
7
- import { DataType } from '@dxos/schema';
5
+ import { ActivationEvents, Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
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
- export const PreviewPlugin = definePlugin(meta, () => [
14
- defineModule({
15
- id: `${meta.id}/module/translations`,
16
- activatesOn: Events.SetupTranslations,
17
- activate: () => contributes(Capabilities.Translations, translations),
18
- }),
19
- defineModule({
20
- id: `${meta.id}/module/schema`,
21
- activatesOn: ClientEvents.SetupSchema,
22
- activate: () => [contributes(ClientCapabilities.Schema, [DataType.Person, DataType.Organization])],
23
- }),
24
- defineModule({
25
- id: `${meta.id}/module/preview-popover`,
26
- activatesOn: Events.Startup,
13
+ export const PreviewPlugin = Plugin.define(meta).pipe(
14
+ AppPlugin.addSchemaModule({ schema: [Person.Person, Organization.Organization] }),
15
+ AppPlugin.addSurfaceModule({ activate: ReactSurface }),
16
+ AppPlugin.addTranslationsModule({ translations }),
17
+ Plugin.addModule({
18
+ id: 'preview-popover',
19
+ activatesOn: ActivationEvents.Startup,
27
20
  activate: PreviewPopover,
28
21
  }),
29
- defineModule({
30
- id: `${meta.id}/module/react-surface`,
31
- activatesOn: Events.SetupReactSurface,
32
- activate: ReactSurface,
33
- }),
34
- ]);
22
+ Plugin.make,
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,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from '@dxos/app-framework';
5
+ import { Capability } from '@dxos/app-framework';
6
6
 
7
- export const PreviewPopover = lazy(() => import('./preview-popover'));
8
- export const ReactSurface = lazy(() => import('./react-surface'));
7
+ export const PreviewPopover = Capability.lazy('PreviewPopover', () => import('./preview-popover'));
8
+ export const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));
@@ -2,68 +2,95 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, LayoutAction, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import { AppCapabilities, LayoutOperation, getPersonalSpace, getSpaceIdFromPath } from '@dxos/app-toolkit';
6
9
  import { addEventListener } from '@dxos/async';
7
10
  import { type Client } from '@dxos/client';
8
- import { type Space, parseId } from '@dxos/client/echo';
9
- import { DXN } from '@dxos/keys';
11
+ import { type Space } from '@dxos/client/echo';
12
+ import { Obj } from '@dxos/echo';
13
+ import { EchoURI } from '@dxos/keys';
10
14
  import { log } from '@dxos/log';
11
15
  import { ClientCapabilities } from '@dxos/plugin-client';
12
16
  import { DX_ANCHOR_ACTIVATE, type DxAnchorActivate } from '@dxos/react-ui';
13
- import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/react-ui-editor';
17
+ import { type PreviewLinkRef, type PreviewLinkTarget } from '@dxos/ui-editor';
14
18
 
15
19
  const customEventOptions = { capture: true, passive: false };
16
20
 
17
21
  const handlePreviewLookup = async (
18
22
  client: Client,
19
23
  defaultSpace: Space,
20
- { ref, label }: PreviewLinkRef,
24
+ { dxn, label }: PreviewLinkRef,
21
25
  ): Promise<PreviewLinkTarget | null> => {
22
26
  try {
23
- const object = await defaultSpace.db.ref(DXN.parse(ref)).load();
27
+ const object = await defaultSpace.db.makeRef(EchoURI.parse(dxn)).load();
24
28
  return { label, object };
25
29
  } catch {
26
30
  return null;
27
31
  }
28
32
  };
29
33
 
30
- export default (context: PluginContext) => {
31
- // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
32
- const handleDxAnchorActivate = async ({ refId, label, trigger }: DxAnchorActivate) => {
33
- const { dispatchPromise: dispatch } = context.getCapability(Capabilities.IntentDispatcher);
34
- const client = context.getCapability(ClientCapabilities.Client);
35
- const [layout] = context.getCapabilities(Capabilities.Layout);
36
- const { spaceId } = parseId(layout.workspace);
37
- const space = (spaceId && client.spaces.get(spaceId)) ?? client.spaces.default;
38
- const result = await handlePreviewLookup(client, space, { ref: refId, label });
39
- if (!result) {
40
- return;
41
- }
34
+ export default Capability.makeModule(
35
+ Effect.fnUntraced(function* () {
36
+ // Get context for lazy capability access in callbacks.
37
+ const capabilities = yield* Capability.Service;
38
+
39
+ // TODO(wittjosiah): Factor out lookup handlers to other plugins to make not ECHO-specific.
40
+ const handleAnchorActivate = async ({
41
+ dxn,
42
+ label,
43
+ trigger,
44
+ kind = 'card',
45
+ title: titleProp,
46
+ side,
47
+ props,
48
+ }: DxAnchorActivate) => {
49
+ const { invokePromise } = capabilities.get(Capabilities.OperationInvoker);
50
+ const client = capabilities.get(ClientCapabilities.Client);
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.
56
+ const [layoutAtom] = capabilities.getAll(AppCapabilities.Layout);
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
+ }
62
+ const result = await handlePreviewLookup(client, space, { dxn, label });
63
+ if (!result) {
64
+ return;
65
+ }
66
+
67
+ const title = titleProp ?? Obj.getLabel(result.object, { fallback: 'typename' });
42
68
 
43
- await dispatch(
44
- createIntent(LayoutAction.UpdatePopover, {
45
- part: 'popover',
69
+ await invokePromise(LayoutOperation.UpdatePopover, {
70
+ subjectRef: dxn,
46
71
  subject: result.object,
47
- options: {
48
- state: true,
49
- variant: 'virtual',
50
- anchor: trigger,
51
- },
52
- }),
53
- );
54
- };
72
+ state: true,
73
+ variant: 'virtual',
74
+ anchor: trigger,
75
+ ...(kind && { kind }),
76
+ ...(title && { title }),
77
+ ...(side && { side }),
78
+ ...(props && { props }),
79
+ });
80
+ };
55
81
 
56
- let cleanup: () => void;
57
- if (document.defaultView) {
58
- cleanup = addEventListener(
59
- document.defaultView,
60
- DX_ANCHOR_ACTIVATE as any,
61
- handleDxAnchorActivate,
62
- customEventOptions,
63
- );
64
- } else {
65
- log.warn('No default view found');
66
- }
82
+ let cleanup: () => void;
83
+ if (document.defaultView) {
84
+ cleanup = addEventListener(
85
+ document.defaultView,
86
+ DX_ANCHOR_ACTIVATE as any,
87
+ handleAnchorActivate,
88
+ customEventOptions,
89
+ );
90
+ } else {
91
+ log.warn('no default view found');
92
+ }
67
93
 
68
- return contributes(Capabilities.Null, null, () => cleanup());
69
- };
94
+ return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => cleanup?.()));
95
+ }),
96
+ );