@dxos/plugin-testing 0.8.4-main.1068cf700f → 0.8.4-main.1c7ec43d41
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.
- package/dist/lib/browser/harness.mjs +35 -0
- package/dist/lib/browser/harness.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -183
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/harness.mjs +37 -0
- package/dist/lib/node-esm/harness.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -183
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/StorybookPlugin.d.ts +2 -1
- package/dist/types/src/StorybookPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +15 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/{Layout.d.ts → Layout/Layout.d.ts} +1 -1
- package/dist/types/src/components/Layout/Layout.d.ts.map +1 -0
- package/dist/types/src/components/Layout/index.d.ts +2 -0
- package/dist/types/src/components/Layout/index.d.ts.map +1 -0
- package/dist/types/src/core.d.ts +1 -7
- package/dist/types/src/core.d.ts.map +1 -1
- package/dist/types/src/harness.d.ts +20 -0
- package/dist/types/src/harness.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/add-toast.d.ts +5 -0
- package/dist/types/src/operations/add-toast.d.ts.map +1 -0
- package/dist/types/src/operations/close.d.ts +5 -0
- package/dist/types/src/operations/close.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/scroll-into-view.d.ts +5 -0
- package/dist/types/src/operations/scroll-into-view.d.ts.map +1 -0
- package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
- package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
- package/dist/types/src/operations/switch-workspace.d.ts +5 -0
- package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/update-complementary.d.ts +5 -0
- package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
- package/dist/types/src/operations/update-dialog.d.ts +5 -0
- package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
- package/dist/types/src/operations/update-popover.d.ts +5 -0
- package/dist/types/src/operations/update-popover.d.ts.map +1 -0
- package/dist/types/src/operations/update-sidebar.d.ts +5 -0
- package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
- package/dist/types/src/operations/update-state.d.ts +5 -0
- package/dist/types/src/operations/update-state.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +2 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -18
- package/src/StorybookPlugin.ts +9 -7
- package/src/capabilities/index.ts +8 -2
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/{state/state.tsx → state.tsx} +2 -1
- package/src/components/Layout/Layout.tsx +236 -0
- package/src/components/Layout/index.ts +5 -0
- package/src/core.ts +19 -9
- package/src/harness.ts +52 -0
- package/src/index.ts +6 -1
- package/src/meta.ts +1 -1
- package/src/operations/add-toast.ts +22 -0
- package/src/operations/close.ts +14 -0
- package/src/operations/index.ts +18 -0
- package/src/operations/open.ts +18 -0
- package/src/operations/scroll-into-view.ts +14 -0
- package/src/operations/set-layout-mode.ts +14 -0
- package/src/operations/switch-workspace.ts +20 -0
- package/src/operations/update-complementary.ts +27 -0
- package/src/operations/update-dialog.ts +27 -0
- package/src/operations/update-popover.ts +37 -0
- package/src/operations/update-sidebar.ts +26 -0
- package/src/operations/update-state.ts +17 -0
- package/src/types/capabilities.ts +5 -2
- package/dist/lib/browser/chunk-YHPXIILW.mjs +0 -21
- package/dist/lib/browser/chunk-YHPXIILW.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-FLU4ZARD.mjs +0 -112
- package/dist/lib/browser/operation-resolver-FLU4ZARD.mjs.map +0 -7
- package/dist/lib/browser/state-MIKI67FF.mjs +0 -43
- package/dist/lib/browser/state-MIKI67FF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OWK6XE6C.mjs +0 -23
- package/dist/lib/node-esm/chunk-OWK6XE6C.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-NWF6KBHP.mjs +0 -113
- package/dist/lib/node-esm/operation-resolver-NWF6KBHP.mjs.map +0 -7
- package/dist/lib/node-esm/state-JQVVUKO2.mjs +0 -44
- package/dist/lib/node-esm/state-JQVVUKO2.mjs.map +0 -7
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -14
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/components/Layout.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -99
- package/src/capabilities/state/index.ts +0 -7
- package/src/components/Layout.tsx +0 -174
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/harness.ts
|
|
2
|
+
import { OperationPlugin, RuntimePlugin } from "@dxos/app-framework";
|
|
3
|
+
import { createTestApp } from "@dxos/app-framework/testing";
|
|
4
|
+
import { AttentionPlugin } from "@dxos/plugin-attention";
|
|
5
|
+
import { GraphPlugin } from "@dxos/plugin-graph";
|
|
6
|
+
import { SettingsPlugin } from "@dxos/plugin-settings";
|
|
7
|
+
var headlessCorePlugins = () => [
|
|
8
|
+
AttentionPlugin(),
|
|
9
|
+
GraphPlugin(),
|
|
10
|
+
OperationPlugin(),
|
|
11
|
+
RuntimePlugin(),
|
|
12
|
+
SettingsPlugin()
|
|
13
|
+
];
|
|
14
|
+
var createComposerTestApp = async (opts = {}) => {
|
|
15
|
+
const { plugins = [], theme = false, ...rest } = opts;
|
|
16
|
+
const core = headlessCorePlugins();
|
|
17
|
+
if (theme) {
|
|
18
|
+
const { ThemePlugin } = await import("@dxos/plugin-theme");
|
|
19
|
+
const { defaultTx } = await import("@dxos/ui-theme");
|
|
20
|
+
core.push(ThemePlugin({
|
|
21
|
+
tx: defaultTx
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
return createTestApp({
|
|
25
|
+
...rest,
|
|
26
|
+
plugins: [
|
|
27
|
+
...core,
|
|
28
|
+
...plugins
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
createComposerTestApp
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=harness.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/harness.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';\nimport { createTestApp, type TestAppOptions, type TestHarness } from '@dxos/app-framework/testing';\nimport { AttentionPlugin } from '@dxos/plugin-attention';\nimport { GraphPlugin } from '@dxos/plugin-graph';\nimport { SettingsPlugin } from '@dxos/plugin-settings';\n\nexport type ComposerTestAppOptions = Omit<TestAppOptions, 'plugins'> & {\n /** Plugins to register in addition to the Composer core plugins. */\n plugins?: Plugin.Plugin[];\n /**\n * Whether to include `ThemePlugin` in the core plugin set.\n * Defaults to `false` — `ThemePlugin` requires a browser DOM and breaks Node-only tests.\n * Set to `true` (with jsdom/happy-dom) when rendering React surfaces.\n */\n theme?: boolean;\n};\n\n/**\n * Headless core plugins for the test harness — the subset of `corePlugins()`\n * that can be activated without a browser DOM.\n */\nconst headlessCorePlugins = (): Plugin.Plugin[] => [\n AttentionPlugin(),\n GraphPlugin(),\n OperationPlugin(),\n RuntimePlugin(),\n SettingsPlugin(),\n];\n\n/**\n * Creates a TestHarness pre-loaded with the Composer core plugins\n * (Attention, Graph, Operation, Runtime, Settings, optionally Theme).\n *\n * For a ClientPlugin-backed harness, pass `ClientPlugin({ ... })` via `plugins`.\n */\nexport const createComposerTestApp = async (opts: ComposerTestAppOptions = {}): Promise<TestHarness> => {\n const { plugins = [], theme = false, ...rest } = opts;\n const core = headlessCorePlugins();\n if (theme) {\n const { ThemePlugin } = await import('@dxos/plugin-theme');\n const { defaultTx } = await import('@dxos/ui-theme');\n core.push(ThemePlugin({ tx: defaultTx }));\n }\n return createTestApp({\n ...rest,\n plugins: [...core, ...plugins],\n });\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,iBAA8BC,qBAAqB;AAC5D,SAASC,qBAA4D;AACrE,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;AAC5B,SAASC,sBAAsB;AAiB/B,IAAMC,sBAAsB,MAAuB;EACjDH,gBAAAA;EACAC,YAAAA;EACAJ,gBAAAA;EACAC,cAAAA;EACAI,eAAAA;;AASK,IAAME,wBAAwB,OAAOC,OAA+B,CAAC,MAAC;AAC3E,QAAM,EAAEC,UAAU,CAAA,GAAIC,QAAQ,OAAO,GAAGC,KAAAA,IAASH;AACjD,QAAMI,OAAON,oBAAAA;AACb,MAAII,OAAO;AACT,UAAM,EAAEG,YAAW,IAAK,MAAM,OAAO,oBAAA;AACrC,UAAM,EAAEC,UAAS,IAAK,MAAM,OAAO,gBAAA;AACnCF,SAAKG,KAAKF,YAAY;MAAEG,IAAIF;IAAU,CAAA,CAAA;EACxC;AACA,SAAOZ,cAAc;IACnB,GAAGS;IACHF,SAAS;SAAIG;SAASH;;EACxB,CAAA;AACF;",
|
|
6
|
+
"names": ["OperationPlugin", "RuntimePlugin", "createTestApp", "AttentionPlugin", "GraphPlugin", "SettingsPlugin", "headlessCorePlugins", "createComposerTestApp", "opts", "plugins", "theme", "rest", "core", "ThemePlugin", "defaultTx", "push", "tx"]
|
|
7
|
+
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Plugin } from "@dxos/app-framework";
|
|
3
|
+
|
|
4
|
+
// src/meta.ts
|
|
5
|
+
import { trim } from "@dxos/util";
|
|
6
|
+
var meta = {
|
|
7
|
+
id: "org.dxos.plugin.storybook-layout",
|
|
8
|
+
name: "Storybook",
|
|
9
|
+
description: trim`
|
|
10
|
+
Development layout optimized for Storybook component testing and documentation.
|
|
11
|
+
Provides specialized views for component development and design system exploration.
|
|
12
|
+
`,
|
|
13
|
+
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-testing"
|
|
14
|
+
};
|
|
5
15
|
|
|
6
16
|
// src/core.ts
|
|
7
17
|
import { OperationPlugin, RuntimePlugin } from "@dxos/app-framework";
|
|
8
|
-
import { AttentionPlugin } from "@dxos/plugin-attention";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ThemePlugin } from "@dxos/plugin-theme";
|
|
18
|
+
import { AttentionPlugin } from "@dxos/plugin-attention/plugin";
|
|
19
|
+
import { GraphPlugin } from "@dxos/plugin-graph/plugin";
|
|
20
|
+
import { SettingsPlugin } from "@dxos/plugin-settings/plugin";
|
|
21
|
+
import { ThemePlugin } from "@dxos/plugin-theme/plugin";
|
|
13
22
|
import { defaultTx } from "@dxos/ui-theme";
|
|
14
23
|
var corePlugins = () => [
|
|
15
24
|
AttentionPlugin(),
|
|
@@ -22,182 +31,10 @@ var corePlugins = () => [
|
|
|
22
31
|
})
|
|
23
32
|
];
|
|
24
33
|
|
|
25
|
-
// src/
|
|
26
|
-
|
|
27
|
-
import { ActivationEvents, Capabilities, Capability as Capability3, Plugin } from "@dxos/app-framework";
|
|
28
|
-
import { AppActivationEvents, AppPlugin } from "@dxos/app-toolkit";
|
|
29
|
-
|
|
30
|
-
// src/capabilities/operation-resolver/index.ts
|
|
31
|
-
import { Capability } from "@dxos/app-framework";
|
|
32
|
-
var OperationResolver = Capability.lazy("OperationResolver", () => import("./operation-resolver-FLU4ZARD.mjs"));
|
|
33
|
-
|
|
34
|
-
// src/capabilities/state/index.ts
|
|
35
|
-
import { Capability as Capability2 } from "@dxos/app-framework";
|
|
36
|
-
var State = Capability2.lazy("State", () => import("./state-MIKI67FF.mjs"));
|
|
37
|
-
|
|
38
|
-
// src/components/Layout.tsx
|
|
39
|
-
import { RegistryContext, useAtomValue } from "@effect-atom/atom-react";
|
|
40
|
-
import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
41
|
-
import { Surface, useCapability } from "@dxos/app-framework/ui";
|
|
42
|
-
import { AlertDialog, Dialog, Main, Popover, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
43
|
-
import { Card, Mosaic } from "@dxos/react-ui-mosaic";
|
|
44
|
-
import { descriptionMessage, mx } from "@dxos/ui-theme";
|
|
45
|
-
var debounce_delay = 100;
|
|
46
|
-
var Layout = ({ children }) => {
|
|
47
|
-
const { t } = useTranslation(meta.id);
|
|
48
|
-
const trigger = useRef(null);
|
|
49
|
-
const registry = useContext(RegistryContext);
|
|
50
|
-
const stateAtom = useCapability(LayoutState);
|
|
51
|
-
const layout = useAtomValue(stateAtom);
|
|
52
|
-
const [iter, setIter] = useState(0);
|
|
53
|
-
const [open, setOpen] = useState(false);
|
|
54
|
-
const debounceRef = useRef(null);
|
|
55
|
-
const updateState = useCallback((updates) => {
|
|
56
|
-
const current = registry.get(stateAtom);
|
|
57
|
-
registry.set(stateAtom, {
|
|
58
|
-
...current,
|
|
59
|
-
...updates
|
|
60
|
-
});
|
|
61
|
-
}, [
|
|
62
|
-
registry,
|
|
63
|
-
stateAtom
|
|
64
|
-
]);
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
setOpen(false);
|
|
67
|
-
if (debounceRef.current) {
|
|
68
|
-
clearTimeout(debounceRef.current);
|
|
69
|
-
debounceRef.current = null;
|
|
70
|
-
}
|
|
71
|
-
trigger.current = layout.popoverAnchor ?? null;
|
|
72
|
-
setIter((iter2) => iter2 + 1);
|
|
73
|
-
if (layout.popoverOpen) {
|
|
74
|
-
debounceRef.current = setTimeout(() => setOpen(true), debounce_delay);
|
|
75
|
-
}
|
|
76
|
-
}, [
|
|
77
|
-
layout.popoverAnchor,
|
|
78
|
-
layout.popoverContent,
|
|
79
|
-
layout.popoverOpen
|
|
80
|
-
]);
|
|
81
|
-
const handleClose = useCallback(() => {
|
|
82
|
-
setOpen(false);
|
|
83
|
-
updateState({
|
|
84
|
-
popoverOpen: false,
|
|
85
|
-
popoverAnchor: void 0,
|
|
86
|
-
popoverAnchorId: void 0,
|
|
87
|
-
popoverSide: void 0
|
|
88
|
-
});
|
|
89
|
-
}, [
|
|
90
|
-
updateState
|
|
91
|
-
]);
|
|
92
|
-
const handleInteractOutside = useCallback((event) => {
|
|
93
|
-
if (
|
|
94
|
-
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
95
|
-
event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
|
|
96
|
-
) {
|
|
97
|
-
event.preventDefault();
|
|
98
|
-
} else {
|
|
99
|
-
handleClose();
|
|
100
|
-
}
|
|
101
|
-
}, [
|
|
102
|
-
handleClose
|
|
103
|
-
]);
|
|
104
|
-
const DialogRoot = layout.dialogType === "alert" ? AlertDialog.Root : Dialog.Root;
|
|
105
|
-
const DialogOverlay = layout.dialogType === "alert" ? AlertDialog.Overlay : Dialog.Overlay;
|
|
106
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
107
|
-
role: "none",
|
|
108
|
-
className: "fixed inset-0 flex overflow-hidden"
|
|
109
|
-
}, /* @__PURE__ */ React.createElement(Mosaic.Root, null, /* @__PURE__ */ React.createElement(Popover.Root, {
|
|
110
|
-
open
|
|
111
|
-
}, /* @__PURE__ */ React.createElement(Main.Root, {
|
|
112
|
-
navigationSidebarState: layout.sidebarState,
|
|
113
|
-
complementarySidebarState: layout.complementarySidebarState,
|
|
114
|
-
onNavigationSidebarStateChange: (next) => updateState({
|
|
115
|
-
sidebarState: next
|
|
116
|
-
}),
|
|
117
|
-
onComplementarySidebarStateChange: (next) => updateState({
|
|
118
|
-
complementarySidebarState: next
|
|
119
|
-
})
|
|
120
|
-
}, children), /* @__PURE__ */ React.createElement(DialogRoot, {
|
|
121
|
-
modal: layout.dialogBlockAlign !== "end",
|
|
122
|
-
open: layout.dialogOpen,
|
|
123
|
-
onOpenChange: (nextOpen) => updateState({
|
|
124
|
-
dialogOpen: nextOpen
|
|
125
|
-
})
|
|
126
|
-
}, layout.dialogBlockAlign === "end" ? /* @__PURE__ */ React.createElement(Surface.Surface, {
|
|
127
|
-
role: "dialog",
|
|
128
|
-
data: layout.dialogContent,
|
|
129
|
-
limit: 1,
|
|
130
|
-
fallback: ContentError,
|
|
131
|
-
placeholder: /* @__PURE__ */ React.createElement("div", null)
|
|
132
|
-
}) : /* @__PURE__ */ React.createElement(DialogOverlay, {
|
|
133
|
-
blockAlign: layout.dialogBlockAlign,
|
|
134
|
-
classNames: layout.dialogOverlayClasses,
|
|
135
|
-
style: layout.dialogOverlayStyle
|
|
136
|
-
}, /* @__PURE__ */ React.createElement(Surface.Surface, {
|
|
137
|
-
role: "dialog",
|
|
138
|
-
data: layout.dialogContent,
|
|
139
|
-
limit: 1,
|
|
140
|
-
fallback: ContentError
|
|
141
|
-
}))), /* @__PURE__ */ React.createElement(Popover.VirtualTrigger, {
|
|
142
|
-
key: iter,
|
|
143
|
-
virtualRef: trigger
|
|
144
|
-
}), /* @__PURE__ */ React.createElement(Popover.Portal, null, /* @__PURE__ */ React.createElement(Popover.Content, {
|
|
145
|
-
side: layout.popoverSide,
|
|
146
|
-
onInteractOutside: handleInteractOutside,
|
|
147
|
-
onEscapeKeyDown: handleInteractOutside,
|
|
148
|
-
sticky: "always",
|
|
149
|
-
hideWhenDetached: true
|
|
150
|
-
}, /* @__PURE__ */ React.createElement(Popover.Viewport, null, layout.popoverKind === "card" && /* @__PURE__ */ React.createElement(Card.Root, null, /* @__PURE__ */ React.createElement(Card.Toolbar, null, /* @__PURE__ */ React.createElement("span", null), layout.popoverTitle ? /* @__PURE__ */ React.createElement(Card.Title, null, toLocalizedString(layout.popoverTitle, t)) : /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement(Card.Close, {
|
|
151
|
-
onClick: handleClose
|
|
152
|
-
})), /* @__PURE__ */ React.createElement(Surface.Surface, {
|
|
153
|
-
role: "card--content",
|
|
154
|
-
data: layout.popoverContent,
|
|
155
|
-
limit: 1
|
|
156
|
-
})), layout.popoverKind === "base" && /* @__PURE__ */ React.createElement(Surface.Surface, {
|
|
157
|
-
role: "popover",
|
|
158
|
-
data: layout.popoverContent,
|
|
159
|
-
limit: 1
|
|
160
|
-
})), /* @__PURE__ */ React.createElement(Popover.Arrow, null))))));
|
|
161
|
-
};
|
|
162
|
-
var ContentError = ({ error }) => {
|
|
163
|
-
const { t } = useTranslation(meta.id);
|
|
164
|
-
const errorString = error?.toString() ?? "";
|
|
165
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
166
|
-
role: "none",
|
|
167
|
-
className: "overflow-auto p-8 attention-surface grid place-items-center"
|
|
168
|
-
}, /* @__PURE__ */ React.createElement("p", {
|
|
169
|
-
role: "alert",
|
|
170
|
-
className: mx(descriptionMessage, "break-words rounded-md p-8", errorString.length < 256 && "text-lg")
|
|
171
|
-
}, error ? errorString : t("error fallback message")));
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// src/StorybookPlugin.ts
|
|
175
|
-
var StorybookPlugin = Plugin.define(meta).pipe(AppPlugin.addOperationResolverModule({
|
|
176
|
-
activate: OperationResolver
|
|
177
|
-
}), AppPlugin.addReactContextModule({
|
|
178
|
-
activate: () => Effect.succeed(Capability3.contributes(Capabilities.ReactContext, {
|
|
179
|
-
id: "storybook-layout",
|
|
180
|
-
context: Layout
|
|
181
|
-
}))
|
|
182
|
-
}), Plugin.addModule(({ initialState }) => ({
|
|
183
|
-
id: Capability3.getModuleTag(State),
|
|
184
|
-
activatesOn: ActivationEvents.Startup,
|
|
185
|
-
activatesAfter: [
|
|
186
|
-
AppActivationEvents.LayoutReady
|
|
187
|
-
],
|
|
188
|
-
activate: () => State({
|
|
189
|
-
initialState
|
|
190
|
-
})
|
|
191
|
-
})), Plugin.make);
|
|
34
|
+
// src/index.ts
|
|
35
|
+
var StorybookPlugin = Plugin.lazy(meta, () => import("#plugin"));
|
|
192
36
|
export {
|
|
193
|
-
AttentionPlugin,
|
|
194
|
-
ClientPlugin,
|
|
195
|
-
GraphPlugin,
|
|
196
|
-
OperationPlugin,
|
|
197
|
-
RuntimePlugin,
|
|
198
|
-
SettingsPlugin,
|
|
199
37
|
StorybookPlugin,
|
|
200
|
-
ThemePlugin,
|
|
201
38
|
corePlugins,
|
|
202
39
|
meta
|
|
203
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/meta.ts", "../../../src/core.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport * from './core';\nexport * from './meta';\n\nexport const StorybookPlugin = Plugin.lazy(meta, () => import('#plugin'));\nexport type { StorybookPluginOptions } from '#plugin';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.storybook-layout',\n name: 'Storybook',\n description: trim`\n Development layout optimized for Storybook component testing and documentation.\n Provides specialized views for component development and design system exploration.\n `,\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-testing',\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';\n// `/plugin` entrypoints — `@dxos/plugin-attention/plugin`, `/plugin-client/plugin`,\n// `/plugin-graph/plugin`, `/plugin-preview/plugin`, `/plugin-settings/plugin`,\n// `/plugin-space/plugin`, `/plugin-theme/plugin` — re-export the plugin eagerly\n// (without `Plugin.lazy`). The default `.` export wraps each plugin in a lazy\n// stub (`() => import('./XPlugin')`), which webkit cannot reliably resolve\n// under vite-dev: the dynamic-import promise can settle with a\n// partially-evaluated namespace, throwing `ReferenceError: Cannot access\n// 'default' before initialization` from the loader's `mod.default` access.\n// Storybook runs inside `storybook dev` (vite-dev) and is currently the only\n// host that hits this. Production hosts (composer-app via `vite preview`)\n// keep using the lazy `.` exports and their associated code splitting.\n//\n// Use these `/plugin` entrypoints from any storybook `withPluginManager`\n// setup. The single-line `export * from './XPlugin'` re-exports avoid the\n// dynamic-import path entirely — see e.g. `plugin-attention/src/plugin.ts`.\nimport { AttentionPlugin } from '@dxos/plugin-attention/plugin';\nimport { GraphPlugin } from '@dxos/plugin-graph/plugin';\nimport { SettingsPlugin } from '@dxos/plugin-settings/plugin';\nimport { ThemePlugin } from '@dxos/plugin-theme/plugin';\nimport { defaultTx } from '@dxos/ui-theme';\n\n/**\n * Core plugins for testing/storybook environments.\n * NOTE: Does not include SpacePlugin to avoid circular dependencies.\n * Import SpacePlugin directly in your stories if needed.\n */\nexport const corePlugins = (): Plugin.Plugin[] => [\n AttentionPlugin(),\n GraphPlugin(),\n OperationPlugin(),\n RuntimePlugin(),\n SettingsPlugin(),\n ThemePlugin({ tx: defaultTx }),\n];\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,cAAc;;;ACCvB,SAASC,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaJ;;;;EAIbK,QAAQ;AACV;;;ACXA,SAASC,iBAA8BC,qBAAqB;AAgB5D,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;AAC5B,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;AAC5B,SAASC,iBAAiB;AAOnB,IAAMC,cAAc,MAAuB;EAChDL,gBAAAA;EACAC,YAAAA;EACAH,gBAAAA;EACAC,cAAAA;EACAG,eAAAA;EACAC,YAAY;IAAEG,IAAIF;EAAU,CAAA;;;;AF1BvB,IAAMG,kBAAkBC,OAAOC,KAAKC,MAAM,MAAM,OAAO,SAAA,CAAA;",
|
|
6
|
+
"names": ["Plugin", "trim", "meta", "id", "name", "description", "source", "OperationPlugin", "RuntimePlugin", "AttentionPlugin", "GraphPlugin", "SettingsPlugin", "ThemePlugin", "defaultTx", "corePlugins", "tx", "StorybookPlugin", "Plugin", "lazy", "meta"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/
|
|
1
|
+
{"inputs":{"src/meta.ts":{"bytes":1576,"imports":[{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/core.ts":{"bytes":5426,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-settings/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-theme/plugin","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":1102,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"src/core.ts","kind":"import-statement","original":"./core"},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"#plugin","kind":"dynamic-import","external":true}],"format":"esm"},"src/harness.ts":{"bytes":5175,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-framework/testing","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-settings","kind":"import-statement","external":true},{"path":"@dxos/plugin-theme","kind":"dynamic-import","external":true},{"path":"@dxos/ui-theme","kind":"dynamic-import","external":true}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":3548},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-settings/plugin","kind":"import-statement","external":true},{"path":"@dxos/plugin-theme/plugin","kind":"import-statement","external":true},{"path":"@dxos/ui-theme","kind":"import-statement","external":true},{"path":"#plugin","kind":"dynamic-import","external":true}],"exports":["StorybookPlugin","corePlugins","meta"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":112},"src/meta.ts":{"bytesInOutput":395},"src/core.ts":{"bytesInOutput":522}},"bytes":1182},"dist/lib/browser/harness.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2767},"dist/lib/browser/harness.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-framework/testing","kind":"import-statement","external":true},{"path":"@dxos/plugin-attention","kind":"import-statement","external":true},{"path":"@dxos/plugin-graph","kind":"import-statement","external":true},{"path":"@dxos/plugin-settings","kind":"import-statement","external":true},{"path":"@dxos/plugin-theme","kind":"dynamic-import","external":true},{"path":"@dxos/ui-theme","kind":"dynamic-import","external":true}],"exports":["createComposerTestApp"],"entryPoint":"src/harness.ts","inputs":{"src/harness.ts":{"bytesInOutput":873}},"bytes":964}}}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/harness.ts
|
|
4
|
+
import { OperationPlugin, RuntimePlugin } from "@dxos/app-framework";
|
|
5
|
+
import { createTestApp } from "@dxos/app-framework/testing";
|
|
6
|
+
import { AttentionPlugin } from "@dxos/plugin-attention";
|
|
7
|
+
import { GraphPlugin } from "@dxos/plugin-graph";
|
|
8
|
+
import { SettingsPlugin } from "@dxos/plugin-settings";
|
|
9
|
+
var headlessCorePlugins = () => [
|
|
10
|
+
AttentionPlugin(),
|
|
11
|
+
GraphPlugin(),
|
|
12
|
+
OperationPlugin(),
|
|
13
|
+
RuntimePlugin(),
|
|
14
|
+
SettingsPlugin()
|
|
15
|
+
];
|
|
16
|
+
var createComposerTestApp = async (opts = {}) => {
|
|
17
|
+
const { plugins = [], theme = false, ...rest } = opts;
|
|
18
|
+
const core = headlessCorePlugins();
|
|
19
|
+
if (theme) {
|
|
20
|
+
const { ThemePlugin } = await import("@dxos/plugin-theme");
|
|
21
|
+
const { defaultTx } = await import("@dxos/ui-theme");
|
|
22
|
+
core.push(ThemePlugin({
|
|
23
|
+
tx: defaultTx
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
return createTestApp({
|
|
27
|
+
...rest,
|
|
28
|
+
plugins: [
|
|
29
|
+
...core,
|
|
30
|
+
...plugins
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
createComposerTestApp
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=harness.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/harness.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';\nimport { createTestApp, type TestAppOptions, type TestHarness } from '@dxos/app-framework/testing';\nimport { AttentionPlugin } from '@dxos/plugin-attention';\nimport { GraphPlugin } from '@dxos/plugin-graph';\nimport { SettingsPlugin } from '@dxos/plugin-settings';\n\nexport type ComposerTestAppOptions = Omit<TestAppOptions, 'plugins'> & {\n /** Plugins to register in addition to the Composer core plugins. */\n plugins?: Plugin.Plugin[];\n /**\n * Whether to include `ThemePlugin` in the core plugin set.\n * Defaults to `false` — `ThemePlugin` requires a browser DOM and breaks Node-only tests.\n * Set to `true` (with jsdom/happy-dom) when rendering React surfaces.\n */\n theme?: boolean;\n};\n\n/**\n * Headless core plugins for the test harness — the subset of `corePlugins()`\n * that can be activated without a browser DOM.\n */\nconst headlessCorePlugins = (): Plugin.Plugin[] => [\n AttentionPlugin(),\n GraphPlugin(),\n OperationPlugin(),\n RuntimePlugin(),\n SettingsPlugin(),\n];\n\n/**\n * Creates a TestHarness pre-loaded with the Composer core plugins\n * (Attention, Graph, Operation, Runtime, Settings, optionally Theme).\n *\n * For a ClientPlugin-backed harness, pass `ClientPlugin({ ... })` via `plugins`.\n */\nexport const createComposerTestApp = async (opts: ComposerTestAppOptions = {}): Promise<TestHarness> => {\n const { plugins = [], theme = false, ...rest } = opts;\n const core = headlessCorePlugins();\n if (theme) {\n const { ThemePlugin } = await import('@dxos/plugin-theme');\n const { defaultTx } = await import('@dxos/ui-theme');\n core.push(ThemePlugin({ tx: defaultTx }));\n }\n return createTestApp({\n ...rest,\n plugins: [...core, ...plugins],\n });\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,iBAA8BC,qBAAqB;AAC5D,SAASC,qBAA4D;AACrE,SAASC,uBAAuB;AAChC,SAASC,mBAAmB;AAC5B,SAASC,sBAAsB;AAiB/B,IAAMC,sBAAsB,MAAuB;EACjDH,gBAAAA;EACAC,YAAAA;EACAJ,gBAAAA;EACAC,cAAAA;EACAI,eAAAA;;AASK,IAAME,wBAAwB,OAAOC,OAA+B,CAAC,MAAC;AAC3E,QAAM,EAAEC,UAAU,CAAA,GAAIC,QAAQ,OAAO,GAAGC,KAAAA,IAASH;AACjD,QAAMI,OAAON,oBAAAA;AACb,MAAII,OAAO;AACT,UAAM,EAAEG,YAAW,IAAK,MAAM,OAAO,oBAAA;AACrC,UAAM,EAAEC,UAAS,IAAK,MAAM,OAAO,gBAAA;AACnCF,SAAKG,KAAKF,YAAY;MAAEG,IAAIF;IAAU,CAAA,CAAA;EACxC;AACA,SAAOZ,cAAc;IACnB,GAAGS;IACHF,SAAS;SAAIG;SAASH;;EACxB,CAAA;AACF;",
|
|
6
|
+
"names": ["OperationPlugin", "RuntimePlugin", "createTestApp", "AttentionPlugin", "GraphPlugin", "SettingsPlugin", "headlessCorePlugins", "createComposerTestApp", "opts", "plugins", "theme", "rest", "core", "ThemePlugin", "defaultTx", "push", "tx"]
|
|
7
|
+
}
|