@holtjs/stage 0.15.0 → 0.16.0
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/CHANGELOG.md +11 -0
- package/dist/ecs.d.ts +18 -0
- package/dist/ecs.js +174 -0
- package/dist/{game-Ce35GTH4.d.ts → game-Dxh9e0Hv.d.ts} +87 -1
- package/dist/headless.d.ts +52 -1
- package/dist/headless.js +152 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +166 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/particles.d.ts +75 -0
- package/dist/particles.js +127 -1
- package/dist/projection.d.ts +1 -1
- package/dist/renderer-webgpu.d.ts +1 -1
- package/dist/rig2d.d.ts +1 -1
- package/dist/tilemap.d.ts +1 -1
- package/dist/trace.d.ts +1 -1
- package/dist/world.d.ts +1 -1
- package/package.json +1 -1
- package/skills/stage/references/subpaths.md +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.16.0] - 2026-12-05
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- **Sub-Millisecond `SoaWorld` Binary Snapshots, State Checksums & `RollbackSession` (`@holtjs/stage/ecs` & `@holtjs/stage/kernel`, `src/ecs.ts`, `src/kernel.ts`)**:
|
|
13
|
+
- Added `world.snapshotByteLength()`, `world.snapshot(into?)`, `world.restore(bytes)` (`'HSOA'` 8-byte aligned binary layout with schema-hash validation, preserving generational `EntityId`s and compiled `world.select()` views in `< 0.1 ms`), and `world.checksum()` (canonicalized 32-bit FNV-1a state checksum).
|
|
14
|
+
- Added `RollbackSession<TInput>` (`RollbackSession.fromSoaWorld`, `createRollbackSession`) with preallocated ring-buffer snapshot slots (`advance`, `applyAuthoritativeInput` for GGPO-style rollback netcode prediction & deterministic re-simulation, `rewindTo` for interactive Time-Travel debugging, and `checksumAt` / `currentChecksum`).
|
|
15
|
+
- **Single-Process Zero-Rasterization Batch Balance Rollout Runner (`runHeadlessRollouts`, `@holtjs/stage/headless`, `src/headless.ts`)**:
|
|
16
|
+
- Added `runHeadlessRollouts({ runs, seeds, ticksPerRun, createScene, onTick, extractMetrics })` executing dozens to hundreds of deterministic `stepSimOnly` game rollouts in a single Node.js, Bun, or Deno process with zero pixel rasterization or GPU driver overhead, returning per-run telemetry and aggregated `min / max / mean / p50 / p95 / sum` statistics.
|
|
17
|
+
- **Velocity-Driven Procedural Character Squash, Stretch & Lean (`LocomotionFeel`, `@holtjs/stage/particles` & `@holtjs/stage`, `src/particles.ts`)**:
|
|
18
|
+
- Added `LocomotionFeel` providing area-preserving (`scaleX * scaleY === 1`) log-space damped spring squash-and-stretch (`impulse`), automatic sharp-turn anticipation squash, velocity-proportional landing thud (`wz -> 0`), ground stride hop, and velocity lean (`applyTo(sprite)`).
|
|
19
|
+
|
|
9
20
|
## [0.15.0] - 2026-12-05
|
|
10
21
|
|
|
11
22
|
### Added, Optimized & Fixed
|
package/dist/ecs.d.ts
CHANGED
|
@@ -228,6 +228,24 @@ export declare class SoaWorld {
|
|
|
228
228
|
clear(): void;
|
|
229
229
|
/** PII-free runtime statistics snapshot. */
|
|
230
230
|
stats(): SoaWorldStats;
|
|
231
|
+
private computeSchemaHash;
|
|
232
|
+
/** Compute exact byte length required to snapshot the current `SoaWorld` state (`'HSOA'` binary layout). */
|
|
233
|
+
snapshotByteLength(count?: number, nextHandle?: number, freeCount?: number): number;
|
|
234
|
+
/**
|
|
235
|
+
* Capture a complete binary snapshot of all live entities, generational handle tables, and SoA component columns.
|
|
236
|
+
* Pass a reusable `into` `Uint8Array` (`byteLength >= world.snapshotByteLength()`) for zero-GC sub-millisecond capture.
|
|
237
|
+
*/
|
|
238
|
+
snapshot(into?: Uint8Array): Uint8Array;
|
|
239
|
+
/**
|
|
240
|
+
* Restore `SoaWorld` in-place from a snapshot produced by `world.snapshot()`.
|
|
241
|
+
* Preserves all compiled `world.select()` / `world.store()` column views and generational `EntityId` validity.
|
|
242
|
+
*/
|
|
243
|
+
restore(snapshot: Uint8Array): void;
|
|
244
|
+
/**
|
|
245
|
+
* Compute a fast deterministic 32-bit FNV-1a checksum over all live entities, masks, and active component columns
|
|
246
|
+
* (canonicalizing `-0.0` in float columns for rollback netcode & replay desync verification).
|
|
247
|
+
*/
|
|
248
|
+
checksum(): number;
|
|
231
249
|
}
|
|
232
250
|
/**
|
|
233
251
|
* In-place zero-GC insertion/Ciura-gap Shell sort of `slots[0..count - 1]` ordered ascending by
|
package/dist/ecs.js
CHANGED
|
@@ -557,6 +557,180 @@ var SoaWorld = class {
|
|
|
557
557
|
spatialCells: this.grid ? this.grid.cols * this.grid.rows : 0
|
|
558
558
|
};
|
|
559
559
|
}
|
|
560
|
+
computeSchemaHash() {
|
|
561
|
+
let h = 0x811c9dc5;
|
|
562
|
+
for (let i = 0; i < this.stores.length; i++) {
|
|
563
|
+
const def = this.stores[i].def;
|
|
564
|
+
const sig = def.isTag ? `${def.name}:tag` : `${def.name}:${def.fields.map((f) => `${f}=${def.schema[f]}`).join(",")}`;
|
|
565
|
+
for (let c = 0; c < sig.length; c++) {
|
|
566
|
+
h ^= sig.charCodeAt(c);
|
|
567
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return h >>> 0;
|
|
571
|
+
}
|
|
572
|
+
/** Compute exact byte length required to snapshot the current `SoaWorld` state (`'HSOA'` binary layout). */
|
|
573
|
+
snapshotByteLength(count = this.count, nextHandle = this.nextHandle, freeCount = this.freeCount) {
|
|
574
|
+
const align8 = (n) => n + 7 & -8;
|
|
575
|
+
let off = 32;
|
|
576
|
+
off = align8(off + count * 4);
|
|
577
|
+
off = align8(off + count * 4);
|
|
578
|
+
off = align8(off + freeCount * 4);
|
|
579
|
+
off = align8(off + nextHandle * 4);
|
|
580
|
+
off = align8(off + nextHandle * 2);
|
|
581
|
+
for (let i = 0; i < this.stores.length; i++) {
|
|
582
|
+
const st = this.stores[i];
|
|
583
|
+
if (st.def.isTag) continue;
|
|
584
|
+
const fields = st.def.fields;
|
|
585
|
+
for (let f = 0; f < fields.length; f++) {
|
|
586
|
+
const bpe = st.columns[fields[f]].BYTES_PER_ELEMENT;
|
|
587
|
+
off = align8(off + count * bpe);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return off;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Capture a complete binary snapshot of all live entities, generational handle tables, and SoA component columns.
|
|
594
|
+
* Pass a reusable `into` `Uint8Array` (`byteLength >= world.snapshotByteLength()`) for zero-GC sub-millisecond capture.
|
|
595
|
+
*/
|
|
596
|
+
snapshot(into) {
|
|
597
|
+
const count = this.count;
|
|
598
|
+
const nextHandle = this.nextHandle;
|
|
599
|
+
const freeCount = this.freeCount;
|
|
600
|
+
const totalBytes = this.snapshotByteLength(count, nextHandle, freeCount);
|
|
601
|
+
const out = into && into.byteLength >= totalBytes ? into.subarray(0, totalBytes) : new Uint8Array(totalBytes);
|
|
602
|
+
const dv = new DataView(out.buffer, out.byteOffset, totalBytes);
|
|
603
|
+
dv.setUint32(0, 0x414f5348, true);
|
|
604
|
+
dv.setUint32(4, 1, true);
|
|
605
|
+
dv.setUint32(8, count, true);
|
|
606
|
+
dv.setUint32(12, nextHandle, true);
|
|
607
|
+
dv.setUint32(16, freeCount, true);
|
|
608
|
+
dv.setUint32(20, this.stores.length, true);
|
|
609
|
+
dv.setUint32(24, this.computeSchemaHash(), true);
|
|
610
|
+
dv.setUint32(28, 0, true);
|
|
611
|
+
let off = 32;
|
|
612
|
+
const writeBytes = (arr, byteLen) => {
|
|
613
|
+
if (byteLen > 0) out.set(new Uint8Array(arr.buffer, arr.byteOffset, byteLen), off);
|
|
614
|
+
const nextOff = off + byteLen + 7 & -8;
|
|
615
|
+
for (let p = off + byteLen; p < nextOff; p++) out[p] = 0;
|
|
616
|
+
off = nextOff;
|
|
617
|
+
};
|
|
618
|
+
writeBytes(this.masks, count * 4);
|
|
619
|
+
writeBytes(this.entities, count * 4);
|
|
620
|
+
writeBytes(this.freeHandles, freeCount * 4);
|
|
621
|
+
writeBytes(this.handleToSlot, nextHandle * 4);
|
|
622
|
+
writeBytes(this.handleGen, nextHandle * 2);
|
|
623
|
+
for (let i = 0; i < this.stores.length; i++) {
|
|
624
|
+
const st = this.stores[i];
|
|
625
|
+
if (st.def.isTag) continue;
|
|
626
|
+
const fields = st.def.fields;
|
|
627
|
+
for (let f = 0; f < fields.length; f++) {
|
|
628
|
+
const col = st.columns[fields[f]];
|
|
629
|
+
writeBytes(col, count * col.BYTES_PER_ELEMENT);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return out;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Restore `SoaWorld` in-place from a snapshot produced by `world.snapshot()`.
|
|
636
|
+
* Preserves all compiled `world.select()` / `world.store()` column views and generational `EntityId` validity.
|
|
637
|
+
*/
|
|
638
|
+
restore(snapshot) {
|
|
639
|
+
if (!snapshot || snapshot.byteLength < 32) throw new Error("SoaWorld.restore: invalid snapshot buffer (< 32 bytes)");
|
|
640
|
+
const dv = new DataView(snapshot.buffer, snapshot.byteOffset, snapshot.byteLength);
|
|
641
|
+
const magic = dv.getUint32(0, true);
|
|
642
|
+
const version = dv.getUint32(4, true);
|
|
643
|
+
if (magic !== 0x414f5348 || version !== 1) throw new Error("SoaWorld.restore: unrecognized HSOA snapshot header");
|
|
644
|
+
const snapCount = dv.getUint32(8, true);
|
|
645
|
+
const snapNextHandle = dv.getUint32(12, true);
|
|
646
|
+
const snapFreeCount = dv.getUint32(16, true);
|
|
647
|
+
const snapStores = dv.getUint32(20, true);
|
|
648
|
+
const snapSchema = dv.getUint32(24, true);
|
|
649
|
+
if (snapStores !== this.stores.length || snapSchema !== this.computeSchemaHash()) throw new Error("SoaWorld.restore: registered component schema does not match snapshot");
|
|
650
|
+
const expectedBytes = this.snapshotByteLength(snapCount, snapNextHandle, snapFreeCount);
|
|
651
|
+
if (snapshot.byteLength < expectedBytes) throw new Error(`SoaWorld.restore: truncated snapshot (${snapshot.byteLength} < ${expectedBytes})`);
|
|
652
|
+
const prevCount = this.count;
|
|
653
|
+
const prevNextHandle = this.nextHandle;
|
|
654
|
+
this.ensureCapacity(Math.max(16, snapCount));
|
|
655
|
+
this.ensureHandleCapacity(Math.max(16, snapNextHandle, snapFreeCount));
|
|
656
|
+
let off = 32;
|
|
657
|
+
const readBytes = (dst, byteLen) => {
|
|
658
|
+
if (byteLen > 0) new Uint8Array(dst.buffer, dst.byteOffset, byteLen).set(snapshot.subarray(off, off + byteLen));
|
|
659
|
+
off = off + byteLen + 7 & -8;
|
|
660
|
+
};
|
|
661
|
+
readBytes(this.masks, snapCount * 4);
|
|
662
|
+
if (prevCount > snapCount) this.masks.fill(0, snapCount, prevCount);
|
|
663
|
+
readBytes(this.entities, snapCount * 4);
|
|
664
|
+
if (prevCount > snapCount) this.entities.fill(0, snapCount, prevCount);
|
|
665
|
+
readBytes(this.freeHandles, snapFreeCount * 4);
|
|
666
|
+
readBytes(this.handleToSlot, snapNextHandle * 4);
|
|
667
|
+
this.handleToSlot.fill(-1, snapNextHandle);
|
|
668
|
+
readBytes(this.handleGen, snapNextHandle * 2);
|
|
669
|
+
if (prevNextHandle > snapNextHandle) this.handleGen.fill(0, snapNextHandle, prevNextHandle);
|
|
670
|
+
for (let i = 0; i < this.stores.length; i++) {
|
|
671
|
+
const st = this.stores[i];
|
|
672
|
+
if (st.def.isTag) continue;
|
|
673
|
+
const fields = st.def.fields;
|
|
674
|
+
for (let f = 0; f < fields.length; f++) {
|
|
675
|
+
const col = st.columns[fields[f]];
|
|
676
|
+
readBytes(col, snapCount * col.BYTES_PER_ELEMENT);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
this.count = snapCount;
|
|
680
|
+
this.nextHandle = snapNextHandle;
|
|
681
|
+
this.freeCount = snapFreeCount;
|
|
682
|
+
this.clearEvents();
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Compute a fast deterministic 32-bit FNV-1a checksum over all live entities, masks, and active component columns
|
|
686
|
+
* (canonicalizing `-0.0` in float columns for rollback netcode & replay desync verification).
|
|
687
|
+
*/
|
|
688
|
+
checksum() {
|
|
689
|
+
const count = this.count;
|
|
690
|
+
let h = 0x811c9dc5;
|
|
691
|
+
const mixByte = (b) => {
|
|
692
|
+
h ^= b & 255;
|
|
693
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
694
|
+
};
|
|
695
|
+
const mixU32 = (v) => {
|
|
696
|
+
mixByte(v);
|
|
697
|
+
mixByte(v >>> 8);
|
|
698
|
+
mixByte(v >>> 16);
|
|
699
|
+
mixByte(v >>> 24);
|
|
700
|
+
};
|
|
701
|
+
mixU32(count);
|
|
702
|
+
for (let s = 0; s < count; s++) {
|
|
703
|
+
mixU32(this.masks[s]);
|
|
704
|
+
mixU32(this.entities[s]);
|
|
705
|
+
}
|
|
706
|
+
const fDv = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
|
|
707
|
+
for (let i = 0; i < this.stores.length; i++) {
|
|
708
|
+
const st = this.stores[i];
|
|
709
|
+
if (st.def.isTag) continue;
|
|
710
|
+
const fields = st.def.fields;
|
|
711
|
+
for (let f = 0; f < fields.length; f++) {
|
|
712
|
+
const fname = fields[f];
|
|
713
|
+
const kind = st.def.schema[fname];
|
|
714
|
+
const col = st.columns[fname];
|
|
715
|
+
if (kind === "f32") for (let s = 0; s < count; s++) {
|
|
716
|
+
const v = col[s];
|
|
717
|
+
fDv.setFloat32(0, v === 0 ? 0 : Number.isNaN(v) ? 0 : v, true);
|
|
718
|
+
mixU32(fDv.getUint32(0, true));
|
|
719
|
+
}
|
|
720
|
+
else if (kind === "f64") for (let s = 0; s < count; s++) {
|
|
721
|
+
const v = col[s];
|
|
722
|
+
fDv.setFloat64(0, v === 0 ? 0 : Number.isNaN(v) ? 0 : v, true);
|
|
723
|
+
mixU32(fDv.getUint32(0, true));
|
|
724
|
+
mixU32(fDv.getUint32(4, true));
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
const bytes = new Uint8Array(col.buffer, col.byteOffset, count * col.BYTES_PER_ELEMENT);
|
|
728
|
+
for (let b = 0; b < bytes.length; b++) mixByte(bytes[b]);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
return h >>> 0;
|
|
733
|
+
}
|
|
560
734
|
};
|
|
561
735
|
/**
|
|
562
736
|
* In-place zero-GC insertion/Ciura-gap Shell sort of `slots[0..count - 1]` ordered ascending by
|
|
@@ -2351,6 +2351,92 @@ interface InputRecorderPlugin extends StagePlugin {
|
|
|
2351
2351
|
declare function createInputRecorder(id?: string): InputRecorderPlugin;
|
|
2352
2352
|
/** Replays a recorded `RecordedInputEntry[]` log deterministically on matching simulation timestamps. */
|
|
2353
2353
|
declare function createInputReplay(log: ReadonlyArray<RecordedInputEntry>, id?: string): StagePlugin & InputProvider;
|
|
2354
|
+
interface RollbackStateCodec {
|
|
2355
|
+
/** Save current simulation state into `into` (if large enough) or return a fresh `Uint8Array`. */
|
|
2356
|
+
save(into?: Uint8Array): Uint8Array;
|
|
2357
|
+
/** Restore simulation state in-place from `snapshot`. */
|
|
2358
|
+
load(snapshot: Uint8Array): void;
|
|
2359
|
+
/** Optional deterministic 32-bit state checksum for desync detection. */
|
|
2360
|
+
checksum?(): number;
|
|
2361
|
+
}
|
|
2362
|
+
interface RollbackSessionOptions<TInput> {
|
|
2363
|
+
/** Maximum number of historical frames retained in the ring buffer (`default = 120` = 2.0s @ 60 Hz). */
|
|
2364
|
+
readonly windowFrames?: number;
|
|
2365
|
+
/** Initial simulation frame number (`default = 0`). */
|
|
2366
|
+
readonly initialFrame?: number;
|
|
2367
|
+
/** Equality comparator for `TInput` to skip redundant rollbacks when authoritative input matches prediction. */
|
|
2368
|
+
readonly inputEquals?: (a: TInput, b: TInput) => boolean;
|
|
2369
|
+
/** State serializer/deserializer (or pass a `SoaWorld` to `RollbackSession.fromSoaWorld(...)`). */
|
|
2370
|
+
readonly codec: RollbackStateCodec;
|
|
2371
|
+
/** Pure deterministic single-frame simulation step `(frame, input) => void`. */
|
|
2372
|
+
readonly step: (frame: number, input: TInput) => void;
|
|
2373
|
+
}
|
|
2374
|
+
interface RollbackResult {
|
|
2375
|
+
readonly rolledBack: boolean;
|
|
2376
|
+
readonly targetFrame: number;
|
|
2377
|
+
readonly framesResimulated: number;
|
|
2378
|
+
readonly checksum: number;
|
|
2379
|
+
}
|
|
2380
|
+
interface RollbackStats {
|
|
2381
|
+
readonly currentFrame: number;
|
|
2382
|
+
readonly oldestFrame: number;
|
|
2383
|
+
readonly windowFrames: number;
|
|
2384
|
+
readonly rollbackCount: number;
|
|
2385
|
+
readonly resimulatedFrames: number;
|
|
2386
|
+
readonly maxRollbackDepth: number;
|
|
2387
|
+
}
|
|
2388
|
+
interface SnapshotableWorldLike {
|
|
2389
|
+
snapshot(into?: Uint8Array): Uint8Array;
|
|
2390
|
+
restore(snapshot: Uint8Array): void;
|
|
2391
|
+
checksum?(): number;
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Deterministic ring-buffered rollback netcode (GGPO-style prediction + authoritative correction)
|
|
2395
|
+
* and interactive Time-Travel debugger with zero steady-state heap allocations.
|
|
2396
|
+
*/
|
|
2397
|
+
declare class RollbackSession<TInput> {
|
|
2398
|
+
readonly windowFrames: number;
|
|
2399
|
+
private curFrame;
|
|
2400
|
+
private minRecordedFrame;
|
|
2401
|
+
private readonly codec;
|
|
2402
|
+
private readonly stepFn;
|
|
2403
|
+
private readonly inputEq;
|
|
2404
|
+
private readonly ringFrames;
|
|
2405
|
+
private readonly ringBufs;
|
|
2406
|
+
private readonly ringLens;
|
|
2407
|
+
private readonly ringChecksums;
|
|
2408
|
+
private readonly ringInputs;
|
|
2409
|
+
private rollbacks;
|
|
2410
|
+
private resimFrames;
|
|
2411
|
+
private maxDepth;
|
|
2412
|
+
constructor(options: RollbackSessionOptions<TInput>);
|
|
2413
|
+
/** Create a `RollbackSession` bound directly to a `SoaWorld` (`world.snapshot` / `world.restore` / `world.checksum`). */
|
|
2414
|
+
static fromSoaWorld<TInput>(world: SnapshotableWorldLike, step: (frame: number, input: TInput) => void, options?: Omit<RollbackSessionOptions<TInput>, 'codec' | 'step'>): RollbackSession<TInput>;
|
|
2415
|
+
get currentFrame(): number;
|
|
2416
|
+
get oldestFrame(): number;
|
|
2417
|
+
private captureAtSlot;
|
|
2418
|
+
/** Save pre-step state for `currentFrame`, execute `step(currentFrame, input)`, and advance `currentFrame`. */
|
|
2419
|
+
advance(input: TInput): number;
|
|
2420
|
+
/** Read the input applied at historical `frame` (within `[oldestFrame .. currentFrame - 1]`). */
|
|
2421
|
+
inputAt(frame: number): TInput | undefined;
|
|
2422
|
+
/** Compute current live state checksum. */
|
|
2423
|
+
currentChecksum(): number;
|
|
2424
|
+
/** Compute checksum of the pre-step snapshot stored at historical `frame` (`null` if evicted). */
|
|
2425
|
+
checksumAt(frame: number): number | null;
|
|
2426
|
+
/**
|
|
2427
|
+
* Time-Travel rewind: restore live simulation state back to `targetFrame` (`oldestFrame <= targetFrame <= currentFrame`),
|
|
2428
|
+
* resetting `currentFrame = targetFrame` so subsequent `advance()` calls branch into a new timeline cleanly.
|
|
2429
|
+
*/
|
|
2430
|
+
rewindTo(targetFrame: number): void;
|
|
2431
|
+
/**
|
|
2432
|
+
* Apply an authoritative remote/replay input for `targetFrame`.
|
|
2433
|
+
* If it matches the predicted input already simulated at `targetFrame`, returns immediately (`rolledBack: false`).
|
|
2434
|
+
* Otherwise restores `targetFrame`'s snapshot, updates the input at `targetFrame`, and re-simulates `[targetFrame .. currentFrame - 1]`.
|
|
2435
|
+
*/
|
|
2436
|
+
applyAuthoritativeInput(targetFrame: number, actualInput: TInput, equals?: (a: TInput, b: TInput) => boolean): RollbackResult;
|
|
2437
|
+
stats(): RollbackStats;
|
|
2438
|
+
}
|
|
2439
|
+
declare function createRollbackSession<TInput>(options: RollbackSessionOptions<TInput>): RollbackSession<TInput>;
|
|
2354
2440
|
type StageRenderer = RendererGl | Renderer2D | RendererWebGpu;
|
|
2355
2441
|
interface EngineClockSnapshot {
|
|
2356
2442
|
readonly frameSeq: number;
|
|
@@ -2664,4 +2750,4 @@ declare class Game {
|
|
|
2664
2750
|
step(time: number, delta: number): void;
|
|
2665
2751
|
destroy(removeCanvas?: boolean): void;
|
|
2666
2752
|
}
|
|
2667
|
-
export {
|
|
2753
|
+
export { WorldCatalogSpec as $, SpriteObject as $n, WebGpuBootstrapResult as $t, StageKernel as A, DisplaySemantics as An, unpackChunkX as At, FrozenWorldCatalog as B, MsdfIconConfig as Bn, SceneDigestSurfaceEntry as Bt, RecordedInputEntry as C, CustomPassCallback as Cn, createIslandBiomeGenerator as Ct, RollbackStateCodec as D, DisplayList as Dn, mountChunkedTilemap as Dt, RollbackSessionOptions as E, DirectionalPlayOptions as En, hash2D as Et, createInputRecorder as F, EquipmentBinding as Fn, SceneDigestEngineSandbox as Ft, RecipeDef as G, PanelStyleConfig as Gn, InputConfig as Gt, ItemDef as H, NineSliceObject as Hn, SceneDigestSurfaces as Ht, createInputReplay as I, Graphics as In, SceneDigestNode as It, WorkstationInstance as J, SceneHostLike as Jn, Pointer as Jt, RecipeRegistry as K, RectClipMask as Kn, InputPlugin as Kt, createInputTimeline as L, ImageObject as Ln, SceneDigestOptions as Lt, TimelineClickOptions as M, DrawStreamObject as Mn, valueNoise2D as Mt, TimelineDragOptions as N, DrawStreamOptions as Nn, SceneDigest as Nt, RollbackStats as O, DisplayObject as On, packChunkKey as Ot, TimelineKeyOptions as P, DrawStreamSpriteOptions as Pn, SceneDigestActiveFocus as Pt, WorldCatalogRuntime as Q, SpriteAnimEventListener as Qn, RequestWebGpuOptions as Qt, createRollbackSession as R, InstancedBatchObject as Rn, SceneDigestOverlayStats as Rt, InputTimelinePlugin as S, ContainerFiltersShim as Sn, computeDualGridMask as St, RollbackSession as T, CustomPassOptions as Tn, floorDiv as Tt, ItemRegistry as U, PanelObject as Un, buildSceneDigest as Ut, InventoryContainer as V, MsdfIconObject as Vn, SceneDigestSurfaceSource as Vt, ItemStack as W, PanelOpenSide as Wn, sanitizeTrackToken as Wt, WorkstationScheduler as X, ShapeBatchObject as Xn, RendererWebGpu as Xt, WorkstationJob as Y, ShapeBatchColumns as Yn, PointerSample as Yt, WorkstationSnapshot as Z, ShapeBatchStyleDefaults as Zn, RendererWebGpuOptions as Zt, ActionMap as _, AnchorPose2D as _n, SurvivalBiomes as _t, GameLoop as a, HeadlessWebGpuOptions as an, Camera as ar, decodeWorldDeltaBytes as at, InputTargetSpec as b, Bob as bn, bakeDualGridTileset as bt, LoaderPlugin as c, openDawnWebGpu as cn, HiDpiScaleLike as cr, BakeDualGridTilesetOptions as ct, SceneCtor as d, Renderer2D as dn, ChunkedTilemap as dt, WebGpuCanvasContextLike as en, SpritePlayOptions as er, WorldDeltaSnapshot as et, SceneInput as f, RendererGl as fn, ChunkedTilemapOptions as ft, ViewportFitResult as g, StageRenderTarget as gn, MountedChunkedTilemap as gt, StageRenderer as h, Stage2DCustomImageHandler as hn, MountChunkedTilemapOptions as ht, GameConfig as i, HeadlessWebGpuHandle as in, TileSpriteObject as ir, createWorldCatalogRuntime as it, StagePlugin as j, DrawStreamBulkView as jn, unpackChunkY as jt, StageInputEvent as k, DisplayObjectType as kn, positiveMod as kt, ScaleManager as l, openWgpuNativeFfi as ln, BakedDualGridAtlas as lt, SceneManager as m, RendererStats as mn, IslandBiomeConfig as mt, EngineClockSnapshot as n, requestWebGpuDevice as nn, TextObject as nr, applyWorldDelta as nt, GameObjectFactory as o, OpenDawnWebGpuOptions as on, CameraFollowOptions as or, defineWorldCatalog as ot, SceneLifecycleStats as p, RendererGlOptions as pn, DualGridLayerSpec as pt, TileCellDelta as q, RectangleObject as qn, KeyboardPlugin as qt, Game as r, HeadlessWebGpuBackend as rn, TextStyleConfig as rr, captureWorldDelta as rt, JsonCache as s, OpenWgpuNativeFfiOptions as sn, HiDpiConfigureOptions as sr, encodeWorldDeltaBytes as st, EngineClock as t, WebGpuDeviceLike as tn, SyncAttachmentOptions as tr, WorldEntityRecord as tt, Scene as u, requestHeadlessWebGpu as un, ChunkGeneratorFn as ut, InputProvider as v, BindEquipmentOptions as vn, TileCellFlags as vt, RollbackResult as w, CustomPassObject as wn, fbm2D as wt, InputTimelineOptions as x, Container as xn, computeBlob47Index as xt, InputRecorderPlugin as y, BlitterObject as yn, TileChunk as yt, CatalogReloadDiff as z, InstancedColumns as zn, SceneDigestSandbox as zt };
|
package/dist/headless.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lt as SceneDigestOptions, Nt as SceneDigest, an as HeadlessWebGpuOptions, cn as openDawnWebGpu, f as SceneInput, in as HeadlessWebGpuHandle, j as StagePlugin, ln as openWgpuNativeFfi, n as EngineClockSnapshot, on as OpenDawnWebGpuOptions, r as Game, rn as HeadlessWebGpuBackend, sn as OpenWgpuNativeFfiOptions, tn as WebGpuDeviceLike, u as Scene, un as requestHeadlessWebGpu } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
/** Minimal Canvas2D surface compatible with `@napi-rs/canvas`, `node-canvas`, and browser `<canvas>`. */
|
|
3
3
|
export interface HeadlessCanvasLike {
|
|
4
4
|
width: number;
|
|
@@ -287,4 +287,55 @@ export declare function buildFfmpegRawVideoArgs(options: FfmpegRawVideoArgsOptio
|
|
|
287
287
|
* `image2pipe` (`mjpeg` + `libvpx-vp9` WebM) when only Playwright's trimmed `ffmpeg` binary is available.
|
|
288
288
|
*/
|
|
289
289
|
export declare function encodeVideoWithFfmpeg(stage: HeadlessStage, options: EncodeVideoWithFfmpegOptions): Promise<EncodeVideoResult>;
|
|
290
|
+
export interface MetricSummaryStats {
|
|
291
|
+
readonly min: number;
|
|
292
|
+
readonly max: number;
|
|
293
|
+
readonly mean: number;
|
|
294
|
+
readonly p50: number;
|
|
295
|
+
readonly p95: number;
|
|
296
|
+
readonly sum: number;
|
|
297
|
+
}
|
|
298
|
+
export interface HeadlessRolloutRunResult<TMetrics extends Record<string, number>> {
|
|
299
|
+
readonly runIndex: number;
|
|
300
|
+
readonly seed: number;
|
|
301
|
+
readonly ticks: number;
|
|
302
|
+
readonly simTimeMs: number;
|
|
303
|
+
readonly metrics: TMetrics;
|
|
304
|
+
}
|
|
305
|
+
export interface HeadlessRolloutOptions<TMetrics extends Record<string, number>, TScene extends Scene = Scene> {
|
|
306
|
+
/** Number of independent simulation rollouts (`default = seeds?.length ?? 16`). */
|
|
307
|
+
readonly runs?: number;
|
|
308
|
+
/** Optional explicit seed list; defaults to `baseSeed + runIndex`. */
|
|
309
|
+
readonly seeds?: readonly number[];
|
|
310
|
+
/** Starting integer seed when `seeds` is omitted (`default = 1`). */
|
|
311
|
+
readonly baseSeed?: number;
|
|
312
|
+
/** Total deterministic simulation ticks executed per run (`default = 1800` = 30s @ 60 Hz). */
|
|
313
|
+
readonly ticksPerRun?: number;
|
|
314
|
+
/** Simulation tick frequency in Hz (`default = 60`). */
|
|
315
|
+
readonly fps?: number;
|
|
316
|
+
/** Logical viewport width (`default = 1280`). */
|
|
317
|
+
readonly width?: number;
|
|
318
|
+
/** Logical viewport height (`default = 720`). */
|
|
319
|
+
readonly height?: number;
|
|
320
|
+
/** Construct a fresh `Scene` instance for `(runIndex, seed)`. */
|
|
321
|
+
readonly createScene: (runIndex: number, seed: number) => TScene;
|
|
322
|
+
/** Optional per-tick bot/policy hook `(stage, tick, runIndex, seed) => boolean | void` (return `false` for early stop). */
|
|
323
|
+
readonly onTick?: (stage: HeadlessStage, tick: number, runIndex: number, seed: number) => boolean | void;
|
|
324
|
+
/** Extract numeric telemetry metrics `{ survived: 1, kills: 14, ... }` at the end of each rollout. */
|
|
325
|
+
readonly extractMetrics: (scene: TScene, clock: EngineClockSnapshot, runIndex: number, seed: number) => TMetrics;
|
|
326
|
+
}
|
|
327
|
+
export interface HeadlessRolloutReport<TMetrics extends Record<string, number>> {
|
|
328
|
+
readonly runsCompleted: number;
|
|
329
|
+
readonly totalTicks: number;
|
|
330
|
+
readonly elapsedMs: number;
|
|
331
|
+
readonly ticksPerSecond: number;
|
|
332
|
+
readonly summary: { readonly [K in keyof TMetrics]: MetricSummaryStats; };
|
|
333
|
+
readonly results: ReadonlyArray<HeadlessRolloutRunResult<TMetrics>>;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Execute `N` deterministic zero-rasterization headless game rollouts in a single Node.js, Bun, or Deno process
|
|
337
|
+
* (`stepSimOnly` / `fastForward` with a zero-overhead stub canvas — zero pixel rasterization or GPU driver required!),
|
|
338
|
+
* returning per-run results and aggregated `min / max / mean / p50 / p95 / sum` balance statistics.
|
|
339
|
+
*/
|
|
340
|
+
export declare function runHeadlessRollouts<TMetrics extends Record<string, number>, TScene extends Scene = Scene>(options: HeadlessRolloutOptions<TMetrics, TScene>): HeadlessRolloutReport<TMetrics>;
|
|
290
341
|
export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu };
|
package/dist/headless.js
CHANGED
|
@@ -1820,4 +1820,155 @@ async function encodeVideoWithFfmpeg(stage, options) {
|
|
|
1820
1820
|
} catch {}
|
|
1821
1821
|
}
|
|
1822
1822
|
}
|
|
1823
|
-
|
|
1823
|
+
function summarizeValues(values) {
|
|
1824
|
+
if (values.length === 0) return {
|
|
1825
|
+
min: 0,
|
|
1826
|
+
max: 0,
|
|
1827
|
+
mean: 0,
|
|
1828
|
+
p50: 0,
|
|
1829
|
+
p95: 0,
|
|
1830
|
+
sum: 0
|
|
1831
|
+
};
|
|
1832
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
1833
|
+
let sum = 0;
|
|
1834
|
+
for (let i = 0; i < sorted.length; i++) sum += sorted[i];
|
|
1835
|
+
const n = sorted.length;
|
|
1836
|
+
const p50Idx = Math.min(n - 1, Math.floor((n - 1) * .5));
|
|
1837
|
+
const p95Idx = Math.min(n - 1, Math.ceil((n - 1) * .95));
|
|
1838
|
+
return {
|
|
1839
|
+
min: sorted[0],
|
|
1840
|
+
max: sorted[n - 1],
|
|
1841
|
+
mean: sum / n,
|
|
1842
|
+
p50: sorted[p50Idx],
|
|
1843
|
+
p95: sorted[p95Idx],
|
|
1844
|
+
sum
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
const noop2dCtx = {
|
|
1848
|
+
canvas: {
|
|
1849
|
+
width: 1,
|
|
1850
|
+
height: 1
|
|
1851
|
+
},
|
|
1852
|
+
save() {},
|
|
1853
|
+
restore() {},
|
|
1854
|
+
scale() {},
|
|
1855
|
+
rotate() {},
|
|
1856
|
+
translate() {},
|
|
1857
|
+
transform() {},
|
|
1858
|
+
setTransform() {},
|
|
1859
|
+
resetTransform() {},
|
|
1860
|
+
clearRect() {},
|
|
1861
|
+
fillRect() {},
|
|
1862
|
+
strokeRect() {},
|
|
1863
|
+
beginPath() {},
|
|
1864
|
+
closePath() {},
|
|
1865
|
+
moveTo() {},
|
|
1866
|
+
lineTo() {},
|
|
1867
|
+
arc() {},
|
|
1868
|
+
arcTo() {},
|
|
1869
|
+
ellipse() {},
|
|
1870
|
+
rect() {},
|
|
1871
|
+
quadraticCurveTo() {},
|
|
1872
|
+
bezierCurveTo() {},
|
|
1873
|
+
fill() {},
|
|
1874
|
+
stroke() {},
|
|
1875
|
+
clip() {},
|
|
1876
|
+
drawImage() {},
|
|
1877
|
+
fillText() {},
|
|
1878
|
+
strokeText() {},
|
|
1879
|
+
measureText: (t) => ({ width: String(t).length * 8 }),
|
|
1880
|
+
createLinearGradient: () => ({ addColorStop() {} }),
|
|
1881
|
+
createRadialGradient: () => ({ addColorStop() {} }),
|
|
1882
|
+
createImageData: (w, h) => ({
|
|
1883
|
+
width: w,
|
|
1884
|
+
height: h,
|
|
1885
|
+
data: new Uint8ClampedArray(w * h * 4)
|
|
1886
|
+
}),
|
|
1887
|
+
getImageData: (_x, _y, w, h) => ({
|
|
1888
|
+
width: w,
|
|
1889
|
+
height: h,
|
|
1890
|
+
data: new Uint8ClampedArray(w * h * 4)
|
|
1891
|
+
}),
|
|
1892
|
+
putImageData() {}
|
|
1893
|
+
};
|
|
1894
|
+
function createZeroRasterCanvas(width, height) {
|
|
1895
|
+
return {
|
|
1896
|
+
width,
|
|
1897
|
+
height,
|
|
1898
|
+
getContext() {
|
|
1899
|
+
return noop2dCtx;
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Execute `N` deterministic zero-rasterization headless game rollouts in a single Node.js, Bun, or Deno process
|
|
1905
|
+
* (`stepSimOnly` / `fastForward` with a zero-overhead stub canvas — zero pixel rasterization or GPU driver required!),
|
|
1906
|
+
* returning per-run results and aggregated `min / max / mean / p50 / p95 / sum` balance statistics.
|
|
1907
|
+
*/
|
|
1908
|
+
function runHeadlessRollouts(options) {
|
|
1909
|
+
const seeds = options.seeds;
|
|
1910
|
+
const runCount = Math.max(1, Math.floor(options.runs ?? seeds?.length ?? 16));
|
|
1911
|
+
const baseSeed = options.baseSeed ?? 1;
|
|
1912
|
+
const ticksPerRun = Math.max(1, Math.floor(options.ticksPerRun ?? 1800));
|
|
1913
|
+
const fps = Math.max(1, Math.min(240, options.fps ?? 60));
|
|
1914
|
+
const width = Math.max(1, Math.round(options.width ?? 1280));
|
|
1915
|
+
const height = Math.max(1, Math.round(options.height ?? 720));
|
|
1916
|
+
const t0 = performance.now();
|
|
1917
|
+
const results = [];
|
|
1918
|
+
const metricBuckets = /* @__PURE__ */ new Map();
|
|
1919
|
+
let totalTicks = 0;
|
|
1920
|
+
for (let r = 0; r < runCount; r++) {
|
|
1921
|
+
const seed = seeds && r < seeds.length ? seeds[r] : baseSeed + r;
|
|
1922
|
+
const stage = createHeadlessStage({
|
|
1923
|
+
createCanvas: createZeroRasterCanvas,
|
|
1924
|
+
width,
|
|
1925
|
+
height,
|
|
1926
|
+
fps,
|
|
1927
|
+
scene: options.createScene(r, seed)
|
|
1928
|
+
});
|
|
1929
|
+
let executedTicks = 0;
|
|
1930
|
+
try {
|
|
1931
|
+
if (options.onTick) for (let t = 0; t < ticksPerRun; t++) {
|
|
1932
|
+
if (options.onTick(stage, t, r, seed) === false) break;
|
|
1933
|
+
stage.fastForward(1);
|
|
1934
|
+
executedTicks++;
|
|
1935
|
+
}
|
|
1936
|
+
else {
|
|
1937
|
+
stage.fastForward(ticksPerRun);
|
|
1938
|
+
executedTicks = ticksPerRun;
|
|
1939
|
+
}
|
|
1940
|
+
totalTicks += executedTicks;
|
|
1941
|
+
const snap = stage.game.clock.snapshot();
|
|
1942
|
+
const metrics = options.extractMetrics(stage.scene, snap, r, seed);
|
|
1943
|
+
for (const key of Object.keys(metrics)) {
|
|
1944
|
+
let arr = metricBuckets.get(key);
|
|
1945
|
+
if (!arr) {
|
|
1946
|
+
arr = [];
|
|
1947
|
+
metricBuckets.set(key, arr);
|
|
1948
|
+
}
|
|
1949
|
+
arr.push(Number(metrics[key]) || 0);
|
|
1950
|
+
}
|
|
1951
|
+
results.push({
|
|
1952
|
+
runIndex: r,
|
|
1953
|
+
seed,
|
|
1954
|
+
ticks: executedTicks,
|
|
1955
|
+
simTimeMs: snap.simTimeMs,
|
|
1956
|
+
metrics
|
|
1957
|
+
});
|
|
1958
|
+
} finally {
|
|
1959
|
+
stage.destroy();
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
const elapsedMs = Math.max(.001, performance.now() - t0);
|
|
1963
|
+
const summaryObj = {};
|
|
1964
|
+
for (const [key, vals] of metricBuckets.entries()) summaryObj[key] = summarizeValues(vals);
|
|
1965
|
+
return {
|
|
1966
|
+
runsCompleted: results.length,
|
|
1967
|
+
totalTicks,
|
|
1968
|
+
elapsedMs,
|
|
1969
|
+
ticksPerSecond: Math.round(totalTicks / elapsedMs * 1e3),
|
|
1970
|
+
summary: summaryObj,
|
|
1971
|
+
results
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1974
|
+
export { buildFfmpegRawVideoArgs, createAudioTimeline, createHeadlessStage, createHeadlessStageAsync, encodeVideoWithFfmpeg, openDawnWebGpu, openHeadlessStage, openWgpuNativeFfi, renderStoryboard, requestHeadlessWebGpu, runHeadlessRollouts };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as SpriteObject, $t as WebGpuBootstrapResult, A as StageKernel, An as DisplaySemantics, Bn as MsdfIconConfig, Bt as SceneDigestSurfaceEntry, C as RecordedInputEntry, Cn as CustomPassCallback, D as RollbackStateCodec, Dn as DisplayList, E as RollbackSessionOptions, En as DirectionalPlayOptions, F as createInputRecorder, Fn as EquipmentBinding, Ft as SceneDigestEngineSandbox, Gn as PanelStyleConfig, Gt as InputConfig, Hn as NineSliceObject, Ht as SceneDigestSurfaces, I as createInputReplay, In as Graphics, It as SceneDigestNode, Jn as SceneHostLike, Jt as Pointer, Kn as RectClipMask, Kt as InputPlugin, L as createInputTimeline, Ln as ImageObject, Lt as SceneDigestOptions, M as TimelineClickOptions, Mn as DrawStreamObject, N as TimelineDragOptions, Nn as DrawStreamOptions, Nt as SceneDigest, O as RollbackStats, On as DisplayObject, P as TimelineKeyOptions, Pn as DrawStreamSpriteOptions, Pt as SceneDigestActiveFocus, Qn as SpriteAnimEventListener, Qt as RequestWebGpuOptions, R as createRollbackSession, Rn as InstancedBatchObject, Rt as SceneDigestOverlayStats, S as InputTimelinePlugin, Sn as ContainerFiltersShim, T as RollbackSession, Tn as CustomPassOptions, Un as PanelObject, Ut as buildSceneDigest, Vn as MsdfIconObject, Vt as SceneDigestSurfaceSource, Wn as PanelOpenSide, Wt as sanitizeTrackToken, Xn as ShapeBatchObject, Xt as RendererWebGpu, Yn as ShapeBatchColumns, Yt as PointerSample, Zn as ShapeBatchStyleDefaults, Zt as RendererWebGpuOptions, _ as ActionMap, _n as AnchorPose2D, a as GameLoop, an as HeadlessWebGpuOptions, ar as Camera, b as InputTargetSpec, bn as Bob$1, c as LoaderPlugin, cn as openDawnWebGpu, cr as HiDpiScaleLike, d as SceneCtor, dn as Renderer2D, en as WebGpuCanvasContextLike, er as SpritePlayOptions, f as SceneInput, fn as RendererGl, g as ViewportFitResult, gn as StageRenderTarget, h as StageRenderer, hn as Stage2DCustomImageHandler, i as GameConfig$1, in as HeadlessWebGpuHandle, ir as TileSpriteObject, j as StagePlugin, jn as DrawStreamBulkView, k as StageInputEvent, kn as DisplayObjectType, l as ScaleManager, ln as openWgpuNativeFfi, m as SceneManager, mn as RendererStats, n as EngineClockSnapshot, nn as requestWebGpuDevice, nr as TextObject, o as GameObjectFactory, on as OpenDawnWebGpuOptions, or as CameraFollowOptions, p as SceneLifecycleStats, pn as RendererGlOptions, qn as RectangleObject, qt as KeyboardPlugin, r as Game, rn as HeadlessWebGpuBackend, rr as TextStyleConfig, s as JsonCache, sn as OpenWgpuNativeFfiOptions, sr as HiDpiConfigureOptions, t as EngineClock, tn as WebGpuDeviceLike, tr as SyncAttachmentOptions, u as Scene, un as requestHeadlessWebGpu, v as InputProvider, vn as BindEquipmentOptions, w as RollbackResult, wn as CustomPassObject, x as InputTimelineOptions, xn as Container, y as InputRecorderPlugin, yn as BlitterObject, zn as InstancedColumns, zt as SceneDigestSandbox } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
import { A as FilterModeValue, B as WEBGL, C as AUTO, D as CANVAS, E as BlendModes, F as Scale, G as packColorAbgr, H as WHITE_RGB, I as ScaleMode, K as parseColor, L as Scenes, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, V as WEBGPU, W as createMatrix2D, _ as SpriteSheetConfig, a as AtlasClipRule, b as TextureImageSource, c as GenerateFrameNamesConfig, d as AtlasJsonLike, f as CanvasTexture, g as GlTextureHost, h as FrameExtraMeta, i as AtlasAutoAnimOptions, j as HEX_MASK, k as FilterMode, l as GenerateFrameNumbersConfig, m as FrameAnchorTuple, n as AnimationFrameInput, o as CompiledAnimationFrame, p as Frame, q as rgbToCss, r as AnimationManager, s as DirectionalAnimGroup, t as AnimationConfig, u as StageAnimation, v as Texture, w as BLACK_RGB, x as TextureManager, y as TextureImageOptions, z as TintModes } from "./anims-BOvaKn6w.js";
|
|
3
|
+
import { LocomotionFeel, LocomotionFeelInput, LocomotionFeelOptions, LocomotionFeelSample } from "./particles.js";
|
|
3
4
|
import { FlattenedFlexNode, FlattenedFlexTree, FlexAlign, FlexContainerSpec, FlexDir, FlexIconSpec, FlexItemRect, FlexItemSpec, FlexJustify, FlexNodeSpec, FlexPadding, FlexPanelStyle, FlexResult, FlexTextSpec, MountFlexUiOptions, MountedFlexUi, WrapContainerSpec, WrapItemRect, WrapItemSpec, WrapJustify, WrapResult, computeFlexLayout, computeWrapLayout, flattenFlexTree, mountFlexUi, resolvePadding } from "./flex.js";
|
|
4
5
|
import { a as SpringHandle, c as TweenManager, i as Easings, l as TweenOptions, n as EasingFn, o as SpringOptions, r as EasingName, s as TweenHandle, t as DisposableOwner, u as TweenStats } from "./tween-BiF1FUvc.js";
|
|
5
6
|
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
|
@@ -332,4 +333,4 @@ export declare const Stage: {
|
|
|
332
333
|
};
|
|
333
334
|
};
|
|
334
335
|
};
|
|
335
|
-
export { AUTO, ActionMap, type AnchorPose2D, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BindEquipmentOptions, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraFollowOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CoroutineGenerator, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type DrawStreamBulkView, DrawStreamObject, type DrawStreamOptions, type DrawStreamSpriteOptions, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, type EquipmentBinding, EventEmitter, FilterMode, type FilterModeValue, type FlattenedFlexNode, type FlattenedFlexTree, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexIconSpec, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexNodeSpec, type FlexPadding, type FlexPanelStyle, type FlexResult, type FlexTextSpec, Frame, type FrameAnchorTuple, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, type Matrix2D, type MountFlexUiOptions, type MountedFlexUi, type MsdfIconConfig, MsdfIconObject, NineSliceObject, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, type SyncAttachmentOptions, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
336
|
+
export { AUTO, ActionMap, type AnchorPose2D, type AnimationConfig, type AnimationFrameInput, AnimationManager, type AtlasAutoAnimOptions, type AtlasClipRule, type AtlasJsonLike, BLACK_RGB, type BindEquipmentOptions, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, type CameraFollowOptions, CanvasTexture, type CompiledAnimationFrame, Container, type ContainerFiltersShim, type CoroutineGenerator, type CustomPassCallback, CustomPassObject, type CustomPassOptions, type DirectionalAnimGroup, type DirectionalPlayOptions, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type DrawStreamBulkView, DrawStreamObject, type DrawStreamOptions, type DrawStreamSpriteOptions, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, type EquipmentBinding, EventEmitter, FilterMode, type FilterModeValue, type FlattenedFlexNode, type FlattenedFlexTree, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexIconSpec, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexNodeSpec, type FlexPadding, type FlexPanelStyle, type FlexResult, type FlexTextSpec, Frame, type FrameAnchorTuple, type FrameExtraMeta, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GenerateFrameNamesConfig, type GenerateFrameNumbersConfig, type GlTextureHost, Graphics, HEX_MASK, type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type HiDpiConfigureOptions, type HiDpiScaleLike, ImageObject, type InputConfig, InputPlugin, type InputProvider, type InputRecorderPlugin, type InputTargetSpec, type InputTimelineOptions, type InputTimelinePlugin, InstancedBatchObject, type InstancedColumns, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, type LocomotionFeelInput, type LocomotionFeelOptions, type LocomotionFeelSample, type Matrix2D, type MountFlexUiOptions, type MountedFlexUi, type MsdfIconConfig, MsdfIconObject, NineSliceObject, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type RecordedInputEntry, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, RendererWebGpu, type RendererWebGpuOptions, type RequestWebGpuOptions, type RgbaColor, type RollbackResult, RollbackSession, type RollbackSessionOptions, type RollbackStateCodec, type RollbackStats, SURFACE_BAND, Scale, ScaleManager, type ScaleMode, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, type ShapeBatchColumns, ShapeBatchObject, type ShapeBatchStyleDefaults, type SpringHandle, type SpringOptions, type SpriteAnimEventListener, SpriteObject, type SpritePlayOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageAnimation, type StageInputEvent, StageKernel, type StagePlugin, type StageRenderTarget, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, type SyncAttachmentOptions, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TimelineClickOptions, type TimelineDragOptions, type TimelineKeyOptions, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, type ViewportFitResult, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WEBGPU, WHITE_RGB, type WebGpuBootstrapResult, type WebGpuCanvasContextLike, type WebGpuDeviceLike, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ import { _ as CanvasTexture, a as JsonCache, b as TextureManager, c as Scene, d
|
|
|
3
3
|
import { AnimationManager } from "./anims.js";
|
|
4
4
|
import { a as requestHeadlessWebGpu, i as openWgpuNativeFfi, n as requestWebGpuDevice, o as Renderer2D, r as openDawnWebGpu, s as Camera, t as RendererWebGpu } from "./renderer-webgpu-q4vdE3kA.js";
|
|
5
5
|
import { _ as TileSpriteObject, a as DisplayObject, c as ImageObject, d as NineSliceObject, f as PanelObject, g as TextObject, h as SpriteObject, i as DisplayList, l as InstancedBatchObject, m as ShapeBatchObject, n as Container, o as DrawStreamObject, p as RectangleObject, r as CustomPassObject, s as Graphics, t as BlitterObject, u as MsdfIconObject } from "./display-CVjvA8ZO.js";
|
|
6
|
-
import { ActionMap, StageKernel, createInputRecorder, createInputReplay, createInputTimeline } from "./kernel.js";
|
|
6
|
+
import { ActionMap, RollbackSession, StageKernel, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession } from "./kernel.js";
|
|
7
|
+
import { LocomotionFeel } from "./particles.js";
|
|
7
8
|
import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
|
|
8
9
|
import { computeFlexLayout, computeWrapLayout, flattenFlexTree, mountFlexUi, resolvePadding } from "./flex.js";
|
|
9
10
|
import { Easings, TweenManager } from "./tween.js";
|
|
@@ -51,4 +52,4 @@ const Stage2D = {
|
|
|
51
52
|
Display: { Canvas: { CanvasPool: { enableSmoothing() {} } } }
|
|
52
53
|
};
|
|
53
54
|
const Stage = Stage2D;
|
|
54
|
-
export { AUTO, ActionMap, AnimationManager, BLACK_RGB, BlendModes, BlitterObject, CANVAS, Camera, CanvasTexture, Container, CustomPassObject, DisplayList, DisplayObject, DrawStreamObject, Easings, EngineClock, EventEmitter, FilterMode, Frame, Game, GameLoop, GameObjectFactory, Graphics, HEX_MASK, ImageObject, InputPlugin, InstancedBatchObject, JsonCache, KeyboardPlugin, LoaderPlugin, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, SURFACE_BAND, Scale, ScaleManager, Scene, SceneManager, Scenes, ScriptScheduler, SdfPanelBatcher, ShapeBatchObject, SpriteObject, Stage, Stage as default, Stage2D, StageKernel, TextObject, Texture, TextureManager, TextureSource, TileSpriteObject, TintModes, TweenManager, VirtualJoystick, WEBGL, WEBGPU, WHITE_RGB, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
|
55
|
+
export { AUTO, ActionMap, AnimationManager, BLACK_RGB, BlendModes, BlitterObject, CANVAS, Camera, CanvasTexture, Container, CustomPassObject, DisplayList, DisplayObject, DrawStreamObject, Easings, EngineClock, EventEmitter, FilterMode, Frame, Game, GameLoop, GameObjectFactory, Graphics, HEX_MASK, ImageObject, InputPlugin, InstancedBatchObject, JsonCache, KeyboardPlugin, LoaderPlugin, LocomotionFeel, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, RendererWebGpu, RollbackSession, SURFACE_BAND, Scale, ScaleManager, Scene, SceneManager, Scenes, ScriptScheduler, SdfPanelBatcher, ShapeBatchObject, SpriteObject, Stage, Stage as default, Stage2D, StageKernel, TextObject, Texture, TextureManager, TextureSource, TileSpriteObject, TintModes, TweenManager, VirtualJoystick, WEBGL, WEBGPU, WHITE_RGB, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createInputRecorder, createInputReplay, createInputTimeline, createMatrix2D, createRollbackSession, createSurfaceTree, flattenFlexTree, isInJoystickZone, mountFlexUi, openDawnWebGpu, openWgpuNativeFfi, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, requestHeadlessWebGpu, requestWebGpuDevice, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
|
package/dist/joystick.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jt as Pointer, Un as PanelObject, u as Scene, xn as Container } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export type VirtualJoystickMode = 'floating' | 'fixed';
|
|
3
3
|
export interface JoystickVector {
|
|
4
4
|
/** Normalized X axis in [-1, 1] after deadzone remapping. */
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
|
2
|
-
import { A as
|
|
3
|
-
export { ActionMap, type CoroutineGenerator, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createInputRecorder, createInputReplay, createInputTimeline };
|
|
2
|
+
import { A as StageKernel, C as RecordedInputEntry, D as RollbackStateCodec, E as RollbackSessionOptions, F as createInputRecorder, I as createInputReplay, L as createInputTimeline, M as TimelineClickOptions, N as TimelineDragOptions, O as RollbackStats, P as TimelineKeyOptions, R as createRollbackSession, S as InputTimelinePlugin, T as RollbackSession, _ as ActionMap, b as InputTargetSpec, j as StagePlugin, k as StageInputEvent, v as InputProvider, w as RollbackResult, x as InputTimelineOptions, y as InputRecorderPlugin } from "./game-Dxh9e0Hv.js";
|
|
3
|
+
export { ActionMap, type CoroutineGenerator, InputProvider, InputRecorderPlugin, InputTargetSpec, InputTimelineOptions, InputTimelinePlugin, RecordedInputEntry, RollbackResult, RollbackSession, RollbackSessionOptions, RollbackStateCodec, RollbackStats, type ScriptContext, type ScriptHandle, type ScriptOptions, ScriptScheduler, type ScriptStats, StageInputEvent, StageKernel, StagePlugin, TimelineClickOptions, TimelineDragOptions, TimelineKeyOptions, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession };
|
package/dist/kernel.js
CHANGED
|
@@ -654,4 +654,169 @@ function createInputReplay(log, id = "stage.input-replay") {
|
|
|
654
654
|
};
|
|
655
655
|
return replay;
|
|
656
656
|
}
|
|
657
|
-
|
|
657
|
+
function fnv1aBytes(buf) {
|
|
658
|
+
let h = 0x811c9dc5;
|
|
659
|
+
for (let i = 0; i < buf.length; i++) {
|
|
660
|
+
h ^= buf[i];
|
|
661
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
662
|
+
}
|
|
663
|
+
return h >>> 0;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Deterministic ring-buffered rollback netcode (GGPO-style prediction + authoritative correction)
|
|
667
|
+
* and interactive Time-Travel debugger with zero steady-state heap allocations.
|
|
668
|
+
*/
|
|
669
|
+
var RollbackSession = class RollbackSession {
|
|
670
|
+
windowFrames;
|
|
671
|
+
curFrame;
|
|
672
|
+
minRecordedFrame;
|
|
673
|
+
codec;
|
|
674
|
+
stepFn;
|
|
675
|
+
inputEq;
|
|
676
|
+
ringFrames;
|
|
677
|
+
ringBufs;
|
|
678
|
+
ringLens;
|
|
679
|
+
ringChecksums;
|
|
680
|
+
ringInputs;
|
|
681
|
+
rollbacks = 0;
|
|
682
|
+
resimFrames = 0;
|
|
683
|
+
maxDepth = 0;
|
|
684
|
+
constructor(options) {
|
|
685
|
+
this.windowFrames = Math.max(2, Math.floor(options.windowFrames ?? 120));
|
|
686
|
+
this.curFrame = Math.max(0, Math.floor(options.initialFrame ?? 0));
|
|
687
|
+
this.minRecordedFrame = this.curFrame;
|
|
688
|
+
this.codec = options.codec;
|
|
689
|
+
this.stepFn = options.step;
|
|
690
|
+
this.inputEq = options.inputEquals ?? Object.is;
|
|
691
|
+
this.ringFrames = new Int32Array(this.windowFrames).fill(-1);
|
|
692
|
+
this.ringBufs = new Array(this.windowFrames);
|
|
693
|
+
this.ringLens = new Uint32Array(this.windowFrames);
|
|
694
|
+
this.ringChecksums = new Uint32Array(this.windowFrames);
|
|
695
|
+
this.ringInputs = new Array(this.windowFrames);
|
|
696
|
+
}
|
|
697
|
+
/** Create a `RollbackSession` bound directly to a `SoaWorld` (`world.snapshot` / `world.restore` / `world.checksum`). */
|
|
698
|
+
static fromSoaWorld(world, step, options = {}) {
|
|
699
|
+
return new RollbackSession({
|
|
700
|
+
...options,
|
|
701
|
+
codec: {
|
|
702
|
+
save: (into) => world.snapshot(into),
|
|
703
|
+
load: (snap) => world.restore(snap),
|
|
704
|
+
checksum: world.checksum ? () => world.checksum() : void 0
|
|
705
|
+
},
|
|
706
|
+
step
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
get currentFrame() {
|
|
710
|
+
return this.curFrame;
|
|
711
|
+
}
|
|
712
|
+
get oldestFrame() {
|
|
713
|
+
return Math.max(this.minRecordedFrame, this.curFrame - this.windowFrames);
|
|
714
|
+
}
|
|
715
|
+
captureAtSlot(slot, frame) {
|
|
716
|
+
let capBuf = this.ringBufs[slot];
|
|
717
|
+
const snap = this.codec.save(capBuf);
|
|
718
|
+
if (!capBuf || snap.buffer !== capBuf.buffer || capBuf.byteLength < snap.byteLength) {
|
|
719
|
+
const nextCap = Math.max(256, snap.byteLength * 2);
|
|
720
|
+
capBuf = new Uint8Array(nextCap);
|
|
721
|
+
capBuf.set(snap, 0);
|
|
722
|
+
this.ringBufs[slot] = capBuf;
|
|
723
|
+
}
|
|
724
|
+
this.ringLens[slot] = snap.byteLength;
|
|
725
|
+
this.ringChecksums[slot] = this.codec.checksum ? this.codec.checksum() >>> 0 : fnv1aBytes(snap);
|
|
726
|
+
this.ringFrames[slot] = frame;
|
|
727
|
+
}
|
|
728
|
+
/** Save pre-step state for `currentFrame`, execute `step(currentFrame, input)`, and advance `currentFrame`. */
|
|
729
|
+
advance(input) {
|
|
730
|
+
const f = this.curFrame;
|
|
731
|
+
const slot = f % this.windowFrames;
|
|
732
|
+
this.captureAtSlot(slot, f);
|
|
733
|
+
this.ringInputs[slot] = input;
|
|
734
|
+
this.stepFn(f, input);
|
|
735
|
+
this.curFrame = f + 1;
|
|
736
|
+
return this.curFrame;
|
|
737
|
+
}
|
|
738
|
+
/** Read the input applied at historical `frame` (within `[oldestFrame .. currentFrame - 1]`). */
|
|
739
|
+
inputAt(frame) {
|
|
740
|
+
if (frame < this.oldestFrame || frame >= this.curFrame) return void 0;
|
|
741
|
+
const slot = frame % this.windowFrames;
|
|
742
|
+
return this.ringFrames[slot] === frame ? this.ringInputs[slot] : void 0;
|
|
743
|
+
}
|
|
744
|
+
/** Compute current live state checksum. */
|
|
745
|
+
currentChecksum() {
|
|
746
|
+
if (this.codec.checksum) return this.codec.checksum() >>> 0;
|
|
747
|
+
return fnv1aBytes(this.codec.save());
|
|
748
|
+
}
|
|
749
|
+
/** Compute checksum of the pre-step snapshot stored at historical `frame` (`null` if evicted). */
|
|
750
|
+
checksumAt(frame) {
|
|
751
|
+
if (frame === this.curFrame) return this.currentChecksum();
|
|
752
|
+
if (frame < this.oldestFrame || frame > this.curFrame) return null;
|
|
753
|
+
const slot = frame % this.windowFrames;
|
|
754
|
+
if (this.ringFrames[slot] !== frame) return null;
|
|
755
|
+
return this.ringChecksums[slot];
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Time-Travel rewind: restore live simulation state back to `targetFrame` (`oldestFrame <= targetFrame <= currentFrame`),
|
|
759
|
+
* resetting `currentFrame = targetFrame` so subsequent `advance()` calls branch into a new timeline cleanly.
|
|
760
|
+
*/
|
|
761
|
+
rewindTo(targetFrame) {
|
|
762
|
+
const tf = Math.floor(targetFrame);
|
|
763
|
+
if (tf === this.curFrame) return;
|
|
764
|
+
if (tf < this.oldestFrame || tf > this.curFrame) throw new RangeError(`RollbackSession.rewindTo: frame ${tf} outside retained window [${this.oldestFrame}..${this.curFrame}]`);
|
|
765
|
+
const slot = tf % this.windowFrames;
|
|
766
|
+
const buf = this.ringBufs[slot];
|
|
767
|
+
if (this.ringFrames[slot] !== tf || !buf) throw new Error(`RollbackSession.rewindTo: missing snapshot for frame ${tf}`);
|
|
768
|
+
this.codec.load(buf.subarray(0, this.ringLens[slot]));
|
|
769
|
+
for (let f = tf + 1; f < this.curFrame; f++) this.ringFrames[f % this.windowFrames] = -1;
|
|
770
|
+
this.curFrame = tf;
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Apply an authoritative remote/replay input for `targetFrame`.
|
|
774
|
+
* If it matches the predicted input already simulated at `targetFrame`, returns immediately (`rolledBack: false`).
|
|
775
|
+
* Otherwise restores `targetFrame`'s snapshot, updates the input at `targetFrame`, and re-simulates `[targetFrame .. currentFrame - 1]`.
|
|
776
|
+
*/
|
|
777
|
+
applyAuthoritativeInput(targetFrame, actualInput, equals) {
|
|
778
|
+
const tf = Math.floor(targetFrame);
|
|
779
|
+
if (tf < this.oldestFrame || tf >= this.curFrame) throw new RangeError(`RollbackSession.applyAuthoritativeInput: frame ${tf} outside active window [${this.oldestFrame}..${this.curFrame - 1}]`);
|
|
780
|
+
const slot = tf % this.windowFrames;
|
|
781
|
+
const buf = this.ringBufs[slot];
|
|
782
|
+
if (this.ringFrames[slot] !== tf || !buf) throw new Error(`RollbackSession.applyAuthoritativeInput: missing snapshot at frame ${tf}`);
|
|
783
|
+
if ((equals ?? this.inputEq)(this.ringInputs[slot], actualInput)) return {
|
|
784
|
+
rolledBack: false,
|
|
785
|
+
targetFrame: tf,
|
|
786
|
+
framesResimulated: 0,
|
|
787
|
+
checksum: this.currentChecksum()
|
|
788
|
+
};
|
|
789
|
+
const endFrame = this.curFrame;
|
|
790
|
+
const depth = endFrame - tf;
|
|
791
|
+
this.codec.load(buf.subarray(0, this.ringLens[slot]));
|
|
792
|
+
this.ringInputs[slot] = actualInput;
|
|
793
|
+
for (let f = tf; f < endFrame; f++) {
|
|
794
|
+
const fSlot = f % this.windowFrames;
|
|
795
|
+
if (f > tf) this.captureAtSlot(fSlot, f);
|
|
796
|
+
this.stepFn(f, this.ringInputs[fSlot]);
|
|
797
|
+
}
|
|
798
|
+
this.rollbacks++;
|
|
799
|
+
this.resimFrames += depth;
|
|
800
|
+
if (depth > this.maxDepth) this.maxDepth = depth;
|
|
801
|
+
return {
|
|
802
|
+
rolledBack: true,
|
|
803
|
+
targetFrame: tf,
|
|
804
|
+
framesResimulated: depth,
|
|
805
|
+
checksum: this.currentChecksum()
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
stats() {
|
|
809
|
+
return {
|
|
810
|
+
currentFrame: this.curFrame,
|
|
811
|
+
oldestFrame: this.oldestFrame,
|
|
812
|
+
windowFrames: this.windowFrames,
|
|
813
|
+
rollbackCount: this.rollbacks,
|
|
814
|
+
resimulatedFrames: this.resimFrames,
|
|
815
|
+
maxRollbackDepth: this.maxDepth
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
function createRollbackSession(options) {
|
|
820
|
+
return new RollbackSession(options);
|
|
821
|
+
}
|
|
822
|
+
export { ActionMap, RollbackSession, ScriptScheduler, StageKernel, createInputRecorder, createInputReplay, createInputTimeline, createRollbackSession };
|
package/dist/lighting.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jn as SceneHostLike, Ln as ImageObject, On as DisplayObject, gn as StageRenderTarget, wn as CustomPassObject, xn as Container } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export type DayPhase = 'day' | 'dusk' | 'night';
|
|
3
3
|
export interface DayNightConfig {
|
|
4
4
|
dayLengthMs?: number;
|
package/dist/particles.d.ts
CHANGED
|
@@ -216,4 +216,79 @@ export declare class JuiceController {
|
|
|
216
216
|
* Returns effective world particle delta in seconds (`0` while held in hitstop).
|
|
217
217
|
*/
|
|
218
218
|
tick(frameMs: number, nowMs: number, paused?: boolean): number;
|
|
219
|
+
}
|
|
220
|
+
export interface LocomotionFeelOptions {
|
|
221
|
+
/** Spring stiffness driving squash/stretch recovery back to `1.0` (`default = 260`). */
|
|
222
|
+
readonly stiffness?: number;
|
|
223
|
+
/** Damping ratio (`< 1` bouncy, `1` critically damped; `default = 0.62` for lively rubbery settle). */
|
|
224
|
+
readonly dampingRatio?: number;
|
|
225
|
+
/** Maximum lean angle in radians at full reference horizontal speed (`default = 0.12` rad ~ 7 deg). */
|
|
226
|
+
readonly maxLeanRad?: number;
|
|
227
|
+
/** Reference movement speed in world px/s for full lean & stride bob (`default = 180`). */
|
|
228
|
+
readonly referenceSpeed?: number;
|
|
229
|
+
/** Automatic squash impulse injected when reversing movement direction sharply (`default = -0.18`). */
|
|
230
|
+
readonly turnSquash?: number;
|
|
231
|
+
/** Automatic squash factor per px/s of downward landing velocity (`default = 0.0014`). */
|
|
232
|
+
readonly landSquashScale?: number;
|
|
233
|
+
/** Optional vertical stride hop amplitude in pixels while moving on the ground (`default = 0`). */
|
|
234
|
+
readonly strideBobPx?: number;
|
|
235
|
+
/** Stride hop frequency in Hz (`default = 7.5`). */
|
|
236
|
+
readonly strideFreqHz?: number;
|
|
237
|
+
}
|
|
238
|
+
export interface LocomotionFeelInput {
|
|
239
|
+
readonly vx: number;
|
|
240
|
+
readonly vy: number;
|
|
241
|
+
/** Optional height above ground (`>= 0`); triggers automatic landing squash when touching down to `0`. */
|
|
242
|
+
readonly wz?: number;
|
|
243
|
+
}
|
|
244
|
+
export interface LocomotionFeelSample {
|
|
245
|
+
/** Volume-preserving horizontal scale multiplier (`scaleX = 1 / scaleY`). */
|
|
246
|
+
scaleX: number;
|
|
247
|
+
/** Volume-preserving vertical scale multiplier. */
|
|
248
|
+
scaleY: number;
|
|
249
|
+
/** Velocity-driven lean angle in radians. */
|
|
250
|
+
rotation: number;
|
|
251
|
+
/** Vertical stride-hop offset in pixels (`<= 0`). */
|
|
252
|
+
offsetY: number;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Procedural character secondary-motion controller providing volume-preserving (`scaleX * scaleY = 1`)
|
|
256
|
+
* spring squash-and-stretch, sharp-turn anticipation squash, landing thud, stride bob, and velocity lean
|
|
257
|
+
* for any `SpriteObject`, `ImageObject`, or `Container` without baking extra animation frames.
|
|
258
|
+
*/
|
|
259
|
+
export declare class LocomotionFeel {
|
|
260
|
+
private stretch;
|
|
261
|
+
private stretchVel;
|
|
262
|
+
private lean;
|
|
263
|
+
private stridePhase;
|
|
264
|
+
private prevDirX;
|
|
265
|
+
private prevDirY;
|
|
266
|
+
private hadPrevDir;
|
|
267
|
+
private prevWz;
|
|
268
|
+
private prevVz;
|
|
269
|
+
private readonly stiffness;
|
|
270
|
+
private readonly damping;
|
|
271
|
+
private readonly maxLean;
|
|
272
|
+
private readonly refSpeed;
|
|
273
|
+
private readonly turnSquash;
|
|
274
|
+
private readonly landScale;
|
|
275
|
+
private readonly bobPx;
|
|
276
|
+
private readonly bobFreq;
|
|
277
|
+
private readonly out;
|
|
278
|
+
constructor(opts?: LocomotionFeelOptions);
|
|
279
|
+
/**
|
|
280
|
+
* Inject an instantaneous squash (`amount < 0`, wide & short) or stretch (`amount > 0`, tall & narrow)
|
|
281
|
+
* impulse — e.g. `-0.28` on melee hit/landing, `+0.25` on dash/jump launch.
|
|
282
|
+
*/
|
|
283
|
+
impulse(amount: number): this;
|
|
284
|
+
reset(): this;
|
|
285
|
+
/** Advance procedural squash/stretch, turn anticipation, landing thud, and lean by `dtSec` seconds. */
|
|
286
|
+
step(dtSec: number, input: LocomotionFeelInput): LocomotionFeelSample;
|
|
287
|
+
get current(): LocomotionFeelSample;
|
|
288
|
+
/** Apply current `scaleX`, `scaleY`, and `rotation` multipliers onto a Stage `DisplayObject`. */
|
|
289
|
+
applyTo(target: {
|
|
290
|
+
scaleX: number;
|
|
291
|
+
scaleY: number;
|
|
292
|
+
rotation: number;
|
|
293
|
+
}, baseScaleX?: number, baseScaleY?: number): LocomotionFeelSample;
|
|
219
294
|
}
|
package/dist/particles.js
CHANGED
|
@@ -475,4 +475,130 @@ var JuiceController = class {
|
|
|
475
475
|
return this.stop > 0 ? 0 : safeMs / 1e3;
|
|
476
476
|
}
|
|
477
477
|
};
|
|
478
|
-
|
|
478
|
+
/**
|
|
479
|
+
* Procedural character secondary-motion controller providing volume-preserving (`scaleX * scaleY = 1`)
|
|
480
|
+
* spring squash-and-stretch, sharp-turn anticipation squash, landing thud, stride bob, and velocity lean
|
|
481
|
+
* for any `SpriteObject`, `ImageObject`, or `Container` without baking extra animation frames.
|
|
482
|
+
*/
|
|
483
|
+
var LocomotionFeel = class {
|
|
484
|
+
stretch = 0;
|
|
485
|
+
stretchVel = 0;
|
|
486
|
+
lean = 0;
|
|
487
|
+
stridePhase = 0;
|
|
488
|
+
prevDirX = 0;
|
|
489
|
+
prevDirY = 0;
|
|
490
|
+
hadPrevDir = false;
|
|
491
|
+
prevWz = 0;
|
|
492
|
+
prevVz = 0;
|
|
493
|
+
stiffness;
|
|
494
|
+
damping;
|
|
495
|
+
maxLean;
|
|
496
|
+
refSpeed;
|
|
497
|
+
turnSquash;
|
|
498
|
+
landScale;
|
|
499
|
+
bobPx;
|
|
500
|
+
bobFreq;
|
|
501
|
+
out = {
|
|
502
|
+
scaleX: 1,
|
|
503
|
+
scaleY: 1,
|
|
504
|
+
rotation: 0,
|
|
505
|
+
offsetY: 0
|
|
506
|
+
};
|
|
507
|
+
constructor(opts = {}) {
|
|
508
|
+
this.stiffness = Math.max(10, opts.stiffness ?? 260);
|
|
509
|
+
const zeta = Math.max(.1, Math.min(2, opts.dampingRatio ?? .62));
|
|
510
|
+
this.damping = 2 * zeta * Math.sqrt(this.stiffness);
|
|
511
|
+
this.maxLean = Math.max(0, opts.maxLeanRad ?? .12);
|
|
512
|
+
this.refSpeed = Math.max(1, opts.referenceSpeed ?? 180);
|
|
513
|
+
this.turnSquash = opts.turnSquash ?? -.18;
|
|
514
|
+
this.landScale = Math.max(0, opts.landSquashScale ?? .0014);
|
|
515
|
+
this.bobPx = Math.max(0, opts.strideBobPx ?? 0);
|
|
516
|
+
this.bobFreq = Math.max(.5, opts.strideFreqHz ?? 7.5);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Inject an instantaneous squash (`amount < 0`, wide & short) or stretch (`amount > 0`, tall & narrow)
|
|
520
|
+
* impulse — e.g. `-0.28` on melee hit/landing, `+0.25` on dash/jump launch.
|
|
521
|
+
*/
|
|
522
|
+
impulse(amount) {
|
|
523
|
+
this.stretch = Math.max(-.55, Math.min(.55, this.stretch + amount));
|
|
524
|
+
return this;
|
|
525
|
+
}
|
|
526
|
+
reset() {
|
|
527
|
+
this.stretch = 0;
|
|
528
|
+
this.stretchVel = 0;
|
|
529
|
+
this.lean = 0;
|
|
530
|
+
this.stridePhase = 0;
|
|
531
|
+
this.hadPrevDir = false;
|
|
532
|
+
this.prevWz = 0;
|
|
533
|
+
this.prevVz = 0;
|
|
534
|
+
this.out.scaleX = 1;
|
|
535
|
+
this.out.scaleY = 1;
|
|
536
|
+
this.out.rotation = 0;
|
|
537
|
+
this.out.offsetY = 0;
|
|
538
|
+
return this;
|
|
539
|
+
}
|
|
540
|
+
/** Advance procedural squash/stretch, turn anticipation, landing thud, and lean by `dtSec` seconds. */
|
|
541
|
+
step(dtSec, input) {
|
|
542
|
+
const dt = Math.min(.1, Math.max(0, dtSec));
|
|
543
|
+
if (dt <= 0) return this.out;
|
|
544
|
+
const { vx, vy } = input;
|
|
545
|
+
const wz = Math.max(0, input.wz ?? 0);
|
|
546
|
+
const speed = Math.hypot(vx, vy);
|
|
547
|
+
if (speed > this.refSpeed * .2) {
|
|
548
|
+
const dx = vx / speed;
|
|
549
|
+
const dy = vy / speed;
|
|
550
|
+
if (this.hadPrevDir) {
|
|
551
|
+
const dot = dx * this.prevDirX + dy * this.prevDirY;
|
|
552
|
+
if (dot < -.25 && this.turnSquash !== 0) this.impulse(this.turnSquash * Math.min(1, (-dot - .25) / .75));
|
|
553
|
+
}
|
|
554
|
+
this.prevDirX = dx;
|
|
555
|
+
this.prevDirY = dy;
|
|
556
|
+
this.hadPrevDir = true;
|
|
557
|
+
} else if (speed < this.refSpeed * .05) this.hadPrevDir = false;
|
|
558
|
+
const vz = (wz - this.prevWz) / dt;
|
|
559
|
+
if (this.prevWz > .5 && wz <= .01) {
|
|
560
|
+
const impactSpeed = Math.max(40, -Math.min(vz, this.prevVz));
|
|
561
|
+
this.impulse(-Math.min(.42, impactSpeed * this.landScale));
|
|
562
|
+
}
|
|
563
|
+
this.prevWz = wz;
|
|
564
|
+
this.prevVz = vz;
|
|
565
|
+
const subSteps = 2;
|
|
566
|
+
const h = dt / subSteps;
|
|
567
|
+
for (let s = 0; s < subSteps; s++) {
|
|
568
|
+
const acc = -this.stiffness * this.stretch - this.damping * this.stretchVel;
|
|
569
|
+
this.stretchVel += acc * h;
|
|
570
|
+
this.stretch += this.stretchVel * h;
|
|
571
|
+
}
|
|
572
|
+
if (Math.abs(this.stretch) < 1e-4 && Math.abs(this.stretchVel) < 1e-4) {
|
|
573
|
+
this.stretch = 0;
|
|
574
|
+
this.stretchVel = 0;
|
|
575
|
+
}
|
|
576
|
+
const targetLean = Math.max(-1, Math.min(1, vx / this.refSpeed)) * this.maxLean;
|
|
577
|
+
const leanAlpha = 1 - Math.exp(-16 * dt);
|
|
578
|
+
this.lean += (targetLean - this.lean) * leanAlpha;
|
|
579
|
+
let offsetY = 0;
|
|
580
|
+
if (this.bobPx > 0 && wz <= .05 && speed > this.refSpeed * .1) {
|
|
581
|
+
const speedNorm = Math.min(1.25, speed / this.refSpeed);
|
|
582
|
+
this.stridePhase = (this.stridePhase + dt * this.bobFreq * speedNorm * Math.PI * 2) % (Math.PI * 2);
|
|
583
|
+
offsetY = -Math.abs(Math.sin(this.stridePhase)) * this.bobPx * speedNorm;
|
|
584
|
+
} else this.stridePhase = 0;
|
|
585
|
+
const clamped = Math.max(-.55, Math.min(.55, this.stretch));
|
|
586
|
+
const sy = Math.exp(clamped);
|
|
587
|
+
this.out.scaleX = 1 / sy;
|
|
588
|
+
this.out.scaleY = sy;
|
|
589
|
+
this.out.rotation = Math.abs(this.lean) < 1e-4 ? 0 : this.lean;
|
|
590
|
+
this.out.offsetY = offsetY;
|
|
591
|
+
return this.out;
|
|
592
|
+
}
|
|
593
|
+
get current() {
|
|
594
|
+
return this.out;
|
|
595
|
+
}
|
|
596
|
+
/** Apply current `scaleX`, `scaleY`, and `rotation` multipliers onto a Stage `DisplayObject`. */
|
|
597
|
+
applyTo(target, baseScaleX = 1, baseScaleY = 1) {
|
|
598
|
+
target.scaleX = baseScaleX * this.out.scaleX;
|
|
599
|
+
target.scaleY = baseScaleY * this.out.scaleY;
|
|
600
|
+
target.rotation = this.out.rotation;
|
|
601
|
+
return this.out;
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
export { AmbientEmitterPool, FADE_EASE, FADE_FLICKER, FADE_LINEAR, FADE_PUNCH, FADE_SINE, FLAG_SIZE_POP, JuiceController, LocomotionFeel, PARTICLE_BUBBLE, PARTICLE_RECT, PARTICLE_SPARKLE, PARTICLE_WAKE, ParticlePool, drawParticlePool };
|
package/dist/projection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jn as SceneHostLike, On as DisplayObject, xn as Container } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export interface Camera25DConfig {
|
|
3
3
|
viewportWidth: number;
|
|
4
4
|
viewportHeight: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $t as
|
|
1
|
+
import { $t as WebGpuBootstrapResult, Qt as RequestWebGpuOptions, Xt as RendererWebGpu, Zt as RendererWebGpuOptions, an as HeadlessWebGpuOptions, cn as openDawnWebGpu, en as WebGpuCanvasContextLike, in as HeadlessWebGpuHandle, ln as openWgpuNativeFfi, nn as requestWebGpuDevice, on as OpenDawnWebGpuOptions, rn as HeadlessWebGpuBackend, sn as OpenWgpuNativeFfiOptions, tn as WebGpuDeviceLike, un as requestHeadlessWebGpu } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export { type HeadlessWebGpuBackend, type HeadlessWebGpuHandle, type HeadlessWebGpuOptions, type OpenDawnWebGpuOptions, type OpenWgpuNativeFfiOptions, RendererWebGpu, RendererWebGpuOptions, RequestWebGpuOptions, WebGpuBootstrapResult, WebGpuCanvasContextLike, WebGpuDeviceLike, openDawnWebGpu, openWgpuNativeFfi, requestHeadlessWebGpu, requestWebGpuDevice };
|
package/dist/rig2d.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { T as BlendMode } from "./anims-BOvaKn6w.js";
|
|
2
|
-
import {
|
|
2
|
+
import { In as Graphics, Jn as SceneHostLike, Ln as ImageObject, xn as Container } from "./game-Dxh9e0Hv.js";
|
|
3
3
|
export type RigCurveKind = 'linear' | 'step' | 'smoothstep' | 'outBack';
|
|
4
4
|
export interface RigBoneDef {
|
|
5
5
|
name: string;
|
package/dist/tilemap.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as unpackChunkX, Ct as createIslandBiomeGenerator, Dt as mountChunkedTilemap, Et as hash2D, Mt as valueNoise2D, Ot as packChunkKey, St as computeDualGridMask, Tt as floorDiv, _t as SurvivalBiomes, bt as bakeDualGridTileset, ct as BakeDualGridTilesetOptions, dt as ChunkedTilemap, ft as ChunkedTilemapOptions, gt as MountedChunkedTilemap, ht as MountChunkedTilemapOptions, jt as unpackChunkY, kt as positiveMod, lt as BakedDualGridAtlas, mt as IslandBiomeConfig, pt as DualGridLayerSpec, ut as ChunkGeneratorFn, vt as TileCellFlags, wt as fbm2D, xt as computeBlob47Index, yt as TileChunk } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export { BakeDualGridTilesetOptions, BakedDualGridAtlas, ChunkGeneratorFn, ChunkedTilemap, ChunkedTilemapOptions, DualGridLayerSpec, IslandBiomeConfig, MountChunkedTilemapOptions, MountedChunkedTilemap, SurvivalBiomes, TileCellFlags, TileChunk, bakeDualGridTileset, computeBlob47Index, computeDualGridMask, createIslandBiomeGenerator, fbm2D, floorDiv, hash2D, mountChunkedTilemap, packChunkKey, positiveMod, unpackChunkX, unpackChunkY, valueNoise2D };
|
package/dist/trace.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bt as SceneDigestSurfaceEntry, Ft as SceneDigestEngineSandbox, Ht as SceneDigestSurfaces, It as SceneDigestNode, Lt as SceneDigestOptions, Nt as SceneDigest, Pt as SceneDigestActiveFocus, Rt as SceneDigestOverlayStats, Ut as buildSceneDigest, Vt as SceneDigestSurfaceSource, Wt as sanitizeTrackToken, zt as SceneDigestSandbox } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export { SceneDigest, SceneDigestActiveFocus, SceneDigestEngineSandbox, SceneDigestNode, SceneDigestOptions, SceneDigestOverlayStats, SceneDigestSandbox, SceneDigestSurfaceEntry, SceneDigestSurfaceSource, SceneDigestSurfaces, buildSceneDigest, sanitizeTrackToken };
|
package/dist/world.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as WorldCatalogSpec, B as FrozenWorldCatalog, G as RecipeDef, H as ItemDef, J as WorkstationInstance, K as RecipeRegistry, Q as WorldCatalogRuntime, U as ItemRegistry, V as InventoryContainer, W as ItemStack, X as WorkstationScheduler, Y as WorkstationJob, Z as WorkstationSnapshot, at as decodeWorldDeltaBytes, et as WorldDeltaSnapshot, it as createWorldCatalogRuntime, nt as applyWorldDelta, ot as defineWorldCatalog, q as TileCellDelta, rt as captureWorldDelta, st as encodeWorldDeltaBytes, tt as WorldEntityRecord, z as CatalogReloadDiff } from "./game-Dxh9e0Hv.js";
|
|
2
2
|
export { CatalogReloadDiff, FrozenWorldCatalog, InventoryContainer, ItemDef, ItemRegistry, ItemStack, RecipeDef, RecipeRegistry, TileCellDelta, WorkstationInstance, WorkstationJob, WorkstationScheduler, WorkstationSnapshot, WorldCatalogRuntime, WorldCatalogSpec, WorldDeltaSnapshot, WorldEntityRecord, applyWorldDelta, captureWorldDelta, createWorldCatalogRuntime, decodeWorldDeltaBytes, defineWorldCatalog, encodeWorldDeltaBytes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holtjs/stage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Zero-dependency TypeScript stage engine for 2D WebGPU/WebGL2/Canvas2D games, GPU SDF UI, procedural audio, StageKernel plugins, tracing-native observability, and deterministic 60 FPS headless image & video rendering.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Botiverse, Inc.",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@holtjs/stage` Subpath API Quick Reference
|
|
2
2
|
|
|
3
|
-
All symbols verified against `src/*.ts` (`@holtjs/stage@0.
|
|
3
|
+
All symbols verified against `src/*.ts` (`@holtjs/stage@0.16.0`, 22 subpaths).
|
|
4
4
|
|
|
5
5
|
## `@holtjs/stage` (~71.3 kB gz · Core Engine Barrel)
|
|
6
6
|
- **Bootstrap & Lifecycle**: `Stage` / `Stage2D` (namespaces), `AUTO`, `WEBGPU`, `WEBGL`, `CANVAS`, `Scale` (`NONE`, `FIT`, `RESIZE`), `Scenes`, `Game` (`.stepSimOnly()`, `.kernel`, `.anims`), `Scene` (`.update()` simulation + `.preRender()` presentation, `.anims`), `SceneManager`, `ScaleManager` (`.fitToContainer()`), `GameLoop`, `EngineClock`, `LoaderPlugin` (`.atlas()`), `JsonCache`, `GameObjectFactory` (`scene.add.sprite`, `shapeBatch`, `instancedBatch`, `customPass`, `panel`, `blitter`, etc.), `AnimationManager` (`.create()`, `.createFromAtlas()`, `.generateFrameNames()`, `.generateFrameNumbers()`)
|
|
@@ -23,14 +23,15 @@ All symbols verified against `src/*.ts` (`@holtjs/stage@0.10.1`, 21 subpaths).
|
|
|
23
23
|
- `StageKernel` (`game.kernel`): `.use(plugin)`, `.remove(id)`, `.get(id)`, `.addInputProvider(p)`, `.actions`, `.digest()`
|
|
24
24
|
- `ActionMap`: `.bind(action, codes)`, `.unbind(action)`, `.isDown(action)`, `.justPressed(action)`, `.justReleased(action)`, `.axis(negAction, posAction)`
|
|
25
25
|
- `createInputTimeline(opts?)`: `.moveTo()`, `.click(trackIdOrPt, atMs, opts?)`, `.drag()`, `.pressKey()`, `.typeText()` (with optional rendered virtual cursor & click ripples via `showCursor: true`)
|
|
26
|
-
- `createInputRecorder(id?)`, `createInputReplay(entries, id?)`
|
|
27
|
-
- Types: `StagePlugin`, `InputProvider`, `StageInputEvent`, `InputTargetSpec`, `TimelineClickOptions`, `TimelineDragOptions`, `TimelineKeyOptions`, `InputTimelineOptions`, `InputTimelinePlugin`, `InputRecorderPlugin`, `RecordedInputEntry`
|
|
26
|
+
- `createInputRecorder(id?)`, `createInputReplay(entries, id?)`, `RollbackSession` (`.fromSoaWorld()`, `.advance()`, `.applyAuthoritativeInput()`, `.rewindTo()`, `.checksumAt()`), `createRollbackSession(opts)`
|
|
27
|
+
- Types: `StagePlugin`, `InputProvider`, `StageInputEvent`, `InputTargetSpec`, `TimelineClickOptions`, `TimelineDragOptions`, `TimelineKeyOptions`, `InputTimelineOptions`, `InputTimelinePlugin`, `InputRecorderPlugin`, `RecordedInputEntry`, `RollbackStateCodec`, `RollbackSessionOptions`, `RollbackResult`, `RollbackStats`
|
|
28
28
|
|
|
29
|
-
## `@holtjs/stage/headless` (~
|
|
30
|
-
- `createHeadlessStage(opts)`: `.step()`, `.stepToMs()`, `.stepToFrame()`, `.fastForward(frames)`, `.pointerDown/Move/Up()`, `.keyDown/Up()`, `.toRgba()`, `.
|
|
29
|
+
## `@holtjs/stage/headless` (~42 kB gz · Headless WebGPU, Canvas2D, Video & Batch Rollouts)
|
|
30
|
+
- `createHeadlessStageAsync(opts)` (`openHeadlessStage`), `createHeadlessStage(opts)`: `.step()`, `.stepToMs()`, `.stepToFrame()`, `.fastForward(frames)`, `.pointerDown/Move/Up()`, `.keyDown/Up()`, `.toRgba()`, `.toRgbaAsync()`, `.toPng()`, `.toPngAsync()`, `.encodeVideo(opts)`, `.digest()`, `.recordFrames({ ..., reuseFrameBuffer? })`
|
|
31
|
+
- `runHeadlessRollouts(opts)` -> `HeadlessRolloutReport` (`summary` with `min / max / mean / p50 / p95 / sum`, `ticksPerSecond`, `results`)
|
|
31
32
|
- `renderStoryboard(stage, opts)` -> `{ png, width, height, digests }`
|
|
32
33
|
- `createAudioTimeline(opts?)`: `.addAtMs()`, `.addAtFrame()`, `.toStereoPcm16()`, `.toWav()`
|
|
33
|
-
- Types: `HeadlessCanvasLike`, `CreateHeadlessCanvas`, `HeadlessStageOptions`, `HeadlessRecordedFrame`, `RecordFramesOptions`, `HeadlessStage`, `StoryboardOptions`, `StoryboardResult`, `AudioCueOptions`, `AudioTimelineOptions`, `AudioTimeline`
|
|
34
|
+
- Types: `HeadlessCanvasLike`, `CreateHeadlessCanvas`, `HeadlessStageOptions`, `AsyncHeadlessStageOptions`, `HeadlessRecordedFrame`, `RecordFramesOptions`, `HeadlessStage`, `StoryboardOptions`, `StoryboardResult`, `AudioCueOptions`, `AudioTimelineOptions`, `AudioTimeline`, `EncodeVideoWithFfmpegOptions`, `EncodeVideoResult`, `HeadlessRolloutOptions`, `HeadlessRolloutReport`, `MetricSummaryStats`
|
|
34
35
|
|
|
35
36
|
## `@holtjs/stage/rig2d` (~5.7 kB gz · zero DOM)
|
|
36
37
|
- Skeleton & Mixer: `defineRig2DSkeleton(def)`, `Rig2DInstance` (`.play(clip, opts?)`, `.playOverlay(clip, { maskBones?, loop? })`, `.clearOverlay()`, `.setAttachment(slot, attachment)`, `.applySkin(skinNameOrMap)`, `.setSlotTint()`, `.setBoneManualOffset()`, `.onEvent(fn)`, `.step(deltaMs)`, `.getBoneWorldTransform(bone, out?)`)
|
|
@@ -84,11 +85,11 @@ All symbols verified against `src/*.ts` (`@holtjs/stage@0.10.1`, 21 subpaths).
|
|
|
84
85
|
## `@holtjs/stage/nav` (~2.3 kB gz · zero DOM)
|
|
85
86
|
- `FlowFieldGrid`, `buildCircleObstacleGrid`, `buildTileWalkGrid`, `computeFlowField`, `isFlowLineClear`, `sampleFlowStep`, `hasGridLineOfSight`, `findGridPath`, `steerToward`
|
|
86
87
|
|
|
87
|
-
## `@holtjs/stage/particles` (~3.
|
|
88
|
-
- `ParticlePool`, `drawParticlePool`, `AmbientEmitterPool`, `JuiceController`, `PARTICLE_RECT`, `PARTICLE_SPARKLE`, `PARTICLE_BUBBLE`, `PARTICLE_WAKE`, `FADE_PUNCH`, `FADE_SINE`, `FADE_FLICKER`, `FADE_EASE`, `FADE_LINEAR`, `FLAG_SIZE_POP`
|
|
88
|
+
## `@holtjs/stage/particles` (~3.6 kB gz · zero DOM)
|
|
89
|
+
- `ParticlePool`, `drawParticlePool`, `AmbientEmitterPool`, `JuiceController`, `LocomotionFeel` (`.impulse()`, `.step()`, `.applyTo()`), `PARTICLE_RECT`, `PARTICLE_SPARKLE`, `PARTICLE_BUBBLE`, `PARTICLE_WAKE`, `FADE_PUNCH`, `FADE_SINE`, `FADE_FLICKER`, `FADE_EASE`, `FADE_LINEAR`, `FLAG_SIZE_POP`
|
|
89
90
|
|
|
90
91
|
## `@holtjs/stage/audio` (~4.0 kB gz · zero DOM)
|
|
91
92
|
- `renderFoley`, `renderFoleyVariants`, `createVariantPicker`, `buildSwimStrokeFoley`, `buildDiveInFoley`, `buildClimbOutFoley`, `buildStepWoodFoley`, `buildStepGrassFoley`, `buildStepSandFoley`, `buildStepStoneFoley`, `buildStepSoftFoley`, `midi`, `noteNum`, `hz`, `synthVoice`, `tune`, `renderVoices`, `spatialMix`, `encodeWavPcm16`
|
|
92
93
|
|
|
93
|
-
## `@holtjs/stage/ecs` (~
|
|
94
|
-
- `SoaWorld`, `defineComponent`, `entityIndex`, `entityGeneration`, `sortSlotsByDepth`, `cullAndSortSlots`, `partitionDepthBands`
|
|
94
|
+
## `@holtjs/stage/ecs` (~4.5 kB gz · zero DOM)
|
|
95
|
+
- `SoaWorld` (`.snapshot()`, `.restore()`, `.checksum()`, `.select()`), `defineComponent`, `defineTag`, `defineEvent`, `entityIndex`, `entityGeneration`, `sortSlotsByDepth`, `cullAndSortSlots`, `partitionDepthBands`
|