@dreamboard-games/sdk 0.4.0-alpha.6 → 0.4.0-alpha.7

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 (46) hide show
  1. package/REFERENCE.md +408 -8
  2. package/dist/authoring/index.d.ts +5 -4
  3. package/dist/authoring/index.js +3 -3
  4. package/dist/authoring/index.js.map +1 -1
  5. package/dist/{chunk-PAPIAMYX.js → chunk-3QIZKXJ2.js} +6 -4
  6. package/dist/{chunk-PAPIAMYX.js.map → chunk-3QIZKXJ2.js.map} +1 -1
  7. package/dist/chunk-5IHU5CUK.js +575 -0
  8. package/dist/chunk-5IHU5CUK.js.map +1 -0
  9. package/dist/chunk-IU6KGPY7.js +659 -0
  10. package/dist/chunk-IU6KGPY7.js.map +1 -0
  11. package/dist/{chunk-HK3WN4U7.js → chunk-KYEWGZ2Y.js} +2 -2
  12. package/dist/{chunk-HK3WN4U7.js.map → chunk-KYEWGZ2Y.js.map} +1 -1
  13. package/dist/{chunk-DDST4U2P.js → chunk-NO537WSS.js} +2 -2
  14. package/dist/{chunk-SOBNI363.js → chunk-Q322XCY2.js} +11 -6
  15. package/dist/{chunk-SOBNI363.js.map → chunk-Q322XCY2.js.map} +1 -1
  16. package/dist/{chunk-OV6JC2BM.js → chunk-RKGJ64UN.js} +19 -15
  17. package/dist/chunk-RKGJ64UN.js.map +1 -0
  18. package/dist/chunk-VLG4YST5.js +564 -0
  19. package/dist/chunk-VLG4YST5.js.map +1 -0
  20. package/dist/{stale-contract-artifact-error-BelRiIDR.d.ts → diagnostics-1BWjRo6-.d.ts} +1 -18
  21. package/dist/index.js +2 -2
  22. package/dist/package-set.d.ts +2 -2
  23. package/dist/package-set.js +2 -2
  24. package/dist/reducer.d.ts +3 -2
  25. package/dist/reducer.js +5 -5
  26. package/dist/reducer.js.map +1 -1
  27. package/dist/reference-games/index.d.ts +223 -0
  28. package/dist/reference-games/index.js +230 -0
  29. package/dist/reference-games/index.js.map +1 -0
  30. package/dist/runtime/primitives.js +4 -3
  31. package/dist/runtime/workspace-contract.js +5 -4
  32. package/dist/runtime.js +15 -205
  33. package/dist/runtime.js.map +1 -1
  34. package/dist/stale-contract-artifact-error-C5AaZPJ8.d.ts +18 -0
  35. package/dist/testing-runtime.d.ts +42 -0
  36. package/dist/testing-runtime.js +153 -0
  37. package/dist/testing-runtime.js.map +1 -0
  38. package/dist/testing.d.ts +5 -191
  39. package/dist/testing.js +22 -640
  40. package/dist/testing.js.map +1 -1
  41. package/dist/types-DcADVHe9.d.ts +192 -0
  42. package/package.json +13 -2
  43. package/dist/chunk-OV6JC2BM.js.map +0 -1
  44. package/dist/chunk-UUQNOGZV.js +0 -1266
  45. package/dist/chunk-UUQNOGZV.js.map +0 -1
  46. /package/dist/{chunk-DDST4U2P.js.map → chunk-NO537WSS.js.map} +0 -0
@@ -0,0 +1,564 @@
1
+ import {
2
+ BROWSER_INTERACTION_ATTRIBUTES,
3
+ DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
4
+ GAMEPLAY_BROWSER_INTERACTION_SURFACE
5
+ } from "./chunk-WHR5UW3F.js";
6
+ import {
7
+ digestPluginGameplayFrame
8
+ } from "./chunk-5IHU5CUK.js";
9
+
10
+ // src/runtime/context/PluginGameplayFrameContext.tsx
11
+ import {
12
+ createContext,
13
+ useContext,
14
+ useMemo as useMemo2,
15
+ useSyncExternalStore as useSyncExternalStore2
16
+ } from "react";
17
+
18
+ // src/runtime/hooks/useRuntimeSnapshotSelector.ts
19
+ import { useCallback, useMemo, useSyncExternalStore } from "react";
20
+ function defaultRuntimeSnapshotEquality(left, right) {
21
+ return Object.is(left, right);
22
+ }
23
+ function useRuntimeSnapshotSelector(subscribe, getSnapshot, getServerSnapshot, selector, equalityFn = defaultRuntimeSnapshotEquality) {
24
+ const cache = useMemo(
25
+ () => ({ current: null, selector, equalityFn }),
26
+ [equalityFn, selector]
27
+ );
28
+ const getSelectedFromSnapshot = useCallback(
29
+ (snapshot) => {
30
+ const cached = cache.current;
31
+ if (cached && cached.snapshot === snapshot) {
32
+ return cached.selection;
33
+ }
34
+ const nextSelection = selector(snapshot);
35
+ if (cached && equalityFn(cached.selection, nextSelection)) {
36
+ cache.current = {
37
+ snapshot,
38
+ selection: cached.selection
39
+ };
40
+ return cached.selection;
41
+ }
42
+ cache.current = {
43
+ snapshot,
44
+ selection: nextSelection
45
+ };
46
+ return nextSelection;
47
+ },
48
+ [cache, equalityFn, selector]
49
+ );
50
+ const getSelectedSnapshot = useCallback(
51
+ () => getSelectedFromSnapshot(getSnapshot()),
52
+ [getSelectedFromSnapshot, getSnapshot]
53
+ );
54
+ const getSelectedServerSnapshot = useCallback(
55
+ () => selector(getServerSnapshot()),
56
+ [getServerSnapshot, selector]
57
+ );
58
+ const subscribeSelected = useCallback(
59
+ (onStoreChange) => subscribe(() => {
60
+ const previous = cache.current;
61
+ const nextSelection = getSelectedSnapshot();
62
+ if (!previous || !equalityFn(previous.selection, nextSelection)) {
63
+ onStoreChange();
64
+ }
65
+ }),
66
+ [cache, equalityFn, getSelectedSnapshot, subscribe]
67
+ );
68
+ return useSyncExternalStore(
69
+ subscribeSelected,
70
+ getSelectedSnapshot,
71
+ getSelectedServerSnapshot
72
+ );
73
+ }
74
+
75
+ // src/runtime/context/PluginGameplayFrameContext.tsx
76
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
77
+ var contextRegistryKey = "__dreamboardPluginGameplayFrameContext";
78
+ var contextRegistryGlobal = globalThis;
79
+ var contextRegistry = contextRegistryGlobal[contextRegistryKey] ?? (contextRegistryGlobal[contextRegistryKey] = {
80
+ store: createContext(null),
81
+ frame: createContext(null)
82
+ });
83
+ var PluginGameplayFrameStoreContext = contextRegistry.store;
84
+ var PluginGameplayFrameContext = contextRegistry.frame;
85
+ function DefaultLoadingScreen() {
86
+ return /* @__PURE__ */ jsx(
87
+ "div",
88
+ {
89
+ style: {
90
+ display: "flex",
91
+ alignItems: "center",
92
+ justifyContent: "center",
93
+ height: "100%",
94
+ width: "100%",
95
+ color: "#666"
96
+ },
97
+ children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
98
+ /* @__PURE__ */ jsx(
99
+ "div",
100
+ {
101
+ style: {
102
+ width: "40px",
103
+ height: "40px",
104
+ border: "3px solid #e0e0e0",
105
+ borderTopColor: "#666",
106
+ borderRadius: "50%",
107
+ animation: "spin 1s linear infinite",
108
+ margin: "0 auto 12px"
109
+ }
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` }),
113
+ /* @__PURE__ */ jsx("p", { children: "Loading game view..." })
114
+ ] })
115
+ }
116
+ );
117
+ }
118
+ function PluginGameplayFrameProvider({
119
+ runtime,
120
+ children,
121
+ loadingComponent = /* @__PURE__ */ jsx(DefaultLoadingScreen, {})
122
+ }) {
123
+ const storeApi = useMemo2(() => {
124
+ let current = runtime.getFrame();
125
+ return {
126
+ subscribe: (onStoreChange) => runtime.subscribeFrame(() => {
127
+ current = runtime.getFrame();
128
+ onStoreChange();
129
+ }),
130
+ getSnapshot: () => current,
131
+ getServerSnapshot: () => current
132
+ };
133
+ }, [runtime]);
134
+ return /* @__PURE__ */ jsx(
135
+ PluginGameplayFrameStoreProvider,
136
+ {
137
+ store: storeApi,
138
+ loadingComponent,
139
+ children
140
+ }
141
+ );
142
+ }
143
+ function PluginGameplayFrameStoreProvider({
144
+ store,
145
+ children,
146
+ loadingComponent
147
+ }) {
148
+ const frame = useSyncExternalStore2(
149
+ store.subscribe,
150
+ store.getSnapshot,
151
+ store.getServerSnapshot
152
+ );
153
+ if (!frame) {
154
+ return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
155
+ }
156
+ return /* @__PURE__ */ jsx(PluginGameplayFrameStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxs(PluginGameplayFrameContext.Provider, { value: frame, children: [
157
+ /* @__PURE__ */ jsx(SemanticGameplayFrameMarker, { frame }),
158
+ children
159
+ ] }) });
160
+ }
161
+ function usePluginGameplayFrameSelector(selector, equalityFn = defaultRuntimeSnapshotEquality) {
162
+ const store = useContext(PluginGameplayFrameStoreContext);
163
+ if (!store) {
164
+ throw new Error(
165
+ "usePluginGameplayFrameSelector must be used within PluginGameplayFrameProvider."
166
+ );
167
+ }
168
+ return useRuntimeSnapshotSelector(
169
+ store.subscribe,
170
+ store.getSnapshot,
171
+ store.getServerSnapshot,
172
+ (frame) => selector(requirePluginGameplayFrame(frame)),
173
+ equalityFn
174
+ );
175
+ }
176
+ function useAuthoredPluginGameplayFrameSelector(selector, equalityFn = defaultRuntimeSnapshotEquality) {
177
+ return usePluginGameplayFrameSelector(
178
+ (frame) => selector(frame),
179
+ equalityFn
180
+ );
181
+ }
182
+ function requirePluginGameplayFrame(frame) {
183
+ if (!frame) {
184
+ throw new Error("Plugin gameplay frame is not available.");
185
+ }
186
+ return frame;
187
+ }
188
+ var GAMEPLAY_BROWSER_SCOPE_ID = "runtime";
189
+ var BROWSER_PROJECTION_DIGEST_ATTRIBUTE = "data-dreamboard-projection-digest";
190
+ function SemanticGameplayFrameMarker({
191
+ frame
192
+ }) {
193
+ const digest = digestPluginGameplayFrame(frame);
194
+ return /* @__PURE__ */ jsx(
195
+ "span",
196
+ {
197
+ "aria-hidden": "true",
198
+ style: { display: "none" },
199
+ ...{
200
+ [BROWSER_INTERACTION_ATTRIBUTES.protocol]: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
201
+ [BROWSER_INTERACTION_ATTRIBUTES.surface]: GAMEPLAY_BROWSER_INTERACTION_SURFACE,
202
+ [BROWSER_INTERACTION_ATTRIBUTES.scope]: GAMEPLAY_BROWSER_SCOPE_ID,
203
+ [BROWSER_INTERACTION_ATTRIBUTES.role]: "projection",
204
+ [BROWSER_PROJECTION_DIGEST_ATTRIBUTE]: digest
205
+ }
206
+ }
207
+ );
208
+ }
209
+
210
+ // src/runtime/context/InteractionDraftContext.tsx
211
+ import {
212
+ createContext as createContext2,
213
+ useContext as useContext2,
214
+ useMemo as useMemo3
215
+ } from "react";
216
+ import { useStore } from "zustand";
217
+ import { createStore } from "zustand/vanilla";
218
+ import { useShallow } from "zustand/shallow";
219
+ import { jsx as jsx2 } from "react/jsx-runtime";
220
+ var EMPTY_DRAFT = Object.freeze({});
221
+ function omitRecordKey(record, key) {
222
+ const next = { ...record };
223
+ delete next[key];
224
+ return next;
225
+ }
226
+ function createInteractionUiStore() {
227
+ const store = createStore()(() => ({
228
+ drafts: {},
229
+ arms: {},
230
+ submitting: {},
231
+ pendingInteractionKey: null,
232
+ pendingInteractionRevision: 0
233
+ }));
234
+ const api = {
235
+ getDraft(interactionId) {
236
+ return store.getState().drafts[interactionId] ?? EMPTY_DRAFT;
237
+ },
238
+ setInput(interactionId, key, value) {
239
+ store.setState((prev) => {
240
+ const current = prev.drafts[interactionId];
241
+ if (current && current[key] === value) return prev;
242
+ return {
243
+ ...prev,
244
+ drafts: {
245
+ ...prev.drafts,
246
+ [interactionId]: { ...current ?? {}, [key]: value }
247
+ }
248
+ };
249
+ });
250
+ },
251
+ clearInput(interactionId, key) {
252
+ store.setState((prev) => {
253
+ const current = prev.drafts[interactionId];
254
+ if (!current) return prev;
255
+ if (key === void 0) {
256
+ return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };
257
+ }
258
+ if (!(key in current)) return prev;
259
+ const remainingKeys = omitRecordKey(current, key);
260
+ if (Object.keys(remainingKeys).length === 0) {
261
+ return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };
262
+ }
263
+ return {
264
+ ...prev,
265
+ drafts: { ...prev.drafts, [interactionId]: remainingKeys }
266
+ };
267
+ });
268
+ },
269
+ clearAll() {
270
+ store.setState((prev) => {
271
+ if (Object.keys(prev.drafts).length === 0 && Object.keys(prev.arms).length === 0 && Object.keys(prev.submitting).length === 0 && prev.pendingInteractionKey === null) {
272
+ return prev;
273
+ }
274
+ return {
275
+ drafts: {},
276
+ arms: {},
277
+ submitting: {},
278
+ pendingInteractionKey: null,
279
+ pendingInteractionRevision: prev.pendingInteractionRevision + 1
280
+ };
281
+ });
282
+ },
283
+ getArmed(surface) {
284
+ return store.getState().arms[surface] ?? null;
285
+ },
286
+ arm(surface, interactionId) {
287
+ store.setState((prev) => {
288
+ const current = prev.arms[surface] ?? null;
289
+ if (current === interactionId) return prev;
290
+ if (interactionId === null) {
291
+ return { ...prev, arms: omitRecordKey(prev.arms, surface) };
292
+ }
293
+ return { ...prev, arms: { ...prev.arms, [surface]: interactionId } };
294
+ });
295
+ },
296
+ getPendingInteraction() {
297
+ return store.getState().pendingInteractionKey;
298
+ },
299
+ setPendingInteraction(interactionId) {
300
+ store.setState((prev) => {
301
+ if (prev.pendingInteractionKey === interactionId) {
302
+ return interactionId === null ? prev : {
303
+ ...prev,
304
+ pendingInteractionRevision: prev.pendingInteractionRevision + 1
305
+ };
306
+ }
307
+ return {
308
+ ...prev,
309
+ pendingInteractionKey: interactionId,
310
+ pendingInteractionRevision: prev.pendingInteractionRevision + 1
311
+ };
312
+ });
313
+ },
314
+ getPendingInteractionRevision() {
315
+ return store.getState().pendingInteractionRevision;
316
+ },
317
+ isSubmitting(interactionId) {
318
+ return store.getState().submitting[interactionId] === true;
319
+ },
320
+ claimSubmitting(interactionId) {
321
+ let claimed = false;
322
+ store.setState((prev) => {
323
+ if (prev.submitting[interactionId] === true) return prev;
324
+ claimed = true;
325
+ return {
326
+ ...prev,
327
+ submitting: { ...prev.submitting, [interactionId]: true }
328
+ };
329
+ });
330
+ return claimed;
331
+ },
332
+ setSubmitting(interactionId, submitting) {
333
+ store.setState((prev) => {
334
+ const current = prev.submitting[interactionId] === true;
335
+ if (current === submitting) return prev;
336
+ if (!submitting) {
337
+ return {
338
+ ...prev,
339
+ submitting: omitRecordKey(prev.submitting, interactionId)
340
+ };
341
+ }
342
+ return {
343
+ ...prev,
344
+ submitting: { ...prev.submitting, [interactionId]: true }
345
+ };
346
+ });
347
+ }
348
+ };
349
+ return Object.assign(store, api);
350
+ }
351
+ var contextRegistryKey2 = "__dreamboardInteractionUiContext";
352
+ var contextRegistryGlobal2 = globalThis;
353
+ var InteractionUiCtx = contextRegistryGlobal2[contextRegistryKey2] ?? (contextRegistryGlobal2[contextRegistryKey2] = createContext2(null));
354
+ function InteractionUiProvider({
355
+ children,
356
+ store
357
+ }) {
358
+ const ownedStore = useMemo3(() => createInteractionUiStore(), []);
359
+ return /* @__PURE__ */ jsx2(InteractionUiCtx.Provider, { value: store ?? ownedStore, children });
360
+ }
361
+ function useInteractionUiStore() {
362
+ const ctx = useContext2(InteractionUiCtx);
363
+ const fallback = useMemo3(() => createInteractionUiStore(), []);
364
+ return ctx ?? fallback;
365
+ }
366
+ function useInteractionDraft(interactionId) {
367
+ const store = useInteractionUiStore();
368
+ useStore(
369
+ store,
370
+ useShallow(
371
+ (state) => state.drafts[interactionId] ?? EMPTY_DRAFT
372
+ )
373
+ );
374
+ return store.getDraft(interactionId);
375
+ }
376
+ function useArmedInteraction(surface) {
377
+ const store = useInteractionUiStore();
378
+ return useStore(store, (state) => state.arms[surface] ?? null);
379
+ }
380
+ function usePendingInteractionKey() {
381
+ const store = useInteractionUiStore();
382
+ const subscribed = useStore(
383
+ store,
384
+ (state) => state.pendingInteractionKey ?? null
385
+ );
386
+ return store.getPendingInteraction() ?? subscribed;
387
+ }
388
+ function usePendingInteractionRevision() {
389
+ const store = useInteractionUiStore();
390
+ const subscribed = useStore(
391
+ store,
392
+ (state) => state.pendingInteractionRevision
393
+ );
394
+ return Math.max(store.getPendingInteractionRevision(), subscribed);
395
+ }
396
+ function useInteractionSubmitting(interactionId) {
397
+ const store = useInteractionUiStore();
398
+ return useStore(
399
+ store,
400
+ (state) => state.submitting[interactionId] === true
401
+ );
402
+ }
403
+
404
+ // src/runtime/context/PluginSessionContext.tsx
405
+ import {
406
+ createContext as createContext3,
407
+ useContext as useContext3,
408
+ useMemo as useMemo4,
409
+ useSyncExternalStore as useSyncExternalStore3
410
+ } from "react";
411
+ import { jsx as jsx3 } from "react/jsx-runtime";
412
+ var contextRegistryKey3 = "__dreamboardPluginSessionContext";
413
+ var contextRegistryGlobal3 = globalThis;
414
+ var contextRegistry2 = contextRegistryGlobal3[contextRegistryKey3] ?? (contextRegistryGlobal3[contextRegistryKey3] = {
415
+ session: createContext3(null),
416
+ descriptor: createContext3(null)
417
+ });
418
+ var PluginSessionContext = contextRegistry2.session;
419
+ var PluginSessionDescriptorContext = contextRegistry2.descriptor;
420
+ function sessionStateFromClient(runtime) {
421
+ const session = runtime.getSession();
422
+ const frame = runtime.getFrame();
423
+ return {
424
+ status: session ? "ready" : "loading",
425
+ sessionId: session?.sessionId ?? null,
426
+ controllingPlayerId: frame?.perspectivePlayerId ?? null
427
+ };
428
+ }
429
+ function pluginSessionStatesEqual(left, right) {
430
+ if (left.status !== right.status || left.sessionId !== right.sessionId || left.controllingPlayerId !== right.controllingPlayerId) {
431
+ return false;
432
+ }
433
+ return true;
434
+ }
435
+ function pluginSessionDescriptorsEqual(left, right) {
436
+ if (left === right) return true;
437
+ if (!left || !right) return false;
438
+ if (left.sessionId !== right.sessionId || left.players.length !== right.players.length) {
439
+ return false;
440
+ }
441
+ return left.players.every((player, index) => {
442
+ const next = right.players[index];
443
+ return player.playerId === next?.playerId && player.displayName === next.displayName && player.color === next.color;
444
+ });
445
+ }
446
+ function PluginSessionProvider({
447
+ runtime,
448
+ children
449
+ }) {
450
+ const sessionStore = useMemo4(() => {
451
+ let current = sessionStateFromClient(runtime);
452
+ return {
453
+ subscribe: (onStoreChange) => {
454
+ const refresh = () => {
455
+ const next = sessionStateFromClient(runtime);
456
+ if (pluginSessionStatesEqual(current, next)) {
457
+ return;
458
+ }
459
+ current = next;
460
+ onStoreChange();
461
+ };
462
+ const unsubscribeSession = runtime.subscribeSession(refresh);
463
+ const unsubscribeFrame = runtime.subscribeFrame(refresh);
464
+ return () => {
465
+ unsubscribeFrame();
466
+ unsubscribeSession();
467
+ };
468
+ },
469
+ getSnapshot: () => current,
470
+ getServerSnapshot: () => current
471
+ };
472
+ }, [runtime]);
473
+ const descriptorStore = useMemo4(() => {
474
+ let current = runtime.getSession();
475
+ return {
476
+ subscribe: (onStoreChange) => {
477
+ const refresh = () => {
478
+ const next = runtime.getSession();
479
+ if (pluginSessionDescriptorsEqual(current, next)) {
480
+ return;
481
+ }
482
+ current = next;
483
+ onStoreChange();
484
+ };
485
+ const unsubscribeSession = runtime.subscribeSession(refresh);
486
+ return () => {
487
+ unsubscribeSession();
488
+ };
489
+ },
490
+ getSnapshot: () => current,
491
+ getServerSnapshot: () => current
492
+ };
493
+ }, [runtime]);
494
+ const sessionState = useSyncExternalStore3(
495
+ sessionStore.subscribe,
496
+ sessionStore.getSnapshot,
497
+ sessionStore.getServerSnapshot
498
+ );
499
+ const sessionDescriptor = useSyncExternalStore3(
500
+ descriptorStore.subscribe,
501
+ descriptorStore.getSnapshot,
502
+ descriptorStore.getServerSnapshot
503
+ );
504
+ return /* @__PURE__ */ jsx3(PluginSessionContext.Provider, { value: sessionState, children: /* @__PURE__ */ jsx3(PluginSessionDescriptorContext.Provider, { value: sessionDescriptor, children }) });
505
+ }
506
+ function usePluginSession() {
507
+ const context = useContext3(PluginSessionContext);
508
+ if (context === null) {
509
+ throw new Error(
510
+ "usePluginSession must be used within a PluginSessionContext.Provider (provided by RuntimeContext)"
511
+ );
512
+ }
513
+ return context;
514
+ }
515
+ function useOptionalPluginSessionDescriptor() {
516
+ return useContext3(PluginSessionDescriptorContext);
517
+ }
518
+ function usePluginSessionDescriptor() {
519
+ const descriptor = useOptionalPluginSessionDescriptor();
520
+ if (!descriptor) {
521
+ throw new Error(
522
+ "usePluginSessionDescriptor must be used within PluginSessionProvider."
523
+ );
524
+ }
525
+ return descriptor;
526
+ }
527
+
528
+ // src/runtime/context/RuntimeContext.tsx
529
+ import { createContext as createContext4, useContext as useContext4, useState, useEffect } from "react";
530
+ import { jsx as jsx4 } from "react/jsx-runtime";
531
+ var contextRegistryKey4 = "__dreamboardRuntimeContext";
532
+ var contextRegistryGlobal4 = globalThis;
533
+ var RuntimeContext = contextRegistryGlobal4[contextRegistryKey4] ?? (contextRegistryGlobal4[contextRegistryKey4] = createContext4(
534
+ null
535
+ ));
536
+ function useRuntimeContext() {
537
+ const context = useContext4(RuntimeContext);
538
+ if (!context) {
539
+ throw new Error(
540
+ "useRuntimeContext must be used within a RuntimeContext.Provider"
541
+ );
542
+ }
543
+ return context;
544
+ }
545
+
546
+ export {
547
+ defaultRuntimeSnapshotEquality,
548
+ PluginGameplayFrameProvider,
549
+ usePluginGameplayFrameSelector,
550
+ useAuthoredPluginGameplayFrameSelector,
551
+ InteractionUiProvider,
552
+ useInteractionUiStore,
553
+ useInteractionDraft,
554
+ useArmedInteraction,
555
+ usePendingInteractionKey,
556
+ usePendingInteractionRevision,
557
+ useInteractionSubmitting,
558
+ PluginSessionProvider,
559
+ usePluginSession,
560
+ usePluginSessionDescriptor,
561
+ RuntimeContext,
562
+ useRuntimeContext
563
+ };
564
+ //# sourceMappingURL=chunk-VLG4YST5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime/context/PluginGameplayFrameContext.tsx","../src/runtime/hooks/useRuntimeSnapshotSelector.ts","../src/runtime/context/InteractionDraftContext.tsx","../src/runtime/context/PluginSessionContext.tsx","../src/runtime/context/RuntimeContext.tsx"],"sourcesContent":["import {\n default as React,\n createContext,\n useContext,\n useMemo,\n useSyncExternalStore,\n} from \"react\";\nimport {\n digestPluginGameplayFrame,\n type PluginGameplayFrame,\n} from \"@dreamboard-games/plugin-runtime-contract\";\nimport type { PluginRuntimeClient } from \"../core/types.js\";\nimport type {\n InteractionDescriptor,\n ZoneHandlesSnapshot,\n} from \"../types/plugin-state.js\";\nimport {\n BROWSER_INTERACTION_ATTRIBUTES,\n DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,\n GAMEPLAY_BROWSER_INTERACTION_SURFACE,\n} from \"../../browser-interaction/index.js\";\nimport {\n defaultRuntimeSnapshotEquality,\n type EqualityFn,\n useRuntimeSnapshotSelector,\n} from \"../hooks/useRuntimeSnapshotSelector.js\";\n\ntype PluginGameplayFrameStore = {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => PluginGameplayFrame | null;\n getServerSnapshot: () => PluginGameplayFrame | null;\n};\n\ntype PluginGameplayFrameContextRegistry = {\n store: React.Context<PluginGameplayFrameStore | null>;\n frame: React.Context<PluginGameplayFrame | null>;\n};\n\nconst contextRegistryKey = \"__dreamboardPluginGameplayFrameContext\";\nconst contextRegistryGlobal = globalThis as typeof globalThis & {\n [contextRegistryKey]?: PluginGameplayFrameContextRegistry;\n};\nconst contextRegistry =\n contextRegistryGlobal[contextRegistryKey] ??\n (contextRegistryGlobal[contextRegistryKey] = {\n store: createContext<PluginGameplayFrameStore | null>(null),\n frame: createContext<PluginGameplayFrame | null>(null),\n });\n\nconst PluginGameplayFrameStoreContext = contextRegistry.store;\nconst PluginGameplayFrameContext = contextRegistry.frame;\n\nfunction DefaultLoadingScreen() {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n height: \"100%\",\n width: \"100%\",\n color: \"#666\",\n }}\n >\n <div style={{ textAlign: \"center\" }}>\n <div\n style={{\n width: \"40px\",\n height: \"40px\",\n border: \"3px solid #e0e0e0\",\n borderTopColor: \"#666\",\n borderRadius: \"50%\",\n animation: \"spin 1s linear infinite\",\n margin: \"0 auto 12px\",\n }}\n />\n <style>{`@keyframes spin { to { transform: rotate(360deg); } }`}</style>\n <p>Loading game view...</p>\n </div>\n </div>\n );\n}\n\nexport interface PluginGameplayFrameProviderProps {\n runtime: PluginRuntimeClient;\n children: React.ReactNode;\n loadingComponent?: React.ReactNode;\n}\n\nexport function PluginGameplayFrameProvider({\n runtime,\n children,\n loadingComponent = <DefaultLoadingScreen />,\n}: PluginGameplayFrameProviderProps) {\n const storeApi = useMemo<PluginGameplayFrameStore>(() => {\n let current = runtime.getFrame();\n return {\n subscribe: (onStoreChange) =>\n runtime.subscribeFrame(() => {\n current = runtime.getFrame();\n onStoreChange();\n }),\n getSnapshot: () => current,\n getServerSnapshot: () => current,\n };\n }, [runtime]);\n\n return (\n <PluginGameplayFrameStoreProvider\n store={storeApi}\n loadingComponent={loadingComponent}\n >\n {children}\n </PluginGameplayFrameStoreProvider>\n );\n}\n\nfunction PluginGameplayFrameStoreProvider({\n store,\n children,\n loadingComponent,\n}: {\n store: PluginGameplayFrameStore;\n children: React.ReactNode;\n loadingComponent: React.ReactNode;\n}) {\n const frame = useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n );\n\n if (!frame) {\n return <>{loadingComponent}</>;\n }\n\n return (\n <PluginGameplayFrameStoreContext.Provider value={store}>\n <PluginGameplayFrameContext.Provider value={frame}>\n <SemanticGameplayFrameMarker frame={frame} />\n {children}\n </PluginGameplayFrameContext.Provider>\n </PluginGameplayFrameStoreContext.Provider>\n );\n}\n\nexport function usePluginGameplayFrame(): PluginGameplayFrame {\n const frame = useContext(PluginGameplayFrameContext);\n if (!frame) {\n throw new Error(\n \"usePluginGameplayFrame must be used within PluginGameplayFrameProvider.\",\n );\n }\n return frame;\n}\n\nexport function usePluginGameplayFrameSelector<T>(\n selector: (frame: PluginGameplayFrame) => T,\n equalityFn: EqualityFn<T> = defaultRuntimeSnapshotEquality,\n): T {\n const store = useContext(PluginGameplayFrameStoreContext);\n if (!store) {\n throw new Error(\n \"usePluginGameplayFrameSelector must be used within PluginGameplayFrameProvider.\",\n );\n }\n\n return useRuntimeSnapshotSelector(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n (frame) => selector(requirePluginGameplayFrame(frame)),\n equalityFn,\n );\n}\n\ntype AuthoredPluginGameplayFrame = Omit<\n PluginGameplayFrame,\n \"availableInteractions\" | \"zones\"\n> & {\n readonly availableInteractions: readonly InteractionDescriptor[];\n readonly zones: Readonly<Record<string, ZoneHandlesSnapshot>>;\n};\n\nexport function useAuthoredPluginGameplayFrameSelector<T>(\n selector: (frame: AuthoredPluginGameplayFrame) => T,\n equalityFn: EqualityFn<T> = defaultRuntimeSnapshotEquality,\n): T {\n return usePluginGameplayFrameSelector(\n (frame) => selector(frame as unknown as AuthoredPluginGameplayFrame),\n equalityFn,\n );\n}\n\nfunction requirePluginGameplayFrame(\n frame: PluginGameplayFrame | null,\n): PluginGameplayFrame {\n if (!frame) {\n throw new Error(\"Plugin gameplay frame is not available.\");\n }\n return frame;\n}\n\nconst GAMEPLAY_BROWSER_SCOPE_ID = \"runtime\";\nconst BROWSER_PROJECTION_DIGEST_ATTRIBUTE = \"data-dreamboard-projection-digest\";\n\nexport function RuntimeSemanticProjectionMarker() {\n const frame = usePluginGameplayFrame();\n return <SemanticGameplayFrameMarker frame={frame} />;\n}\n\nexport function SemanticGameplayFrameMarker({\n frame,\n}: {\n frame: PluginGameplayFrame;\n}) {\n const digest = digestPluginGameplayFrame(frame);\n return (\n <span\n aria-hidden=\"true\"\n style={{ display: \"none\" }}\n {...{\n [BROWSER_INTERACTION_ATTRIBUTES.protocol]:\n DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,\n [BROWSER_INTERACTION_ATTRIBUTES.surface]:\n GAMEPLAY_BROWSER_INTERACTION_SURFACE,\n [BROWSER_INTERACTION_ATTRIBUTES.scope]: GAMEPLAY_BROWSER_SCOPE_ID,\n [BROWSER_INTERACTION_ATTRIBUTES.role]: \"projection\",\n [BROWSER_PROJECTION_DIGEST_ATTRIBUTE]: digest,\n }}\n />\n );\n}\n","import { useCallback, useMemo, useSyncExternalStore } from \"react\";\n\nexport type EqualityFn<T> = (left: T, right: T) => boolean;\n\nexport function defaultRuntimeSnapshotEquality<T>(left: T, right: T): boolean {\n return Object.is(left, right);\n}\n\ninterface SelectorCache<State, Selection> {\n snapshot: State;\n selection: Selection;\n}\n\ninterface SelectorCacheCell<State, Selection> {\n current: SelectorCache<State, Selection> | null;\n selector: (state: State) => Selection;\n equalityFn: EqualityFn<Selection>;\n}\n\nexport function useRuntimeSnapshotSelector<State, Selection>(\n subscribe: (listener: () => void) => () => void,\n getSnapshot: () => State,\n getServerSnapshot: () => State,\n selector: (state: State) => Selection,\n equalityFn: EqualityFn<Selection> = defaultRuntimeSnapshotEquality,\n): Selection {\n const cache = useMemo<SelectorCacheCell<State, Selection>>(\n () => ({ current: null, selector, equalityFn }),\n [equalityFn, selector],\n );\n\n const getSelectedFromSnapshot = useCallback(\n (snapshot: State): Selection => {\n const cached = cache.current;\n if (cached && cached.snapshot === snapshot) {\n return cached.selection;\n }\n\n const nextSelection = selector(snapshot);\n if (cached && equalityFn(cached.selection, nextSelection)) {\n cache.current = {\n snapshot,\n selection: cached.selection,\n };\n return cached.selection;\n }\n\n cache.current = {\n snapshot,\n selection: nextSelection,\n };\n return nextSelection;\n },\n [cache, equalityFn, selector],\n );\n\n const getSelectedSnapshot = useCallback(\n () => getSelectedFromSnapshot(getSnapshot()),\n [getSelectedFromSnapshot, getSnapshot],\n );\n\n const getSelectedServerSnapshot = useCallback(\n () => selector(getServerSnapshot()),\n [getServerSnapshot, selector],\n );\n\n const subscribeSelected = useCallback(\n (onStoreChange: () => void) =>\n subscribe(() => {\n const previous = cache.current;\n const nextSelection = getSelectedSnapshot();\n if (!previous || !equalityFn(previous.selection, nextSelection)) {\n onStoreChange();\n }\n }),\n [cache, equalityFn, getSelectedSnapshot, subscribe],\n );\n\n return useSyncExternalStore(\n subscribeSelected,\n getSelectedSnapshot,\n getSelectedServerSnapshot,\n );\n}\n","import {\n createContext,\n useContext,\n useMemo,\n type Context,\n type ReactNode,\n} from \"react\";\nimport { useStore } from \"zustand\";\nimport { createStore, type StoreApi } from \"zustand/vanilla\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype Draft = Readonly<Record<string, unknown>>;\n\nconst EMPTY_DRAFT: Draft = Object.freeze({});\n\nfunction omitRecordKey<Value>(\n record: Readonly<Record<string, Value>>,\n key: string,\n): Readonly<Record<string, Value>> {\n const next: Record<string, Value> = { ...record };\n delete next[key];\n return next;\n}\n\ninterface DraftState {\n drafts: Readonly<Record<string, Draft>>;\n arms: Readonly<Record<string, string>>;\n submitting: Readonly<Record<string, true>>;\n pendingInteractionKey: string | null;\n pendingInteractionRevision: number;\n}\n\n/**\n * Imperative API exposed to interaction primitives.\n * Intentionally small; the vanilla zustand store underneath powers\n * fine-grained subscriptions via {@link useDraft} and {@link useArmed}.\n */\nexport interface InteractionUiStore {\n /** Read the current draft for an interaction id. Never undefined. */\n getDraft(interactionId: string): Draft;\n /** Merge a single input key into the draft. Creates the draft if needed. */\n setInput(interactionId: string, key: string, value: unknown): void;\n /** Clear a single input, or the whole draft if `key` is omitted. */\n clearInput(interactionId: string, key?: string): void;\n /** Clear every draft and arming state. */\n clearAll(): void;\n /** Which interaction (if any) is currently armed on the given surface. */\n getArmed(surface: string): string | null;\n /** Arm a specific interaction on a surface. Pass `null` to disarm. */\n arm(surface: string, interactionId: string | null): void;\n /** Which interaction draft currently needs route-owned remaining input UI. */\n getPendingInteraction(): string | null;\n /** Mark the interaction draft currently waiting for remaining input. */\n setPendingInteraction(interactionId: string | null): void;\n /** Monotonic revision bumped whenever a pending interaction is routed. */\n getPendingInteractionRevision(): number;\n /** True while a local submission is in flight before the host echo arrives. */\n isSubmitting(interactionId: string): boolean;\n /** Atomically mark a submission in flight. Returns false if already busy. */\n claimSubmitting(interactionId: string): boolean;\n /** Mark or clear a local submission in flight. */\n setSubmitting(interactionId: string, submitting: boolean): void;\n}\n\n/** Vanilla zustand store implementing {@link InteractionUiStore}. */\nexport type InteractionUiStoreApi = StoreApi<DraftState> & InteractionUiStore;\n\nexport function createInteractionUiStore(): InteractionUiStoreApi {\n const store = createStore<DraftState>()(() => ({\n drafts: {},\n arms: {},\n submitting: {},\n pendingInteractionKey: null,\n pendingInteractionRevision: 0,\n }));\n\n const api: InteractionUiStore = {\n getDraft(interactionId) {\n return store.getState().drafts[interactionId] ?? EMPTY_DRAFT;\n },\n setInput(interactionId, key, value) {\n store.setState((prev) => {\n const current = prev.drafts[interactionId];\n if (current && current[key] === value) return prev;\n return {\n ...prev,\n drafts: {\n ...prev.drafts,\n [interactionId]: { ...(current ?? {}), [key]: value },\n },\n };\n });\n },\n clearInput(interactionId, key) {\n store.setState((prev) => {\n const current = prev.drafts[interactionId];\n if (!current) return prev;\n if (key === undefined) {\n return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };\n }\n if (!(key in current)) return prev;\n const remainingKeys = omitRecordKey(current, key);\n if (Object.keys(remainingKeys).length === 0) {\n return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };\n }\n return {\n ...prev,\n drafts: { ...prev.drafts, [interactionId]: remainingKeys },\n };\n });\n },\n clearAll() {\n store.setState((prev) => {\n if (\n Object.keys(prev.drafts).length === 0 &&\n Object.keys(prev.arms).length === 0 &&\n Object.keys(prev.submitting).length === 0 &&\n prev.pendingInteractionKey === null\n ) {\n return prev;\n }\n return {\n drafts: {},\n arms: {},\n submitting: {},\n pendingInteractionKey: null,\n pendingInteractionRevision: prev.pendingInteractionRevision + 1,\n };\n });\n },\n getArmed(surface) {\n return store.getState().arms[surface] ?? null;\n },\n arm(surface, interactionId) {\n store.setState((prev) => {\n const current = prev.arms[surface] ?? null;\n if (current === interactionId) return prev;\n if (interactionId === null) {\n return { ...prev, arms: omitRecordKey(prev.arms, surface) };\n }\n return { ...prev, arms: { ...prev.arms, [surface]: interactionId } };\n });\n },\n getPendingInteraction() {\n return store.getState().pendingInteractionKey;\n },\n setPendingInteraction(interactionId) {\n store.setState((prev) => {\n if (prev.pendingInteractionKey === interactionId) {\n return interactionId === null\n ? prev\n : {\n ...prev,\n pendingInteractionRevision: prev.pendingInteractionRevision + 1,\n };\n }\n return {\n ...prev,\n pendingInteractionKey: interactionId,\n pendingInteractionRevision: prev.pendingInteractionRevision + 1,\n };\n });\n },\n getPendingInteractionRevision() {\n return store.getState().pendingInteractionRevision;\n },\n isSubmitting(interactionId) {\n return store.getState().submitting[interactionId] === true;\n },\n claimSubmitting(interactionId) {\n let claimed = false;\n store.setState((prev) => {\n if (prev.submitting[interactionId] === true) return prev;\n claimed = true;\n return {\n ...prev,\n submitting: { ...prev.submitting, [interactionId]: true },\n };\n });\n return claimed;\n },\n setSubmitting(interactionId, submitting) {\n store.setState((prev) => {\n const current = prev.submitting[interactionId] === true;\n if (current === submitting) return prev;\n if (!submitting) {\n return {\n ...prev,\n submitting: omitRecordKey(prev.submitting, interactionId),\n };\n }\n return {\n ...prev,\n submitting: { ...prev.submitting, [interactionId]: true },\n };\n });\n },\n };\n\n return Object.assign(store, api);\n}\n\nconst contextRegistryKey = \"__dreamboardInteractionUiContext\";\nconst contextRegistryGlobal = globalThis as typeof globalThis & {\n [contextRegistryKey]?: Context<InteractionUiStoreApi | null>;\n};\nconst InteractionUiCtx =\n contextRegistryGlobal[contextRegistryKey] ??\n (contextRegistryGlobal[contextRegistryKey] =\n createContext<InteractionUiStoreApi | null>(null));\n\n/**\n * React provider that holds draft input state shared across every surface\n * inside the tree. Auto-installed by `<PluginRuntime>`; authors rarely\n * mount it directly. Mount manually when rendering surface components in\n * isolation (e.g., Storybook, snapshot tests).\n *\n * ```tsx\n * <InteractionUiProvider>\n * <PanelSurface />\n * <Board.Root>{...}</Board.Root>\n * </InteractionUiProvider>\n * ```\n */\nexport function InteractionUiProvider({\n children,\n store,\n}: {\n children: ReactNode;\n store?: InteractionUiStoreApi;\n}) {\n const ownedStore = useMemo(() => createInteractionUiStore(), []);\n return (\n <InteractionUiCtx.Provider value={store ?? ownedStore}>\n {children}\n </InteractionUiCtx.Provider>\n );\n}\n\n/**\n * Access the active draft store. Falls back to an inert in-memory store\n * when no provider is mounted, so surface hooks remain callable in bare\n * test harnesses without crashing — draft state simply isn't shared\n * across components in that case.\n */\nexport function useInteractionUiStore(): InteractionUiStoreApi {\n const ctx = useContext(InteractionUiCtx);\n const fallback = useMemo(() => createInteractionUiStore(), []);\n return ctx ?? fallback;\n}\n\n/**\n * Subscribe to the draft for a single interaction id with per-slice\n * re-renders. Returns a stable empty object when the draft is unset.\n */\nexport function useInteractionDraft(interactionId: string): Draft {\n const store = useInteractionUiStore();\n useStore(\n store,\n useShallow(\n (state: DraftState) => state.drafts[interactionId] ?? EMPTY_DRAFT,\n ),\n );\n return store.getDraft(interactionId);\n}\n\n/** Subscribe to the armed interaction id on a given surface. */\nexport function useArmedInteraction(surface: string): string | null {\n const store = useInteractionUiStore();\n return useStore(store, (state: DraftState) => state.arms[surface] ?? null);\n}\n\n/** Subscribe to the interaction draft currently waiting for pending input. */\nexport function usePendingInteractionKey(): string | null {\n const store = useInteractionUiStore();\n const subscribed = useStore(\n store,\n (state: DraftState) => state.pendingInteractionKey ?? null,\n );\n return store.getPendingInteraction() ?? subscribed;\n}\n\n/** Subscribe to pending interaction route attempts. */\nexport function usePendingInteractionRevision(): number {\n const store = useInteractionUiStore();\n const subscribed = useStore(\n store,\n (state: DraftState) => state.pendingInteractionRevision,\n );\n return Math.max(store.getPendingInteractionRevision(), subscribed);\n}\n\n/** Subscribe to local submitting status for a single interaction key. */\nexport function useInteractionSubmitting(interactionId: string): boolean {\n const store = useInteractionUiStore();\n return useStore(\n store,\n (state: DraftState) => state.submitting[interactionId] === true,\n );\n}\n","import {\n createContext,\n useContext,\n useMemo,\n useSyncExternalStore,\n type ReactNode,\n} from \"react\";\nimport type {\n PluginPlayerSummary,\n PluginSessionDescriptor,\n} from \"@dreamboard-games/plugin-runtime-contract\";\nimport type { PluginRuntimeClient } from \"../core/types.js\";\nimport type { PluginSessionState } from \"../types/runtime-api\";\n\n/**\n * Context for plugin session metadata.\n * This context is provided by the RuntimeContext after receiving init message from parent.\n */\ntype PluginSessionContextRegistry = {\n session: React.Context<PluginSessionState | null>;\n descriptor: React.Context<PluginSessionDescriptor | null>;\n};\n\nconst contextRegistryKey = \"__dreamboardPluginSessionContext\";\nconst contextRegistryGlobal = globalThis as typeof globalThis & {\n [contextRegistryKey]?: PluginSessionContextRegistry;\n};\nconst contextRegistry =\n contextRegistryGlobal[contextRegistryKey] ??\n (contextRegistryGlobal[contextRegistryKey] = {\n session: createContext<PluginSessionState | null>(null),\n descriptor: createContext<PluginSessionDescriptor | null>(null),\n });\n\nexport const PluginSessionContext = contextRegistry.session;\nconst PluginSessionDescriptorContext = contextRegistry.descriptor;\n\nfunction sessionStateFromClient(\n runtime: PluginRuntimeClient,\n): PluginSessionState {\n const session = runtime.getSession();\n const frame = runtime.getFrame();\n return {\n status: session ? \"ready\" : \"loading\",\n sessionId: session?.sessionId ?? null,\n controllingPlayerId: frame?.perspectivePlayerId ?? null,\n };\n}\n\nfunction pluginSessionStatesEqual(\n left: PluginSessionState,\n right: PluginSessionState,\n): boolean {\n if (\n left.status !== right.status ||\n left.sessionId !== right.sessionId ||\n left.controllingPlayerId !== right.controllingPlayerId\n ) {\n return false;\n }\n return true;\n}\n\nfunction pluginSessionDescriptorsEqual(\n left: PluginSessionDescriptor | null,\n right: PluginSessionDescriptor | null,\n): boolean {\n if (left === right) return true;\n if (!left || !right) return false;\n if (\n left.sessionId !== right.sessionId ||\n left.players.length !== right.players.length\n ) {\n return false;\n }\n\n return left.players.every((player, index) => {\n const next = right.players[index];\n return (\n player.playerId === next?.playerId &&\n player.displayName === next.displayName &&\n player.color === next.color\n );\n });\n}\n\nexport function PluginSessionProvider({\n runtime,\n children,\n}: {\n runtime: PluginRuntimeClient;\n children: ReactNode;\n}) {\n const sessionStore = useMemo(() => {\n let current = sessionStateFromClient(runtime);\n return {\n subscribe: (onStoreChange: () => void) => {\n const refresh = () => {\n const next = sessionStateFromClient(runtime);\n if (pluginSessionStatesEqual(current, next)) {\n return;\n }\n current = next;\n onStoreChange();\n };\n const unsubscribeSession = runtime.subscribeSession(refresh);\n const unsubscribeFrame = runtime.subscribeFrame(refresh);\n return () => {\n unsubscribeFrame();\n unsubscribeSession();\n };\n },\n getSnapshot: () => current,\n getServerSnapshot: () => current,\n };\n }, [runtime]);\n const descriptorStore = useMemo(() => {\n let current = runtime.getSession();\n return {\n subscribe: (onStoreChange: () => void) => {\n const refresh = () => {\n const next = runtime.getSession();\n if (pluginSessionDescriptorsEqual(current, next)) {\n return;\n }\n current = next;\n onStoreChange();\n };\n const unsubscribeSession = runtime.subscribeSession(refresh);\n return () => {\n unsubscribeSession();\n };\n },\n getSnapshot: () => current,\n getServerSnapshot: () => current,\n };\n }, [runtime]);\n const sessionState = useSyncExternalStore(\n sessionStore.subscribe,\n sessionStore.getSnapshot,\n sessionStore.getServerSnapshot,\n );\n const sessionDescriptor = useSyncExternalStore(\n descriptorStore.subscribe,\n descriptorStore.getSnapshot,\n descriptorStore.getServerSnapshot,\n );\n\n return (\n <PluginSessionContext.Provider value={sessionState}>\n <PluginSessionDescriptorContext.Provider value={sessionDescriptor}>\n {children}\n </PluginSessionDescriptorContext.Provider>\n </PluginSessionContext.Provider>\n );\n}\n\nexport function PluginSessionDescriptorProvider({\n descriptor,\n children,\n}: {\n descriptor: PluginSessionDescriptor | null;\n children: ReactNode;\n}) {\n return (\n <PluginSessionDescriptorContext.Provider value={descriptor}>\n {children}\n </PluginSessionDescriptorContext.Provider>\n );\n}\n\n/**\n * Hook to access plugin session metadata.\n * Returns session initialization status and IDs.\n *\n * @returns Plugin session state with status, sessionId, and controllingPlayerId\n *\n * @example\n * ```tsx\n * function MyPluginComponent() {\n * const { status, sessionId, controllingPlayerId } = usePluginSession();\n *\n * if (status === \"loading\") {\n * return <div>Initializing...</div>;\n * }\n *\n * return (\n * <div>\n * <p>Session: {sessionId}</p>\n * <p>Current perspective: {controllingPlayerId}</p>\n * </div>\n * );\n * }\n * ```\n */\nexport function usePluginSession(): PluginSessionState {\n const context = useContext(PluginSessionContext);\n\n if (context === null) {\n throw new Error(\n \"usePluginSession must be used within a PluginSessionContext.Provider (provided by RuntimeContext)\",\n );\n }\n\n return context;\n}\n\nexport function useOptionalPluginSessionDescriptor(): PluginSessionDescriptor | null {\n return useContext(PluginSessionDescriptorContext);\n}\n\nexport function usePluginSessionDescriptor(): PluginSessionDescriptor {\n const descriptor = useOptionalPluginSessionDescriptor();\n if (!descriptor) {\n throw new Error(\n \"usePluginSessionDescriptor must be used within PluginSessionProvider.\",\n );\n }\n return descriptor;\n}\n\nexport function usePluginPlayers(): readonly PluginPlayerSummary[] {\n return usePluginSessionDescriptor().players;\n}\n","import React, { createContext, useContext, useState, useEffect } from \"react\";\nimport type { RuntimeAPI, PluginSessionState } from \"../types/runtime-api.js\";\nimport { PluginSessionContext } from \"./PluginSessionContext.js\";\n\n/**\n * React Context for providing RuntimeAPI to plugin components.\n * This context must be provided by the plugin wrapper, not by the plugin code itself.\n */\nconst contextRegistryKey = \"__dreamboardRuntimeContext\";\nconst contextRegistryGlobal = globalThis as typeof globalThis & {\n [contextRegistryKey]?: React.Context<RuntimeAPI | null>;\n};\nexport const RuntimeContext =\n contextRegistryGlobal[contextRegistryKey] ??\n (contextRegistryGlobal[contextRegistryKey] = createContext<RuntimeAPI | null>(\n null,\n ));\n\n/**\n * Hook to access the RuntimeAPI from context.\n *\n * @throws Error if used outside of RuntimeContext.Provider\n * @returns RuntimeAPI instance\n *\n * @example\n * ```typescript\n * function MyPluginComponent() {\n * const runtime = useRuntimeContext();\n * return (\n * <button onClick={() => runtime.submitInteraction(\"pass\", {})}>\n * Pass\n * </button>\n * );\n * }\n * ```\n */\nexport function useRuntimeContext(): RuntimeAPI {\n const context = useContext(RuntimeContext);\n\n if (!context) {\n throw new Error(\n \"useRuntimeContext must be used within a RuntimeContext.Provider\",\n );\n }\n\n return context;\n}\n\n/**\n * RuntimeProvider component that provides both RuntimeAPI and PluginSessionContext.\n * This component subscribes to session state changes from the RuntimeAPI and provides\n * them through PluginSessionContext.\n *\n * @example\n * ```tsx\n * function PluginRoot() {\n * const runtime = createPluginRuntimeClient({ transport });\n *\n * return (\n * <RuntimeProvider runtime={runtime}>\n * <App />\n * </RuntimeProvider>\n * );\n * }\n * ```\n */\nexport function RuntimeProvider({\n runtime,\n children,\n}: {\n runtime: RuntimeAPI;\n children: React.ReactNode;\n}) {\n // Subscribe to session state changes\n const [sessionState, setSessionState] = useState<PluginSessionState>(() =>\n runtime.getSessionState(),\n );\n\n useEffect(() => {\n // Subscribe to session state changes via internal API\n const runtimeWithInternal = runtime as RuntimeAPI & {\n _subscribeToSessionState?: (\n listener: (state: PluginSessionState) => void,\n ) => () => void;\n };\n\n if (runtimeWithInternal._subscribeToSessionState) {\n return runtimeWithInternal._subscribeToSessionState((state) => {\n setSessionState(state);\n });\n }\n\n // Fallback: no session state subscription available\n return () => {};\n }, [runtime]);\n\n return (\n <RuntimeContext.Provider value={runtime}>\n <PluginSessionContext.Provider value={sessionState}>\n {children}\n </PluginSessionContext.Provider>\n </RuntimeContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA,WAAAA;AAAA,EACA,wBAAAC;AAAA,OACK;;;ACNP,SAAS,aAAa,SAAS,4BAA4B;AAIpD,SAAS,+BAAkC,MAAS,OAAmB;AAC5E,SAAO,OAAO,GAAG,MAAM,KAAK;AAC9B;AAaO,SAAS,2BACd,WACA,aACA,mBACA,UACA,aAAoC,gCACzB;AACX,QAAM,QAAQ;AAAA,IACZ,OAAO,EAAE,SAAS,MAAM,UAAU,WAAW;AAAA,IAC7C,CAAC,YAAY,QAAQ;AAAA,EACvB;AAEA,QAAM,0BAA0B;AAAA,IAC9B,CAAC,aAA+B;AAC9B,YAAM,SAAS,MAAM;AACrB,UAAI,UAAU,OAAO,aAAa,UAAU;AAC1C,eAAO,OAAO;AAAA,MAChB;AAEA,YAAM,gBAAgB,SAAS,QAAQ;AACvC,UAAI,UAAU,WAAW,OAAO,WAAW,aAAa,GAAG;AACzD,cAAM,UAAU;AAAA,UACd;AAAA,UACA,WAAW,OAAO;AAAA,QACpB;AACA,eAAO,OAAO;AAAA,MAChB;AAEA,YAAM,UAAU;AAAA,QACd;AAAA,QACA,WAAW;AAAA,MACb;AACA,aAAO;AAAA,IACT;AAAA,IACA,CAAC,OAAO,YAAY,QAAQ;AAAA,EAC9B;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SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","createContext","useContext","useMemo","jsx","contextRegistryKey","contextRegistryGlobal","createContext","useContext","useMemo","useSyncExternalStore","jsx","contextRegistryKey","contextRegistryGlobal","contextRegistry","useContext","createContext","useContext","jsx","contextRegistryKey","contextRegistryGlobal","createContext","useContext"]}
@@ -46,21 +46,4 @@ type ReducerDiagnosticsSink = {
46
46
  };
47
47
  declare const noopDiagnosticsSink: ReducerDiagnosticsSink;
48
48
 
49
- type StaleContractArtifactKind = "base-states" | "session-state";
50
- type StaleContractArtifactErrorOptions = {
51
- artifact: StaleContractArtifactKind;
52
- expected: string;
53
- found: string;
54
- remedy?: string;
55
- };
56
- declare class StaleContractArtifactError extends Error {
57
- readonly code = "STALE_CONTRACT_ARTIFACT";
58
- readonly artifact: StaleContractArtifactKind;
59
- readonly expected: string;
60
- readonly found: string;
61
- readonly remedy: string;
62
- constructor(options: StaleContractArtifactErrorOptions);
63
- }
64
- declare function isStaleContractArtifactError(error: unknown): error is StaleContractArtifactError;
65
-
66
- export { type DispatchTraceSummaryEntry as D, type ReducerDiagnosticEvent as R, StaleContractArtifactError as S, type ReducerDiagnosticsSink as a, type StaleContractArtifactErrorOptions as b, type StaleContractArtifactKind as c, isStaleContractArtifactError as i, noopDiagnosticsSink as n };
49
+ export { type DispatchTraceSummaryEntry as D, type ReducerDiagnosticEvent as R, type ReducerDiagnosticsSink as a, noopDiagnosticsSink as n };