castle-web-cli 0.4.228 → 0.4.230
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/dist/agent-prompts.d.ts +11 -3
- package/dist/agent-prompts.js +153 -53
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +43 -33
- package/dist/api.d.ts +47 -2
- package/dist/api.js +85 -16
- package/dist/castle-host/host.d.ts +91 -0
- package/dist/castle-host/host.js +779 -3
- package/dist/castleJson.d.ts +59 -0
- package/dist/castleJson.js +267 -3
- package/dist/check.js +27 -1
- package/dist/cloudGit.d.ts +20 -1
- package/dist/cloudGit.js +267 -10
- package/dist/contentPack.d.ts +49 -0
- package/dist/contentPack.js +273 -0
- package/dist/devExperiments.d.ts +21 -0
- package/dist/devExperiments.js +139 -0
- package/dist/devHub.d.ts +55 -0
- package/dist/devHub.js +187 -0
- package/dist/devSessionChild.js +3 -1
- package/dist/devSessionServer.d.ts +14 -1
- package/dist/devSessionServer.js +229 -44
- package/dist/experimentAssignment.d.ts +15 -0
- package/dist/experimentAssignment.js +41 -0
- package/dist/importCheckHook.d.ts +40 -0
- package/dist/importCheckHook.js +171 -0
- package/dist/importRegression.d.ts +15 -0
- package/dist/importRegression.js +100 -0
- package/dist/importTrust.d.ts +2 -0
- package/dist/importTrust.js +27 -0
- package/dist/importUpdateHook.d.ts +18 -0
- package/dist/importUpdateHook.js +31 -8
- package/dist/importUpdateHookRunner.js +19 -7
- package/dist/imports.d.ts +16 -0
- package/dist/imports.js +145 -33
- package/dist/index.js +8 -1
- package/dist/init.d.ts +3 -0
- package/dist/init.js +125 -8
- package/dist/install.js +4 -1
- package/dist/localPaths.js +4 -0
- package/dist/login.js +2 -2
- package/dist/platformDoc.js +3 -8
- package/dist/playPagePolicy.js +3 -1
- package/dist/remix.js +5 -0
- package/dist/routerTaskReport.d.ts +28 -0
- package/dist/routerTaskReport.js +56 -0
- package/dist/save-deck.d.ts +18 -0
- package/dist/save-deck.js +145 -6
- package/dist/serve.d.ts +8 -0
- package/dist/serve.js +94 -13
- package/dist/serverBundle.d.ts +1 -1
- package/dist/serverBundle.js +5 -1
- package/dist/sourceLineage.d.ts +42 -0
- package/dist/sourceLineage.js +380 -0
- package/dist/webSourceSync.d.ts +11 -0
- package/dist/webSourceSync.js +26 -9
- package/kits/base/CLAUDE.md +2 -3
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +301 -52
- package/kits/base/sdk/agent.js +4 -4
- package/kits/base/sdk/avatar.d.ts +12 -0
- package/kits/base/sdk/avatar.js +23 -0
- package/kits/base/sdk/castle.d.ts +6 -1
- package/kits/base/sdk/castle.js +3 -0
- package/kits/base/sdk/commands.d.ts +208 -0
- package/kits/base/sdk/commands.js +16 -0
- package/kits/base/sdk/context.d.ts +6 -0
- package/kits/base/sdk/experiments.d.ts +15 -0
- package/kits/base/sdk/experiments.js +83 -0
- package/kits/base/sdk/hub.d.ts +85 -0
- package/kits/base/sdk/hub.js +107 -0
- package/kits/base/sdk/multiplayer.d.ts +86 -6
- package/kits/base/sdk/multiplayer.js +157 -4
- package/kits/base/sdk/server/hub.d.ts +169 -0
- package/kits/base/sdk/server/hub.js +125 -0
- package/kits/base/sdk/server/platformHandle.d.ts +49 -2
- package/kits/base/sdk/server/storage.d.ts +55 -2
- package/kits/base/sdk/server/wrapper.d.ts +85 -6
- package/kits/base/sdk/server/wrapper.js +393 -30
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +13 -1
- package/kits/hub-game/.prettierrc +5 -0
- package/kits/hub-game/CLAUDE.md +146 -0
- package/kits/hub-game/blueprints/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-3.scene +28 -0
- package/kits/hub-game/castle.json +96 -0
- package/kits/hub-game/code/client/attention.js +133 -0
- package/kits/hub-game/code/client/avatar.js +288 -0
- package/kits/hub-game/code/client/cabinets.js +90 -0
- package/kits/hub-game/code/client/chat.js +135 -0
- package/kits/hub-game/code/client/chrome.js +1001 -0
- package/kits/hub-game/code/client/doorFrame.js +15 -0
- package/kits/hub-game/code/client/firstJoin.js +14 -0
- package/kits/hub-game/code/client/grab.js +241 -0
- package/kits/hub-game/code/client/hookLayer.js +230 -0
- package/kits/hub-game/code/client/idle.js +326 -0
- package/kits/hub-game/code/client/keys.js +48 -0
- package/kits/hub-game/code/client/pack.js +232 -0
- package/kits/hub-game/code/client/packFormat.js +397 -0
- package/kits/hub-game/code/client/say.js +127 -0
- package/kits/hub-game/code/client/sha256.js +80 -0
- package/kits/hub-game/code/client/sound.js +147 -0
- package/kits/hub-game/code/client/state.js +131 -0
- package/kits/hub-game/code/client/talk.js +259 -0
- package/kits/hub-game/code/client/together.js +365 -0
- package/kits/hub-game/code/client/wear.js +149 -0
- package/kits/hub-game/code/server/actors.js +627 -0
- package/kits/hub-game/code/server/blocks.js +103 -0
- package/kits/hub-game/code/server/cabinets.js +309 -0
- package/kits/hub-game/code/server/game.js +137 -0
- package/kits/hub-game/code/server/grab.js +247 -0
- package/kits/hub-game/code/server/history.js +96 -0
- package/kits/hub-game/code/server/hub.js +1904 -0
- package/kits/hub-game/code/server/idle.js +412 -0
- package/kits/hub-game/code/server/index.js +64 -0
- package/kits/hub-game/code/server/labels.js +59 -0
- package/kits/hub-game/code/server/manifest.js +527 -0
- package/kits/hub-game/code/server/npcs.js +745 -0
- package/kits/hub-game/code/server/party.js +381 -0
- package/kits/hub-game/code/server/place.js +43 -0
- package/kits/hub-game/code/server/say.js +83 -0
- package/kits/hub-game/code/server/wear.js +142 -0
- package/kits/hub-game/code/systems/hub.js +2230 -0
- package/kits/hub-game/docs/content-pack.md +151 -0
- package/kits/hub-game/docs/contract.md +1139 -0
- package/kits/hub-game/docs/style.md +137 -0
- package/kits/hub-game/drawings/blocky/castle-eye.sprite +58 -0
- package/kits/hub-game/drawings/blocky/dash.sprite +59 -0
- package/kits/hub-game/drawings/blocky/pom.sprite +59 -0
- package/kits/hub-game/drawings/blocky/tabby.sprite +59 -0
- package/kits/hub-game/drawings/pixel/castle-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/castle-body.sprite +23 -0
- package/kits/hub-game/drawings/pixel/castle-leg.sprite +12 -0
- package/kits/hub-game/drawings/pixel/kai-arm.sprite +14 -0
- package/kits/hub-game/drawings/pixel/kai-head.sprite +24 -0
- package/kits/hub-game/drawings/pixel/kai-leg.sprite +15 -0
- package/kits/hub-game/drawings/pixel/kai-torso.sprite +18 -0
- package/kits/hub-game/drawings/pixel/mimi-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/mimi-head.sprite +23 -0
- package/kits/hub-game/drawings/pixel/mimi-leg.sprite +15 -0
- package/kits/hub-game/drawings/pixel/mimi-torso.sprite +18 -0
- package/kits/hub-game/drawings/pixel/nox-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/nox-head.sprite +21 -0
- package/kits/hub-game/drawings/pixel/nox-leg.sprite +14 -0
- package/kits/hub-game/drawings/pixel/nox-torso.sprite +18 -0
- package/kits/hub-game/eslint.config.js +20 -0
- package/kits/hub-game/fonts.generated.js +9 -0
- package/kits/hub-game/index.html +22 -0
- package/kits/hub-game/main.jsx +6 -0
- package/kits/hub-game/models/avatar-0.pxmodel +21 -0
- package/kits/hub-game/models/avatar-1.pxmodel +24 -0
- package/kits/hub-game/models/avatar-2.pxmodel +27 -0
- package/kits/hub-game/models/avatar-3.pxmodel +22 -0
- package/kits/hub-game/models/bean/avatar-0.pxmodel +19 -0
- package/kits/hub-game/models/bean/avatar-1.pxmodel +24 -0
- package/kits/hub-game/models/bean/avatar-2.pxmodel +22 -0
- package/kits/hub-game/models/bean/avatar-3.pxmodel +24 -0
- package/kits/hub-game/models/blocky/avatar-0.pxmodel +21 -0
- package/kits/hub-game/models/blocky/avatar-1.pxmodel +30 -0
- package/kits/hub-game/models/blocky/avatar-2.pxmodel +28 -0
- package/kits/hub-game/models/blocky/avatar-3.pxmodel +27 -0
- package/kits/hub-game/models/pixel/avatar-0.pxmodel +24 -0
- package/kits/hub-game/models/pixel/avatar-1.pxmodel +16 -0
- package/kits/hub-game/models/pixel/avatar-2.pxmodel +19 -0
- package/kits/hub-game/models/pixel/avatar-3.pxmodel +23 -0
- package/kits/hub-game/package-lock.json +365 -0
- package/kits/hub-game/package.json +32 -0
- package/kits/hub-game/scenes/main.scene +318 -0
- package/kits/hub-game/scripts/check.mjs +339 -0
- package/kits/hub-game/scripts/fixtures/sdk-stub.mjs +3 -0
- package/kits/hub-game/scripts/gen-avatars-bean.mjs +748 -0
- package/kits/hub-game/scripts/gen-avatars-blocky.mjs +607 -0
- package/kits/hub-game/scripts/gen-avatars-pixel.mjs +771 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +621 -0
- package/kits/hub-game/scripts/pack.mjs +192 -0
- package/kits/hub-game/scripts/test-actors.mjs +666 -0
- package/kits/hub-game/scripts/test-attention.mjs +103 -0
- package/kits/hub-game/scripts/test-avatar.mjs +472 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +194 -0
- package/kits/hub-game/scripts/test-blocks.mjs +351 -0
- package/kits/hub-game/scripts/test-chat.mjs +98 -0
- package/kits/hub-game/scripts/test-classic.mjs +590 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +131 -0
- package/kits/hub-game/scripts/test-door.mjs +56 -0
- package/kits/hub-game/scripts/test-grab.mjs +331 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +835 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +1310 -0
- package/kits/hub-game/scripts/test-idle.mjs +518 -0
- package/kits/hub-game/scripts/test-interest.mjs +413 -0
- package/kits/hub-game/scripts/test-keys.mjs +50 -0
- package/kits/hub-game/scripts/test-manifest.mjs +224 -0
- package/kits/hub-game/scripts/test-no-forms.mjs +16 -0
- package/kits/hub-game/scripts/test-npcs.mjs +714 -0
- package/kits/hub-game/scripts/test-pack.mjs +424 -0
- package/kits/hub-game/scripts/test-party.mjs +286 -0
- package/kits/hub-game/scripts/test-say.mjs +149 -0
- package/kits/hub-game/scripts/test-together.mjs +183 -0
- package/kits/hub-game/theme.style +3 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +101 -1
- package/kits/multiplayer-3d/code/server/players.js +4 -1
- package/kits/multiplayer-3d/code/server/sceneBodies.js +27 -6
- package/kits/multiplayer-3d/code/server/world.js +20 -7
- package/kits/multiplayer-3d/code/systems/multiplayer.js +222 -11
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/art.js +13 -0
- package/kits/physics-2d/engine/assets.js +4 -2
- package/kits/physics-2d/engine/scene.js +25 -5
- package/kits/physics-3d/CLAUDE.md +6 -1
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +32 -4
- package/kits/physics-3d/engine3d/artobjects.js +2 -2
- package/kits/physics-3d/engine3d/materials.js +29 -1
- package/kits/physics-3d/engine3d/world3d.js +65 -1
- package/kits/physics-3d/systems/physics3d.js +5 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +77 -7
- package/kits/real-time/code/client/gameHooks.js +63 -3
- package/kits/real-time/code/client/messages.js +7 -0
- package/kits/real-time/code/server/gameHooks.js +24 -0
- package/kits/real-time/code/server/session.js +390 -22
- package/package.json +2 -2
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// Tests over the contract's pure parts: the manifest reader, the result check
|
|
2
|
+
// and place resolution. `npm run check` runs it; it needs nothing installed.
|
|
3
|
+
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import os from 'node:os';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { checkResult, GRAB_DEFAULTS, publicPlace, readManifest } from '../code/server/manifest.js';
|
|
9
|
+
import { resolvePlace } from '../code/server/place.js';
|
|
10
|
+
|
|
11
|
+
const kit = JSON.parse(fs.readFileSync(new URL('../castle.json', import.meta.url), 'utf8'));
|
|
12
|
+
const has = (scene) => ['scenes/main.scene', 'scenes/race.scene'].includes(scene);
|
|
13
|
+
|
|
14
|
+
function base(hub = {}, rest = {}) {
|
|
15
|
+
return { server: { maxPlayers: 8 }, hub: { contract: 1, title: 'Game', ...hub }, ...rest };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let n = 0;
|
|
19
|
+
function test(name, fn) {
|
|
20
|
+
fn();
|
|
21
|
+
n += 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
test("the kit's own manifest is valid", () => {
|
|
25
|
+
const { errors, manifest } = readManifest(kit, has);
|
|
26
|
+
assert.deepEqual(errors, []);
|
|
27
|
+
assert.equal(manifest.places.main.controller, 'walk');
|
|
28
|
+
assert.deepEqual(kit.starterConfig.hub, kit.hub);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('defaults fill in', () => {
|
|
32
|
+
const { manifest } = readManifest(base(), has);
|
|
33
|
+
const main = manifest.places.main;
|
|
34
|
+
assert.equal(main.scene, 'scenes/main.scene');
|
|
35
|
+
assert.equal(main.minPlayers, 1);
|
|
36
|
+
assert.equal(main.maxPlayers, 8);
|
|
37
|
+
assert.equal(main.lateJoin, false);
|
|
38
|
+
assert.equal(main.maxDurationSec, null);
|
|
39
|
+
const game = readManifest(base({ result: {} }), has).manifest.places.main;
|
|
40
|
+
assert.equal(game.maxDurationSec, 600);
|
|
41
|
+
assert.deepEqual(main.arrival, { actor: null, spread: 1.5, face: 'actor' });
|
|
42
|
+
assert.equal(main.result, null);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('no hub block, wrong or future contract', () => {
|
|
46
|
+
assert.equal(readManifest({}, has).manifest, null);
|
|
47
|
+
assert.match(readManifest(base({ contract: 2 }), has).errors[0], /newer than this kit/);
|
|
48
|
+
assert.match(readManifest(base({ contract: 0 }), has).errors[0], /must be 1/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('unknown keys are refused, not ignored', () => {
|
|
52
|
+
const { errors } = readManifest(base({ maxPlayer: 4 }), has);
|
|
53
|
+
assert.match(errors.join('\n'), /hub\.maxPlayer is not part/);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('player counts', () => {
|
|
57
|
+
assert.match(readManifest(base({ minPlayers: 5, maxPlayers: 4 }), has).errors.join(), /more than maxPlayers/);
|
|
58
|
+
assert.match(readManifest(base({ maxPlayers: 12 }), has).errors.join(), /server\.maxPlayers/);
|
|
59
|
+
assert.match(readManifest(base({ maxPlayers: 30 }), has).errors.join(), /1 to 24/);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('controllers: walk only, reserved names say so', () => {
|
|
63
|
+
assert.match(readManifest(base({ controller: 'vehicle' }), has).errors.join(), /not built yet/);
|
|
64
|
+
assert.match(readManifest(base({ controller: 'fly' }), has).errors.join(), /must be one of walk/);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('a scene the deck lacks', () => {
|
|
68
|
+
assert.match(readManifest(base({ scene: 'scenes/nope.scene' }), has).errors.join(), /does not have/);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('places', () => {
|
|
72
|
+
const ok = readManifest(base({ places: { race: { title: 'Race', scene: 'scenes/race.scene' } } }), has);
|
|
73
|
+
assert.deepEqual(ok.errors, []);
|
|
74
|
+
assert.equal(ok.manifest.places.race.scene, 'scenes/race.scene');
|
|
75
|
+
assert.match(readManifest(base({ places: { main: { title: 'x' } } }), has).errors.join(), /not "main"/);
|
|
76
|
+
assert.match(readManifest(base({ places: { Race: { title: 'x' } } }), has).errors.join(), /place id/);
|
|
77
|
+
assert.match(
|
|
78
|
+
readManifest(base({ places: { race: { title: 'x', scene: 'scenes/race.scene', contract: 1 } } }), has).errors.join(),
|
|
79
|
+
/places\.race\.contract is not part/,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('result shape and sign', () => {
|
|
84
|
+
const r = { outcomes: ['win', 'lose'], score: { unit: 'ms', better: 'lower', min: 0, max: 1000 }, stats: { laps: 'number' } };
|
|
85
|
+
assert.deepEqual(readManifest(base({ result: r, sign: { board: 'laps' } }), has).errors, []);
|
|
86
|
+
assert.match(readManifest(base({ result: { outcomes: ['tie'] } }), has).errors.join(), /outcomes/);
|
|
87
|
+
assert.match(readManifest(base({ sign: { board: 'score' } }), has).errors.join(), /board/);
|
|
88
|
+
// v1.1: a kill height inside the world's floor and ceiling.
|
|
89
|
+
assert.equal(readManifest(base({ fallY: -10 }), has).manifest.places.main.fallY, -10);
|
|
90
|
+
assert.equal(readManifest(base({}), has).manifest.places.main.fallY, null);
|
|
91
|
+
assert.match(readManifest(base({ fallY: -40 }), has).errors.join(), /fallY/);
|
|
92
|
+
assert.match(readManifest(base({ fallY: '3' }), has).errors.join(), /fallY/);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('grab (v1.3): true is the defaults, an object sets any of them, off is none', () => {
|
|
96
|
+
const place = (grab) => readManifest(base(grab === undefined ? {} : { grab }), has);
|
|
97
|
+
assert.equal(place(undefined).manifest.places.main.grab, null);
|
|
98
|
+
assert.equal(place(false).manifest.places.main.grab, null);
|
|
99
|
+
assert.deepEqual(place(true).manifest.places.main.grab, { throwSpeed: 10, holdDistance: 1.4, holdHeight: 1.2 });
|
|
100
|
+
assert.deepEqual(GRAB_DEFAULTS, { throwSpeed: 10, holdDistance: 1.4, holdHeight: 1.2 });
|
|
101
|
+
assert.deepEqual(place({ throwSpeed: 14, holdHeight: 0 }).manifest.places.main.grab, { throwSpeed: 14, holdDistance: 1.4, holdHeight: 0 });
|
|
102
|
+
assert.deepEqual(place({}).manifest.places.main.grab, GRAB_DEFAULTS);
|
|
103
|
+
assert.match(place({ throwSpeed: 15 }).errors.join(), /grab\.throwSpeed must be a number of m\/s from 1 to 14/);
|
|
104
|
+
assert.match(place({ throwSpeed: 0.5 }).errors.join(), /throwSpeed/);
|
|
105
|
+
assert.match(place({ holdDistance: 0.5 }).errors.join(), /holdDistance .*0\.8 to 3/);
|
|
106
|
+
assert.match(place({ holdDistance: 3.5 }).errors.join(), /holdDistance/);
|
|
107
|
+
assert.match(place({ holdHeight: -1 }).errors.join(), /holdHeight .*0 to 2\.5/);
|
|
108
|
+
assert.match(place({ holdHeight: '1' }).errors.join(), /holdHeight/);
|
|
109
|
+
assert.match(place({ throwSpeed: Number.NaN }).errors.join(), /throwSpeed/);
|
|
110
|
+
assert.match(place({ throw: 10 }).errors.join(), /hub\.grab\.throw is not part/);
|
|
111
|
+
assert.match(place('yes').errors.join(), /grab must be true, false or an object/);
|
|
112
|
+
assert.match(place([]).errors.join(), /grab must be/);
|
|
113
|
+
assert.match(place(1).errors.join(), /grab must be/);
|
|
114
|
+
// A place of its own may offer it; the main place need not.
|
|
115
|
+
const more = readManifest(base({ places: { arena: { title: 'Arena', scene: 'scenes/race.scene', grab: { throwSpeed: 6 } } } }), has);
|
|
116
|
+
assert.deepEqual(more.errors, []);
|
|
117
|
+
assert.equal(more.manifest.places.main.grab, null);
|
|
118
|
+
assert.equal(more.manifest.places.arena.grab.throwSpeed, 6);
|
|
119
|
+
assert.match(
|
|
120
|
+
readManifest(base({ places: { arena: { title: 'Arena', scene: 'scenes/race.scene', grab: { far: 1 } } } }), has).errors.join(),
|
|
121
|
+
/places\.arena\.grab\.far is not part/,
|
|
122
|
+
);
|
|
123
|
+
// The client is told only where it is set: a place without it is sent what it was.
|
|
124
|
+
assert.deepEqual(publicPlace('main', place(true).manifest.places.main).grab, GRAB_DEFAULTS);
|
|
125
|
+
assert.ok(!('grab' in publicPlace('main', place(undefined).manifest.places.main)));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('results are checked against the declared shape', () => {
|
|
129
|
+
const { manifest } = readManifest(
|
|
130
|
+
base({ result: { outcomes: ['win', 'lose'], score: { min: 0, max: 100 }, stats: { kart: 'string' } } }),
|
|
131
|
+
has,
|
|
132
|
+
);
|
|
133
|
+
const place = manifest.places.main;
|
|
134
|
+
assert.deepEqual(checkResult(place, { outcome: 'win', score: 5 }).result, { outcome: 'win', score: 5 });
|
|
135
|
+
assert.match(checkResult(place, { outcome: 'draw' }).error, /outcome/);
|
|
136
|
+
// v1.1: a score alone is a result; nothing at all is not.
|
|
137
|
+
assert.deepEqual(checkResult(place, { score: 5 }).result, { score: 5 });
|
|
138
|
+
assert.deepEqual(checkResult(place, { outcome: null, score: 5 }).result, { score: 5 });
|
|
139
|
+
assert.match(checkResult(place, {}).error, /needs a score/);
|
|
140
|
+
assert.match(checkResult(place, { stats: { kart: 'red' } }).error, /needs a score/);
|
|
141
|
+
assert.match(checkResult(place, { outcome: 'win', score: 101 }).error, /outside/);
|
|
142
|
+
assert.match(checkResult(place, { outcome: 'win', score: NaN }).error, /finite/);
|
|
143
|
+
assert.match(checkResult(place, { outcome: 'win', stats: { laps: 1 } }).error, /not declared/);
|
|
144
|
+
assert.match(checkResult(place, { outcome: 'win', stats: { constructor: 'x' } }).error, /not declared/);
|
|
145
|
+
assert.match(checkResult(place, { outcome: 'win', text: 'I am the best' }).error, /not part of a result/);
|
|
146
|
+
assert.deepEqual(checkResult(place, { outcome: 'lose', stats: { kart: 'red' } }).result, {
|
|
147
|
+
outcome: 'lose',
|
|
148
|
+
stats: { kart: 'red' },
|
|
149
|
+
});
|
|
150
|
+
const town = readManifest(base(), has).manifest.places.main;
|
|
151
|
+
assert.match(checkResult(town, { outcome: 'win' }).error, /declares no result/);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('a session learns its place from the session, never a client', () => {
|
|
155
|
+
const { manifest } = readManifest(base({ places: { race: { title: 'Race', scene: 'scenes/race.scene' } } }), has);
|
|
156
|
+
assert.deepEqual(resolvePlace({ sessionId: 'abc', place: 'race' }, manifest), { id: 'race', source: 'host' });
|
|
157
|
+
assert.equal(resolvePlace({ sessionId: 'abc', place: 'nope' }, manifest).id, 'main');
|
|
158
|
+
assert.deepEqual(resolvePlace({ sessionId: 'dev:hub.race.x1y2' }, manifest), { id: 'race', source: 'dev-key' });
|
|
159
|
+
// A production named session's id is not a dev key, whatever its key was.
|
|
160
|
+
assert.equal(resolvePlace({ sessionId: 'hub.race.x1y2' }, manifest).id, 'main');
|
|
161
|
+
assert.equal(resolvePlace({ sessionId: 'dev:race' }, manifest).id, 'main');
|
|
162
|
+
assert.equal(resolvePlace({ sessionId: 'dev' }, manifest).id, 'main');
|
|
163
|
+
// The host's stamp wins over a dev key.
|
|
164
|
+
assert.equal(resolvePlace({ sessionId: 'dev:hub.race.x', place: 'main' }, manifest).id, 'main');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('npcs name a shared-character route', () => {
|
|
168
|
+
const route = { routeId: 'town', access: 'public', selection: 'exact', persistence: 'world', characters: 'shared', maxPlayers: 8 };
|
|
169
|
+
const server = { maxPlayers: 8, destinations: [route, { ...route, routeId: 'plain', characters: undefined }] };
|
|
170
|
+
const characterBundle = { characters: [{ id: 'greeter' }], conversation: { version: 1, authority: 'server', maxListeners: 0 } };
|
|
171
|
+
const ok = readManifest(base({ npcs: { route: 'town' } }, { server, characterBundle }), has);
|
|
172
|
+
assert.deepEqual(ok.errors, []);
|
|
173
|
+
assert.deepEqual(ok.manifest.places.main.npcs, { route: 'town', slot: 'main', turnsPerMinute: 6, disclosure: 'participants', followSec: 120 });
|
|
174
|
+
assert.equal(readManifest(base(), has).manifest.places.main.npcs, null);
|
|
175
|
+
assert.match(readManifest(base({ npcs: { route: 'nope' } }, { server, characterBundle }), has).errors[0], /routeIds/);
|
|
176
|
+
// No route: the place's minds only (every layer, one memory).
|
|
177
|
+
const placeOnly = readManifest(base({ npcs: {} }, { server: { maxPlayers: 8 }, characterBundle }), has);
|
|
178
|
+
assert.deepEqual(placeOnly.errors, []);
|
|
179
|
+
assert.equal(placeOnly.manifest.places.main.npcs.route, null);
|
|
180
|
+
assert.match(readManifest(base({ npcs: { route: 'plain' } }, { server, characterBundle }), has).errors[0], /characters: "shared"/);
|
|
181
|
+
assert.match(readManifest(base({ npcs: { route: 'town', turnsPerMinute: 0 } }, { server, characterBundle }), has).errors[0], /turnsPerMinute/);
|
|
182
|
+
assert.match(readManifest(base({ npcs: { route: 'town', disclosure: 'everyone' } }, { server, characterBundle }), has).errors[0], /disclosure/);
|
|
183
|
+
assert.match(readManifest(base({ npcs: { route: 'town', slot: 'a b' } }, { server, characterBundle }), has).errors[0], /slot/);
|
|
184
|
+
assert.match(readManifest(base({ npcs: { route: 'town', budget: 3 } }, { server, characterBundle }), has).errors[0], /not part of the hub contract/);
|
|
185
|
+
assert.match(readManifest(base({ npcs: { route: 'town' } }, { server }), has).errors[0], /characterBundle/);
|
|
186
|
+
const clientAuthority = { ...characterBundle, conversation: { version: 1, authority: 'client', maxListeners: 0 } };
|
|
187
|
+
assert.match(readManifest(base({ npcs: { route: 'town' } }, { server, characterBundle: clientAuthority }), has).errors[0], /authority/);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('a door to a local deck may not drift from that deck\'s castle.json', () => {
|
|
191
|
+
return import('./check.mjs').then(async ({ default: check }) => {
|
|
192
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-door-check-'));
|
|
193
|
+
try {
|
|
194
|
+
const town = path.join(root, 'town');
|
|
195
|
+
const race = path.join(root, 'race');
|
|
196
|
+
fs.mkdirSync(path.join(town, 'scenes'), { recursive: true });
|
|
197
|
+
fs.mkdirSync(race);
|
|
198
|
+
const door = { id: 'race', to: 'deck:race', title: 'Foot Race', minPlayers: 2, maxPlayers: 8, lateJoin: true };
|
|
199
|
+
const write = (props) =>
|
|
200
|
+
fs.writeFileSync(
|
|
201
|
+
path.join(town, 'scenes', 'main.scene'),
|
|
202
|
+
JSON.stringify({ actors: [{ id: 'player', components: { Player: {} } }, { id: 'door', components: { HubDoor: props } }] }),
|
|
203
|
+
);
|
|
204
|
+
fs.writeFileSync(path.join(town, 'castle.json'), JSON.stringify({ server: { main: 'code/server/index.js' }, devDecks: { race: '../race' }, hub: { contract: 1, title: 'Town' } }));
|
|
205
|
+
fs.writeFileSync(path.join(race, 'castle.json'), JSON.stringify({ hub: { contract: 1, title: 'Foot Race', minPlayers: 2, maxPlayers: 8, lateJoin: true, result: {} } }));
|
|
206
|
+
write(door);
|
|
207
|
+
assert.deepEqual((await check({ deckDir: town, self: true })).errors, []);
|
|
208
|
+
write({ ...door, maxPlayers: 6 });
|
|
209
|
+
assert.match((await check({ deckDir: town, self: true })).errors.join(), /maxPlayers 6.*says 8/);
|
|
210
|
+
// A door whose props come from a blueprint is checked as the engine merges it.
|
|
211
|
+
fs.mkdirSync(path.join(town, 'blueprints'));
|
|
212
|
+
fs.writeFileSync(path.join(town, 'blueprints', 'door.scene'), JSON.stringify({ actors: [{ components: { HubDoor: { ...door, title: 'Stale' } } }] }));
|
|
213
|
+
fs.writeFileSync(
|
|
214
|
+
path.join(town, 'scenes', 'main.scene'),
|
|
215
|
+
JSON.stringify({ actors: [{ id: 'player', components: { Player: {} } }, { id: 'door', blueprint: 'blueprints/door.scene', components: {} }] }),
|
|
216
|
+
);
|
|
217
|
+
assert.match((await check({ deckDir: town, self: true })).errors.join(), /title "Stale"/);
|
|
218
|
+
} finally {
|
|
219
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
console.log(`hub-game manifest: ${n} tests passed`);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// castle.xyz plays a deck in a frame sandboxed without `allow-forms`: a form's
|
|
2
|
+
// submission there is blocked before its submit event fires, so a chat or talk
|
|
3
|
+
// field built on <form> silently sends nothing (the NPC talk panel did, on
|
|
4
|
+
// 2026-10-03). The hub chrome handles Enter and its buttons itself instead.
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
const dir = new URL('../code/client/', import.meta.url).pathname;
|
|
10
|
+
for (const name of fs.readdirSync(dir).filter((f) => f.endsWith('.js'))) {
|
|
11
|
+
const src = fs.readFileSync(path.join(dir, name), 'utf8');
|
|
12
|
+
assert.doesNotMatch(src, /el\(\s*['"]form['"]|createElement\(\s*['"]form['"]/, `${name} builds a <form>`);
|
|
13
|
+
assert.doesNotMatch(src, /\.type\s*=\s*['"]submit['"]/, `${name} has a submit button`);
|
|
14
|
+
assert.doesNotMatch(src, /addEventListener\(\s*['"]submit['"]/, `${name} waits for a submit event`);
|
|
15
|
+
}
|
|
16
|
+
console.log('no forms in the hub chrome: ok');
|