@dreamboard-games/sdk 0.3.0-alpha.1 → 0.4.0-alpha.0

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 (56) hide show
  1. package/REFERENCE.md +19935 -0
  2. package/dist/{chunk-3RQEICD3.js → chunk-2LDZ5C3T.js} +2 -2
  3. package/dist/chunk-3OZMHZK3.js +40 -0
  4. package/dist/chunk-3OZMHZK3.js.map +1 -0
  5. package/dist/{chunk-TXXLS3OI.js → chunk-4G7552LO.js} +3 -3
  6. package/dist/{chunk-P7VMTJ5D.js → chunk-MNKDSGIA.js} +2 -2
  7. package/dist/{chunk-P7VMTJ5D.js.map → chunk-MNKDSGIA.js.map} +1 -1
  8. package/dist/{chunk-W6SGFWXH.js → chunk-NBAEEHAU.js} +101 -60
  9. package/dist/chunk-NBAEEHAU.js.map +1 -0
  10. package/dist/{chunk-ADYH6PVT.js → chunk-P7F4L2FF.js} +49 -25
  11. package/dist/chunk-P7F4L2FF.js.map +1 -0
  12. package/dist/{chunk-QZ6X4B5P.js → chunk-Q5O7GPVY.js} +1 -1
  13. package/dist/{chunk-QZ6X4B5P.js.map → chunk-Q5O7GPVY.js.map} +1 -1
  14. package/dist/chunk-U5KBV2BA.js +2654 -0
  15. package/dist/chunk-U5KBV2BA.js.map +1 -0
  16. package/dist/{chunk-Y2AFYBMB.js → chunk-Y6Y2YABD.js} +9 -5
  17. package/dist/chunk-Y6Y2YABD.js.map +1 -0
  18. package/dist/codegen.d.ts +44 -51
  19. package/dist/codegen.js +1 -1
  20. package/dist/{index.d-BGqVifr_.d.ts → index.d-BL3bT5lt.d.ts} +82 -3
  21. package/dist/index.js +1 -1
  22. package/dist/package-set.d.ts +2 -2
  23. package/dist/package-set.js +1 -1
  24. package/dist/reducer/advanced.d.ts +78 -0
  25. package/dist/reducer/advanced.js +139 -0
  26. package/dist/reducer/advanced.js.map +1 -0
  27. package/dist/reducer-contract.d.ts +1 -1
  28. package/dist/reducer-contract.js +2 -2
  29. package/dist/reducer.d.ts +363 -3263
  30. package/dist/reducer.js +2778 -4081
  31. package/dist/reducer.js.map +1 -1
  32. package/dist/runtime/primitives.d.ts +3 -3
  33. package/dist/runtime/primitives.js +3 -3
  34. package/dist/runtime/runtime-api.d.ts +1 -1
  35. package/dist/runtime/workspace-contract.d.ts +18 -4
  36. package/dist/runtime/workspace-contract.js +4 -4
  37. package/dist/{runtime-api-tGL3ArsB.d.ts → runtime-api-BXd70c2e.d.ts} +6 -0
  38. package/dist/runtime.d.ts +2 -2
  39. package/dist/runtime.js +85 -20
  40. package/dist/runtime.js.map +1 -1
  41. package/dist/stale-contract-artifact-error-BelRiIDR.d.ts +66 -0
  42. package/dist/testing.d.ts +59 -5
  43. package/dist/testing.js +170 -6
  44. package/dist/testing.js.map +1 -1
  45. package/dist/types.d.ts +112 -119
  46. package/dist/ui/components.js +1 -1
  47. package/dist/ui/plugin-styles.css +2 -250
  48. package/dist/{ui-contract-SctM4ibF.d.ts → ui-contract-BUC6iS3s.d.ts} +1 -1
  49. package/dist/ui.js +2 -2
  50. package/dist/views-B0hlW6IT.d.ts +3153 -0
  51. package/package.json +18 -10
  52. package/dist/chunk-ADYH6PVT.js.map +0 -1
  53. package/dist/chunk-W6SGFWXH.js.map +0 -1
  54. package/dist/chunk-Y2AFYBMB.js.map +0 -1
  55. /package/dist/{chunk-3RQEICD3.js.map → chunk-2LDZ5C3T.js.map} +0 -0
  56. /package/dist/{chunk-TXXLS3OI.js.map → chunk-4G7552LO.js.map} +0 -0
@@ -17,7 +17,7 @@ import {
17
17
  useChromeSuppression,
18
18
  useTheme,
19
19
  useThemeCssVars
20
- } from "./chunk-QZ6X4B5P.js";
20
+ } from "./chunk-Q5O7GPVY.js";
21
21
  import {
22
22
  composeEventHandlers,
23
23
  renderPrimitive
@@ -341,7 +341,10 @@ function semanticSeatProjection(state, gameplay, seatOrder) {
341
341
  (playerId) => canonicalizeSeatReference(playerId, playerToSeat)
342
342
  ),
343
343
  view: canonicalizeSemanticProjectionValue(state.view, playerToSeat),
344
- zones: canonicalizeSemanticProjectionValue(gameplay.zones ?? {}, playerToSeat),
344
+ zones: canonicalizeSemanticProjectionValue(
345
+ gameplay.zones ?? {},
346
+ playerToSeat
347
+ ),
345
348
  availableInteractions: gameplay.availableInteractions.map(
346
349
  (descriptor) => semanticInteractionDescriptor(descriptor, playerToSeat)
347
350
  )
@@ -419,7 +422,10 @@ function canonicalizeSemanticProjectionValue(value, playerToSeat) {
419
422
  return null;
420
423
  }
421
424
  function canonicalizeSemanticProjectionProperty(key, value, playerToSeat) {
422
- const canonicalValue = canonicalizeSemanticProjectionValue(value, playerToSeat);
425
+ const canonicalValue = canonicalizeSemanticProjectionValue(
426
+ value,
427
+ playerToSeat
428
+ );
423
429
  if ((key === "eligibleTargets" || key === "dependentCases") && Array.isArray(canonicalValue)) {
424
430
  return [...canonicalValue].sort(
425
431
  (left, right) => compareJson(canonicalJson(left), canonicalJson(right))
@@ -1881,7 +1887,8 @@ import {
1881
1887
  async function runInteractionAction(action, {
1882
1888
  onSuccess,
1883
1889
  onError,
1884
- unhandledError = "throw"
1890
+ unhandledError = "throw",
1891
+ onDiagnostic
1885
1892
  } = {}) {
1886
1893
  try {
1887
1894
  const result = await action();
@@ -1892,7 +1899,17 @@ async function runInteractionAction(action, {
1892
1899
  return;
1893
1900
  }
1894
1901
  if (unhandledError === "log") {
1895
- console.error(error);
1902
+ const message = error instanceof Error ? error.message : String(error);
1903
+ if (onDiagnostic) {
1904
+ onDiagnostic({
1905
+ type: "runtimeLog",
1906
+ level: "error",
1907
+ message,
1908
+ details: [error]
1909
+ });
1910
+ } else {
1911
+ console.error(error);
1912
+ }
1896
1913
  return;
1897
1914
  }
1898
1915
  if (unhandledError === "ignore") {
@@ -3477,16 +3494,20 @@ var warnedAmbiguousBoardTargets = /* @__PURE__ */ new Set();
3477
3494
  function warnAmbiguousBoardTarget({
3478
3495
  kind,
3479
3496
  value,
3480
- interactionKeys
3497
+ interactionKeys,
3498
+ runtime
3481
3499
  }) {
3482
3500
  const key = `${kind}:${value}:${interactionKeys.join("|")}`;
3483
3501
  if (warnedAmbiguousBoardTargets.has(key)) return;
3484
3502
  warnedAmbiguousBoardTargets.add(key);
3485
- console.error(
3486
- `[dreamboard] Ambiguous Board.${kind} target "${value}" matched multiple available interactions: ${interactionKeys.join(
3487
- ", "
3488
- )}. Declare the real initiating collector in Interaction.Routes (for example, a card or form input), arm one interaction before collecting this board target, or render an explicit Board.Target interaction prop.`
3489
- );
3503
+ const message = `[dreamboard] Ambiguous Board.${kind} target "${value}" matched multiple available interactions: ${interactionKeys.join(
3504
+ ", "
3505
+ )}. Declare the real initiating collector in Interaction.Routes (for example, a card or form input), arm one interaction before collecting this board target, or render an explicit Board.Target interaction prop.`;
3506
+ if (runtime?.emitDiagnostic) {
3507
+ runtime.emitDiagnostic({ type: "runtimeLog", level: "error", message });
3508
+ } else {
3509
+ console.error(message);
3510
+ }
3490
3511
  }
3491
3512
  function useBoardPrimitiveContext() {
3492
3513
  const value = useContext7(BoardContext);
@@ -3590,6 +3611,7 @@ function UnambiguousBoardTarget({
3590
3611
  ...props
3591
3612
  }) {
3592
3613
  const board = useBoardPrimitiveContext();
3614
+ const runtime = useRuntimeContext();
3593
3615
  const gameActionError = useGameActionError();
3594
3616
  const targetState = board.targetState(kind, value);
3595
3617
  const eligible = board.isEligible(value, kind);
@@ -3599,7 +3621,8 @@ function UnambiguousBoardTarget({
3599
3621
  warnAmbiguousBoardTarget({
3600
3622
  kind,
3601
3623
  value,
3602
- interactionKeys: conflictInteractionKeys
3624
+ interactionKeys: conflictInteractionKeys,
3625
+ runtime
3603
3626
  });
3604
3627
  }
3605
3628
  const isDisabled = disabled ?? (!targetState.eligible || ambiguous);
@@ -3776,11 +3799,7 @@ var Board = {
3776
3799
  };
3777
3800
 
3778
3801
  // src/runtime/primitives/interaction/context.tsx
3779
- import {
3780
- createContext as createContext9,
3781
- useContext as useContext9,
3782
- useMemo as useMemo11
3783
- } from "react";
3802
+ import { createContext as createContext9, useContext as useContext9, useMemo as useMemo11 } from "react";
3784
3803
 
3785
3804
  // src/runtime/hooks/useInteractionHandle.ts
3786
3805
  import { useCallback as useCallback4, useEffect as useEffect5, useMemo as useMemo10, useRef as useRef3 } from "react";
@@ -5559,16 +5578,21 @@ function InteractionSwitch({
5559
5578
  }) });
5560
5579
  }
5561
5580
  var warnedInteractionRouteIssues = /* @__PURE__ */ new Set();
5562
- function warnInteractionRouteIssue(message) {
5581
+ function warnInteractionRouteIssue(message, runtime) {
5563
5582
  if (warnedInteractionRouteIssues.has(message)) return;
5564
5583
  warnedInteractionRouteIssues.add(message);
5565
- console.warn(message);
5584
+ if (runtime?.emitDiagnostic) {
5585
+ runtime.emitDiagnostic({ type: "runtimeLog", level: "warn", message });
5586
+ } else {
5587
+ console.warn(message);
5588
+ }
5566
5589
  }
5567
5590
  function InteractionRoutes({
5568
5591
  routes,
5569
5592
  fallback = null,
5570
5593
  includeUnavailable = false
5571
5594
  }) {
5595
+ const runtime = useRuntimeContext();
5572
5596
  const descriptors = usePluginState(
5573
5597
  (state) => state.gameplay.availableInteractions
5574
5598
  );
@@ -5580,7 +5604,8 @@ function InteractionRoutes({
5580
5604
  const route = routes[interaction];
5581
5605
  if (!route) {
5582
5606
  warnInteractionRouteIssue(
5583
- `[dreamboard] Interaction.Routes is missing a collector route for "${descriptor.interactionKey}". Declare the interaction in routes so input collection stays explicit.`
5607
+ `[dreamboard] Interaction.Routes is missing a collector route for "${descriptor.interactionKey}". Declare the interaction in routes so input collection stays explicit.`,
5608
+ runtime
5584
5609
  );
5585
5610
  return null;
5586
5611
  }
@@ -5589,7 +5614,8 @@ function InteractionRoutes({
5589
5614
  warnInteractionRouteIssue(
5590
5615
  `[dreamboard] Interaction.Routes route "${descriptor.interactionKey}" is missing collectors for: ${missingInputs.join(
5591
5616
  ", "
5592
- )}.`
5617
+ )}.`,
5618
+ runtime
5593
5619
  );
5594
5620
  }
5595
5621
  return descriptor;
@@ -5862,9 +5888,7 @@ function InteractionValidationMessage({
5862
5888
  }
5863
5889
 
5864
5890
  // src/runtime/primitives/interaction/card-input.tsx
5865
- import {
5866
- useCallback as useCallback6
5867
- } from "react";
5891
+ import { useCallback as useCallback6 } from "react";
5868
5892
  function InteractionCardInput({
5869
5893
  input,
5870
5894
  unsafeCardId,
@@ -6590,4 +6614,4 @@ export {
6590
6614
  DiceValues,
6591
6615
  Dice
6592
6616
  };
6593
- //# sourceMappingURL=chunk-ADYH6PVT.js.map
6617
+ //# sourceMappingURL=chunk-P7F4L2FF.js.map