@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,192 @@
1
+ import { R as ReducerDiagnosticEvent, D as DispatchTraceSummaryEntry } from './diagnostics-1BWjRo6-.js';
2
+ import { a as ReducerBundleContract, w as wire } from './index.d-DMASeF6M.js';
3
+
4
+ type TestRunner = "reducer" | "remote" | "browser";
5
+ type InteractionDescriptorLike = {
6
+ interactionId?: string;
7
+ surface?: string;
8
+ kind?: string;
9
+ availability?: InteractionAvailabilityLike;
10
+ context?: {
11
+ to?: string;
12
+ };
13
+ } & Record<string, unknown>;
14
+ type InteractionAvailabilityLike = {
15
+ status: "available";
16
+ } | {
17
+ status: "notYourTurn";
18
+ reason: string;
19
+ } | {
20
+ status: "insufficientResources";
21
+ reason: string;
22
+ missingResources?: Record<string, unknown>;
23
+ } | {
24
+ status: "blocked";
25
+ reason: string;
26
+ };
27
+ type InteractionExplanationLike = {
28
+ interactionId: string;
29
+ phase: string;
30
+ step: string | null;
31
+ availability: "available" | "notYourTurn" | "wrongPhase" | "wrongStep" | "blocked";
32
+ rules: ReadonlyArray<{
33
+ ruleId: string;
34
+ outcome: "passed" | "failed" | "notEvaluated";
35
+ errorCode?: string;
36
+ message?: string;
37
+ }>;
38
+ actor: {
39
+ required: readonly string[];
40
+ playerIsActor: boolean;
41
+ };
42
+ inputs: ReadonlyArray<{
43
+ key: string;
44
+ kind: string;
45
+ eligibleCount: number | "lazy";
46
+ }>;
47
+ };
48
+ type SnapshotMatcherHandler = (name: string | undefined, actual: unknown) => void;
49
+ type RejectionExpectation = {
50
+ errorCode?: string;
51
+ message?: string | RegExp;
52
+ };
53
+ type ExpectMatchers = {
54
+ toBe: (expected: unknown) => void;
55
+ toEqual: (expected: unknown) => void;
56
+ toMatchObject: (expected: Record<string, unknown>) => void;
57
+ toBeDefined: () => void;
58
+ toBeUndefined: () => void;
59
+ toBeNull: () => void;
60
+ toContain: (expected: unknown) => void;
61
+ toContainEqual: (expected: unknown) => void;
62
+ toHaveLength: (expected: number) => void;
63
+ toBeGreaterThan: (expected: number) => void;
64
+ toBeGreaterThanOrEqual: (expected: number) => void;
65
+ toThrow: (predicate?: string | RegExp | ((error: Error) => boolean)) => void;
66
+ toMatchSnapshot: (filename?: string) => void;
67
+ toRejectWith: (expected: RejectionExpectation) => Promise<void>;
68
+ toHaveInteraction: (interactionId: string, opts?: Partial<InteractionDescriptorLike>) => void;
69
+ toBeGatedBy: (reason: string, opts?: {
70
+ interactionId?: string;
71
+ }) => void;
72
+ toBeAvailable: (explanation?: InteractionExplanationLike) => void;
73
+ toBeActiveFor: (playerId: string, opts?: {
74
+ interactionId?: string;
75
+ }) => void;
76
+ not: {
77
+ toHaveInteraction: (interactionId: string) => void;
78
+ };
79
+ };
80
+ type ExpectFn = (actual: unknown) => ExpectMatchers;
81
+ interface BaseContext<PlayerId extends string = string> {
82
+ game: {
83
+ start(): Promise<void>;
84
+ patchState?(mutator: (state: Record<string, unknown>) => void): Promise<void>;
85
+ submit(playerId: PlayerId, interactionId: string, params?: unknown): Promise<void>;
86
+ };
87
+ players(): readonly PlayerId[];
88
+ seat(index: number): PlayerId;
89
+ }
90
+ interface SharedScenarioContext<PlayerId extends string = string, StateName extends string = string, View = unknown, Descriptor extends InteractionDescriptorLike = InteractionDescriptorLike> extends BaseContext<PlayerId> {
91
+ state(): StateName;
92
+ view(playerId: PlayerId): View;
93
+ interactions(playerId: PlayerId): readonly Descriptor[];
94
+ explain(playerId: PlayerId, interactionId: string): InteractionExplanationLike;
95
+ diagnostics: {
96
+ readonly events: readonly ReducerDiagnosticEvent[];
97
+ readonly lastDispatch: {
98
+ submissionId: string;
99
+ trace: readonly DispatchTraceSummaryEntry[];
100
+ } | null;
101
+ clear(): void;
102
+ };
103
+ expect: ExpectFn;
104
+ }
105
+ interface BaseDefinition {
106
+ id: string;
107
+ seed?: number;
108
+ players?: number;
109
+ setupProfileId?: string | null;
110
+ extends?: string;
111
+ setup: (ctx: BaseContext) => void | Promise<void>;
112
+ }
113
+ interface ScenarioDefinition<Runners extends readonly TestRunner[] = readonly ["reducer"], PhaseName extends string = string, StageName extends string = string> {
114
+ id: string;
115
+ description?: string;
116
+ from: string;
117
+ runners?: Runners;
118
+ phase?: PhaseName;
119
+ stage?: StageName;
120
+ when: (ctx: SharedScenarioContext) => void | Promise<void>;
121
+ then: (ctx: SharedScenarioContext) => void | Promise<void>;
122
+ }
123
+ declare function defineBase<const Definition extends BaseDefinition>(definition: Definition): Definition;
124
+ declare function defineScenario<const Runners extends readonly TestRunner[] = readonly ["reducer"], const PhaseName extends string = string, const StageName extends string = string>(definition: ScenarioDefinition<Runners, PhaseName, StageName>): ScenarioDefinition<Runners, PhaseName, StageName>;
125
+
126
+ type ReducerScenarioBundle = Pick<ReducerBundleContract, "projectSeatsDynamic" | "validateInput" | "dispatch" | "projectStatic">;
127
+ interface ReducerScenarioViewer {
128
+ readonly seatId: string;
129
+ readonly playerId: string;
130
+ }
131
+ interface ReducerScenarioFrame {
132
+ readonly id: string;
133
+ readonly reducerState: wire.ReducerSessionState;
134
+ readonly dynamicProjection: wire.SeatProjectionBundle;
135
+ readonly staticProjection?: wire.BoardStaticProjection | null;
136
+ readonly gameVersion: number;
137
+ readonly actionSetVersion: string;
138
+ readonly projectionDigest: string;
139
+ }
140
+ interface ReducerScenarioTrace {
141
+ readonly scenarioId: string;
142
+ readonly gameId: string;
143
+ readonly viewer: ReducerScenarioViewer;
144
+ readonly frames: readonly ReducerScenarioFrame[];
145
+ readonly exchanges: readonly ReducerScenarioExchange[];
146
+ }
147
+ type ReducerScenarioExchange = {
148
+ readonly id: string;
149
+ readonly operation: "validate";
150
+ readonly fromFrameId: string;
151
+ readonly input: wire.GameInput;
152
+ readonly result: wire.ReducerInputValidationResult;
153
+ } | {
154
+ readonly id: string;
155
+ readonly operation: "submit";
156
+ readonly fromFrameId: string;
157
+ readonly input: wire.GameInput;
158
+ readonly result: {
159
+ readonly kind: "accepted";
160
+ readonly toFrameId: string;
161
+ } | {
162
+ readonly kind: "rejected";
163
+ readonly diagnostics: readonly ReducerScenarioDiagnostic[];
164
+ };
165
+ };
166
+ interface ReducerScenarioDiagnostic {
167
+ readonly code: string;
168
+ readonly message: string;
169
+ }
170
+ type ReducerScenarioOperation = {
171
+ readonly id: string;
172
+ readonly operation: "validate";
173
+ readonly input: wire.GameInput;
174
+ } | {
175
+ readonly id: string;
176
+ readonly operation: "submit";
177
+ readonly input: wire.GameInput;
178
+ };
179
+ interface CreateReducerScenarioRunnerOptions {
180
+ readonly scenarioId: string;
181
+ readonly gameId: string;
182
+ readonly initialState: wire.ReducerSessionState;
183
+ readonly bundle: ReducerScenarioBundle;
184
+ readonly viewer: ReducerScenarioViewer;
185
+ readonly playerIds: readonly string[];
186
+ readonly initialGameVersion?: number;
187
+ }
188
+ interface ReducerScenarioRunner {
189
+ run(operations: readonly ReducerScenarioOperation[]): Promise<ReducerScenarioTrace>;
190
+ }
191
+
192
+ export { type BaseContext as B, type CreateReducerScenarioRunnerOptions as C, type ExpectFn as E, type InteractionAvailabilityLike as I, type ReducerScenarioBundle as R, type ScenarioDefinition as S, type TestRunner as T, type BaseDefinition as a, type ExpectMatchers as b, type InteractionDescriptorLike as c, type InteractionExplanationLike as d, type ReducerScenarioDiagnostic as e, type ReducerScenarioExchange as f, type ReducerScenarioFrame as g, type ReducerScenarioOperation as h, type ReducerScenarioRunner as i, type ReducerScenarioTrace as j, type ReducerScenarioViewer as k, type RejectionExpectation as l, type SharedScenarioContext as m, type SnapshotMatcherHandler as n, defineBase as o, defineScenario as p };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamboard-games/sdk",
3
- "version": "0.4.0-alpha.6",
3
+ "version": "0.4.0-alpha.7",
4
4
  "description": "Dreamboard SDK package set metadata and public facade",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,6 +16,11 @@
16
16
  "import": "./dist/package-set.js",
17
17
  "default": "./dist/package-set.js"
18
18
  },
19
+ "./reference-games": {
20
+ "types": "./dist/reference-games/index.d.ts",
21
+ "import": "./dist/reference-games/index.js",
22
+ "default": "./dist/reference-games/index.js"
23
+ },
19
24
  "./types": {
20
25
  "types": "./dist/types.d.ts",
21
26
  "import": "./dist/types.js",
@@ -94,6 +99,11 @@
94
99
  "import": "./dist/testing.js",
95
100
  "default": "./dist/testing.js"
96
101
  },
102
+ "./testing-runtime": {
103
+ "types": "./dist/testing-runtime.d.ts",
104
+ "import": "./dist/testing-runtime.js",
105
+ "default": "./dist/testing-runtime.js"
106
+ },
97
107
  "./browser-interaction": {
98
108
  "bun": "./src/browser-interaction.ts",
99
109
  "types": "./dist/browser-interaction.d.ts",
@@ -111,7 +121,7 @@
111
121
  "!tsconfig.tsbuildinfo"
112
122
  ],
113
123
  "scripts": {
114
- "build": "pnpm --dir ../.. --filter @dreamboard-games/plugin-runtime-contract build && pnpm --dir ../.. authoring-metadata:generate && tsup && node ../../scripts/copy-sdk-private-dts.mjs && mkdir -p dist/ui && tailwindcss -i src/ui/plugin-styles.css -o dist/ui/plugin-styles.css --minify",
124
+ "build": "pnpm --dir ../.. --filter @dreamboard-games/sdk-types build && pnpm --dir ../.. --filter @dreamboard-games/plugin-runtime-contract build && pnpm --dir ../.. authoring-metadata:generate && tsup && node ../../scripts/copy-sdk-private-dts.mjs && mkdir -p dist/ui && tailwindcss -i src/ui/plugin-styles.css -o dist/ui/plugin-styles.css --minify",
115
125
  "typecheck": "tsc --noEmit",
116
126
  "lint": "eslint 'src/**/*.{ts,tsx}'",
117
127
  "storybook": "storybook dev -p 6006 --host 127.0.0.1 --no-open",
@@ -128,6 +138,7 @@
128
138
  "@radix-ui/react-select": "^2.3.1",
129
139
  "@radix-ui/react-slot": "^1.3.0",
130
140
  "@radix-ui/react-tooltip": "^1.2.10",
141
+ "@noble/hashes": "^2.2.0",
131
142
  "@use-gesture/react": "^10.3.1",
132
143
  "clsx": "^2.1.1",
133
144
  "lucide-react": "^1.20.0",