@dreamboard-games/sdk 0.5.0-alpha.0 → 0.5.0-alpha.1
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 +122 -0
- package/dist/authoring/index.js +3 -3
- package/dist/authoring-compiler.js +4 -4
- package/dist/{authoring-materialize-cli.js → authoring-generate-cli.js} +6 -6
- package/dist/authoring-generate-cli.js.map +1 -0
- package/dist/{chunk-HUK4234C.js → chunk-2WJSQQT7.js} +3 -3
- package/dist/{chunk-VRRR6QZT.js → chunk-32PFKDV7.js} +170 -406
- package/dist/chunk-32PFKDV7.js.map +1 -0
- package/dist/{chunk-N33CGX2F.js → chunk-3BAD4VC2.js} +3 -3
- package/dist/{chunk-LMHCGCA6.js → chunk-3SKDNDPG.js} +2 -2
- package/dist/{chunk-6LMESVGT.js → chunk-4ZKTGZZK.js} +3 -3
- package/dist/{chunk-533O7C4L.js → chunk-7M3N5DFJ.js} +500 -430
- package/dist/chunk-7M3N5DFJ.js.map +1 -0
- package/dist/{chunk-FL67RDID.js → chunk-EHPEMPRZ.js} +128 -128
- package/dist/chunk-EHPEMPRZ.js.map +1 -0
- package/dist/chunk-EY2LL5WD.js +9 -0
- package/dist/{chunk-DQS2EG5E.js → chunk-GDPKTBUR.js} +2 -2
- package/dist/{chunk-HIH6Y4FA.js → chunk-JUGQ6F3N.js} +88 -352
- package/dist/{chunk-HIH6Y4FA.js.map → chunk-JUGQ6F3N.js.map} +1 -1
- package/dist/{chunk-VWTKGIYF.js → chunk-K2JGSRMD.js} +1 -1
- package/dist/{chunk-ZSTCUJKZ.js → chunk-M2S3QC32.js} +2 -2
- package/dist/{chunk-KRJPRYEA.js → chunk-MIKC4Y67.js} +5 -5
- package/dist/{chunk-KRJPRYEA.js.map → chunk-MIKC4Y67.js.map} +1 -1
- package/dist/chunk-MYKS6MTR.js +1347 -0
- package/dist/chunk-MYKS6MTR.js.map +1 -0
- package/dist/{chunk-KGV2EUNN.js → chunk-QLSK3DYO.js} +3 -3
- package/dist/{chunk-2GQIALJL.js → chunk-UGH54WZ2.js} +6 -2
- package/dist/chunk-UGH54WZ2.js.map +1 -0
- package/dist/chunk-VCDWP5VL.js +746 -0
- package/dist/chunk-VCDWP5VL.js.map +1 -0
- package/dist/{chunk-TXELBVTG.js → chunk-VZ7N6WAQ.js} +2 -2
- package/dist/{chunk-EOEA3I64.js → chunk-XRS4AZFK.js} +5 -5
- package/dist/codegen.d.ts +1 -3
- package/dist/codegen.js +1 -5
- package/dist/{components-CNAt5J1p.d.ts → components-CuBO6rev.d.ts} +2 -18
- package/dist/{definitions-bZSBaPjj.d.ts → definitions-1Hj-pQU8.d.ts} +2 -2
- package/dist/digest.d.ts +2 -2
- package/dist/game-g9dDFYyU.d.ts +546 -0
- package/dist/{index-CR69MyWr.d.ts → index-Bxbv3c9W.d.ts} +1 -1
- package/dist/{index.d-Bw8AOcgp.d.ts → index.d-DjzoK7zn.d.ts} +67 -2
- package/dist/index.js +2 -2
- package/dist/package-set.js +2 -2
- package/dist/plugin-runtime-contract.d.ts +4 -4
- package/dist/plugin-runtime-contract.js +13 -15
- package/dist/{protocol-CVaSqPgX.d.ts → protocol-dYgafTYY.d.ts} +1 -7
- package/dist/reducer/advanced.d.ts +6 -5
- package/dist/reducer/advanced.js +8 -4
- package/dist/reducer-contract.d.ts +1 -1
- package/dist/reducer-contract.js +2 -2
- package/dist/reducer.d.ts +9 -689
- package/dist/reducer.js +15 -1293
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +3 -4
- package/dist/runtime/primitives.js +5 -5
- package/dist/runtime/runtime-api.d.ts +1 -2
- package/dist/runtime/workspace-contract.d.ts +19 -15
- package/dist/runtime/workspace-contract.js +11 -10
- package/dist/{runtime-C7Z2acNU.d.ts → runtime-DksMTWtC.d.ts} +2 -2
- package/dist/{plugin-state-BRH3UiUp.d.ts → runtime-api-C9bDgp63.d.ts} +83 -4
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +14 -13
- package/dist/runtime.js.map +1 -1
- package/dist/schema.d.ts +2 -28
- package/dist/testing-compiler.d.ts +4 -4
- package/dist/testing-runtime.d.ts +7 -7
- package/dist/testing-runtime.js +6 -6
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +8 -8
- package/dist/{types-q1Guidm5.d.ts → types-DR7DoB1x.d.ts} +1 -1
- package/dist/{types-DN4O7kH_.d.ts → types-Dlh4GsNp.d.ts} +2 -2
- package/dist/ui/components.d.ts +3 -4
- package/dist/ui/components.js +1 -5
- package/dist/{ui-contract-BC4JpysE.d.ts → ui-contract-Mgx_k9gm.d.ts} +1 -2
- package/dist/ui.d.ts +4 -5
- package/dist/ui.js +2 -6
- package/dist/{views-D2Cfzr3h.d.ts → views-B4lD4fT0.d.ts} +100 -47
- package/package.json +4 -4
- package/dist/authoring-materialize-cli.js.map +0 -1
- package/dist/chunk-2GQIALJL.js.map +0 -1
- package/dist/chunk-533O7C4L.js.map +0 -1
- package/dist/chunk-FL67RDID.js.map +0 -1
- package/dist/chunk-KWHOFBDM.js +0 -9
- package/dist/chunk-VRRR6QZT.js.map +0 -1
- package/dist/chunk-XFMSLL3P.js +0 -637
- package/dist/chunk-XFMSLL3P.js.map +0 -1
- package/dist/runtime-api-CgPuEVeF.d.ts +0 -86
- /package/dist/{authoring-materialize-cli.d.ts → authoring-generate-cli.d.ts} +0 -0
- /package/dist/{chunk-HUK4234C.js.map → chunk-2WJSQQT7.js.map} +0 -0
- /package/dist/{chunk-N33CGX2F.js.map → chunk-3BAD4VC2.js.map} +0 -0
- /package/dist/{chunk-LMHCGCA6.js.map → chunk-3SKDNDPG.js.map} +0 -0
- /package/dist/{chunk-6LMESVGT.js.map → chunk-4ZKTGZZK.js.map} +0 -0
- /package/dist/{chunk-KWHOFBDM.js.map → chunk-EY2LL5WD.js.map} +0 -0
- /package/dist/{chunk-DQS2EG5E.js.map → chunk-GDPKTBUR.js.map} +0 -0
- /package/dist/{chunk-VWTKGIYF.js.map → chunk-K2JGSRMD.js.map} +0 -0
- /package/dist/{chunk-ZSTCUJKZ.js.map → chunk-M2S3QC32.js.map} +0 -0
- /package/dist/{chunk-KGV2EUNN.js.map → chunk-QLSK3DYO.js.map} +0 -0
- /package/dist/{chunk-TXELBVTG.js.map → chunk-VZ7N6WAQ.js.map} +0 -0
- /package/dist/{chunk-EOEA3I64.js.map → chunk-XRS4AZFK.js.map} +0 -0
package/README.md
CHANGED
|
@@ -36,6 +36,128 @@ Include the packaged stylesheet when using SDK UI components:
|
|
|
36
36
|
import "@dreamboard-games/sdk/ui/plugin-styles.css";
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
## Game authoring
|
|
40
|
+
|
|
41
|
+
`createGame(model)` is the single authoring entry point. The **model** is a
|
|
42
|
+
plain object: manifest ids, state schemas, one Zod schema per phase, and error
|
|
43
|
+
codes. The returned value is three things at once:
|
|
44
|
+
|
|
45
|
+
- the **type leaf**: `typeof game.types.State`, `.ErrorCode`, `.PlayerId`,
|
|
46
|
+
`.Queries`, `.Tx` (phantom carriers; reading them at runtime throws),
|
|
47
|
+
- the **factory namespace**: `game.phase(name)`, `phase.define`,
|
|
48
|
+
`phase.interaction`, `phase.inputs.*`, `game.views.*`,
|
|
49
|
+
- the **assembler**: `game.assemble({ initial, initialPhase, phases, views })`.
|
|
50
|
+
|
|
51
|
+
Mutation callbacks (`enter`, `reduce`, `resolve`) receive an open transaction
|
|
52
|
+
`tx`. Mutate through it and finish with a bare `return` (accept), or with
|
|
53
|
+
`tx.transition(name)`, `tx.endGame(outcome)`, or `tx.reject(code)`. Events go
|
|
54
|
+
through `tx.emit(...)`. `state` is the read-only snapshot the callback started
|
|
55
|
+
from; `tx.state` is the current draft.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// app/game-model.ts — the model, bound once
|
|
59
|
+
import { z } from "zod";
|
|
60
|
+
import { createGame } from "@dreamboard-games/sdk/reducer";
|
|
61
|
+
import { ids, manifestContract } from "../shared/manifest-contract";
|
|
62
|
+
|
|
63
|
+
export const game = createGame({
|
|
64
|
+
manifest: manifestContract,
|
|
65
|
+
state: {
|
|
66
|
+
public: z.object({ currentPlayerId: ids.playerId.nullable() }),
|
|
67
|
+
private: z.object({}),
|
|
68
|
+
hidden: z.object({}),
|
|
69
|
+
},
|
|
70
|
+
phases: {
|
|
71
|
+
setup: z.object({}),
|
|
72
|
+
play: z.object({ leadCardId: ids.cardId.nullable() }),
|
|
73
|
+
},
|
|
74
|
+
errors: { NOT_YOUR_CARD: "Play a card from your own hand." },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export type GameState = typeof game.types.State;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// app/phases/play.ts — one phase, one file
|
|
82
|
+
import { game } from "../game-model";
|
|
83
|
+
|
|
84
|
+
const play = game.phase("play");
|
|
85
|
+
|
|
86
|
+
// Inputs name their candidate domain and eligibility predicates directly.
|
|
87
|
+
// `where.errorCode` is checked against `model.errors`.
|
|
88
|
+
const ownCard = play.inputs.card({
|
|
89
|
+
from: ["hand"],
|
|
90
|
+
where: {
|
|
91
|
+
id: "own-card",
|
|
92
|
+
errorCode: "NOT_YOUR_CARD",
|
|
93
|
+
test: ({ q, playerId, targetId }) =>
|
|
94
|
+
q.zone.playerCards(playerId, "hand").includes(targetId),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export default play.define({
|
|
99
|
+
kind: "player",
|
|
100
|
+
initialState: () => ({ leadCardId: null }),
|
|
101
|
+
actor: ({ state }) => state.publicState.currentPlayerId,
|
|
102
|
+
interactions: {
|
|
103
|
+
playCard: play.interaction({
|
|
104
|
+
inputs: { cardId: ownCard },
|
|
105
|
+
reduce({ tx, input, q }) {
|
|
106
|
+
// tx.state.phase.leadCardId and input.params.cardId are inferred.
|
|
107
|
+
tx.moveCardFromPlayerZoneToSharedZone({
|
|
108
|
+
playerId: input.playerId,
|
|
109
|
+
fromZoneId: "hand",
|
|
110
|
+
toZoneId: "trick",
|
|
111
|
+
cardId: input.params.cardId,
|
|
112
|
+
});
|
|
113
|
+
tx.patchPhaseState({ leadCardId: input.params.cardId });
|
|
114
|
+
const next = q.player.nextInOrder(input.playerId);
|
|
115
|
+
if (next) tx.setActivePlayers([next]);
|
|
116
|
+
if (q.zone.playerCards(input.playerId, "hand").length === 0) {
|
|
117
|
+
return tx.transition("setup");
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
// app/game.ts — assembly
|
|
127
|
+
import { game } from "./game-model";
|
|
128
|
+
import play from "./phases/play";
|
|
129
|
+
import setup from "./phases/setup";
|
|
130
|
+
|
|
131
|
+
export default game.assemble({
|
|
132
|
+
initial: {
|
|
133
|
+
public: ({ playerIds }) => ({ currentPlayerId: playerIds[0] ?? null }),
|
|
134
|
+
private: () => ({}),
|
|
135
|
+
hidden: () => ({}),
|
|
136
|
+
},
|
|
137
|
+
initialPhase: "setup",
|
|
138
|
+
phases: { setup, play },
|
|
139
|
+
views: {
|
|
140
|
+
shared: game.views.empty(),
|
|
141
|
+
player: game.views.player({
|
|
142
|
+
project: ({ state, playerId, q }) => ({
|
|
143
|
+
me: playerId,
|
|
144
|
+
hand: q.zone.playerCards(playerId, "hand"),
|
|
145
|
+
current: state.publicState.currentPlayerId,
|
|
146
|
+
}),
|
|
147
|
+
}),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
A missing, extra, or misspelled phase key fails to typecheck at `assemble`
|
|
153
|
+
or at `game.phase(name)`. Rules, views, and tests import `GameState` and
|
|
154
|
+
`typeof game.types.Tx` from the model module; nothing but the test harness
|
|
155
|
+
imports the assembled game, so there is no import cycle.
|
|
156
|
+
|
|
157
|
+
New workspaces keep authored starter code in `app/game.ts` and `ui/App.tsx`.
|
|
158
|
+
Run the package-local `pnpm generate` command to refresh framework-owned
|
|
159
|
+
manifest and UI contracts; generated files are not authoring surfaces.
|
|
160
|
+
|
|
39
161
|
## Reducer runner contract
|
|
40
162
|
|
|
41
163
|
`createReducerBundle(game)` returns exactly the contract version and four
|
package/dist/authoring/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
materializeManifest,
|
|
8
8
|
projectAuthoringAdapter,
|
|
9
9
|
validateManifest
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-QLSK3DYO.js";
|
|
11
|
+
import "../chunk-EY2LL5WD.js";
|
|
12
|
+
import "../chunk-JUGQ6F3N.js";
|
|
13
13
|
import "../chunk-PZ5AY32C.js";
|
|
14
14
|
export {
|
|
15
15
|
GENERATED_WORKSPACE_PATHS,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
materializeWorkspace
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-2WJSQQT7.js";
|
|
4
|
+
import "./chunk-QLSK3DYO.js";
|
|
5
|
+
import "./chunk-EY2LL5WD.js";
|
|
6
|
+
import "./chunk-JUGQ6F3N.js";
|
|
7
7
|
import "./chunk-PZ5AY32C.js";
|
|
8
8
|
export {
|
|
9
9
|
materializeWorkspace
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
materializeWorkspace
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-2WJSQQT7.js";
|
|
5
|
+
import "./chunk-QLSK3DYO.js";
|
|
6
|
+
import "./chunk-EY2LL5WD.js";
|
|
7
|
+
import "./chunk-JUGQ6F3N.js";
|
|
8
8
|
import "./chunk-PZ5AY32C.js";
|
|
9
9
|
|
|
10
|
-
// src/authoring-
|
|
10
|
+
// src/authoring-generate-cli.ts
|
|
11
11
|
var options = parseArgs(process.argv.slice(2));
|
|
12
12
|
var result = await materializeWorkspace(options);
|
|
13
13
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -42,4 +42,4 @@ function parseArgs(argv) {
|
|
|
42
42
|
...writeMissingSeeds ? { writeMissingSeeds: true } : {}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
//# sourceMappingURL=authoring-
|
|
45
|
+
//# sourceMappingURL=authoring-generate-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/authoring-generate-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { materializeWorkspace } from \"./authoring/materialize-workspace.js\";\n\nconst options = parseArgs(process.argv.slice(2));\nconst result = await materializeWorkspace(options);\nconsole.log(JSON.stringify(result, null, 2));\n\nfunction parseArgs(argv: readonly string[]): {\n readonly manifestPath: string;\n readonly projectRoot?: string;\n readonly writeMissingSeeds?: boolean;\n} {\n let manifestPath: string | undefined;\n let projectRoot: string | undefined;\n let writeMissingSeeds = false;\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index];\n if (arg === \"--manifest\") {\n manifestPath = argv[index + 1];\n index += 1;\n continue;\n }\n if (arg === \"--project-root\") {\n projectRoot = argv[index + 1];\n index += 1;\n continue;\n }\n if (arg === \"--write-missing-seeds\") {\n writeMissingSeeds = true;\n continue;\n }\n throw new Error(`Unknown argument '${arg}'.`);\n }\n if (!manifestPath) {\n throw new Error(\"--manifest is required.\");\n }\n return {\n manifestPath,\n ...(projectRoot === undefined ? {} : { projectRoot }),\n ...(writeMissingSeeds ? { writeMissingSeeds: true } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAM,UAAU,UAAU,QAAQ,KAAK,MAAM,CAAC,CAAC;AAC/C,IAAM,SAAS,MAAM,qBAAqB,OAAO;AACjD,QAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAE3C,SAAS,UAAU,MAIjB;AACA,MAAI;AACJ,MAAI;AACJ,MAAI,oBAAoB;AACxB,WAAS,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,MAAM,KAAK,KAAK;AACtB,QAAI,QAAQ,cAAc;AACxB,qBAAe,KAAK,QAAQ,CAAC;AAC7B,eAAS;AACT;AAAA,IACF;AACA,QAAI,QAAQ,kBAAkB;AAC5B,oBAAc,KAAK,QAAQ,CAAC;AAC5B,eAAS;AACT;AAAA,IACF;AACA,QAAI,QAAQ,yBAAyB;AACnC,0BAAoB;AACpB;AAAA,IACF;AACA,UAAM,IAAI,MAAM,qBAAqB,GAAG,IAAI;AAAA,EAC9C;AACA,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,yBAAyB;AAAA,EAC3C;AACA,SAAO;AAAA,IACL;AAAA,IACA,GAAI,gBAAgB,SAAY,CAAC,IAAI,EAAE,YAAY;AAAA,IACnD,GAAI,oBAAoB,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAAA,EACzD;AACF;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateWorkspaceArtifacts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QLSK3DYO.js";
|
|
4
4
|
import {
|
|
5
5
|
WORKSPACE_CODEGEN_OWNERSHIP
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JUGQ6F3N.js";
|
|
7
7
|
|
|
8
8
|
// src/authoring/materialize-workspace.ts
|
|
9
9
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -163,4 +163,4 @@ async function isFile(filePath) {
|
|
|
163
163
|
export {
|
|
164
164
|
materializeWorkspace
|
|
165
165
|
};
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-2WJSQQT7.js.map
|