@dreamboard-games/sdk 0.5.0-alpha.7 → 0.5.0-alpha.9
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 +10 -1
- package/dist/{chunk-3JXUL4VN.js → chunk-DPRHGA2C.js} +2 -2
- package/dist/chunk-DPRHGA2C.js.map +1 -0
- package/dist/{chunk-K75F5UIJ.js → chunk-FUYMFUXO.js} +305 -288
- package/dist/chunk-FUYMFUXO.js.map +1 -0
- package/dist/{chunk-UESVBUPU.js → chunk-LBUAMC7E.js} +21 -21
- package/dist/chunk-LBUAMC7E.js.map +1 -0
- package/dist/{chunk-N37D7NPB.js → chunk-QHYXNDJS.js} +13 -22
- package/dist/chunk-QHYXNDJS.js.map +1 -0
- package/dist/{chunk-HZPKKBEG.js → chunk-ZH5BENBP.js} +4 -4
- package/dist/chunk-ZH5BENBP.js.map +1 -0
- package/dist/{diagnostics-9gJgI85c.d.ts → diagnostics-7D8Bo8Ve.d.ts} +2 -2
- package/dist/{extract-Bjuw_gdF.d.ts → extract--xGrzaA9.d.ts} +127 -99
- package/dist/index.d.ts +89 -17
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/{model-D2Z9j0Yi.d.ts → model-BvimcW9Q.d.ts} +8 -13
- package/dist/react.d.ts +9 -5
- package/dist/react.js +12 -6
- package/dist/react.js.map +1 -1
- package/dist/reducer.d.ts +15 -14
- package/dist/reducer.js +15 -15
- package/dist/reducer.js.map +1 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +8 -8
- package/dist/testing.js.map +1 -1
- package/dist/{types-B3kIhBWb.d.ts → types-Dkcj6g_z.d.ts} +3 -3
- package/package.json +1 -1
- package/dist/chunk-3JXUL4VN.js.map +0 -1
- package/dist/chunk-HZPKKBEG.js.map +0 -1
- package/dist/chunk-K75F5UIJ.js.map +0 -1
- package/dist/chunk-N37D7NPB.js.map +0 -1
- package/dist/chunk-UESVBUPU.js.map +0 -1
package/README.md
CHANGED
|
@@ -234,7 +234,7 @@ To migrate an older manifest, replace each card's `type` with `id` and set
|
|
|
234
234
|
|
|
235
235
|
`createReducerBundle(game)` returns exactly the contract version and four
|
|
236
236
|
operations: `boardStatic()`, `initialize(input)`, `dispatch({ state, input })`,
|
|
237
|
-
and `project({ state, playerIds })`. The runner contract is `0.
|
|
237
|
+
and `project({ state, playerIds })`. The runner contract is `0.9.0`; hosts must
|
|
238
238
|
require that exact version. Dispatch includes validation, direct transaction mutations, and phase entry.
|
|
239
239
|
Initialization returns
|
|
240
240
|
`{ state, terminal?, events? }`, preserving outcomes and events from initial
|
|
@@ -325,6 +325,15 @@ and gameplay websocket schemas plus `materializePluginGameplayFrame` live at the
|
|
|
325
325
|
root. Materialize the seat projection with static board data before publishing it;
|
|
326
326
|
sources publish the canonical seat view and keep command bases private.
|
|
327
327
|
|
|
328
|
+
Visible cards share one complete `ViewCard` shape: `id`, `cardType`, and JSON
|
|
329
|
+
`properties`, plus optional `name`, `text`, `frontImage`, and `backImage`.
|
|
330
|
+
`ViewCardSchema` validates this shape. Reducer and gameplay `cardViewsById` maps
|
|
331
|
+
contain these objects directly. Headless `card.view` preserves the manifest's
|
|
332
|
+
card identity, category, and property inference and is deeply readonly; table-only
|
|
333
|
+
`cardSetId` and `componentType` are absent. Concealed cards have a positional
|
|
334
|
+
`hidden:<zone>:<index>` identity, no view, and an optional separate `cardBacksById` entry.
|
|
335
|
+
This wire format requires plugin protocol version 8 and reducer contract `0.9.0`.
|
|
336
|
+
|
|
328
337
|
Card sets contain their authored `cards`, `cardSchema`, and `defaultHome` directly.
|
|
329
338
|
Standard playing cards are game-owned definitions with ordinary suit/rank
|
|
330
339
|
properties; the SDK does not synthesize inventories or assign built-in rules.
|
|
@@ -11,7 +11,7 @@ function requireLookup(value, kind, id) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// src/shared/board-target.ts
|
|
14
|
-
import
|
|
14
|
+
import * as z from "zod";
|
|
15
15
|
var PlayerBoardSpaceTargetSchema = z.strictObject({
|
|
16
16
|
boardId: z.string(),
|
|
17
17
|
playerId: z.string(),
|
|
@@ -136,4 +136,4 @@ export {
|
|
|
136
136
|
inputTargetInDomain,
|
|
137
137
|
inputValueKey
|
|
138
138
|
};
|
|
139
|
-
//# sourceMappingURL=chunk-
|
|
139
|
+
//# sourceMappingURL=chunk-DPRHGA2C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/lookup.ts","../src/shared/board-target.ts","../src/shared/input-domain.ts"],"sourcesContent":["/** Assert presence at a mutable table or projected-snapshot lookup boundary. */\nexport function requireLookup<T>(\n value: T | undefined,\n kind: string,\n id: string,\n): T {\n if (value === undefined) throw new Error(`${kind} \"${id}\" is not present.`);\n return value;\n}\n","import * as z from \"zod\";\n\n/** A space on one player's board; boardId is the base manifest board ID. */\nexport type PlayerBoardSpaceTarget<\n BoardId extends string = string,\n SpaceId extends string = string,\n PlayerId extends string = string,\n> = {\n readonly boardId: BoardId;\n readonly playerId: PlayerId;\n readonly spaceId: SpaceId;\n};\n\nexport const PlayerBoardSpaceTargetSchema = z.strictObject({\n boardId: z.string(),\n playerId: z.string(),\n spaceId: z.string(),\n});\n\nexport function isPlayerBoardSpaceTarget(\n value: unknown,\n): value is PlayerBoardSpaceTarget {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.keys(value).length === 3 &&\n \"boardId\" in value &&\n typeof value.boardId === \"string\" &&\n \"playerId\" in value &&\n typeof value.playerId === \"string\" &&\n \"spaceId\" in value &&\n typeof value.spaceId === \"string\"\n );\n}\n\nexport function samePlayerBoardSpaceTarget(\n left: PlayerBoardSpaceTarget,\n right: PlayerBoardSpaceTarget,\n): boolean {\n return (\n left.boardId === right.boardId &&\n left.playerId === right.playerId &&\n left.spaceId === right.spaceId\n );\n}\n","import {\n isPlayerBoardSpaceTarget,\n samePlayerBoardSpaceTarget,\n} from \"./board-target\";\nimport type {\n InputDomainDescriptor,\n InputSelectionDescriptor,\n} from \"../reducer/model/spec/inputs\";\n\n/** Projected domain rules only; schemas and authored target checks remain server-owned. */\nexport function inputDomainErrors(\n domain: InputDomainDescriptor,\n value: unknown,\n selection?: InputSelectionDescriptor,\n options: { ignoreMinimum?: boolean } = {},\n): string[] {\n if (selection?.mode === \"many\") {\n if (!Array.isArray(value)) return [\"Expected a list of values.\"];\n const errors = cardinalityErrors(\n value,\n selection.min,\n selection.max,\n \"value\",\n options.ignoreMinimum,\n );\n if (\n selection.distinct &&\n new Set(value.map(inputValueKey)).size !== value.length\n )\n errors.push(\"Choose each value only once.\");\n if (\n value.some(\n (item) =>\n inputDomainErrors(domain, item, undefined, options).length > 0,\n )\n )\n errors.push(ineligibleMessage(domain));\n return errors;\n }\n switch (domain.type) {\n case \"choice\":\n return inputTargetInDomain(domain, value)\n ? []\n : [ineligibleMessage(domain)];\n case \"choiceList\": {\n if (!Array.isArray(value)) return [\"Expected a list of choices.\"];\n const errors = cardinalityErrors(\n value,\n domain.min ?? 0,\n domain.max ?? domain.choices.length,\n \"option\",\n options.ignoreMinimum,\n );\n if (value.some((item) => !inputTargetInDomain(domain, item)))\n errors.push(ineligibleMessage(domain));\n return errors;\n }\n case \"cardTarget\":\n case \"boardTarget\":\n return inputTargetInDomain(domain, value)\n ? []\n : [ineligibleMessage(domain)];\n case \"boundedNumber\":\n return typeof value === \"number\" &&\n value >= domain.min &&\n value <= domain.max &&\n Math.abs(\n (value - domain.min) / (domain.step ?? 1) -\n Math.round((value - domain.min) / (domain.step ?? 1)),\n ) < 1e-9\n ? []\n : [\"Value is outside the current input domain.\"];\n case \"resourceMap\":\n return typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).every((key) =>\n domain.resources.some((entry) => entry.resourceId === key),\n ) &&\n domain.resources.every((entry) => {\n const amount =\n (value as Record<string, unknown>)[entry.resourceId] ?? 0;\n return (\n typeof amount === \"number\" &&\n Number.isInteger(amount) &&\n amount >= (entry.min ?? 0) &&\n amount <= (entry.max ?? Infinity)\n );\n })\n ? []\n : [\"Value is outside the current input domain.\"];\n }\n}\n\nexport function inputValueInDomain(\n domain: InputDomainDescriptor,\n value: unknown,\n selection?: InputSelectionDescriptor,\n options: { ignoreMinimum?: boolean } = {},\n): boolean {\n return inputDomainErrors(domain, value, selection, options).length === 0;\n}\n\n/** One selectable option, including an option within a choiceList or many input. */\nexport function inputTargetInDomain(\n domain: InputDomainDescriptor,\n value: unknown,\n): boolean {\n switch (domain.type) {\n case \"choice\":\n case \"choiceList\":\n return domain.choices.some(\n (choice) => !choice.disabled && Object.is(choice.value, value),\n );\n case \"cardTarget\":\n return (\n typeof value === \"string\" && domain.eligibleTargets.includes(value)\n );\n case \"boardTarget\":\n return domain.valueKind === \"player-board-space\"\n ? isPlayerBoardSpaceTarget(value) &&\n domain.eligibleTargets.some((candidate) =>\n samePlayerBoardSpaceTarget(candidate, value),\n )\n : typeof value === \"string\" && domain.eligibleTargets.includes(value);\n default:\n return inputValueInDomain(domain, value);\n }\n}\n\nfunction cardinalityErrors(\n value: readonly unknown[],\n min: number,\n max: number | undefined,\n unit: string,\n ignoreMinimum = false,\n): string[] {\n const errors: string[] = [];\n if (!ignoreMinimum && value.length < min)\n errors.push(`Choose at least ${min} ${pluralize(unit, min)}.`);\n if (max !== undefined && value.length > max)\n errors.push(`Choose at most ${max} ${pluralize(unit, max)}.`);\n return errors;\n}\n\nfunction ineligibleMessage(domain: InputDomainDescriptor): string {\n return domain.type === \"choice\" || domain.type === \"choiceList\"\n ? \"Selected choice is not eligible.\"\n : domain.type === \"cardTarget\" || domain.type === \"boardTarget\"\n ? \"Selected target is not eligible.\"\n : \"Value is outside the current input domain.\";\n}\n\n/** Matches the reducer's JSON value identity for projected distinct selections. */\nexport function inputValueKey(value: unknown): string {\n if (value === null) return \"null\";\n if (isPlayerBoardSpaceTarget(value))\n return `player-board-space:${JSON.stringify([value.boardId, value.playerId, value.spaceId])}`;\n switch (typeof value) {\n case \"string\":\n return `string:${value}`;\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n return `${typeof value}:${String(value)}`;\n default:\n return `json:${JSON.stringify(value)}`;\n }\n}\n\nfunction pluralize(word: string, count: number): string {\n return count === 1 ? word : `${word}s`;\n}\n"],"mappings":";;;;;;;AACO,SAAS,cACd,OACA,MACA,IACG;AACH,MAAI,UAAU,OAAW,OAAM,IAAI,MAAM,GAAG,IAAI,KAAK,EAAE,mBAAmB;AAC1E,SAAO;AACT;;;ACRA,YAAY,OAAO;AAaZ,IAAM,+BAAiC,eAAa;AAAA,EACzD,SAAW,SAAO;AAAA,EAClB,UAAY,SAAO;AAAA,EACnB,SAAW,SAAO;AACpB,CAAC;AAEM,SAAS,yBACd,OACiC;AACjC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAO,KAAK,KAAK,EAAE,WAAW,KAC9B,aAAa,SACb,OAAO,MAAM,YAAY,YACzB,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;AAEO,SAAS,2BACd,MACA,OACS;AACT,SACE,KAAK,YAAY,MAAM,WACvB,KAAK,aAAa,MAAM,YACxB,KAAK,YAAY,MAAM;AAE3B;;;AClCO,SAAS,kBACd,QACA,OACA,WACA,UAAuC,CAAC,GAC9B;AACV,MAAI,WAAW,SAAS,QAAQ;AAC9B,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC,4BAA4B;AAC/D,UAAM,SAAS;AAAA,MACb;AAAA,MACA,UAAU;AAAA,MACV,UAAU;AAAA,MACV;AAAA,MACA,QAAQ;AAAA,IACV;AACA,QACE,UAAU,YACV,IAAI,IAAI,MAAM,IAAI,aAAa,CAAC,EAAE,SAAS,MAAM;AAEjD,aAAO,KAAK,8BAA8B;AAC5C,QACE,MAAM;AAAA,MACJ,CAAC,SACC,kBAAkB,QAAQ,MAAM,QAAW,OAAO,EAAE,SAAS;AAAA,IACjE;AAEA,aAAO,KAAK,kBAAkB,MAAM,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