@dreamboard-games/sdk 0.4.0-alpha.0 → 0.4.0-alpha.2

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 (84) hide show
  1. package/README.md +8 -1
  2. package/REFERENCE.md +1849 -379
  3. package/dist/{ResourceCounter-BTXklCEZ.d.ts → ResourceCounter-BuiNstXs.d.ts} +5 -1
  4. package/dist/{ThemeProvider-DvMl17Ny.d.ts → ThemeProvider-B1sIoBlX.d.ts} +1 -1
  5. package/dist/attributes-DbvyMbXw.d.ts +68 -0
  6. package/dist/authoring/index.d.ts +66 -0
  7. package/dist/authoring/index.js +560 -0
  8. package/dist/authoring/index.js.map +1 -0
  9. package/dist/browser-interaction.d.ts +246 -44
  10. package/dist/browser-interaction.js +14 -1
  11. package/dist/{chunk-Q5O7GPVY.js → chunk-45FI6XII.js} +630 -375
  12. package/dist/chunk-45FI6XII.js.map +1 -0
  13. package/dist/{chunk-4G7552LO.js → chunk-6JQFGSLD.js} +216 -47
  14. package/dist/chunk-6JQFGSLD.js.map +1 -0
  15. package/dist/{chunk-NBAEEHAU.js → chunk-CP35NPPY.js} +5926 -5266
  16. package/dist/chunk-CP35NPPY.js.map +1 -0
  17. package/dist/{chunk-2LDZ5C3T.js → chunk-FWVV2X74.js} +2 -2
  18. package/dist/{chunk-MNKDSGIA.js → chunk-HWJS3VOJ.js} +6 -2
  19. package/dist/chunk-HWJS3VOJ.js.map +1 -0
  20. package/dist/chunk-K5ZRJTZZ.js +328 -0
  21. package/dist/chunk-K5ZRJTZZ.js.map +1 -0
  22. package/dist/{chunk-U5KBV2BA.js → chunk-N6ZDIMRB.js} +444 -223
  23. package/dist/chunk-N6ZDIMRB.js.map +1 -0
  24. package/dist/chunk-O6M6PN4E.js +1225 -0
  25. package/dist/chunk-O6M6PN4E.js.map +1 -0
  26. package/dist/chunk-PF7L4BMG.js +117 -0
  27. package/dist/chunk-PF7L4BMG.js.map +1 -0
  28. package/dist/{chunk-P7F4L2FF.js → chunk-WOWFONLZ.js} +609 -1287
  29. package/dist/chunk-WOWFONLZ.js.map +1 -0
  30. package/dist/{chunk-QLG6VEMW.js → chunk-WUIVY2KE.js} +318 -21
  31. package/dist/chunk-WUIVY2KE.js.map +1 -0
  32. package/dist/chunk-ZAS2SENW.js +12 -0
  33. package/dist/chunk-ZAS2SENW.js.map +1 -0
  34. package/dist/codegen.d.ts +11 -1
  35. package/dist/codegen.js +1 -1
  36. package/dist/{components-DaIqi9QM.d.ts → components-BbWPnZCF.d.ts} +37 -70
  37. package/dist/{hex-board-view-UCUjMALd.d.ts → hex-board-view-Kz9Q_zsv.d.ts} +1 -1
  38. package/dist/index.js +2 -1
  39. package/dist/package-set.d.ts +2 -2
  40. package/dist/package-set.js +2 -1
  41. package/dist/player-state-Cqpyeql0.d.ts +371 -0
  42. package/dist/protocol-BP193lva.d.ts +267 -0
  43. package/dist/reducer/advanced.d.ts +2 -2
  44. package/dist/reducer/advanced.js +1 -1
  45. package/dist/reducer-contract.js +1 -1
  46. package/dist/reducer.d.ts +7 -7
  47. package/dist/reducer.js +190 -183
  48. package/dist/reducer.js.map +1 -1
  49. package/dist/runtime/primitives.d.ts +10 -9
  50. package/dist/runtime/primitives.js +9 -6
  51. package/dist/runtime/runtime-api.d.ts +2 -2
  52. package/dist/runtime/workspace-contract.d.ts +28 -76
  53. package/dist/runtime/workspace-contract.js +7 -5
  54. package/dist/runtime-api-BJharVaj.d.ts +198 -0
  55. package/dist/runtime-api-C6aWo9c0.d.ts +95 -0
  56. package/dist/runtime-json-CQ9QbLZ5.d.ts +5 -0
  57. package/dist/runtime.d.ts +80 -11
  58. package/dist/runtime.js +89 -445
  59. package/dist/runtime.js.map +1 -1
  60. package/dist/testing.d.ts +643 -22
  61. package/dist/testing.js +1371 -76
  62. package/dist/testing.js.map +1 -1
  63. package/dist/types-CYeN0wLK.d.ts +29 -0
  64. package/dist/{attributes-BeRyboMS.d.ts → types-DJj5MJkl.d.ts} +32 -55
  65. package/dist/types.d.ts +14 -7
  66. package/dist/ui/components.d.ts +4 -5
  67. package/dist/ui/components.js +19 -1
  68. package/dist/ui/player-state.d.ts +2 -365
  69. package/dist/ui/plugin-styles.css +1 -1
  70. package/dist/{ui-contract-BUC6iS3s.d.ts → ui-contract-CY7cxsCC.d.ts} +17 -26
  71. package/dist/ui.d.ts +8 -13
  72. package/dist/ui.js +20 -2
  73. package/dist/{views-B0hlW6IT.d.ts → views-fn2RuXOx.d.ts} +59 -44
  74. package/package.json +28 -4
  75. package/dist/chunk-4G7552LO.js.map +0 -1
  76. package/dist/chunk-MNKDSGIA.js.map +0 -1
  77. package/dist/chunk-NBAEEHAU.js.map +0 -1
  78. package/dist/chunk-P7F4L2FF.js.map +0 -1
  79. package/dist/chunk-Q5O7GPVY.js.map +0 -1
  80. package/dist/chunk-QLG6VEMW.js.map +0 -1
  81. package/dist/chunk-U5KBV2BA.js.map +0 -1
  82. package/dist/hex-color-MhOyuY-o.d.ts +0 -8
  83. package/dist/runtime-api-BXd70c2e.d.ts +0 -490
  84. /package/dist/{chunk-2LDZ5C3T.js.map → chunk-FWVV2X74.js.map} +0 -0
@@ -1,6 +1,13 @@
1
+ import {
2
+ BROWSER_ATTRIBUTE_JSON_LIMITS,
3
+ RuntimeJsonSchema,
4
+ assertJsonWithinLimits,
5
+ parseBrowserAttributeJson
6
+ } from "./chunk-PF7L4BMG.js";
7
+
1
8
  // src/browser-interaction/constants.ts
2
9
  var DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_NAME = "dreamboard-browser-interaction";
3
- var DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION = "2.0.0";
10
+ var DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION = "3.0.0";
4
11
  var BROWSER_INTERACTION_ATTRIBUTES = {
5
12
  protocol: "data-dreamboard-browser-protocol",
6
13
  surface: "data-dreamboard-browser-surface",
@@ -18,6 +25,8 @@ var BROWSER_INTERACTION_ATTRIBUTES = {
18
25
  actuatorKind: "data-dreamboard-actuator-kind",
19
26
  enabled: "data-dreamboard-actuator-enabled",
20
27
  actuatorId: "data-dreamboard-actuator-id",
28
+ pointerTargetId: "data-dreamboard-pointer-target-id",
29
+ pointerTargetEnabled: "data-dreamboard-pointer-target-enabled",
21
30
  semanticEffects: "data-dreamboard-semantic-effects",
22
31
  acceptedEffectPatterns: "data-dreamboard-accepted-effect-patterns",
23
32
  preparationPatterns: "data-dreamboard-preparation-patterns",
@@ -29,7 +38,8 @@ var BROWSER_INTERACTION_ATTRIBUTES = {
29
38
  };
30
39
  var BROWSER_INTERACTION_RECORD_ROLES = [
31
40
  "interaction",
32
- "actuator"
41
+ "actuator",
42
+ "pointer-target"
33
43
  ];
34
44
  var GAMEPLAY_BROWSER_INTERACTION_SURFACE = "gameplay";
35
45
  var GAMEPLAY_BROWSER_INTERACTION_INTENTS = [
@@ -110,11 +120,13 @@ function canonicalizeValue(value) {
110
120
  return value;
111
121
  }
112
122
  function encodeCanonicalCandidateValue(value) {
123
+ parseBrowserAttributeJson(value);
113
124
  assertCanonicalValue(value);
114
125
  return JSON.stringify(canonicalizeValue(value));
115
126
  }
116
127
  function decodeCanonicalCandidateValue(encoded) {
117
128
  const parsed = JSON.parse(encoded);
129
+ parseBrowserAttributeJson(parsed);
118
130
  assertCanonicalValue(parsed);
119
131
  return canonicalizeValue(parsed);
120
132
  }
@@ -308,6 +320,23 @@ function createBrowserInteractionActuatorAttributes(input) {
308
320
  }
309
321
  return attrs;
310
322
  }
323
+ function createBrowserInteractionPointerTargetAttributes(input) {
324
+ const attrs = {
325
+ ...baseGameplayAttributes(input),
326
+ [BROWSER_INTERACTION_ATTRIBUTES.role]: "pointer-target",
327
+ [BROWSER_INTERACTION_ATTRIBUTES.pointerTargetId]: input.targetId,
328
+ [BROWSER_INTERACTION_ATTRIBUTES.pointerTargetEnabled]: input.enabled === false ? "false" : "true"
329
+ };
330
+ if (input.descriptorDigest) {
331
+ attrs[BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest] = input.descriptorDigest;
332
+ }
333
+ if (input.acceptedEffectPatterns.length > 0) {
334
+ attrs[BROWSER_INTERACTION_ATTRIBUTES.acceptedEffectPatterns] = JSON.stringify(
335
+ input.acceptedEffectPatterns.map(encodeBrowserInteractionEffectPattern)
336
+ );
337
+ }
338
+ return attrs;
339
+ }
311
340
  function createGameplayInteractionRootAttributes(input) {
312
341
  return createBrowserInteractionRootAttributes({
313
342
  ...input,
@@ -320,6 +349,12 @@ function createGameplayActuatorAttributes(input) {
320
349
  surface: GAMEPLAY_BROWSER_INTERACTION_SURFACE
321
350
  });
322
351
  }
352
+ function createGameplayPointerTargetAttributes(input) {
353
+ return createBrowserInteractionPointerTargetAttributes({
354
+ ...input,
355
+ surface: GAMEPLAY_BROWSER_INTERACTION_SURFACE
356
+ });
357
+ }
323
358
  function createBrowserInteractionActuatorKey(input) {
324
359
  return [
325
360
  input.surface,
@@ -428,7 +463,7 @@ function normalizeBrowserInteractionRecords(records, options = {}) {
428
463
  );
429
464
  continue;
430
465
  }
431
- if (!surface || !scopeId || role !== "interaction" && role !== "actuator") {
466
+ if (!surface || !scopeId || role !== "interaction" && role !== "actuator" && role !== "pointer-target") {
432
467
  diagnostics.push(
433
468
  diagnosticFor({
434
469
  code: "invalid-record",
@@ -484,6 +519,38 @@ function normalizeBrowserInteractionRecords(records, options = {}) {
484
519
  );
485
520
  continue;
486
521
  }
522
+ if (role === "pointer-target") {
523
+ const pointerTarget = parseGameplayPointerTarget(attributes, {
524
+ surface,
525
+ scopeId,
526
+ interactionKey,
527
+ interactionId
528
+ });
529
+ if (pointerTarget.diagnostics.length > 0) {
530
+ interaction.diagnostics.push(...pointerTarget.diagnostics);
531
+ diagnostics.push(...pointerTarget.diagnostics);
532
+ }
533
+ const registered2 = registry.surfaces.get(surface);
534
+ if (registered2?.effectKinds) {
535
+ for (const pattern of pointerTarget.acceptedEffectPatterns) {
536
+ const effectKind = pattern.kind === "exact" ? pattern.effect.kind : pattern.effectKind;
537
+ if (!registered2.effectKinds.includes(effectKind)) {
538
+ const diagnostic = diagnosticFor({
539
+ code: "unknown-surface-effect",
540
+ message: `Unknown browser interaction effect '${effectKind}' for surface '${surface}'.`,
541
+ surface,
542
+ scopeId,
543
+ interactionKey,
544
+ targetId: pointerTarget.targetId
545
+ });
546
+ interaction.diagnostics.push(diagnostic);
547
+ diagnostics.push(diagnostic);
548
+ }
549
+ }
550
+ }
551
+ interaction.pointerTargets.push(pointerTarget);
552
+ continue;
553
+ }
487
554
  const actuator = parseGameplayActuator(attributes, {
488
555
  surface,
489
556
  scopeId,
@@ -549,10 +616,12 @@ function normalizeBrowserInteractionRecords(records, options = {}) {
549
616
  for (const surface of surfaces.values()) {
550
617
  if (surface.kind !== "semantic") continue;
551
618
  for (const interaction of surface.interactions.values()) {
552
- if (interaction.rootSeen || interaction.actuators.length === 0) continue;
619
+ if (interaction.rootSeen || interaction.actuators.length === 0 && interaction.pointerTargets.length === 0) {
620
+ continue;
621
+ }
553
622
  const diagnostic = diagnosticFor({
554
623
  code: "orphan-actuator",
555
- message: "Browser interaction actuators require a rendered semantic root.",
624
+ message: "Browser interaction actuators and pointer targets require a rendered semantic root.",
556
625
  surface: surface.surface,
557
626
  scopeId: surface.scopeId,
558
627
  interactionKey: interaction.interactionKey
@@ -583,6 +652,7 @@ function validateBrowserInteractionSnapshot(snapshot) {
583
652
  if (!isSemanticSurfaceSnapshot(surface)) continue;
584
653
  for (const interaction of surface.interactions) {
585
654
  const enabledByKey = /* @__PURE__ */ new Map();
655
+ const enabledTargetsByKey = /* @__PURE__ */ new Map();
586
656
  for (const actuator of interaction.actuators) {
587
657
  if (!actuator.enabled) continue;
588
658
  const key = actuatorIdentityKey({
@@ -595,6 +665,18 @@ function validateBrowserInteractionSnapshot(snapshot) {
595
665
  group.push(actuator);
596
666
  enabledByKey.set(key, group);
597
667
  }
668
+ for (const pointerTarget of interaction.pointerTargets) {
669
+ if (!pointerTarget.enabled) continue;
670
+ const key = pointerTargetIdentityKey({
671
+ surface: surface.surface,
672
+ scopeId: surface.scopeId,
673
+ interactionKey: interaction.interactionKey,
674
+ pointerTarget
675
+ });
676
+ const group = enabledTargetsByKey.get(key) ?? [];
677
+ group.push(pointerTarget);
678
+ enabledTargetsByKey.set(key, group);
679
+ }
598
680
  for (const [key, actuators] of enabledByKey) {
599
681
  if (actuators.length > 1) {
600
682
  diagnostics.push(
@@ -610,6 +692,20 @@ function validateBrowserInteractionSnapshot(snapshot) {
610
692
  );
611
693
  }
612
694
  }
695
+ for (const [key, pointerTargets] of enabledTargetsByKey) {
696
+ if (pointerTargets.length > 1) {
697
+ diagnostics.push(
698
+ diagnosticFor({
699
+ code: "duplicate-enabled-pointer-target",
700
+ message: `Duplicate enabled pointer target for '${key}'.`,
701
+ surface: surface.surface,
702
+ scopeId: surface.scopeId,
703
+ interactionKey: interaction.interactionKey,
704
+ targetId: pointerTargets[0]?.targetId
705
+ })
706
+ );
707
+ }
708
+ }
613
709
  diagnostics.push(
614
710
  ...diagnosticsForPreparationCycles(surface, interaction),
615
711
  ...diagnosticsForPreparationPatternAmbiguity(surface, interaction),
@@ -622,8 +718,21 @@ function validateBrowserInteractionSnapshot(snapshot) {
622
718
  }
623
719
  function diagnosticsForInvalidAcceptedPatterns(surface, interaction) {
624
720
  const diagnostics = [];
625
- for (const actuator of interaction.actuators) {
626
- for (const pattern of actuator.acceptedEffectPatterns) {
721
+ for (const record of [
722
+ ...interaction.actuators.map((actuator) => ({
723
+ patterns: actuator.acceptedEffectPatterns,
724
+ intent: actuator.intent,
725
+ actuatorId: actuator.actuatorId,
726
+ targetId: void 0
727
+ })),
728
+ ...interaction.pointerTargets.map((pointerTarget) => ({
729
+ patterns: pointerTarget.acceptedEffectPatterns,
730
+ intent: void 0,
731
+ actuatorId: void 0,
732
+ targetId: pointerTarget.targetId
733
+ }))
734
+ ]) {
735
+ for (const pattern of record.patterns) {
627
736
  if (pattern.kind === "match" && Object.keys(pattern.fields ?? {}).length === 0 && pattern.scalar === void 0) {
628
737
  diagnostics.push(
629
738
  diagnosticFor({
@@ -632,8 +741,9 @@ function diagnosticsForInvalidAcceptedPatterns(surface, interaction) {
632
741
  surface: surface.surface,
633
742
  scopeId: surface.scopeId,
634
743
  interactionKey: interaction.interactionKey,
635
- intent: actuator.intent,
636
- actuatorId: actuator.actuatorId
744
+ intent: record.intent,
745
+ actuatorId: record.actuatorId,
746
+ targetId: record.targetId
637
747
  })
638
748
  );
639
749
  }
@@ -795,6 +905,42 @@ function parseGameplayActuator(attributes, context) {
795
905
  diagnostics: diagnostics.sort(compareDiagnostic)
796
906
  };
797
907
  }
908
+ function parseGameplayPointerTarget(attributes, context) {
909
+ const diagnostics = [];
910
+ const targetId = text(
911
+ attributes,
912
+ BROWSER_INTERACTION_ATTRIBUTES.pointerTargetId
913
+ );
914
+ const enabled = parseEnabled(
915
+ attributes[BROWSER_INTERACTION_ATTRIBUTES.pointerTargetEnabled]
916
+ );
917
+ const acceptedEffectPatterns = parseEffectPatternList(
918
+ attributes,
919
+ BROWSER_INTERACTION_ATTRIBUTES.acceptedEffectPatterns,
920
+ context,
921
+ "pointer-target",
922
+ diagnostics
923
+ );
924
+ if (!targetId) {
925
+ diagnostics.push(
926
+ diagnosticFor({
927
+ code: "invalid-record",
928
+ message: "Browser interaction pointer target records require a target id.",
929
+ ...context
930
+ })
931
+ );
932
+ }
933
+ return {
934
+ targetId,
935
+ descriptorDigest: optionalText(
936
+ attributes,
937
+ BROWSER_INTERACTION_ATTRIBUTES.descriptorDigest
938
+ ),
939
+ enabled,
940
+ acceptedEffectPatterns,
941
+ diagnostics: diagnostics.sort(compareDiagnostic)
942
+ };
943
+ }
798
944
  function parseEffectList(attributes, attribute, context, intent, diagnostics) {
799
945
  const encodedList = optionalText(attributes, attribute);
800
946
  if (encodedList === void 0) return [];
@@ -875,6 +1021,7 @@ function getInteraction(surface, interactionKey, interactionId) {
875
1021
  readiness: "ready",
876
1022
  rootSeen: false,
877
1023
  actuators: [],
1024
+ pointerTargets: [],
878
1025
  diagnostics: []
879
1026
  };
880
1027
  surface.interactions.set(interactionKey, next);
@@ -897,6 +1044,7 @@ function finalizeSurface(surface) {
897
1044
  draftDigest: interaction.draftDigest,
898
1045
  readiness: interaction.readiness,
899
1046
  actuators: interaction.actuators.sort(compareActuator),
1047
+ pointerTargets: interaction.pointerTargets.sort(comparePointerTarget),
900
1048
  diagnostics: interaction.diagnostics.sort(compareDiagnostic)
901
1049
  })).sort((a, b) => a.interactionKey.localeCompare(b.interactionKey));
902
1050
  return {
@@ -1038,6 +1186,14 @@ function actuatorIdentityKey(input) {
1038
1186
  actuatorKind: input.actuator.actuatorKind
1039
1187
  });
1040
1188
  }
1189
+ function pointerTargetIdentityKey(input) {
1190
+ return [
1191
+ input.surface,
1192
+ input.scopeId,
1193
+ input.interactionKey,
1194
+ input.pointerTarget.targetId
1195
+ ].map((part) => encodeURIComponent(part)).join("|");
1196
+ }
1041
1197
  function isSemanticSurfaceSnapshot(surface) {
1042
1198
  return "interactions" in surface;
1043
1199
  }
@@ -1096,6 +1252,9 @@ function compareSurface(a, b) {
1096
1252
  function compareActuator(a, b) {
1097
1253
  return a.actuatorId.localeCompare(b.actuatorId);
1098
1254
  }
1255
+ function comparePointerTarget(a, b) {
1256
+ return a.targetId.localeCompare(b.targetId);
1257
+ }
1099
1258
  function compareDiagnostic(a, b) {
1100
1259
  return a.code.localeCompare(b.code) || (a.surface ?? "").localeCompare(b.surface ?? "") || (a.scopeId ?? "").localeCompare(b.scopeId ?? "") || (a.interactionKey ?? "").localeCompare(b.interactionKey ?? "") || (a.intent ?? "").localeCompare(b.intent ?? "") || (a.actuatorId ?? "").localeCompare(b.actuatorId ?? "") || a.message.localeCompare(b.message);
1101
1260
  }
@@ -1314,6 +1473,93 @@ function resolveBrowserInteractionEffect(snapshot, request) {
1314
1473
  ]
1315
1474
  };
1316
1475
  }
1476
+ function resolveBrowserPointerTarget(snapshot, request) {
1477
+ const snapshotDiagnostics = [
1478
+ ...snapshot.diagnostics,
1479
+ ...validateBrowserInteractionSnapshot(snapshot)
1480
+ ];
1481
+ if (snapshotDiagnostics.some((diagnostic) => diagnostic.severity === "error")) {
1482
+ return {
1483
+ ok: false,
1484
+ code: "invalid-snapshot",
1485
+ diagnostics: snapshotDiagnostics
1486
+ };
1487
+ }
1488
+ const effectDiagnostics = validateEffectRequest(request.effect, request);
1489
+ if (effectDiagnostics.length > 0) {
1490
+ return {
1491
+ ok: false,
1492
+ code: "invalid-effect",
1493
+ diagnostics: effectDiagnostics
1494
+ };
1495
+ }
1496
+ const surfaces = matchingSurfaces(snapshot, request);
1497
+ const matches = collectPointerTargetMatches(surfaces, request).filter(
1498
+ (match) => match.pointerTarget.acceptedEffectPatterns.some(
1499
+ (pattern) => browserInteractionEffectPatternMatches(pattern, request.effect)
1500
+ )
1501
+ );
1502
+ const enabledMatches = matches.filter((match) => match.pointerTarget.enabled);
1503
+ const actionableMatches = request.allowDisabled === true ? matches : enabledMatches;
1504
+ if (actionableMatches.length === 1) {
1505
+ const match = actionableMatches[0];
1506
+ if (!match) throw new Error("unreachable browser pointer target match");
1507
+ return {
1508
+ ok: true,
1509
+ pointerTarget: match.pointerTarget,
1510
+ surface: match.surface.surface,
1511
+ scopeId: match.surface.scopeId,
1512
+ interactionKey: match.interaction.interactionKey,
1513
+ match: "accepted-pattern",
1514
+ effect: request.effect,
1515
+ diagnostics: []
1516
+ };
1517
+ }
1518
+ if (actionableMatches.length > 1) {
1519
+ return {
1520
+ ok: false,
1521
+ code: "ambiguous",
1522
+ diagnostics: actionableMatches.map(
1523
+ (match) => diagnosticFor2({
1524
+ code: "ambiguous-pointer-target",
1525
+ message: "Browser interaction effect matched multiple pointer targets.",
1526
+ surface: match.surface.surface,
1527
+ scopeId: match.surface.scopeId,
1528
+ interactionKey: match.interaction.interactionKey,
1529
+ targetId: match.pointerTarget.targetId
1530
+ })
1531
+ )
1532
+ };
1533
+ }
1534
+ if (matches.length > 0 && enabledMatches.length === 0) {
1535
+ return {
1536
+ ok: false,
1537
+ code: "unavailable",
1538
+ diagnostics: [
1539
+ diagnosticFor2({
1540
+ code: "disabled-pointer-target",
1541
+ message: "Browser interaction pointer target exists but is not enabled.",
1542
+ surface: request.surface,
1543
+ scopeId: request.scopeId,
1544
+ interactionKey: request.interactionKey
1545
+ })
1546
+ ]
1547
+ };
1548
+ }
1549
+ return {
1550
+ ok: false,
1551
+ code: "not-found",
1552
+ diagnostics: [
1553
+ diagnosticFor2({
1554
+ code: "missing-effect",
1555
+ message: "Browser interaction effect is not accepted by any pointer target.",
1556
+ surface: request.surface,
1557
+ scopeId: request.scopeId,
1558
+ interactionKey: request.interactionKey
1559
+ })
1560
+ ]
1561
+ };
1562
+ }
1317
1563
  function actuatorMatchesRequest(actuator, request, candidateValueKey) {
1318
1564
  return actuator.intent === request.intent && (request.inputKey === void 0 || actuator.inputKey === request.inputKey) && (candidateValueKey === void 0 || actuator.candidateValueKey === candidateValueKey) && (request.actuatorKind === void 0 || actuator.actuatorKind === request.actuatorKind);
1319
1565
  }
@@ -1401,6 +1647,23 @@ function collectInteractionMatches(surfaces, request) {
1401
1647
  })
1402
1648
  );
1403
1649
  }
1650
+ function collectPointerTargetMatches(surfaces, request) {
1651
+ return surfaces.flatMap(
1652
+ (surface) => surface.interactions.flatMap((interaction) => {
1653
+ if (request.interactionKey !== void 0 && interaction.interactionKey !== request.interactionKey) {
1654
+ return [];
1655
+ }
1656
+ if (request.interactionId !== void 0 && interaction.interactionId !== request.interactionId) {
1657
+ return [];
1658
+ }
1659
+ return interaction.pointerTargets.map((pointerTarget) => ({
1660
+ surface,
1661
+ interaction,
1662
+ pointerTarget
1663
+ }));
1664
+ })
1665
+ );
1666
+ }
1404
1667
  function effectSuccess(match, effect, kind) {
1405
1668
  return {
1406
1669
  ok: true,
@@ -1507,18 +1770,37 @@ function diagnosticFor2(input) {
1507
1770
  return { severity: "error", ...input };
1508
1771
  }
1509
1772
 
1773
+ // src/browser-interaction/dom.ts
1774
+ function readBrowserInteractionSnapshot(root) {
1775
+ const protocol = BROWSER_INTERACTION_ATTRIBUTES.protocol;
1776
+ const role = BROWSER_INTERACTION_ATTRIBUTES.role;
1777
+ const selector = [
1778
+ `[${protocol}="${DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION}"][${role}="interaction"]`,
1779
+ `[${protocol}="${DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION}"][${role}="actuator"]`,
1780
+ `[${protocol}="${DREAMBOARD_BROWSER_INTERACTION_PROTOCOL_VERSION}"][${role}="pointer-target"]`
1781
+ ].join(",");
1782
+ const records = [...root.querySelectorAll(selector)].map((element) => ({
1783
+ attributes: Object.fromEntries(
1784
+ [...element.attributes].map((attribute) => [
1785
+ attribute.name,
1786
+ attribute.value
1787
+ ])
1788
+ )
1789
+ }));
1790
+ return normalizeBrowserInteractionRecords(records);
1791
+ }
1792
+
1510
1793
  // src/browser-interaction/schemas.ts
1511
1794
  import { z } from "zod";
1512
- var jsonValueSchema = z.lazy(
1513
- () => z.union([
1514
- z.null(),
1515
- z.boolean(),
1516
- z.number().finite(),
1517
- z.string(),
1518
- z.array(jsonValueSchema),
1519
- z.record(z.string(), jsonValueSchema)
1520
- ])
1521
- );
1795
+ var jsonValueSchema = z.preprocess((value) => {
1796
+ if (value === void 0) return value;
1797
+ assertJsonWithinLimits(
1798
+ value,
1799
+ BROWSER_ATTRIBUTE_JSON_LIMITS,
1800
+ "Browser interaction attribute"
1801
+ );
1802
+ return value;
1803
+ }, RuntimeJsonSchema);
1522
1804
  var browserInteractionEffectSchema = z.object({
1523
1805
  kind: z.string().min(1)
1524
1806
  }).catchall(jsonValueSchema);
@@ -1573,7 +1855,8 @@ var browserInteractionDiagnosticSchema = z.object({
1573
1855
  scopeId: z.string().optional(),
1574
1856
  interactionKey: z.string().optional(),
1575
1857
  intent: z.string().optional(),
1576
- actuatorId: z.string().optional()
1858
+ actuatorId: z.string().optional(),
1859
+ targetId: z.string().optional()
1577
1860
  });
1578
1861
  var browserInteractionActuatorSchema = z.object({
1579
1862
  actuatorId: z.string(),
@@ -1596,6 +1879,13 @@ var browserInteractionActuatorSchema = z.object({
1596
1879
  }).optional(),
1597
1880
  diagnostics: z.array(browserInteractionDiagnosticSchema)
1598
1881
  });
1882
+ var browserInteractionPointerTargetSchema = z.object({
1883
+ targetId: z.string(),
1884
+ enabled: z.boolean(),
1885
+ acceptedEffectPatterns: z.array(browserInteractionEffectPatternSchema),
1886
+ descriptorDigest: z.string().optional(),
1887
+ diagnostics: z.array(browserInteractionDiagnosticSchema)
1888
+ });
1599
1889
  var browserGameplayInteractionSchema = z.object({
1600
1890
  interactionKey: z.string(),
1601
1891
  interactionId: z.string(),
@@ -1603,6 +1893,7 @@ var browserGameplayInteractionSchema = z.object({
1603
1893
  draftDigest: z.string().optional(),
1604
1894
  readiness: z.enum(BROWSER_INTERACTION_READINESS_VALUES),
1605
1895
  actuators: z.array(browserInteractionActuatorSchema),
1896
+ pointerTargets: z.array(browserInteractionPointerTargetSchema),
1606
1897
  diagnostics: z.array(browserInteractionDiagnosticSchema)
1607
1898
  });
1608
1899
  var browserGameplaySurfaceSnapshotSchema = z.object({
@@ -1663,8 +1954,10 @@ export {
1663
1954
  gameplayInvokeEffect,
1664
1955
  createBrowserInteractionRootAttributes,
1665
1956
  createBrowserInteractionActuatorAttributes,
1957
+ createBrowserInteractionPointerTargetAttributes,
1666
1958
  createGameplayInteractionRootAttributes,
1667
1959
  createGameplayActuatorAttributes,
1960
+ createGameplayPointerTargetAttributes,
1668
1961
  createBrowserInteractionActuatorKey,
1669
1962
  defineBrowserInteractionSurface,
1670
1963
  gameplayBrowserInteractionSurface,
@@ -1673,19 +1966,23 @@ export {
1673
1966
  normalizeBrowserInteractionRecords,
1674
1967
  validateBrowserInteractionSnapshot,
1675
1968
  actuatorIdentityKey,
1969
+ pointerTargetIdentityKey,
1676
1970
  isSemanticSurfaceSnapshot,
1677
1971
  targetIdentityKey,
1678
1972
  resolveBrowserInteractionIntent,
1679
1973
  resolveBrowserInteractionEffect,
1974
+ resolveBrowserPointerTarget,
1975
+ readBrowserInteractionSnapshot,
1680
1976
  browserInteractionEffectSchema,
1681
1977
  browserInteractionEffectPatternSchema,
1682
1978
  gameplaySemanticEffectSchema,
1683
1979
  browserInteractionDiagnosticSchema,
1684
1980
  browserInteractionActuatorSchema,
1981
+ browserInteractionPointerTargetSchema,
1685
1982
  browserGameplayInteractionSchema,
1686
1983
  browserGameplaySurfaceSnapshotSchema,
1687
1984
  browserSemanticSurfaceSnapshotSchema,
1688
1985
  browserUnknownSurfaceSnapshotSchema,
1689
1986
  browserInteractionSnapshotSchema
1690
1987
  };
1691
- //# sourceMappingURL=chunk-QLG6VEMW.js.map
1988
+ //# sourceMappingURL=chunk-WUIVY2KE.js.map