rn-gamekit 0.1.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 +18 -0
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/lib/module/assets/defineAssets.js +48 -0
- package/lib/module/assets/defineAssets.js.map +1 -0
- package/lib/module/assets/errors.js +38 -0
- package/lib/module/assets/errors.js.map +1 -0
- package/lib/module/assets/types.js +2 -0
- package/lib/module/assets/types.js.map +1 -0
- package/lib/module/assets/validation.js +99 -0
- package/lib/module/assets/validation.js.map +1 -0
- package/lib/module/core/frameDriver.js +20 -0
- package/lib/module/core/frameDriver.js.map +1 -0
- package/lib/module/core/input/createInputBuffer.js +296 -0
- package/lib/module/core/input/createInputBuffer.js.map +1 -0
- package/lib/module/core/input/types.js +4 -0
- package/lib/module/core/input/types.js.map +1 -0
- package/lib/module/core/session/createGameSession.js +554 -0
- package/lib/module/core/session/createGameSession.js.map +1 -0
- package/lib/module/core/session/deepFreeze.js +155 -0
- package/lib/module/core/session/deepFreeze.js.map +1 -0
- package/lib/module/core/session/diagnostics.js +2 -0
- package/lib/module/core/session/diagnostics.js.map +1 -0
- package/lib/module/core/session/types.js +43 -0
- package/lib/module/core/session/types.js.map +1 -0
- package/lib/module/definition/defineGame.js +57 -0
- package/lib/module/definition/defineGame.js.map +1 -0
- package/lib/module/definition/types.js +4 -0
- package/lib/module/definition/types.js.map +1 -0
- package/lib/module/geometry/types.js +2 -0
- package/lib/module/geometry/types.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/GamePointerInput.js +385 -0
- package/lib/module/react/GamePointerInput.js.map +1 -0
- package/lib/module/react/GameView.js +223 -0
- package/lib/module/react/GameView.js.map +1 -0
- package/lib/module/react/alphaClock.js +42 -0
- package/lib/module/react/alphaClock.js.map +1 -0
- package/lib/module/react/assets/createGameAssetStore.js +358 -0
- package/lib/module/react/assets/createGameAssetStore.js.map +1 -0
- package/lib/module/react/assets/decodeSkiaImage.js +54 -0
- package/lib/module/react/assets/decodeSkiaImage.js.map +1 -0
- package/lib/module/react/assets/errors.js +10 -0
- package/lib/module/react/assets/errors.js.map +1 -0
- package/lib/module/react/assets/useGameAssets.js +160 -0
- package/lib/module/react/assets/useGameAssets.js.map +1 -0
- package/lib/module/react/bindAppLifecycle.js +58 -0
- package/lib/module/react/bindAppLifecycle.js.map +1 -0
- package/lib/module/react/bindGameSession.js +37 -0
- package/lib/module/react/bindGameSession.js.map +1 -0
- package/lib/module/react/gestureLifecycle.js +68 -0
- package/lib/module/react/gestureLifecycle.js.map +1 -0
- package/lib/module/react/instrumentation.js +4 -0
- package/lib/module/react/instrumentation.js.map +1 -0
- package/lib/module/react/pointerBinding.js +196 -0
- package/lib/module/react/pointerBinding.js.map +1 -0
- package/lib/module/react/pointerCoalescer.js +224 -0
- package/lib/module/react/pointerCoalescer.js.map +1 -0
- package/lib/module/react/pointerContainment.js +27 -0
- package/lib/module/react/pointerContainment.js.map +1 -0
- package/lib/module/react/sprites/GameSprite.js +116 -0
- package/lib/module/react/sprites/GameSprite.js.map +1 -0
- package/lib/module/react/sprites/GameWorld2D.js +44 -0
- package/lib/module/react/sprites/GameWorld2D.js.map +1 -0
- package/lib/module/react/sprites/Sprite.js +147 -0
- package/lib/module/react/sprites/Sprite.js.map +1 -0
- package/lib/module/react/sprites/SpriteBatch.js +173 -0
- package/lib/module/react/sprites/SpriteBatch.js.map +1 -0
- package/lib/module/react/sprites/spriteBatchPolicy.js +25 -0
- package/lib/module/react/sprites/spriteBatchPolicy.js.map +1 -0
- package/lib/module/react/sprites/spriteTransform.js +135 -0
- package/lib/module/react/sprites/spriteTransform.js.map +1 -0
- package/lib/module/react/viewportBinding.js +101 -0
- package/lib/module/react/viewportBinding.js.map +1 -0
- package/lib/module/react.js +13 -0
- package/lib/module/react.js.map +1 -0
- package/lib/module/scene/defineScene.js +29 -0
- package/lib/module/scene/defineScene.js.map +1 -0
- package/lib/module/scene/types.js +4 -0
- package/lib/module/scene/types.js.map +1 -0
- package/lib/module/sprites/sampleSpriteClip.js +50 -0
- package/lib/module/sprites/sampleSpriteClip.js.map +1 -0
- package/lib/module/sprites/spriteAnimationState.js +165 -0
- package/lib/module/sprites/spriteAnimationState.js.map +1 -0
- package/lib/module/testing.js +57 -0
- package/lib/module/testing.js.map +1 -0
- package/lib/module/viewport2d/index.js +4 -0
- package/lib/module/viewport2d/index.js.map +1 -0
- package/lib/module/viewport2d/math.js +129 -0
- package/lib/module/viewport2d/math.js.map +1 -0
- package/lib/module/viewport2d/types.js +2 -0
- package/lib/module/viewport2d/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/assets/defineAssets.d.ts +20 -0
- package/lib/typescript/src/assets/defineAssets.d.ts.map +1 -0
- package/lib/typescript/src/assets/errors.d.ts +20 -0
- package/lib/typescript/src/assets/errors.d.ts.map +1 -0
- package/lib/typescript/src/assets/types.d.ts +138 -0
- package/lib/typescript/src/assets/types.d.ts.map +1 -0
- package/lib/typescript/src/assets/validation.d.ts +15 -0
- package/lib/typescript/src/assets/validation.d.ts.map +1 -0
- package/lib/typescript/src/core/frameDriver.d.ts +12 -0
- package/lib/typescript/src/core/frameDriver.d.ts.map +1 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts +12 -0
- package/lib/typescript/src/core/input/createInputBuffer.d.ts.map +1 -0
- package/lib/typescript/src/core/input/types.d.ts +64 -0
- package/lib/typescript/src/core/input/types.d.ts.map +1 -0
- package/lib/typescript/src/core/session/createGameSession.d.ts +18 -0
- package/lib/typescript/src/core/session/createGameSession.d.ts.map +1 -0
- package/lib/typescript/src/core/session/deepFreeze.d.ts +27 -0
- package/lib/typescript/src/core/session/deepFreeze.d.ts.map +1 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts +36 -0
- package/lib/typescript/src/core/session/diagnostics.d.ts.map +1 -0
- package/lib/typescript/src/core/session/types.d.ts +104 -0
- package/lib/typescript/src/core/session/types.d.ts.map +1 -0
- package/lib/typescript/src/definition/defineGame.d.ts +66 -0
- package/lib/typescript/src/definition/defineGame.d.ts.map +1 -0
- package/lib/typescript/src/definition/types.d.ts +56 -0
- package/lib/typescript/src/definition/types.d.ts.map +1 -0
- package/lib/typescript/src/geometry/types.d.ts +8 -0
- package/lib/typescript/src/geometry/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts +37 -0
- package/lib/typescript/src/react/GamePointerInput.d.ts.map +1 -0
- package/lib/typescript/src/react/GameView.d.ts +61 -0
- package/lib/typescript/src/react/GameView.d.ts.map +1 -0
- package/lib/typescript/src/react/alphaClock.d.ts +29 -0
- package/lib/typescript/src/react/alphaClock.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts +33 -0
- package/lib/typescript/src/react/assets/createGameAssetStore.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts +12 -0
- package/lib/typescript/src/react/assets/decodeSkiaImage.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/errors.d.ts +8 -0
- package/lib/typescript/src/react/assets/errors.d.ts.map +1 -0
- package/lib/typescript/src/react/assets/useGameAssets.d.ts +35 -0
- package/lib/typescript/src/react/assets/useGameAssets.d.ts.map +1 -0
- package/lib/typescript/src/react/bindAppLifecycle.d.ts +32 -0
- package/lib/typescript/src/react/bindAppLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/react/bindGameSession.d.ts +14 -0
- package/lib/typescript/src/react/bindGameSession.d.ts.map +1 -0
- package/lib/typescript/src/react/gestureLifecycle.d.ts +37 -0
- package/lib/typescript/src/react/gestureLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/react/instrumentation.d.ts +47 -0
- package/lib/typescript/src/react/instrumentation.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerBinding.d.ts +104 -0
- package/lib/typescript/src/react/pointerBinding.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts +106 -0
- package/lib/typescript/src/react/pointerCoalescer.d.ts.map +1 -0
- package/lib/typescript/src/react/pointerContainment.d.ts +12 -0
- package/lib/typescript/src/react/pointerContainment.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/GameSprite.d.ts +75 -0
- package/lib/typescript/src/react/sprites/GameSprite.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts +29 -0
- package/lib/typescript/src/react/sprites/GameWorld2D.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/Sprite.d.ts +43 -0
- package/lib/typescript/src/react/sprites/Sprite.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts +41 -0
- package/lib/typescript/src/react/sprites/SpriteBatch.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts +10 -0
- package/lib/typescript/src/react/sprites/spriteBatchPolicy.d.ts.map +1 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts +86 -0
- package/lib/typescript/src/react/sprites/spriteTransform.d.ts.map +1 -0
- package/lib/typescript/src/react/viewportBinding.d.ts +42 -0
- package/lib/typescript/src/react/viewportBinding.d.ts.map +1 -0
- package/lib/typescript/src/react.d.ts +20 -0
- package/lib/typescript/src/react.d.ts.map +1 -0
- package/lib/typescript/src/scene/defineScene.d.ts +26 -0
- package/lib/typescript/src/scene/defineScene.d.ts.map +1 -0
- package/lib/typescript/src/scene/types.d.ts +71 -0
- package/lib/typescript/src/scene/types.d.ts.map +1 -0
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts +24 -0
- package/lib/typescript/src/sprites/sampleSpriteClip.d.ts.map +1 -0
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts +45 -0
- package/lib/typescript/src/sprites/spriteAnimationState.d.ts.map +1 -0
- package/lib/typescript/src/testing.d.ts +28 -0
- package/lib/typescript/src/testing.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/index.d.ts +3 -0
- package/lib/typescript/src/viewport2d/index.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/math.d.ts +25 -0
- package/lib/typescript/src/viewport2d/math.d.ts.map +1 -0
- package/lib/typescript/src/viewport2d/types.d.ts +59 -0
- package/lib/typescript/src/viewport2d/types.d.ts.map +1 -0
- package/package.json +120 -0
- package/src/assets/defineAssets.ts +62 -0
- package/src/assets/errors.ts +64 -0
- package/src/assets/types.ts +164 -0
- package/src/assets/validation.ts +158 -0
- package/src/core/frameDriver.ts +31 -0
- package/src/core/input/createInputBuffer.ts +337 -0
- package/src/core/input/types.ts +67 -0
- package/src/core/session/createGameSession.ts +652 -0
- package/src/core/session/deepFreeze.ts +158 -0
- package/src/core/session/diagnostics.ts +35 -0
- package/src/core/session/types.ts +122 -0
- package/src/definition/defineGame.ts +94 -0
- package/src/definition/types.ts +67 -0
- package/src/geometry/types.ts +7 -0
- package/src/index.ts +84 -0
- package/src/react/GamePointerInput.tsx +478 -0
- package/src/react/GameView.tsx +317 -0
- package/src/react/alphaClock.ts +59 -0
- package/src/react/assets/createGameAssetStore.ts +459 -0
- package/src/react/assets/decodeSkiaImage.ts +64 -0
- package/src/react/assets/errors.ts +7 -0
- package/src/react/assets/useGameAssets.ts +171 -0
- package/src/react/bindAppLifecycle.ts +79 -0
- package/src/react/bindGameSession.ts +41 -0
- package/src/react/gestureLifecycle.ts +73 -0
- package/src/react/instrumentation.ts +54 -0
- package/src/react/pointerBinding.ts +226 -0
- package/src/react/pointerCoalescer.ts +234 -0
- package/src/react/pointerContainment.ts +23 -0
- package/src/react/sprites/GameSprite.tsx +192 -0
- package/src/react/sprites/GameWorld2D.tsx +46 -0
- package/src/react/sprites/Sprite.tsx +194 -0
- package/src/react/sprites/SpriteBatch.tsx +219 -0
- package/src/react/sprites/spriteBatchPolicy.ts +21 -0
- package/src/react/sprites/spriteTransform.ts +163 -0
- package/src/react/viewportBinding.ts +104 -0
- package/src/react.ts +37 -0
- package/src/scene/defineScene.ts +38 -0
- package/src/scene/types.ts +79 -0
- package/src/sprites/sampleSpriteClip.ts +51 -0
- package/src/sprites/spriteAnimationState.ts +176 -0
- package/src/testing.ts +61 -0
- package/src/viewport2d/index.ts +7 -0
- package/src/viewport2d/math.ts +134 -0
- package/src/viewport2d/types.ts +63 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function freezeRect(value) {
|
|
4
|
+
return Object.freeze(value);
|
|
5
|
+
}
|
|
6
|
+
function rect(x, y, width, height) {
|
|
7
|
+
return freezeRect({
|
|
8
|
+
x,
|
|
9
|
+
y,
|
|
10
|
+
width,
|
|
11
|
+
height
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function invalidLogicalSize(config) {
|
|
15
|
+
const {
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
} = config.logicalSize;
|
|
19
|
+
return `Viewport logical size must be finite and positive (got ${width} x ${height})`;
|
|
20
|
+
}
|
|
21
|
+
function isUsableSurface(size) {
|
|
22
|
+
return Number.isFinite(size.width) && Number.isFinite(size.height) && size.width > 0 && size.height > 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Resolve an authored viewport configuration against an actual surface size.
|
|
27
|
+
*
|
|
28
|
+
* Returns `undefined` until both surface dimensions are positive — a
|
|
29
|
+
* zero-sized layout is normal before the first layout pass. Invalid authored
|
|
30
|
+
* sizes throw a `RangeError` naming the invalid dimension. The result is
|
|
31
|
+
* immutable plain data with no platform dependencies.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveViewport2D(config, surfaceSize) {
|
|
34
|
+
const {
|
|
35
|
+
width: logicalWidth,
|
|
36
|
+
height: logicalHeight
|
|
37
|
+
} = config.logicalSize;
|
|
38
|
+
if (!Number.isFinite(logicalWidth) || !Number.isFinite(logicalHeight)) {
|
|
39
|
+
throw new RangeError(invalidLogicalSize(config));
|
|
40
|
+
}
|
|
41
|
+
if (!(logicalWidth > 0) || !(logicalHeight > 0)) {
|
|
42
|
+
throw new RangeError(invalidLogicalSize(config));
|
|
43
|
+
}
|
|
44
|
+
if (!isUsableSurface(surfaceSize)) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
if (config.mode !== 'fit' && config.mode !== 'fill' && config.mode !== 'extend-world') {
|
|
48
|
+
throw new RangeError(`Unknown viewport mode: ${String(config.mode)}`);
|
|
49
|
+
}
|
|
50
|
+
const {
|
|
51
|
+
width: surfaceWidth,
|
|
52
|
+
height: surfaceHeight
|
|
53
|
+
} = surfaceSize;
|
|
54
|
+
const widthScale = surfaceWidth / logicalWidth;
|
|
55
|
+
const heightScale = surfaceHeight / logicalHeight;
|
|
56
|
+
let scale;
|
|
57
|
+
let offsetX;
|
|
58
|
+
let offsetY;
|
|
59
|
+
let visibleLogicalBounds;
|
|
60
|
+
let contentBounds;
|
|
61
|
+
if (config.mode === 'fill') {
|
|
62
|
+
scale = Math.max(widthScale, heightScale);
|
|
63
|
+
offsetX = (surfaceWidth - logicalWidth * scale) / 2;
|
|
64
|
+
offsetY = (surfaceHeight - logicalHeight * scale) / 2;
|
|
65
|
+
visibleLogicalBounds = rect(-offsetX / scale, -offsetY / scale, surfaceWidth / scale, surfaceHeight / scale);
|
|
66
|
+
contentBounds = rect(0, 0, surfaceWidth, surfaceHeight);
|
|
67
|
+
} else {
|
|
68
|
+
// `fit` and `extend-world` share the fit (minimum uniform) scale.
|
|
69
|
+
scale = Math.min(widthScale, heightScale);
|
|
70
|
+
offsetX = (surfaceWidth - logicalWidth * scale) / 2;
|
|
71
|
+
offsetY = (surfaceHeight - logicalHeight * scale) / 2;
|
|
72
|
+
if (config.mode === 'extend-world') {
|
|
73
|
+
const worldWidth = surfaceWidth / scale;
|
|
74
|
+
const worldHeight = surfaceHeight / scale;
|
|
75
|
+
visibleLogicalBounds = rect((logicalWidth - worldWidth) / 2, (logicalHeight - worldHeight) / 2, worldWidth, worldHeight);
|
|
76
|
+
contentBounds = rect(0, 0, surfaceWidth, surfaceHeight);
|
|
77
|
+
} else {
|
|
78
|
+
visibleLogicalBounds = rect(0, 0, logicalWidth, logicalHeight);
|
|
79
|
+
contentBounds = rect(offsetX, offsetY, logicalWidth * scale, logicalHeight * scale);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze({
|
|
83
|
+
surfaceSize: Object.freeze({
|
|
84
|
+
width: surfaceWidth,
|
|
85
|
+
height: surfaceHeight
|
|
86
|
+
}),
|
|
87
|
+
logicalBounds: rect(0, 0, logicalWidth, logicalHeight),
|
|
88
|
+
visibleLogicalBounds,
|
|
89
|
+
contentBounds,
|
|
90
|
+
scale,
|
|
91
|
+
offsetX,
|
|
92
|
+
offsetY
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Convert a logical/world point into surface coordinates. */
|
|
97
|
+
export function worldToSurface(viewport, point) {
|
|
98
|
+
return Object.freeze({
|
|
99
|
+
x: point.x * viewport.scale + viewport.offsetX,
|
|
100
|
+
y: point.y * viewport.scale + viewport.offsetY
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Convert a surface point into logical/world coordinates. */
|
|
105
|
+
export function surfaceToWorld(viewport, point) {
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
x: (point.x - viewport.offsetX) / viewport.scale,
|
|
108
|
+
y: (point.y - viewport.offsetY) / viewport.scale
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Decide whether a surface point lies inside the interactive content area.
|
|
114
|
+
*
|
|
115
|
+
* For `fit` this rejects letterbox space so a pointer cannot begin there. For
|
|
116
|
+
* `fill` and `extend-world` the entire surface is interactive. Conversion
|
|
117
|
+
* itself remains mathematical everywhere; this operation decides whether a
|
|
118
|
+
* gesture may begin.
|
|
119
|
+
*/
|
|
120
|
+
export function containsSurfacePoint(viewport, point) {
|
|
121
|
+
const {
|
|
122
|
+
x,
|
|
123
|
+
y,
|
|
124
|
+
width,
|
|
125
|
+
height
|
|
126
|
+
} = viewport.contentBounds;
|
|
127
|
+
return point.x >= x && point.y >= y && point.x <= x + width && point.y <= y + height;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["freezeRect","value","Object","freeze","rect","x","y","width","height","invalidLogicalSize","config","logicalSize","isUsableSurface","size","Number","isFinite","resolveViewport2D","surfaceSize","logicalWidth","logicalHeight","RangeError","undefined","mode","String","surfaceWidth","surfaceHeight","widthScale","heightScale","scale","offsetX","offsetY","visibleLogicalBounds","contentBounds","Math","max","min","worldWidth","worldHeight","logicalBounds","worldToSurface","viewport","point","surfaceToWorld","containsSurfacePoint"],"sourceRoot":"../../../src","sources":["viewport2d/math.ts"],"mappings":";;AAGA,SAASA,UAAUA,CAACC,KAAW,EAAQ;EACrC,OAAOC,MAAM,CAACC,MAAM,CAACF,KAAK,CAAC;AAC7B;AAEA,SAASG,IAAIA,CAACC,CAAS,EAAEC,CAAS,EAAEC,KAAa,EAAEC,MAAc,EAAQ;EACvE,OAAOR,UAAU,CAAC;IAAEK,CAAC;IAAEC,CAAC;IAAEC,KAAK;IAAEC;EAAO,CAAC,CAAC;AAC5C;AAEA,SAASC,kBAAkBA,CAACC,MAAgB,EAAU;EACpD,MAAM;IAAEH,KAAK;IAAEC;EAAO,CAAC,GAAGE,MAAM,CAACC,WAAW;EAC5C,OAAO,0DAA0DJ,KAAK,MAAMC,MAAM,GAAG;AACvF;AAEA,SAASI,eAAeA,CAACC,IAAiB,EAAW;EACnD,OACEC,MAAM,CAACC,QAAQ,CAACF,IAAI,CAACN,KAAK,CAAC,IAC3BO,MAAM,CAACC,QAAQ,CAACF,IAAI,CAACL,MAAM,CAAC,IAC5BK,IAAI,CAACN,KAAK,GAAG,CAAC,IACdM,IAAI,CAACL,MAAM,GA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AACnC,CAAC,IAAIA,CAAC,IAAImC,KAAK,CAACpC,CAAC,IAAIA,CAAC,GAAGE,KAAK,IAAIkC,KAAK,CAACnC,CAAC,IAAIA,CAAC,GAAGE,MAAM;AACtF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["viewport2d/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AssetGroupMap, GameAssetManifest, ImageDescriptor, SpriteClip, SpriteFrameRect, SpriteSheetDescriptor } from './types.js';
|
|
2
|
+
/** Declare a single full-image asset from a static module handle. */
|
|
3
|
+
export declare function image(source: number): ImageDescriptor;
|
|
4
|
+
/**
|
|
5
|
+
* Declare a sprite-sheet asset: named source frames plus named animation
|
|
6
|
+
* clips. Frame and clip names are preserved as string literals; clip frame
|
|
7
|
+
* references are restricted to the declared frames.
|
|
8
|
+
*/
|
|
9
|
+
export declare function spriteSheet<TFrames extends Record<string, SpriteFrameRect>, TClips extends Record<string, SpriteClip<Extract<keyof TFrames, string>>>>(source: number, spec: {
|
|
10
|
+
readonly frames: TFrames;
|
|
11
|
+
readonly animations: TClips;
|
|
12
|
+
}): SpriteSheetDescriptor<TFrames, TClips>;
|
|
13
|
+
/**
|
|
14
|
+
* Declare the game's asset manifest: a deeply immutable, fully typed group
|
|
15
|
+
* map. Group, asset, frame, and clip names are preserved as string literals
|
|
16
|
+
* and every descriptor is branded with the manifest type so lookups stay
|
|
17
|
+
* typed. Allocates no native resources and performs no I/O.
|
|
18
|
+
*/
|
|
19
|
+
export declare function defineAssets<TGroups extends AssetGroupMap>(groups: TGroups): GameAssetManifest<TGroups>;
|
|
20
|
+
//# sourceMappingURL=defineAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineAssets.d.ts","sourceRoot":"","sources":["../../../../src/assets/defineAssets.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,eAAe,EACf,qBAAqB,EACtB,MAAM,YAAS,CAAC;AAEjB,qEAAqE;AACrE,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAGrD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC/C,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAEzE,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IACJ,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GACA,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CASxC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,aAAa,EACxD,MAAM,EAAE,OAAO,GACd,iBAAiB,CAAC,OAAO,CAAC,CAI5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured asset errors (T7.2).
|
|
3
|
+
*
|
|
4
|
+
* Every definition/loading failure carries a stable machine-readable code
|
|
5
|
+
* and the field path that caused it. Paths are documented in the public
|
|
6
|
+
* error reference; messages never embed machine-specific paths.
|
|
7
|
+
*/
|
|
8
|
+
/** Stable error codes for asset definition and loading. */
|
|
9
|
+
export type GameAssetErrorCode = 'ASSET_INVALID_IDENTIFIER' | 'ASSET_INVALID_SOURCE' | 'ASSET_INVALID_FRAME_RECT' | 'ASSET_EMPTY_CLIP' | 'ASSET_UNKNOWN_FRAME' | 'ASSET_UNKNOWN_CLIP' | 'ASSET_INVALID_DURATION' | 'ASSET_INVALID_MODE' | 'ASSET_UNSUPPORTED_SOURCE' | 'ASSET_UNKNOWN_GROUP' | 'ASSET_UNKNOWN_ASSET' | 'ASSET_RESOLVE_FAILED' | 'ASSET_DECODE_FAILED' | 'ASSET_FRAME_OUT_OF_BOUNDS' | 'ASSET_ABORTED' | 'ASSET_STORE_DISPOSED';
|
|
10
|
+
/** A structured asset definition or loading failure. */
|
|
11
|
+
export declare class GameAssetError extends Error {
|
|
12
|
+
/** Stable machine-readable code. */
|
|
13
|
+
readonly code: GameAssetErrorCode;
|
|
14
|
+
/** Field path within the manifest/descriptor that caused the failure. */
|
|
15
|
+
readonly path: readonly string[];
|
|
16
|
+
constructor(code: GameAssetErrorCode, path: readonly string[], message: string);
|
|
17
|
+
}
|
|
18
|
+
/** Throw when a definition-time identifier is invalid. */
|
|
19
|
+
export declare function assertValidIdentifier(path: readonly string[], value: string): void;
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/assets/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB,GAC1B,0BAA0B,GAC1B,sBAAsB,GACtB,0BAA0B,GAC1B,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,wBAAwB,GACxB,oBAAoB,GACpB,0BAA0B,GAC1B,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,2BAA2B,GAC3B,eAAe,GACf,sBAAsB,CAAC;AAE3B,wDAAwD;AACxD,qBAAa,cAAe,SAAQ,KAAK;IACvC,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;gBAErB,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM;CAM/E;AAED,0DAA0D;AAC1D,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,EAAE,MAAM,GACZ,IAAI,CAiBN"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asset descriptor and manifest types (T7.2).
|
|
3
|
+
*
|
|
4
|
+
* The manifest is the static, deeply immutable declaration of a game's local
|
|
5
|
+
* assets. Group, asset, frame, and clip names are preserved as string
|
|
6
|
+
* literals; retrieval goes through typed descriptor references, never
|
|
7
|
+
* duplicated strings. Sources are static module handles (`number` from
|
|
8
|
+
* `require(...)`) only — string/URL sources are rejected at the type
|
|
9
|
+
* boundary and deliberately have no runtime branch.
|
|
10
|
+
*/
|
|
11
|
+
/** Static React Native module handle returned by `require(...)`. */
|
|
12
|
+
export type AssetSourceHandle = number;
|
|
13
|
+
/** A single full-image asset. */
|
|
14
|
+
export interface ImageDescriptor {
|
|
15
|
+
/** Discriminant. */
|
|
16
|
+
readonly kind: 'image';
|
|
17
|
+
/** Static module handle. */
|
|
18
|
+
readonly source: AssetSourceHandle;
|
|
19
|
+
}
|
|
20
|
+
/** A named rectangle inside a sprite sheet, in source pixels. */
|
|
21
|
+
export interface SpriteFrameRect {
|
|
22
|
+
/** Left edge in source pixels; non-negative finite number. */
|
|
23
|
+
readonly x: number;
|
|
24
|
+
/** Top edge in source pixels; non-negative finite number. */
|
|
25
|
+
readonly y: number;
|
|
26
|
+
/** Width in source pixels; greater than zero. */
|
|
27
|
+
readonly width: number;
|
|
28
|
+
/** Height in source pixels; greater than zero. */
|
|
29
|
+
readonly height: number;
|
|
30
|
+
}
|
|
31
|
+
/** Clip playback mode: looping or one-shot. */
|
|
32
|
+
export type SpriteAnimationMode = 'loop' | 'once';
|
|
33
|
+
/**
|
|
34
|
+
* A named animation clip over a sprite sheet's frames.
|
|
35
|
+
*
|
|
36
|
+
* Frame references are restricted to the sheet's declared frame names and
|
|
37
|
+
* durations are uniform per clip in this version (per-frame durations are
|
|
38
|
+
* deferred so precedence cannot be misunderstood).
|
|
39
|
+
*/
|
|
40
|
+
export interface SpriteClip<TFrameName extends string = string> {
|
|
41
|
+
/** Ordered frame references; at least one, all declared on the sheet. */
|
|
42
|
+
readonly frames: readonly TFrameName[];
|
|
43
|
+
/** Uniform per-frame duration in milliseconds; finite and greater than zero. */
|
|
44
|
+
readonly frameDurationMs: number;
|
|
45
|
+
/** Discriminated playback mode. */
|
|
46
|
+
readonly mode: SpriteAnimationMode;
|
|
47
|
+
}
|
|
48
|
+
/** A sprite-sheet asset: named frames plus named animation clips. */
|
|
49
|
+
export interface SpriteSheetDescriptor<TFrames extends Record<string, SpriteFrameRect> = Record<string, SpriteFrameRect>, TClips extends Record<string, SpriteClip<Extract<keyof TFrames, string>>> = Record<string, SpriteClip<Extract<keyof TFrames, string>>>> {
|
|
50
|
+
/** Discriminant. */
|
|
51
|
+
readonly kind: 'sprite-sheet';
|
|
52
|
+
/** Static module handle. */
|
|
53
|
+
readonly source: AssetSourceHandle;
|
|
54
|
+
/** Named source rectangles. */
|
|
55
|
+
readonly frames: TFrames;
|
|
56
|
+
/** Named animation clips restricted to the declared frames. */
|
|
57
|
+
readonly animations: TClips;
|
|
58
|
+
}
|
|
59
|
+
/** Union of all asset descriptors. */
|
|
60
|
+
export type AssetDescriptor = ImageDescriptor | SpriteSheetDescriptor;
|
|
61
|
+
/** A group of named asset descriptors. */
|
|
62
|
+
export type AssetGroup = Readonly<Record<string, AssetDescriptor>>;
|
|
63
|
+
/** The author-facing group map accepted by `defineAssets`. */
|
|
64
|
+
export type AssetGroupMap = Readonly<Record<string, AssetGroup>>;
|
|
65
|
+
/**
|
|
66
|
+
* Type-level manifest brand. Every descriptor of a manifest carries a
|
|
67
|
+
* phantom reference to its originating manifest type, so a loaded store can
|
|
68
|
+
* reject descriptors from any other manifest at compile time.
|
|
69
|
+
*/
|
|
70
|
+
declare const manifestBrand: unique symbol;
|
|
71
|
+
export type BrandedAssetDescriptor<TManifest, TDescriptor extends AssetDescriptor> = {
|
|
72
|
+
readonly [manifestBrand]?: TManifest;
|
|
73
|
+
} & TDescriptor;
|
|
74
|
+
/**
|
|
75
|
+
* The deeply immutable manifest produced by `defineAssets`.
|
|
76
|
+
*
|
|
77
|
+
* Groups and assets keep their literal names; every descriptor is branded
|
|
78
|
+
* with the manifest type so lookups stay typed.
|
|
79
|
+
*/
|
|
80
|
+
export type GameAssetManifest<TGroups extends AssetGroupMap = AssetGroupMap> = {
|
|
81
|
+
readonly [TGroup in keyof TGroups]: {
|
|
82
|
+
readonly [TAsset in keyof TGroups[TGroup]]: BrandedAssetDescriptor<GameAssetManifest<TGroups>, TGroups[TGroup][TAsset]>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
/** The manifest type of a descriptor's originating manifest. */
|
|
86
|
+
export type ManifestOf<TDescriptor> = TDescriptor extends {
|
|
87
|
+
readonly [manifestBrand]?: infer TManifest;
|
|
88
|
+
} ? TManifest : never;
|
|
89
|
+
/** Loaded-asset lookup keyed by typed descriptor reference.
|
|
90
|
+
*
|
|
91
|
+
* v1 semantics (R9): lookup is descriptor-REFERENCE membership — the exact
|
|
92
|
+
* descriptor object declared by the manifest. The compile-time brand is
|
|
93
|
+
* structural, so identically shaped manifests are not nominally distinct;
|
|
94
|
+
* the runtime reference check is the guarantee, and the type layer still
|
|
95
|
+
* rejects duplicated string keys and descriptors from differently shaped
|
|
96
|
+
* manifests.
|
|
97
|
+
*/
|
|
98
|
+
export interface LoadedAssets<TManifest> {
|
|
99
|
+
/** The manifest this store was created from. */
|
|
100
|
+
readonly manifest: TManifest;
|
|
101
|
+
/** Retrieve a loaded asset by its typed descriptor reference. */
|
|
102
|
+
readonly get: <TDescriptor extends AssetDescriptor>(descriptor: BrandedAssetDescriptor<TManifest, TDescriptor>) => TDescriptor extends {
|
|
103
|
+
readonly kind: 'sprite-sheet';
|
|
104
|
+
} ? LoadedSpriteSheet : LoadedImage;
|
|
105
|
+
}
|
|
106
|
+
/** A ready full-image resource. */
|
|
107
|
+
export interface LoadedImage {
|
|
108
|
+
/** Logical descriptor this resource was loaded for. */
|
|
109
|
+
readonly descriptor: ImageDescriptor;
|
|
110
|
+
/** Decoded source width in pixels. */
|
|
111
|
+
readonly width: number;
|
|
112
|
+
/** Decoded source height in pixels. */
|
|
113
|
+
readonly height: number;
|
|
114
|
+
/** The decoded image handle (Skia's SkImage satisfies this structurally). */
|
|
115
|
+
readonly image: unknown;
|
|
116
|
+
}
|
|
117
|
+
/** A ready sprite-sheet resource with validated frame rectangles. */
|
|
118
|
+
export interface LoadedSpriteSheet {
|
|
119
|
+
/** Logical descriptor this resource was loaded for. */
|
|
120
|
+
readonly descriptor: SpriteSheetDescriptor;
|
|
121
|
+
/** Validated frames in source pixels (offsets against the decoded image). */
|
|
122
|
+
readonly frames: Readonly<Record<string, SpriteFrameRect>>;
|
|
123
|
+
/** Decoded source width in pixels. */
|
|
124
|
+
readonly width: number;
|
|
125
|
+
/** Decoded source height in pixels. */
|
|
126
|
+
readonly height: number;
|
|
127
|
+
/** The decoded image handle (Skia's SkImage satisfies this structurally). */
|
|
128
|
+
readonly image: unknown;
|
|
129
|
+
}
|
|
130
|
+
/** A ready, typed, caller-owned lease over loaded asset groups. */
|
|
131
|
+
export interface GameAssetLease<TManifest> {
|
|
132
|
+
/** Typed lookup; rejects descriptors from other manifests. */
|
|
133
|
+
readonly assets: LoadedAssets<TManifest>;
|
|
134
|
+
/** Release this lease; idempotent; the final release disposes the image. */
|
|
135
|
+
readonly dispose: () => void;
|
|
136
|
+
}
|
|
137
|
+
export {};
|
|
138
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/assets/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC,iCAAiC;AACjC,MAAM,WAAW,eAAe;IAC9B,oB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CAAC,GAAG,EAAE,CAAC,WAAW,SAAS,eAAe,EAChD,UAAU,EAAE,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC,KACvD,WAAW,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;KAAE,GACtD,iBAAiB,GACjB,WAAW,CAAC;CACjB;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC3D,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc,CAAC,SAAS;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AssetGroupMap, SpriteClip, SpriteFrameRect } from './types.js';
|
|
2
|
+
/** Validate one frame rectangle. */
|
|
3
|
+
export declare function validateFrameRect(path: readonly string[], name: string, rect: SpriteFrameRect): void;
|
|
4
|
+
/** Validate one animation clip against the sheet's declared frames. */
|
|
5
|
+
export declare function validateClip(path: readonly string[], name: string, clip: SpriteClip, frames: Readonly<Record<string, SpriteFrameRect>>): void;
|
|
6
|
+
/** Validate a full sprite-sheet descriptor. */
|
|
7
|
+
export declare function validateSpriteSheet(source: unknown, spec: {
|
|
8
|
+
readonly frames: Readonly<Record<string, SpriteFrameRect>>;
|
|
9
|
+
readonly animations: Readonly<Record<string, SpriteClip>>;
|
|
10
|
+
}): void;
|
|
11
|
+
/** Validate an image descriptor's source. */
|
|
12
|
+
export declare function validateImageSource(source: unknown): void;
|
|
13
|
+
/** Validate a full asset manifest. */
|
|
14
|
+
export declare function validateManifest(manifest: AssetGroupMap): void;
|
|
15
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../../src/assets/validation.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,eAAe,EAEhB,MAAM,YAAS,CAAC;AAEjB,oCAAoC;AACpC,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,eAAe,GACpB,IAAI,CA2BN;AAED,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,GAChD,IAAI,CAiCN;AAED,+CAA+C;AAC/C,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;CAAE,GAC9H,IAAI,CAcN;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAQzD;AAED,sCAAsC;AACtC,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAmC9D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Opaque handle returned by an animation-frame driver. */
|
|
2
|
+
export type FrameHandle = number;
|
|
3
|
+
/** Minimal presentation clock used by the fixed-step runtime. */
|
|
4
|
+
export interface FrameDriver {
|
|
5
|
+
/** Request the next presentation callback. */
|
|
6
|
+
requestFrame(callback: (timestampMs: number) => void): FrameHandle;
|
|
7
|
+
/** Cancel a previously requested callback. */
|
|
8
|
+
cancelFrame(handle: FrameHandle): void;
|
|
9
|
+
}
|
|
10
|
+
/** Create the platform animation-frame driver used by live sessions. */
|
|
11
|
+
export declare function createAnimationFrameDriver(): FrameDriver;
|
|
12
|
+
//# sourceMappingURL=frameDriver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameDriver.d.ts","sourceRoot":"","sources":["../../../../src/core/frameDriver.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,8CAA8C;IAC9C,YAAY,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,GAAG,WAAW,CAAC;IACnE,8CAA8C;IAC9C,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CACxC;AAOD,wEAAwE;AACxE,wBAAgB,0BAA0B,IAAI,WAAW,CAaxD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InputMap } from '../../definition/types.js';
|
|
2
|
+
import type { InputController, InputFrame } from './types.js';
|
|
3
|
+
interface InputBuffer<TActionName extends string> {
|
|
4
|
+
readonly controller: InputController<TActionName>;
|
|
5
|
+
sample(): InputFrame<TActionName>;
|
|
6
|
+
/** Clear scene-local edges while retaining pointers that remain physically down. */
|
|
7
|
+
resetForTransition(targetActions: readonly string[]): void;
|
|
8
|
+
reset(): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createInputBuffer<TInput extends InputMap>(input: TInput, assertLive: () => void): InputBuffer<Extract<keyof TInput, string>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=createInputBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInputBuffer.d.ts","sourceRoot":"","sources":["../../../../../src/core/input/createInputBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAAwB,CAAC;AAEvD,OAAO,KAAK,EAAe,eAAe,EAAE,UAAU,EAAgB,MAAM,YAAS,CAAC;AA8BtF,UAAU,WAAW,CAAC,WAAW,SAAS,MAAM;IAC9C,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAClC,oFAAoF;IACpF,kBAAkB,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3D,KAAK,IAAI,IAAI,CAAC;CACf;AAkBD,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,QAAQ,EACvD,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,IAAI,GACrB,WAAW,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,CAqR5C"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Point2D } from '../../geometry/types.js';
|
|
2
|
+
/** The sampled state of a digital action for one simulation tick. */
|
|
3
|
+
export interface ButtonState {
|
|
4
|
+
/** Whether the button is down at the tick boundary. */
|
|
5
|
+
readonly held: boolean;
|
|
6
|
+
/** Whether at least one press arrived since the previous tick. */
|
|
7
|
+
readonly pressed: boolean;
|
|
8
|
+
/** Whether at least one release arrived since the previous tick. */
|
|
9
|
+
readonly released: boolean;
|
|
10
|
+
/** Whether the platform cancelled ownership since the previous tick. */
|
|
11
|
+
readonly cancelled: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The sampled state of a pointer action for one simulation tick.
|
|
15
|
+
*
|
|
16
|
+
* `pressed`, `released`, and `cancelled` are one-tick edges. `active`
|
|
17
|
+
* persists while the owning pointer is down. `delta` accumulates movement
|
|
18
|
+
* between ticks and resets after each sample.
|
|
19
|
+
*/
|
|
20
|
+
export interface PointerState {
|
|
21
|
+
/** Whether the owning pointer is currently down. */
|
|
22
|
+
readonly active: boolean;
|
|
23
|
+
/** Whether a pointer began since the previous tick. */
|
|
24
|
+
readonly pressed: boolean;
|
|
25
|
+
/** Whether the owning pointer was released since the previous tick. */
|
|
26
|
+
readonly released: boolean;
|
|
27
|
+
/** Whether the owning pointer was cancelled since the previous tick. */
|
|
28
|
+
readonly cancelled: boolean;
|
|
29
|
+
/** Stable identifier of the pointer that owns the action. */
|
|
30
|
+
readonly pointerId?: number;
|
|
31
|
+
/** Current logical position of the owning pointer. */
|
|
32
|
+
readonly position?: Point2D;
|
|
33
|
+
/** Logical movement accumulated since the previous tick. */
|
|
34
|
+
readonly delta: Point2D;
|
|
35
|
+
}
|
|
36
|
+
/** An immutable semantic input snapshot sampled once per simulation tick. */
|
|
37
|
+
export interface InputFrame<TActionName extends string> {
|
|
38
|
+
/** Read a declared digital button action. */
|
|
39
|
+
button(action: TActionName): ButtonState;
|
|
40
|
+
/** Read a declared pointer action. */
|
|
41
|
+
pointer(action: TActionName): PointerState;
|
|
42
|
+
}
|
|
43
|
+
/** Platform-facing controls for enqueueing semantic input changes. */
|
|
44
|
+
export interface InputController<TActionName extends string> {
|
|
45
|
+
/** Enqueue a press for a declared button action. */
|
|
46
|
+
press(action: TActionName): void;
|
|
47
|
+
/** Enqueue a release for a declared button action. */
|
|
48
|
+
release(action: TActionName): void;
|
|
49
|
+
/** Begin a pointer for a declared pointer action. */
|
|
50
|
+
begin(action: TActionName, pointerId: number, position: Point2D): void;
|
|
51
|
+
/** Move the owning pointer of a declared pointer action. */
|
|
52
|
+
move(action: TActionName, pointerId: number, position: Point2D): void;
|
|
53
|
+
/** End the owning pointer of a declared pointer action. */
|
|
54
|
+
end(action: TActionName, pointerId: number): void;
|
|
55
|
+
/** Cancel the active button or owning pointer of a declared action. */
|
|
56
|
+
cancel(action: TActionName): void;
|
|
57
|
+
/**
|
|
58
|
+
* Monotonic count of input events accepted by this controller (F1). The
|
|
59
|
+
* session's commit instrumentation uses it to associate a commit with the
|
|
60
|
+
* inputs its fixed step actually sampled.
|
|
61
|
+
*/
|
|
62
|
+
readonly acceptedCount: number;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/input/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAsB,CAAC;AAEpD,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uEAAuE;IACvE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} from '../../definition/types.js';
|
|
2
|
+
import { type FrameDriver } from '../frameDriver.js';
|
|
3
|
+
import { type GameSession } from './types.js';
|
|
4
|
+
import type { SessionDiagnostics } from './diagnostics.js';
|
|
5
|
+
interface SessionOptions {
|
|
6
|
+
readonly frameDriver: FrameDriver;
|
|
7
|
+
readonly fixedStepMs?: number;
|
|
8
|
+
readonly maxCatchUpSteps?: number;
|
|
9
|
+
readonly maxFrameDeltaMs?: number;
|
|
10
|
+
/** @internal Performance instrumentation for the playground Performance Lab. */
|
|
11
|
+
readonly diagnostics?: SessionDiagnostics;
|
|
12
|
+
}
|
|
13
|
+
/** Create a live session using the platform animation-frame driver. */
|
|
14
|
+
export declare function createGameSession<const TScenes extends SceneMap, const TInput extends InputMap, const TInitialScene extends keyof TScenes>(definition: GameDefinition<TScenes, TInput, TInitialScene>): GameSession<TScenes, TInput>;
|
|
15
|
+
/** @internal Deterministic construction seam used by the headless test suite. */
|
|
16
|
+
export declare function createGameSessionWithDriver<const TScenes extends SceneMap, const TInput extends InputMap, const TInitialScene extends keyof TScenes>(definition: GameDefinition<TScenes, TInput, TInitialScene>, options: SessionOptions): GameSession<TScenes, TInput>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=createGameSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createGameSession.d.ts","sourceRoot":"","sources":["../../../../../src/core/session/createGameSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAAwB,CAAC;AAEjF,OAAO,EAA8B,KAAK,WAAW,EAAoB,MAAM,mBAAgB,CAAC;AAGhG,OAAO,EAML,KAAK,WAAW,EAEjB,MAAM,YAAS,CAAC;AACjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAe,CAAC;AAMxD,UAAU,cAAc;IACtB,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAsDD,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,OAAO,SAAS,QAAQ,EAC9B,KAAK,CAAC,MAAM,SAAS,QAAQ,EAC7B,KAAK,CAAC,aAAa,SAAS,MAAM,OAAO,EAEzC,UAAU,EAAE,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,GACzD,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAI9B;AAED,iFAAiF;AACjF,wBAAgB,2BAA2B,CACzC,KAAK,CAAC,OAAO,SAAS,QAAQ,EAC9B,KAAK,CAAC,MAAM,SAAS,QAAQ,EAC7B,KAAK,CAAC,aAAa,SAAS,MAAM,OAAO,EAEzC,UAAU,EAAE,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAC1D,OAAO,EAAE,cAAc,GACtB,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAqiB9B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trusted deep-freeze cache (T3).
|
|
3
|
+
*
|
|
4
|
+
* Each session owns one freezer. A subtree that has been completely frozen
|
|
5
|
+
* once is recorded in a `WeakSet` and never re-traversed: structurally
|
|
6
|
+
* shared snapshot subtrees (the common case: unchanged bricks, entities,
|
|
7
|
+
* or config objects reused by reference across ticks) are walked exactly
|
|
8
|
+
* once for the lifetime of the session.
|
|
9
|
+
*
|
|
10
|
+
* Correctness rules:
|
|
11
|
+
* - A node is promoted into the trusted set **only after** its whole
|
|
12
|
+
* subtree finished freezing. A child getter that throws mid-traversal
|
|
13
|
+
* leaves every ancestor untrusted, so a later snapshot re-walks it.
|
|
14
|
+
* - Cycle detection uses a separate per-traversal `visiting` set, never the
|
|
15
|
+
* trusted set, so cycles freeze exactly once without infinite recursion.
|
|
16
|
+
* - `Object.isFrozen` is never used as a skip test: an externally
|
|
17
|
+
* shallow-frozen object can contain mutable children and must still be
|
|
18
|
+
* recursed into.
|
|
19
|
+
* - Freezing is never dev-only: the public API promise of deeply immutable
|
|
20
|
+
* snapshots holds in every build.
|
|
21
|
+
*/
|
|
22
|
+
import type { DeepReadonly } from './types.js';
|
|
23
|
+
export interface DeepFreezer {
|
|
24
|
+
<T>(value: T): DeepReadonly<T>;
|
|
25
|
+
}
|
|
26
|
+
export declare function createDeepFreeze(): DeepFreezer;
|
|
27
|
+
//# sourceMappingURL=deepFreeze.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepFreeze.d.ts","sourceRoot":"","sources":["../../../../../src/core/session/deepFreeze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAS,CAAC;AA4D5C,MAAM,WAAW,WAAW;IAC1B,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CAChC;AAED,wBAAgB,gBAAgB,IAAI,WAAW,CAuE9C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal performance diagnostics sink.
|
|
3
|
+
*
|
|
4
|
+
* The session calls these hooks only when a sink is supplied through the
|
|
5
|
+
* testing seam. Production sessions pass no sink and pay no timing reads,
|
|
6
|
+
* callbacks, or wrapper allocation on the disabled path (F4). This is
|
|
7
|
+
* intentionally NOT a public diagnostics API: its usefulness is being proven
|
|
8
|
+
* by the playground Performance Lab before any public contract.
|
|
9
|
+
*/
|
|
10
|
+
export interface SessionDiagnostics {
|
|
11
|
+
/** A presentation callback was delivered by the frame driver. */
|
|
12
|
+
onDisplayCallback(): void;
|
|
13
|
+
/** A display callback that ran zero simulation steps. */
|
|
14
|
+
onZeroStepCallback(): void;
|
|
15
|
+
/** A fixed simulation step ran. */
|
|
16
|
+
onFixedStep(): void;
|
|
17
|
+
/** A catch-up step (second or later in the same callback) ran. */
|
|
18
|
+
onCatchUpStep(): void;
|
|
19
|
+
/** Whole-step debt dropped after the catch-up cap, in steps. */
|
|
20
|
+
onDroppedDebt(steps: number): void;
|
|
21
|
+
/** Duration of one scene update, milliseconds. */
|
|
22
|
+
onUpdate(durationMs: number): void;
|
|
23
|
+
/** Duration of one input sample, milliseconds. */
|
|
24
|
+
onInputSample(durationMs: number): void;
|
|
25
|
+
/** Duration of one snapshot extraction, milliseconds. */
|
|
26
|
+
onSnapshot(durationMs: number): void;
|
|
27
|
+
/** Duration of one deep-freeze pass, milliseconds. */
|
|
28
|
+
onDeepFreeze(durationMs: number): void;
|
|
29
|
+
/** Duration of one publish (listener fan-out), milliseconds. */
|
|
30
|
+
onPublish(durationMs: number): void;
|
|
31
|
+
/** A render frame was published to listeners. */
|
|
32
|
+
onCommitNotification(): void;
|
|
33
|
+
/** Listener count at publish time. */
|
|
34
|
+
onListenerCount(count: number): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../../../src/core/session/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,iBAAiB,IAAI,IAAI,CAAC;IAC1B,yDAAyD;IACzD,kBAAkB,IAAI,IAAI,CAAC;IAC3B,mCAAmC;IACnC,WAAW,IAAI,IAAI,CAAC;IACpB,kEAAkE;IAClE,aAAa,IAAI,IAAI,CAAC;IACtB,gEAAgE;IAChE,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kDAAkD;IAClD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,yDAAyD;IACzD,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,sDAAsD;IACtD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,gEAAgE;IAChE,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,iDAAiD;IACjD,oBAAoB,IAAI,IAAI,CAAC;IAC7B,sCAAsC;IACtC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC"}
|