dreamboard 0.1.21 → 0.1.23

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 (186) hide show
  1. package/dist/{chunk-EYYWGWTO.js → chunk-2RCUHMGL.js} +343 -1911
  2. package/dist/chunk-2RCUHMGL.js.map +1 -0
  3. package/dist/{chunk-MOVHYB6E.js → chunk-GN7232BY.js} +1025 -695
  4. package/dist/chunk-GN7232BY.js.map +1 -0
  5. package/dist/{chunk-BMYC6772.js → chunk-H3O43F5P.js} +9765 -3068
  6. package/dist/chunk-H3O43F5P.js.map +1 -0
  7. package/dist/dev-host/dev-api-proxy-plugin.ts +330 -0
  8. package/dist/dev-host/dev-diagnostics.ts +62 -0
  9. package/dist/dev-host/dev-fallback-stylesheet.ts +50 -0
  10. package/dist/dev-host/dev-host-controller.ts +686 -0
  11. package/dist/dev-host/dev-host-player-query.ts +17 -0
  12. package/dist/dev-host/dev-host-session-transport.ts +52 -0
  13. package/dist/dev-host/dev-host-storage.ts +56 -0
  14. package/dist/dev-host/dev-log-relay-plugin.ts +469 -0
  15. package/dist/dev-host/dev-runtime-config.ts +14 -0
  16. package/dist/dev-host/dev-runtime-platform.ts +419 -0
  17. package/dist/dev-host/dev-virtual-modules-plugin.ts +63 -0
  18. package/dist/dev-host/host-main.css +182 -0
  19. package/dist/dev-host/host-main.tsx +754 -0
  20. package/dist/dev-host/index.html +56 -0
  21. package/dist/dev-host/plugin-main.ts +55 -0
  22. package/dist/dev-host/plugin.html +24 -0
  23. package/dist/dev-host/start-dev-server.ts +138 -0
  24. package/dist/dev-host/virtual-modules.d.ts +27 -0
  25. package/dist/dist-FEPN3BDN.js +16543 -0
  26. package/dist/dist-FEPN3BDN.js.map +1 -0
  27. package/dist/{dist-WJRJNFLI.js → dist-FRURQI7Q.js} +4 -2
  28. package/dist/index.js +3 -3
  29. package/dist/internal.js +159 -124
  30. package/dist/internal.js.map +1 -1
  31. package/dist/runtime-packages/tailwind-config/shared-styles.css +146 -0
  32. package/dist/runtime-packages/ui/src/components/.gitkeep +0 -0
  33. package/dist/runtime-packages/ui/src/components/accordion.tsx +66 -0
  34. package/dist/runtime-packages/ui/src/components/ai-elements/actions.tsx +65 -0
  35. package/dist/runtime-packages/ui/src/components/ai-elements/artifact.tsx +147 -0
  36. package/dist/runtime-packages/ui/src/components/ai-elements/branch.tsx +215 -0
  37. package/dist/runtime-packages/ui/src/components/ai-elements/canvas.tsx +22 -0
  38. package/dist/runtime-packages/ui/src/components/ai-elements/chain-of-thought.tsx +228 -0
  39. package/dist/runtime-packages/ui/src/components/ai-elements/code-block.tsx +179 -0
  40. package/dist/runtime-packages/ui/src/components/ai-elements/confirmation.tsx +158 -0
  41. package/dist/runtime-packages/ui/src/components/ai-elements/connection.tsx +28 -0
  42. package/dist/runtime-packages/ui/src/components/ai-elements/context.tsx +408 -0
  43. package/dist/runtime-packages/ui/src/components/ai-elements/controls.tsx +18 -0
  44. package/dist/runtime-packages/ui/src/components/ai-elements/conversation.tsx +97 -0
  45. package/dist/runtime-packages/ui/src/components/ai-elements/edge.tsx +140 -0
  46. package/dist/runtime-packages/ui/src/components/ai-elements/image.tsx +24 -0
  47. package/dist/runtime-packages/ui/src/components/ai-elements/inline-citation.tsx +287 -0
  48. package/dist/runtime-packages/ui/src/components/ai-elements/loader.tsx +96 -0
  49. package/dist/runtime-packages/ui/src/components/ai-elements/message.tsx +463 -0
  50. package/dist/runtime-packages/ui/src/components/ai-elements/node.tsx +71 -0
  51. package/dist/runtime-packages/ui/src/components/ai-elements/open-in-chat.tsx +365 -0
  52. package/dist/runtime-packages/ui/src/components/ai-elements/panel.tsx +15 -0
  53. package/dist/runtime-packages/ui/src/components/ai-elements/plan.tsx +142 -0
  54. package/dist/runtime-packages/ui/src/components/ai-elements/prompt-input.tsx +1380 -0
  55. package/dist/runtime-packages/ui/src/components/ai-elements/queue.tsx +274 -0
  56. package/dist/runtime-packages/ui/src/components/ai-elements/reasoning.tsx +182 -0
  57. package/dist/runtime-packages/ui/src/components/ai-elements/response.tsx +22 -0
  58. package/dist/runtime-packages/ui/src/components/ai-elements/shimmer.tsx +64 -0
  59. package/dist/runtime-packages/ui/src/components/ai-elements/sources.tsx +77 -0
  60. package/dist/runtime-packages/ui/src/components/ai-elements/suggestion.tsx +53 -0
  61. package/dist/runtime-packages/ui/src/components/ai-elements/task.tsx +87 -0
  62. package/dist/runtime-packages/ui/src/components/ai-elements/tool.tsx +165 -0
  63. package/dist/runtime-packages/ui/src/components/ai-elements/toolbar.tsx +16 -0
  64. package/dist/runtime-packages/ui/src/components/ai-elements/web-preview.tsx +263 -0
  65. package/dist/runtime-packages/ui/src/components/alert-dialog.tsx +157 -0
  66. package/dist/runtime-packages/ui/src/components/alert.tsx +66 -0
  67. package/dist/runtime-packages/ui/src/components/avatar.tsx +53 -0
  68. package/dist/runtime-packages/ui/src/components/badge.tsx +46 -0
  69. package/dist/runtime-packages/ui/src/components/button-group.tsx +83 -0
  70. package/dist/runtime-packages/ui/src/components/button.tsx +65 -0
  71. package/dist/runtime-packages/ui/src/components/card.tsx +92 -0
  72. package/dist/runtime-packages/ui/src/components/carousel.tsx +241 -0
  73. package/dist/runtime-packages/ui/src/components/collapsible.tsx +33 -0
  74. package/dist/runtime-packages/ui/src/components/command.tsx +184 -0
  75. package/dist/runtime-packages/ui/src/components/context-menu.tsx +252 -0
  76. package/dist/runtime-packages/ui/src/components/counter.tsx +11 -0
  77. package/dist/runtime-packages/ui/src/components/dialog.tsx +146 -0
  78. package/dist/runtime-packages/ui/src/components/drawer.tsx +132 -0
  79. package/dist/runtime-packages/ui/src/components/dropdown-menu.tsx +257 -0
  80. package/dist/runtime-packages/ui/src/components/form.tsx +168 -0
  81. package/dist/runtime-packages/ui/src/components/header.tsx +13 -0
  82. package/dist/runtime-packages/ui/src/components/hover-card.tsx +44 -0
  83. package/dist/runtime-packages/ui/src/components/input-group.tsx +178 -0
  84. package/dist/runtime-packages/ui/src/components/input.tsx +21 -0
  85. package/dist/runtime-packages/ui/src/components/item.tsx +193 -0
  86. package/dist/runtime-packages/ui/src/components/label.tsx +24 -0
  87. package/dist/runtime-packages/ui/src/components/navigation-menu.tsx +168 -0
  88. package/dist/runtime-packages/ui/src/components/popover.tsx +55 -0
  89. package/dist/runtime-packages/ui/src/components/progress.tsx +31 -0
  90. package/dist/runtime-packages/ui/src/components/radio-group.tsx +45 -0
  91. package/dist/runtime-packages/ui/src/components/resizable.tsx +56 -0
  92. package/dist/runtime-packages/ui/src/components/scroll-area.tsx +58 -0
  93. package/dist/runtime-packages/ui/src/components/select.tsx +187 -0
  94. package/dist/runtime-packages/ui/src/components/separator.tsx +28 -0
  95. package/dist/runtime-packages/ui/src/components/skeleton.tsx +13 -0
  96. package/dist/runtime-packages/ui/src/components/sonner.tsx +25 -0
  97. package/dist/runtime-packages/ui/src/components/spinner.tsx +16 -0
  98. package/dist/runtime-packages/ui/src/components/switch.tsx +31 -0
  99. package/dist/runtime-packages/ui/src/components/table.tsx +137 -0
  100. package/dist/runtime-packages/ui/src/components/tabs.tsx +74 -0
  101. package/dist/runtime-packages/ui/src/components/textarea.tsx +23 -0
  102. package/dist/runtime-packages/ui/src/components/theme-provider.tsx +73 -0
  103. package/dist/runtime-packages/ui/src/components/tooltip.tsx +61 -0
  104. package/dist/runtime-packages/ui/src/components/ui/file-upload.tsx +195 -0
  105. package/dist/runtime-packages/ui/src/hooks/.gitkeep +0 -0
  106. package/dist/runtime-packages/ui/src/index.ts +68 -0
  107. package/dist/runtime-packages/ui/src/lib/utils.ts +6 -0
  108. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +68 -0
  109. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +359 -0
  110. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +274 -0
  111. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +214 -0
  112. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +135 -0
  113. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +5 -0
  114. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +194 -0
  115. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +1 -0
  116. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +1 -0
  117. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +162 -0
  118. package/dist/runtime-packages/ui-host-runtime/src/index.ts +2 -0
  119. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +11 -0
  120. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +253 -0
  121. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +195 -0
  122. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +138 -0
  123. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +159 -0
  124. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +524 -0
  125. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +12 -0
  126. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +122 -0
  127. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +26 -0
  128. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +477 -0
  129. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +209 -0
  130. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +112 -0
  131. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +318 -0
  132. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +211 -0
  133. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +814 -0
  134. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +334 -0
  135. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +180 -0
  136. package/dist/scaffold/assets/static/app/tsconfig.framework.json +3 -1
  137. package/dist/scaffold/assets/static/ui/tsconfig.framework.json +7 -19
  138. package/package.json +52 -17
  139. package/skills/dreamboard/SKILL.md +41 -75
  140. package/LICENSE +0 -89
  141. package/NOTICE +0 -1
  142. package/dist/chunk-BMYC6772.js.map +0 -1
  143. package/dist/chunk-EYYWGWTO.js.map +0 -1
  144. package/dist/chunk-MOVHYB6E.js.map +0 -1
  145. package/dist/scaffold/assets/static/ui/App.tsx +0 -22
  146. package/dist/src-CUL7EGGG.js +0 -634
  147. package/dist/src-CUL7EGGG.js.map +0 -1
  148. package/skills/dreamboard/references/authoring-lifecycle.md +0 -102
  149. package/skills/dreamboard/references/board-surfaces.md +0 -36
  150. package/skills/dreamboard/references/board-topology.md +0 -443
  151. package/skills/dreamboard/references/boards-and-topology.md +0 -100
  152. package/skills/dreamboard/references/card-actions.md +0 -107
  153. package/skills/dreamboard/references/cli.md +0 -120
  154. package/skills/dreamboard/references/core-concepts.md +0 -514
  155. package/skills/dreamboard/references/custom-renderers.md +0 -26
  156. package/skills/dreamboard/references/derived-values.md +0 -55
  157. package/skills/dreamboard/references/effects.md +0 -111
  158. package/skills/dreamboard/references/game-contract.md +0 -89
  159. package/skills/dreamboard/references/game-definition.md +0 -89
  160. package/skills/dreamboard/references/game-shell.md +0 -80
  161. package/skills/dreamboard/references/hand-surfaces.md +0 -33
  162. package/skills/dreamboard/references/index.md +0 -112
  163. package/skills/dreamboard/references/inputs-and-targets.md +0 -160
  164. package/skills/dreamboard/references/interactions.md +0 -158
  165. package/skills/dreamboard/references/manifest-fields.md +0 -137
  166. package/skills/dreamboard/references/manifest.md +0 -81
  167. package/skills/dreamboard/references/package-surfaces.md +0 -69
  168. package/skills/dreamboard/references/phases.md +0 -145
  169. package/skills/dreamboard/references/prompts-and-choices.md +0 -55
  170. package/skills/dreamboard/references/quickstart.md +0 -71
  171. package/skills/dreamboard/references/rule-authoring.md +0 -144
  172. package/skills/dreamboard/references/setup-bootstrap.md +0 -78
  173. package/skills/dreamboard/references/stages-and-zones.md +0 -59
  174. package/skills/dreamboard/references/static-views.md +0 -67
  175. package/skills/dreamboard/references/table-queries-and-ops.md +0 -103
  176. package/skills/dreamboard/references/testing-bases.md +0 -147
  177. package/skills/dreamboard/references/testing-generated-contracts.md +0 -142
  178. package/skills/dreamboard/references/testing-runtime-assertions.md +0 -124
  179. package/skills/dreamboard/references/testing-scenarios.md +0 -148
  180. package/skills/dreamboard/references/testing-ui-tests.md +0 -174
  181. package/skills/dreamboard/references/testing.md +0 -161
  182. package/skills/dreamboard/references/ui-architecture.md +0 -137
  183. package/skills/dreamboard/references/ui-components.md +0 -34
  184. package/skills/dreamboard/references/views.md +0 -72
  185. package/skills/dreamboard/references/workspace-layout.md +0 -136
  186. /package/dist/{dist-WJRJNFLI.js.map → dist-FRURQI7Q.js.map} +0 -0
@@ -1,22 +0,0 @@
1
- import { Phase, PromptInbox } from "@dreamboard/ui-contract";
2
-
3
- function SetupPhase() {
4
- return (
5
- <main>
6
- <PromptInbox.Root>
7
- <PromptInbox.Empty>No available prompts.</PromptInbox.Empty>
8
- <PromptInbox.Items />
9
- </PromptInbox.Root>
10
- </main>
11
- );
12
- }
13
-
14
- export default function App() {
15
- return (
16
- <Phase.Switch
17
- routes={{
18
- setup: () => <SetupPhase />,
19
- }}
20
- />
21
- );
22
- }
@@ -1,634 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- createUnifiedSessionStore
4
- } from "./chunk-EYYWGWTO.js";
5
- import "./chunk-D4HDZEJT.js";
6
-
7
- // ../../packages/testing/src/definitions.ts
8
- function defineBase(definition) {
9
- return definition;
10
- }
11
- function defineScenario(definition) {
12
- return definition;
13
- }
14
-
15
- // ../../packages/testing/src/create-expect-api.ts
16
- import { isDeepStrictEqual } from "util";
17
- function isRecord(value) {
18
- return typeof value === "object" && value !== null && !Array.isArray(value);
19
- }
20
- function matchPartial(actual, expected, path = "value") {
21
- if (!isRecord(expected)) {
22
- return isDeepStrictEqual(actual, expected) ? null : `${path} does not match`;
23
- }
24
- if (!isRecord(actual)) {
25
- return `${path} is not an object`;
26
- }
27
- for (const [key, expectedValue] of Object.entries(expected)) {
28
- const actualValue = actual[key];
29
- if (!(key in actual)) {
30
- return `${path}.${key} is missing`;
31
- }
32
- const mismatch = matchPartial(actualValue, expectedValue, `${path}.${key}`);
33
- if (mismatch) {
34
- return mismatch;
35
- }
36
- }
37
- return null;
38
- }
39
- function asDescriptorList(actual) {
40
- if (!Array.isArray(actual)) {
41
- throw new Error("Expected interaction descriptor array.");
42
- }
43
- return actual;
44
- }
45
- function findInteraction(descriptors, interactionId) {
46
- return descriptors.find(
47
- (descriptor) => descriptor.interactionId === interactionId
48
- ) ?? null;
49
- }
50
- function assertDescriptorMatches(descriptor, opts) {
51
- if (!opts) {
52
- return;
53
- }
54
- const mismatch = matchPartial(descriptor, opts, "interaction");
55
- if (mismatch) {
56
- throw new Error(mismatch);
57
- }
58
- }
59
- function createSubmissionErrorMatcher(actual, expected) {
60
- const resolvePromise = () => {
61
- if (typeof actual === "function") {
62
- return Promise.resolve().then(() => actual());
63
- }
64
- return Promise.resolve(actual);
65
- };
66
- return resolvePromise().then(() => {
67
- throw new Error("Expected promise to reject.");
68
- }).catch((error) => {
69
- if (!(error instanceof Error)) {
70
- throw new Error("Expected rejection to be an Error.");
71
- }
72
- if (expected.errorCode !== void 0 && error.errorCode !== expected.errorCode) {
73
- throw new Error(
74
- `Expected rejection errorCode '${expected.errorCode}', received '${error.errorCode ?? "undefined"}'.`
75
- );
76
- }
77
- if (typeof expected.message === "string" && error.message !== expected.message) {
78
- throw new Error(
79
- `Expected rejection message '${expected.message}', received '${error.message}'.`
80
- );
81
- }
82
- if (expected.message instanceof RegExp && !expected.message.test(error.message)) {
83
- throw new Error(
84
- `Expected rejection message '${error.message}' to match ${String(expected.message)}.`
85
- );
86
- }
87
- });
88
- }
89
- function assertLength(actual, expected) {
90
- if (actual === null || actual === void 0 || typeof actual.length !== "number") {
91
- throw new Error("toHaveLength expects a value with a numeric length.");
92
- }
93
- const length = actual.length;
94
- if (length !== expected) {
95
- throw new Error(`Expected length ${expected}, received ${length}.`);
96
- }
97
- }
98
- function assertThrown(actual, predicate) {
99
- if (typeof actual !== "function") {
100
- throw new Error("toThrow expects a function.");
101
- }
102
- try {
103
- actual();
104
- } catch (error) {
105
- if (!(error instanceof Error)) {
106
- throw new Error("Thrown value is not an Error.");
107
- }
108
- if (predicate === void 0) {
109
- return;
110
- }
111
- if (typeof predicate === "string" && error.message !== predicate) {
112
- throw new Error(
113
- `Expected thrown message '${predicate}', received '${error.message}'.`
114
- );
115
- }
116
- if (predicate instanceof RegExp && !predicate.test(error.message)) {
117
- throw new Error(
118
- `Expected thrown message '${error.message}' to match ${String(predicate)}.`
119
- );
120
- }
121
- if (typeof predicate === "function" && !predicate(error)) {
122
- throw new Error("Thrown error did not satisfy predicate.");
123
- }
124
- return;
125
- }
126
- throw new Error("Expected function to throw.");
127
- }
128
- function createExpectApi(options = {}) {
129
- const buildMatchers = (actual) => ({
130
- toBe: (expected) => {
131
- if (actual !== expected) {
132
- throw new Error(
133
- `Expected '${String(actual)}' to be '${String(expected)}'.`
134
- );
135
- }
136
- },
137
- toEqual: (expected) => {
138
- if (!isDeepStrictEqual(actual, expected)) {
139
- throw new Error("Expected values to be deeply equal.");
140
- }
141
- },
142
- toMatchObject: (expected) => {
143
- const mismatch = matchPartial(actual, expected);
144
- if (mismatch) {
145
- throw new Error(mismatch);
146
- }
147
- },
148
- toBeDefined: () => {
149
- if (actual === void 0) {
150
- throw new Error("Expected value to be defined.");
151
- }
152
- },
153
- toBeUndefined: () => {
154
- if (actual !== void 0) {
155
- throw new Error(
156
- `Expected value to be undefined, but received '${String(actual)}'.`
157
- );
158
- }
159
- },
160
- toBeNull: () => {
161
- if (actual !== null) {
162
- throw new Error(
163
- `Expected value to be null, but received '${String(actual)}'.`
164
- );
165
- }
166
- },
167
- toContain: (expected) => {
168
- if (Array.isArray(actual)) {
169
- if (!actual.includes(expected)) {
170
- throw new Error("Expected array to contain value.");
171
- }
172
- return;
173
- }
174
- if (typeof actual === "string") {
175
- if (!actual.includes(String(expected))) {
176
- throw new Error("Expected string to contain value.");
177
- }
178
- return;
179
- }
180
- throw new Error("toContain expects an array or string actual value.");
181
- },
182
- toContainEqual: (expected) => {
183
- if (!Array.isArray(actual)) {
184
- throw new Error("toContainEqual expects an array actual value.");
185
- }
186
- if (!actual.some((value) => isDeepStrictEqual(value, expected))) {
187
- throw new Error("Expected array to contain an equal value.");
188
- }
189
- },
190
- toHaveLength: (expected) => {
191
- assertLength(actual, expected);
192
- },
193
- toBeGreaterThan: (expected) => {
194
- if (typeof actual !== "number") {
195
- throw new Error("toBeGreaterThan expects a number actual value.");
196
- }
197
- if (actual <= expected) {
198
- throw new Error(`Expected ${actual} to be > ${expected}.`);
199
- }
200
- },
201
- toBeGreaterThanOrEqual: (expected) => {
202
- if (typeof actual !== "number") {
203
- throw new Error(
204
- "toBeGreaterThanOrEqual expects a number actual value."
205
- );
206
- }
207
- if (actual < expected) {
208
- throw new Error(`Expected ${actual} to be >= ${expected}.`);
209
- }
210
- },
211
- toThrow: (predicate) => {
212
- assertThrown(actual, predicate);
213
- },
214
- toMatchSnapshot: (filename) => {
215
- if (!options.matchSnapshot) {
216
- throw new Error(
217
- "Snapshot matching is not configured for this expect API."
218
- );
219
- }
220
- options.matchSnapshot(filename, actual);
221
- },
222
- toRejectWith: (expected) => createSubmissionErrorMatcher(actual, expected),
223
- toHaveInteraction: (interactionId, opts) => {
224
- const descriptors = asDescriptorList(actual);
225
- const descriptor = findInteraction(descriptors, interactionId);
226
- if (!descriptor) {
227
- throw new Error(`Expected interaction '${interactionId}' to exist.`);
228
- }
229
- assertDescriptorMatches(descriptor, opts);
230
- },
231
- toBeGatedBy: (reason, opts) => {
232
- const descriptor = Array.isArray(actual) ? (() => {
233
- if (!opts?.interactionId) {
234
- throw new Error(
235
- "toBeGatedBy on a descriptor array requires opts.interactionId."
236
- );
237
- }
238
- return findInteraction(
239
- asDescriptorList(actual),
240
- opts.interactionId
241
- );
242
- })() : actual;
243
- if (!descriptor) {
244
- throw new Error("Expected interaction descriptor to exist.");
245
- }
246
- if (descriptor.available !== false) {
247
- throw new Error("Expected interaction to be unavailable.");
248
- }
249
- if (descriptor.unavailableReason !== reason) {
250
- throw new Error(
251
- `Expected unavailableReason '${reason}', received '${descriptor.unavailableReason ?? "undefined"}'.`
252
- );
253
- }
254
- },
255
- toBeActiveFor: (playerId, opts) => {
256
- const descriptor = Array.isArray(actual) ? (() => {
257
- if (!opts?.interactionId) {
258
- throw new Error(
259
- "toBeActiveFor on a descriptor array requires opts.interactionId."
260
- );
261
- }
262
- return findInteraction(
263
- asDescriptorList(actual),
264
- opts.interactionId
265
- );
266
- })() : actual;
267
- if (!descriptor) {
268
- throw new Error("Expected interaction descriptor to exist.");
269
- }
270
- if (descriptor.context?.to !== playerId) {
271
- throw new Error(
272
- `Expected interaction to target '${playerId}', received '${descriptor.context?.to ?? "undefined"}'.`
273
- );
274
- }
275
- if (descriptor.available !== true) {
276
- throw new Error("Expected interaction to be available.");
277
- }
278
- },
279
- not: {
280
- toHaveInteraction: (interactionId) => {
281
- const descriptors = asDescriptorList(actual);
282
- if (findInteraction(descriptors, interactionId)) {
283
- throw new Error(
284
- `Expected interaction '${interactionId}' to be absent.`
285
- );
286
- }
287
- }
288
- }
289
- });
290
- return (actual) => buildMatchers(actual);
291
- }
292
-
293
- // ../../packages/testing/src/create-test-runtime.ts
294
- function cloneState(value) {
295
- return structuredClone(value);
296
- }
297
- function createSubmissionError(errorCode, message) {
298
- const error = new Error(message ?? "Interaction rejected");
299
- error.name = "SubmissionError";
300
- error.errorCode = errorCode;
301
- return error;
302
- }
303
- function readFlowState(state) {
304
- const flow = state.domain?.flow ?? {};
305
- return {
306
- currentPhase: flow.currentPhase ?? null,
307
- activePlayers: Array.isArray(flow.activePlayers) ? flow.activePlayers : []
308
- };
309
- }
310
- function buildSeatAssignments(playerIds, userId, displayNameByPlayerId) {
311
- const actor = userId != null ? { kind: "AUTH_USER", id: userId } : void 0;
312
- return playerIds.map((playerId) => ({
313
- playerId,
314
- controllerActor: actor,
315
- displayName: displayNameByPlayerId?.[playerId] ?? playerId
316
- }));
317
- }
318
- function resolvePlayerIds(options) {
319
- if (options.explicitPlayerIds && options.explicitPlayerIds.length > 0) {
320
- return [...options.explicitPlayerIds];
321
- }
322
- return Array.from(
323
- { length: options.baseState.fingerprint.players },
324
- (_, index) => `player-${index + 1}`
325
- );
326
- }
327
- function createStubSseManager() {
328
- return {
329
- connect: () => void 0,
330
- disconnect: () => void 0,
331
- on: () => () => void 0,
332
- onAnyMessage: () => () => void 0
333
- };
334
- }
335
- function buildGameplaySnapshot(options) {
336
- const projection = options.bundle.projectSeatsDynamic({
337
- state: options.state,
338
- playerIds: [options.playerId]
339
- });
340
- const flow = readFlowState(options.state);
341
- if (options.expectedPhase && flow.currentPhase !== options.expectedPhase) {
342
- throw new Error(
343
- `Expected base '${options.baseId}' to be in phase '${options.expectedPhase}', received '${flow.currentPhase ?? "null"}'.`
344
- );
345
- }
346
- const seats = projection.seats ?? {};
347
- const seat = seats[options.playerId];
348
- return {
349
- version: options.version,
350
- actionSetVersion: `${options.version}:test`,
351
- playerId: options.playerId,
352
- activePlayers: flow.activePlayers,
353
- currentPhase: flow.currentPhase ?? "",
354
- currentStage: projection.currentStage ?? "",
355
- stageSeats: projection.stageSeats ?? [],
356
- view: JSON.stringify(seat?.view ?? null),
357
- availableInteractions: seat?.availableInteractions ?? [],
358
- zones: seat?.zones ?? {},
359
- boardStatic: options.staticProjection ? JSON.stringify(options.staticProjection.view) : void 0,
360
- boardStaticHash: options.staticProjection?.hash
361
- };
362
- }
363
- function createHostContext(options) {
364
- return {
365
- sessionId: options.sessionId,
366
- shortCode: options.sessionId,
367
- phase: options.phase,
368
- status: "active",
369
- hostActor: options.hostActor,
370
- gameSource: {
371
- kind: "USER_COMPILED",
372
- ownerUserId: options.userId,
373
- gameId: options.gameId,
374
- compiledResultId: "00000000-0000-0000-0000-000000000000"
375
- },
376
- switchablePlayerIds: options.switchablePlayerIds,
377
- history: {
378
- entries: [],
379
- currentIndex: -1,
380
- canGoBack: false,
381
- canGoForward: false
382
- }
383
- };
384
- }
385
- function createRuntimeSessionContext(options) {
386
- return {
387
- identity: {
388
- sessionId: options.sessionId,
389
- shortCode: options.sessionId,
390
- gameId: options.gameId
391
- },
392
- userId: options.userId,
393
- seats: options.seats,
394
- canStart: options.canStart,
395
- hostActor: options.hostActor,
396
- switchablePlayerIds: options.switchablePlayerIds,
397
- history: {
398
- entries: [],
399
- currentIndex: -1,
400
- canGoBack: false,
401
- canGoForward: false
402
- }
403
- };
404
- }
405
- function gameplayViewportFromSnapshot(snapshot) {
406
- return {
407
- version: snapshot.version,
408
- actionSetVersion: snapshot.actionSetVersion,
409
- activePlayers: snapshot.activePlayers,
410
- currentPhase: snapshot.currentPhase,
411
- currentStage: snapshot.currentStage,
412
- stageSeats: snapshot.stageSeats,
413
- simultaneousPhase: snapshot.simultaneousPhase ?? null,
414
- view: JSON.parse(snapshot.view),
415
- availableInteractions: snapshot.availableInteractions,
416
- zones: snapshot.zones,
417
- boardStatic: snapshot.boardStatic ? JSON.parse(snapshot.boardStatic) : null,
418
- boardStaticHash: snapshot.boardStaticHash ?? null
419
- };
420
- }
421
- function createTestRuntime(options) {
422
- const baseState = options.baseStates[options.baseId];
423
- if (!baseState) {
424
- throw new Error(`Unknown test base '${options.baseId}'.`);
425
- }
426
- let currentState = cloneState(baseState.snapshot);
427
- const playerIds = resolvePlayerIds({
428
- baseState,
429
- explicitPlayerIds: options.playerIds
430
- });
431
- const userId = options.userId ?? "test-user";
432
- const sessionId = options.sessionId ?? "test-session";
433
- const gameId = options.gameId ?? "test-game";
434
- const seats = buildSeatAssignments(
435
- playerIds,
436
- userId,
437
- options.displayNameByPlayerId
438
- );
439
- const storeApi = createUnifiedSessionStore({
440
- createSseManager: createStubSseManager,
441
- // Test runtimes keep `userId` present so the unified store derives
442
- // controllable player ids from seat assignments whenever the
443
- // incoming snapshot omits `controllablePlayerIds`.
444
- fallbackToAllSeatsWhenUserIdMissing: false
445
- });
446
- const hostActor = { kind: "AUTH_USER", id: userId };
447
- const lobbySnapshot = {
448
- type: "lobby",
449
- context: createHostContext({
450
- sessionId,
451
- userId,
452
- gameId,
453
- phase: "lobby",
454
- hostActor,
455
- switchablePlayerIds: playerIds
456
- }),
457
- lobby: {
458
- seats,
459
- canStart: true,
460
- hostActor
461
- }
462
- };
463
- const setSessionState = (input) => {
464
- const context = createRuntimeSessionContext({
465
- sessionId,
466
- userId,
467
- gameId,
468
- hostActor,
469
- switchablePlayerIds: playerIds,
470
- seats,
471
- canStart: true
472
- });
473
- storeApi.setState((state) => ({
474
- ...state,
475
- session: input.gameplay ? {
476
- type: "gameplay",
477
- context,
478
- perspective: { playerId: input.selectedPlayerId },
479
- gameplay: gameplayViewportFromSnapshot(input.gameplay)
480
- } : {
481
- type: "lobby",
482
- context,
483
- preferredPlayerId: input.selectedPlayerId || null
484
- },
485
- connection: { ...state.connection, error: null },
486
- activity: {
487
- ...state.activity,
488
- syncId: state.activity.syncId + 1,
489
- lastSyncTimestamp: Date.now()
490
- }
491
- }));
492
- };
493
- setSessionState({
494
- selectedPlayerId: playerIds[0] ?? ""
495
- });
496
- let version = 0;
497
- let currentPlayerId = playerIds[0] ?? "";
498
- const staticProjection = options.bundle.projectStatic?.() ?? null;
499
- const applyCurrentState = () => {
500
- version += 1;
501
- const snapshot = buildGameplaySnapshot({
502
- state: currentState,
503
- bundle: options.bundle,
504
- staticProjection,
505
- playerId: currentPlayerId,
506
- version,
507
- expectedPhase: version === 1 ? options.phase : void 0,
508
- baseId: options.baseId
509
- });
510
- setSessionState({
511
- selectedPlayerId: currentPlayerId,
512
- gameplay: snapshot
513
- });
514
- };
515
- applyCurrentState();
516
- const stateListeners = /* @__PURE__ */ new Set();
517
- const sessionListeners = /* @__PURE__ */ new Set();
518
- let lastPluginSnapshot = storeApi.getState().getPluginSnapshot();
519
- let lastSessionState = {
520
- ...lastPluginSnapshot.session,
521
- status: "ready"
522
- };
523
- storeApi.subscribe((state, previous) => {
524
- const nextPluginSnapshot = state.getPluginSnapshot();
525
- if (nextPluginSnapshot !== lastPluginSnapshot) {
526
- lastPluginSnapshot = nextPluginSnapshot;
527
- for (const listener of stateListeners) {
528
- listener(nextPluginSnapshot);
529
- }
530
- }
531
- const previousSession = previous.getPluginSnapshot().session;
532
- const nextSession = nextPluginSnapshot.session;
533
- const controllingPlayerChanged = nextSession.controllingPlayerId !== previousSession.controllingPlayerId;
534
- const controllableIdsChanged = nextSession.controllablePlayerIds.join("\0") !== previousSession.controllablePlayerIds.join("\0");
535
- if (controllingPlayerChanged || controllableIdsChanged) {
536
- lastSessionState = {
537
- ...nextPluginSnapshot.session,
538
- status: "ready"
539
- };
540
- for (const listener of sessionListeners) {
541
- listener(lastSessionState);
542
- }
543
- }
544
- });
545
- const validate = async (playerId, interactionId, params = {}) => {
546
- const result = await options.bundle.validateInput({
547
- state: currentState,
548
- input: {
549
- kind: "interaction",
550
- playerId,
551
- interactionId,
552
- params
553
- }
554
- });
555
- return {
556
- valid: result.valid,
557
- errorCode: result.errorCode,
558
- message: result.message
559
- };
560
- };
561
- const submit = async (playerId, interactionId, params = {}) => {
562
- const validation = await validate(playerId, interactionId, params);
563
- if (!validation.valid) {
564
- throw createSubmissionError(validation.errorCode, validation.message);
565
- }
566
- const result = await options.bundle.dispatch({
567
- state: currentState,
568
- input: {
569
- kind: "interaction",
570
- playerId,
571
- interactionId,
572
- params
573
- }
574
- });
575
- if (result.kind === "reject") {
576
- throw createSubmissionError(result.errorCode, result.message);
577
- }
578
- currentState = cloneState(result.state);
579
- applyCurrentState();
580
- };
581
- const setControllingPlayer = (playerId) => {
582
- if (!playerIds.includes(playerId)) {
583
- throw new Error(`Unknown controlling player '${playerId}'.`);
584
- }
585
- currentPlayerId = playerId;
586
- storeApi.getState().selectPlayer(playerId);
587
- applyCurrentState();
588
- };
589
- const runtime = {
590
- validateInteraction: validate,
591
- submitInteraction: submit,
592
- getSessionState: () => ({ ...lastSessionState }),
593
- disconnect: () => void 0,
594
- switchPlayer: (playerId) => {
595
- setControllingPlayer(playerId);
596
- },
597
- getSnapshot: () => lastPluginSnapshot,
598
- subscribeToState: (listener) => {
599
- stateListeners.add(listener);
600
- return () => {
601
- stateListeners.delete(listener);
602
- };
603
- },
604
- _subscribeToSessionState: (listener) => {
605
- sessionListeners.add(listener);
606
- return () => {
607
- sessionListeners.delete(listener);
608
- };
609
- }
610
- };
611
- return {
612
- runtime,
613
- getSnapshot: () => lastPluginSnapshot,
614
- players: () => [...playerIds],
615
- seat: (index) => {
616
- if (!Number.isInteger(index) || index < 0 || index >= playerIds.length) {
617
- throw new Error(
618
- `seat(${index}) is out of range; base '${options.baseId}' has ${playerIds.length} player(s).`
619
- );
620
- }
621
- return playerIds[index];
622
- },
623
- submit,
624
- validate,
625
- setControllingPlayer
626
- };
627
- }
628
- export {
629
- createExpectApi,
630
- createTestRuntime,
631
- defineBase,
632
- defineScenario
633
- };
634
- //# sourceMappingURL=src-CUL7EGGG.js.map