pelican-engine 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +147 -0
- package/LICENSE +22 -0
- package/README.md +129 -2
- package/distribution.json +197 -0
- package/docs/AI-WORKFLOW.md +517 -0
- package/docs/ARCHITECTURE.md +268 -0
- package/docs/CAPABILITIES.md +264 -0
- package/docs/DECISIONS.md +107 -0
- package/docs/M3-USAGE.md +192 -0
- package/docs/PELICAN-MIGRATION.md +38 -0
- package/docs/RENDER-BACKENDS.md +50 -0
- package/docs/ROADMAP.md +239 -0
- package/docs/THIRD-PARTY-NOTICES.md +151 -0
- package/docs/api/REFERENCE.md +1435 -0
- package/docs/api/index.json +1139 -0
- package/docs/npm/DISTRIBUTION.md +130 -0
- package/docs/npm/GAME-AUTHOR.md +147 -0
- package/engine.manifest.json +15 -0
- package/lib/assets/audio.js +67 -0
- package/lib/assets/errors.js +36 -0
- package/lib/assets/glb.js +277 -0
- package/lib/assets/index.js +53 -0
- package/lib/assets/jpeg.js +199 -0
- package/lib/assets/model.js +558 -0
- package/lib/assets/optimize.js +95 -0
- package/lib/assets/texture.js +187 -0
- package/lib/compiler/distribution.js +17 -0
- package/lib/compiler/extract.js +425 -0
- package/lib/compiler/graph.js +366 -0
- package/lib/compiler/index.js +574 -0
- package/lib/compiler/normalize.js +1194 -0
- package/lib/compiler/source-map.js +25 -0
- package/lib/compiler/types.js +2 -0
- package/lib/compiler/version.js +93 -0
- package/lib/experiments/simulation/index.js +2 -0
- package/lib/experiments/simulation/math.js +41 -0
- package/lib/experiments/simulation/probe.js +215 -0
- package/lib/experiments/simulation/scenes.js +192 -0
- package/lib/experiments/simulation/solver.js +346 -0
- package/lib/experiments/simulation/types.js +1 -0
- package/lib/experiments/world/adapters.js +30 -0
- package/lib/experiments/world/geometry.js +180 -0
- package/lib/experiments/world/index.js +2 -0
- package/lib/experiments/world/probe.js +288 -0
- package/lib/experiments/world/types.js +1 -0
- package/lib/experiments/world/world.js +599 -0
- package/lib/navigation/index.js +157 -0
- package/lib/physics/index.js +909 -0
- package/lib/protocol/index.js +92 -0
- package/lib/renderer/acceleration.js +609 -0
- package/lib/renderer/browser.js +2015 -0
- package/lib/renderer/bsdf.js +260 -0
- package/lib/renderer/checkpoint.js +88 -0
- package/lib/renderer/compute-executor.js +1034 -0
- package/lib/renderer/compute-texture-assets.js +49 -0
- package/lib/renderer/compute-view-contract.js +1 -0
- package/lib/renderer/denoiser.js +361 -0
- package/lib/renderer/dielectric.js +360 -0
- package/lib/renderer/embedded-image-pixels.js +368 -0
- package/lib/renderer/emissive-lights.js +67 -0
- package/lib/renderer/environment-importance.js +55 -0
- package/lib/renderer/environment.js +346 -0
- package/lib/renderer/gameplay.js +464 -0
- package/lib/renderer/geometry.js +103 -0
- package/lib/renderer/graph-expressions.js +485 -0
- package/lib/renderer/graph-tsl.js +141 -0
- package/lib/renderer/graph.js +214 -0
- package/lib/renderer/managed-texture-sampling.js +29 -0
- package/lib/renderer/material-graphs.js +297 -0
- package/lib/renderer/medium.js +348 -0
- package/lib/renderer/models.js +1053 -0
- package/lib/renderer/motion-shader.js +40 -0
- package/lib/renderer/path-shader.js +196 -0
- package/lib/renderer/pathtrace.js +324 -0
- package/lib/renderer/postprocess-contract.js +1 -0
- package/lib/renderer/postprocess.js +494 -0
- package/lib/renderer/render-buffers.js +132 -0
- package/lib/renderer/render-textures.js +155 -0
- package/lib/renderer/startup.js +50 -0
- package/lib/renderer/surface-capture.js +199 -0
- package/lib/renderer/surface-gpu.js +270 -0
- package/lib/renderer/surface-motion.js +84 -0
- package/lib/renderer/surface-ray-shader.js +91 -0
- package/lib/renderer/surface-shader.js +88 -0
- package/lib/renderer/surface-tracer.js +1720 -0
- package/lib/renderer/surface.js +1425 -0
- package/lib/renderer/temporal-filter.js +512 -0
- package/lib/renderer/texture-pixels.js +207 -0
- package/lib/renderer/traversal-nodes.js +54 -0
- package/lib/renderer/ui.js +446 -0
- package/lib/renderer/vertex-bounds.js +127 -0
- package/lib/renderer/vertex-contract.js +1 -0
- package/lib/renderer/vertex-graphs.js +197 -0
- package/lib/renderer/volume-shader.js +50 -0
- package/lib/runtime/compute-contract.js +1 -0
- package/lib/runtime/compute-service.js +674 -0
- package/lib/runtime/contracts.js +1 -0
- package/lib/runtime/error.js +37 -0
- package/lib/runtime/events.js +189 -0
- package/lib/runtime/game-services.js +772 -0
- package/lib/runtime/host.js +839 -0
- package/lib/runtime/material-parameters.js +145 -0
- package/lib/runtime/plugins.js +1 -0
- package/lib/runtime/postprocess-contract.js +1 -0
- package/lib/runtime/postprocess.js +189 -0
- package/lib/runtime/prefabs.js +13 -0
- package/lib/runtime/random.js +88 -0
- package/lib/runtime/render-buffer-contract.js +1 -0
- package/lib/runtime/render-buffers.js +243 -0
- package/lib/runtime/render-capabilities.js +17 -0
- package/lib/runtime/render-settings.js +249 -0
- package/lib/runtime/render-texture-contract.js +1 -0
- package/lib/runtime/render-textures.js +271 -0
- package/lib/runtime/resources.js +648 -0
- package/lib/runtime/scheduler.js +765 -0
- package/lib/runtime/storage.js +169 -0
- package/lib/runtime/world.js +594 -0
- package/lib/schema/index.js +24 -0
- package/lib/sdk/graph-values.js +16 -0
- package/lib/sdk/index.d.ts +800 -0
- package/lib/sdk/index.js +82 -0
- package/lib/tools/api-index.js +113 -0
- package/lib/tools/browser-session.js +89 -0
- package/lib/tools/cli.js +513 -0
- package/lib/tools/compress-dist.js +59 -0
- package/lib/tools/control-client.js +153 -0
- package/lib/tools/control-server.js +633 -0
- package/lib/tools/diagnostic-code.js +3 -0
- package/lib/tools/doctor.js +496 -0
- package/lib/tools/npm/browser-cli.js +6 -0
- package/lib/tools/npm/entry.js +40 -0
- package/lib/tools/npm/layout.js +195 -0
- package/lib/tools/setup.js +153 -0
- package/licenses/@dimforge/rapier2d-compat/LICENSE +201 -0
- package/licenses/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@gltf-transform/core/LICENSE.md +21 -0
- package/licenses/@gltf-transform/extensions/LICENSE.md +21 -0
- package/licenses/@gltf-transform/functions/LICENSE.md +21 -0
- package/licenses/@img/colour/LICENSE.md +82 -0
- package/licenses/@img/sharp-win32-x64/LICENSE +191 -0
- package/licenses/@oxc-project/types/LICENSE +22 -0
- package/licenses/@rolldown/pluginutils/LICENSE +21 -0
- package/licenses/@tweenjs/tween.js/LICENSE +23 -0
- package/licenses/@types/ndarray/LICENSE +21 -0
- package/licenses/@types/node/LICENSE +21 -0
- package/licenses/@types/stats.js/LICENSE +21 -0
- package/licenses/@types/three/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@types/three/LICENSE +21 -0
- package/licenses/@types/webxr/LICENSE +21 -0
- package/licenses/@webgpu/types/LICENSE +26 -0
- package/licenses/THIRD-PARTY-NOTICES.md +139 -0
- package/licenses/cwise-compiler/LICENSE +22 -0
- package/licenses/detect-libc/LICENSE +201 -0
- package/licenses/esbuild/LICENSE.md +21 -0
- package/licenses/fast-png/LICENSE +21 -0
- package/licenses/fdir/LICENSE +7 -0
- package/licenses/fflate/LICENSE +21 -0
- package/licenses/iobuffer/LICENSE +22 -0
- package/licenses/iota-array/LICENSE +22 -0
- package/licenses/is-buffer/LICENSE +21 -0
- package/licenses/ktx-parse/LICENSE +21 -0
- package/licenses/lightningcss/LICENSE +373 -0
- package/licenses/lightningcss-win32-x64-msvc/LICENSE +373 -0
- package/licenses/meshoptimizer/LICENSE.md +21 -0
- package/licenses/nanoid/LICENSE +20 -0
- package/licenses/ndarray/LICENSE +22 -0
- package/licenses/ndarray-lanczos/LICENSE +21 -0
- package/licenses/ndarray-ops/LICENSE +22 -0
- package/licenses/ndarray-pixels/LICENSE +21 -0
- package/licenses/ngraph.path/LICENSE +21 -0
- package/licenses/picocolors/LICENSE +15 -0
- package/licenses/picomatch/LICENSE +21 -0
- package/licenses/playwright/LICENSE +202 -0
- package/licenses/playwright/NOTICE +5 -0
- package/licenses/playwright-core/LICENSE +202 -0
- package/licenses/playwright-core/NOTICE +5 -0
- package/licenses/postcss/LICENSE +20 -0
- package/licenses/prettier/LICENSE +7 -0
- package/licenses/property-graph/LICENSE +21 -0
- package/licenses/rolldown/LICENSE +25 -0
- package/licenses/semver/LICENSE +15 -0
- package/licenses/sharp/LICENSE +191 -0
- package/licenses/source-map-js/LICENSE +28 -0
- package/licenses/three/LICENSE +21 -0
- package/licenses/tinyglobby/LICENSE +21 -0
- package/licenses/tsx/LICENSE +21 -0
- package/licenses/typescript/LICENSE.txt +55 -0
- package/licenses/undici-types/LICENSE +21 -0
- package/licenses/uniq/LICENSE +22 -0
- package/licenses/vite/LICENSE.md +2084 -0
- package/package.json +49 -4
- package/web/index.html +34 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { createWorldProbe } from "./world.js";
|
|
2
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
3
|
+
function withoutEpoch(value) {
|
|
4
|
+
const { epoch: _epoch, ...rest } = value;
|
|
5
|
+
return rest;
|
|
6
|
+
}
|
|
7
|
+
export async function runWorldProbe(options = {}) {
|
|
8
|
+
const start = performance.now(), seed = options.seed ?? 12345, world = createWorldProbe({ seed });
|
|
9
|
+
const checks = {};
|
|
10
|
+
try {
|
|
11
|
+
await Promise.all([
|
|
12
|
+
world.loadChunk([0, 0]),
|
|
13
|
+
world.loadChunk([1, 0]),
|
|
14
|
+
world.loadChunk([-1, 0]),
|
|
15
|
+
]);
|
|
16
|
+
checks.loaded =
|
|
17
|
+
world.inspect().resident.length === 3 &&
|
|
18
|
+
world.inspect().consumers.consistent;
|
|
19
|
+
const before = world.getRenderState();
|
|
20
|
+
const pathBefore = world.findPath({ chunk: [0, 0], cell: [2, 1] }, { chunk: [1, 0], cell: [1, 1] });
|
|
21
|
+
await world.applyEdits([{ chunk: [0, 0], x: 4, z: 2, height: 2 }]);
|
|
22
|
+
const after = world.getRenderState(), collision = world.getCollisionState(), nav = world.getNavigationState();
|
|
23
|
+
const left = collision.chunks.find((c) => c.id === "chunk:0:0"), right = collision.chunks.find((c) => c.id === "chunk:1:0");
|
|
24
|
+
checks.borderShared =
|
|
25
|
+
left.heights[2 * 5 + 4] === 2 && right.heights[2 * 5] === 2;
|
|
26
|
+
checks.atomicVersions =
|
|
27
|
+
left.version === 1 &&
|
|
28
|
+
right.version === 1 &&
|
|
29
|
+
world.inspect().consumers.consistent;
|
|
30
|
+
checks.geometryChanged = !same(before.chunks.find((c) => c.id === left.id).positions, after.chunks.find((c) => c.id === left.id).positions);
|
|
31
|
+
checks.collisionChanged =
|
|
32
|
+
world.sampleHeight({ chunk: [1, 0], local: [0, 0, 4] })?.height === 2;
|
|
33
|
+
const pathAfter = world.findPath({ chunk: [0, 0], cell: [2, 1] }, { chunk: [1, 0], cell: [1, 1] });
|
|
34
|
+
checks.navigationChanged =
|
|
35
|
+
pathBefore.found &&
|
|
36
|
+
pathAfter.found &&
|
|
37
|
+
pathAfter.nodes.length > pathBefore.nodes.length &&
|
|
38
|
+
nav.blockedCells > 0;
|
|
39
|
+
await world.unloadChunk([0, 0]);
|
|
40
|
+
await world.loadChunk([0, 0]);
|
|
41
|
+
checks.persistentReturn =
|
|
42
|
+
world.sampleHeight({ chunk: [0, 0], local: [8 - 1e-6, 0, 4] }).height >
|
|
43
|
+
1.999 &&
|
|
44
|
+
world.getCollisionState().chunks.find((c) => c.id === left.id)
|
|
45
|
+
.version === 1;
|
|
46
|
+
const capture = performance.now(), snapshot = world.snapshot(), captureWallMs = performance.now() - capture;
|
|
47
|
+
const geometry = withoutEpoch(world.getRenderState());
|
|
48
|
+
await world.applyEdits([{ chunk: [0, 0], x: 1, z: 1, height: -1 }]);
|
|
49
|
+
await world.unloadChunk([1, 0]);
|
|
50
|
+
await world.setOrigin({ chunk: [1, 0], offset: [0, 0, 0] });
|
|
51
|
+
const restoreStart = performance.now();
|
|
52
|
+
await world.restore(JSON.parse(JSON.stringify(snapshot)));
|
|
53
|
+
const restoreWallMs = performance.now() - restoreStart;
|
|
54
|
+
const logicalStateRestoredExactly = same(world.snapshot(), snapshot), geometryRestoredExactly = same(withoutEpoch(world.getRenderState()), geometry);
|
|
55
|
+
checks.restore =
|
|
56
|
+
logicalStateRestoredExactly &&
|
|
57
|
+
geometryRestoredExactly &&
|
|
58
|
+
world.inspect().consumers.consistent;
|
|
59
|
+
const far = createWorldProbe({
|
|
60
|
+
seed,
|
|
61
|
+
bounds: { min: [100000000, -100000000], max: [100000001, -100000000] },
|
|
62
|
+
origin: { chunk: [100000000, -100000000], offset: [0, 0, 0] },
|
|
63
|
+
});
|
|
64
|
+
const point = {
|
|
65
|
+
chunk: [100000000, -100000000],
|
|
66
|
+
local: [3.125, 0.000125, 2.25],
|
|
67
|
+
};
|
|
68
|
+
let float32GlobalError = 0, float32LocalError = 0, roundTripError = 0;
|
|
69
|
+
try {
|
|
70
|
+
await far.loadChunk(point.chunk);
|
|
71
|
+
const local = far.toLocal(point), round = far.fromLocal(local);
|
|
72
|
+
float32GlobalError = Math.abs(Math.fround(point.chunk[0] * 8 + point.local[0]) -
|
|
73
|
+
(point.chunk[0] * 8 + point.local[0]));
|
|
74
|
+
float32LocalError = Math.abs(Math.fround(local[0]) - point.local[0]);
|
|
75
|
+
roundTripError = Math.max(...round.local.map((x, i) => Math.abs(x - point.local[i])));
|
|
76
|
+
checks.originPrecision =
|
|
77
|
+
float32GlobalError > 1 &&
|
|
78
|
+
float32LocalError === 0 &&
|
|
79
|
+
roundTripError === 0 &&
|
|
80
|
+
same(round.chunk, point.chunk);
|
|
81
|
+
const old = far.getRenderState();
|
|
82
|
+
await far.setOrigin({
|
|
83
|
+
chunk: [100000001, -100000000],
|
|
84
|
+
offset: [0, 0, 0],
|
|
85
|
+
});
|
|
86
|
+
const shifted = far.getRenderState();
|
|
87
|
+
checks.originSynchronization =
|
|
88
|
+
shifted.chunks[0].positions[0] === old.chunks[0].positions[0] - 8 &&
|
|
89
|
+
shifted.chunks[0].version === old.chunks[0].version &&
|
|
90
|
+
far.inspect().consumers.consistent;
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
far.dispose();
|
|
94
|
+
}
|
|
95
|
+
let allReleased = true;
|
|
96
|
+
for (let cycle = 0; cycle < 8; cycle++) {
|
|
97
|
+
const temporary = createWorldProbe({ seed });
|
|
98
|
+
await temporary.restore(snapshot);
|
|
99
|
+
await temporary.unloadChunk([0, 0]);
|
|
100
|
+
temporary.dispose();
|
|
101
|
+
temporary.dispose();
|
|
102
|
+
const i = temporary.inspect();
|
|
103
|
+
allReleased &&=
|
|
104
|
+
i.disposed &&
|
|
105
|
+
i.pending.length === 0 &&
|
|
106
|
+
i.resident.length === 0 &&
|
|
107
|
+
i.persistentEdits === 0 &&
|
|
108
|
+
Object.values(i.resources).every((n) => n === 0);
|
|
109
|
+
}
|
|
110
|
+
checks.released = allReleased;
|
|
111
|
+
const asyncTransactions = await asyncTransactionEvidence(seed);
|
|
112
|
+
checks.asyncRaces =
|
|
113
|
+
asyncTransactions.cancelSettledBeforeSource &&
|
|
114
|
+
asyncTransactions.lateResultDiscarded &&
|
|
115
|
+
asyncTransactions.newGenerationKept &&
|
|
116
|
+
asyncTransactions.editInvalidatedOldLoad;
|
|
117
|
+
checks.transactionRollback =
|
|
118
|
+
asyncTransactions.unchangedDuringPrepare &&
|
|
119
|
+
asyncTransactions.rollbackRestored;
|
|
120
|
+
const final = world.inspect();
|
|
121
|
+
return {
|
|
122
|
+
prototype: "pelican-m0-world-streaming",
|
|
123
|
+
version: 1,
|
|
124
|
+
passed: Object.values(checks).every(Boolean),
|
|
125
|
+
checks,
|
|
126
|
+
load: {
|
|
127
|
+
chunks: before.chunks.length,
|
|
128
|
+
verticesPerChunk: before.chunks[0].positions.length / 3,
|
|
129
|
+
trianglesPerChunk: before.chunks[0].indices.length / 3,
|
|
130
|
+
},
|
|
131
|
+
edits: {
|
|
132
|
+
sharedBorderHeight: left.heights[14],
|
|
133
|
+
versions: final.resident,
|
|
134
|
+
blockedCells: nav.blockedCells,
|
|
135
|
+
pathBefore: pathBefore.nodes.length,
|
|
136
|
+
pathAfter: pathAfter.nodes.length,
|
|
137
|
+
},
|
|
138
|
+
asyncTransactions,
|
|
139
|
+
snapshot: {
|
|
140
|
+
bytes: new TextEncoder().encode(JSON.stringify(snapshot)).length,
|
|
141
|
+
captureWallMs,
|
|
142
|
+
restoreWallMs,
|
|
143
|
+
logicalStateRestoredExactly,
|
|
144
|
+
geometryRestoredExactly,
|
|
145
|
+
},
|
|
146
|
+
precision: {
|
|
147
|
+
chunk: point.chunk,
|
|
148
|
+
float32GlobalError,
|
|
149
|
+
float32LocalError,
|
|
150
|
+
roundTripError,
|
|
151
|
+
},
|
|
152
|
+
timing: {
|
|
153
|
+
totalWallMs: performance.now() - start,
|
|
154
|
+
prepareWallMs: final.metrics.prepareWallMs,
|
|
155
|
+
commitWallMs: final.metrics.commitWallMs,
|
|
156
|
+
},
|
|
157
|
+
lifecycle: { cycles: 8, allReleased },
|
|
158
|
+
final,
|
|
159
|
+
limitations: [
|
|
160
|
+
"Finite CPU reference: at most 8×8 chunks and 16×16 cells per chunk; report exercises three 4×4-cell chunks.",
|
|
161
|
+
"Procedural height grid only; no production terrain, holes, caves, LOD, geometry destruction, disk I/O or asset bandwidth measurement.",
|
|
162
|
+
"Collision is real triangle-consistent height sampling, not a rigid-body solver or broadphase.",
|
|
163
|
+
"Navigation is a real four-neighbor cell graph and BFS, not a Recast / volumetric / continuous navmesh library.",
|
|
164
|
+
"Each commit rebuilds all resident consumer artifacts; no incremental BVH/GPU upload is performed here.",
|
|
165
|
+
"Adapters must prepare without side effects; commit/rollback/discard are synchronous, trusted and non-reentrant. Rollback violation faults the world.",
|
|
166
|
+
"Snapshot persistence is JSON data in memory/files; no disk journal or crash durability protocol.",
|
|
167
|
+
"Logical release counts are not a process/GPU memory leak audit. An uncooperative asynchronous hook cannot be forcibly terminated.",
|
|
168
|
+
"Origin-local precision covers split chunk/local coordinates; callers must not first collapse large positions to global Float32.",
|
|
169
|
+
"Real WebGPU, BVH and physics/navigation library adapters require separate mainline integration verification.",
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
world.dispose();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function deferred() {
|
|
178
|
+
let resolve;
|
|
179
|
+
const promise = new Promise((r) => {
|
|
180
|
+
resolve = r;
|
|
181
|
+
});
|
|
182
|
+
return { promise, resolve };
|
|
183
|
+
}
|
|
184
|
+
async function asyncTransactionEvidence(seed) {
|
|
185
|
+
const entered = [deferred(), deferred(), deferred()], release = [deferred(), deferred(), deferred()];
|
|
186
|
+
let calls = 0;
|
|
187
|
+
const w = createWorldProbe({
|
|
188
|
+
seed,
|
|
189
|
+
beforeBuild() {
|
|
190
|
+
const i = calls++;
|
|
191
|
+
entered[i].resolve();
|
|
192
|
+
return release[i].promise;
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
let cancelSettledBeforeSource = false, lateResultDiscarded = false, newGenerationKept = false, editInvalidatedOldLoad = false, staleResults = 0;
|
|
196
|
+
try {
|
|
197
|
+
const old = w.loadChunk([0, 0]);
|
|
198
|
+
await entered[0].promise;
|
|
199
|
+
w.cancelLoad([0, 0]);
|
|
200
|
+
cancelSettledBeforeSource = (await old).status === "cancelled";
|
|
201
|
+
const fresh = w.loadChunk([0, 0]);
|
|
202
|
+
await entered[1].promise;
|
|
203
|
+
release[1].resolve();
|
|
204
|
+
newGenerationKept = (await fresh).status === "loaded";
|
|
205
|
+
const saved = w.snapshot(), epoch = w.inspect().epoch;
|
|
206
|
+
release[0].resolve();
|
|
207
|
+
await release[0].promise;
|
|
208
|
+
lateResultDiscarded =
|
|
209
|
+
same(w.snapshot(), saved) &&
|
|
210
|
+
w.inspect().epoch === epoch &&
|
|
211
|
+
w.inspect().metrics.staleResults > 0;
|
|
212
|
+
const pending = w.loadChunk([1, 0]);
|
|
213
|
+
await entered[2].promise;
|
|
214
|
+
await w.applyEdits([{ chunk: [1, 0], x: 1, z: 1, height: 2 }]);
|
|
215
|
+
editInvalidatedOldLoad = (await pending).status === "stale";
|
|
216
|
+
release[2].resolve();
|
|
217
|
+
await release[2].promise;
|
|
218
|
+
editInvalidatedOldLoad &&= !w
|
|
219
|
+
.inspect()
|
|
220
|
+
.resident.some((c) => c.id === "chunk:1:0");
|
|
221
|
+
staleResults = w.inspect().metrics.staleResults;
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
release.forEach((d) => d.resolve());
|
|
225
|
+
w.dispose();
|
|
226
|
+
}
|
|
227
|
+
const prepared = deferred(), ready = deferred();
|
|
228
|
+
let value = 0;
|
|
229
|
+
const adapter = {
|
|
230
|
+
name: "report-failure-injection",
|
|
231
|
+
async prepare(t) {
|
|
232
|
+
const previous = value;
|
|
233
|
+
if (t.reason === "edit") {
|
|
234
|
+
ready.resolve();
|
|
235
|
+
await prepared.promise;
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
commit() {
|
|
239
|
+
value = t.epoch;
|
|
240
|
+
if (t.reason === "edit")
|
|
241
|
+
throw new Error("intentional partial commit failure");
|
|
242
|
+
},
|
|
243
|
+
rollback() {
|
|
244
|
+
value = previous;
|
|
245
|
+
},
|
|
246
|
+
discard() { },
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
const transactionWorld = createWorldProbe({ seed, adapters: [adapter] });
|
|
251
|
+
let unchangedDuringPrepare = false, rollbackRestored = false;
|
|
252
|
+
try {
|
|
253
|
+
await transactionWorld.loadChunk([0, 0]);
|
|
254
|
+
const logical = transactionWorld.snapshot(), r = transactionWorld.getRenderState(), p = transactionWorld.getCollisionState(), n = transactionWorld.getNavigationState(), old = value;
|
|
255
|
+
const result = transactionWorld
|
|
256
|
+
.applyEdits([{ chunk: [0, 0], x: 1, z: 1, height: 2 }])
|
|
257
|
+
.then(() => false, (error) => String(error).includes("WORLD_COMMIT"));
|
|
258
|
+
await ready.promise;
|
|
259
|
+
unchangedDuringPrepare =
|
|
260
|
+
same(transactionWorld.snapshot(), logical) &&
|
|
261
|
+
same(transactionWorld.getRenderState(), r) &&
|
|
262
|
+
same(transactionWorld.getCollisionState(), p) &&
|
|
263
|
+
same(transactionWorld.getNavigationState(), n);
|
|
264
|
+
prepared.resolve();
|
|
265
|
+
const rejected = await result;
|
|
266
|
+
rollbackRestored =
|
|
267
|
+
rejected &&
|
|
268
|
+
value === old &&
|
|
269
|
+
same(transactionWorld.snapshot(), logical) &&
|
|
270
|
+
same(transactionWorld.getRenderState(), r) &&
|
|
271
|
+
same(transactionWorld.getCollisionState(), p) &&
|
|
272
|
+
same(transactionWorld.getNavigationState(), n) &&
|
|
273
|
+
transactionWorld.inspect().consumers.consistent;
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
prepared.resolve();
|
|
277
|
+
transactionWorld.dispose();
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
cancelSettledBeforeSource,
|
|
281
|
+
lateResultDiscarded,
|
|
282
|
+
newGenerationKept,
|
|
283
|
+
editInvalidatedOldLoad,
|
|
284
|
+
unchangedDuringPrepare,
|
|
285
|
+
rollbackRestored,
|
|
286
|
+
staleResults,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|