@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
@@ -1,1266 +0,0 @@
1
- import {
2
- BROWSER_INTERACTION_ATTRIBUTES,
3
- DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
4
- GAMEPLAY_BROWSER_INTERACTION_SURFACE
5
- } from "./chunk-WHR5UW3F.js";
6
-
7
- // ../plugin-runtime-contract/dist/chunk-LCXQNYOL.js
8
- function canonicalizePluginRuntimeJson(value) {
9
- assertRuntimeJson(value);
10
- return canonicalizeJson(value);
11
- }
12
- function encodeCanonicalPluginRuntimeJson(value) {
13
- return JSON.stringify(canonicalizePluginRuntimeJson(value));
14
- }
15
- function digestPluginRuntimeJson(value) {
16
- return `sha256:${sha256Hex(encodeCanonicalPluginRuntimeJson(value))}`;
17
- }
18
- function canonicalizeJson(value) {
19
- if (value === null || typeof value === "boolean" || typeof value === "string") {
20
- return value;
21
- }
22
- if (typeof value === "number") {
23
- if (!Number.isFinite(value)) {
24
- throw new Error("canonical JSON contains a non-finite number");
25
- }
26
- return value;
27
- }
28
- if (Array.isArray(value)) {
29
- return value.map((item) => canonicalizeJson(item));
30
- }
31
- return Object.fromEntries(
32
- Object.entries(value).filter(([, item]) => item !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalizeJson(item)])
33
- );
34
- }
35
- function assertRuntimeJson(value) {
36
- if (value === null || typeof value === "boolean" || typeof value === "string") {
37
- return;
38
- }
39
- if (typeof value === "number") {
40
- if (!Number.isFinite(value)) {
41
- throw new Error("runtime JSON contains a non-finite number");
42
- }
43
- return;
44
- }
45
- if (Array.isArray(value)) {
46
- value.forEach(assertRuntimeJson);
47
- return;
48
- }
49
- if (typeof value === "object") {
50
- Object.values(value).forEach((item) => {
51
- if (item !== void 0) {
52
- assertRuntimeJson(item);
53
- }
54
- });
55
- return;
56
- }
57
- throw new Error(`runtime JSON contains unsupported ${typeof value} value`);
58
- }
59
- var SHA256_K = [
60
- 1116352408,
61
- 1899447441,
62
- 3049323471,
63
- 3921009573,
64
- 961987163,
65
- 1508970993,
66
- 2453635748,
67
- 2870763221,
68
- 3624381080,
69
- 310598401,
70
- 607225278,
71
- 1426881987,
72
- 1925078388,
73
- 2162078206,
74
- 2614888103,
75
- 3248222580,
76
- 3835390401,
77
- 4022224774,
78
- 264347078,
79
- 604807628,
80
- 770255983,
81
- 1249150122,
82
- 1555081692,
83
- 1996064986,
84
- 2554220882,
85
- 2821834349,
86
- 2952996808,
87
- 3210313671,
88
- 3336571891,
89
- 3584528711,
90
- 113926993,
91
- 338241895,
92
- 666307205,
93
- 773529912,
94
- 1294757372,
95
- 1396182291,
96
- 1695183700,
97
- 1986661051,
98
- 2177026350,
99
- 2456956037,
100
- 2730485921,
101
- 2820302411,
102
- 3259730800,
103
- 3345764771,
104
- 3516065817,
105
- 3600352804,
106
- 4094571909,
107
- 275423344,
108
- 430227734,
109
- 506948616,
110
- 659060556,
111
- 883997877,
112
- 958139571,
113
- 1322822218,
114
- 1537002063,
115
- 1747873779,
116
- 1955562222,
117
- 2024104815,
118
- 2227730452,
119
- 2361852424,
120
- 2428436474,
121
- 2756734187,
122
- 3204031479,
123
- 3329325298
124
- ];
125
- function sha256Hex(input) {
126
- const bytes = utf8Bytes(input);
127
- const bitLength = bytes.length * 8;
128
- bytes.push(128);
129
- while (bytes.length % 64 !== 56) {
130
- bytes.push(0);
131
- }
132
- for (let shift = 56; shift >= 0; shift -= 8) {
133
- bytes.push(Math.floor(bitLength / 2 ** shift) & 255);
134
- }
135
- let h0 = 1779033703;
136
- let h1 = 3144134277;
137
- let h2 = 1013904242;
138
- let h3 = 2773480762;
139
- let h4 = 1359893119;
140
- let h5 = 2600822924;
141
- let h6 = 528734635;
142
- let h7 = 1541459225;
143
- const words = new Array(64);
144
- for (let offset = 0; offset < bytes.length; offset += 64) {
145
- for (let i = 0; i < 16; i += 1) {
146
- const index = offset + i * 4;
147
- words[i] = (bytes[index] ?? 0) << 24 | (bytes[index + 1] ?? 0) << 16 | (bytes[index + 2] ?? 0) << 8 | (bytes[index + 3] ?? 0);
148
- }
149
- for (let i = 16; i < 64; i += 1) {
150
- const s0 = rightRotate(words[i - 15] ?? 0, 7) ^ rightRotate(words[i - 15] ?? 0, 18) ^ (words[i - 15] ?? 0) >>> 3;
151
- const s1 = rightRotate(words[i - 2] ?? 0, 17) ^ rightRotate(words[i - 2] ?? 0, 19) ^ (words[i - 2] ?? 0) >>> 10;
152
- words[i] = (words[i - 16] ?? 0) + s0 + (words[i - 7] ?? 0) + s1 >>> 0;
153
- }
154
- let a = h0;
155
- let b = h1;
156
- let c = h2;
157
- let d = h3;
158
- let e = h4;
159
- let f = h5;
160
- let g = h6;
161
- let h = h7;
162
- for (let i = 0; i < 64; i += 1) {
163
- const s1 = rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25);
164
- const ch = e & f ^ ~e & g;
165
- const temp1 = h + s1 + ch + (SHA256_K[i] ?? 0) + (words[i] ?? 0) >>> 0;
166
- const s0 = rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22);
167
- const maj = a & b ^ a & c ^ b & c;
168
- const temp2 = s0 + maj >>> 0;
169
- h = g;
170
- g = f;
171
- f = e;
172
- e = d + temp1 >>> 0;
173
- d = c;
174
- c = b;
175
- b = a;
176
- a = temp1 + temp2 >>> 0;
177
- }
178
- h0 = h0 + a >>> 0;
179
- h1 = h1 + b >>> 0;
180
- h2 = h2 + c >>> 0;
181
- h3 = h3 + d >>> 0;
182
- h4 = h4 + e >>> 0;
183
- h5 = h5 + f >>> 0;
184
- h6 = h6 + g >>> 0;
185
- h7 = h7 + h >>> 0;
186
- }
187
- return [h0, h1, h2, h3, h4, h5, h6, h7].map((word) => word.toString(16).padStart(8, "0")).join("");
188
- }
189
- function rightRotate(value, bits) {
190
- return value >>> bits | value << 32 - bits;
191
- }
192
- function utf8Bytes(input) {
193
- const bytes = [];
194
- for (let i = 0; i < input.length; i += 1) {
195
- const code = input.charCodeAt(i);
196
- if (code < 128) {
197
- bytes.push(code);
198
- } else if (code < 2048) {
199
- bytes.push(192 | code >> 6, 128 | code & 63);
200
- } else if (code >= 55296 && code <= 56319) {
201
- const next = input.charCodeAt(i += 1);
202
- const point = 65536 + ((code & 1023) << 10 | next & 1023);
203
- bytes.push(
204
- 240 | point >> 18,
205
- 128 | point >> 12 & 63,
206
- 128 | point >> 6 & 63,
207
- 128 | point & 63
208
- );
209
- } else {
210
- bytes.push(
211
- 224 | code >> 12,
212
- 128 | code >> 6 & 63,
213
- 128 | code & 63
214
- );
215
- }
216
- }
217
- return bytes;
218
- }
219
- function computePluginActionSetVersion(input) {
220
- return digestPluginRuntimeJson({
221
- digestVersion: "plugin-action-set@3",
222
- gameVersion: input.gameVersion,
223
- availableInteractions: input.availableInteractions
224
- });
225
- }
226
- function digestPluginGameplayFrame(frame) {
227
- return digestPluginRuntimeJson({
228
- digestVersion: "plugin-gameplay-frame@3",
229
- frame
230
- });
231
- }
232
-
233
- // ../plugin-runtime-contract/dist/chunk-E4Y6SAWF.js
234
- import { z } from "zod";
235
- var DREAMBOARD_PLUGIN_PROTOCOL = "dreamboard-plugin";
236
- var DREAMBOARD_PLUGIN_PROTOCOL_VERSION = 3;
237
- var RuntimeJsonSchema = z.lazy(
238
- () => z.union([
239
- z.null(),
240
- z.boolean(),
241
- z.number().finite(),
242
- z.string(),
243
- z.array(RuntimeJsonSchema),
244
- z.record(z.string(), RuntimeJsonSchema)
245
- ])
246
- );
247
- var BoardStaticProjectionSchema = z.object({
248
- view: RuntimeJsonSchema,
249
- hash: z.string().optional(),
250
- manifestVersion: z.string().optional()
251
- }).strict();
252
- var SetupGuidanceStepSchema = z.object({
253
- id: z.string().min(1),
254
- label: z.string().min(1),
255
- description: z.string().optional()
256
- }).strict();
257
- var GameGuidanceProjectionSchema = z.object({
258
- phase: z.object({
259
- id: z.string().min(1),
260
- label: z.string().min(1),
261
- summary: z.string().optional(),
262
- objective: z.string().optional()
263
- }).strict(),
264
- setup: z.object({
265
- profileId: z.string().min(1),
266
- name: z.string().min(1),
267
- summary: z.string().optional(),
268
- steps: z.array(SetupGuidanceStepSchema)
269
- }).strict().optional()
270
- }).strict();
271
- var GameEventDetailSchema = z.object({
272
- label: z.string().min(1),
273
- value: z.union([z.string(), z.number().finite(), z.boolean()])
274
- }).strict();
275
- var SystemActionEventSchema = z.object({
276
- kind: z.literal("systemAction"),
277
- procedureId: z.string().min(1),
278
- title: z.string().min(1),
279
- summary: z.string().optional(),
280
- details: z.array(GameEventDetailSchema).optional()
281
- }).strict();
282
- var GameEventSchema = z.discriminatedUnion("kind", [
283
- SystemActionEventSchema
284
- ]);
285
- var ProjectedGameEventSchema = GameEventSchema.and(
286
- z.object({
287
- version: z.number().int().nonnegative(),
288
- index: z.number().int().nonnegative()
289
- }).strict()
290
- );
291
- var SeatProjectionBundleSchema = z.object({
292
- currentStage: z.string().nullable().optional(),
293
- stageSeats: z.array(z.string()).optional(),
294
- simultaneousPhase: z.unknown().nullable().optional(),
295
- guidance: GameGuidanceProjectionSchema.nullable().optional(),
296
- recentEvents: z.array(ProjectedGameEventSchema).optional(),
297
- interactionsByRef: z.record(z.string(), z.unknown()).optional(),
298
- seats: z.record(
299
- z.string(),
300
- z.object({
301
- view: z.unknown().optional(),
302
- availableInteractionRefs: z.array(z.string()).optional(),
303
- zones: z.unknown().optional()
304
- }).strict()
305
- )
306
- }).strict();
307
- var PlayerIdSchema = z.string().min(1);
308
- var PluginPlayerSummarySchema = z.object({
309
- playerId: PlayerIdSchema,
310
- displayName: z.string(),
311
- color: z.string().optional()
312
- }).strict();
313
- var PluginSessionDescriptorSchema = z.object({
314
- sessionId: z.string().min(1),
315
- players: z.array(PluginPlayerSummarySchema)
316
- }).strict();
317
- var InteractionCommitPolicySchema = z.discriminatedUnion("mode", [
318
- z.object({ mode: z.literal("manual") }).strict(),
319
- z.object({ mode: z.literal("autoWhenReady") }).strict()
320
- ]);
321
- var InputSelectionSchema = z.discriminatedUnion("mode", [
322
- z.object({ mode: z.literal("single") }).strict(),
323
- z.object({
324
- mode: z.literal("many"),
325
- min: z.number().int(),
326
- max: z.number().int().optional(),
327
- distinct: z.boolean().optional()
328
- }).strict()
329
- ]);
330
- var InputDomainDependencyCaseSchema = z.lazy(
331
- () => z.object({
332
- when: z.record(z.string(), z.string()),
333
- domain: InputDomainSchema
334
- }).strict()
335
- );
336
- var InputDomainDependenciesSchema = z.discriminatedUnion("mode", [
337
- z.object({
338
- mode: z.literal("eager"),
339
- dependentCases: z.array(InputDomainDependencyCaseSchema)
340
- }).strict(),
341
- z.object({
342
- mode: z.literal("lazy"),
343
- dependsOn: z.array(z.string()),
344
- resolver: z.object({
345
- interactionKey: z.string().optional(),
346
- inputKey: z.string()
347
- }).strict()
348
- }).strict()
349
- ]);
350
- var InputDomainSchema = z.object({
351
- type: z.string(),
352
- selection: InputSelectionSchema.optional(),
353
- dependencies: InputDomainDependenciesSchema.optional()
354
- }).catchall(RuntimeJsonSchema);
355
- var InteractionChoiceOptionSchema = z.object({
356
- value: z.string().nullable(),
357
- label: z.string(),
358
- icon: z.string().optional(),
359
- badge: z.string().optional(),
360
- description: z.string().optional(),
361
- disabled: z.boolean().optional(),
362
- disabledReason: z.string().optional()
363
- }).strict();
364
- var InteractionInputDescriptorSchema = z.object({
365
- key: z.string().min(1),
366
- kind: z.string().min(1),
367
- domain: InputDomainSchema,
368
- defaultValue: RuntimeJsonSchema.optional()
369
- }).strict();
370
- var InteractionAvailabilitySchema = z.discriminatedUnion("status", [
371
- z.object({ status: z.literal("available") }).strict(),
372
- z.object({ status: z.literal("notYourTurn"), reason: z.string() }).strict(),
373
- z.object({
374
- status: z.literal("insufficientResources"),
375
- reason: z.string(),
376
- missingResources: z.record(z.string(), z.number().finite())
377
- }).strict(),
378
- z.object({
379
- status: z.literal("blocked"),
380
- reason: z.string(),
381
- code: z.string().optional()
382
- }).strict()
383
- ]);
384
- var InteractionBaseSchema = z.object({
385
- phaseName: z.string().min(1),
386
- interactionKey: z.string().min(1),
387
- interactionId: z.string().min(1),
388
- label: z.string().min(1),
389
- help: z.string().optional(),
390
- zoneId: z.string().optional(),
391
- zoneIds: z.array(z.string()).optional(),
392
- commit: InteractionCommitPolicySchema,
393
- descriptorDigest: z.string().optional(),
394
- actorSeat: z.number().int().optional(),
395
- draftDigest: z.string().optional(),
396
- inputs: z.array(InteractionInputDescriptorSchema),
397
- cost: z.record(z.string(), RuntimeJsonSchema).optional(),
398
- currentResources: z.record(z.string(), RuntimeJsonSchema).optional(),
399
- availability: InteractionAvailabilitySchema,
400
- reasons: z.array(
401
- z.object({
402
- ruleId: z.string(),
403
- errorCode: z.string()
404
- }).strict()
405
- ).optional()
406
- }).strict();
407
- var InteractionContextSchema = z.object({
408
- to: z.string().min(1),
409
- title: z.string().optional(),
410
- payload: z.record(z.string(), RuntimeJsonSchema).optional(),
411
- options: z.array(
412
- z.object({
413
- id: z.string(),
414
- label: z.string().optional()
415
- }).strict()
416
- ).optional()
417
- }).strict();
418
- var InteractionDescriptorSchema = z.discriminatedUnion("kind", [
419
- InteractionBaseSchema.extend({ kind: z.literal("action") }).strict(),
420
- InteractionBaseSchema.extend({
421
- kind: z.literal("prompt"),
422
- context: InteractionContextSchema
423
- }).strict()
424
- ]);
425
- var ZoneHandlesSnapshotSchema = z.object({
426
- cardIds: z.array(z.string()),
427
- cardViewsById: z.record(z.string(), z.string()),
428
- playableByCardId: z.record(
429
- z.string(),
430
- z.array(InteractionDescriptorSchema)
431
- )
432
- }).strict();
433
- var SimultaneousPhaseSnapshotSchema = z.object({
434
- phaseName: z.string().min(1),
435
- interactionId: z.string().min(1),
436
- actorIds: z.array(PlayerIdSchema),
437
- sealedPlayerIds: z.array(PlayerIdSchema),
438
- pendingPlayerIds: z.array(PlayerIdSchema)
439
- }).strict();
440
- var PluginGameplayFrameSchema = z.object({
441
- gameVersion: z.number().int().nonnegative(),
442
- actionSetVersion: z.string().min(1),
443
- perspectivePlayerId: PlayerIdSchema.nullable(),
444
- view: RuntimeJsonSchema.nullable(),
445
- flow: z.object({
446
- currentPhase: z.string().nullable(),
447
- currentStage: z.string().nullable(),
448
- activePlayers: z.array(PlayerIdSchema),
449
- simultaneousPhase: SimultaneousPhaseSnapshotSchema.nullable()
450
- }).strict(),
451
- availableInteractions: z.array(InteractionDescriptorSchema),
452
- guidance: GameGuidanceProjectionSchema.nullable().optional(),
453
- recentEvents: z.array(ProjectedGameEventSchema),
454
- zones: z.record(z.string(), ZoneHandlesSnapshotSchema)
455
- }).strict();
456
- var ValidationResultSchema = z.object({
457
- valid: z.boolean(),
458
- errorCode: z.string().optional(),
459
- message: z.string().optional()
460
- }).strict();
461
- var SubmissionResultSchema = z.discriminatedUnion("accepted", [
462
- z.object({ accepted: z.literal(true) }).strict(),
463
- z.object({
464
- accepted: z.literal(false),
465
- errorCode: z.string().min(1),
466
- message: z.string().optional()
467
- }).strict()
468
- ]);
469
- var PluginInteractionBasisSchema = z.object({
470
- gameVersion: z.number().int().nonnegative(),
471
- actionSetVersion: z.string().min(1),
472
- perspectivePlayerId: PlayerIdSchema.nullable()
473
- }).strict();
474
- var ValidateInteractionCommandSchema = z.object({
475
- type: z.literal("interaction.validate"),
476
- requestId: z.string().min(1),
477
- basis: PluginInteractionBasisSchema,
478
- interactionId: z.string().min(1),
479
- params: RuntimeJsonSchema
480
- }).strict();
481
- var SubmitInteractionCommandSchema = z.object({
482
- type: z.literal("interaction.submit"),
483
- requestId: z.string().min(1),
484
- basis: PluginInteractionBasisSchema,
485
- interactionId: z.string().min(1),
486
- params: RuntimeJsonSchema
487
- }).strict();
488
- var HostToPluginPayloadSchema = z.discriminatedUnion("type", [
489
- z.object({
490
- type: z.literal("runtime.init"),
491
- session: PluginSessionDescriptorSchema
492
- }).strict(),
493
- z.object({
494
- type: z.literal("gameplay.frame"),
495
- frame: PluginGameplayFrameSchema
496
- }).strict(),
497
- z.object({
498
- type: z.literal("interaction.validation-result"),
499
- requestId: z.string().min(1),
500
- result: ValidationResultSchema
501
- }).strict(),
502
- z.object({
503
- type: z.literal("interaction.submit-result"),
504
- requestId: z.string().min(1),
505
- result: SubmissionResultSchema
506
- }).strict()
507
- ]);
508
- var PluginToHostPayloadSchema = z.discriminatedUnion("type", [
509
- z.object({ type: z.literal("runtime.ready") }).strict(),
510
- z.object({
511
- type: z.literal("runtime.ack"),
512
- sequence: z.number().int().nonnegative(),
513
- clientReceivedAtMs: z.number().finite().optional(),
514
- clientRenderedAtMs: z.number().finite().optional()
515
- }).strict(),
516
- ValidateInteractionCommandSchema,
517
- SubmitInteractionCommandSchema,
518
- z.object({
519
- type: z.literal("runtime.error"),
520
- message: z.string(),
521
- code: z.string().optional()
522
- }).strict()
523
- ]);
524
- function createPluginProtocolEnvelopeSchema(payloadSchema) {
525
- return z.object({
526
- protocol: z.literal(DREAMBOARD_PLUGIN_PROTOCOL),
527
- version: z.literal(DREAMBOARD_PLUGIN_PROTOCOL_VERSION),
528
- channelId: z.string().min(1),
529
- sequence: z.number().int().nonnegative(),
530
- payload: payloadSchema
531
- }).strict();
532
- }
533
- var HostToPluginEnvelopeSchema = createPluginProtocolEnvelopeSchema(
534
- HostToPluginPayloadSchema
535
- );
536
- var PluginToHostEnvelopeSchema = createPluginProtocolEnvelopeSchema(
537
- PluginToHostPayloadSchema
538
- );
539
- var PluginProtocolFrameSchema = z.object({
540
- id: z.string().min(1),
541
- frame: PluginGameplayFrameSchema,
542
- projectionDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/)
543
- }).strict();
544
- var PluginProtocolStepSchema = z.discriminatedUnion("kind", [
545
- z.object({
546
- id: z.string().min(1),
547
- kind: z.literal("host.frame"),
548
- frameId: z.string().min(1)
549
- }).strict(),
550
- z.object({
551
- id: z.string().min(1),
552
- kind: z.literal("client.validate"),
553
- fromFrameId: z.string().min(1),
554
- requestDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),
555
- response: ValidationResultSchema
556
- }).strict(),
557
- z.object({
558
- id: z.string().min(1),
559
- kind: z.literal("client.submit"),
560
- fromFrameId: z.string().min(1),
561
- requestDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),
562
- response: SubmissionResultSchema
563
- }).strict()
564
- ]);
565
- var PluginProtocolTapeSchema = z.object({
566
- session: PluginSessionDescriptorSchema,
567
- frames: z.array(PluginProtocolFrameSchema),
568
- steps: z.array(PluginProtocolStepSchema)
569
- }).strict();
570
-
571
- // ../plugin-runtime-contract/dist/index.js
572
- function materializePluginGameplayFrame(input) {
573
- const dynamicProjection = SeatProjectionBundleSchema.parse(
574
- input.dynamicProjection
575
- );
576
- const staticProjection = input.staticProjection == null ? null : BoardStaticProjectionSchema.parse(
577
- input.staticProjection
578
- );
579
- const registry = parseInteractionRegistry(
580
- dynamicProjection.interactionsByRef
581
- );
582
- const seat = input.perspectivePlayerId == null ? null : dynamicProjection.seats[input.perspectivePlayerId] ?? null;
583
- const availableInteractions = seat == null ? [] : hydrateInteractionRefs(
584
- registry,
585
- seat.availableInteractionRefs,
586
- "availableInteractionRefs"
587
- );
588
- const zones = seat?.zones == null ? {} : hydrateZones(registry, seat.zones, "zones");
589
- const frame = {
590
- gameVersion: input.gameVersion,
591
- actionSetVersion: input.actionSetVersion,
592
- perspectivePlayerId: input.perspectivePlayerId,
593
- view: composeProjectionView(staticProjection, seat?.view),
594
- flow: {
595
- currentPhase: input.currentPhase,
596
- currentStage: dynamicProjection.currentStage ?? null,
597
- activePlayers: [...input.activePlayers],
598
- simultaneousPhase: dynamicProjection.simultaneousPhase ?? null
599
- },
600
- availableInteractions,
601
- guidance: dynamicProjection.guidance ?? null,
602
- recentEvents: [...dynamicProjection.recentEvents ?? []],
603
- zones
604
- };
605
- return PluginGameplayFrameSchema.parse(frame);
606
- }
607
- function parseInteractionRegistry(value) {
608
- if (value == null) return {};
609
- if (!isRecord(value)) {
610
- throw new Error("Seat projection interactionsByRef must be an object.");
611
- }
612
- return Object.fromEntries(
613
- Object.entries(value).map(([ref, descriptor]) => [
614
- ref,
615
- InteractionDescriptorSchema.parse(descriptor)
616
- ])
617
- );
618
- }
619
- function hydrateZones(registry, value, path) {
620
- if (!isRecord(value)) {
621
- throw new Error(`Seat projection ${path} must be an object.`);
622
- }
623
- return Object.fromEntries(
624
- Object.entries(value).map(([zoneId, zoneValue]) => [
625
- zoneId,
626
- hydrateZone(registry, zoneValue, `${path}.${zoneId}`)
627
- ])
628
- );
629
- }
630
- function hydrateZone(registry, value, path) {
631
- if (!isRecord(value)) {
632
- throw new Error(`Seat projection ${path} must be an object.`);
633
- }
634
- const cardIds = arrayOfStrings(value.cardIds, `${path}.cardIds`);
635
- const cardViewsById = stringRecord(
636
- value.cardViewsById,
637
- `${path}.cardViewsById`
638
- );
639
- if (!isRecord(value.playableByCardId)) {
640
- throw new Error(
641
- `Seat projection ${path}.playableByCardId must be an object.`
642
- );
643
- }
644
- const playableByCardId = Object.fromEntries(
645
- Object.entries(value.playableByCardId).map(([cardId, refs]) => [
646
- cardId,
647
- hydrateInteractionRefs(
648
- registry,
649
- refs,
650
- `${path}.playableByCardId.${cardId}`
651
- )
652
- ])
653
- );
654
- return ZoneHandlesSnapshotSchema.parse({
655
- cardIds,
656
- cardViewsById,
657
- playableByCardId
658
- });
659
- }
660
- function hydrateInteractionRefs(registry, value, path) {
661
- if (!Array.isArray(value)) {
662
- throw new Error(`Seat projection ${path} must be an array of refs.`);
663
- }
664
- return value.map((ref, index) => {
665
- if (typeof ref !== "string") {
666
- throw new Error(
667
- `Seat projection ${path}[${index}] must be a ref string.`
668
- );
669
- }
670
- const descriptor = registry[ref];
671
- if (!descriptor) {
672
- throw new Error(
673
- `Seat projection ${path}[${index}] references '${ref}', which is missing from interactionsByRef.`
674
- );
675
- }
676
- return descriptor;
677
- });
678
- }
679
- function composeProjectionView(staticProjection, dynamicView) {
680
- const normalizedDynamicView = dynamicView === void 0 ? null : dynamicView;
681
- if (staticProjection == null) {
682
- return normalizedDynamicView;
683
- }
684
- if (normalizedDynamicView == null) {
685
- return staticProjection.view;
686
- }
687
- if (isRecord(staticProjection.view) && isRecord(normalizedDynamicView)) {
688
- return {
689
- ...staticProjection.view,
690
- ...normalizedDynamicView
691
- };
692
- }
693
- return {
694
- static: staticProjection.view,
695
- dynamic: normalizedDynamicView
696
- };
697
- }
698
- function arrayOfStrings(value, path) {
699
- if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
700
- throw new Error(`Seat projection ${path} must be an array of strings.`);
701
- }
702
- return value;
703
- }
704
- function stringRecord(value, path) {
705
- if (!isRecord(value)) {
706
- throw new Error(`Seat projection ${path} must be an object.`);
707
- }
708
- const result = {};
709
- for (const [key, item] of Object.entries(value)) {
710
- if (typeof item !== "string") {
711
- throw new Error(`Seat projection ${path}.${key} must be a string.`);
712
- }
713
- result[key] = item;
714
- }
715
- return result;
716
- }
717
- function isRecord(value) {
718
- return value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
719
- }
720
-
721
- // src/runtime/context/PluginGameplayFrameContext.tsx
722
- import {
723
- createContext,
724
- useContext,
725
- useMemo as useMemo2,
726
- useSyncExternalStore as useSyncExternalStore2
727
- } from "react";
728
-
729
- // src/runtime/hooks/useRuntimeSnapshotSelector.ts
730
- import { useCallback, useMemo, useSyncExternalStore } from "react";
731
- function defaultRuntimeSnapshotEquality(left, right) {
732
- return Object.is(left, right);
733
- }
734
- function useRuntimeSnapshotSelector(subscribe, getSnapshot, getServerSnapshot, selector, equalityFn = defaultRuntimeSnapshotEquality) {
735
- const cache = useMemo(
736
- () => ({ current: null, selector, equalityFn }),
737
- [equalityFn, selector]
738
- );
739
- const getSelectedFromSnapshot = useCallback(
740
- (snapshot) => {
741
- const cached = cache.current;
742
- if (cached && cached.snapshot === snapshot) {
743
- return cached.selection;
744
- }
745
- const nextSelection = selector(snapshot);
746
- if (cached && equalityFn(cached.selection, nextSelection)) {
747
- cache.current = {
748
- snapshot,
749
- selection: cached.selection
750
- };
751
- return cached.selection;
752
- }
753
- cache.current = {
754
- snapshot,
755
- selection: nextSelection
756
- };
757
- return nextSelection;
758
- },
759
- [cache, equalityFn, selector]
760
- );
761
- const getSelectedSnapshot = useCallback(
762
- () => getSelectedFromSnapshot(getSnapshot()),
763
- [getSelectedFromSnapshot, getSnapshot]
764
- );
765
- const getSelectedServerSnapshot = useCallback(
766
- () => selector(getServerSnapshot()),
767
- [getServerSnapshot, selector]
768
- );
769
- const subscribeSelected = useCallback(
770
- (onStoreChange) => subscribe(() => {
771
- const previous = cache.current;
772
- const nextSelection = getSelectedSnapshot();
773
- if (!previous || !equalityFn(previous.selection, nextSelection)) {
774
- onStoreChange();
775
- }
776
- }),
777
- [cache, equalityFn, getSelectedSnapshot, subscribe]
778
- );
779
- return useSyncExternalStore(
780
- subscribeSelected,
781
- getSelectedSnapshot,
782
- getSelectedServerSnapshot
783
- );
784
- }
785
-
786
- // src/runtime/context/PluginGameplayFrameContext.tsx
787
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
788
- var PluginGameplayFrameStoreContext = createContext(null);
789
- var PluginGameplayFrameContext = createContext(
790
- null
791
- );
792
- function DefaultLoadingScreen() {
793
- return /* @__PURE__ */ jsx(
794
- "div",
795
- {
796
- style: {
797
- display: "flex",
798
- alignItems: "center",
799
- justifyContent: "center",
800
- height: "100%",
801
- width: "100%",
802
- color: "#666"
803
- },
804
- children: /* @__PURE__ */ jsxs("div", { style: { textAlign: "center" }, children: [
805
- /* @__PURE__ */ jsx(
806
- "div",
807
- {
808
- style: {
809
- width: "40px",
810
- height: "40px",
811
- border: "3px solid #e0e0e0",
812
- borderTopColor: "#666",
813
- borderRadius: "50%",
814
- animation: "spin 1s linear infinite",
815
- margin: "0 auto 12px"
816
- }
817
- }
818
- ),
819
- /* @__PURE__ */ jsx("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` }),
820
- /* @__PURE__ */ jsx("p", { children: "Loading game view..." })
821
- ] })
822
- }
823
- );
824
- }
825
- function PluginGameplayFrameProvider({
826
- runtime,
827
- children,
828
- loadingComponent = /* @__PURE__ */ jsx(DefaultLoadingScreen, {})
829
- }) {
830
- const storeApi = useMemo2(() => {
831
- let current = runtime.getFrame();
832
- return {
833
- subscribe: (onStoreChange) => runtime.subscribeFrame(() => {
834
- current = runtime.getFrame();
835
- onStoreChange();
836
- }),
837
- getSnapshot: () => current,
838
- getServerSnapshot: () => current
839
- };
840
- }, [runtime]);
841
- return /* @__PURE__ */ jsx(
842
- PluginGameplayFrameStoreProvider,
843
- {
844
- store: storeApi,
845
- loadingComponent,
846
- children
847
- }
848
- );
849
- }
850
- function PluginGameplayFrameStoreProvider({
851
- store,
852
- children,
853
- loadingComponent
854
- }) {
855
- const frame = useSyncExternalStore2(
856
- store.subscribe,
857
- store.getSnapshot,
858
- store.getServerSnapshot
859
- );
860
- if (!frame) {
861
- return /* @__PURE__ */ jsx(Fragment, { children: loadingComponent });
862
- }
863
- return /* @__PURE__ */ jsx(PluginGameplayFrameStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxs(PluginGameplayFrameContext.Provider, { value: frame, children: [
864
- /* @__PURE__ */ jsx(SemanticGameplayFrameMarker, { frame }),
865
- children
866
- ] }) });
867
- }
868
- function usePluginGameplayFrameSelector(selector, equalityFn = defaultRuntimeSnapshotEquality) {
869
- const store = useContext(PluginGameplayFrameStoreContext);
870
- if (!store) {
871
- throw new Error(
872
- "usePluginGameplayFrameSelector must be used within PluginGameplayFrameProvider."
873
- );
874
- }
875
- return useRuntimeSnapshotSelector(
876
- store.subscribe,
877
- store.getSnapshot,
878
- store.getServerSnapshot,
879
- (frame) => selector(requirePluginGameplayFrame(frame)),
880
- equalityFn
881
- );
882
- }
883
- function useAuthoredPluginGameplayFrameSelector(selector, equalityFn = defaultRuntimeSnapshotEquality) {
884
- return usePluginGameplayFrameSelector(
885
- (frame) => selector(frame),
886
- equalityFn
887
- );
888
- }
889
- function requirePluginGameplayFrame(frame) {
890
- if (!frame) {
891
- throw new Error("Plugin gameplay frame is not available.");
892
- }
893
- return frame;
894
- }
895
- var GAMEPLAY_BROWSER_SCOPE_ID = "runtime";
896
- var BROWSER_PROJECTION_DIGEST_ATTRIBUTE = "data-dreamboard-projection-digest";
897
- function SemanticGameplayFrameMarker({
898
- frame
899
- }) {
900
- const digest = digestPluginGameplayFrame(frame);
901
- return /* @__PURE__ */ jsx(
902
- "span",
903
- {
904
- "aria-hidden": "true",
905
- style: { display: "none" },
906
- ...{
907
- [BROWSER_INTERACTION_ATTRIBUTES.protocol]: DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION,
908
- [BROWSER_INTERACTION_ATTRIBUTES.surface]: GAMEPLAY_BROWSER_INTERACTION_SURFACE,
909
- [BROWSER_INTERACTION_ATTRIBUTES.scope]: GAMEPLAY_BROWSER_SCOPE_ID,
910
- [BROWSER_INTERACTION_ATTRIBUTES.role]: "projection",
911
- [BROWSER_PROJECTION_DIGEST_ATTRIBUTE]: digest
912
- }
913
- }
914
- );
915
- }
916
-
917
- // src/runtime/context/InteractionDraftContext.tsx
918
- import { createContext as createContext2, useContext as useContext2, useMemo as useMemo3 } from "react";
919
- import { useStore } from "zustand";
920
- import { createStore } from "zustand/vanilla";
921
- import { useShallow } from "zustand/shallow";
922
- import { jsx as jsx2 } from "react/jsx-runtime";
923
- var EMPTY_DRAFT = Object.freeze({});
924
- function omitRecordKey(record, key) {
925
- const next = { ...record };
926
- delete next[key];
927
- return next;
928
- }
929
- function createInteractionUiStore() {
930
- const store = createStore()(() => ({
931
- drafts: {},
932
- arms: {},
933
- submitting: {},
934
- pendingInteractionKey: null,
935
- pendingInteractionRevision: 0
936
- }));
937
- const api = {
938
- getDraft(interactionId) {
939
- return store.getState().drafts[interactionId] ?? EMPTY_DRAFT;
940
- },
941
- setInput(interactionId, key, value) {
942
- store.setState((prev) => {
943
- const current = prev.drafts[interactionId];
944
- if (current && current[key] === value) return prev;
945
- return {
946
- ...prev,
947
- drafts: {
948
- ...prev.drafts,
949
- [interactionId]: { ...current ?? {}, [key]: value }
950
- }
951
- };
952
- });
953
- },
954
- clearInput(interactionId, key) {
955
- store.setState((prev) => {
956
- const current = prev.drafts[interactionId];
957
- if (!current) return prev;
958
- if (key === void 0) {
959
- return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };
960
- }
961
- if (!(key in current)) return prev;
962
- const remainingKeys = omitRecordKey(current, key);
963
- if (Object.keys(remainingKeys).length === 0) {
964
- return { ...prev, drafts: omitRecordKey(prev.drafts, interactionId) };
965
- }
966
- return {
967
- ...prev,
968
- drafts: { ...prev.drafts, [interactionId]: remainingKeys }
969
- };
970
- });
971
- },
972
- clearAll() {
973
- store.setState((prev) => {
974
- if (Object.keys(prev.drafts).length === 0 && Object.keys(prev.arms).length === 0 && Object.keys(prev.submitting).length === 0 && prev.pendingInteractionKey === null) {
975
- return prev;
976
- }
977
- return {
978
- drafts: {},
979
- arms: {},
980
- submitting: {},
981
- pendingInteractionKey: null,
982
- pendingInteractionRevision: prev.pendingInteractionRevision + 1
983
- };
984
- });
985
- },
986
- getArmed(surface) {
987
- return store.getState().arms[surface] ?? null;
988
- },
989
- arm(surface, interactionId) {
990
- store.setState((prev) => {
991
- const current = prev.arms[surface] ?? null;
992
- if (current === interactionId) return prev;
993
- if (interactionId === null) {
994
- return { ...prev, arms: omitRecordKey(prev.arms, surface) };
995
- }
996
- return { ...prev, arms: { ...prev.arms, [surface]: interactionId } };
997
- });
998
- },
999
- getPendingInteraction() {
1000
- return store.getState().pendingInteractionKey;
1001
- },
1002
- setPendingInteraction(interactionId) {
1003
- store.setState((prev) => {
1004
- if (prev.pendingInteractionKey === interactionId) {
1005
- return interactionId === null ? prev : {
1006
- ...prev,
1007
- pendingInteractionRevision: prev.pendingInteractionRevision + 1
1008
- };
1009
- }
1010
- return {
1011
- ...prev,
1012
- pendingInteractionKey: interactionId,
1013
- pendingInteractionRevision: prev.pendingInteractionRevision + 1
1014
- };
1015
- });
1016
- },
1017
- getPendingInteractionRevision() {
1018
- return store.getState().pendingInteractionRevision;
1019
- },
1020
- isSubmitting(interactionId) {
1021
- return store.getState().submitting[interactionId] === true;
1022
- },
1023
- claimSubmitting(interactionId) {
1024
- let claimed = false;
1025
- store.setState((prev) => {
1026
- if (prev.submitting[interactionId] === true) return prev;
1027
- claimed = true;
1028
- return {
1029
- ...prev,
1030
- submitting: { ...prev.submitting, [interactionId]: true }
1031
- };
1032
- });
1033
- return claimed;
1034
- },
1035
- setSubmitting(interactionId, submitting) {
1036
- store.setState((prev) => {
1037
- const current = prev.submitting[interactionId] === true;
1038
- if (current === submitting) return prev;
1039
- if (!submitting) {
1040
- return {
1041
- ...prev,
1042
- submitting: omitRecordKey(prev.submitting, interactionId)
1043
- };
1044
- }
1045
- return {
1046
- ...prev,
1047
- submitting: { ...prev.submitting, [interactionId]: true }
1048
- };
1049
- });
1050
- }
1051
- };
1052
- return Object.assign(store, api);
1053
- }
1054
- var InteractionUiCtx = createContext2(null);
1055
- function InteractionUiProvider({
1056
- children,
1057
- store
1058
- }) {
1059
- const ownedStore = useMemo3(() => createInteractionUiStore(), []);
1060
- return /* @__PURE__ */ jsx2(InteractionUiCtx.Provider, { value: store ?? ownedStore, children });
1061
- }
1062
- function useInteractionUiStore() {
1063
- const ctx = useContext2(InteractionUiCtx);
1064
- const fallback = useMemo3(() => createInteractionUiStore(), []);
1065
- return ctx ?? fallback;
1066
- }
1067
- function useInteractionDraft(interactionId) {
1068
- const store = useInteractionUiStore();
1069
- useStore(
1070
- store,
1071
- useShallow(
1072
- (state) => state.drafts[interactionId] ?? EMPTY_DRAFT
1073
- )
1074
- );
1075
- return store.getDraft(interactionId);
1076
- }
1077
- function useArmedInteraction(surface) {
1078
- const store = useInteractionUiStore();
1079
- return useStore(store, (state) => state.arms[surface] ?? null);
1080
- }
1081
- function usePendingInteractionKey() {
1082
- const store = useInteractionUiStore();
1083
- const subscribed = useStore(
1084
- store,
1085
- (state) => state.pendingInteractionKey ?? null
1086
- );
1087
- return store.getPendingInteraction() ?? subscribed;
1088
- }
1089
- function usePendingInteractionRevision() {
1090
- const store = useInteractionUiStore();
1091
- const subscribed = useStore(
1092
- store,
1093
- (state) => state.pendingInteractionRevision
1094
- );
1095
- return Math.max(store.getPendingInteractionRevision(), subscribed);
1096
- }
1097
- function useInteractionSubmitting(interactionId) {
1098
- const store = useInteractionUiStore();
1099
- return useStore(
1100
- store,
1101
- (state) => state.submitting[interactionId] === true
1102
- );
1103
- }
1104
-
1105
- // src/runtime/context/PluginSessionContext.tsx
1106
- import {
1107
- createContext as createContext3,
1108
- useContext as useContext3,
1109
- useMemo as useMemo4,
1110
- useSyncExternalStore as useSyncExternalStore3
1111
- } from "react";
1112
- import { jsx as jsx3 } from "react/jsx-runtime";
1113
- var PluginSessionContext = createContext3(
1114
- null
1115
- );
1116
- var PluginSessionDescriptorContext = createContext3(null);
1117
- function sessionStateFromClient(runtime) {
1118
- const session = runtime.getSession();
1119
- const frame = runtime.getFrame();
1120
- return {
1121
- status: session ? "ready" : "loading",
1122
- sessionId: session?.sessionId ?? null,
1123
- controllingPlayerId: frame?.perspectivePlayerId ?? null
1124
- };
1125
- }
1126
- function pluginSessionStatesEqual(left, right) {
1127
- if (left.status !== right.status || left.sessionId !== right.sessionId || left.controllingPlayerId !== right.controllingPlayerId) {
1128
- return false;
1129
- }
1130
- return true;
1131
- }
1132
- function pluginSessionDescriptorsEqual(left, right) {
1133
- if (left === right) return true;
1134
- if (!left || !right) return false;
1135
- if (left.sessionId !== right.sessionId || left.players.length !== right.players.length) {
1136
- return false;
1137
- }
1138
- return left.players.every((player, index) => {
1139
- const next = right.players[index];
1140
- return player.playerId === next?.playerId && player.displayName === next.displayName && player.color === next.color;
1141
- });
1142
- }
1143
- function PluginSessionProvider({
1144
- runtime,
1145
- children
1146
- }) {
1147
- const sessionStore = useMemo4(() => {
1148
- let current = sessionStateFromClient(runtime);
1149
- return {
1150
- subscribe: (onStoreChange) => {
1151
- const refresh = () => {
1152
- const next = sessionStateFromClient(runtime);
1153
- if (pluginSessionStatesEqual(current, next)) {
1154
- return;
1155
- }
1156
- current = next;
1157
- onStoreChange();
1158
- };
1159
- const unsubscribeSession = runtime.subscribeSession(refresh);
1160
- const unsubscribeFrame = runtime.subscribeFrame(refresh);
1161
- return () => {
1162
- unsubscribeFrame();
1163
- unsubscribeSession();
1164
- };
1165
- },
1166
- getSnapshot: () => current,
1167
- getServerSnapshot: () => current
1168
- };
1169
- }, [runtime]);
1170
- const descriptorStore = useMemo4(() => {
1171
- let current = runtime.getSession();
1172
- return {
1173
- subscribe: (onStoreChange) => {
1174
- const refresh = () => {
1175
- const next = runtime.getSession();
1176
- if (pluginSessionDescriptorsEqual(current, next)) {
1177
- return;
1178
- }
1179
- current = next;
1180
- onStoreChange();
1181
- };
1182
- const unsubscribeSession = runtime.subscribeSession(refresh);
1183
- return () => {
1184
- unsubscribeSession();
1185
- };
1186
- },
1187
- getSnapshot: () => current,
1188
- getServerSnapshot: () => current
1189
- };
1190
- }, [runtime]);
1191
- const sessionState = useSyncExternalStore3(
1192
- sessionStore.subscribe,
1193
- sessionStore.getSnapshot,
1194
- sessionStore.getServerSnapshot
1195
- );
1196
- const sessionDescriptor = useSyncExternalStore3(
1197
- descriptorStore.subscribe,
1198
- descriptorStore.getSnapshot,
1199
- descriptorStore.getServerSnapshot
1200
- );
1201
- return /* @__PURE__ */ jsx3(PluginSessionContext.Provider, { value: sessionState, children: /* @__PURE__ */ jsx3(PluginSessionDescriptorContext.Provider, { value: sessionDescriptor, children }) });
1202
- }
1203
- function usePluginSession() {
1204
- const context = useContext3(PluginSessionContext);
1205
- if (context === null) {
1206
- throw new Error(
1207
- "usePluginSession must be used within a PluginSessionContext.Provider (provided by RuntimeContext)"
1208
- );
1209
- }
1210
- return context;
1211
- }
1212
- function useOptionalPluginSessionDescriptor() {
1213
- return useContext3(PluginSessionDescriptorContext);
1214
- }
1215
- function usePluginSessionDescriptor() {
1216
- const descriptor = useOptionalPluginSessionDescriptor();
1217
- if (!descriptor) {
1218
- throw new Error(
1219
- "usePluginSessionDescriptor must be used within PluginSessionProvider."
1220
- );
1221
- }
1222
- return descriptor;
1223
- }
1224
-
1225
- // src/runtime/context/RuntimeContext.tsx
1226
- import { createContext as createContext4, useContext as useContext4, useState, useEffect } from "react";
1227
- import { jsx as jsx4 } from "react/jsx-runtime";
1228
- var RuntimeContext = createContext4(null);
1229
- function useRuntimeContext() {
1230
- const context = useContext4(RuntimeContext);
1231
- if (!context) {
1232
- throw new Error(
1233
- "useRuntimeContext must be used within a RuntimeContext.Provider"
1234
- );
1235
- }
1236
- return context;
1237
- }
1238
-
1239
- export {
1240
- computePluginActionSetVersion,
1241
- DREAMBOARD_PLUGIN_PROTOCOL,
1242
- DREAMBOARD_PLUGIN_PROTOCOL_VERSION,
1243
- RuntimeJsonSchema,
1244
- HostToPluginEnvelopeSchema,
1245
- PluginProtocolFrameSchema,
1246
- PluginProtocolStepSchema,
1247
- PluginProtocolTapeSchema,
1248
- materializePluginGameplayFrame,
1249
- defaultRuntimeSnapshotEquality,
1250
- PluginGameplayFrameProvider,
1251
- usePluginGameplayFrameSelector,
1252
- useAuthoredPluginGameplayFrameSelector,
1253
- InteractionUiProvider,
1254
- useInteractionUiStore,
1255
- useInteractionDraft,
1256
- useArmedInteraction,
1257
- usePendingInteractionKey,
1258
- usePendingInteractionRevision,
1259
- useInteractionSubmitting,
1260
- PluginSessionProvider,
1261
- usePluginSession,
1262
- usePluginSessionDescriptor,
1263
- RuntimeContext,
1264
- useRuntimeContext
1265
- };
1266
- //# sourceMappingURL=chunk-UUQNOGZV.js.map