@dxos/plugin-testing 0.8.4-main.d05673bc65 → 0.8.4-main.dfabb4ec29

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 (155) hide show
  1. package/dist/lib/neutral/StorybookPlugin.mjs +10 -0
  2. package/dist/lib/neutral/StorybookPlugin.mjs.map +7 -0
  3. package/dist/lib/neutral/add-toast-Z2RXG4RX.mjs +23 -0
  4. package/dist/lib/neutral/add-toast-Z2RXG4RX.mjs.map +7 -0
  5. package/dist/lib/neutral/capabilities/index.mjs +11 -0
  6. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  7. package/dist/lib/neutral/chunk-7UPIIIZM.mjs +22 -0
  8. package/dist/lib/neutral/chunk-7UPIIIZM.mjs.map +7 -0
  9. package/dist/lib/neutral/chunk-E4LBVPH5.mjs +8 -0
  10. package/dist/lib/neutral/chunk-E4LBVPH5.mjs.map +7 -0
  11. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  12. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  13. package/dist/lib/neutral/chunk-NZ2VT6N2.mjs +17 -0
  14. package/dist/lib/neutral/chunk-NZ2VT6N2.mjs.map +7 -0
  15. package/dist/lib/neutral/chunk-R7AV233N.mjs +31 -0
  16. package/dist/lib/neutral/chunk-R7AV233N.mjs.map +7 -0
  17. package/dist/lib/neutral/chunk-ULNF6GTG.mjs +21 -0
  18. package/dist/lib/neutral/chunk-ULNF6GTG.mjs.map +7 -0
  19. package/dist/lib/{browser/chunk-NWOKPVNQ.mjs → neutral/chunk-ZVN23V74.mjs} +2 -7
  20. package/dist/lib/neutral/chunk-ZVN23V74.mjs.map +7 -0
  21. package/dist/lib/neutral/close-L3FBJQ3J.mjs +12 -0
  22. package/dist/lib/neutral/close-L3FBJQ3J.mjs.map +7 -0
  23. package/dist/lib/{node-esm → neutral/components}/index.mjs +53 -76
  24. package/dist/lib/neutral/components/index.mjs.map +7 -0
  25. package/dist/lib/neutral/core.mjs +8 -0
  26. package/dist/lib/neutral/core.mjs.map +7 -0
  27. package/dist/lib/neutral/harness.mjs +37 -0
  28. package/dist/lib/neutral/harness.mjs.map +7 -0
  29. package/dist/lib/neutral/index.mjs +20 -0
  30. package/dist/lib/neutral/index.mjs.map +7 -0
  31. package/dist/lib/neutral/meta.json +1 -0
  32. package/dist/lib/neutral/meta.mjs +8 -0
  33. package/dist/lib/neutral/meta.mjs.map +7 -0
  34. package/dist/lib/neutral/open-WBONYQ47.mjs +14 -0
  35. package/dist/lib/neutral/open-WBONYQ47.mjs.map +7 -0
  36. package/dist/lib/neutral/operation-handler-LQIWHQVY.mjs +13 -0
  37. package/dist/lib/neutral/operation-handler-LQIWHQVY.mjs.map +7 -0
  38. package/dist/lib/neutral/operations/index.mjs +8 -0
  39. package/dist/lib/neutral/operations/index.mjs.map +7 -0
  40. package/dist/lib/neutral/plugin.mjs +16 -0
  41. package/dist/lib/neutral/plugin.mjs.map +7 -0
  42. package/dist/lib/neutral/scroll-into-view-BKOOOECC.mjs +12 -0
  43. package/dist/lib/neutral/scroll-into-view-BKOOOECC.mjs.map +7 -0
  44. package/dist/lib/neutral/set-layout-mode-2KHD2AEY.mjs +12 -0
  45. package/dist/lib/neutral/set-layout-mode-2KHD2AEY.mjs.map +7 -0
  46. package/dist/lib/{browser/state-TCYYH5JN.mjs → neutral/state-AJ62JEEG.mjs} +6 -6
  47. package/dist/lib/neutral/state-AJ62JEEG.mjs.map +7 -0
  48. package/dist/lib/neutral/switch-workspace-SAT2NGXV.mjs +20 -0
  49. package/dist/lib/neutral/switch-workspace-SAT2NGXV.mjs.map +7 -0
  50. package/dist/lib/neutral/types/index.mjs +8 -0
  51. package/dist/lib/neutral/types/index.mjs.map +7 -0
  52. package/dist/lib/neutral/update-complementary-JP2OL73Z.mjs +26 -0
  53. package/dist/lib/neutral/update-complementary-JP2OL73Z.mjs.map +7 -0
  54. package/dist/lib/neutral/update-dialog-MX6IKKJX.mjs +28 -0
  55. package/dist/lib/neutral/update-dialog-MX6IKKJX.mjs.map +7 -0
  56. package/dist/lib/neutral/update-popover-DOORE3TD.mjs +46 -0
  57. package/dist/lib/neutral/update-popover-DOORE3TD.mjs.map +7 -0
  58. package/dist/lib/neutral/update-sidebar-LWQ3IA6S.mjs +26 -0
  59. package/dist/lib/neutral/update-sidebar-LWQ3IA6S.mjs.map +7 -0
  60. package/dist/types/src/StorybookPlugin.d.ts +3 -2
  61. package/dist/types/src/StorybookPlugin.d.ts.map +1 -1
  62. package/dist/types/src/capabilities/index.d.ts +15 -2
  63. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  64. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  65. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  66. package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +3 -3
  67. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  68. package/dist/types/src/components/Layout/Layout.d.ts.map +1 -1
  69. package/dist/types/src/core.d.ts +1 -7
  70. package/dist/types/src/core.d.ts.map +1 -1
  71. package/dist/types/src/harness.d.ts +20 -0
  72. package/dist/types/src/harness.d.ts.map +1 -0
  73. package/dist/types/src/index.d.ts +1 -0
  74. package/dist/types/src/index.d.ts.map +1 -1
  75. package/dist/types/src/operations/add-toast.d.ts +5 -0
  76. package/dist/types/src/operations/add-toast.d.ts.map +1 -0
  77. package/dist/types/src/operations/close.d.ts +5 -0
  78. package/dist/types/src/operations/close.d.ts.map +1 -0
  79. package/dist/types/src/operations/index.d.ts +3 -0
  80. package/dist/types/src/operations/index.d.ts.map +1 -0
  81. package/dist/types/src/operations/open.d.ts +5 -0
  82. package/dist/types/src/operations/open.d.ts.map +1 -0
  83. package/dist/types/src/operations/scroll-into-view.d.ts +5 -0
  84. package/dist/types/src/operations/scroll-into-view.d.ts.map +1 -0
  85. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  86. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  87. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  88. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  89. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  90. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  91. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  92. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  93. package/dist/types/src/operations/update-popover.d.ts +5 -0
  94. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  95. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  96. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  97. package/dist/types/src/operations/update-state.d.ts +5 -0
  98. package/dist/types/src/operations/update-state.d.ts.map +1 -0
  99. package/dist/types/src/plugin.d.ts +5 -0
  100. package/dist/types/src/plugin.d.ts.map +1 -0
  101. package/dist/types/src/types/{capabilities.d.ts → StorybookCapabilities.d.ts} +3 -1
  102. package/dist/types/src/types/StorybookCapabilities.d.ts.map +1 -0
  103. package/dist/types/src/types/index.d.ts +1 -1
  104. package/dist/types/src/types/index.d.ts.map +1 -1
  105. package/dist/types/tsconfig.tsbuildinfo +1 -1
  106. package/package.json +60 -19
  107. package/src/StorybookPlugin.ts +10 -8
  108. package/src/capabilities/index.ts +8 -2
  109. package/src/capabilities/operation-handler.ts +16 -0
  110. package/src/capabilities/{state/state.tsx → state.tsx} +9 -5
  111. package/src/components/Layout/Layout.tsx +135 -75
  112. package/src/core.ts +19 -9
  113. package/src/harness.ts +52 -0
  114. package/src/index.ts +6 -0
  115. package/src/operations/add-toast.ts +22 -0
  116. package/src/operations/close.ts +14 -0
  117. package/src/operations/index.ts +18 -0
  118. package/src/operations/open.ts +18 -0
  119. package/src/operations/scroll-into-view.ts +14 -0
  120. package/src/operations/set-layout-mode.ts +14 -0
  121. package/src/operations/switch-workspace.ts +20 -0
  122. package/src/operations/update-complementary.ts +27 -0
  123. package/src/operations/update-dialog.ts +27 -0
  124. package/src/operations/update-popover.ts +37 -0
  125. package/src/operations/update-sidebar.ts +26 -0
  126. package/src/operations/update-state.ts +19 -0
  127. package/src/plugin.ts +12 -0
  128. package/src/types/{capabilities.ts → StorybookCapabilities.ts} +6 -1
  129. package/src/types/index.ts +1 -1
  130. package/dist/lib/browser/chunk-NWOKPVNQ.mjs.map +0 -7
  131. package/dist/lib/browser/index.mjs +0 -205
  132. package/dist/lib/browser/index.mjs.map +0 -7
  133. package/dist/lib/browser/meta.json +0 -1
  134. package/dist/lib/browser/operation-resolver-SR4GZ7Q5.mjs +0 -112
  135. package/dist/lib/browser/operation-resolver-SR4GZ7Q5.mjs.map +0 -7
  136. package/dist/lib/browser/state-TCYYH5JN.mjs.map +0 -7
  137. package/dist/lib/node-esm/chunk-NWN7D2LS.mjs +0 -23
  138. package/dist/lib/node-esm/chunk-NWN7D2LS.mjs.map +0 -7
  139. package/dist/lib/node-esm/index.mjs.map +0 -7
  140. package/dist/lib/node-esm/meta.json +0 -1
  141. package/dist/lib/node-esm/operation-resolver-A6XLCTWX.mjs +0 -113
  142. package/dist/lib/node-esm/operation-resolver-A6XLCTWX.mjs.map +0 -7
  143. package/dist/lib/node-esm/state-ZJEK6SP7.mjs +0 -44
  144. package/dist/lib/node-esm/state-ZJEK6SP7.mjs.map +0 -7
  145. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  146. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  147. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  148. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  149. package/dist/types/src/capabilities/state/index.d.ts +0 -14
  150. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  151. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  152. package/dist/types/src/types/capabilities.d.ts.map +0 -1
  153. package/src/capabilities/operation-resolver/index.ts +0 -7
  154. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -99
  155. package/src/capabilities/state/index.ts +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-testing",
3
- "version": "0.8.4-main.d05673bc65",
3
+ "version": "0.8.4-main.dfabb4ec29",
4
4
  "description": "Plugin testing utils",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -12,11 +12,53 @@
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
+ "#components": {
22
+ "source": "./src/components/index.ts",
23
+ "types": "./dist/types/src/components/index.d.ts",
24
+ "default": "./dist/lib/neutral/components/index.mjs"
25
+ },
26
+ "#meta": {
27
+ "source": "./src/meta.ts",
28
+ "types": "./dist/types/src/meta.d.ts",
29
+ "default": "./dist/lib/neutral/meta.mjs"
30
+ },
31
+ "#operations": {
32
+ "source": "./src/operations/index.ts",
33
+ "types": "./dist/types/src/operations/index.d.ts",
34
+ "default": "./dist/lib/neutral/operations/index.mjs"
35
+ },
36
+ "#plugin": {
37
+ "source": "./src/StorybookPlugin.ts",
38
+ "types": "./dist/types/src/StorybookPlugin.d.ts",
39
+ "default": "./dist/lib/neutral/StorybookPlugin.mjs"
40
+ },
41
+ "#types": {
42
+ "source": "./src/types/index.ts",
43
+ "types": "./dist/types/src/types/index.d.ts",
44
+ "default": "./dist/lib/neutral/types/index.mjs"
45
+ }
46
+ },
15
47
  "exports": {
16
48
  ".": {
17
49
  "source": "./src/index.ts",
18
50
  "types": "./dist/types/src/index.d.ts",
19
- "browser": "./dist/lib/browser/index.mjs"
51
+ "default": "./dist/lib/neutral/index.mjs"
52
+ },
53
+ "./harness": {
54
+ "source": "./src/harness.ts",
55
+ "types": "./dist/types/src/harness.d.ts",
56
+ "default": "./dist/lib/neutral/harness.mjs"
57
+ },
58
+ "./plugin": {
59
+ "source": "./src/plugin.ts",
60
+ "types": "./dist/types/src/plugin.d.ts",
61
+ "default": "./dist/lib/neutral/plugin.mjs"
20
62
  }
21
63
  },
22
64
  "types": "dist/types/src/index.d.ts",
@@ -27,33 +69,32 @@
27
69
  "dependencies": {
28
70
  "@effect-atom/atom": "^0.5.1",
29
71
  "@effect-atom/atom-react": "^0.5.0",
30
- "@dxos/app-framework": "0.8.4-main.d05673bc65",
31
- "@dxos/app-toolkit": "0.8.4-main.d05673bc65",
32
- "@dxos/operation": "0.8.4-main.d05673bc65",
33
- "@dxos/plugin-attention": "0.8.4-main.d05673bc65",
34
- "@dxos/plugin-client": "0.8.4-main.d05673bc65",
35
- "@dxos/plugin-graph": "0.8.4-main.d05673bc65",
36
- "@dxos/plugin-settings": "0.8.4-main.d05673bc65",
37
- "@dxos/react-ui-mosaic": "0.8.4-main.d05673bc65",
38
- "@dxos/plugin-theme": "0.8.4-main.d05673bc65",
39
- "@dxos/util": "0.8.4-main.d05673bc65"
72
+ "@dxos/app-framework": "0.8.4-main.dfabb4ec29",
73
+ "@dxos/plugin-settings": "0.8.4-main.dfabb4ec29",
74
+ "@dxos/app-toolkit": "0.8.4-main.dfabb4ec29",
75
+ "@dxos/plugin-attention": "0.8.4-main.dfabb4ec29",
76
+ "@dxos/plugin-graph": "0.8.4-main.dfabb4ec29",
77
+ "@dxos/plugin-theme": "0.8.4-main.dfabb4ec29",
78
+ "@dxos/react-ui-mosaic": "0.8.4-main.dfabb4ec29",
79
+ "@dxos/util": "0.8.4-main.dfabb4ec29",
80
+ "@dxos/compute": "0.8.4-main.dfabb4ec29"
40
81
  },
41
82
  "devDependencies": {
42
83
  "@types/react": "~19.2.7",
43
84
  "@types/react-dom": "~19.2.3",
44
- "effect": "3.19.16",
85
+ "effect": "3.20.0",
45
86
  "react": "~19.2.3",
46
87
  "react-dom": "~19.2.3",
47
- "vite": "^7.1.11",
48
- "@dxos/react-ui": "0.8.4-main.d05673bc65",
49
- "@dxos/ui-theme": "0.8.4-main.d05673bc65"
88
+ "vite": "^8.0.10",
89
+ "@dxos/react-ui": "0.8.4-main.dfabb4ec29",
90
+ "@dxos/ui-theme": "0.8.4-main.dfabb4ec29"
50
91
  },
51
92
  "peerDependencies": {
52
- "effect": "3.19.16",
93
+ "effect": "3.20.0",
53
94
  "react": "~19.2.3",
54
95
  "react-dom": "~19.2.3",
55
- "@dxos/react-ui": "0.8.4-main.d05673bc65",
56
- "@dxos/ui-theme": "0.8.4-main.d05673bc65"
96
+ "@dxos/react-ui": "0.8.4-main.dfabb4ec29",
97
+ "@dxos/ui-theme": "0.8.4-main.dfabb4ec29"
57
98
  },
58
99
  "publishConfig": {
59
100
  "access": "public"
@@ -7,18 +7,18 @@ import * as Effect from 'effect/Effect';
7
7
  import { ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';
8
8
  import { AppActivationEvents, AppPlugin } from '@dxos/app-toolkit';
9
9
 
10
- import { OperationResolver, State } from './capabilities';
11
- import { Layout } from './components';
12
- import { meta } from './meta';
13
- import { type LayoutStateProps } from './types';
10
+ import { OperationHandler, State } from '#capabilities';
11
+ import { Layout } from '#components';
12
+ import { meta } from '#meta';
13
+ import { StorybookCapabilities } from '#types';
14
14
 
15
15
  export type StorybookPluginOptions = {
16
- initialState?: Partial<LayoutStateProps>;
16
+ initialState?: Partial<StorybookCapabilities.LayoutStateProps>;
17
17
  };
18
18
 
19
19
  export const StorybookPlugin = Plugin.define<StorybookPluginOptions>(meta).pipe(
20
- AppPlugin.addOperationResolverModule({
21
- activate: OperationResolver,
20
+ AppPlugin.addOperationHandlerModule({
21
+ activate: OperationHandler,
22
22
  }),
23
23
  AppPlugin.addReactContextModule({
24
24
  activate: () =>
@@ -32,8 +32,10 @@ export const StorybookPlugin = Plugin.define<StorybookPluginOptions>(meta).pipe(
32
32
  Plugin.addModule(({ initialState }) => ({
33
33
  id: Capability.getModuleTag(State),
34
34
  activatesOn: ActivationEvents.Startup,
35
- activatesAfter: [AppActivationEvents.LayoutReady],
35
+ firesAfterActivation: [AppActivationEvents.LayoutReady],
36
36
  activate: () => State({ initialState }),
37
37
  })),
38
38
  Plugin.make,
39
39
  );
40
+
41
+ export default StorybookPlugin;
@@ -2,5 +2,11 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './operation-resolver';
6
- export * from './state';
5
+ import { Capability } from '@dxos/app-framework';
6
+ import { OperationHandlerSet } from '@dxos/compute';
7
+
8
+ export const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(
9
+ 'OperationHandler',
10
+ () => import('./operation-handler'),
11
+ );
12
+ export const State = Capability.lazy('State', () => import('./state'));
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { Capabilities, Capability } from '@dxos/app-framework';
8
+ import type { OperationHandlerSet } from '@dxos/compute';
9
+
10
+ import { TestingOperationHandlerSet } from '#operations';
11
+
12
+ export default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(
13
+ Effect.fnUntraced(function* () {
14
+ return Capability.contributes(Capabilities.OperationHandler, TestingOperationHandlerSet);
15
+ }),
16
+ );
@@ -8,19 +8,20 @@ import * as Effect from 'effect/Effect';
8
8
  import { Capability } from '@dxos/app-framework';
9
9
  import { AppCapabilities } from '@dxos/app-toolkit';
10
10
 
11
- import { LayoutState, type LayoutStateProps } from '../../types';
11
+ import { StorybookCapabilities } from '#types';
12
12
 
13
- const defaultState: LayoutStateProps = {
13
+ const defaultState: StorybookCapabilities.LayoutStateProps = {
14
14
  sidebarState: 'closed',
15
15
  complementarySidebarState: 'closed',
16
16
  dialogOpen: false,
17
+ toasts: [],
17
18
  workspace: 'default',
18
19
  };
19
20
 
20
21
  export default Capability.makeModule(
21
- Effect.fnUntraced(function* (props?: { initialState?: Partial<LayoutStateProps> }) {
22
+ Effect.fnUntraced(function* (props?: { initialState?: Partial<StorybookCapabilities.LayoutStateProps> }) {
22
23
  const { initialState } = props ?? {};
23
- const stateAtom = Atom.make<LayoutStateProps>({ ...defaultState, ...initialState });
24
+ const stateAtom = Atom.make<StorybookCapabilities.LayoutStateProps>({ ...defaultState, ...initialState });
24
25
 
25
26
  const layoutAtom = Atom.make((get): AppCapabilities.Layout => {
26
27
  const state = get(stateAtom);
@@ -36,6 +37,9 @@ export default Capability.makeModule(
36
37
  };
37
38
  });
38
39
 
39
- return [Capability.contributes(LayoutState, stateAtom), Capability.contributes(AppCapabilities.Layout, layoutAtom)];
40
+ return [
41
+ Capability.contributes(StorybookCapabilities.LayoutState, stateAtom),
42
+ Capability.contributes(AppCapabilities.Layout, layoutAtom),
43
+ ];
40
44
  }),
41
45
  );
@@ -6,12 +6,17 @@ import { RegistryContext, useAtomValue } from '@effect-atom/atom-react';
6
6
  import React, { type PropsWithChildren, useCallback, useContext, useEffect, useRef, useState } from 'react';
7
7
 
8
8
  import { Surface, useCapability } from '@dxos/app-framework/ui';
9
+ import { type LayoutOperation } from '@dxos/app-toolkit';
10
+ import { AppSurface } from '@dxos/app-toolkit/ui';
9
11
  import {
10
12
  AlertDialog,
13
+ Button,
11
14
  Dialog,
15
+ Icon,
12
16
  Main,
13
17
  Popover,
14
18
  type PopoverContentInteractOutsideEvent,
19
+ Toast,
15
20
  toLocalizedString,
16
21
  useTranslation,
17
22
  } from '@dxos/react-ui';
@@ -19,24 +24,61 @@ import { Card } from '@dxos/react-ui';
19
24
  import { Mosaic } from '@dxos/react-ui-mosaic';
20
25
  import { descriptionMessage, mx } from '@dxos/ui-theme';
21
26
 
22
- import { meta } from '../../meta';
23
- import { LayoutState, type LayoutStateProps } from '../../types';
27
+ import { meta } from '#meta';
28
+ import { StorybookCapabilities } from '#types';
24
29
 
25
30
  const debounce_delay = 100;
26
31
 
27
- // TODO(wittjosiah): Support dialogs, tooltips, maybe toast.
32
+ const StoryToast = ({ toast, onDismiss }: { toast: LayoutOperation.Toast; onDismiss: (id: string) => void }) => {
33
+ const { t } = useTranslation(meta.id);
34
+ return (
35
+ <Toast.Root
36
+ data-testid={toast.id}
37
+ defaultOpen
38
+ duration={toast.duration}
39
+ onOpenChange={(open) => {
40
+ if (!open) {
41
+ onDismiss(toast.id);
42
+ }
43
+ }}
44
+ >
45
+ <Toast.Body>
46
+ <Toast.Title classNames='items-center'>
47
+ {toast.icon && <Icon icon={toast.icon} classNames='inline mr-1' />}
48
+ {toast.title && <span>{toLocalizedString(toast.title, t)}</span>}
49
+ </Toast.Title>
50
+ {toast.description && <Toast.Description>{toLocalizedString(toast.description, t)}</Toast.Description>}
51
+ </Toast.Body>
52
+ <Toast.Actions>
53
+ {toast.onAction && toast.actionAlt && toast.actionLabel && (
54
+ <Toast.Action altText={toLocalizedString(toast.actionAlt, t)} asChild>
55
+ <Button variant='primary' onClick={() => toast.onAction?.()}>
56
+ {toLocalizedString(toast.actionLabel, t)}
57
+ </Button>
58
+ </Toast.Action>
59
+ )}
60
+ {toast.closeLabel && (
61
+ <Toast.Close asChild>
62
+ <Button>{toLocalizedString(toast.closeLabel, t)}</Button>
63
+ </Toast.Close>
64
+ )}
65
+ </Toast.Actions>
66
+ </Toast.Root>
67
+ );
68
+ };
69
+
28
70
  export const Layout = ({ children }: PropsWithChildren<{}>) => {
29
71
  const { t } = useTranslation(meta.id);
30
72
  const trigger = useRef<HTMLButtonElement | null>(null);
31
73
  const registry = useContext(RegistryContext);
32
- const stateAtom = useCapability(LayoutState);
74
+ const stateAtom = useCapability(StorybookCapabilities.LayoutState);
33
75
  const layout = useAtomValue(stateAtom);
34
76
  const [iter, setIter] = useState(0);
35
77
  const [open, setOpen] = useState(false);
36
78
  const debounceRef = useRef<NodeJS.Timeout | null>(null);
37
79
 
38
80
  const updateState = useCallback(
39
- (updates: Partial<LayoutStateProps>) => {
81
+ (updates: Partial<StorybookCapabilities.LayoutStateProps>) => {
40
82
  const current = registry.get(stateAtom);
41
83
  registry.set(stateAtom, { ...current, ...updates });
42
84
  },
@@ -81,81 +123,99 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
81
123
  [handleClose],
82
124
  );
83
125
 
126
+ const handleDismissToast = useCallback(
127
+ (id: string) => {
128
+ updateState({ toasts: layout.toasts.filter((toast) => toast.id !== id) });
129
+ },
130
+ [updateState, layout.toasts],
131
+ );
132
+
84
133
  const DialogRoot = layout.dialogType === 'alert' ? AlertDialog.Root : Dialog.Root;
85
134
  const DialogOverlay = layout.dialogType === 'alert' ? AlertDialog.Overlay : Dialog.Overlay;
86
135
 
87
136
  return (
88
- <div role='none' className='fixed inset-0 flex overflow-hidden'>
89
- <Mosaic.Root>
90
- <Popover.Root open={open}>
91
- <Main.Root
92
- navigationSidebarState={layout.sidebarState}
93
- complementarySidebarState={layout.complementarySidebarState}
94
- onNavigationSidebarStateChange={(next) => updateState({ sidebarState: next })}
95
- onComplementarySidebarStateChange={(next) => updateState({ complementarySidebarState: next })}
96
- >
97
- {children}
98
- </Main.Root>
99
-
100
- <DialogRoot
101
- modal={layout.dialogBlockAlign !== 'end'}
102
- open={layout.dialogOpen}
103
- onOpenChange={(nextOpen) => updateState({ dialogOpen: nextOpen })}
104
- >
105
- {layout.dialogBlockAlign === 'end' ? (
106
- <Surface.Surface
107
- role='dialog'
108
- data={layout.dialogContent}
109
- limit={1}
110
- fallback={ErrorFallback}
111
- placeholder={<div />}
112
- />
113
- ) : (
114
- <DialogOverlay
115
- blockAlign={layout.dialogBlockAlign}
116
- classNames={layout.dialogOverlayClasses}
117
- style={layout.dialogOverlayStyle}
118
- >
119
- <Surface.Surface role='dialog' data={layout.dialogContent} limit={1} fallback={ErrorFallback} />
120
- </DialogOverlay>
121
- )}
122
- </DialogRoot>
123
-
124
- <Popover.VirtualTrigger key={iter} virtualRef={trigger} />
125
- <Popover.Portal>
126
- <Popover.Content
127
- side={layout.popoverSide}
128
- onInteractOutside={handleInteractOutside}
129
- onEscapeKeyDown={handleInteractOutside}
130
- sticky='always'
131
- hideWhenDetached
137
+ <Toast.Provider>
138
+ <div className='fixed inset-0 flex overflow-hidden'>
139
+ <Mosaic.Root>
140
+ <Popover.Root open={open}>
141
+ <Main.Root
142
+ navigationSidebarState={layout.sidebarState}
143
+ complementarySidebarState={layout.complementarySidebarState}
144
+ onNavigationSidebarStateChange={(next) => updateState({ sidebarState: next })}
145
+ onComplementarySidebarStateChange={(next) => updateState({ complementarySidebarState: next })}
146
+ >
147
+ {children}
148
+ </Main.Root>
149
+
150
+ <DialogRoot
151
+ modal={layout.dialogBlockAlign !== 'end'}
152
+ open={layout.dialogOpen}
153
+ onOpenChange={(nextOpen) => updateState({ dialogOpen: nextOpen })}
132
154
  >
133
- <Popover.Viewport>
134
- {layout.popoverKind === 'card' && (
135
- <Card.Root>
136
- <Card.Toolbar>
137
- {/* TODO(wittjosiah): Cleaner way to handle no drag handle in toolbar? */}
138
- <span />
139
- {layout.popoverTitle ? (
140
- <Card.Title>{toLocalizedString(layout.popoverTitle, t)}</Card.Title>
141
- ) : (
155
+ {layout.dialogBlockAlign === 'end' ? (
156
+ <Surface.Surface
157
+ type={AppSurface.Dialog}
158
+ data={layout.dialogContent}
159
+ limit={1}
160
+ fallback={ErrorFallback}
161
+ placeholder={<div />}
162
+ />
163
+ ) : (
164
+ <DialogOverlay
165
+ blockAlign={layout.dialogBlockAlign}
166
+ classNames={layout.dialogOverlayClasses}
167
+ style={layout.dialogOverlayStyle}
168
+ >
169
+ <Surface.Surface
170
+ type={AppSurface.Dialog}
171
+ data={layout.dialogContent}
172
+ limit={1}
173
+ fallback={ErrorFallback}
174
+ />
175
+ </DialogOverlay>
176
+ )}
177
+ </DialogRoot>
178
+
179
+ <Popover.VirtualTrigger key={iter} virtualRef={trigger} />
180
+ <Popover.Portal>
181
+ <Popover.Content
182
+ side={layout.popoverSide}
183
+ onInteractOutside={handleInteractOutside}
184
+ onEscapeKeyDown={handleInteractOutside}
185
+ sticky='always'
186
+ hideWhenDetached
187
+ >
188
+ <Popover.Viewport>
189
+ {layout.popoverKind === 'card' && (
190
+ <Card.Root>
191
+ <Card.Toolbar>
192
+ {/* TODO(wittjosiah): Cleaner way to handle no drag handle in toolbar? */}
142
193
  <span />
143
- )}
144
- <Card.CloseIconButton onClick={handleClose} />
145
- </Card.Toolbar>
146
- <Surface.Surface role='card--content' data={layout.popoverContent} limit={1} />
147
- </Card.Root>
148
- )}
149
- {layout.popoverKind === 'base' && (
150
- <Surface.Surface role='popover' data={layout.popoverContent} limit={1} />
151
- )}
152
- </Popover.Viewport>
153
- <Popover.Arrow />
154
- </Popover.Content>
155
- </Popover.Portal>
156
- </Popover.Root>
157
- </Mosaic.Root>
158
- </div>
194
+ {layout.popoverTitle ? (
195
+ <Card.Title>{toLocalizedString(layout.popoverTitle, t)}</Card.Title>
196
+ ) : (
197
+ <span />
198
+ )}
199
+ <Card.CloseIconButton onClick={handleClose} />
200
+ </Card.Toolbar>
201
+ <Surface.Surface type={AppSurface.Card} data={layout.popoverContent} limit={1} />
202
+ </Card.Root>
203
+ )}
204
+ {layout.popoverKind === 'base' && (
205
+ <Surface.Surface type={AppSurface.Popover} data={layout.popoverContent} limit={1} />
206
+ )}
207
+ </Popover.Viewport>
208
+ <Popover.Arrow />
209
+ </Popover.Content>
210
+ </Popover.Portal>
211
+ </Popover.Root>
212
+ </Mosaic.Root>
213
+ {layout.toasts.map((toast) => (
214
+ <StoryToast key={toast.id} toast={toast} onDismiss={handleDismissToast} />
215
+ ))}
216
+ <Toast.Viewport />
217
+ </div>
218
+ </Toast.Provider>
159
219
  );
160
220
  };
161
221
 
@@ -169,7 +229,7 @@ export const ErrorFallback = ({ error }: { error?: Error }) => {
169
229
  className={mx('overflow-auto p-8 dx-attention-surface grid place-items-center')}
170
230
  >
171
231
  <p className={mx(descriptionMessage, 'break-words rounded-md p-8', errorString.length < 256 && 'text-lg')}>
172
- {error ? errorString : t('error fallback message')}
232
+ {error ? errorString : t('error-fallback.message')}
173
233
  </p>
174
234
  </div>
175
235
  );
package/src/core.ts CHANGED
@@ -3,17 +3,27 @@
3
3
  //
4
4
 
5
5
  import { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';
6
- import { AttentionPlugin } from '@dxos/plugin-attention';
7
- import { ClientPlugin } from '@dxos/plugin-client';
8
- import { GraphPlugin } from '@dxos/plugin-graph';
9
- import { SettingsPlugin } from '@dxos/plugin-settings';
10
- import { ThemePlugin } from '@dxos/plugin-theme';
6
+ // `/plugin` entrypoints `@dxos/plugin-attention/plugin`, `/plugin-client/plugin`,
7
+ // `/plugin-graph/plugin`, `/plugin-preview/plugin`, `/plugin-settings/plugin`,
8
+ // `/plugin-space/plugin`, `/plugin-theme/plugin` re-export the plugin eagerly
9
+ // (without `Plugin.lazy`). The default `.` export wraps each plugin in a lazy
10
+ // stub (`() => import('./XPlugin')`), which webkit cannot reliably resolve
11
+ // under vite-dev: the dynamic-import promise can settle with a
12
+ // partially-evaluated namespace, throwing `ReferenceError: Cannot access
13
+ // 'default' before initialization` from the loader's `mod.default` access.
14
+ // Storybook runs inside `storybook dev` (vite-dev) and is currently the only
15
+ // host that hits this. Production hosts (composer-app via `vite preview`)
16
+ // keep using the lazy `.` exports and their associated code splitting.
17
+ //
18
+ // Use these `/plugin` entrypoints from any storybook `withPluginManager`
19
+ // setup. The single-line `export * from './XPlugin'` re-exports avoid the
20
+ // dynamic-import path entirely — see e.g. `plugin-attention/src/plugin.ts`.
21
+ import { AttentionPlugin } from '@dxos/plugin-attention/testing';
22
+ import { GraphPlugin } from '@dxos/plugin-graph/testing';
23
+ import { SettingsPlugin } from '@dxos/plugin-settings/testing';
24
+ import { ThemePlugin } from '@dxos/plugin-theme/plugin';
11
25
  import { defaultTx } from '@dxos/ui-theme';
12
26
 
13
- // TODO(burdon): Remove this.
14
- // Re-export common framework plugins.
15
- export { AttentionPlugin, ClientPlugin, GraphPlugin, OperationPlugin, RuntimePlugin, SettingsPlugin, ThemePlugin };
16
-
17
27
  /**
18
28
  * Core plugins for testing/storybook environments.
19
29
  * NOTE: Does not include SpacePlugin to avoid circular dependencies.
package/src/harness.ts ADDED
@@ -0,0 +1,52 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';
6
+ import { createTestApp, type TestAppOptions, type TestHarness } from '@dxos/app-framework/testing';
7
+ import { AttentionPlugin } from '@dxos/plugin-attention/plugin';
8
+ import { GraphPlugin } from '@dxos/plugin-graph/plugin';
9
+ import { SettingsPlugin } from '@dxos/plugin-settings/plugin';
10
+
11
+ export type ComposerTestAppOptions = Omit<TestAppOptions, 'plugins'> & {
12
+ /** Plugins to register in addition to the Composer core plugins. */
13
+ plugins?: Plugin.Plugin[];
14
+ /**
15
+ * Whether to include `ThemePlugin` in the core plugin set.
16
+ * Defaults to `false` — `ThemePlugin` requires a browser DOM and breaks Node-only tests.
17
+ * Set to `true` (with jsdom/happy-dom) when rendering React surfaces.
18
+ */
19
+ theme?: boolean;
20
+ };
21
+
22
+ /**
23
+ * Headless core plugins for the test harness — the subset of `corePlugins()`
24
+ * that can be activated without a browser DOM.
25
+ */
26
+ const headlessCorePlugins = (): Plugin.Plugin[] => [
27
+ AttentionPlugin(),
28
+ GraphPlugin(),
29
+ OperationPlugin(),
30
+ RuntimePlugin(),
31
+ SettingsPlugin(),
32
+ ];
33
+
34
+ /**
35
+ * Creates a TestHarness pre-loaded with the Composer core plugins
36
+ * (Attention, Graph, Operation, Runtime, Settings, optionally Theme).
37
+ *
38
+ * For a ClientPlugin-backed harness, pass `ClientPlugin({ ... })` via `plugins`.
39
+ */
40
+ export const createComposerTestApp = async (opts: ComposerTestAppOptions = {}): Promise<TestHarness> => {
41
+ const { plugins = [], theme = false, ...rest } = opts;
42
+ const core = headlessCorePlugins();
43
+ if (theme) {
44
+ const { ThemePlugin } = await import('@dxos/plugin-theme/plugin');
45
+ const { defaultTx } = await import('@dxos/ui-theme');
46
+ core.push(ThemePlugin({ tx: defaultTx }));
47
+ }
48
+ return createTestApp({
49
+ ...rest,
50
+ plugins: [...core, ...plugins],
51
+ });
52
+ };
package/src/index.ts CHANGED
@@ -4,5 +4,11 @@
4
4
 
5
5
  export * from './core';
6
6
  export * from './meta';
7
+ export * from './types';
7
8
 
9
+ // `@dxos/plugin-testing` is a testing-only package, so `StorybookPlugin` is
10
+ // exported eagerly from the `.` entrypoint (no `Plugin.lazy` indirection).
11
+ // Storybook on webkit + vite-dev cannot reliably resolve the lazy form's
12
+ // dynamic `import()` — see `./core.ts` for the underlying chunk-init issue
13
+ // — and there is no production code-splitting benefit to recover here.
8
14
  export * from './StorybookPlugin';
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { LayoutOperation } from '@dxos/app-toolkit';
8
+ import { Operation } from '@dxos/compute';
9
+
10
+ import { updateState } from './update-state';
11
+
12
+ const handler: Operation.WithHandler<typeof LayoutOperation.AddToast> = LayoutOperation.AddToast.pipe(
13
+ Operation.withHandler(
14
+ Effect.fnUntraced(function* (input) {
15
+ yield* updateState((state) => ({
16
+ toasts: [...state.toasts, input as LayoutOperation.Toast],
17
+ }));
18
+ }),
19
+ ),
20
+ );
21
+
22
+ export default handler;
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Effect from 'effect/Effect';
6
+
7
+ import { LayoutOperation } from '@dxos/app-toolkit';
8
+ import { Operation } from '@dxos/compute';
9
+
10
+ const handler: Operation.WithHandler<typeof LayoutOperation.Close> = LayoutOperation.Close.pipe(
11
+ Operation.withHandler(() => Effect.void),
12
+ );
13
+
14
+ export default handler;
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { OperationHandlerSet } from '@dxos/compute';
6
+
7
+ export const TestingOperationHandlerSet = OperationHandlerSet.lazy(
8
+ () => import('./add-toast'),
9
+ () => import('./close'),
10
+ () => import('./open'),
11
+ () => import('./scroll-into-view'),
12
+ () => import('./set-layout-mode'),
13
+ () => import('./switch-workspace'),
14
+ () => import('./update-complementary'),
15
+ () => import('./update-dialog'),
16
+ () => import('./update-popover'),
17
+ () => import('./update-sidebar'),
18
+ );