@holtjs/stage 0.0.1 → 0.3.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/dist/hit.js ADDED
@@ -0,0 +1,185 @@
1
+ // src/hit.ts
2
+ const TAU = Math.PI * 2;
3
+ const clamp = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
4
+ /**
5
+ * Continuous swept-circle intersection: returns the earliest fraction `t in [0, 1]` along the
6
+ * segment from `(ax, ay)` by `(sx, sy)` where a point touches circle `(cx, cy, radius)`
7
+ * (use `radius = moverRadius + targetRadius` for two circles). Returns `0` if already overlapping
8
+ * at the start, or `-1` if there is no contact. Prevents high-speed projectiles from tunneling.
9
+ */
10
+ function sweptCircleHit(ax, ay, sx, sy, cx, cy, radius) {
11
+ const fx = ax - cx;
12
+ const fy = ay - cy;
13
+ const c = fx * fx + fy * fy - radius * radius;
14
+ if (c < 0) return 0;
15
+ const a = sx * sx + sy * sy;
16
+ if (a < 1e-9) return -1;
17
+ const bq = fx * sx + fy * sy;
18
+ if (bq >= 0) return -1;
19
+ const disc = bq * bq - a * c;
20
+ if (disc < 0) return -1;
21
+ const t = (-bq - Math.sqrt(disc)) / a;
22
+ return t <= 1 ? t : -1;
23
+ }
24
+ /**
25
+ * First contact fraction `f in [0, 1]` of a rotating radial melee blade (length `reach`, sweeping
26
+ * from `startAngle` across `arcSpan` in direction `dir` = `1` CW or `-1` CCW) against target circle
27
+ * `(targetX, targetY, targetRadius)`. Returns `-1` when missed, `0` when already overlapping at
28
+ * `startAngle` or within `closeSq` of the origin.
29
+ */
30
+ function arcSweepFirstContact(originX, originY, reach, startAngle, arcSpan, dir, closeSq, targetX, targetY, targetRadius) {
31
+ const dx = targetX - originX;
32
+ const dy = targetY - originY;
33
+ const q = dx * dx + dy * dy;
34
+ if (!(reach > 0) || !(targetRadius >= 0)) return q < closeSq ? 0 : -1;
35
+ const dist = Math.sqrt(q);
36
+ if (dist >= reach + targetRadius) return -1;
37
+ if (q < closeSq || dist <= targetRadius) return 0;
38
+ const halfAngle = dist * dist - targetRadius * targetRadius <= reach * reach ? Math.asin(Math.min(1, targetRadius / dist)) : Math.acos(clamp((dist * dist + reach * reach - targetRadius * targetRadius) / (2 * dist * reach), -1, 1));
39
+ let u = (Math.atan2(dy, dx) - startAngle) * dir;
40
+ u -= Math.floor(u / TAU) * TAU;
41
+ if (u >= TAU - halfAngle) return 0;
42
+ if (!(arcSpan > 0)) return u <= halfAngle ? 0 : -1;
43
+ if (u > arcSpan + halfAngle) return -1;
44
+ return Math.max(0, Math.min(1, (u - halfAngle) / arcSpan));
45
+ }
46
+ /**
47
+ * True if target circle `(targetX, targetY, targetRadius)` intersects an angular melee slice
48
+ * `[startAngle, startAngle + dir * sliceWidth]` of radius `reach` around `(originX, originY)`
49
+ * (or lies inside `closeSq` close-range tolerance).
50
+ */
51
+ function arcSweepTouches(originX, originY, reach, startAngle, sliceWidth, dir, closeSq, targetX, targetY, targetRadius) {
52
+ const dx = targetX - originX;
53
+ const dy = targetY - originY;
54
+ const q = dx * dx + dy * dy;
55
+ if (!(reach > 0) || !(targetRadius >= 0)) return q < closeSq;
56
+ const maxReach = reach + targetRadius;
57
+ if (q >= maxReach * maxReach) return false;
58
+ const dist = Math.sqrt(q);
59
+ if (q < closeSq || dist <= targetRadius) return true;
60
+ const halfAngle = dist * dist - targetRadius * targetRadius <= reach * reach ? Math.asin(Math.min(1, targetRadius / dist)) : Math.acos(clamp((dist * dist + reach * reach - targetRadius * targetRadius) / (2 * dist * reach), -1, 1));
61
+ let u = (Math.atan2(dy, dx) - startAngle) * dir;
62
+ u -= Math.floor(u / TAU) * TAU;
63
+ return u <= sliceWidth + halfAngle || u >= TAU - halfAngle;
64
+ }
65
+ /** True when two circles overlap (strictly closer than `ar + br`). */
66
+ function circleOverlapsCircle(ax, ay, ar, bx, by, br) {
67
+ const dx = ax - bx;
68
+ const dy = ay - by;
69
+ const r = ar + br;
70
+ return dx * dx + dy * dy < r * r;
71
+ }
72
+ /** True when two axis-aligned bounding boxes strictly overlap. */
73
+ function aabbOverlapsAabb(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1) {
74
+ return ax0 < bx1 && ax1 > bx0 && ay0 < by1 && ay1 > by0;
75
+ }
76
+ /** True when circle `(cx, cy, radius)` intersects AABB `[x0, x1] x [y0, y1]`. */
77
+ function circleOverlapsAabb(cx, cy, radius, x0, y0, x1, y1) {
78
+ const nx = clamp(cx, x0, x1);
79
+ const ny = clamp(cy, y0, y1);
80
+ const dx = cx - nx;
81
+ const dy = cy - ny;
82
+ return dx * dx + dy * dy < radius * radius;
83
+ }
84
+ /** Squared distance from point `(px, py)` to line segment `(ax, ay) -> (bx, by)`. */
85
+ function pointToSegmentDistSq(px, py, ax, ay, bx, by) {
86
+ const vx = bx - ax;
87
+ const vy = by - ay;
88
+ const lenSq = vx * vx + vy * vy;
89
+ if (lenSq < 1e-12) {
90
+ const dx = px - ax;
91
+ const dy = py - ay;
92
+ return dx * dx + dy * dy;
93
+ }
94
+ const t = clamp(((px - ax) * vx + (py - ay) * vy) / lenSq, 0, 1);
95
+ const cx = ax + vx * t;
96
+ const cy = ay + vy * t;
97
+ const dx = px - cx;
98
+ const dy = py - cy;
99
+ return dx * dx + dy * dy;
100
+ }
101
+ /** True when line segment `(ax, ay) -> (bx, by)` intersects circle `(cx, cy, radius)`. */
102
+ function segmentHitsCircle(ax, ay, bx, by, cx, cy, radius) {
103
+ return pointToSegmentDistSq(cx, cy, ax, ay, bx, by) < radius * radius;
104
+ }
105
+ /** True when capsule `(ax, ay) -> (bx, by)` with radius `capsuleRadius` hits circle `(cx, cy, targetRadius)`. */
106
+ function capsuleHitsCircle(ax, ay, bx, by, capsuleRadius, cx, cy, targetRadius) {
107
+ const r = capsuleRadius + targetRadius;
108
+ return pointToSegmentDistSq(cx, cy, ax, ay, bx, by) < r * r;
109
+ }
110
+ /**
111
+ * Push a circle `(pos.x, pos.y, radius)` out of static circle obstacles and optionally clamp inside `bounds`.
112
+ * Uses `Math.sqrt` deterministically so client prediction and server DO agree to the bit.
113
+ */
114
+ function resolveCircleObstacles(pos, radius, obstacles, bounds, candidateIndices) {
115
+ const n = candidateIndices ? candidateIndices.length : obstacles.length;
116
+ for (let j = 0; j < n; j++) {
117
+ const k = obstacles[candidateIndices ? candidateIndices[j] : j];
118
+ if (!k) continue;
119
+ const minR = k.r + radius;
120
+ const dx = pos.x - k.x;
121
+ const dy = pos.y - k.y;
122
+ const d2 = dx * dx + dy * dy;
123
+ if (d2 >= minR * minR) continue;
124
+ const d = Math.sqrt(d2);
125
+ if (d < 1e-6) {
126
+ pos.x = k.x + minR;
127
+ continue;
128
+ }
129
+ pos.x = k.x + dx / d * minR;
130
+ pos.y = k.y + dy / d * minR;
131
+ }
132
+ if (bounds) {
133
+ pos.x = clamp(pos.x, bounds.minX + radius, bounds.maxX - radius);
134
+ pos.y = clamp(pos.y, bounds.minY + radius, bounds.maxY - radius);
135
+ }
136
+ }
137
+ /**
138
+ * Push circle `(pos.x, pos.y, radius)` smoothly out of axis-aligned obstacle `[x0, x1] x [y0, y1]`.
139
+ * Returns `true` if a penetration was resolved.
140
+ */
141
+ function resolveCircleAabb(pos, radius, x0, y0, x1, y1) {
142
+ const nx = clamp(pos.x, x0, x1);
143
+ const ny = clamp(pos.y, y0, y1);
144
+ const dx = pos.x - nx;
145
+ const dy = pos.y - ny;
146
+ const d2 = dx * dx + dy * dy;
147
+ if (d2 >= radius * radius) return false;
148
+ if (d2 > 1e-12) {
149
+ const d = Math.sqrt(d2);
150
+ const push = radius - d;
151
+ pos.x += dx / d * push;
152
+ pos.y += dy / d * push;
153
+ return true;
154
+ }
155
+ const dl = pos.x - x0;
156
+ const dr = x1 - pos.x;
157
+ const dt = pos.y - y0;
158
+ const db = y1 - pos.y;
159
+ const m = Math.min(dl, dr, dt, db);
160
+ if (m === dl) pos.x = x0 - radius;
161
+ else if (m === dr) pos.x = x1 + radius;
162
+ else if (m === dt) pos.y = y0 - radius;
163
+ else pos.y = y1 + radius;
164
+ return true;
165
+ }
166
+ /** Exponential per-tick knockback decay factor (`exp(-dt / tau)`). */
167
+ function knockbackDecay(dt, tau = .07) {
168
+ return Math.exp(-dt / Math.max(1e-6, tau));
169
+ }
170
+ /** Initial velocity (units/s) whose exponentially-decayed discrete steps sum to `distance`. */
171
+ function knockbackInitialSpeed(distance, dt, decay) {
172
+ return distance * (1 - decay) / Math.max(1e-6, dt);
173
+ }
174
+ /** Advance knockback velocity one tick in-place and snap tiny residuals below `stopSq` to zero. */
175
+ function stepKnockback(vel, decay, stopSq = 4) {
176
+ vel.x *= decay;
177
+ vel.y *= decay;
178
+ if (vel.x * vel.x + vel.y * vel.y < stopSq) {
179
+ vel.x = 0;
180
+ vel.y = 0;
181
+ return false;
182
+ }
183
+ return true;
184
+ }
185
+ export { aabbOverlapsAabb, arcSweepFirstContact, arcSweepTouches, capsuleHitsCircle, circleOverlapsAabb, circleOverlapsCircle, knockbackDecay, knockbackInitialSpeed, pointToSegmentDistSq, resolveCircleAabb, resolveCircleObstacles, segmentHitsCircle, stepKnockback, sweptCircleHit };
@@ -0,0 +1,307 @@
1
+ import { $ as GlTextureHost, A as CustomPassCallback, B as NineSliceObject, C as RendererGlOptions, Ct as WHITE_RGB, D as Bob$1, Dt as parseColor, E as BlitterObject, Et as packColorAbgr, F as DisplaySemantics, G as RectangleObject, H as PanelOpenSide, I as Graphics, J as TextStyleConfig, K as SceneHostLike, L as ImageObject, M as DisplayList, N as DisplayObject, O as Container, Ot as rgbToCss, P as DisplayObjectType, Q as Frame, R as MsdfIconConfig, S as RendererGl, St as WEBGL, T as Stage2DCustomImageHandler, Tt as createMatrix2D, U as PanelStyleConfig, V as PanelObject, W as RectClipMask, X as Camera, Y as TileSpriteObject, Z as CanvasTexture, _ as InputPlugin, _t as RgbaColor, a as GameLoop, at as TextureSource, b as PointerSample, bt as TintMode, c as LoaderPlugin, ct as BlendMode, d as SceneCtor, dt as EventEmitter, et as SpriteSheetConfig, f as SceneInput, ft as FilterMode, g as InputConfig, gt as Rect2D, h as StageRenderer, ht as Matrix2D, i as GameConfig$1, it as TextureManager, j as CustomPassObject, k as ContainerFiltersShim, l as ScaleManager, lt as BlendModes, m as SceneManager, mt as HEX_MASK, n as EngineClockSnapshot, nt as TextureImageOptions, o as GameObjectFactory, ot as AUTO, p as SceneLifecycleStats, pt as FilterModeValue, q as TextObject, r as Game, rt as TextureImageSource, s as JsonCache, st as BLACK_RGB, t as EngineClock, tt as Texture, u as Scene, ut as CANVAS, v as KeyboardPlugin, vt as Scale, w as RendererStats, wt as WorldView2D, x as Renderer2D, xt as TintModes, y as Pointer, yt as Scenes, z as MsdfIconObject } from "./game-NqFMKsuL.js";
2
+ import { SceneDigest, SceneDigestActiveFocus, SceneDigestEngineSandbox, SceneDigestNode, SceneDigestOptions, SceneDigestOverlayStats, SceneDigestSandbox, SceneDigestSurfaceEntry, SceneDigestSurfaceSource, SceneDigestSurfaces, buildSceneDigest, sanitizeTrackToken } from "./trace.js";
3
+ import { FlexAlign, FlexContainerSpec, FlexDir, FlexItemRect, FlexItemSpec, FlexJustify, FlexPadding, FlexResult, WrapContainerSpec, WrapItemRect, WrapItemSpec, WrapJustify, WrapResult, computeFlexLayout, computeWrapLayout, resolvePadding } from "./flex.js";
4
+ import { a as SpringHandle, c as TweenManager, i as Easings, l as TweenOptions, n as EasingFn, o as SpringOptions, r as EasingName, s as TweenHandle, t as DisposableOwner, u as TweenStats } from "./tween-D3Ztppuz.js";
5
+ import { JoystickDpad, JoystickDpadOptions, JoystickState, JoystickVector, JoystickViewport, JoystickZone, JoystickZonePredicate, JoystickZoneRect, VirtualJoystick, VirtualJoystickMode, VirtualJoystickOptions, VirtualJoystickStyle, clampJoystickOrigin, computeJoystickVector, isInJoystickZone, pullJoystickOrigin, quantizeJoystickDpad } from "./joystick.js";
6
+ import { SURFACE_BAND, SurfaceBand, SurfaceBandName, SurfaceBarrier, SurfaceCancelContext, SurfaceCancelDispatchResult, SurfaceCancelResult, SurfaceDomEntry, SurfaceFocusContext, SurfaceFocusDispatchResult, SurfaceFocusResult, SurfaceKeyContext, SurfaceKeyDispatchResult, SurfaceKeyResult, SurfaceNodeInfo, SurfaceNodeInput, SurfaceScope, SurfaceTree, computeSurfaceDomZ, createSurfaceTree, resolveSurfacePriority, surfacePriorityToDomZ } from "./surfaces.js";
7
+ export declare class SdfPanelBatcher {
8
+ private readonly gl;
9
+ private readonly isWebGL2;
10
+ private program;
11
+ private uResolution;
12
+ private vbo;
13
+ private vao;
14
+ private quadIbo;
15
+ private readonly vertBuf;
16
+ private readonly vertF32;
17
+ private readonly vertU32;
18
+ private panelCount;
19
+ private lastResW;
20
+ private lastResH;
21
+ framePanels: number;
22
+ frameDraws: number;
23
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, isWebGL2: boolean, sharedQuadIbo: WebGLBuffer);
24
+ get pending(): number;
25
+ resetFrameStats(): void;
26
+ initGl(sharedQuadIbo: WebGLBuffer): void;
27
+ private setupAttribs;
28
+ push(m: Matrix2D, ox: number, oy: number, w: number, h: number, rTL: number, rTR: number, rBR: number, rBL: number, fillColor: number, fillAlpha: number, borderColor: number, borderAlpha: number, borderWidth: number, pixelStep: number, openSide: number, topGlintColor: number, topGlintAlpha: number, topGlintHeight: number, resW: number, resH: number): void;
29
+ flush(resW: number, resH: number): boolean;
30
+ onContextLost(): void;
31
+ destroy(contextLost: boolean): void;
32
+ }
33
+ export declare class MsdfIconBatcher {
34
+ private readonly gl;
35
+ private readonly isWebGL2;
36
+ private readonly bindSlot0;
37
+ private program;
38
+ private uResolution;
39
+ private vbo;
40
+ private vao;
41
+ private quadIbo;
42
+ private readonly vertBuf;
43
+ private readonly vertF32;
44
+ private readonly vertU32;
45
+ private iconCount;
46
+ private curTex;
47
+ private lastResW;
48
+ private lastResH;
49
+ frameIcons: number;
50
+ frameDraws: number;
51
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, isWebGL2: boolean, sharedQuadIbo: WebGLBuffer, bindSlot0: (tex: WebGLTexture) => void);
52
+ get pending(): number;
53
+ resetFrameStats(): void;
54
+ initGl(sharedQuadIbo: WebGLBuffer): void;
55
+ private setupAttribs;
56
+ push(tex: WebGLTexture, m: Matrix2D, ox: number, oy: number, w: number, h: number, u0: number, v0: number, u1: number, v1: number, padRatio: number, rangeUnits: number, viewSize: number, fillColor: number, fillAlpha: number, outlineColor: number, outlineAlpha: number, outlineWidth: number, resW: number, resH: number): boolean;
57
+ flush(resW: number, resH: number): boolean;
58
+ onContextLost(): void;
59
+ destroy(contextLost: boolean): void;
60
+ }
61
+ export declare class PixelAaBatcher {
62
+ private readonly gl;
63
+ private readonly isWebGL2;
64
+ private readonly bindSlot0;
65
+ private program;
66
+ private uResolution;
67
+ private vbo;
68
+ private vao;
69
+ private linearSampler;
70
+ private quadIbo;
71
+ private readonly vertBuf;
72
+ private readonly vertF32;
73
+ private readonly vertU32;
74
+ private iconCount;
75
+ private curTex;
76
+ private lastResW;
77
+ private lastResH;
78
+ frameIcons: number;
79
+ frameDraws: number;
80
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, isWebGL2: boolean, sharedQuadIbo: WebGLBuffer, bindSlot0: (tex: WebGLTexture) => void);
81
+ get pending(): number;
82
+ resetFrameStats(): void;
83
+ initGl(sharedQuadIbo: WebGLBuffer): void;
84
+ private setupAttribs;
85
+ push(tex: WebGLTexture, m: Matrix2D, x0: number, y0: number, x1: number, y1: number, cutX: number, cutY: number, cutW: number, cutH: number, texW: number, texH: number, flipX: boolean, flipY: boolean, tintColor: number, alpha: number, resW: number, resH: number): boolean;
86
+ flush(resW: number, resH: number): boolean;
87
+ onContextLost(): void;
88
+ destroy(contextLost: boolean): void;
89
+ }
90
+ type Stage2DGameType = Game;
91
+ type Stage2DSceneType = Scene;
92
+ type Stage2DGameConfigType = GameConfig$1;
93
+ type Stage2DTextureType = Texture;
94
+ type Stage2DCanvasTextureType = CanvasTexture;
95
+ type Stage2DFrameType = Frame;
96
+ type Stage2DTextureManagerType = TextureManager;
97
+ type Stage2DCameraType = Camera;
98
+ type Stage2DGraphicsType = Graphics;
99
+ type Stage2DContainerType = Container;
100
+ type Stage2DLoaderPluginType = LoaderPlugin;
101
+ export declare namespace Stage2D {
102
+ type Game = Stage2DGameType;
103
+ type Scene = Stage2DSceneType;
104
+ type GameConfig = Stage2DGameConfigType;
105
+ namespace Textures {
106
+ type Texture = Stage2DTextureType;
107
+ type CanvasTexture = Stage2DCanvasTextureType;
108
+ type Frame = Stage2DFrameType;
109
+ type TextureManager = Stage2DTextureManagerType;
110
+ }
111
+ namespace Cameras {
112
+ namespace Scene2D {
113
+ type Camera = Stage2DCameraType;
114
+ }
115
+ }
116
+ namespace GameObjects {
117
+ type GameObject = DisplayObject;
118
+ type Image = ImageObject;
119
+ type MsdfIcon = MsdfIconObject;
120
+ type NineSlice = NineSliceObject;
121
+ type Panel = PanelObject;
122
+ type TileSprite = TileSpriteObject;
123
+ type Rectangle = RectangleObject;
124
+ type Text = TextObject;
125
+ type Graphics = Stage2DGraphicsType;
126
+ type Blitter = BlitterObject;
127
+ type Bob = Bob$1;
128
+ type Container = Stage2DContainerType;
129
+ type CustomPass = CustomPassObject;
130
+ }
131
+ namespace Loader {
132
+ type LoaderPlugin = Stage2DLoaderPluginType;
133
+ }
134
+ }
135
+ export declare const Stage2D: {
136
+ readonly AUTO: 0;
137
+ readonly CANVAS: 1;
138
+ readonly WEBGL: 2;
139
+ readonly BlendModes: {
140
+ readonly NORMAL: 0;
141
+ readonly ADD: 1;
142
+ };
143
+ readonly TintModes: {
144
+ readonly MULTIPLY: 0;
145
+ readonly FILL: 1;
146
+ };
147
+ readonly Scale: {
148
+ readonly NONE: 0;
149
+ };
150
+ readonly Scenes: {
151
+ readonly PENDING: 0;
152
+ readonly INIT: 1;
153
+ readonly START: 2;
154
+ readonly LOADING: 3;
155
+ readonly CREATING: 4;
156
+ readonly RUNNING: 5;
157
+ readonly PAUSED: 6;
158
+ readonly SLEEPING: 7;
159
+ readonly SHUTDOWN: 8;
160
+ readonly DESTROYED: 9;
161
+ };
162
+ readonly Game: typeof Game;
163
+ readonly Scene: typeof Scene;
164
+ readonly Textures: {
165
+ readonly FilterMode: {
166
+ readonly LINEAR: 0;
167
+ readonly NEAREST: 1;
168
+ };
169
+ readonly Texture: typeof Texture;
170
+ readonly CanvasTexture: typeof CanvasTexture;
171
+ readonly Frame: typeof Frame;
172
+ readonly TextureManager: typeof TextureManager;
173
+ };
174
+ readonly Cameras: {
175
+ readonly Scene2D: {
176
+ readonly Camera: typeof Camera;
177
+ };
178
+ };
179
+ readonly GameObjects: {
180
+ readonly GameObject: typeof DisplayObject;
181
+ readonly Image: typeof ImageObject;
182
+ readonly MsdfIcon: typeof MsdfIconObject;
183
+ readonly NineSlice: typeof NineSliceObject;
184
+ readonly Panel: typeof PanelObject;
185
+ readonly TileSprite: typeof TileSpriteObject;
186
+ readonly Rectangle: typeof RectangleObject;
187
+ readonly Text: typeof TextObject;
188
+ readonly Graphics: typeof Graphics;
189
+ readonly Blitter: typeof BlitterObject;
190
+ readonly Container: typeof Container;
191
+ readonly CustomPass: typeof CustomPassObject;
192
+ };
193
+ readonly Loader: {
194
+ readonly LoaderPlugin: typeof LoaderPlugin;
195
+ };
196
+ readonly Display: {
197
+ readonly Canvas: {
198
+ readonly CanvasPool: {
199
+ readonly enableSmoothing: () => void;
200
+ };
201
+ };
202
+ };
203
+ };
204
+ export declare namespace Stage {
205
+ type Game = Stage2DGameType;
206
+ type Scene = Stage2DSceneType;
207
+ type GameConfig = Stage2DGameConfigType;
208
+ namespace Textures {
209
+ type Texture = Stage2DTextureType;
210
+ type CanvasTexture = Stage2DCanvasTextureType;
211
+ type Frame = Stage2DFrameType;
212
+ type TextureManager = Stage2DTextureManagerType;
213
+ }
214
+ namespace Cameras {
215
+ namespace Scene2D {
216
+ type Camera = Stage2DCameraType;
217
+ }
218
+ }
219
+ namespace GameObjects {
220
+ type GameObject = DisplayObject;
221
+ type Image = ImageObject;
222
+ type MsdfIcon = MsdfIconObject;
223
+ type NineSlice = NineSliceObject;
224
+ type Panel = PanelObject;
225
+ type TileSprite = TileSpriteObject;
226
+ type Rectangle = RectangleObject;
227
+ type Text = TextObject;
228
+ type Graphics = Stage2DGraphicsType;
229
+ type Blitter = BlitterObject;
230
+ type Bob = Bob$1;
231
+ type Container = Stage2DContainerType;
232
+ type CustomPass = CustomPassObject;
233
+ }
234
+ namespace Loader {
235
+ type LoaderPlugin = Stage2DLoaderPluginType;
236
+ }
237
+ }
238
+ export declare const Stage: {
239
+ readonly AUTO: 0;
240
+ readonly CANVAS: 1;
241
+ readonly WEBGL: 2;
242
+ readonly BlendModes: {
243
+ readonly NORMAL: 0;
244
+ readonly ADD: 1;
245
+ };
246
+ readonly TintModes: {
247
+ readonly MULTIPLY: 0;
248
+ readonly FILL: 1;
249
+ };
250
+ readonly Scale: {
251
+ readonly NONE: 0;
252
+ };
253
+ readonly Scenes: {
254
+ readonly PENDING: 0;
255
+ readonly INIT: 1;
256
+ readonly START: 2;
257
+ readonly LOADING: 3;
258
+ readonly CREATING: 4;
259
+ readonly RUNNING: 5;
260
+ readonly PAUSED: 6;
261
+ readonly SLEEPING: 7;
262
+ readonly SHUTDOWN: 8;
263
+ readonly DESTROYED: 9;
264
+ };
265
+ readonly Game: typeof Game;
266
+ readonly Scene: typeof Scene;
267
+ readonly Textures: {
268
+ readonly FilterMode: {
269
+ readonly LINEAR: 0;
270
+ readonly NEAREST: 1;
271
+ };
272
+ readonly Texture: typeof Texture;
273
+ readonly CanvasTexture: typeof CanvasTexture;
274
+ readonly Frame: typeof Frame;
275
+ readonly TextureManager: typeof TextureManager;
276
+ };
277
+ readonly Cameras: {
278
+ readonly Scene2D: {
279
+ readonly Camera: typeof Camera;
280
+ };
281
+ };
282
+ readonly GameObjects: {
283
+ readonly GameObject: typeof DisplayObject;
284
+ readonly Image: typeof ImageObject;
285
+ readonly MsdfIcon: typeof MsdfIconObject;
286
+ readonly NineSlice: typeof NineSliceObject;
287
+ readonly Panel: typeof PanelObject;
288
+ readonly TileSprite: typeof TileSpriteObject;
289
+ readonly Rectangle: typeof RectangleObject;
290
+ readonly Text: typeof TextObject;
291
+ readonly Graphics: typeof Graphics;
292
+ readonly Blitter: typeof BlitterObject;
293
+ readonly Container: typeof Container;
294
+ readonly CustomPass: typeof CustomPassObject;
295
+ };
296
+ readonly Loader: {
297
+ readonly LoaderPlugin: typeof LoaderPlugin;
298
+ };
299
+ readonly Display: {
300
+ readonly Canvas: {
301
+ readonly CanvasPool: {
302
+ readonly enableSmoothing: () => void;
303
+ };
304
+ };
305
+ };
306
+ };
307
+ export { AUTO, BLACK_RGB, type BlendMode, BlendModes, BlitterObject, type Bob$1 as Bob, CANVAS, Camera, CanvasTexture, Container, type ContainerFiltersShim, type CustomPassCallback, CustomPassObject, DisplayList, DisplayObject, type DisplayObjectType, type DisplaySemantics, type DisposableOwner, type EasingFn, type EasingName, Easings, EngineClock, type EngineClockSnapshot, EventEmitter, FilterMode, type FilterModeValue, type FlexAlign, type FlexContainerSpec, type FlexDir, type FlexItemRect, type FlexItemSpec, type FlexJustify, type FlexPadding, type FlexResult, Frame, Game, type GameConfig$1 as GameConfig, GameLoop, GameObjectFactory, type GlTextureHost, Graphics, HEX_MASK, ImageObject, type InputConfig, InputPlugin, type JoystickDpad, type JoystickDpadOptions, type JoystickState, type JoystickVector, type JoystickViewport, type JoystickZone, type JoystickZonePredicate, type JoystickZoneRect, JsonCache, KeyboardPlugin, LoaderPlugin, type Matrix2D, type MsdfIconConfig, MsdfIconObject, NineSliceObject, PanelObject, type PanelOpenSide, type PanelStyleConfig, Pointer, type PointerSample, type Rect2D, type RectClipMask, RectangleObject, Renderer2D, RendererGl, type RendererGlOptions, type RendererStats, type RgbaColor, SURFACE_BAND, Scale, ScaleManager, Scene, type SceneCtor, type SceneDigest, type SceneDigestActiveFocus, type SceneDigestEngineSandbox, type SceneDigestNode, type SceneDigestOptions, type SceneDigestOverlayStats, type SceneDigestSandbox, type SceneDigestSurfaceEntry, type SceneDigestSurfaceSource, type SceneDigestSurfaces, type SceneHostLike, type SceneInput, type SceneLifecycleStats, SceneManager, Scenes, type SpringHandle, type SpringOptions, type SpriteSheetConfig, Stage as default, type Stage2DCustomImageHandler, type StageRenderer, type SurfaceBand, type SurfaceBandName, type SurfaceBarrier, type SurfaceCancelContext, type SurfaceCancelDispatchResult, type SurfaceCancelResult, type SurfaceDomEntry, type SurfaceFocusContext, type SurfaceFocusDispatchResult, type SurfaceFocusResult, type SurfaceKeyContext, type SurfaceKeyDispatchResult, type SurfaceKeyResult, type SurfaceNodeInfo, type SurfaceNodeInput, type SurfaceScope, type SurfaceTree, TextObject, type TextStyleConfig, Texture, type TextureImageOptions, type TextureImageSource, TextureManager, TextureSource, TileSpriteObject, type TintMode, TintModes, type TweenHandle, TweenManager, type TweenOptions, type TweenStats, VirtualJoystick, type VirtualJoystickMode, type VirtualJoystickOptions, type VirtualJoystickStyle, WEBGL, WHITE_RGB, type WorldView2D, type WrapContainerSpec, type WrapItemRect, type WrapItemSpec, type WrapJustify, type WrapResult, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createMatrix2D, createSurfaceTree, isInJoystickZone, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ import { a as EventEmitter, c as Scale, d as WEBGL, f as WHITE_RGB, g as rgbToCss, h as parseColor, i as CANVAS, l as Scenes, m as packColorAbgr, n as BLACK_RGB, o as FilterMode, p as createMatrix2D, r as BlendModes, s as HEX_MASK, t as AUTO, u as TintModes } from "./types-ChGhuDNX.js";
2
+ import { A as TileSpriteObject, C as Graphics, D as PanelObject, E as NineSliceObject, F as TextureManager, I as TextureSource, M as CanvasTexture, N as Frame, O as RectangleObject, P as Texture, S as DisplayObject, T as MsdfIconObject, _ as SdfPanelBatcher, a as JsonCache, b as CustomPassObject, c as Scene, d as KeyboardPlugin, f as Pointer, g as MsdfIconBatcher, h as PixelAaBatcher, i as GameObjectFactory, j as Camera, k as TextObject, l as SceneManager, m as RendererGl, n as Game, o as LoaderPlugin, p as Renderer2D, r as GameLoop, s as ScaleManager, t as EngineClock, u as InputPlugin, v as BlitterObject, w as ImageObject, x as DisplayList, y as Container } from "./game-BHDcwovp.js";
3
+ import { buildSceneDigest, sanitizeTrackToken } from "./trace.js";
4
+ import { computeFlexLayout, computeWrapLayout, resolvePadding } from "./flex.js";
5
+ import { Easings, TweenManager } from "./tween.js";
6
+ import { VirtualJoystick, clampJoystickOrigin, computeJoystickVector, isInJoystickZone, pullJoystickOrigin, quantizeJoystickDpad } from "./joystick.js";
7
+ import { SURFACE_BAND, computeSurfaceDomZ, createSurfaceTree, resolveSurfacePriority, surfacePriorityToDomZ } from "./surfaces.js";
8
+ // src/index.ts
9
+ const Stage2D = {
10
+ AUTO: 0,
11
+ CANVAS: 1,
12
+ WEBGL: 2,
13
+ BlendModes,
14
+ TintModes,
15
+ Scale,
16
+ Scenes,
17
+ Game,
18
+ Scene,
19
+ Textures: {
20
+ FilterMode,
21
+ Texture,
22
+ CanvasTexture,
23
+ Frame,
24
+ TextureManager
25
+ },
26
+ Cameras: { Scene2D: { Camera } },
27
+ GameObjects: {
28
+ GameObject: DisplayObject,
29
+ Image: ImageObject,
30
+ MsdfIcon: MsdfIconObject,
31
+ NineSlice: NineSliceObject,
32
+ Panel: PanelObject,
33
+ TileSprite: TileSpriteObject,
34
+ Rectangle: RectangleObject,
35
+ Text: TextObject,
36
+ Graphics,
37
+ Blitter: BlitterObject,
38
+ Container,
39
+ CustomPass: CustomPassObject
40
+ },
41
+ Loader: { LoaderPlugin },
42
+ Display: { Canvas: { CanvasPool: { enableSmoothing() {} } } }
43
+ };
44
+ const Stage = Stage2D;
45
+ export { AUTO, BLACK_RGB, BlendModes, BlitterObject, CANVAS, Camera, CanvasTexture, Container, CustomPassObject, DisplayList, DisplayObject, Easings, EngineClock, EventEmitter, FilterMode, Frame, Game, GameLoop, GameObjectFactory, Graphics, HEX_MASK, ImageObject, InputPlugin, JsonCache, KeyboardPlugin, LoaderPlugin, MsdfIconBatcher, MsdfIconObject, NineSliceObject, PanelObject, PixelAaBatcher, Pointer, RectangleObject, Renderer2D, RendererGl, SURFACE_BAND, Scale, ScaleManager, Scene, SceneManager, Scenes, SdfPanelBatcher, Stage, Stage as default, Stage2D, TextObject, Texture, TextureManager, TextureSource, TileSpriteObject, TintModes, TweenManager, VirtualJoystick, WEBGL, WHITE_RGB, buildSceneDigest, clampJoystickOrigin, computeFlexLayout, computeJoystickVector, computeSurfaceDomZ, computeWrapLayout, createMatrix2D, createSurfaceTree, isInJoystickZone, packColorAbgr, parseColor, pullJoystickOrigin, quantizeJoystickDpad, resolvePadding, resolveSurfacePriority, rgbToCss, sanitizeTrackToken, surfacePriorityToDomZ };