castle-web-cli 0.4.236 → 0.4.238
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/api.d.ts +2 -0
- package/dist/bundle.d.ts +24 -0
- package/dist/bundle.js +447 -4
- package/dist/bundleLatin1.d.ts +6 -0
- package/dist/bundleLatin1.js +333 -0
- package/dist/castle-host/host.d.ts +10 -1
- package/dist/castle-host/host.js +78 -9
- package/dist/castleJson.d.ts +20 -0
- package/dist/castleJson.js +40 -0
- package/dist/deckExports.d.ts +35 -0
- package/dist/deckExports.js +365 -0
- package/dist/importCheckHook.d.ts +1 -0
- package/dist/importCheckHook.js +1 -1
- package/dist/index.js +5 -0
- package/dist/init.js +2 -1
- package/dist/save-deck.js +18 -13
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +47 -0
- package/kits/base/sdk/castle.d.ts +3 -1
- package/kits/base/sdk/castle.js +1 -0
- package/kits/base/sdk/commands.d.ts +25 -1
- package/kits/base/sdk/commands.js +29 -1
- package/kits/base/sdk/hub.d.ts +17 -0
- package/kits/base/sdk/hub.js +33 -9
- package/kits/base/sdk/localCache.d.ts +27 -0
- package/kits/base/sdk/localCache.js +115 -0
- package/kits/base/sdk/localCacheStore.d.ts +15 -0
- package/kits/base/sdk/localCacheStore.js +358 -0
- package/kits/base/sdk/transport.d.ts +1 -0
- package/kits/base/sdk/transport.js +4 -5
- package/kits/hub-game/CLAUDE.md +22 -2
- package/kits/hub-game/castle.json +4 -1
- package/kits/hub-game/code/client/act.js +66 -91
- package/kits/hub-game/code/client/actCore.js +134 -0
- package/kits/hub-game/code/client/car.js +35 -0
- package/kits/hub-game/code/client/chrome.js +207 -381
- package/kits/hub-game/code/client/crowdNames.js +2 -2
- package/kits/hub-game/code/client/emoteWheel.js +109 -0
- package/kits/hub-game/code/client/hats.js +2 -0
- package/kits/hub-game/code/client/hookLayer.js +99 -48
- package/kits/hub-game/code/client/hostGo.js +77 -0
- package/kits/hub-game/code/client/hubControls.js +125 -0
- package/kits/hub-game/code/client/hubEntry.js +187 -0
- package/kits/hub-game/code/client/hudSurface.js +148 -0
- package/kits/hub-game/code/client/hudTree.js +96 -0
- package/kits/hub-game/code/client/idle.js +59 -13
- package/kits/hub-game/code/client/invites.js +13 -4
- package/kits/hub-game/code/client/menuIcons.js +8 -0
- package/kits/hub-game/code/client/noTrips.js +38 -0
- package/kits/hub-game/code/client/qualityEntry.js +6 -1
- package/kits/hub-game/code/client/rehello.js +3 -1
- package/kits/hub-game/code/client/riders.js +26 -0
- package/kits/hub-game/code/client/role.js +79 -0
- package/kits/hub-game/code/client/safeLayout.js +32 -3
- package/kits/hub-game/code/client/sound.js +10 -3
- package/kits/hub-game/code/client/soundscape.js +2 -2
- package/kits/hub-game/code/client/soundscapeAmbience.js +38 -8
- package/kits/hub-game/code/client/soundscapeBaked.js +24 -5
- package/kits/hub-game/code/client/soundscapeCues.js +2 -1
- package/kits/hub-game/code/client/state.js +19 -0
- package/kits/hub-game/code/client/stuck.js +2 -1
- package/kits/hub-game/code/client/talkSurface.js +178 -0
- package/kits/hub-game/code/client/talkTree.js +238 -0
- package/kits/hub-game/code/client/tiers.js +8 -5
- package/kits/hub-game/code/client/uiDom.js +600 -0
- package/kits/hub-game/code/client/uiTree.js +359 -0
- package/kits/hub-game/code/client/vehicle.js +154 -0
- package/kits/hub-game/code/client/wear.js +27 -5
- package/kits/hub-game/code/client/worldLabels.js +3 -2
- package/kits/hub-game/code/client/yours.js +10 -3
- package/kits/hub-game/code/server/actors.js +4 -3
- package/kits/hub-game/code/server/analytics.js +56 -6
- package/kits/hub-game/code/server/decor.js +56 -16
- package/kits/hub-game/code/server/hub.js +258 -46
- package/kits/hub-game/code/server/idle.js +118 -5
- package/kits/hub-game/code/server/manifest.js +46 -4
- package/kits/hub-game/code/server/npcs.js +4 -2
- package/kits/hub-game/code/server/players.js +3 -0
- package/kits/hub-game/code/server/role.js +142 -0
- package/kits/hub-game/code/server/standing.js +6 -4
- package/kits/hub-game/code/server/vehicle.js +126 -0
- package/kits/hub-game/code/shared/car.js +52 -0
- package/kits/hub-game/code/shared/deckFlags.js +34 -0
- package/kits/hub-game/code/shared/deviceClass.js +39 -0
- package/kits/hub-game/code/shared/expression.js +9 -0
- package/kits/hub-game/code/systems/hub.js +300 -85
- package/kits/hub-game/docs/analytics.md +11 -2
- package/kits/hub-game/docs/contract.md +353 -14
- package/kits/hub-game/docs/vehicle-preset.md +132 -0
- package/kits/hub-game/models/hats/baker-cap.pxmodel +89 -0
- package/kits/hub-game/models/hats/chef-toque.pxmodel +60 -0
- package/kits/hub-game/models/hats/delivery-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/fire-helmet.pxmodel +87 -0
- package/kits/hub-game/models/hats/hard-hat.pxmodel +71 -0
- package/kits/hub-game/models/hats/nurse-cap.pxmodel +61 -0
- package/kits/hub-game/models/hats/police-cap.pxmodel +105 -0
- package/kits/hub-game/models/hats/teacher-beret.pxmodel +52 -0
- package/kits/hub-game/models/role/square/top-apron.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-cardigan.pxmodel +141 -0
- package/kits/hub-game/models/role/square/top-coat.pxmodel +157 -0
- package/kits/hub-game/models/role/square/top-scrubs.pxmodel +93 -0
- package/kits/hub-game/models/role/square/top-tabard.pxmodel +109 -0
- package/kits/hub-game/models/role/square/top-vest.pxmodel +109 -0
- package/kits/hub-game/models/role/tool-bag.pxmodel +75 -0
- package/kits/hub-game/models/role/tool-bell.pxmodel +71 -0
- package/kits/hub-game/models/role/tool-hose.pxmodel +60 -0
- package/kits/hub-game/models/role/tool-parcel.pxmodel +61 -0
- package/kits/hub-game/models/role/tool-torch.pxmodel +55 -0
- package/kits/hub-game/models/role/tool-tray.pxmodel +75 -0
- package/kits/hub-game/models/role/top-apron.pxmodel +70 -0
- package/kits/hub-game/models/role/top-cardigan.pxmodel +102 -0
- package/kits/hub-game/models/role/top-coat.pxmodel +79 -0
- package/kits/hub-game/models/role/top-scrubs.pxmodel +54 -0
- package/kits/hub-game/models/role/top-tabard.pxmodel +70 -0
- package/kits/hub-game/models/role/top-vest.pxmodel +70 -0
- package/kits/hub-game/package-lock.json +1 -1
- package/kits/hub-game/package.json +1 -1
- package/kits/hub-game/scripts/check.mjs +7 -4
- package/kits/hub-game/scripts/fixtures/car-vectors.json +279 -0
- package/kits/hub-game/scripts/fixtures/decor-keyless-draw.json +2 -1
- package/kits/hub-game/scripts/fixtures/hud-surface.json +670 -0
- package/kits/hub-game/scripts/fixtures/talk-surface.json +3930 -0
- package/kits/hub-game/scripts/gen-hats.mjs +46 -2
- package/kits/hub-game/scripts/gen-role.mjs +80 -0
- package/kits/hub-game/scripts/test-act-core.mjs +167 -0
- package/kits/hub-game/scripts/test-actions-client.mjs +34 -0
- package/kits/hub-game/scripts/test-actors.mjs +48 -0
- package/kits/hub-game/scripts/test-analytics.mjs +99 -5
- package/kits/hub-game/scripts/test-apply-deck.mjs +122 -0
- package/kits/hub-game/scripts/test-back-visibility.mjs +3 -1
- package/kits/hub-game/scripts/test-ballot.mjs +2 -0
- package/kits/hub-game/scripts/test-car.mjs +43 -0
- package/kits/hub-game/scripts/test-decor-client.mjs +2 -1
- package/kits/hub-game/scripts/test-decor.mjs +77 -0
- package/kits/hub-game/scripts/test-device-class.mjs +83 -0
- package/kits/hub-game/scripts/test-emote-wheel.mjs +374 -0
- package/kits/hub-game/scripts/test-hats.mjs +5 -4
- package/kits/hub-game/scripts/test-host-go.mjs +265 -0
- package/kits/hub-game/scripts/test-hub-controls.mjs +108 -0
- package/kits/hub-game/scripts/test-hub-entry.mjs +531 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +75 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +85 -0
- package/kits/hub-game/scripts/test-hud-clear.mjs +12 -2
- package/kits/hub-game/scripts/test-hud-rate.mjs +6 -2
- package/kits/hub-game/scripts/test-hud-surface.mjs +272 -0
- package/kits/hub-game/scripts/test-idle.mjs +347 -1
- package/kits/hub-game/scripts/test-interest-cells.mjs +8 -1
- package/kits/hub-game/scripts/test-invites-client.mjs +42 -1
- package/kits/hub-game/scripts/test-manifest.mjs +30 -0
- package/kits/hub-game/scripts/test-no-trips.mjs +42 -0
- package/kits/hub-game/scripts/test-placement-cache.mjs +1 -1
- package/kits/hub-game/scripts/test-quality.mjs +13 -0
- package/kits/hub-game/scripts/test-rehello.mjs +258 -3
- package/kits/hub-game/scripts/test-resume-pose-server.mjs +203 -0
- package/kits/hub-game/scripts/test-resync.mjs +183 -0
- package/kits/hub-game/scripts/test-role-client.mjs +421 -0
- package/kits/hub-game/scripts/test-role.mjs +350 -0
- package/kits/hub-game/scripts/test-safe-layout.mjs +50 -1
- package/kits/hub-game/scripts/test-soundscape.mjs +124 -7
- package/kits/hub-game/scripts/test-standing.mjs +15 -1
- package/kits/hub-game/scripts/test-talk-surface.mjs +296 -0
- package/kits/hub-game/scripts/test-tiers.mjs +13 -0
- package/kits/hub-game/scripts/test-ui-dom-dom.mjs +96 -0
- package/kits/hub-game/scripts/test-ui-tree.mjs +711 -0
- package/kits/hub-game/scripts/test-vehicle-client.mjs +159 -0
- package/kits/hub-game/scripts/test-vehicle.mjs +135 -0
- package/kits/hub-game/scripts/test-yours.mjs +33 -0
- package/kits/hub-game/tools/hubScene/export.mjs +613 -0
- package/kits/hub-game/tools/hubScene/hubdata.mjs +921 -0
- package/kits/hub-game/tools/hubScene/merge-root.mjs +39 -0
- package/kits/hub-game/tools/hubScene/nodeworld.mjs +227 -0
- package/kits/hub-game/tools/hubScene/test/export-fixture.mjs +798 -0
- package/kits/hub-game/tools/hubScene/test/fixture.json +637 -0
- package/kits/hub-game/tools/hubScene/test/paint-export.mjs +40 -0
- package/kits/hub-game/tools/hubScene/test/upload.test.mjs +655 -0
- package/kits/hub-game/tools/hubScene/upload.mjs +636 -0
- package/kits/hub-game/tools/hubScene/validate-manifest.mjs +291 -0
- package/kits/multiplayer-3d/castle.json +4 -4
- package/kits/multiplayer-3d/code/client/resumeGate.js +30 -2
- package/kits/multiplayer-3d/code/client/steer.js +3 -1
- package/kits/multiplayer-3d/code/systems/multiplayer.js +30 -2
- package/kits/multiplayer-3d/package-lock.json +1 -1
- package/kits/multiplayer-3d/scripts/test-resume-gate.mjs +74 -2
- package/kits/physics-3d/CLAUDE.md +1 -1
- package/kits/physics-3d/behaviors/Player.jsx +37 -27
- package/kits/physics-3d/castle.json +2 -2
- package/kits/physics-3d/docs/engine-geometry-memory.md +23 -0
- package/kits/physics-3d/engine3d/memoryprofile.js +17 -0
- package/kits/physics-3d/engine3d/playerRun.js +6 -1
- package/kits/physics-3d/engine3d/pxmodel.js +6 -1
- package/kits/physics-3d/engine3d/world3d.js +6 -3
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/play/behaviors/Player.js +40 -28
- package/kits/physics-3d/scripts/test-memory-profile.mjs +237 -0
- package/kits/physics-3d/systems/physics3d.js +5 -2
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/messages.js +5 -0
- package/kits/real-time/code/server/session.js +28 -1
- package/kits/real-time/package-lock.json +1 -1
- package/package.json +5 -4
- package/vendor/three/LICENSE +21 -0
- package/vendor/three/build/three.core.js +58773 -0
- package/vendor/three/build/three.module.js +18251 -0
- package/vendor/three/examples/jsm/controls/OrbitControls.js +1860 -0
- package/vendor/three/examples/jsm/controls/TransformControls.js +1918 -0
- package/vendor/three/examples/jsm/exporters/GLTFExporter.js +3595 -0
- package/vendor/three/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
- package/vendor/three/examples/jsm/math/MeshSurfaceSampler.js +315 -0
- package/vendor/three/examples/jsm/postprocessing/EffectComposer.js +363 -0
- package/vendor/three/examples/jsm/postprocessing/MaskPass.js +195 -0
- package/vendor/three/examples/jsm/postprocessing/OutputPass.js +139 -0
- package/vendor/three/examples/jsm/postprocessing/Pass.js +191 -0
- package/vendor/three/examples/jsm/postprocessing/RenderPass.js +183 -0
- package/vendor/three/examples/jsm/postprocessing/ShaderPass.js +135 -0
- package/vendor/three/examples/jsm/shaders/CopyShader.js +52 -0
- package/vendor/three/examples/jsm/shaders/OutputShader.js +103 -0
- package/vendor/three/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
- package/vendor/three/package.json +134 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
// The hubScene exporter through `castle-web export`, on a small fixture hub (fixture.json) and a
|
|
2
|
+
// copy of the shipped kits, in a temp dir. Covers: a cold export with no validator faults, reuse
|
|
3
|
+
// while the key holds, re-export on a scene change, a kit file change and a door's preferred
|
|
4
|
+
// folder appearing; a deck's imports/ never executed; a kit module symlinked outside refused;
|
|
5
|
+
// three loaded only from the CLI's own copy, never the deck's node_modules;
|
|
6
|
+
// the reserved hub ids refused; the v1.4 deck block and interactables (HubNpc, HubAct, HubSeat,
|
|
7
|
+
// and the chat moderation marker when the scene has it); the v1.6 audio map, its content-addressed
|
|
8
|
+
// sound assets, deck.soundscape and idle, and the jukebox and soundscape actors in interactables;
|
|
9
|
+
// the v1.7 avatar fits, untinted wear models and piece placement descriptions;
|
|
10
|
+
// a .castle or exports folder symlinked outside refused with
|
|
11
|
+
// nothing written or deleted there; and, in this process, actors a live page hid before the export
|
|
12
|
+
// still exported with their meshes and split models at their authored pose (hiddenAtExport).
|
|
13
|
+
// node kits/hub-game/tools/hubScene/test/export-fixture.mjs (needs cli/dist: npm run build:cli)
|
|
14
|
+
import assert from 'node:assert/strict';
|
|
15
|
+
import crypto from 'node:crypto';
|
|
16
|
+
import { spawnSync } from 'node:child_process';
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import os from 'node:os';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
const HERE = import.meta.dirname;
|
|
22
|
+
const REPO = path.resolve(HERE, '../../../../..');
|
|
23
|
+
const CLI = path.join(REPO, 'cli/dist/index.js');
|
|
24
|
+
assert.ok(fs.existsSync(CLI), 'build the CLI first (npm run build:cli)');
|
|
25
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'hub-scene-export-'));
|
|
26
|
+
|
|
27
|
+
// The shipped kits, copied so a test can change them; three resolves through node_modules beside.
|
|
28
|
+
const kits = path.join(tmp, 'kits');
|
|
29
|
+
for (const kit of ['physics-2d', 'physics-3d', 'hub-game']) {
|
|
30
|
+
fs.cpSync(path.join(REPO, 'kits', kit), path.join(kits, kit), {
|
|
31
|
+
recursive: true, filter: (src) => !/[/\\](node_modules|imports|\.castle)([/\\]|$)/.test(src.slice(path.join(REPO, 'kits').length)),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
fs.symlinkSync(path.join(REPO, 'node_modules'), path.join(tmp, 'node_modules'));
|
|
35
|
+
const fixture = JSON.parse(fs.readFileSync(path.join(HERE, 'fixture.json'), 'utf8'));
|
|
36
|
+
for (const [rel, value] of Object.entries(fixture.files)) {
|
|
37
|
+
fs.mkdirSync(path.dirname(path.join(tmp, rel)), { recursive: true });
|
|
38
|
+
fs.writeFileSync(path.join(tmp, rel), typeof value === 'string' ? value : JSON.stringify(value, null, 1));
|
|
39
|
+
}
|
|
40
|
+
const deck = path.join(tmp, 'hub-mini');
|
|
41
|
+
const out = path.join(deck, '.castle/exports/hubScene');
|
|
42
|
+
const cacheRoot = path.join(tmp, 'cache');
|
|
43
|
+
|
|
44
|
+
const exportDeck = (deckDir = deck) => {
|
|
45
|
+
const r = spawnSync(process.execPath, [CLI, 'export', deckDir], {
|
|
46
|
+
encoding: 'utf8', timeout: 180_000,
|
|
47
|
+
env: { ...process.env, CASTLE_NO_AUTO_UPDATE: '1', CASTLE_WEB_KITS_DIR: kits, CASTLE_EXPORT_CACHE_ROOT: cacheRoot },
|
|
48
|
+
});
|
|
49
|
+
assert.ifError(r.error);
|
|
50
|
+
const line = r.stdout.split('\n').find((l) => l.startsWith('Exported hubScene'));
|
|
51
|
+
return { status: r.status, output: `${r.stdout}\n${r.stderr}`, summary: line ? JSON.parse(line.slice(line.indexOf('{'))) : null };
|
|
52
|
+
};
|
|
53
|
+
const run = () => {
|
|
54
|
+
const r = exportDeck();
|
|
55
|
+
assert.equal(r.status, 0, r.output);
|
|
56
|
+
assert.ok(r.summary, `no export summary:\n${r.output}`);
|
|
57
|
+
return r.summary;
|
|
58
|
+
};
|
|
59
|
+
const manifest = () => JSON.parse(fs.readFileSync(path.join(out, 'hub-mini/manifest.json'), 'utf8'));
|
|
60
|
+
const marker = path.join(tmp, 'planted-ran');
|
|
61
|
+
const plant = (file) => {
|
|
62
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
63
|
+
fs.writeFileSync(file, `import fs from 'node:fs'; fs.writeFileSync(${JSON.stringify(marker)}, 'ran'); export const x = 1;`);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
const cold = run();
|
|
68
|
+
assert.deepEqual(cold.faults, [], 'no validator faults');
|
|
69
|
+
assert.equal(cold.cached, false);
|
|
70
|
+
assert.equal(cold.hubId, 'hub-mini', 'an unsaved deck is named by its folder');
|
|
71
|
+
assert.equal(cold.title, 'Mini Hub');
|
|
72
|
+
assert.equal(cold.doors, 4);
|
|
73
|
+
assert.equal(cold.doorsResolved, 2, 'deck:dash resolves through devDecks, deck:dash2 through hub-dash2; deck:nowhere and the cabinet stay unresolved');
|
|
74
|
+
assert.equal(cold.characters, 1);
|
|
75
|
+
assert.equal(cold.labels, 2, 'the sign and the look spot (a label needs no node)');
|
|
76
|
+
assert.ok(cold.avatar, 'the platform avatar is built');
|
|
77
|
+
assert.equal(cold.models, 2, 'the bench and its byte-identical copy: two layers');
|
|
78
|
+
assert.equal(cold.placements, 3, 'placed three times (the player is the avatar, never a prop)');
|
|
79
|
+
const m = manifest();
|
|
80
|
+
assert.equal(m.format, 'castle.hubScene');
|
|
81
|
+
assert.equal(m.version, 1, 'v1.7 is additive, as v1.4 and v1.6 were');
|
|
82
|
+
assert.deepEqual(Object.keys(m.avatarFits), ['toon', 'blocky', 'bean', 'pixel']);
|
|
83
|
+
for (const fits of Object.values(m.avatarFits)) assert.equal(fits.length, 16);
|
|
84
|
+
assert.deepEqual(m.avatarFits.toon[0].waist, [0.41, 0.41, 0.41], 'avatar.js waist [y, rx, rz], verbatim');
|
|
85
|
+
assert.deepEqual(m.avatarFits.toon[0].chest, [0.19, 0.52, 0.35, 15]);
|
|
86
|
+
assert.deepEqual(m.avatarFits.toon[0].hat, [1.27, 1.3, 0.08]);
|
|
87
|
+
assert.equal(m.avatarFits.toon[0].top, 1.38);
|
|
88
|
+
assert.equal(m.avatarFits.blocky[0].square, true);
|
|
89
|
+
assert.equal(m.avatarFits.pixel[0].square, undefined, 'pixel Castle uses round rings');
|
|
90
|
+
for (const style of ['blocky', 'bean', 'pixel']) {
|
|
91
|
+
for (let i = 4; i < 16; i += 1) {
|
|
92
|
+
assert.equal(m.avatarFits[style][i].drawnFrom, 'toon');
|
|
93
|
+
assert.deepEqual(m.avatarFits[style][i], m.avatarFits.toon[i], 'all fallback fits use toon');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const wearFiles = ['hats', 'earned', 'role'].flatMap((dir) => fs.readdirSync(path.join(kits, 'hub-game/models', dir), { recursive: true })
|
|
97
|
+
.filter((file) => file.endsWith('.pxmodel')).map((file) => `${dir === 'hats' ? 'hat' : dir}/${file.slice(0, -'.pxmodel'.length).split(path.sep).join('/')}`));
|
|
98
|
+
assert.deepEqual(Object.keys(m.wearModels).sort(), wearFiles.sort(), 'every kit wear model, including square variants');
|
|
99
|
+
for (const id of ['role/top-vest', 'role/tool-torch', 'hat/police-cap', 'role/square/top-vest', 'earned/square/belt-plain']) {
|
|
100
|
+
const asset = m.wearModels[id];
|
|
101
|
+
assert.equal(asset.type, 'glb');
|
|
102
|
+
assert.deepEqual(asset, m.assets[id], 'registered for cache restaging and upload');
|
|
103
|
+
assert.ok(fs.existsSync(path.resolve(out, 'hub-mini', asset.uri)), 'staged');
|
|
104
|
+
}
|
|
105
|
+
assert.equal(m.wearPieces['role/top-vest'].anchor, 'waist');
|
|
106
|
+
assert.equal(m.wearPieces['role/top-vest'].scale, undefined, 'top stretching depends on the fit');
|
|
107
|
+
assert.equal(m.wearPieces['role/tool-torch'].scale, 1.2);
|
|
108
|
+
assert.equal(m.wearPieces['role/tool-torch'].anchor, 'hand');
|
|
109
|
+
assert.equal(m.wearPieces['earned/badge-star'].scale, 2.6);
|
|
110
|
+
assert.equal(m.wearPieces['earned/pin-round'].scale, 2.1);
|
|
111
|
+
assert.equal(m.wearPieces['earned/belt-plain'].anchor, 'waist');
|
|
112
|
+
assert.equal(m.wearPieces['earned/belt-plain'].scale, 1);
|
|
113
|
+
assert.ok(Object.values(m.wearPieces).every((piece) => piece.tint === '#3aa0d8' && piece.placement.length));
|
|
114
|
+
const { validateManifest: validateWear } = await import('../validate-manifest.mjs');
|
|
115
|
+
const wearFaults = (patch) => validateWear({ ...m, ...patch }, path.join(out, 'hub-mini'), { hash: false });
|
|
116
|
+
assert.ok(wearFaults({ avatarFits: { ...m.avatarFits, toon: [] } }).includes('avatarFits.toon: expected 16 entries'));
|
|
117
|
+
assert.ok(wearFaults({ wearPieces: null }).includes('wearPieces is not an object'));
|
|
118
|
+
const missingHat = { ...m.wearModels }; delete missingHat['hat/police-cap'];
|
|
119
|
+
assert.ok(wearFaults({ wearModels: missingHat }).includes('wearModels: missing hat/police-cap'));
|
|
120
|
+
const badWear = { ...m.wearModels, 'role/top-vest': { ...m.wearModels['role/top-vest'], uri: '../shared/missing.glb' } };
|
|
121
|
+
assert.ok(wearFaults({ wearModels: badWear }).some((fault) => fault.startsWith('asset wearModels role/top-vest:') && fault.endsWith('missing')));
|
|
122
|
+
const benchLayers = m.layers.filter((l) => l.role === 'prop');
|
|
123
|
+
assert.equal(m.assets[benchLayers[0].asset].sha256, m.assets[benchLayers[1].asset].sha256, 'identical models share one cache entry');
|
|
124
|
+
assert.deepEqual(m.doors.find((d) => d.id === 'dash').target, { type: 'deck', deckId: 'fixtureDash1', hubId: 'fixtureDash1' });
|
|
125
|
+
assert.equal(m.doors.find((d) => d.id === 'lost').target.resolveAt, 'load', 'a door no folder resolves is resolved at load, from Ghost');
|
|
126
|
+
assert.deepEqual(m.doors.find((d) => d.id === 'arcade').target, { type: 'unresolved', resolveAt: 'load', note: 'door arcade: cabinet: the server door table names the classic deck' },
|
|
127
|
+
'a cabinet is resolved at load too: only the server door table names its classic deck');
|
|
128
|
+
assert.ok(m.doors.filter((d) => d.target.type === 'unresolved').every((d) => d.target.resolveAt === 'load'), 'every door the export cannot resolve is resolved at load');
|
|
129
|
+
// v1.4: the hub block's client flags (shared/deckFlags.js), invite resolved from places.main,
|
|
130
|
+
// and nothing the client never reads (contract, title, arrival, places).
|
|
131
|
+
// v1.6 adds `places` (each place's idle; none here, as export-hub.mjs writes it: an empty map).
|
|
132
|
+
assert.deepEqual(m.deck, { invite: false, tiers: true, safeInsets: true, lowActorDistance: true, act: true, labels: 'near', places: {} });
|
|
133
|
+
assert.deepEqual(cold.deck, Object.keys(m.deck));
|
|
134
|
+
// v1.4: the actors the kit's talk and act find, as its scene has them.
|
|
135
|
+
assert.equal(cold.interactables, 3);
|
|
136
|
+
const inter = Object.fromEntries(m.interactables.map((a) => [a.id, a.components]));
|
|
137
|
+
assert.deepEqual(Object.keys(inter).sort(), ['lever-1', 'npc-greeter', 'seat-1']);
|
|
138
|
+
assert.deepEqual(inter['lever-1'], { HubAct: { verb: 'Pull', reach: 1.5, hold: false, id: 'lever' }, Transform: { x: -8, y: 0.5, z: 5, rotationY: 45 } },
|
|
139
|
+
'an act: its HubAct and Transform, no Shape');
|
|
140
|
+
assert.deepEqual(inter['seat-1'].HubSeat, {});
|
|
141
|
+
assert.deepEqual(inter['seat-1'].Transform, { x: 8, y: 0.25, z: 5, rotationY: 0 }, 'an absent rotationY is 0');
|
|
142
|
+
assert.equal(inter['seat-1'].Shape.width, 1, "a seat keeps its Shape, the kit's footprint");
|
|
143
|
+
assert.deepEqual([inter['npc-greeter'].HubNpc.name, inter['npc-greeter'].HubNpc.character], ['Rowan', 'greeter']);
|
|
144
|
+
assert.ok(!m.interactables.some((a) => a.components.Player), 'the player is never one');
|
|
145
|
+
assert.ok(!m.interactables.some((a) => a.id === 'hub-chat-moderation'), 'no chat moderation marker in the scene, none exported');
|
|
146
|
+
assert.deepEqual(m.audio, {}, 'v1.6: a deck naming no sounds has an empty audio map');
|
|
147
|
+
assert.equal(cold.audio, 0);
|
|
148
|
+
const inputs = JSON.parse(fs.readFileSync(path.join(out, 'hub-mini/inputs.json'), 'utf8'));
|
|
149
|
+
assert.equal(inputs.inputKey, m.source.inputKey, 'the input list beside the manifest is its key\'s');
|
|
150
|
+
assert.ok(inputs.inputs.some((i) => i.path === 'models/bench.pxmodel'), 'the model file is an input');
|
|
151
|
+
assert.ok(m.source.kits['castle.physics-3d'], 'the shipped kit versions are recorded');
|
|
152
|
+
for (const a of Object.values(m.assets)) assert.ok(fs.existsSync(path.join(cacheRoot, 'hubScene/shared', path.basename(a.uri))), `${a.uri} is in the cache`);
|
|
153
|
+
assert.deepEqual(fs.readdirSync(cacheRoot).filter((n) => n.startsWith('.stage')), [], 'the stage was moved into the deck');
|
|
154
|
+
|
|
155
|
+
// Still scenery (staticActors marks) is baked into chunks by cell; what could be addressed stays.
|
|
156
|
+
const mergedIds = Object.values(m.merged ?? {}).flat();
|
|
157
|
+
for (const id of ['wall-n', 'sign-1', 'rock-a', 'rock-far', 'bush-0']) {
|
|
158
|
+
assert.ok(mergedIds.includes(id), `${id} is merged`);
|
|
159
|
+
assert.equal(m.actors[id], undefined, `${id} has no node of its own`);
|
|
160
|
+
}
|
|
161
|
+
const chunkOf = (id) => Object.keys(m.merged).find((c) => m.merged[c].includes(id));
|
|
162
|
+
assert.equal(chunkOf('wall-n'), chunkOf('rock-a'), 'one cell, one chunk');
|
|
163
|
+
assert.notEqual(chunkOf('rock-far'), chunkOf('rock-a'), 'another cell, another chunk');
|
|
164
|
+
assert.notEqual(chunkOf('bush-0'), chunkOf('rock-a'), 'decor and static apart, so a tier can hide decor');
|
|
165
|
+
assert.equal(m.actors[chunkOf('bush-0')].kind, 'decor');
|
|
166
|
+
for (const chunk of Object.keys(m.merged)) assert.ok(m.actors[chunk]?.bounds, `${chunk} stands in for its actors`);
|
|
167
|
+
assert.notEqual(chunkOf('rock-near'), chunkOf('rock-a'), 'its own Low distance, its own chunk');
|
|
168
|
+
assert.equal(m.actors[chunkOf('rock-near')].nearM, 12);
|
|
169
|
+
// hub.tiers: the kit's Low picture is a profile beside High.
|
|
170
|
+
assert.deepEqual(m.tiers.order, ['weakest', 'middle', 'low', 'high']);
|
|
171
|
+
assert.equal(m.tiers.default, 'high');
|
|
172
|
+
const { hiddenAtExport, ...low } = m.tiers.profiles.low;
|
|
173
|
+
assert.deepEqual(low, { decor: false, sceneryNearM: 30, npcNearM: 20, sunShadow: false, sky: false, pixelRatio: null });
|
|
174
|
+
assert.ok(Array.isArray(hiddenAtExport));
|
|
175
|
+
assert.equal(m.tiers.profiles.middle, undefined, 'no weakestTier, no middle or weakest');
|
|
176
|
+
// The reference camera is where Player puts the orbit camera on arrival: behind the arrival
|
|
177
|
+
// facing (180: the player looks north, -z, so the camera is south of it), 15 degrees down, 12.5 studs out.
|
|
178
|
+
const ref = m.camera.reference;
|
|
179
|
+
const spawn = m.spawns.find((sp) => sp.default);
|
|
180
|
+
assert.equal(ref.mode, 'orbit');
|
|
181
|
+
assert.equal(m.camera.fovDeg, 70);
|
|
182
|
+
assert.ok(Math.abs(ref.pitchDeg - 15) < 1e-9 && Math.abs(ref.range - 12.5 * 1.46 / 5) < 1e-4, JSON.stringify(ref));
|
|
183
|
+
assert.ok(Math.abs(ref.eye[0] - spawn.position[0]) < 1e-4 && ref.eye[2] > spawn.position[2], `camera south of the spawn: ${ref.eye} vs ${spawn.position}`);
|
|
184
|
+
assert.deepEqual(ref.matrixWorld.slice(12, 15), ref.eye);
|
|
185
|
+
// Player's own constants, which the reference mirrors.
|
|
186
|
+
const player = fs.readFileSync(path.join(REPO, 'kits/physics-3d/play/behaviors/Player.js'), 'utf8');
|
|
187
|
+
for (const line of ['const STUD = 1.46 / 5;', 'const LOOK_HEIGHT = 1.5 * STUD;', 'const ORBIT_START = 12.5 * STUD;', 'const ORBIT_NEAREST = 1.5;',
|
|
188
|
+
'const ORBIT_FARTHEST = 128 * STUD;', 'const ORBIT_PITCH_START = 15 * DEG;', 'const ORBIT_PITCH_MOST = 80 * DEG;', 'cam.lookAt(t.x, t.y + 0.5, t.z);',
|
|
189
|
+
'const distance = finiteOr(props.camDistance, 9);', 'const height = finiteOr(props.camHeight, 7);']) {
|
|
190
|
+
assert.ok(player.includes(line), `physics-3d Player.js still has ${line} (hubdata.mjs PLAYER_CAMERA mirrors it)`);
|
|
191
|
+
}
|
|
192
|
+
// The readability rings: cues for the active ring, the spawn ring as a layer at the arrival.
|
|
193
|
+
assert.equal(m.padCues.ring, true);
|
|
194
|
+
assert.deepEqual(m.padCues.cues.map((c) => c.id), ['pad-dash']);
|
|
195
|
+
assert.equal(m.padCues.cues[0].title, 'Dash');
|
|
196
|
+
const ringLayer = m.layers.find((l) => l.id === 'spawn-ring');
|
|
197
|
+
assert.ok(ringLayer && m.assets['spawn-ring'], 'the spawn ring is a layer');
|
|
198
|
+
assert.deepEqual(ringLayer.transform.slice(12, 15), [0, 0.73, 4], 'at the player actor\'s authored point, 0.03 m up');
|
|
199
|
+
// Colliders unrounded (manifest v1.2): the kit's own f64 quaternion (three's setFromEuler, as
|
|
200
|
+
// physics3d quatFromEuler), so native Rapier starts a body from the kit's f32 bits; eulerDeg is
|
|
201
|
+
// the Transform it came from.
|
|
202
|
+
const bench = m.colliders.find((c) => c.actorId === 'bench-0');
|
|
203
|
+
assert.deepEqual(bench.eulerDeg, [0, 90, 0]);
|
|
204
|
+
assert.deepEqual(bench.rotation, [0, Math.sin(Math.PI / 4), 0, Math.cos(Math.PI / 4)], 'the unrounded quaternion');
|
|
205
|
+
assert.deepEqual([bench.center, bench.size], [[3, 0, 2], [2, 0.6, 0.6]]);
|
|
206
|
+
assert.ok(m.colliders.every((c) => Array.isArray(c.eulerDeg) && c.eulerDeg.length === 3), 'every collider carries eulerDeg');
|
|
207
|
+
assert.ok(m.actors['lamp-1'], 'quoted by code that tints: not merged');
|
|
208
|
+
assert.ok(m.actors.statue, 'named by another actor: not merged');
|
|
209
|
+
assert.ok(m.actors['bench-0'] && m.actors['door-dash'] && m.actors['npc-greeter'], 'unmarked and gameplay actors keep their nodes');
|
|
210
|
+
assert.equal(m.actors['look-spot'], undefined, 'drawn by nothing: no node');
|
|
211
|
+
assert.equal(m.stats.droppedEmpty, 2, 'look-spot and the plaque');
|
|
212
|
+
assert.ok(inputs.inputs.some((i) => i.path === 'code/server/lamps.js'), 'the code read for ids is an input');
|
|
213
|
+
const glb = fs.readFileSync(path.join(out, 'hub-mini', m.assets.scene.uri));
|
|
214
|
+
const gltf = JSON.parse(glb.subarray(20, 20 + glb.readUInt32LE(12)).toString('utf8'));
|
|
215
|
+
const nodeNames = new Set(gltf.nodes.map((n) => n.name));
|
|
216
|
+
for (const chunk of Object.keys(m.merged)) assert.ok(nodeNames.has(chunk), `the scene glb has ${chunk}`);
|
|
217
|
+
for (const id of ['wall-n', 'rock-a', 'look-spot']) assert.ok(!nodeNames.has(id), `the scene glb has no ${id}`);
|
|
218
|
+
assert.ok(nodeNames.has('lamp-1'));
|
|
219
|
+
// Materials that differ in anything the glb carries are not grouped onto one.
|
|
220
|
+
const strengths = (gltf.materials ?? []).map((mat) => mat.extensions?.KHR_materials_emissive_strength?.emissiveStrength ?? 1);
|
|
221
|
+
assert.ok(strengths.includes(4) && strengths.some((x) => Math.abs(x - 0.2) < 1e-6), `both emissive strengths kept: ${strengths}`);
|
|
222
|
+
|
|
223
|
+
assert.equal(run().cached, true, 'same inputs: the manifest is reused');
|
|
224
|
+
|
|
225
|
+
// Cache GC: entries no run used for 30 days and stale temp files go; what this export uses, a
|
|
226
|
+
// fresh entry and anything not named as the cache names its files stay.
|
|
227
|
+
const shared = path.join(cacheRoot, 'hubScene/shared');
|
|
228
|
+
const old = new Date(Date.now() - 31 * 24 * 3600 * 1000);
|
|
229
|
+
const plantEntry = (name, when) => { fs.writeFileSync(path.join(shared, name), name); fs.utimesSync(path.join(shared, name), when, when); };
|
|
230
|
+
const stale = `${'a'.repeat(64)}.glb`; const fresh = `${'b'.repeat(64)}.glb`; const foreign = 'notes.txt'; const tmpOld = '.tmp-123-abcdefabcdef';
|
|
231
|
+
plantEntry(stale, old); plantEntry(fresh, new Date()); plantEntry(foreign, old); plantEntry(tmpOld, old);
|
|
232
|
+
const usedName = path.basename(manifest().assets.scene.uri);
|
|
233
|
+
fs.utimesSync(path.join(shared, usedName), old, old);
|
|
234
|
+
const gcRun = spawnSync(process.execPath, [CLI, 'export', deck], { encoding: 'utf8', timeout: 180_000,
|
|
235
|
+
env: { ...process.env, CASTLE_NO_AUTO_UPDATE: '1', CASTLE_WEB_KITS_DIR: kits, CASTLE_EXPORT_CACHE_ROOT: cacheRoot, CASTLE_EXPORT_GC: '1' } });
|
|
236
|
+
assert.equal(gcRun.status, 0, gcRun.stdout + gcRun.stderr);
|
|
237
|
+
assert.ok(!fs.existsSync(path.join(shared, stale)) && !fs.existsSync(path.join(shared, tmpOld)), 'stale entry and temp file removed');
|
|
238
|
+
for (const name of [fresh, foreign, usedName]) assert.ok(fs.existsSync(path.join(shared, name)), `${name} kept`);
|
|
239
|
+
for (const a of Object.values(manifest().assets)) assert.ok(fs.existsSync(path.join(shared, path.basename(a.uri))), `${a.uri} still cached`);
|
|
240
|
+
fs.rmSync(path.join(shared, fresh)); fs.rmSync(path.join(shared, foreign));
|
|
241
|
+
// The once-a-day marker is replaced, never written through: a symlink there leaves its target alone.
|
|
242
|
+
const markerFile = path.join(cacheRoot, 'hubScene/.gc-at');
|
|
243
|
+
const victimFile = path.join(tmp, 'gc-marker-victim.txt');
|
|
244
|
+
fs.writeFileSync(victimFile, 'keep me');
|
|
245
|
+
fs.rmSync(markerFile, { force: true });
|
|
246
|
+
fs.symlinkSync(victimFile, markerFile);
|
|
247
|
+
const markerRun = spawnSync(process.execPath, [CLI, 'export', deck], { encoding: 'utf8', timeout: 180_000,
|
|
248
|
+
env: { ...process.env, CASTLE_NO_AUTO_UPDATE: '1', CASTLE_WEB_KITS_DIR: kits, CASTLE_EXPORT_CACHE_ROOT: cacheRoot, CASTLE_EXPORT_GC: '1' } });
|
|
249
|
+
assert.equal(markerRun.status, 0, markerRun.stdout + markerRun.stderr);
|
|
250
|
+
assert.equal(fs.readFileSync(victimFile, 'utf8'), 'keep me', 'the marker symlink target is untouched');
|
|
251
|
+
assert.ok(!fs.lstatSync(markerFile).isSymbolicLink(), 'the marker is a file of its own now');
|
|
252
|
+
|
|
253
|
+
// A code file added later that addresses a merged actor re-exports, and keeps it apart.
|
|
254
|
+
fs.writeFileSync(path.join(deck, 'code/server/rocks.js'), "export const hideRock = (hub) => hub.hide('rock-a');\n");
|
|
255
|
+
assert.equal(run().cached, false, 'a new code file exports again');
|
|
256
|
+
assert.ok(manifest().actors['rock-a'], 'rock-a, now hidden by code, has its own node');
|
|
257
|
+
fs.rmSync(path.join(deck, 'code/server/rocks.js'));
|
|
258
|
+
assert.equal(run().cached, false, 'removing it exports again');
|
|
259
|
+
assert.equal(manifest().actors['rock-a'], undefined);
|
|
260
|
+
|
|
261
|
+
// What a place can spawn, hide or show by an id the code never quotes for hide/show keeps its own
|
|
262
|
+
// node: a template only ever spawned, one the decor catalogue copies (`"decor": true`), and ids
|
|
263
|
+
// the scene's engine.hubKeepNodes patterns match. Unmatched still scenery is merged as before.
|
|
264
|
+
{
|
|
265
|
+
const { globMatch } = await import(path.join(REPO, 'kits/hub-game/tools/hubScene/hubdata.mjs'));
|
|
266
|
+
for (const [p, id, want] of [['statue-*', 'statue-n', true], ['statue-*', 'statue-', true], ['statue-*', 'statues', false], ['*-tpl', 'lamp-tpl', true],
|
|
267
|
+
['a*b*c', 'axxbyyc', true], ['a*b*c', 'axxbyy', false], ['*', '', true], ['', '', true], ['x', 'xy', false], ['a.b', 'axb', false]]) {
|
|
268
|
+
assert.equal(globMatch(p, id), want, `${p} ~ ${id}`);
|
|
269
|
+
}
|
|
270
|
+
const t1 = Date.now();
|
|
271
|
+
assert.equal(globMatch(`${'*'.repeat(24)}b`, 'a'.repeat(48)), false);
|
|
272
|
+
assert.equal(globMatch(`${'*a'.repeat(24)}b`, 'a'.repeat(48)), false);
|
|
273
|
+
assert.ok(Date.now() - t1 < 1000, 'linear-time glob');
|
|
274
|
+
const plainFile = path.join(deck, 'scenes/main.scene');
|
|
275
|
+
const plainText = fs.readFileSync(plainFile, 'utf8');
|
|
276
|
+
const plainManifest = manifest();
|
|
277
|
+
const sc = JSON.parse(plainText);
|
|
278
|
+
const rock = (id, x, extra = {}) => ({ id, static: true, ...extra, components: { Transform: { x, y: 0.3, z: 6 }, Shape: { kind: 'sphere', radius: 0.4, color: '#8d8d8d' }, Solid: {} } });
|
|
279
|
+
sc.actors.push(rock('lamp-tpl', 1), rock('chair-tpl', 2, { decor: true }), rock('statue-n', 3), rock('statue-s', 4), rock('tpl-gem', 5), rock('pebble', 6), rock('opt-rock', 7), rock('a'.repeat(48), 8));
|
|
280
|
+
sc.actors.find((a) => a.id === 'chair-tpl').components = { Transform: { x: 2, y: 0.3, z: 6 }, Shape: { kind: 'box', width: 0.5, height: 0.5, depth: 0.5 } };
|
|
281
|
+
fs.writeFileSync(plainFile, JSON.stringify(sc, null, 1));
|
|
282
|
+
// Only spawn: before, a file that called none of hide/show/tint/move/despawn/touch was not read for ids.
|
|
283
|
+
// An optional call with spaces is still a spawn; a quoted word elsewhere in a spawn-only file
|
|
284
|
+
// (a comment here) is not a target: only spawn's literal first argument is read.
|
|
285
|
+
fs.writeFileSync(path.join(deck, 'code/server/spawner.js'), "// called 'pebble' on the map\nexport const lamp = (hub) => hub.spawn('lamp-tpl', { x: 1, z: 1 });\nexport const opt = (hub) => hub.spawn ?. ('opt-rock', { x: 2 });\n");
|
|
286
|
+
assert.equal(run().cached, false);
|
|
287
|
+
let mm = manifest();
|
|
288
|
+
let mergedNow = Object.values(mm.merged).flat();
|
|
289
|
+
for (const id of ['lamp-tpl', 'chair-tpl', 'opt-rock']) assert.ok(mm.actors[id] && !mergedNow.includes(id), `${id}, a template, keeps its own node`);
|
|
290
|
+
for (const id of ['statue-n', 'statue-s', 'tpl-gem', 'pebble']) assert.ok(mergedNow.includes(id), `${id} is merged without a pattern`);
|
|
291
|
+
assert.ok(!mm.source.notes.some((n) => n.includes('hubKeepNodes')));
|
|
292
|
+
// A pattern list: `*` matches any run; ids it does not match still merge.
|
|
293
|
+
// Patterns that would make a backtracking RegExp run for ages on a 48-character id match in
|
|
294
|
+
// linear time and miss it.
|
|
295
|
+
sc.engine = { ...sc.engine, hubKeepNodes: ['statue-*', 'tpl-gem', `${'*'.repeat(24)}b`, `${'*a'.repeat(24)}b`] };
|
|
296
|
+
fs.writeFileSync(plainFile, JSON.stringify(sc, null, 1));
|
|
297
|
+
const t0 = Date.now();
|
|
298
|
+
assert.equal(run().cached, false, 'a new pattern exports again');
|
|
299
|
+
assert.ok(Date.now() - t0 < 60_000, `pathological patterns took ${Date.now() - t0} ms`);
|
|
300
|
+
mm = manifest();
|
|
301
|
+
mergedNow = Object.values(mm.merged).flat();
|
|
302
|
+
for (const id of ['statue-n', 'statue-s', 'tpl-gem']) assert.ok(mm.actors[id] && !mergedNow.includes(id), `${id} matches a pattern: its own node`);
|
|
303
|
+
assert.ok(mergedNow.includes('pebble') && mergedNow.includes('rock-a') && mergedNow.includes('a'.repeat(48)), 'unmatched scenery still merged');
|
|
304
|
+
assert.ok(mm.source.notes.some((n) => /marked actors kept apart: .*3 hubKeepNodes/.test(n)), mm.source.notes.join('\n'));
|
|
305
|
+
// A malformed list is ignored with a note, never a fault.
|
|
306
|
+
sc.engine.hubKeepNodes = ['statue-n', 7];
|
|
307
|
+
fs.writeFileSync(plainFile, JSON.stringify(sc, null, 1));
|
|
308
|
+
assert.equal(run().cached, false);
|
|
309
|
+
mm = manifest();
|
|
310
|
+
assert.ok(mm.actors['statue-n'] && Object.values(mm.merged).flat().includes('statue-s'));
|
|
311
|
+
assert.ok(mm.source.notes.some((n) => n.includes('engine.hubKeepNodes takes a list')));
|
|
312
|
+
// Put back, a deck using none of it exports what it did before, byte for byte bar the key.
|
|
313
|
+
fs.writeFileSync(plainFile, plainText);
|
|
314
|
+
fs.rmSync(path.join(deck, 'code/server/spawner.js'));
|
|
315
|
+
assert.equal(run().cached, false);
|
|
316
|
+
const strip = (x) => JSON.stringify({ ...x, source: { ...x.source, inputKey: null, exportedAt: null } });
|
|
317
|
+
assert.equal(strip(manifest()), strip(plainManifest), 'an unaffected deck exports identically');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const sceneFile = path.join(deck, 'scenes/main.scene');
|
|
321
|
+
const scene = JSON.parse(fs.readFileSync(sceneFile, 'utf8'));
|
|
322
|
+
scene.actors.find((a) => a.id === 'bench-0').components.Transform.x = 3.5;
|
|
323
|
+
fs.writeFileSync(sceneFile, JSON.stringify(scene, null, 1));
|
|
324
|
+
assert.equal(run().cached, false, 'a changed scene exports again');
|
|
325
|
+
|
|
326
|
+
// The chat moderation opt-in (contract: "Optional chat report and block scene marker") is an
|
|
327
|
+
// interactable of its component alone: no Transform, nothing else the actor carries.
|
|
328
|
+
const modActor = { id: 'hub-chat-moderation', components: { Transform: { x: 1, y: 2, z: 3 }, Tag: { tag: 'x' }, HubChatModeration: { v: 1 } } };
|
|
329
|
+
scene.actors.push(modActor);
|
|
330
|
+
fs.writeFileSync(sceneFile, JSON.stringify(scene, null, 1));
|
|
331
|
+
const marked = run();
|
|
332
|
+
assert.deepEqual(marked.faults, [], 'the marker entry passes the validator');
|
|
333
|
+
assert.equal(marked.interactables, 4);
|
|
334
|
+
assert.deepEqual(manifest().interactables.find((a) => a.id === 'hub-chat-moderation'), { id: 'hub-chat-moderation', components: { HubChatModeration: { v: 1 } } });
|
|
335
|
+
// Anything but exactly { v: 1 } is no opt-in on the web (client/chatModeration.js): left out.
|
|
336
|
+
modActor.components.HubChatModeration = { v: 1, extra: true };
|
|
337
|
+
fs.writeFileSync(sceneFile, JSON.stringify(scene, null, 1));
|
|
338
|
+
assert.equal(run().interactables, 3);
|
|
339
|
+
assert.ok(!manifest().interactables.some((a) => a.id === 'hub-chat-moderation'), 'an inexact marker is not exported');
|
|
340
|
+
// The validator refuses a marker entry carrying anything else.
|
|
341
|
+
const { validateManifest } = await import('../validate-manifest.mjs');
|
|
342
|
+
const bad = { ...manifest(), interactables: [{ id: 'hub-chat-moderation', components: { HubChatModeration: { v: 1 }, Transform: { x: 0, y: 0, z: 0, rotationY: 0 } } }] };
|
|
343
|
+
assert.ok(validateManifest(bad, path.join(out, 'hub-mini'), { hash: false }).some((f) => f.startsWith('interactable hub-chat-moderation')), 'a marker with a Transform is a fault');
|
|
344
|
+
bad.interactables = [{ id: 'hub-chat-moderation', components: { HubChatModeration: { v: 2 } } }];
|
|
345
|
+
assert.ok(validateManifest(bad, path.join(out, 'hub-mini'), { hash: false }).some((f) => f.startsWith('interactable hub-chat-moderation')), 'a marker of another version is a fault');
|
|
346
|
+
bad.interactables = [{ id: 'hub-chat-moderation', components: { HubChatModeration: { v: 1 } } }];
|
|
347
|
+
assert.deepEqual(validateManifest(bad, path.join(out, 'hub-mini'), { hash: false }), []);
|
|
348
|
+
scene.actors.pop();
|
|
349
|
+
fs.writeFileSync(sceneFile, JSON.stringify(scene, null, 1));
|
|
350
|
+
assert.equal(run().interactables, 3, 'the marker removed, the export has none again');
|
|
351
|
+
|
|
352
|
+
// v1.6 sound: the files the hub block's root and places' idle.sounds name, as the page's
|
|
353
|
+
// initialMedia holds them, content-addressed in shared/ and mapped by their castle.json path;
|
|
354
|
+
// deck.soundscape and the idle blocks at their keys; the jukebox and soundscape actors.
|
|
355
|
+
{
|
|
356
|
+
const cjFile = path.join(deck, 'castle.json');
|
|
357
|
+
const cjText = fs.readFileSync(cjFile, 'utf8');
|
|
358
|
+
const sceneText = fs.readFileSync(sceneFile, 'utf8');
|
|
359
|
+
const cj = JSON.parse(cjText);
|
|
360
|
+
const soundscape = { ui: true, zones: 'TownDistrict', steps: { default: 'street', zones: { 'district-a': 'grass' }, paths: 'TownAlley' },
|
|
361
|
+
ambience: { default: 'square', beds: { 'district-a': 'meadow' }, spots: { TownStamp: 'market' }, music: true } };
|
|
362
|
+
cj.hub = { ...cj.hub, soundscape, idle: { emotes: true, sounds: ['sounds/song-a.mp3', 'sounds/gone.mp3', 'sounds/odd.ogg', '../outside.mp3', 'sounds/song-a.mp3'] },
|
|
363
|
+
places: { main: { invite: false, idle: { sounds: ['sounds/rain.wav', 'sounds/song-a.mp3'] } }, side: { title: 'Side' } } };
|
|
364
|
+
fs.writeFileSync(cjFile, JSON.stringify(cj, null, 1));
|
|
365
|
+
fs.mkdirSync(path.join(deck, 'sounds'), { recursive: true });
|
|
366
|
+
fs.writeFileSync(path.join(deck, 'sounds/song-a.mp3'), Buffer.from('ID3 song a'));
|
|
367
|
+
fs.writeFileSync(path.join(deck, 'sounds/rain.wav'), Buffer.from('RIFF rain'));
|
|
368
|
+
fs.writeFileSync(path.join(deck, 'sounds/odd.ogg'), Buffer.from('OggS'));
|
|
369
|
+
fs.writeFileSync(path.join(tmp, 'outside.mp3'), Buffer.from('ID3 outside'));
|
|
370
|
+
const sc = JSON.parse(sceneText);
|
|
371
|
+
const jukebox = { Transform: { x: 2, y: 0, z: -3, rotationY: 90 }, Shape: { kind: 'box', width: 1, height: 1.6, depth: 0.6, color: '#884422' }, Lookable: { prompt: 'Jukebox' }, Tag: { tag: 'music' } };
|
|
372
|
+
sc.actors.push({ id: 'jukebox', components: jukebox },
|
|
373
|
+
{ id: 'district-a', components: { Transform: { x: 0, y: 0, z: 0 }, TownDistrict: { id: 'district-a', x0: -10, x1: 10, z0: -10, z1: 10 } } },
|
|
374
|
+
{ id: 'alley-1', components: { Transform: { x: 5, y: 0, z: 5 }, TownAlley: { x0: 4, x1: 6, z0: 0, z1: 9 } } },
|
|
375
|
+
{ id: 'stamp-1', components: { Transform: { x: -3, y: 0.5, z: 2, rotationY: 30 }, Shape: { kind: 'box' }, TownStamp: { radius: 4 } } });
|
|
376
|
+
fs.writeFileSync(sceneFile, JSON.stringify(sc, null, 1));
|
|
377
|
+
const sounded = run();
|
|
378
|
+
assert.deepEqual(sounded.faults, [], 'the v1.6 manifest passes the validator');
|
|
379
|
+
assert.equal(sounded.cached, false);
|
|
380
|
+
assert.equal(sounded.audio, 2);
|
|
381
|
+
const sm = manifest();
|
|
382
|
+
const sha = (rel) => crypto.createHash('sha256').update(fs.readFileSync(path.join(deck, rel))).digest('hex');
|
|
383
|
+
assert.deepEqual(sm.audio, { 'sounds/song-a.mp3': 'audio-0', 'sounds/rain.wav': 'audio-1' }, 'root sounds first, then places; each once; only what the page bundles');
|
|
384
|
+
assert.deepEqual(sm.assets['audio-0'], { type: 'mp3', uri: `../shared/${sha('sounds/song-a.mp3')}.mp3`, sha256: sha('sounds/song-a.mp3'), bytes: 10, shared: true });
|
|
385
|
+
assert.equal(sm.assets['audio-1'].type, 'wav');
|
|
386
|
+
assert.ok(fs.existsSync(path.join(out, 'shared', `${sha('sounds/rain.wav')}.wav`)), 'the sound is staged in shared/');
|
|
387
|
+
assert.ok(fs.existsSync(path.join(cacheRoot, 'hubScene/shared', `${sha('sounds/rain.wav')}.wav`)), 'and cached');
|
|
388
|
+
for (const why of ['"sounds/gone.mp3": missing', '"sounds/odd.ogg": not an .mp3', '"../outside.mp3": not a deck media path']) {
|
|
389
|
+
assert.ok(sm.source.notes.some((n) => n.startsWith(`sound ${why}`)), `noted: ${why}`);
|
|
390
|
+
}
|
|
391
|
+
assert.deepEqual(sm.deck.soundscape, soundscape, 'the soundscape as castle.json has it');
|
|
392
|
+
assert.deepEqual(sm.deck.idle, cj.hub.idle, 'the root idle at its key');
|
|
393
|
+
assert.deepEqual(sm.deck.places, { main: { idle: { sounds: ['sounds/rain.wav', 'sounds/song-a.mp3'] } } }, 'places with an idle, only that');
|
|
394
|
+
const inter = Object.fromEntries(sm.interactables.map((a) => [a.id, a.components]));
|
|
395
|
+
// As the kit's world holds them (its defaults filled in), like every interactable's components.
|
|
396
|
+
assert.deepEqual(Object.keys(inter.jukebox), ['Lookable', 'Transform', 'Shape'], 'the jukebox: Lookable, Transform, Shape, nothing else');
|
|
397
|
+
assert.deepEqual(inter.jukebox.Transform, { x: 2, y: 0, z: -3, rotationY: 90 });
|
|
398
|
+
assert.equal(inter.jukebox.Lookable.prompt, 'Jukebox');
|
|
399
|
+
assert.deepEqual([inter.jukebox.Shape.kind, inter.jukebox.Shape.height, inter.jukebox.Shape.color], ['box', 1.6, '#884422']);
|
|
400
|
+
assert.deepEqual(inter['district-a'], { TownDistrict: { id: 'district-a', x0: -10, x1: 10, z0: -10, z1: 10 }, Transform: { x: 0, y: 0, z: 0, rotationY: 0 } }, 'a zone with no draw node');
|
|
401
|
+
assert.deepEqual(inter['alley-1'], { TownAlley: { x0: 4, x1: 6, z0: 0, z1: 9 }, Transform: { x: 5, y: 0, z: 5, rotationY: 0 } });
|
|
402
|
+
assert.deepEqual(inter['stamp-1'], { TownStamp: { radius: 4 }, Transform: { x: -3, y: 0.5, z: 2, rotationY: 30 } }, 'a spot: its component whole, no Shape');
|
|
403
|
+
const inputs = JSON.parse(fs.readFileSync(path.join(out, 'hub-mini/inputs.json'), 'utf8')).inputs;
|
|
404
|
+
assert.ok(inputs.some((i) => i.path === 'sounds/song-a.mp3' && i.sha256 === sha('sounds/song-a.mp3')), 'a sound file is an input');
|
|
405
|
+
assert.ok(inputs.some((i) => i.path === 'sounds/gone.mp3' && i.sha256 === null), 'a missing one too');
|
|
406
|
+
assert.equal(run().cached, true, 'unchanged, reused');
|
|
407
|
+
fs.writeFileSync(path.join(deck, 'sounds/gone.mp3'), Buffer.from('ID3 back'));
|
|
408
|
+
assert.equal(run().cached, false, 'a named sound appearing exports again');
|
|
409
|
+
assert.equal(manifest().audio['sounds/gone.mp3'], 'audio-1');
|
|
410
|
+
fs.writeFileSync(path.join(deck, 'sounds/song-a.mp3'), Buffer.from('ID3 song a, remixed'));
|
|
411
|
+
assert.equal(run().cached, false, 'a changed sound exports again');
|
|
412
|
+
assert.equal(manifest().assets['audio-0'].sha256, sha('sounds/song-a.mp3'));
|
|
413
|
+
// A sound that is a link is never followed, even to the same bytes, and the swap is a new
|
|
414
|
+
// input both ways: the cached manifest is not reused with the wrong audio.
|
|
415
|
+
const rain = path.join(deck, 'sounds/rain.wav');
|
|
416
|
+
const rainBytes = fs.readFileSync(rain);
|
|
417
|
+
fs.writeFileSync(path.join(tmp, 'rain-copy.wav'), rainBytes);
|
|
418
|
+
fs.rmSync(rain);
|
|
419
|
+
fs.symlinkSync(path.join(tmp, 'rain-copy.wav'), rain);
|
|
420
|
+
assert.equal(manifest().audio['sounds/rain.wav'], 'audio-2');
|
|
421
|
+
const linked = run();
|
|
422
|
+
assert.equal(linked.cached, false, 'a sound replaced by a link to the same bytes exports again');
|
|
423
|
+
assert.equal(manifest().audio['sounds/rain.wav'], undefined, 'a linked sound is left out');
|
|
424
|
+
assert.ok(manifest().source.notes.includes('sound "sounds/rain.wav": a link, not followed; left out'));
|
|
425
|
+
fs.rmSync(rain);
|
|
426
|
+
fs.writeFileSync(rain, rainBytes);
|
|
427
|
+
assert.equal(run().cached, false, 'the link replaced by a regular copy exports again');
|
|
428
|
+
assert.equal(manifest().audio['sounds/rain.wav'], 'audio-2');
|
|
429
|
+
// A folder on the way out of the deck is refused by real path, without reading the file.
|
|
430
|
+
fs.mkdirSync(path.join(tmp, 'outside-sounds'));
|
|
431
|
+
fs.writeFileSync(path.join(tmp, 'outside-sounds/far.mp3'), Buffer.from('ID3 far'));
|
|
432
|
+
fs.symlinkSync(path.join(tmp, 'outside-sounds'), path.join(deck, 'far'));
|
|
433
|
+
// A FIFO named as a sound is never opened (it would block the export).
|
|
434
|
+
assert.equal(spawnSync('mkfifo', [path.join(deck, 'sounds/pipe.mp3')]).status, 0, 'mkfifo');
|
|
435
|
+
const cjNow = JSON.parse(fs.readFileSync(cjFile, 'utf8'));
|
|
436
|
+
cjNow.hub.places.side.idle = { sounds: ['far/far.mp3', 'sounds/pipe.mp3'] };
|
|
437
|
+
fs.writeFileSync(cjFile, JSON.stringify(cjNow, null, 1));
|
|
438
|
+
const odd = run();
|
|
439
|
+
assert.deepEqual(odd.faults, []);
|
|
440
|
+
const om = manifest();
|
|
441
|
+
assert.equal(om.audio['far/far.mp3'], undefined);
|
|
442
|
+
assert.equal(om.audio['sounds/pipe.mp3'], undefined);
|
|
443
|
+
assert.ok(om.source.notes.includes('sound "far/far.mp3": a link, not followed; left out'));
|
|
444
|
+
assert.ok(om.source.notes.includes('sound "sounds/pipe.mp3": not a regular file; left out'));
|
|
445
|
+
assert.equal(run().cached, true, 'and reused while nothing changes, the FIFO never opened');
|
|
446
|
+
fs.rmSync(path.join(deck, 'far'));
|
|
447
|
+
// A folder link that stays inside the deck is not followed either.
|
|
448
|
+
// (Its own folder: sounds/ holds the FIFO, which the deck's other readers must not reach.)
|
|
449
|
+
fs.mkdirSync(path.join(deck, 'more-sounds'));
|
|
450
|
+
fs.copyFileSync(path.join(deck, 'sounds/song-a.mp3'), path.join(deck, 'more-sounds/song-a.mp3'));
|
|
451
|
+
fs.symlinkSync(path.join(deck, 'more-sounds'), path.join(deck, 'inside'));
|
|
452
|
+
const cjIn = JSON.parse(fs.readFileSync(cjFile, 'utf8'));
|
|
453
|
+
cjIn.hub.places.side.idle = { sounds: ['inside/song-a.mp3'] };
|
|
454
|
+
fs.writeFileSync(cjFile, JSON.stringify(cjIn, null, 1));
|
|
455
|
+
run();
|
|
456
|
+
assert.equal(manifest().audio['inside/song-a.mp3'], undefined, 'a sound under a linked folder is left out');
|
|
457
|
+
assert.ok(manifest().source.notes.includes('sound "inside/song-a.mp3": a link, not followed; left out'));
|
|
458
|
+
fs.rmSync(path.join(deck, 'inside'));
|
|
459
|
+
fs.rmSync(path.join(deck, 'more-sounds'), { recursive: true });
|
|
460
|
+
// The validator: an audio entry must name an audio asset, and the soundscape keeps its shape.
|
|
461
|
+
const { validateManifest } = await import('../validate-manifest.mjs');
|
|
462
|
+
const dir = path.join(out, 'hub-mini');
|
|
463
|
+
const v = (patch) => validateManifest({ ...manifest(), ...patch }, dir, { hash: false });
|
|
464
|
+
assert.ok(v({ audio: { 'x.mp3': 'scene' } }).includes('audio x.mp3: asset scene is not audio'));
|
|
465
|
+
assert.ok(v({ audio: { 'x.mp3': 'nope' } }).includes('audio x.mp3: unknown asset nope'));
|
|
466
|
+
assert.ok(v({ deck: { soundscape: { zones: 'Town District' } } }).includes('deck.soundscape.zones'));
|
|
467
|
+
assert.ok(v({ interactables: [{ id: 'crate', components: { Shape: {}, Transform: { x: 0, y: 0, z: 0, rotationY: 0 } } }] }).some((f) => f.startsWith('interactable crate')), 'a non-jukebox Shape-only actor is no interactable');
|
|
468
|
+
fs.writeFileSync(cjFile, cjText);
|
|
469
|
+
fs.writeFileSync(sceneFile, sceneText);
|
|
470
|
+
fs.rmSync(path.join(deck, 'sounds'), { recursive: true, force: true });
|
|
471
|
+
const back = run();
|
|
472
|
+
assert.equal(back.audio, 0, 'sounds named no more, none exported');
|
|
473
|
+
assert.equal(back.interactables, 3);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// A door's preferred folder (devDecks) appearing later is a new input.
|
|
477
|
+
assert.equal(manifest().doors.find((d) => d.id === 'dash2').target.deckId, 'fixtureDash2');
|
|
478
|
+
fs.mkdirSync(path.join(tmp, 'dash2-preferred'));
|
|
479
|
+
fs.writeFileSync(path.join(tmp, 'dash2-preferred/castle.json'), JSON.stringify({ deckId: 'fixturePref2' }));
|
|
480
|
+
assert.equal(run().cached, false, 'the preferred door folder appearing exports again');
|
|
481
|
+
assert.equal(manifest().doors.find((d) => d.id === 'dash2').target.deckId, 'fixturePref2');
|
|
482
|
+
|
|
483
|
+
// Any file in a shipped kit's tree is in the key, however the loader would reach it.
|
|
484
|
+
fs.appendFileSync(path.join(kits, 'physics-3d/engine3d/sky.js'), '\n// changed\n');
|
|
485
|
+
assert.equal(run().cached, false, 'a kit file change exports again');
|
|
486
|
+
|
|
487
|
+
// A deck file the shipped kit stood in for, appearing later, is a new input.
|
|
488
|
+
const avatarModel = path.join(deck, 'imports/castle.hub-game/models/avatar-0.pxmodel');
|
|
489
|
+
fs.mkdirSync(path.dirname(avatarModel), { recursive: true });
|
|
490
|
+
fs.writeFileSync(avatarModel, fs.readFileSync(path.join(kits, 'hub-game/models/avatar-0.pxmodel')));
|
|
491
|
+
assert.equal(run().cached, false, "the deck's own copy of a shipped file appearing exports again");
|
|
492
|
+
fs.rmSync(path.join(deck, 'imports'), { recursive: true, force: true });
|
|
493
|
+
|
|
494
|
+
// A deck's imports/ is data: its code never runs, pinned or not.
|
|
495
|
+
const cjFile = path.join(deck, 'castle.json');
|
|
496
|
+
const cj = JSON.parse(fs.readFileSync(cjFile, 'utf8'));
|
|
497
|
+
plant(path.join(deck, 'imports/castle.physics-3d/engine3d/world3d.js'));
|
|
498
|
+
plant(path.join(deck, 'imports/castle.unpinned/index.js'));
|
|
499
|
+
fs.writeFileSync(path.join(deck, 'imports/castle.physics-3d/castle.json'), '{}');
|
|
500
|
+
fs.writeFileSync(cjFile, JSON.stringify({ ...cj, imports: { ...cj.imports, 'castle.physics-3d': { deckId: 'someoneElse1', version: 'x' } } }));
|
|
501
|
+
assert.deepEqual(run().faults, []);
|
|
502
|
+
assert.ok(!fs.existsSync(marker), 'imports/ code never ran');
|
|
503
|
+
fs.writeFileSync(cjFile, JSON.stringify(cj));
|
|
504
|
+
fs.rmSync(path.join(deck, 'imports'), { recursive: true, force: true });
|
|
505
|
+
|
|
506
|
+
// three comes from the CLI's own copy (cli/vendor/three), never from the deck's node_modules.
|
|
507
|
+
const deckThree = path.join(deck, 'node_modules/three');
|
|
508
|
+
fs.mkdirSync(path.join(deckThree, 'build'), { recursive: true });
|
|
509
|
+
fs.writeFileSync(path.join(deckThree, 'package.json'), JSON.stringify({ name: 'three', version: '0.0.1-planted', type: 'module', exports: { '.': './build/three.module.js' } }));
|
|
510
|
+
plant(path.join(deckThree, 'build/three.module.js'));
|
|
511
|
+
const vendored = JSON.parse(fs.readFileSync(path.join(REPO, 'cli/vendor/three/package.json'), 'utf8')).version;
|
|
512
|
+
const withPlant = exportDeck();
|
|
513
|
+
assert.equal(withPlant.status, 0, withPlant.output);
|
|
514
|
+
assert.ok(!fs.existsSync(marker), "the deck's three never ran");
|
|
515
|
+
assert.equal(manifest().source.three, vendored, 'built with the CLI\'s three');
|
|
516
|
+
// By hand, with no CLI copy named and no three the kits resolve: refused, not the deck's.
|
|
517
|
+
fs.renameSync(path.join(tmp, 'node_modules'), path.join(tmp, 'node_modules-aside'));
|
|
518
|
+
const stage = fs.mkdtempSync(path.join(tmp, 'stage-'));
|
|
519
|
+
const byHand = spawnSync(process.execPath, [path.join(kits, 'hub-game/tools/hubScene/export.mjs'), '--deck', deck, '--stage', stage, '--cache', path.join(tmp, 'cache-by-hand'), '--kits', kits],
|
|
520
|
+
{ encoding: 'utf8', timeout: 120_000, env: { ...process.env, CASTLE_EXPORT_THREE_DIR: '' } });
|
|
521
|
+
fs.renameSync(path.join(tmp, 'node_modules-aside'), path.join(tmp, 'node_modules'));
|
|
522
|
+
assert.notEqual(byHand.status, 0, 'no three for the kits: refused');
|
|
523
|
+
assert.ok(/three is not installed for the shipped kits/.test(byHand.stderr), byHand.stderr);
|
|
524
|
+
assert.ok(!fs.existsSync(marker), "and the deck's three never ran");
|
|
525
|
+
// A CLI installed in the deck (kits under its node_modules) without its three copy: refused,
|
|
526
|
+
// though walking up from those kits would find the deck's planted three.
|
|
527
|
+
const installedKits = path.join(deck, 'node_modules/castle-web-cli/kits');
|
|
528
|
+
fs.mkdirSync(path.dirname(installedKits), { recursive: true });
|
|
529
|
+
fs.cpSync(kits, installedKits, { recursive: true });
|
|
530
|
+
const stage2 = fs.mkdtempSync(path.join(tmp, 'stage-'));
|
|
531
|
+
const installed = spawnSync(process.execPath, [path.join(installedKits, 'hub-game/tools/hubScene/export.mjs'), '--deck', deck, '--stage', stage2, '--cache', path.join(tmp, 'cache-by-hand'), '--kits', installedKits],
|
|
532
|
+
{ encoding: 'utf8', timeout: 120_000, env: { ...process.env, CASTLE_EXPORT_THREE_DIR: '' } });
|
|
533
|
+
assert.notEqual(installed.status, 0, 'installed kits without the CLI three: refused');
|
|
534
|
+
assert.ok(/an installed package's/.test(installed.stderr), installed.stderr);
|
|
535
|
+
assert.ok(!fs.existsSync(marker), "and the deck's three never ran");
|
|
536
|
+
fs.rmSync(path.join(deck, 'node_modules'), { recursive: true, force: true });
|
|
537
|
+
|
|
538
|
+
// A module symlinked out of a shipped kit is refused by its real path.
|
|
539
|
+
const sky = path.join(kits, 'physics-3d/engine3d/sky.js');
|
|
540
|
+
const skyText = fs.readFileSync(sky);
|
|
541
|
+
const outsideModule = path.join(tmp, 'outside-module/sky.js');
|
|
542
|
+
plant(outsideModule);
|
|
543
|
+
fs.rmSync(sky);
|
|
544
|
+
fs.symlinkSync(outsideModule, sky);
|
|
545
|
+
const linked = exportDeck();
|
|
546
|
+
assert.notEqual(linked.status, 0, 'a kit module symlinked outside the kits is refused');
|
|
547
|
+
assert.ok(/refused to load/.test(linked.output), linked.output);
|
|
548
|
+
assert.ok(!fs.existsSync(marker), 'and never ran');
|
|
549
|
+
fs.rmSync(sky);
|
|
550
|
+
fs.writeFileSync(sky, skyText);
|
|
551
|
+
|
|
552
|
+
// The exporter's own helpers come in through the guard too: one symlinked outside is refused.
|
|
553
|
+
const helper = path.join(kits, 'hub-game/tools/hubScene/hubdata.mjs');
|
|
554
|
+
const helperText = fs.readFileSync(helper);
|
|
555
|
+
fs.rmSync(helper);
|
|
556
|
+
fs.symlinkSync(outsideModule, helper);
|
|
557
|
+
const helperRun = exportDeck();
|
|
558
|
+
assert.notEqual(helperRun.status, 0, 'a helper symlinked outside the kits is refused');
|
|
559
|
+
assert.ok(/refused to load/.test(helperRun.output), helperRun.output);
|
|
560
|
+
assert.ok(!fs.existsSync(marker), 'and never ran');
|
|
561
|
+
fs.rmSync(helper);
|
|
562
|
+
fs.writeFileSync(helper, helperText);
|
|
563
|
+
|
|
564
|
+
// The reserved hub ids name folders a manifest root keeps for itself.
|
|
565
|
+
for (const id of ['shared', 'packs', '../../x']) {
|
|
566
|
+
fs.writeFileSync(cjFile, JSON.stringify({ ...cj, deckId: id }));
|
|
567
|
+
const before = fs.readdirSync(out).sort();
|
|
568
|
+
const refused = exportDeck();
|
|
569
|
+
assert.notEqual(refused.status, 0, `hub id ${id} is refused`);
|
|
570
|
+
assert.ok(/is not an id/.test(refused.output), refused.output);
|
|
571
|
+
assert.deepEqual(fs.readdirSync(out).sort(), before, 'the deck output is unchanged');
|
|
572
|
+
assert.ok(fs.existsSync(path.join(out, 'hub-mini/manifest.json')), 'the last good manifest is kept');
|
|
573
|
+
}
|
|
574
|
+
fs.writeFileSync(cjFile, JSON.stringify(cj));
|
|
575
|
+
|
|
576
|
+
// A .castle, or .castle/exports, symlinked outside the deck: refused before anything runs,
|
|
577
|
+
// nothing written or deleted out there.
|
|
578
|
+
for (const linkAt of ['.castle', '.castle/exports']) {
|
|
579
|
+
const deck2 = path.join(tmp, `hub-mini-${linkAt.length}`);
|
|
580
|
+
fs.cpSync(deck, deck2, { recursive: true, filter: (src) => !src.includes(`${path.sep}.castle`) });
|
|
581
|
+
const outside = path.join(tmp, `outside-${linkAt.length}`);
|
|
582
|
+
const victim = path.join(outside, linkAt === '.castle' ? 'exports/hubScene/shared/victim.glb' : 'hubScene/shared/victim.glb');
|
|
583
|
+
fs.mkdirSync(path.dirname(victim), { recursive: true });
|
|
584
|
+
fs.writeFileSync(victim, 'keep me');
|
|
585
|
+
const listing = () => fs.readdirSync(outside, { recursive: true }).map(String).sort();
|
|
586
|
+
const before = listing();
|
|
587
|
+
fs.mkdirSync(path.dirname(path.join(deck2, linkAt)), { recursive: true });
|
|
588
|
+
fs.symlinkSync(outside, path.join(deck2, linkAt));
|
|
589
|
+
const r = exportDeck(deck2);
|
|
590
|
+
assert.notEqual(r.status, 0, `${linkAt} symlinked outside is refused`);
|
|
591
|
+
assert.ok(/refused its output folders/.test(r.output), r.output);
|
|
592
|
+
assert.equal(fs.readFileSync(victim, 'utf8'), 'keep me', 'nothing outside was deleted');
|
|
593
|
+
assert.deepEqual(listing(), before, 'nothing outside was written');
|
|
594
|
+
}
|
|
595
|
+
await hiddenActorsExport();
|
|
596
|
+
console.log(`hubScene export fixture OK (cold ${cold.seconds}s, ${cold.totalBytes} bytes)`);
|
|
597
|
+
} finally {
|
|
598
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// An actor a live page hid before the export (a live session's ready code ran hub.hide on its spawn
|
|
602
|
+
// templates and car looks: node hidden and dropped HIDE_DROP_M below) still has its meshes in the
|
|
603
|
+
// scene glb and its split model, at its authored pose, so native can copy it (hub.spawn) or show it;
|
|
604
|
+
// it stays visibleAtExport false and in hiddenAtExport, is never merged, and everything collect
|
|
605
|
+
// changed is put back. The CLI's Node world hides nothing, so this one runs collectHubData itself
|
|
606
|
+
// over a world built in this process (the kits' bundler paths resolved as paint-export.mjs does).
|
|
607
|
+
async function hiddenActorsExport() {
|
|
608
|
+
await import('../../../../physics-3d/scripts/test-static-passes.mjs');
|
|
609
|
+
const THREE = await import('three');
|
|
610
|
+
const { GLTFExporter } = await import('three/examples/jsm/exporters/GLTFExporter.js');
|
|
611
|
+
const { mergeGeometries } = await import('three/examples/jsm/utils/BufferGeometryUtils.js');
|
|
612
|
+
const world3d = await import('../../../../physics-3d/engine3d/world3d.js');
|
|
613
|
+
const { parseBlueprintText, mergeComponents } = await import('../../../../physics-2d/engine/blueprintCore.js');
|
|
614
|
+
const { buildDeckWorld } = await import('../nodeworld.mjs');
|
|
615
|
+
const { collectHubData } = await import('../hubdata.mjs');
|
|
616
|
+
const engine = { THREE, GLTFExporter, mergeGeometries, world3d, parseBlueprintText, mergeComponents, resolveDeckFile: (ref) => ref };
|
|
617
|
+
|
|
618
|
+
const box = (id, x, extra = {}) => ({ id, static: true, ...extra, components: { Transform: { x, y: 0.3, z: 4, rotationY: 30 }, Shape: { kind: 'box', width: 0.5, height: 0.5, depth: 0.5, color: '#8d8d8d' }, Solid: {} } });
|
|
619
|
+
const scene = { name: 'Hidden', engine: { staticActors: true }, actors: [
|
|
620
|
+
{ id: 'floor', components: { Transform: { y: -0.25 }, Shape: { kind: 'box', width: 20, height: 0.5, depth: 20 }, Solid: {}, WalkSurface: {} } },
|
|
621
|
+
{ id: 'player', components: { Transform: { x: 0, y: 1, z: 0 }, Shape: { kind: 'capsule', radius: 0.35, height: 1.4 }, Player: {} } },
|
|
622
|
+
box('rock', 1), box('rock-2', 2),
|
|
623
|
+
// A spawn template the place hid at ready (hidden and dropped), and one only dropped.
|
|
624
|
+
box('piece-tpl', 3, { spawnTemplate: true }), box('piece-low', 4),
|
|
625
|
+
// A car look drawn by a model (a split model), hidden and dropped.
|
|
626
|
+
{ id: 'car-sedan', components: { Transform: { x: -3, y: 0, z: 2, rotationY: 90 }, Shape: { kind: 'box', width: 2, height: 0.6, depth: 0.6 }, Model: { file: 'models/bench.pxmodel' } } },
|
|
627
|
+
// An actor whose parent group is hidden, beside one that group also hides.
|
|
628
|
+
box('lamp-tpl', 5), box('lamp-other', 6),
|
|
629
|
+
// A parked stall carrying a sign as its child node (still scenery both), and a kiosk under a
|
|
630
|
+
// visible subgroup of a hidden group, beside a mesh that group hides.
|
|
631
|
+
box('stall', 7), { ...box('stall-sign', 7), components: { ...box('stall-sign', 7).components, Transform: { x: 7, y: 1.3, z: 4 } } },
|
|
632
|
+
box('kiosk', 8),
|
|
633
|
+
// A parked, hidden crate with a lid hidden on its own and moved off its authored (local) place.
|
|
634
|
+
// One the page took out of the scene (tiers.js hide) and a car look held outside it.
|
|
635
|
+
box('gone-tpl', 10),
|
|
636
|
+
{ id: 'held-car', components: { Transform: { x: -5, y: 0, z: 2, rotationY: 90 }, Shape: { kind: 'box', width: 2, height: 0.6, depth: 0.6 }, Model: { file: 'models/bench.pxmodel' } } },
|
|
637
|
+
box('crate', 9), { ...box('crate-lid', 0), components: { ...box('crate-lid', 0).components, Transform: { x: 1, y: 1, z: 0 } } },
|
|
638
|
+
] };
|
|
639
|
+
const files = { 'scenes/hidden.scene': JSON.stringify(scene), 'models/bench.pxmodel': JSON.stringify(fixture.files['hub-mini/models/bench.pxmodel']) };
|
|
640
|
+
const glbJson = (b64) => {
|
|
641
|
+
const buf = Buffer.from(b64, 'base64');
|
|
642
|
+
return JSON.parse(buf.subarray(20, 20 + buf.readUInt32LE(12)).toString('utf8'));
|
|
643
|
+
};
|
|
644
|
+
const nodeMeshes = (gltf, name) => {
|
|
645
|
+
const i = gltf.nodes.findIndex((n) => n.name === name);
|
|
646
|
+
if (i < 0) return null;
|
|
647
|
+
let count = 0;
|
|
648
|
+
const walk = (k) => { if (gltf.nodes[k].mesh !== undefined) count += 1; for (const c of gltf.nodes[k].children ?? []) walk(c); };
|
|
649
|
+
walk(i);
|
|
650
|
+
return { count, node: gltf.nodes[i] };
|
|
651
|
+
};
|
|
652
|
+
// GLTFExporter dumps whole light objects when it drops the ambient/hemisphere lights (as export.mjs).
|
|
653
|
+
const quiet = async (f) => { const warn = console.warn; console.warn = () => {}; try { return await f(); } finally { console.warn = warn; } };
|
|
654
|
+
const collect = () => quiet(() => collectHubData({ exportAvatar: false, splitModels: true, mergeStatic: { cellM: 24, exclude: new Set() } }));
|
|
655
|
+
|
|
656
|
+
// Nothing hidden: nothing changes (no note, all visible, the templates merged as plain scenery).
|
|
657
|
+
buildDeckWorld(engine, { files, scenePath: 'scenes/hidden.scene' });
|
|
658
|
+
const plainR = await collect();
|
|
659
|
+
assert.deepEqual(plainR.errors, []);
|
|
660
|
+
assert.ok(!plainR.notes.some((n) => n.startsWith('hidden at export')), plainR.notes.join('\n'));
|
|
661
|
+
assert.ok(Object.values(plainR.actors).every((a) => a.visibleAtExport), 'nothing hidden');
|
|
662
|
+
assert.ok(Object.values(plainR.merged).flat().includes('piece-low'));
|
|
663
|
+
globalThis.__hub.tier = { current: 'low', profile: 'low' };
|
|
664
|
+
const plainLow = await collect();
|
|
665
|
+
assert.ok(!Object.hasOwn(plainLow.tiers.profiles.high, 'hiddenAtExport'), 'nothing hidden: the made-up High profile is as before');
|
|
666
|
+
globalThis.__hub.tier = null;
|
|
667
|
+
|
|
668
|
+
// Hidden as a live page hides them: node.visible false and the Transform dropped (hub.js applyVisibility).
|
|
669
|
+
const built = buildDeckWorld(engine, { files, scenePath: 'scenes/hidden.scene' });
|
|
670
|
+
const w = built.world;
|
|
671
|
+
const nodeOf = (id) => w.nodes.get(id).node;
|
|
672
|
+
const drop = (id, hide) => {
|
|
673
|
+
const t = globalThis.__hub.scene.actors.get(id).components.Transform;
|
|
674
|
+
t.y -= 10000; nodeOf(id).position.y -= 10000;
|
|
675
|
+
if (hide) nodeOf(id).visible = false;
|
|
676
|
+
};
|
|
677
|
+
drop('piece-tpl', true); drop('piece-low', false); drop('car-sedan', true);
|
|
678
|
+
const group = new THREE.Group();
|
|
679
|
+
group.name = 'district';
|
|
680
|
+
w.scene.add(group);
|
|
681
|
+
group.add(nodeOf('lamp-tpl'), nodeOf('lamp-other'));
|
|
682
|
+
group.visible = false;
|
|
683
|
+
// The sign hangs 1 m above the stall; the stall is parked, carrying it down too.
|
|
684
|
+
nodeOf('stall').add(nodeOf('stall-sign'));
|
|
685
|
+
nodeOf('stall-sign').position.set(0, 1, 0); nodeOf('stall-sign').quaternion.identity();
|
|
686
|
+
drop('stall', false);
|
|
687
|
+
nodeOf('crate').add(nodeOf('crate-lid'));
|
|
688
|
+
nodeOf('crate-lid').position.set(99, 1, 0); nodeOf('crate-lid').quaternion.identity(); nodeOf('crate-lid').visible = false;
|
|
689
|
+
drop('crate', true);
|
|
690
|
+
drop('gone-tpl', false); drop('held-car', false);
|
|
691
|
+
const gone = nodeOf('gone-tpl');
|
|
692
|
+
gone.parent.remove(gone);
|
|
693
|
+
const holder = new THREE.Group();
|
|
694
|
+
holder.name = 'holder';
|
|
695
|
+
holder.add(new THREE.Group());
|
|
696
|
+
holder.add(nodeOf('held-car'));
|
|
697
|
+
holder.updateMatrixWorld(true); gone.updateMatrixWorld(true);
|
|
698
|
+
const district2 = new THREE.Group();
|
|
699
|
+
const sub = new THREE.Group();
|
|
700
|
+
district2.visible = false;
|
|
701
|
+
w.scene.add(district2); district2.add(sub);
|
|
702
|
+
sub.add(nodeOf('kiosk'));
|
|
703
|
+
const decoy2 = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshBasicMaterial());
|
|
704
|
+
decoy2.name = 'decoy-under-subgroup';
|
|
705
|
+
sub.add(decoy2);
|
|
706
|
+
w.scene.updateMatrixWorld(true);
|
|
707
|
+
const before = new Map();
|
|
708
|
+
const note = (o) => before.set(o, [o.visible, o.position.toArray(), o.quaternion.toArray(), o.name, o.parent, o.parent?.children.indexOf(o), o.matrix.toArray(), o.matrixWorld.toArray()]);
|
|
709
|
+
const outside = new Set();
|
|
710
|
+
w.scene.traverse(note); holder.traverse((o) => { note(o); outside.add(o); }); gone.traverse((o) => { note(o); outside.add(o); });
|
|
711
|
+
|
|
712
|
+
const r = await collect();
|
|
713
|
+
assert.deepEqual(r.errors, []);
|
|
714
|
+
const hiddenIds = ['piece-tpl', 'piece-low', 'car-sedan', 'lamp-tpl', 'lamp-other', 'stall', 'stall-sign', 'kiosk', 'crate', 'crate-lid', 'gone-tpl', 'held-car'];
|
|
715
|
+
for (const id of hiddenIds) {
|
|
716
|
+
assert.equal(r.actors[id]?.visibleAtExport, false, `${id} stays hidden at export`);
|
|
717
|
+
assert.ok(r.tiers.profiles[r.tiers.default].hiddenAtExport.includes(id), `${id} in hiddenAtExport`);
|
|
718
|
+
}
|
|
719
|
+
const mergedIds = Object.values(r.merged).flat();
|
|
720
|
+
assert.ok(mergedIds.includes('rock') && mergedIds.includes('rock-2'), 'visible still scenery still merges');
|
|
721
|
+
for (const id of hiddenIds) assert.ok(!mergedIds.includes(id), `${id} is never merged`);
|
|
722
|
+
assert.ok(r.notes.includes('hidden at export: 12 actors exported with their meshes at their authored pose, still hidden'), r.notes.join('\n'));
|
|
723
|
+
|
|
724
|
+
const gltf = glbJson(r.sceneB64);
|
|
725
|
+
for (const id of ['piece-tpl', 'piece-low', 'lamp-tpl', 'lamp-other']) {
|
|
726
|
+
const found = nodeMeshes(gltf, id);
|
|
727
|
+
assert.ok(found && found.count > 0, `${id}'s mesh is in the scene glb`);
|
|
728
|
+
}
|
|
729
|
+
// At its authored pose, not dropped; bounds describe that pose.
|
|
730
|
+
const piece = nodeMeshes(gltf, 'piece-tpl').node;
|
|
731
|
+
const at = piece.translation ?? piece.matrix?.slice(12, 15);
|
|
732
|
+
assert.deepEqual(at?.map((n) => Math.round(n * 1e4) / 1e4), [3, 0.3, 4], JSON.stringify(piece));
|
|
733
|
+
assert.ok(r.actors['piece-tpl'].bounds[1] > 0 && r.actors['piece-low'].bounds[1] > 0, 'bounds at the authored pose');
|
|
734
|
+
assert.ok(r.actors['car-sedan'].bounds[1] > -1, 'a model actor too');
|
|
735
|
+
// The hidden group's other child (shown by nothing the page draws) comes along only as an actor
|
|
736
|
+
// of its own: it is hidden too, so it is lifted the same way. Nothing else the group held does.
|
|
737
|
+
const decoy = new THREE.Mesh(new THREE.BoxGeometry(), new THREE.MeshBasicMaterial());
|
|
738
|
+
decoy.name = 'decoy-under-district';
|
|
739
|
+
group.add(decoy);
|
|
740
|
+
const r2 = await collect();
|
|
741
|
+
assert.equal(nodeMeshes(glbJson(r2.sceneB64), 'decoy-under-district'), null, 'what a hidden ancestor hid that is no actor stays out');
|
|
742
|
+
group.remove(decoy);
|
|
743
|
+
// The car look: its model split out with an instance at the authored pose.
|
|
744
|
+
const prop = r.props.find((p) => p.instances.some((i) => i.actorId === 'car-sedan'));
|
|
745
|
+
assert.ok(prop, 'the hidden car look has its split model');
|
|
746
|
+
const inst = prop.instances.find((i) => i.actorId === 'car-sedan');
|
|
747
|
+
assert.ok(Math.abs(inst.transform[12] + 3) < 1e-4 && inst.transform[13] > -1 && Math.abs(inst.transform[14] - 2) < 1e-4, `instance at the authored pose: ${inst.transform}`);
|
|
748
|
+
// Stats: drawn counts what the page draws (not the hidden actors), inventory what the glb holds.
|
|
749
|
+
assert.ok(r.stats.drawnMeshes <= plainR.stats.drawnMeshes - 12, 'the twelve hidden actors are not drawn');
|
|
750
|
+
assert.ok(r.stats.meshes >= plainR.stats.meshes, 'the scene glb holds them');
|
|
751
|
+
|
|
752
|
+
// Everything put back: visibility, pose, names.
|
|
753
|
+
w.scene.updateMatrixWorld(true);
|
|
754
|
+
for (const [o, [visible, pos, quat, name, parent, index, matrix, matrixWorld]] of before) {
|
|
755
|
+
assert.equal(o.parent, parent, `${o.name} parent restored`);
|
|
756
|
+
assert.equal(o.parent?.children.indexOf(o), index, `${o.name} place restored`);
|
|
757
|
+
if (outside.has(o)) {
|
|
758
|
+
assert.deepEqual(o.matrix.toArray(), matrix, `${o.name} matrix restored`);
|
|
759
|
+
assert.deepEqual(o.matrixWorld.toArray(), matrixWorld, `${o.name} world matrix restored`);
|
|
760
|
+
}
|
|
761
|
+
assert.equal(o.visible, visible, `${o.name} visibility restored`);
|
|
762
|
+
assert.deepEqual(o.position.toArray(), pos, `${o.name} position restored`);
|
|
763
|
+
assert.deepEqual(o.quaternion.toArray(), quat, `${o.name} rotation restored`);
|
|
764
|
+
assert.equal(o.name, name);
|
|
765
|
+
}
|
|
766
|
+
// A parked parent's child is in the hidden set from the start (never merged), and its parent's
|
|
767
|
+
// lift brings it back to its authored place; a hidden group's visible subgroup keeps only the actor.
|
|
768
|
+
assert.ok(r.actors['stall-sign'].bounds[1] > 0.9, `the sign at its authored height: ${r.actors['stall-sign'].bounds}`);
|
|
769
|
+
assert.ok(nodeMeshes(gltf, 'stall-sign')?.count > 0 && nodeMeshes(gltf, 'kiosk')?.count > 0);
|
|
770
|
+
assert.equal(nodeMeshes(gltf, 'decoy-under-subgroup'), null, 'what the hidden group hid through a visible subgroup stays out');
|
|
771
|
+
// Taken out of the scene, or held outside it: drawn at the authored pose all the same, split model too.
|
|
772
|
+
const goneNode = nodeMeshes(gltf, 'gone-tpl');
|
|
773
|
+
assert.ok(goneNode?.count > 0, 'a detached actor is in the scene glb');
|
|
774
|
+
assert.deepEqual((goneNode.node.translation ?? goneNode.node.matrix?.slice(12, 15)).map((n) => Math.round(n * 1e4) / 1e4), [10, 0.3, 4]);
|
|
775
|
+
const heldInst = r.props.flatMap((x) => x.instances).find((i) => i.actorId === 'held-car');
|
|
776
|
+
assert.ok(heldInst && Math.abs(heldInst.transform[12] + 5) < 1e-4 && heldInst.transform[13] > -1, 'a held car look has its split model at its authored pose');
|
|
777
|
+
assert.ok(!r.notes.some((n) => n.includes('not in the scene')), r.notes.join('\n'));
|
|
778
|
+
// A child hidden on its own under a lifted parent gets its authored pose too, not where it was.
|
|
779
|
+
const lid = nodeMeshes(gltf, 'crate-lid').node;
|
|
780
|
+
assert.deepEqual((lid.translation ?? lid.matrix?.slice(12, 15))?.map((n) => Math.round(n * 1e4) / 1e4), [1, 1, 0], JSON.stringify(lid));
|
|
781
|
+
// A model actor's rig the page had hidden already is hidden again after, not shown.
|
|
782
|
+
const sedanNode = nodeOf('car-sedan');
|
|
783
|
+
const rig = sedanNode.children.find((c) => c.userData.modelParts === sedanNode.userData.modelParts);
|
|
784
|
+
rig.visible = false;
|
|
785
|
+
await collect();
|
|
786
|
+
assert.equal(rig.visible, false, 'a rig keeps its own visibility');
|
|
787
|
+
rig.visible = true;
|
|
788
|
+
// A Low export: the High profile it makes up carries the same hidden list.
|
|
789
|
+
globalThis.__hub.tier = { current: 'low', profile: 'low' };
|
|
790
|
+
const low = await collect();
|
|
791
|
+
assert.equal(low.tiers.default, 'low');
|
|
792
|
+
assert.deepEqual(low.tiers.profiles.high.hiddenAtExport, low.tiers.profiles.low.hiddenAtExport);
|
|
793
|
+
for (const id of hiddenIds) assert.ok(low.tiers.profiles.high.hiddenAtExport.includes(id), `${id} hidden on the High profile too`);
|
|
794
|
+
globalThis.__hub.tier = null;
|
|
795
|
+
// And so a second export is the same.
|
|
796
|
+
const again = await collect();
|
|
797
|
+
assert.equal(again.sceneB64, r.sceneB64, 'a second export after the restore is identical');
|
|
798
|
+
}
|