@holtjs/stage 0.10.3 → 0.12.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 +27 -0
- package/dist/{anims-D9N8w6IM.d.ts → anims-BYBzSNXO.d.ts} +8 -0
- package/dist/anims.d.ts +1 -1
- package/dist/coroutine-DLgJumtD.d.ts +73 -0
- package/dist/coroutine.d.ts +2 -0
- package/dist/coroutine.js +322 -0
- package/dist/{display-DU4edtH-.js → display-CuyQc8oE.js} +223 -1
- package/dist/ecs.d.ts +87 -6
- package/dist/ecs.js +172 -6
- package/dist/flex.d.ts +185 -1
- package/dist/flex.js +353 -1
- package/dist/{game-CytDvQt9.d.ts → game-CT_WCPjJ.d.ts} +595 -4
- package/dist/{game-D-rfAnoA.js → game-DZoRjZNH.js} +60 -3
- package/dist/headless.d.ts +14 -3
- package/dist/headless.js +64 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +6 -5
- package/dist/joystick.d.ts +1 -1
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +15 -1
- package/dist/lighting.d.ts +1 -1
- package/dist/lighting.js +1 -1
- package/dist/projection.d.ts +1 -1
- package/dist/{renderer-webgpu-CHJxmCvR.js → renderer-webgpu-B8vktrUk.js} +1710 -22
- package/dist/renderer-webgpu.d.ts +2 -2
- package/dist/renderer-webgpu.js +1 -1
- package/dist/rig2d.d.ts +2 -2
- package/dist/tilemap.d.ts +2 -169
- package/dist/trace.d.ts +1 -1
- package/dist/world.d.ts +2 -183
- package/dist/world.js +140 -1
- package/package.json +5 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-
|
|
1
|
+
import { I as ScaleMode, M as Matrix2D, N as Rect2D, O as EventEmitter, P as RgbaColor, R as TintMode, S as TextureSource, T as BlendMode, U as WorldView2D, _ as SpriteSheetConfig, d as AtlasJsonLike, g as GlTextureHost, p as Frame, r as AnimationManager, u as StageAnimation, v as Texture, x as TextureManager, y as TextureImageOptions } from "./anims-BYBzSNXO.js";
|
|
2
2
|
import { c as TweenManager, u as TweenStats } from "./tween-BiF1FUvc.js";
|
|
3
|
+
import { a as ScriptOptions, i as ScriptHandle, o as ScriptScheduler, r as ScriptContext, s as ScriptStats, t as CoroutineGenerator } from "./coroutine-DLgJumtD.js";
|
|
3
4
|
interface CameraFollowOptions {
|
|
4
5
|
/** Horizontal smoothing factor in `(0, 1]` (`1` = instant lock; default `1`). */
|
|
5
6
|
lerpX?: number;
|
|
@@ -930,6 +931,80 @@ declare class ShapeBatchObject extends DisplayObject {
|
|
|
930
931
|
setColumns(columns: ShapeBatchColumns): this;
|
|
931
932
|
destroy(fromScene?: boolean): void;
|
|
932
933
|
}
|
|
934
|
+
interface DrawStreamOptions {
|
|
935
|
+
/** Initial sprite instance capacity (`default = 256`, doubles automatically on demand). */
|
|
936
|
+
initialCapacity?: number;
|
|
937
|
+
/** Default frame when `sprite()` passes `undefined` (`default = '__BASE'`). */
|
|
938
|
+
defaultFrame?: string | number;
|
|
939
|
+
/** Automatically reset `count = 0` on scene `'preupdate'` each tick (`default = true`). */
|
|
940
|
+
autoReset?: boolean;
|
|
941
|
+
/** Automatically sort emitted instances by `depth` (ascending painter's order) before render (`default = false`). */
|
|
942
|
+
depthSort?: boolean;
|
|
943
|
+
/** Scene-graph depth of this `DrawStreamObject`. */
|
|
944
|
+
depth?: number;
|
|
945
|
+
/** Optional blend mode (`BlendModes.NORMAL`, `ADD`, `MULTIPLY`, `SCREEN`). */
|
|
946
|
+
blendMode?: BlendMode;
|
|
947
|
+
/** Scroll factor (`default = 1` world space; `0` screen/HUD space). */
|
|
948
|
+
scrollFactor?: number;
|
|
949
|
+
/** Optional logical stream key when acquired via `scene.drawStream(textureKey, opts)`. */
|
|
950
|
+
streamId?: string;
|
|
951
|
+
}
|
|
952
|
+
interface DrawStreamSpriteOptions {
|
|
953
|
+
scale?: number;
|
|
954
|
+
scaleX?: number;
|
|
955
|
+
scaleY?: number;
|
|
956
|
+
rotation?: number;
|
|
957
|
+
alpha?: number;
|
|
958
|
+
tint?: number;
|
|
959
|
+
depth?: number;
|
|
960
|
+
}
|
|
961
|
+
interface DrawStreamBulkView {
|
|
962
|
+
readonly x: Float32Array;
|
|
963
|
+
readonly y: Float32Array;
|
|
964
|
+
readonly scaleX: Float32Array;
|
|
965
|
+
readonly scaleY: Float32Array;
|
|
966
|
+
readonly rotation: Float32Array;
|
|
967
|
+
readonly alpha: Float32Array;
|
|
968
|
+
readonly tint: Uint32Array;
|
|
969
|
+
readonly frameIndex: Int32Array;
|
|
970
|
+
readonly depth: Float32Array;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Stateless per-frame immediate-mode sprite batch (`scene.drawStream(textureKey)` or `scene.add.drawStream(...)`).
|
|
974
|
+
* Submits thousands of transient drops, projectiles, grass tufts, or minimap markers in 1 GPU instanced draw call
|
|
975
|
+
* across WebGPU, WebGL2, and Canvas2D with zero retained `DisplayObject` allocations!
|
|
976
|
+
*/
|
|
977
|
+
declare class DrawStreamObject extends InstancedBatchObject {
|
|
978
|
+
autoReset: boolean;
|
|
979
|
+
depthSort: boolean;
|
|
980
|
+
private cap;
|
|
981
|
+
private curCount;
|
|
982
|
+
private depthDirty;
|
|
983
|
+
private colX;
|
|
984
|
+
private colY;
|
|
985
|
+
private colSx;
|
|
986
|
+
private colSy;
|
|
987
|
+
private colRot;
|
|
988
|
+
private colAlpha;
|
|
989
|
+
private colTint;
|
|
990
|
+
private colFrame;
|
|
991
|
+
private colDepth;
|
|
992
|
+
private colOrder;
|
|
993
|
+
private readonly liveColumns;
|
|
994
|
+
private readonly detachEvents;
|
|
995
|
+
constructor(scene: SceneHostLike, key: string, options?: DrawStreamOptions);
|
|
996
|
+
get count(): number;
|
|
997
|
+
/** Reset write cursor to `0` for a fresh frame (zero memory freed or allocated). */
|
|
998
|
+
begin(): this;
|
|
999
|
+
private ensureStreamCapacity;
|
|
1000
|
+
/** Append a single sprite command in O(1) zero-GC typed-array writes; returns emitted instance index. */
|
|
1001
|
+
sprite(frame: string | number | undefined, x: number, y: number, opts?: DrawStreamSpriteOptions): number;
|
|
1002
|
+
/** Reserve `count` contiguous instance slots for bulk SIMD / Worker `TypedArray.set()` fills! */
|
|
1003
|
+
writeBulk(count: number, writer: (cols: DrawStreamBulkView, offset: number) => void): number;
|
|
1004
|
+
/** Materialize ascending `depth` painter's order in `columns.order` when `depthSort: true`. */
|
|
1005
|
+
flushOrder(): void;
|
|
1006
|
+
destroy(fromScene?: boolean): void;
|
|
1007
|
+
}
|
|
933
1008
|
interface RendererGlOptions {
|
|
934
1009
|
transparent?: boolean;
|
|
935
1010
|
antialias?: boolean;
|
|
@@ -1184,10 +1259,76 @@ declare class Renderer2D extends EventEmitter {
|
|
|
1184
1259
|
render(displayList: DisplayList, camera: Camera): void;
|
|
1185
1260
|
destroy(): void;
|
|
1186
1261
|
}
|
|
1262
|
+
type HeadlessWebGpuBackend = 'wgpu-bun-ffi' | 'wgpu-node-koffi' | 'dawn' | 'navigator';
|
|
1263
|
+
interface HeadlessWebGpuHandle {
|
|
1264
|
+
readonly backend: HeadlessWebGpuBackend;
|
|
1265
|
+
readonly device: WebGpuDeviceLike;
|
|
1266
|
+
readonly format: 'rgba8unorm' | 'bgra8unorm';
|
|
1267
|
+
/** `true` when `stage.toRgba()` / `renderer.readPixelsSync()` works synchronously without `await` (`wgpu-native` FFI). */
|
|
1268
|
+
readonly supportsSyncReadback: boolean;
|
|
1269
|
+
/** Release native `GPUDevice` / `WGPUInstance` resources. */
|
|
1270
|
+
destroy(): void;
|
|
1271
|
+
}
|
|
1272
|
+
interface OpenWgpuNativeFfiOptions {
|
|
1273
|
+
/**
|
|
1274
|
+
* Path to `libwgpu_native.so` (Linux), `libwgpu_native.dylib` (macOS), or `wgpu_native.dll` (Windows).
|
|
1275
|
+
* Defaults to `process.env.STAGE_WGPU_LIB` or `process.env.WGPU_NATIVE_LIB`, then standard system/local paths.
|
|
1276
|
+
*/
|
|
1277
|
+
readonly libPath?: string;
|
|
1278
|
+
/** FFI engine selection (`'auto'` uses built-in `'bun:ffi'` on Bun and `'koffi'` on Node.js). */
|
|
1279
|
+
readonly runtime?: 'auto' | 'bun' | 'koffi';
|
|
1280
|
+
/** Optional pre-loaded `koffi` module instance on Node.js. */
|
|
1281
|
+
readonly koffiModule?: any;
|
|
1282
|
+
/** Adapter power profile (default `'high-performance'`). */
|
|
1283
|
+
readonly powerPreference?: 'low-power' | 'high-performance';
|
|
1284
|
+
}
|
|
1285
|
+
interface OpenDawnWebGpuOptions {
|
|
1286
|
+
/** Optional pre-loaded `'webgpu'` (Google Dawn N-API) module. */
|
|
1287
|
+
readonly dawnModule?: any;
|
|
1288
|
+
/** Optional Dawn instance flags passed to `dawn.create([...])` (default `[]`). */
|
|
1289
|
+
readonly dawnFlags?: readonly string[];
|
|
1290
|
+
/** Adapter power profile (default `'high-performance'`). */
|
|
1291
|
+
readonly powerPreference?: 'low-power' | 'high-performance';
|
|
1292
|
+
}
|
|
1293
|
+
interface HeadlessWebGpuOptions extends OpenWgpuNativeFfiOptions, OpenDawnWebGpuOptions {
|
|
1294
|
+
/** Backend discovery strategy (`'auto'` tries `wgpu-native` FFI -> Google Dawn `'webgpu'` -> `navigator.gpu`). */
|
|
1295
|
+
readonly backend?: 'auto' | 'ffi' | 'dawn' | 'navigator';
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Open a synchronous native Headless WebGPU `GPUDevice` via `wgpu-native` (`libwgpu_native.so`/`.dylib`/`.dll`)
|
|
1299
|
+
* using Bun's built-in `bun:ffi` or Node.js's prebuilt `koffi` C FFI.
|
|
1300
|
+
* Returns `null` cleanly if `libwgpu_native` or the FFI driver is unavailable.
|
|
1301
|
+
*/
|
|
1302
|
+
declare function openWgpuNativeFfi(options?: OpenWgpuNativeFfiOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Open a native Headless WebGPU `GPUDevice` via Google Dawn's prebuilt N-API `'webgpu'` package
|
|
1305
|
+
* (works identically in both Node.js and Bun!).
|
|
1306
|
+
* Returns `null` cleanly if `'webgpu'` is not installed or no Vulkan/Metal/D3D12 adapter is available.
|
|
1307
|
+
*/
|
|
1308
|
+
declare function openDawnWebGpu(options?: OpenDawnWebGpuOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Acquire an isomorphic Headless WebGPU device across Bun (`bun:ffi` + `wgpu-native` or Dawn `webgpu`),
|
|
1311
|
+
* Node.js (`koffi` + `wgpu-native` or Dawn `webgpu`), and Deno / Browser (`navigator.gpu`).
|
|
1312
|
+
* Never throws when native drivers are absent — returns `null` so callers can cleanly fall back to Canvas2D.
|
|
1313
|
+
*/
|
|
1314
|
+
declare function requestHeadlessWebGpu(options?: HeadlessWebGpuOptions): Promise<HeadlessWebGpuHandle | null>;
|
|
1187
1315
|
interface WebGpuDeviceLike {
|
|
1188
1316
|
readonly queue: {
|
|
1189
1317
|
writeBuffer(buffer: any, bufferOffset: number, data: BufferSource, dataOffset?: number, size?: number): void;
|
|
1190
|
-
copyExternalImageToTexture(source: any, destination: any, copySize: any): void;
|
|
1318
|
+
copyExternalImageToTexture?(source: any, destination: any, copySize: any): void;
|
|
1319
|
+
writeTexture?(destination: {
|
|
1320
|
+
texture: any;
|
|
1321
|
+
mipLevel?: number;
|
|
1322
|
+
origin?: [number, number, number];
|
|
1323
|
+
}, data: BufferSource, dataLayout: {
|
|
1324
|
+
offset?: number;
|
|
1325
|
+
bytesPerRow: number;
|
|
1326
|
+
rowsPerImage?: number;
|
|
1327
|
+
}, size: [number, number, number] | {
|
|
1328
|
+
width: number;
|
|
1329
|
+
height: number;
|
|
1330
|
+
depthOrArrayLayers?: number;
|
|
1331
|
+
}): void;
|
|
1191
1332
|
submit(commandBuffers: any[]): void;
|
|
1192
1333
|
};
|
|
1193
1334
|
createShaderModule(descriptor: {
|
|
@@ -1205,6 +1346,8 @@ interface WebGpuDeviceLike {
|
|
|
1205
1346
|
createRenderPipeline(descriptor: any): any;
|
|
1206
1347
|
createBindGroup(descriptor: any): any;
|
|
1207
1348
|
createCommandEncoder(descriptor?: any): any;
|
|
1349
|
+
/** Optional synchronous staging-buffer read hook provided by `wgpu-native` C FFI (`bun:ffi` / `koffi`). */
|
|
1350
|
+
_readBufferSync?(buffer: any, dst: Uint8Array, byteLength: number): boolean;
|
|
1208
1351
|
destroy?(): void;
|
|
1209
1352
|
}
|
|
1210
1353
|
interface WebGpuCanvasContextLike {
|
|
@@ -1247,10 +1390,20 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1247
1390
|
readonly maxTextures = 16;
|
|
1248
1391
|
readonly canvas: HTMLCanvasElement;
|
|
1249
1392
|
readonly device: WebGpuDeviceLike;
|
|
1250
|
-
readonly gpuContext: WebGpuCanvasContextLike;
|
|
1393
|
+
readonly gpuContext: WebGpuCanvasContextLike | null;
|
|
1251
1394
|
readonly format: string;
|
|
1252
1395
|
width: number;
|
|
1253
1396
|
height: number;
|
|
1397
|
+
private offscreenTex;
|
|
1398
|
+
private offscreenView;
|
|
1399
|
+
private offscreenW;
|
|
1400
|
+
private offscreenH;
|
|
1401
|
+
private readbackBuf;
|
|
1402
|
+
private readbackCap;
|
|
1403
|
+
private readbackBytesPerRow;
|
|
1404
|
+
private uploadStaging;
|
|
1405
|
+
private uploadScratchCanvas;
|
|
1406
|
+
private uploadScratchCtx;
|
|
1254
1407
|
private readonly globalsBuf;
|
|
1255
1408
|
private readonly vbo;
|
|
1256
1409
|
private readonly ibo;
|
|
@@ -1290,6 +1443,8 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1290
1443
|
private makeBatchBindGroup;
|
|
1291
1444
|
stats(): RendererStats;
|
|
1292
1445
|
resize(width: number, height: number): void;
|
|
1446
|
+
private ensureOffscreenTarget;
|
|
1447
|
+
private extractAndUploadTexture;
|
|
1293
1448
|
private ensureGpuTexture;
|
|
1294
1449
|
private ensureSourceBindGroup;
|
|
1295
1450
|
private currentScissor;
|
|
@@ -1304,6 +1459,18 @@ declare class RendererWebGpu extends EventEmitter {
|
|
|
1304
1459
|
private renderGraphics;
|
|
1305
1460
|
private renderNode;
|
|
1306
1461
|
render(displayList: DisplayList, camera: Camera): void;
|
|
1462
|
+
private encodeCopyToStaging;
|
|
1463
|
+
private unpackStagingBytes;
|
|
1464
|
+
/**
|
|
1465
|
+
* Synchronously read rendered W3C `RGBA8888` pixels when backed by a synchronous native WebGPU device
|
|
1466
|
+
* (`wgpu-native` C FFI via `bun:ffi` or Node `koffi`).
|
|
1467
|
+
*/
|
|
1468
|
+
readPixelsSync(out?: Uint8Array): Uint8Array;
|
|
1469
|
+
/**
|
|
1470
|
+
* Asynchronously read rendered W3C `RGBA8888` pixels across ALL WebGPU backends
|
|
1471
|
+
* (`wgpu-native` FFI, Google Dawn `webgpu`, Deno `navigator.gpu`, and Browser WebGPU).
|
|
1472
|
+
*/
|
|
1473
|
+
readPixelsAsync(out?: Uint8Array): Promise<Uint8Array>;
|
|
1307
1474
|
/** Create an offscreen render target backed by a registered Stage `Texture` (`key`) for WebGPU passes (e.g. `Lighting2DSystem`). */
|
|
1308
1475
|
createRenderTarget(key: string, width: number, height: number, textures: TextureManager, filterMode?: 0 | 1): StageRenderTarget;
|
|
1309
1476
|
/** Render a `DisplayList` (or callback) into an offscreen `StageRenderTarget` and mark its texture dirty for WebGPU upload (`camera` defaults to `target.camera`). */
|
|
@@ -1545,6 +1712,411 @@ declare function sanitizeTrackToken(raw: unknown, maxLen?: number): string | nul
|
|
|
1545
1712
|
* tokens and explicitly declared semantic `alt` labels.
|
|
1546
1713
|
*/
|
|
1547
1714
|
declare function buildSceneDigest(scene: Scene, opts?: SceneDigestOptions): SceneDigest;
|
|
1715
|
+
/** Pack signed 16-bit chunk coordinates `[-32768..32767]` into a single 32-bit integer Map key (zero string allocation). */
|
|
1716
|
+
declare function packChunkKey(cx: number, cy: number): number;
|
|
1717
|
+
declare function unpackChunkX(key: number): number;
|
|
1718
|
+
declare function unpackChunkY(key: number): number;
|
|
1719
|
+
declare function floorDiv(a: number, b: number): number;
|
|
1720
|
+
declare function positiveMod(a: number, b: number): number;
|
|
1721
|
+
/**
|
|
1722
|
+
* Compute Oskar Stålberg's 4-bit **Dual-Grid** mask (`0..15`) for visual vertex `(vx, vy)`,
|
|
1723
|
+
* which sits at world `(vx * tileSize - tileSize * 0.5, vy * tileSize - tileSize * 0.5)` and samples
|
|
1724
|
+
* the 4 surrounding logical cells `(vx-1, vy-1)`, `(vx, vy-1)`, `(vx-1, vy)`, `(vx, vy)`.
|
|
1725
|
+
*
|
|
1726
|
+
* Bit layout: `TL (8) | TR (4) | BL (2) | BR (1)`.
|
|
1727
|
+
* - `0` = completely empty (do not draw this overlay layer)
|
|
1728
|
+
* - `15` = solid interior fill
|
|
1729
|
+
* - `1..14` = 14 organic rounded corners, edges, and diagonal saddles (`6` and `9`)
|
|
1730
|
+
*/
|
|
1731
|
+
declare function computeDualGridMask(tl: boolean, tr: boolean, bl: boolean, br: boolean): number;
|
|
1732
|
+
/**
|
|
1733
|
+
* Compute the canonical **47-tile Blob** index (`0..46`) from 8 neighbors (`n, ne, e, se, s, sw, w, nw`).
|
|
1734
|
+
* Diagonal bits are automatically gated by their two adjacent cardinal neighbors so invalid corner combinations collapse cleanly.
|
|
1735
|
+
*/
|
|
1736
|
+
declare function computeBlob47Index(n: boolean, ne: boolean, e: boolean, se: boolean, s: boolean, sw: boolean, w: boolean, nw: boolean): number;
|
|
1737
|
+
interface TileChunk {
|
|
1738
|
+
readonly cx: number;
|
|
1739
|
+
readonly cy: number;
|
|
1740
|
+
readonly size: number;
|
|
1741
|
+
/** Primary ground turf ID per cell (`Uint16Array(size * size)`). */
|
|
1742
|
+
readonly ground: Uint16Array;
|
|
1743
|
+
/** Optional wall / road / overlay ID per cell (`Uint16Array(size * size)`). */
|
|
1744
|
+
readonly overlay: Uint16Array;
|
|
1745
|
+
/** Per-cell bitflags (`bit 0 = solid/blocked`, `bit 1 = water`, `bit 2 = modifiedByPlayer`). */
|
|
1746
|
+
readonly flags: Uint8Array;
|
|
1747
|
+
/** Monotonic revision incremented whenever this chunk or a 1-tile neighbor mutates. */
|
|
1748
|
+
version: number;
|
|
1749
|
+
/** True if player/world simulation mutated at least one cell away from procedural baseline. */
|
|
1750
|
+
modified: boolean;
|
|
1751
|
+
}
|
|
1752
|
+
declare const TileCellFlags: {
|
|
1753
|
+
readonly NONE: 0;
|
|
1754
|
+
readonly SOLID: 1;
|
|
1755
|
+
readonly WATER: 2;
|
|
1756
|
+
readonly MODIFIED: 4;
|
|
1757
|
+
};
|
|
1758
|
+
type ChunkGeneratorFn = (cx: number, cy: number, chunk: TileChunk) => void;
|
|
1759
|
+
interface ChunkedTilemapOptions {
|
|
1760
|
+
chunkSize?: number;
|
|
1761
|
+
tileSize?: number;
|
|
1762
|
+
defaultGround?: number;
|
|
1763
|
+
generator?: ChunkGeneratorFn;
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* Sparse chunked 2D world grid supporting massive/infinite survival worlds (`+/-1,000,000` cells)
|
|
1767
|
+
* with lazy procedural chunk creation, cross-border autotile dirty propagation, and O(1) nav collision queries.
|
|
1768
|
+
*/
|
|
1769
|
+
declare class ChunkedTilemap {
|
|
1770
|
+
readonly chunkSize: number;
|
|
1771
|
+
readonly tileSize: number;
|
|
1772
|
+
readonly defaultGround: number;
|
|
1773
|
+
private readonly chunks;
|
|
1774
|
+
private generator;
|
|
1775
|
+
private globalRevision;
|
|
1776
|
+
constructor(opts?: ChunkedTilemapOptions);
|
|
1777
|
+
get loadedChunkCount(): number;
|
|
1778
|
+
get revision(): number;
|
|
1779
|
+
setGenerator(gen: ChunkGeneratorFn | undefined): void;
|
|
1780
|
+
hasChunk(cx: number, cy: number): boolean;
|
|
1781
|
+
peekChunk(cx: number, cy: number): TileChunk | undefined;
|
|
1782
|
+
getOrCreateChunk(cx: number, cy: number): TileChunk;
|
|
1783
|
+
/** Iterate over all currently materialized chunks without copying. */
|
|
1784
|
+
forEachChunk(fn: (chunk: TileChunk) => void): void;
|
|
1785
|
+
unloadChunk(cx: number, cy: number): boolean;
|
|
1786
|
+
worldToTileX(wx: number): number;
|
|
1787
|
+
worldToTileY(wy: number): number;
|
|
1788
|
+
tileToWorldCenter(tx: number, ty: number, out?: {
|
|
1789
|
+
x: number;
|
|
1790
|
+
y: number;
|
|
1791
|
+
}): {
|
|
1792
|
+
x: number;
|
|
1793
|
+
y: number;
|
|
1794
|
+
};
|
|
1795
|
+
getGround(tx: number, ty: number, createIfMissing?: boolean): number;
|
|
1796
|
+
setGround(tx: number, ty: number, turfId: number, markModified?: boolean): void;
|
|
1797
|
+
getOverlay(tx: number, ty: number, createIfMissing?: boolean): number;
|
|
1798
|
+
setOverlay(tx: number, ty: number, overlayId: number, solid?: boolean, markModified?: boolean): void;
|
|
1799
|
+
getFlags(tx: number, ty: number, createIfMissing?: boolean): number;
|
|
1800
|
+
setSolid(tx: number, ty: number, solid: boolean, markModified?: boolean): void;
|
|
1801
|
+
isWalkable(tx: number, ty: number, createIfMissing?: boolean): boolean;
|
|
1802
|
+
/** Sample the 4-bit Dual-Grid mask (`0..15`) for visual vertex `(vx, vy)` matching `predicate(turfId)`. */
|
|
1803
|
+
sampleDualGridMask(vx: number, vy: number, predicate: (turfId: number) => boolean): number;
|
|
1804
|
+
/** Sample the canonical 47-tile Blob index (`0..46`) at `(tx, ty)` for wall/cliff `overlayId`. */
|
|
1805
|
+
sampleOverlayBlob47(tx: number, ty: number, predicate: (overlayId: number) => boolean): number;
|
|
1806
|
+
/**
|
|
1807
|
+
* Extract a dense `Uint8Array` obstacle grid (`1 = blocked, 0 = walkable`) over `[originTx..originTx+cols-1, originTy..originTy+rows-1]`
|
|
1808
|
+
* ready to feed directly into `FlowFieldGrid` or `findGridPath` (`@holtjs/stage/nav`).
|
|
1809
|
+
*/
|
|
1810
|
+
extractObstacleGrid(originTx: number, originTy: number, cols: number, rows: number, out?: Uint8Array): Uint8Array;
|
|
1811
|
+
private bumpChunkAndBorderNeighbors;
|
|
1812
|
+
}
|
|
1813
|
+
declare function hash2D(ix: number, iy: number, seed: number): number;
|
|
1814
|
+
declare function valueNoise2D(x: number, y: number, seed: number): number;
|
|
1815
|
+
declare function fbm2D(x: number, y: number, seed: number, octaves?: number): number;
|
|
1816
|
+
declare const SurvivalBiomes: {
|
|
1817
|
+
readonly OCEAN: 0;
|
|
1818
|
+
readonly BEACH: 1;
|
|
1819
|
+
readonly MEADOW: 2;
|
|
1820
|
+
readonly FOREST: 3;
|
|
1821
|
+
readonly GRAVEYARD_STONE: 4;
|
|
1822
|
+
readonly COBBLESTONE_ROAD: 5;
|
|
1823
|
+
};
|
|
1824
|
+
interface IslandBiomeConfig {
|
|
1825
|
+
seed: number;
|
|
1826
|
+
radiusTiles?: number;
|
|
1827
|
+
featureScale?: number;
|
|
1828
|
+
}
|
|
1829
|
+
/** Build a deterministic *Don't Starve* / *Graveyard Keeper* island chunk generator from a single integer seed. */
|
|
1830
|
+
declare function createIslandBiomeGenerator(cfg: IslandBiomeConfig): ChunkGeneratorFn;
|
|
1831
|
+
interface DualGridLayerSpec {
|
|
1832
|
+
id: string;
|
|
1833
|
+
fillColor: number;
|
|
1834
|
+
edgeColor: number;
|
|
1835
|
+
speckleColor?: number;
|
|
1836
|
+
/** Returns true when a ground `turfId` belongs to (or sits above) this Dual-Grid terrain layer. */
|
|
1837
|
+
matches: (turfId: number) => boolean;
|
|
1838
|
+
}
|
|
1839
|
+
interface BakedDualGridAtlas {
|
|
1840
|
+
readonly textureKey: string;
|
|
1841
|
+
readonly tileSize: number;
|
|
1842
|
+
readonly canvas: HTMLCanvasElement;
|
|
1843
|
+
readonly layers: ReadonlyArray<DualGridLayerSpec>;
|
|
1844
|
+
frameName(layerId: string, mask: number): string;
|
|
1845
|
+
registerOnScene(scene: SceneHostLike): void;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Bake one or more 16-tile (`0..15`) organic Dual-Grid terrain layers onto a single crisp texture atlas!
|
|
1849
|
+
* Uses smooth analytical quarter-circle / saddle SDF distance fields per pixel so beaches, grass, dark forest,
|
|
1850
|
+
* and cobblestone roads interlock with hand-crafted *Don't Starve* turf borders.
|
|
1851
|
+
*/
|
|
1852
|
+
declare function bakeDualGridTileset(textureKey: string, tileSize: number, layers: DualGridLayerSpec[], createCanvasFn?: (w: number, h: number) => HTMLCanvasElement): BakedDualGridAtlas;
|
|
1853
|
+
interface MountedChunkedTilemap {
|
|
1854
|
+
readonly container: Container;
|
|
1855
|
+
readonly blitters: ReadonlyArray<BlitterObject>;
|
|
1856
|
+
/** Update visible chunks around `(viewLeft, viewTop, viewWidth, viewHeight)` in world pixels (O(visibleChunks)). */
|
|
1857
|
+
syncViewport(viewLeft: number, viewTop: number, viewWidth: number, viewHeight: number): void;
|
|
1858
|
+
/** Convenience alias accepting `Camera25D.getGroundViewportBounds()` (`{ left, top, width, height }`) directly. */
|
|
1859
|
+
update(bounds: {
|
|
1860
|
+
left: number;
|
|
1861
|
+
top: number;
|
|
1862
|
+
width: number;
|
|
1863
|
+
height: number;
|
|
1864
|
+
}): void;
|
|
1865
|
+
readonly activeChunkCount: number;
|
|
1866
|
+
readonly activeBobCount: number;
|
|
1867
|
+
destroy(): void;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Mount a `ChunkedTilemap` + `BakedDualGridAtlas` onto a Stage `Scene`.
|
|
1871
|
+
* - On WebGL2 / WebGPU: batches into 1 GPU `BlitterObject` draw call per Dual-Grid layer.
|
|
1872
|
+
* - On Canvas2D / pure-Node `createHeadlessStage`: automatically pre-composites all Dual-Grid layers of each
|
|
1873
|
+
* `16×16` chunk onto a cached offscreen chunk canvas keyed by `chunk.version` (collapsing ~4,500 per-frame
|
|
1874
|
+
* rotated tile `drawImage` calls down to ~12 chunk blits — >10× faster 60 FPS headless video rendering!).
|
|
1875
|
+
*/
|
|
1876
|
+
declare function mountChunkedTilemap(scene: SceneHostLike, map: ChunkedTilemap, atlas: BakedDualGridAtlas, opts?: {
|
|
1877
|
+
baseColor?: number;
|
|
1878
|
+
depth?: number;
|
|
1879
|
+
marginChunks?: number;
|
|
1880
|
+
trackId?: string;
|
|
1881
|
+
chunkCache?: boolean;
|
|
1882
|
+
}): MountedChunkedTilemap;
|
|
1883
|
+
interface ItemDef {
|
|
1884
|
+
id: string;
|
|
1885
|
+
name?: string;
|
|
1886
|
+
maxStack?: number;
|
|
1887
|
+
/** Time in ms until `freshness01` decays from `1.0` to `0.0` (`undefined` = non-perishable). */
|
|
1888
|
+
spoilDurationMs?: number;
|
|
1889
|
+
/** Item ID produced when `freshness01` hits `0` (`default = 'rot'`). */
|
|
1890
|
+
spoiledItemId?: string;
|
|
1891
|
+
/** Fuel burn time in ms when fed into a fuel-burning workstation (`undefined` = not fuel). */
|
|
1892
|
+
fuelValueMs?: number;
|
|
1893
|
+
/** Max tool uses (`undefined` = infinite durability). */
|
|
1894
|
+
maxUses?: number;
|
|
1895
|
+
}
|
|
1896
|
+
interface ItemStack {
|
|
1897
|
+
itemId: string;
|
|
1898
|
+
count: number;
|
|
1899
|
+
freshness01: number;
|
|
1900
|
+
durability01: number;
|
|
1901
|
+
}
|
|
1902
|
+
declare class ItemRegistry {
|
|
1903
|
+
private readonly defs;
|
|
1904
|
+
register(def: ItemDef): this;
|
|
1905
|
+
registerAll(list: ReadonlyArray<ItemDef>): this;
|
|
1906
|
+
/** Replace all registered item definitions in-place (preserving `ItemRegistry` identity for live `InventoryContainer`s!). */
|
|
1907
|
+
replaceAll(list: ReadonlyArray<ItemDef>): this;
|
|
1908
|
+
get size(): number;
|
|
1909
|
+
ids(): string[];
|
|
1910
|
+
get(itemId: string): ItemDef | undefined;
|
|
1911
|
+
maxStackOf(itemId: string): number;
|
|
1912
|
+
}
|
|
1913
|
+
declare class InventoryContainer {
|
|
1914
|
+
readonly capacity: number;
|
|
1915
|
+
readonly registry: ItemRegistry;
|
|
1916
|
+
/** Spoilage rate multiplier (`1.0` normal backpack, `0.25` icebox, `0` preserved). */
|
|
1917
|
+
spoilMultiplier: number;
|
|
1918
|
+
readonly slots: Array<ItemStack | null>;
|
|
1919
|
+
constructor(registry: ItemRegistry, capacity?: number, spoilMultiplier?: number);
|
|
1920
|
+
countItem(itemId: string): number;
|
|
1921
|
+
hasItems(reqs: ReadonlyArray<{
|
|
1922
|
+
itemId: string;
|
|
1923
|
+
count: number;
|
|
1924
|
+
}>): boolean;
|
|
1925
|
+
/** Add items, merging weighted freshness into existing partial stacks first; returns leftover count that did not fit. */
|
|
1926
|
+
addItem(itemId: string, count?: number, freshness01?: number, durability01?: number): number;
|
|
1927
|
+
/** Consume up to `count` of `itemId`; returns true if the full requested amount was removed. */
|
|
1928
|
+
removeItem(itemId: string, count?: number): boolean;
|
|
1929
|
+
/** Advance perishable spoilage across all slots; converts fully spoiled stacks into `spoiledItemId` (`'rot'`). */
|
|
1930
|
+
stepSpoilage(deltaMs: number): number;
|
|
1931
|
+
toJSON(): Array<ItemStack | null>;
|
|
1932
|
+
loadJSON(data: ReadonlyArray<ItemStack | null>): void;
|
|
1933
|
+
}
|
|
1934
|
+
interface RecipeDef {
|
|
1935
|
+
id: string;
|
|
1936
|
+
/** Required workstation kind (`null` / `undefined` = hand-craftable anywhere). */
|
|
1937
|
+
stationKind?: string | null;
|
|
1938
|
+
inputs: Array<{
|
|
1939
|
+
itemId: string;
|
|
1940
|
+
count: number;
|
|
1941
|
+
}>;
|
|
1942
|
+
outputs: Array<{
|
|
1943
|
+
itemId: string;
|
|
1944
|
+
count: number;
|
|
1945
|
+
}>;
|
|
1946
|
+
/** Processing duration in ms (`0` = instant craft). */
|
|
1947
|
+
durationMs?: number;
|
|
1948
|
+
/** Whether processing requires active fuel burning on the station (`default = false`). */
|
|
1949
|
+
requiresFuel?: boolean;
|
|
1950
|
+
}
|
|
1951
|
+
declare class RecipeRegistry {
|
|
1952
|
+
private readonly recipes;
|
|
1953
|
+
register(recipe: RecipeDef): this;
|
|
1954
|
+
registerAll(list: ReadonlyArray<RecipeDef>): this;
|
|
1955
|
+
/** Replace all registered crafting recipes in-place (preserving `RecipeRegistry` identity for live `WorkstationScheduler`s!). */
|
|
1956
|
+
replaceAll(list: ReadonlyArray<RecipeDef>): this;
|
|
1957
|
+
get size(): number;
|
|
1958
|
+
ids(): string[];
|
|
1959
|
+
get(recipeId: string): RecipeDef | undefined;
|
|
1960
|
+
canCraft(recipeId: string, inventory: InventoryContainer, availableStationKinds?: ReadonlySet<string>): boolean;
|
|
1961
|
+
/** Perform an instant craft directly from/into `inventory`. */
|
|
1962
|
+
craftInstant(recipeId: string, inventory: InventoryContainer, availableStationKinds?: ReadonlySet<string>): boolean;
|
|
1963
|
+
}
|
|
1964
|
+
interface WorkstationJob {
|
|
1965
|
+
recipeId: string;
|
|
1966
|
+
batchesRemaining: number;
|
|
1967
|
+
progressMs: number;
|
|
1968
|
+
}
|
|
1969
|
+
interface WorkstationSnapshot {
|
|
1970
|
+
id: string;
|
|
1971
|
+
kind: string;
|
|
1972
|
+
wx: number;
|
|
1973
|
+
wy: number;
|
|
1974
|
+
fuelRemainingMs: number;
|
|
1975
|
+
maxFuelMs: number;
|
|
1976
|
+
queue: WorkstationJob[];
|
|
1977
|
+
inputSlots: Array<ItemStack | null>;
|
|
1978
|
+
fuelSlots: Array<ItemStack | null>;
|
|
1979
|
+
outputSlots: Array<ItemStack | null>;
|
|
1980
|
+
}
|
|
1981
|
+
declare class WorkstationInstance {
|
|
1982
|
+
readonly id: string;
|
|
1983
|
+
readonly kind: string;
|
|
1984
|
+
wx: number;
|
|
1985
|
+
wy: number;
|
|
1986
|
+
fuelRemainingMs: number;
|
|
1987
|
+
readonly maxFuelMs: number;
|
|
1988
|
+
readonly inputInv: InventoryContainer;
|
|
1989
|
+
readonly fuelInv: InventoryContainer;
|
|
1990
|
+
readonly outputInv: InventoryContainer;
|
|
1991
|
+
readonly queue: WorkstationJob[];
|
|
1992
|
+
constructor(id: string, kind: string, itemRegistry: ItemRegistry, opts?: {
|
|
1993
|
+
wx?: number;
|
|
1994
|
+
wy?: number;
|
|
1995
|
+
maxFuelMs?: number;
|
|
1996
|
+
});
|
|
1997
|
+
get isBurning(): boolean;
|
|
1998
|
+
get activeProgress01(): number;
|
|
1999
|
+
private activeProgressRatio;
|
|
2000
|
+
enqueue(recipe: RecipeDef, batches?: number): boolean;
|
|
2001
|
+
private tryAutoRefuel;
|
|
2002
|
+
/**
|
|
2003
|
+
* Deterministically advance smelting/crafting + fuel burn + slot spoilage over arbitrarily small or huge `deltaMs`
|
|
2004
|
+
* (supports multi-minute offline chunk catch-up in exact analytical sub-steps!).
|
|
2005
|
+
*/
|
|
2006
|
+
step(deltaMs: number, recipes: RecipeRegistry): number;
|
|
2007
|
+
toSnapshot(): WorkstationSnapshot;
|
|
2008
|
+
loadSnapshot(snap: WorkstationSnapshot): void;
|
|
2009
|
+
}
|
|
2010
|
+
declare class WorkstationScheduler {
|
|
2011
|
+
readonly items: ItemRegistry;
|
|
2012
|
+
readonly recipes: RecipeRegistry;
|
|
2013
|
+
private readonly stations;
|
|
2014
|
+
constructor(items: ItemRegistry, recipes: RecipeRegistry);
|
|
2015
|
+
addStation(station: WorkstationInstance): WorkstationInstance;
|
|
2016
|
+
getStation(id: string): WorkstationInstance | undefined;
|
|
2017
|
+
removeStation(id: string): boolean;
|
|
2018
|
+
stepAll(deltaMs: number): number;
|
|
2019
|
+
/** Return set of station `kind`s within `radiusPx` of `(wx, wy)` for proximity-gated crafting menus. */
|
|
2020
|
+
nearbyStationKinds(wx: number, wy: number, radiusPx?: number): Set<string>;
|
|
2021
|
+
toJSON(): WorkstationSnapshot[];
|
|
2022
|
+
loadJSON(snaps: ReadonlyArray<WorkstationSnapshot>): void;
|
|
2023
|
+
}
|
|
2024
|
+
interface WorldEntityRecord {
|
|
2025
|
+
id: string;
|
|
2026
|
+
kind: string;
|
|
2027
|
+
x: number;
|
|
2028
|
+
y: number;
|
|
2029
|
+
state?: Record<string, number | string | boolean>;
|
|
2030
|
+
}
|
|
2031
|
+
interface TileCellDelta {
|
|
2032
|
+
tx: number;
|
|
2033
|
+
ty: number;
|
|
2034
|
+
ground: number;
|
|
2035
|
+
overlay: number;
|
|
2036
|
+
flags: number;
|
|
2037
|
+
}
|
|
2038
|
+
interface WorldDeltaSnapshot {
|
|
2039
|
+
schemaVersion: 1;
|
|
2040
|
+
seed: number;
|
|
2041
|
+
dayCount: number;
|
|
2042
|
+
time01: number;
|
|
2043
|
+
tileDeltas: TileCellDelta[];
|
|
2044
|
+
spawnedOrModifiedEntities: WorldEntityRecord[];
|
|
2045
|
+
/** Seed-generated entity IDs that were chopped/mined/destroyed so they stay removed on reload! */
|
|
2046
|
+
removedSeedEntityIds: string[];
|
|
2047
|
+
workstations: WorkstationSnapshot[];
|
|
2048
|
+
playerInventory?: Array<ItemStack | null>;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Capture ONLY player/simulation-modified tiles (`TileCellFlags.MODIFIED`) from a `ChunkedTilemap`
|
|
2052
|
+
* plus entity deltas and workstation states into a tiny `WorldDeltaSnapshot`.
|
|
2053
|
+
*/
|
|
2054
|
+
declare function captureWorldDelta(opts: {
|
|
2055
|
+
seed: number;
|
|
2056
|
+
dayCount?: number;
|
|
2057
|
+
time01?: number;
|
|
2058
|
+
tilemap: ChunkedTilemap;
|
|
2059
|
+
spawnedOrModifiedEntities?: ReadonlyArray<WorldEntityRecord>;
|
|
2060
|
+
removedSeedEntityIds?: Iterable<string>;
|
|
2061
|
+
scheduler?: WorkstationScheduler;
|
|
2062
|
+
playerInventory?: InventoryContainer;
|
|
2063
|
+
}): WorldDeltaSnapshot;
|
|
2064
|
+
/** Replay a `WorldDeltaSnapshot` onto a freshly seeded `ChunkedTilemap` + `WorkstationScheduler` + `InventoryContainer`. */
|
|
2065
|
+
declare function applyWorldDelta(snapshot: WorldDeltaSnapshot, targets: {
|
|
2066
|
+
tilemap: ChunkedTilemap;
|
|
2067
|
+
scheduler?: WorkstationScheduler;
|
|
2068
|
+
playerInventory?: InventoryContainer;
|
|
2069
|
+
}): void;
|
|
2070
|
+
/** Compact UTF-8 binary framing (`HWLD` magic + version + JSON payload) for tiny file / IndexedDB / network storage. */
|
|
2071
|
+
declare function encodeWorldDeltaBytes(snapshot: WorldDeltaSnapshot): Uint8Array;
|
|
2072
|
+
declare function decodeWorldDeltaBytes(bytes: Uint8Array): WorldDeltaSnapshot;
|
|
2073
|
+
interface WorldCatalogSpec<TRules extends Record<string, unknown> = Record<string, unknown>> {
|
|
2074
|
+
readonly version?: number | string;
|
|
2075
|
+
readonly items?: ReadonlyArray<ItemDef>;
|
|
2076
|
+
readonly recipes?: ReadonlyArray<RecipeDef>;
|
|
2077
|
+
readonly rules?: Readonly<TRules>;
|
|
2078
|
+
}
|
|
2079
|
+
interface FrozenWorldCatalog<TRules extends Record<string, unknown> = Record<string, unknown>> {
|
|
2080
|
+
readonly version: number | string;
|
|
2081
|
+
readonly items: ReadonlyArray<Readonly<ItemDef>>;
|
|
2082
|
+
readonly recipes: ReadonlyArray<Readonly<RecipeDef>>;
|
|
2083
|
+
readonly rules: Readonly<TRules>;
|
|
2084
|
+
}
|
|
2085
|
+
interface CatalogReloadDiff {
|
|
2086
|
+
readonly reloadSeq: number;
|
|
2087
|
+
readonly addedItems: readonly string[];
|
|
2088
|
+
readonly updatedItems: readonly string[];
|
|
2089
|
+
readonly removedItems: readonly string[];
|
|
2090
|
+
readonly addedRecipes: readonly string[];
|
|
2091
|
+
readonly updatedRecipes: readonly string[];
|
|
2092
|
+
readonly removedRecipes: readonly string[];
|
|
2093
|
+
readonly changedRules: readonly string[];
|
|
2094
|
+
}
|
|
2095
|
+
interface WorldCatalogRuntime<TRules extends Record<string, unknown> = Record<string, unknown>> {
|
|
2096
|
+
readonly items: ItemRegistry;
|
|
2097
|
+
readonly recipes: RecipeRegistry;
|
|
2098
|
+
readonly catalog: FrozenWorldCatalog<TRules>;
|
|
2099
|
+
readonly rules: Readonly<TRules>;
|
|
2100
|
+
readonly reloadSeq: number;
|
|
2101
|
+
/** Hot-swap static item/recipe/balance rules in-place without resetting live inventories, workstations, or world tiles! */
|
|
2102
|
+
reload(next: WorldCatalogSpec<TRules> | FrozenWorldCatalog<TRules>): CatalogReloadDiff;
|
|
2103
|
+
/** Subscribe to hot-reload diffs (e.g. from Vite `import.meta.hot`, Bun `--hot`, or AI balance sweeps). */
|
|
2104
|
+
onReload(listener: (diff: CatalogReloadDiff, catalog: FrozenWorldCatalog<TRules>) => void): () => void;
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* Validate, deep-clone, and deep-freeze a pure acyclic `WorldCatalogSpec` (rejecting functions,
|
|
2108
|
+
* class instances, and cycles so static rules stay 100% decoupled from mutable runtime state).
|
|
2109
|
+
*/
|
|
2110
|
+
declare function defineWorldCatalog<const TRules extends Record<string, unknown> = Record<string, unknown>>(spec: WorldCatalogSpec<TRules>): FrozenWorldCatalog<TRules>;
|
|
2111
|
+
/**
|
|
2112
|
+
* Create a hot-reloadable catalog runtime backed by live `ItemRegistry` and `RecipeRegistry` instances.
|
|
2113
|
+
* Calling `runtime.reload(nextCatalog)` swaps item/recipe/balance definitions in-place while preserving
|
|
2114
|
+
* all active `InventoryContainer` stacks, `WorkstationInstance` progress, and `ChunkedTilemap` state!
|
|
2115
|
+
*/
|
|
2116
|
+
declare function createWorldCatalogRuntime<TRules extends Record<string, unknown> = Record<string, unknown>>(initial: WorldCatalogSpec<TRules> | FrozenWorldCatalog<TRules>, opts?: {
|
|
2117
|
+
items?: ItemRegistry;
|
|
2118
|
+
recipes?: RecipeRegistry;
|
|
2119
|
+
}): WorldCatalogRuntime<TRules>;
|
|
1548
2120
|
type StageInputEvent = {
|
|
1549
2121
|
readonly kind: 'pointerdown' | 'pointermove' | 'pointerup';
|
|
1550
2122
|
readonly x: number;
|
|
@@ -1616,10 +2188,15 @@ declare class StageKernel {
|
|
|
1616
2188
|
private readonly providerOrder;
|
|
1617
2189
|
private readonly inputListeners;
|
|
1618
2190
|
private inputGuard;
|
|
2191
|
+
private boundCatalog;
|
|
1619
2192
|
private disposed;
|
|
1620
2193
|
constructor(game: Game);
|
|
1621
2194
|
/** Optional input barrier predicate (e.g. `() => !surfaces.isWorldBlocked()`). */
|
|
1622
2195
|
setInputGuard(guard: ((ev: StageInputEvent) => boolean) | null): this;
|
|
2196
|
+
/** Bind a `WorldCatalogRuntime` so Vite/Bun HMR or AI balance harnesses can hot-reload via `kernel.reloadCatalog()`. */
|
|
2197
|
+
bindCatalog<TRules extends Record<string, unknown>>(catalogRuntime: WorldCatalogRuntime<TRules> | null): this;
|
|
2198
|
+
/** Hot-reload the bound `WorldCatalogRuntime` in-place without resetting live scene/world state! */
|
|
2199
|
+
reloadCatalog<TRules extends Record<string, unknown> = Record<string, unknown>>(nextCatalog: WorldCatalogSpec<TRules>): CatalogReloadDiff;
|
|
1623
2200
|
/** Subscribe to every normalized `StageInputEvent` flowing through the kernel (used by recorders/mods). */
|
|
1624
2201
|
onInput(listener: (ev: StageInputEvent, frameSeq: number, simTimeMs: number) => void): () => void;
|
|
1625
2202
|
/** Mount a `StagePlugin` (idempotent per `plugin.id`; LIFO-disposed on `remove` or `game.destroy()`). */
|
|
@@ -1834,6 +2411,8 @@ declare class GameObjectFactory {
|
|
|
1834
2411
|
}): Graphics;
|
|
1835
2412
|
blitter(x: number, y: number, key: string): BlitterObject;
|
|
1836
2413
|
instancedBatch(key: string, maxCount?: number, frame?: string | number): InstancedBatchObject;
|
|
2414
|
+
/** Create an immediate-mode per-frame `DrawStreamObject` (`sprite()` / `writeBulk()`). */
|
|
2415
|
+
drawStream(key: string, options?: DrawStreamOptions): DrawStreamObject;
|
|
1837
2416
|
/** Create a zero-texture GPU analytical SDF shape batch (`circles`, `rings`, `pills`, `rounded rects`). */
|
|
1838
2417
|
shapeBatch(maxCount?: number, defaults?: ShapeBatchStyleDefaults): ShapeBatchObject;
|
|
1839
2418
|
container(x?: number, y?: number, children?: DisplayObject[]): Container;
|
|
@@ -1881,6 +2460,9 @@ declare class Scene {
|
|
|
1881
2460
|
readonly events: EventEmitter;
|
|
1882
2461
|
/** Deterministic EngineClock-driven tween & spring manager (auto-stepped in `Game.step()`). */
|
|
1883
2462
|
readonly tweens: TweenManager;
|
|
2463
|
+
/** Deterministic EngineClock-driven generator coroutine scheduler (`scene.script(function* (co) { ... })`). */
|
|
2464
|
+
readonly scripts: ScriptScheduler;
|
|
2465
|
+
private readonly _drawStreams;
|
|
1884
2466
|
private readonly _animatedSprites;
|
|
1885
2467
|
private readonly _equippedSprites;
|
|
1886
2468
|
private _nodesCreated;
|
|
@@ -1937,6 +2519,15 @@ declare class Scene {
|
|
|
1937
2519
|
lifecycleStats(): SceneLifecycleStats;
|
|
1938
2520
|
/** Lightweight active/completed/cancelled tween & spring counters for `sceneDigest()` and `perf()`. */
|
|
1939
2521
|
tweenStats(): TweenStats;
|
|
2522
|
+
/** Launch a deterministic EngineClock-driven generator coroutine (`function* (co) { yield* co.wait(0.35); ... }`). */
|
|
2523
|
+
script<R = unknown>(fn: (co: ScriptContext) => CoroutineGenerator<R>, options?: ScriptOptions): ScriptHandle;
|
|
2524
|
+
/** Lightweight active/completed/cancelled coroutine counters. */
|
|
2525
|
+
scriptStats(): ScriptStats;
|
|
2526
|
+
/**
|
|
2527
|
+
* Acquire (or lazily create) a memoized immediate-mode `DrawStreamObject` keyed by `(textureKey, opts?.streamId ?? 'default')`.
|
|
2528
|
+
* Safe to call directly inside `update()` or `preRender()` every frame with zero node allocation!
|
|
2529
|
+
*/
|
|
2530
|
+
drawStream(key: string, options?: DrawStreamOptions): DrawStreamObject;
|
|
1940
2531
|
_registerAnimatedSprite(sprite: SpriteObject): void;
|
|
1941
2532
|
_unregisterAnimatedSprite(sprite: SpriteObject): void;
|
|
1942
2533
|
_stepAnimations(deltaMs: number): void;
|
|
@@ -2008,4 +2599,4 @@ declare class Game {
|
|
|
2008
2599
|
step(time: number, delta: number): void;
|
|
2009
2600
|
destroy(removeCanvas?: boolean): void;
|
|
2010
2601
|
}
|
|
2011
|
-
export {
|
|
2602
|
+
export { decodeWorldDeltaBytes as $, HiDpiConfigureOptions as $n, OpenWgpuNativeFfiOptions as $t, createInputRecorder as A, InstancedBatchObject as An, SceneDigestOverlayStats as At, RecipeRegistry as B, SceneHostLike as Bn, Pointer as Bt, RecordedInputEntry as C, DrawStreamBulkView as Cn, unpackChunkY as Ct, TimelineClickOptions as D, EquipmentBinding as Dn, SceneDigestEngineSandbox as Dt, StagePlugin as E, DrawStreamSpriteOptions as En, SceneDigestActiveFocus as Et, InventoryContainer as F, PanelObject as Fn, buildSceneDigest as Ft, WorkstationSnapshot as G, SpriteObject as Gn, WebGpuBootstrapResult as Gt, WorkstationInstance as H, ShapeBatchObject as Hn, RendererWebGpu as Ht, ItemDef as I, PanelOpenSide as In, sanitizeTrackToken as It, WorldDeltaSnapshot as J, TextObject as Jn, requestWebGpuDevice as Jt, WorldCatalogRuntime as K, SpritePlayOptions as Kn, WebGpuCanvasContextLike as Kt, ItemRegistry as L, PanelStyleConfig as Ln, InputConfig as Lt, createInputTimeline as M, MsdfIconConfig as Mn, SceneDigestSurfaceEntry as Mt, CatalogReloadDiff as N, MsdfIconObject as Nn, SceneDigestSurfaceSource as Nt, TimelineDragOptions as O, Graphics as On, SceneDigestNode as Ot, FrozenWorldCatalog as P, NineSliceObject as Pn, SceneDigestSurfaces as Pt, createWorldCatalogRuntime as Q, CameraFollowOptions as Qn, OpenDawnWebGpuOptions as Qt, ItemStack as R, RectClipMask as Rn, InputPlugin as Rt, InputTimelinePlugin as S, DisplaySemantics as Sn, unpackChunkX as St, StageKernel as T, DrawStreamOptions as Tn, SceneDigest as Tt, WorkstationJob as U, ShapeBatchStyleDefaults as Un, RendererWebGpuOptions as Ut, TileCellDelta as V, ShapeBatchColumns as Vn, PointerSample as Vt, WorkstationScheduler as W, SpriteAnimEventListener as Wn, RequestWebGpuOptions as Wt, applyWorldDelta as X, TileSpriteObject as Xn, HeadlessWebGpuHandle as Xt, WorldEntityRecord as Y, TextStyleConfig as Yn, HeadlessWebGpuBackend as Yt, captureWorldDelta as Z, Camera as Zn, HeadlessWebGpuOptions as Zt, ActionMap as _, CustomPassOptions as _n, floorDiv as _t, GameLoop as a, RendererGlOptions as an, ChunkedTilemapOptions as at, InputTargetSpec as b, DisplayObject as bn, packChunkKey as bt, LoaderPlugin as c, StageRenderTarget as cn, MountedChunkedTilemap as ct, SceneCtor as d, BlitterObject as dn, TileChunk as dt, openDawnWebGpu as en, HiDpiScaleLike as er, defineWorldCatalog as et, SceneInput as f, Bob as fn, bakeDualGridTileset as ft, ViewportFitResult as g, CustomPassObject as gn, fbm2D as gt, StageRenderer as h, CustomPassCallback as hn, createIslandBiomeGenerator as ht, GameConfig as i, RendererGl as in, ChunkedTilemap as it, createInputReplay as j, InstancedColumns as jn, SceneDigestSandbox as jt, TimelineKeyOptions as k, ImageObject as kn, SceneDigestOptions as kt, ScaleManager as l, AnchorPose2D as ln, SurvivalBiomes as lt, SceneManager as m, ContainerFiltersShim as mn, computeDualGridMask as mt, EngineClockSnapshot as n, requestHeadlessWebGpu as nn, BakedDualGridAtlas as nt, GameObjectFactory as o, RendererStats as on, DualGridLayerSpec as ot, SceneLifecycleStats as p, Container as pn, computeBlob47Index as pt, WorldCatalogSpec as q, SyncAttachmentOptions as qn, WebGpuDeviceLike as qt, Game as r, Renderer2D as rn, ChunkGeneratorFn as rt, JsonCache as s, Stage2DCustomImageHandler as sn, IslandBiomeConfig as st, EngineClock as t, openWgpuNativeFfi as tn, encodeWorldDeltaBytes as tt, Scene as u, BindEquipmentOptions as un, TileCellFlags as ut, InputProvider as v, DirectionalPlayOptions as vn, hash2D as vt, StageInputEvent as w, DrawStreamObject as wn, valueNoise2D as wt, InputTimelineOptions as x, DisplayObjectType as xn, positiveMod as xt, InputRecorderPlugin as y, DisplayList as yn, mountChunkedTilemap as yt, RecipeDef as z, RectangleObject as zn, KeyboardPlugin as zt };
|