@dreamboard-games/sdk 0.5.0-alpha.2 → 0.5.0-alpha.3
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.
- package/README.md +136 -45
- package/dist/chunk-DMFVAZI2.js +16 -0
- package/dist/chunk-DMFVAZI2.js.map +1 -0
- package/dist/chunk-FMM5LVJW.js +833 -0
- package/dist/chunk-FMM5LVJW.js.map +1 -0
- package/dist/{chunk-S2JEDVWH.js → chunk-LRILEVKC.js} +6113 -6489
- package/dist/chunk-LRILEVKC.js.map +1 -0
- package/dist/chunk-SP234IY4.js +1363 -0
- package/dist/chunk-SP234IY4.js.map +1 -0
- package/dist/chunk-VUWNJXLJ.js +52 -0
- package/dist/chunk-VUWNJXLJ.js.map +1 -0
- package/dist/chunk-ZPRKWPEP.js +511 -0
- package/dist/chunk-ZPRKWPEP.js.map +1 -0
- package/dist/definition-BaHNPZol.d.ts +4639 -0
- package/dist/diagnostics-B0lgnuZ6.d.ts +65 -0
- package/dist/index.d.ts +3553 -1
- package/dist/index.js +1045 -6
- package/dist/index.js.map +1 -1
- package/dist/model-BHro6yXu.d.ts +288 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.js +80 -0
- package/dist/react.js.map +1 -0
- package/dist/reducer.d.ts +1194 -79
- package/dist/reducer.js +4326 -121
- package/dist/reducer.js.map +1 -1
- package/dist/testing.d.ts +518 -564
- package/dist/testing.js +2448 -915
- package/dist/testing.js.map +1 -1
- package/dist/types-DimqnJBq.d.ts +86 -0
- package/package.json +26 -131
- package/dist/HandView-Bi2lxzQP.d.ts +0 -79
- package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
- package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
- package/dist/attributes-DbvyMbXw.d.ts +0 -68
- package/dist/browser-interaction.d.ts +0 -910
- package/dist/browser-interaction.js +0 -119
- package/dist/browser-interaction.js.map +0 -1
- package/dist/chunk-32PFKDV7.js +0 -11705
- package/dist/chunk-32PFKDV7.js.map +0 -1
- package/dist/chunk-3BAD4VC2.js +0 -263
- package/dist/chunk-3BAD4VC2.js.map +0 -1
- package/dist/chunk-3SKDNDPG.js +0 -104
- package/dist/chunk-3SKDNDPG.js.map +0 -1
- package/dist/chunk-5YV2WHJ4.js +0 -25
- package/dist/chunk-5YV2WHJ4.js.map +0 -1
- package/dist/chunk-ANRB4XKA.js +0 -90
- package/dist/chunk-ANRB4XKA.js.map +0 -1
- package/dist/chunk-BI4G3PM2.js +0 -1864
- package/dist/chunk-BI4G3PM2.js.map +0 -1
- package/dist/chunk-EVCLTY4Q.js +0 -935
- package/dist/chunk-EVCLTY4Q.js.map +0 -1
- package/dist/chunk-GDPKTBUR.js +0 -564
- package/dist/chunk-GDPKTBUR.js.map +0 -1
- package/dist/chunk-H6VDGFL5.js +0 -2903
- package/dist/chunk-H6VDGFL5.js.map +0 -1
- package/dist/chunk-LR3ZTWQF.js +0 -5960
- package/dist/chunk-LR3ZTWQF.js.map +0 -1
- package/dist/chunk-PF7L4BMG.js +0 -117
- package/dist/chunk-PF7L4BMG.js.map +0 -1
- package/dist/chunk-PN5O6GG2.js +0 -32
- package/dist/chunk-PN5O6GG2.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-S2JEDVWH.js.map +0 -1
- package/dist/chunk-T3ZKNUZ7.js +0 -1
- package/dist/chunk-T3ZKNUZ7.js.map +0 -1
- package/dist/chunk-UGH54WZ2.js +0 -223
- package/dist/chunk-UGH54WZ2.js.map +0 -1
- package/dist/chunk-VCDWP5VL.js +0 -746
- package/dist/chunk-VCDWP5VL.js.map +0 -1
- package/dist/chunk-VDXOF4FW.js +0 -69
- package/dist/chunk-VDXOF4FW.js.map +0 -1
- package/dist/chunk-WHR5UW3F.js +0 -1988
- package/dist/chunk-WHR5UW3F.js.map +0 -1
- package/dist/chunk-Y75CFE77.js +0 -17
- package/dist/chunk-Y75CFE77.js.map +0 -1
- package/dist/chunk-Z7QCREWI.js +0 -3435
- package/dist/chunk-Z7QCREWI.js.map +0 -1
- package/dist/chunk-ZZGN2ATS.js +0 -1941
- package/dist/chunk-ZZGN2ATS.js.map +0 -1
- package/dist/components-gAbIz7hK.d.ts +0 -1284
- package/dist/definitions-BgmV_GhC.d.ts +0 -300
- package/dist/diagnostics-DIi3ina7.d.ts +0 -50
- package/dist/digest.d.ts +0 -8
- package/dist/game-CsZScpcn.d.ts +0 -763
- package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
- package/dist/index-CcT9Q7N7.d.ts +0 -193
- package/dist/index.d-DjzoK7zn.d.ts +0 -2101
- package/dist/package-set.d.ts +0 -13
- package/dist/package-set.js +0 -12
- package/dist/package-set.js.map +0 -1
- package/dist/player-state-Cqpyeql0.d.ts +0 -371
- package/dist/plugin-runtime-contract.d.ts +0 -17
- package/dist/plugin-runtime-contract.js +0 -92
- package/dist/plugin-runtime-contract.js.map +0 -1
- package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
- package/dist/protocol-dYgafTYY.d.ts +0 -314
- package/dist/reducer/advanced.d.ts +0 -82
- package/dist/reducer/advanced.js +0 -51
- package/dist/reducer/advanced.js.map +0 -1
- package/dist/reducer-contract.d.ts +0 -11
- package/dist/reducer-contract.js +0 -16
- package/dist/reducer-contract.js.map +0 -1
- package/dist/reference-games/index.d.ts +0 -31
- package/dist/reference-games/index.js +0 -48
- package/dist/reference-games/index.js.map +0 -1
- package/dist/runtime/primitives.d.ts +0 -250
- package/dist/runtime/primitives.js +0 -189
- package/dist/runtime/primitives.js.map +0 -1
- package/dist/runtime/runtime-api.d.ts +0 -2
- package/dist/runtime/runtime-api.js +0 -1
- package/dist/runtime/runtime-api.js.map +0 -1
- package/dist/runtime/workspace-contract.d.ts +0 -392
- package/dist/runtime/workspace-contract.js +0 -28
- package/dist/runtime/workspace-contract.js.map +0 -1
- package/dist/runtime-RJ5orDJU.d.ts +0 -1699
- package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
- package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
- package/dist/runtime.d.ts +0 -83
- package/dist/runtime.js +0 -242
- package/dist/runtime.js.map +0 -1
- package/dist/schema.d.ts +0 -379
- package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
- package/dist/testing-compiler.d.ts +0 -37
- package/dist/testing-compiler.js +0 -272
- package/dist/testing-compiler.js.map +0 -1
- package/dist/testing-runtime.d.ts +0 -119
- package/dist/testing-runtime.js +0 -212
- package/dist/testing-runtime.js.map +0 -1
- package/dist/types-DJj5MJkl.d.ts +0 -256
- package/dist/types-DR7DoB1x.d.ts +0 -28
- package/dist/types-JWCYHmu7.d.ts +0 -122
- package/dist/types.d.ts +0 -1958
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -1
- package/dist/ui/components.d.ts +0 -17
- package/dist/ui/components.js +0 -216
- package/dist/ui/components.js.map +0 -1
- package/dist/ui/defaults.d.ts +0 -19
- package/dist/ui/defaults.js +0 -104
- package/dist/ui/defaults.js.map +0 -1
- package/dist/ui/player-state.d.ts +0 -2
- package/dist/ui/player-state.js +0 -1
- package/dist/ui/player-state.js.map +0 -1
- package/dist/ui/plugin-styles.css +0 -2
- package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
- package/dist/ui.d.ts +0 -317
- package/dist/ui.js +0 -277
- package/dist/ui.js.map +0 -1
- package/dist/views-BpuWcOyN.d.ts +0 -1641
package/dist/chunk-PF7L4BMG.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// src/runtime-json.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var JsonValidationError = class extends Error {
|
|
4
|
-
constructor(code, message) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.code = code;
|
|
7
|
-
this.name = "JsonValidationError";
|
|
8
|
-
}
|
|
9
|
-
code;
|
|
10
|
-
};
|
|
11
|
-
var BROWSER_ATTRIBUTE_JSON_LIMITS = {
|
|
12
|
-
maxDepth: 32,
|
|
13
|
-
maxNodes: 1e4,
|
|
14
|
-
maxStringBytes: 65536,
|
|
15
|
-
maxCollectionEntries: 5e3
|
|
16
|
-
};
|
|
17
|
-
function jsonError(code, label, detail) {
|
|
18
|
-
return new JsonValidationError(code, `${label} ${detail}.`);
|
|
19
|
-
}
|
|
20
|
-
function requirePlainObject(value, label) {
|
|
21
|
-
const prototype = Object.getPrototypeOf(value);
|
|
22
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
23
|
-
throw jsonError("non-json", label, "contains a non-plain object");
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
function assertJsonWithinLimits(root, limits, label) {
|
|
28
|
-
const stack = [
|
|
29
|
-
{ value: root, depth: 0 }
|
|
30
|
-
];
|
|
31
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
32
|
-
const encoder = new TextEncoder();
|
|
33
|
-
let nodes = 0;
|
|
34
|
-
let stringBytes = 0;
|
|
35
|
-
let collectionEntries = 0;
|
|
36
|
-
while (stack.length > 0) {
|
|
37
|
-
const item = stack.pop();
|
|
38
|
-
if (!item) continue;
|
|
39
|
-
const { value, depth } = item;
|
|
40
|
-
nodes += 1;
|
|
41
|
-
if (nodes > limits.maxNodes) {
|
|
42
|
-
throw jsonError("nodes", label, "exceeds the node limit");
|
|
43
|
-
}
|
|
44
|
-
if (depth > limits.maxDepth) {
|
|
45
|
-
throw jsonError("depth", label, "exceeds the depth limit");
|
|
46
|
-
}
|
|
47
|
-
switch (typeof value) {
|
|
48
|
-
case "string":
|
|
49
|
-
stringBytes += encoder.encode(value).byteLength;
|
|
50
|
-
if (stringBytes > limits.maxStringBytes) {
|
|
51
|
-
throw jsonError(
|
|
52
|
-
"string-bytes",
|
|
53
|
-
label,
|
|
54
|
-
"exceeds the string-byte limit"
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
continue;
|
|
58
|
-
case "number":
|
|
59
|
-
if (!Number.isFinite(value)) {
|
|
60
|
-
throw jsonError("non-json", label, "contains a non-finite number");
|
|
61
|
-
}
|
|
62
|
-
continue;
|
|
63
|
-
case "boolean":
|
|
64
|
-
continue;
|
|
65
|
-
case "object":
|
|
66
|
-
if (value === null) continue;
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
throw jsonError("non-json", label, "contains a non-JSON value");
|
|
70
|
-
}
|
|
71
|
-
if (seen.has(value)) {
|
|
72
|
-
throw jsonError("cycle", label, "contains a cycle");
|
|
73
|
-
}
|
|
74
|
-
seen.add(value);
|
|
75
|
-
const children = Array.isArray(value) ? value : Object.values(requirePlainObject(value, label));
|
|
76
|
-
collectionEntries += children.length;
|
|
77
|
-
if (collectionEntries > limits.maxCollectionEntries) {
|
|
78
|
-
throw jsonError(
|
|
79
|
-
"collection-entries",
|
|
80
|
-
label,
|
|
81
|
-
"exceeds the collection-entry limit"
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
for (const child of children) {
|
|
85
|
-
stack.push({ value: child, depth: depth + 1 });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
var RuntimeJsonSchema = z.lazy(
|
|
90
|
-
() => z.union([
|
|
91
|
-
z.null(),
|
|
92
|
-
z.boolean(),
|
|
93
|
-
z.number().finite(),
|
|
94
|
-
z.string(),
|
|
95
|
-
z.array(RuntimeJsonSchema),
|
|
96
|
-
z.record(z.string(), RuntimeJsonSchema)
|
|
97
|
-
])
|
|
98
|
-
);
|
|
99
|
-
function parseJsonWithLimits(value, limits, label) {
|
|
100
|
-
assertJsonWithinLimits(value, limits, label);
|
|
101
|
-
return RuntimeJsonSchema.parse(value);
|
|
102
|
-
}
|
|
103
|
-
function parseBrowserAttributeJson(value) {
|
|
104
|
-
return parseJsonWithLimits(
|
|
105
|
-
value,
|
|
106
|
-
BROWSER_ATTRIBUTE_JSON_LIMITS,
|
|
107
|
-
"Browser interaction attribute"
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
BROWSER_ATTRIBUTE_JSON_LIMITS,
|
|
113
|
-
assertJsonWithinLimits,
|
|
114
|
-
RuntimeJsonSchema,
|
|
115
|
-
parseBrowserAttributeJson
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=chunk-PF7L4BMG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/runtime-json.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type RuntimeJson =\n | null\n | boolean\n | number\n | string\n | RuntimeJson[]\n | { [key: string]: RuntimeJson };\n\nexport type JsonLimits = {\n maxDepth: number;\n maxNodes: number;\n maxStringBytes: number;\n maxCollectionEntries: number;\n};\n\nexport type JsonValidationCode =\n | \"cycle\"\n | \"depth\"\n | \"nodes\"\n | \"string-bytes\"\n | \"collection-entries\"\n | \"non-json\";\n\nexport class JsonValidationError extends Error {\n constructor(\n public readonly code: JsonValidationCode,\n message: string,\n ) {\n super(message);\n this.name = \"JsonValidationError\";\n }\n}\n\nexport const TRANSPORT_JSON_LIMITS = {\n maxDepth: 64,\n maxNodes: 100_000,\n maxStringBytes: 1_048_576,\n maxCollectionEntries: 50_000,\n} as const satisfies JsonLimits;\n\nexport const BROWSER_ATTRIBUTE_JSON_LIMITS = {\n maxDepth: 32,\n maxNodes: 10_000,\n maxStringBytes: 65_536,\n maxCollectionEntries: 5_000,\n} as const satisfies JsonLimits;\n\nfunction jsonError(\n code: JsonValidationCode,\n label: string,\n detail: string,\n): JsonValidationError {\n return new JsonValidationError(code, `${label} ${detail}.`);\n}\n\nfunction requirePlainObject(\n value: object,\n label: string,\n): Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw jsonError(\"non-json\", label, \"contains a non-plain object\");\n }\n return value as Record<string, unknown>;\n}\n\nexport function assertJsonWithinLimits(\n root: unknown,\n limits: JsonLimits,\n label: string,\n): void {\n const stack: Array<{ value: unknown; depth: number }> = [\n { value: root, depth: 0 },\n ];\n const seen = new WeakSet<object>();\n const encoder = new TextEncoder();\n let nodes = 0;\n let stringBytes = 0;\n let collectionEntries = 0;\n\n while (stack.length > 0) {\n const item = stack.pop();\n if (!item) continue;\n const { value, depth } = item;\n\n nodes += 1;\n if (nodes > limits.maxNodes) {\n throw jsonError(\"nodes\", label, \"exceeds the node limit\");\n }\n if (depth > limits.maxDepth) {\n throw jsonError(\"depth\", label, \"exceeds the depth limit\");\n }\n\n switch (typeof value) {\n case \"string\":\n stringBytes += encoder.encode(value).byteLength;\n if (stringBytes > limits.maxStringBytes) {\n throw jsonError(\n \"string-bytes\",\n label,\n \"exceeds the string-byte limit\",\n );\n }\n continue;\n case \"number\":\n if (!Number.isFinite(value)) {\n throw jsonError(\"non-json\", label, \"contains a non-finite number\");\n }\n continue;\n case \"boolean\":\n continue;\n case \"object\":\n if (value === null) continue;\n break;\n default:\n throw jsonError(\"non-json\", label, \"contains a non-JSON value\");\n }\n\n if (seen.has(value)) {\n throw jsonError(\"cycle\", label, \"contains a cycle\");\n }\n seen.add(value);\n\n const children = Array.isArray(value)\n ? value\n : Object.values(requirePlainObject(value, label));\n collectionEntries += children.length;\n if (collectionEntries > limits.maxCollectionEntries) {\n throw jsonError(\n \"collection-entries\",\n label,\n \"exceeds the collection-entry limit\",\n );\n }\n for (const child of children) {\n stack.push({ value: child, depth: depth + 1 });\n }\n }\n}\n\nexport const RuntimeJsonSchema: z.ZodType<RuntimeJson> = z.lazy(() =>\n z.union([\n z.null(),\n z.boolean(),\n z.number().finite(),\n z.string(),\n z.array(RuntimeJsonSchema),\n z.record(z.string(), RuntimeJsonSchema),\n ]),\n);\n\nexport function parseJsonWithLimits(\n value: unknown,\n limits: JsonLimits,\n label: string,\n): RuntimeJson {\n assertJsonWithinLimits(value, limits, label);\n return RuntimeJsonSchema.parse(value);\n}\n\nexport function parseTransportJson(value: unknown): RuntimeJson {\n return parseJsonWithLimits(value, TRANSPORT_JSON_LIMITS, \"Runtime payload\");\n}\n\nexport function parseBrowserAttributeJson(value: unknown): RuntimeJson {\n return parseJsonWithLimits(\n value,\n BROWSER_ATTRIBUTE_JSON_LIMITS,\n \"Browser interaction attribute\",\n );\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAyBX,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAC7C,YACkB,MAChB,SACA;AACA,UAAM,OAAO;AAHG;AAIhB,SAAK,OAAO;AAAA,EACd;AAAA,EALkB;AAMpB;AASO,IAAM,gCAAgC;AAAA,EAC3C,UAAU;AAAA,EACV,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,sBAAsB;AACxB;AAEA,SAAS,UACP,MACA,OACA,QACqB;AACrB,SAAO,IAAI,oBAAoB,MAAM,GAAG,KAAK,IAAI,MAAM,GAAG;AAC5D;AAEA,SAAS,mBACP,OACA,OACyB;AACzB,QAAM,YAAY,OAAO,eAAe,KAAK;AAC7C,MAAI,cAAc,OAAO,aAAa,cAAc,MAAM;AACxD,UAAM,UAAU,YAAY,OAAO,6BAA6B;AAAA,EAClE;AACA,SAAO;AACT;AAEO,SAAS,uBACd,MACA,QACA,OACM;AACN,QAAM,QAAkD;AAAA,IACtD,EAAE,OAAO,MAAM,OAAO,EAAE;AAAA,EAC1B;AACA,QAAM,OAAO,oBAAI,QAAgB;AACjC,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,QAAQ;AACZ,MAAI,cAAc;AAClB,MAAI,oBAAoB;AAExB,SAAO,MAAM,SAAS,GAAG;AACvB,UAAM,OAAO,MAAM,IAAI;AACvB,QAAI,CAAC,KAAM;AACX,UAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,aAAS;AACT,QAAI,QAAQ,OAAO,UAAU;AAC3B,YAAM,UAAU,SAAS,OAAO,wBAAwB;AAAA,IAC1D;AACA,QAAI,QAAQ,OAAO,UAAU;AAC3B,YAAM,UAAU,SAAS,OAAO,yBAAyB;AAAA,IAC3D;AAEA,YAAQ,OAAO,OAAO;AAAA,MACpB,KAAK;AACH,uBAAe,QAAQ,OAAO,KAAK,EAAE;AACrC,YAAI,cAAc,OAAO,gBAAgB;AACvC,gBAAM;AAAA,YACJ;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AACA;AAAA,MACF,KAAK;AACH,YAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,gBAAM,UAAU,YAAY,OAAO,8BAA8B;AAAA,QACnE;AACA;AAAA,MACF,KAAK;AACH;AAAA,MACF,KAAK;AACH,YAAI,UAAU,KAAM;AACpB;AAAA,MACF;AACE,cAAM,UAAU,YAAY,OAAO,2BAA2B;AAAA,IAClE;AAEA,QAAI,KAAK,IAAI,KAAK,GAAG;AACnB,YAAM,UAAU,SAAS,OAAO,kBAAkB;AAAA,IACpD;AACA,SAAK,IAAI,KAAK;AAEd,UAAM,WAAW,MAAM,QAAQ,KAAK,IAChC,QACA,OAAO,OAAO,mBAAmB,OAAO,KAAK,CAAC;AAClD,yBAAqB,SAAS;AAC9B,QAAI,oBAAoB,OAAO,sBAAsB;AACnD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AACA,eAAW,SAAS,UAAU;AAC5B,YAAM,KAAK,EAAE,OAAO,OAAO,OAAO,QAAQ,EAAE,CAAC;AAAA,IAC/C;AAAA,EACF;AACF;AAEO,IAAM,oBAA4C,EAAE;AAAA,EAAK,MAC9D,EAAE,MAAM;AAAA,IACN,EAAE,KAAK;AAAA,IACP,EAAE,QAAQ;AAAA,IACV,EAAE,OAAO,EAAE,OAAO;AAAA,IAClB,EAAE,OAAO;AAAA,IACT,EAAE,MAAM,iBAAiB;AAAA,IACzB,EAAE,OAAO,EAAE,OAAO,GAAG,iBAAiB;AAAA,EACxC,CAAC;AACH;AAEO,SAAS,oBACd,OACA,QACA,OACa;AACb,yBAAuB,OAAO,QAAQ,KAAK;AAC3C,SAAO,kBAAkB,MAAM,KAAK;AACtC;AAMO,SAAS,0BAA0B,OAA6B;AACrE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-PN5O6GG2.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
collectReducerDefinitionIndex
|
|
3
|
-
} from "./chunk-H6VDGFL5.js";
|
|
4
|
-
|
|
5
|
-
// src/reducer/client-param-schemas.ts
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
function schemaForCollectors(collectors) {
|
|
8
|
-
const shape = {};
|
|
9
|
-
for (const [key, collector] of Object.entries(collectors)) {
|
|
10
|
-
if (collector.kind === "rng") continue;
|
|
11
|
-
const schema = collector.schema;
|
|
12
|
-
shape[key] = "defaultValue" in collector ? schema.default(collector.defaultValue) : schema;
|
|
13
|
-
}
|
|
14
|
-
return z.object(shape);
|
|
15
|
-
}
|
|
16
|
-
function createClientParamSchemasByPhase(definition) {
|
|
17
|
-
const index = collectReducerDefinitionIndex(definition);
|
|
18
|
-
const out = {};
|
|
19
|
-
for (const phaseIndex of index.phasesByName.values()) {
|
|
20
|
-
const phaseSchemas = {};
|
|
21
|
-
for (const [id, interaction] of phaseIndex.interactions) {
|
|
22
|
-
phaseSchemas[id] = interaction.paramsSchema ?? schemaForCollectors(interaction.inputs);
|
|
23
|
-
}
|
|
24
|
-
out[String(phaseIndex.phaseName)] = phaseSchemas;
|
|
25
|
-
}
|
|
26
|
-
return out;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
createClientParamSchemasByPhase
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=chunk-PN5O6GG2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/reducer/client-param-schemas.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { collectReducerDefinitionIndex } from \"./definition-index\";\nimport type {\n InputCollector,\n PhaseMapOf,\n ReducerGameContractLike,\n ReducerGameDefinition,\n ViewMapOf,\n} from \"./model\";\n\nexport type ClientParamSchema = {\n safeParse: (value: unknown) =>\n | { success: true; data: Record<string, unknown> }\n | {\n success: false;\n error: { issues: Array<{ path: PropertyKey[]; message: string }> };\n };\n};\n\nexport type ClientParamSchemasByPhase = Readonly<\n Record<string, Readonly<Record<string, ClientParamSchema>>>\n>;\n\nfunction schemaForCollectors(\n collectors: Record<string, InputCollector>,\n): ClientParamSchema {\n const shape: Record<string, z.ZodTypeAny> = {};\n for (const [key, collector] of Object.entries(collectors)) {\n if (collector.kind === \"rng\") continue;\n const schema = collector.schema as z.ZodTypeAny;\n shape[key] =\n \"defaultValue\" in collector\n ? schema.default(collector.defaultValue)\n : schema;\n }\n return z.object(shape) as unknown as ClientParamSchema;\n}\n\nexport function createClientParamSchemasByPhase<\n Contract extends ReducerGameContractLike,\n Definitions extends PhaseMapOf<Contract>,\n Views extends ViewMapOf<Contract>,\n>(\n definition: ReducerGameDefinition<Contract, Definitions, Views>,\n): ClientParamSchemasByPhase {\n const index = collectReducerDefinitionIndex(definition);\n const out: Record<string, Record<string, ClientParamSchema>> = {};\n for (const phaseIndex of index.phasesByName.values()) {\n const phaseSchemas: Record<string, ClientParamSchema> = {};\n for (const [id, interaction] of phaseIndex.interactions) {\n phaseSchemas[id] =\n interaction.paramsSchema ?? schemaForCollectors(interaction.inputs);\n }\n out[String(phaseIndex.phaseName)] = phaseSchemas;\n }\n return out;\n}\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAuBlB,SAAS,oBACP,YACmB;AACnB,QAAM,QAAsC,CAAC;AAC7C,aAAW,CAAC,KAAK,SAAS,KAAK,OAAO,QAAQ,UAAU,GAAG;AACzD,QAAI,UAAU,SAAS,MAAO;AAC9B,UAAM,SAAS,UAAU;AACzB,UAAM,GAAG,IACP,kBAAkB,YACd,OAAO,QAAQ,UAAU,YAAY,IACrC;AAAA,EACR;AACA,SAAO,EAAE,OAAO,KAAK;AACvB;AAEO,SAAS,gCAKd,YAC2B;AAC3B,QAAM,QAAQ,8BAA8B,UAAU;AACtD,QAAM,MAAyD,CAAC;AAChE,aAAW,cAAc,MAAM,aAAa,OAAO,GAAG;AACpD,UAAM,eAAkD,CAAC;AACzD,eAAW,CAAC,IAAI,WAAW,KAAK,WAAW,cAAc;AACvD,mBAAa,EAAE,IACb,YAAY,gBAAgB,oBAAoB,YAAY,MAAM;AAAA,IACtE;AACA,QAAI,OAAO,WAAW,SAAS,CAAC,IAAI;AAAA,EACtC;AACA,SAAO;AACT;","names":[]}
|
package/dist/chunk-PZ5AY32C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|