@flare-engine/core 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/dist/index.mjs ADDED
@@ -0,0 +1,459 @@
1
+ // src/clock.ts
2
+ var Clock = class {
3
+ /** Unscaled delta time in seconds since last frame. */
4
+ rawDt = 0;
5
+ /** Scaled delta time in seconds (rawDt * timescale). */
6
+ dt = 0;
7
+ /** Fixed timestep in seconds for physics updates (default 1/60). */
8
+ fixedDt = 1 / 60;
9
+ /** Total elapsed time in seconds (scaled). */
10
+ elapsed = 0;
11
+ /** Smoothed frames per second. */
12
+ fps = 0;
13
+ /** Time scale multiplier. 1 = normal, 0 = paused, 0.5 = slow-mo. */
14
+ timescale = 1;
15
+ /** Current frame number (monotonically increasing). */
16
+ frame = 0;
17
+ schedules = [];
18
+ fpsAlpha = 0.9;
19
+ /** Called once per frame by the GameLoop with raw unscaled dt. */
20
+ update(rawDt) {
21
+ this.rawDt = rawDt;
22
+ this.dt = rawDt * this.timescale;
23
+ this.elapsed += this.dt;
24
+ this.frame++;
25
+ if (rawDt > 0) {
26
+ const instantFps = 1 / rawDt;
27
+ this.fps = this.fps === 0 ? instantFps : this.fps * this.fpsAlpha + instantFps * (1 - this.fpsAlpha);
28
+ }
29
+ this.tickSchedules(this.dt);
30
+ }
31
+ /** Schedule a one-shot callback after `delay` seconds (scaled time). */
32
+ schedule(delay, callback) {
33
+ const entry = { remaining: delay, callback, interval: 0 };
34
+ this.schedules.push(entry);
35
+ return () => {
36
+ const idx = this.schedules.indexOf(entry);
37
+ if (idx !== -1) this.schedules.splice(idx, 1);
38
+ };
39
+ }
40
+ /** Schedule a repeating callback every `interval` seconds (scaled time). */
41
+ repeat(interval, callback) {
42
+ const entry = { remaining: interval, callback, interval };
43
+ this.schedules.push(entry);
44
+ return () => {
45
+ const idx = this.schedules.indexOf(entry);
46
+ if (idx !== -1) this.schedules.splice(idx, 1);
47
+ };
48
+ }
49
+ /** Reset clock to initial state. */
50
+ reset() {
51
+ this.rawDt = 0;
52
+ this.dt = 0;
53
+ this.elapsed = 0;
54
+ this.fps = 0;
55
+ this.frame = 0;
56
+ this.timescale = 1;
57
+ this.schedules.length = 0;
58
+ }
59
+ tickSchedules(dt) {
60
+ for (let i = this.schedules.length - 1; i >= 0; i--) {
61
+ const entry = this.schedules[i];
62
+ entry.remaining -= dt;
63
+ if (entry.remaining <= 0) {
64
+ entry.callback();
65
+ if (entry.interval > 0) {
66
+ entry.remaining += entry.interval;
67
+ } else {
68
+ this.schedules.splice(i, 1);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ };
74
+
75
+ // src/game-loop.ts
76
+ import { Signal } from "@flare-engine/events";
77
+ var GameLoop = class {
78
+ clock = new Clock();
79
+ /** Fixed-timestep update (physics, deterministic logic). */
80
+ onFixedUpdate = new Signal();
81
+ /** Variable-timestep update (movement, AI, game logic). */
82
+ onUpdate = new Signal();
83
+ /** Runs after onUpdate (camera follow, post-processing logic). */
84
+ onLateUpdate = new Signal();
85
+ /** Runs before rendering. */
86
+ onPreRender = new Signal();
87
+ /** Runs after rendering. */
88
+ onPostRender = new Signal();
89
+ running = false;
90
+ paused = false;
91
+ accumulator = 0;
92
+ maxDt;
93
+ rafId = 0;
94
+ lastTime = 0;
95
+ /** External tick function — set this for testing or custom scheduling. */
96
+ tick;
97
+ /** External cancel function — paired with tick. */
98
+ cancelTick;
99
+ constructor(config) {
100
+ this.maxDt = config?.maxDt ?? 0.25;
101
+ if (config?.fixedDt !== void 0) {
102
+ this.clock.fixedDt = config.fixedDt;
103
+ }
104
+ }
105
+ /** Start the game loop. */
106
+ start() {
107
+ if (this.running) return;
108
+ this.running = true;
109
+ this.paused = false;
110
+ this.lastTime = 0;
111
+ this.accumulator = 0;
112
+ this.scheduleFrame();
113
+ }
114
+ /** Stop the game loop entirely and reset. */
115
+ stop() {
116
+ this.running = false;
117
+ this.paused = false;
118
+ if (this.rafId !== 0) {
119
+ const cancel = this.cancelTick ?? cancelAnimationFrame;
120
+ cancel(this.rafId);
121
+ this.rafId = 0;
122
+ }
123
+ }
124
+ /** Pause — signals stop firing but loop stays alive. */
125
+ pause() {
126
+ if (!this.running || this.paused) return;
127
+ this.paused = true;
128
+ }
129
+ /** Resume from pause. */
130
+ resume() {
131
+ if (!this.running || !this.paused) return;
132
+ this.paused = false;
133
+ this.lastTime = 0;
134
+ }
135
+ /** Whether the loop is currently running (started and not stopped). */
136
+ get isRunning() {
137
+ return this.running;
138
+ }
139
+ /** Whether the loop is paused. */
140
+ get isPaused() {
141
+ return this.paused;
142
+ }
143
+ /** Process a single frame. Exposed for testing. */
144
+ step(rawDt) {
145
+ if (this.paused) return;
146
+ const capped = Math.min(rawDt, this.maxDt);
147
+ this.clock.update(capped);
148
+ const dt = this.clock.dt;
149
+ const fixedDt = this.clock.fixedDt;
150
+ this.accumulator += dt;
151
+ while (this.accumulator >= fixedDt) {
152
+ this.onFixedUpdate.emit(fixedDt);
153
+ this.accumulator -= fixedDt;
154
+ }
155
+ this.onUpdate.emit(dt);
156
+ this.onLateUpdate.emit(dt);
157
+ this.onPreRender.emit();
158
+ this.onPostRender.emit();
159
+ }
160
+ scheduleFrame() {
161
+ const request = this.tick ?? requestAnimationFrame;
162
+ this.rafId = request((time) => {
163
+ if (!this.running) return;
164
+ if (this.lastTime === 0) {
165
+ this.lastTime = time;
166
+ this.scheduleFrame();
167
+ return;
168
+ }
169
+ const rawDt = (time - this.lastTime) / 1e3;
170
+ this.lastTime = time;
171
+ this.step(rawDt);
172
+ this.scheduleFrame();
173
+ });
174
+ }
175
+ };
176
+
177
+ // src/app-lifecycle.ts
178
+ import { Signal as Signal2 } from "@flare-engine/events";
179
+ var AppLifecycle = class {
180
+ /** Fires when app enters background. */
181
+ onBackground = new Signal2();
182
+ /** Fires when app returns to foreground. */
183
+ onForeground = new Signal2();
184
+ /** Fires on memory warning (RN-specific). */
185
+ onMemoryWarning = new Signal2();
186
+ loop;
187
+ wasRunningBeforeBackground = false;
188
+ constructor(loop) {
189
+ this.loop = loop;
190
+ }
191
+ /** Call when app goes to background. */
192
+ background() {
193
+ this.wasRunningBeforeBackground = this.loop.isRunning && !this.loop.isPaused;
194
+ if (this.wasRunningBeforeBackground) {
195
+ this.loop.pause();
196
+ }
197
+ this.onBackground.emit();
198
+ }
199
+ /** Call when app returns to foreground. */
200
+ foreground() {
201
+ if (this.wasRunningBeforeBackground) {
202
+ this.loop.resume();
203
+ }
204
+ this.onForeground.emit();
205
+ }
206
+ /** Call on memory warning. */
207
+ memoryWarning() {
208
+ this.onMemoryWarning.emit();
209
+ }
210
+ };
211
+
212
+ // src/screen.ts
213
+ import { Signal as Signal3 } from "@flare-engine/events";
214
+ var ScreenManager = class {
215
+ /** Design resolution width. */
216
+ designWidth;
217
+ /** Design resolution height. */
218
+ designHeight;
219
+ /** Current scale mode. */
220
+ scaleMode;
221
+ /** Device pixel ratio. */
222
+ pixelRatio = 1;
223
+ /** Safe area insets (top, right, bottom, left) in device pixels. */
224
+ safeArea = { x: 0, y: 0, width: 0, height: 0 };
225
+ /** Fires when screen dimensions change. */
226
+ onResize = new Signal3();
227
+ /** Computed scale factor X (design → screen). */
228
+ scaleX = 1;
229
+ /** Computed scale factor Y (design → screen). */
230
+ scaleY = 1;
231
+ /** Offset X in screen pixels (for letterboxing). */
232
+ offsetX = 0;
233
+ /** Offset Y in screen pixels (for letterboxing). */
234
+ offsetY = 0;
235
+ screenWidth = 0;
236
+ screenHeight = 0;
237
+ constructor(config) {
238
+ this.designWidth = config.designWidth;
239
+ this.designHeight = config.designHeight;
240
+ this.scaleMode = config.scaleMode ?? "fit";
241
+ }
242
+ safeInsetTop = 0;
243
+ safeInsetRight = 0;
244
+ safeInsetBottom = 0;
245
+ safeInsetLeft = 0;
246
+ /** Update with actual device screen dimensions. Call on mount and resize. */
247
+ resize(screenWidth, screenHeight, pixelRatio) {
248
+ this.screenWidth = screenWidth;
249
+ this.screenHeight = screenHeight;
250
+ if (pixelRatio !== void 0) this.pixelRatio = pixelRatio;
251
+ this.recalculate();
252
+ this.recalculateSafeArea();
253
+ this.onResize.emit();
254
+ }
255
+ /**
256
+ * Set safe-area insets in screen pixels. Call this from the RN host with values from
257
+ * `react-native-safe-area-context`. Populates `safeArea` as the usable region.
258
+ */
259
+ setSafeAreaInsets(top, right, bottom, left) {
260
+ this.safeInsetTop = top;
261
+ this.safeInsetRight = right;
262
+ this.safeInsetBottom = bottom;
263
+ this.safeInsetLeft = left;
264
+ this.recalculateSafeArea();
265
+ this.onResize.emit();
266
+ }
267
+ recalculateSafeArea() {
268
+ this.safeArea.x = this.safeInsetLeft;
269
+ this.safeArea.y = this.safeInsetTop;
270
+ this.safeArea.width = Math.max(0, this.screenWidth - this.safeInsetLeft - this.safeInsetRight);
271
+ this.safeArea.height = Math.max(
272
+ 0,
273
+ this.screenHeight - this.safeInsetTop - this.safeInsetBottom
274
+ );
275
+ }
276
+ /** Convert design-space point to screen-space. */
277
+ designToScreen(point) {
278
+ return {
279
+ x: point.x * this.scaleX + this.offsetX,
280
+ y: point.y * this.scaleY + this.offsetY
281
+ };
282
+ }
283
+ /** Convert screen-space point to design-space. */
284
+ screenToDesign(point) {
285
+ return {
286
+ x: (point.x - this.offsetX) / this.scaleX,
287
+ y: (point.y - this.offsetY) / this.scaleY
288
+ };
289
+ }
290
+ /** Viewport rect in design coordinates (visible area). */
291
+ get viewport() {
292
+ if (this.scaleMode === "fill") {
293
+ const visibleW = this.screenWidth / this.scaleX;
294
+ const visibleH = this.screenHeight / this.scaleY;
295
+ return {
296
+ x: (this.designWidth - visibleW) / 2,
297
+ y: (this.designHeight - visibleH) / 2,
298
+ width: visibleW,
299
+ height: visibleH
300
+ };
301
+ }
302
+ return { x: 0, y: 0, width: this.designWidth, height: this.designHeight };
303
+ }
304
+ recalculate() {
305
+ const ratioX = this.screenWidth / this.designWidth;
306
+ const ratioY = this.screenHeight / this.designHeight;
307
+ switch (this.scaleMode) {
308
+ case "fit": {
309
+ const scale = Math.min(ratioX, ratioY);
310
+ this.scaleX = scale;
311
+ this.scaleY = scale;
312
+ this.offsetX = (this.screenWidth - this.designWidth * scale) / 2;
313
+ this.offsetY = (this.screenHeight - this.designHeight * scale) / 2;
314
+ break;
315
+ }
316
+ case "fill": {
317
+ const scale = Math.max(ratioX, ratioY);
318
+ this.scaleX = scale;
319
+ this.scaleY = scale;
320
+ this.offsetX = (this.screenWidth - this.designWidth * scale) / 2;
321
+ this.offsetY = (this.screenHeight - this.designHeight * scale) / 2;
322
+ break;
323
+ }
324
+ case "stretch": {
325
+ this.scaleX = ratioX;
326
+ this.scaleY = ratioY;
327
+ this.offsetX = 0;
328
+ this.offsetY = 0;
329
+ break;
330
+ }
331
+ }
332
+ }
333
+ };
334
+
335
+ // src/coroutine.ts
336
+ var CoroutineManager = class {
337
+ coroutines = [];
338
+ /** Start a new coroutine. Returns a handle to check status or cancel. */
339
+ start(gen) {
340
+ const state = {
341
+ gen,
342
+ waitTime: 0,
343
+ waitingForPromise: false,
344
+ done: false
345
+ };
346
+ this.coroutines.push(state);
347
+ this.advance(state);
348
+ const handle = {
349
+ get done() {
350
+ return state.done;
351
+ },
352
+ cancel() {
353
+ state.done = true;
354
+ }
355
+ };
356
+ return handle;
357
+ }
358
+ /** Update all running coroutines. Call once per frame with scaled dt. */
359
+ update(dt) {
360
+ for (let i = this.coroutines.length - 1; i >= 0; i--) {
361
+ const state = this.coroutines[i];
362
+ if (state.done) {
363
+ this.coroutines.splice(i, 1);
364
+ continue;
365
+ }
366
+ if (state.waitingForPromise) continue;
367
+ if (state.waitTime > 0) {
368
+ state.waitTime -= dt;
369
+ if (state.waitTime > 0) continue;
370
+ }
371
+ this.advance(state);
372
+ if (state.done) {
373
+ this.coroutines.splice(i, 1);
374
+ }
375
+ }
376
+ }
377
+ /** Cancel all running coroutines. */
378
+ clear() {
379
+ for (const state of this.coroutines) {
380
+ state.done = true;
381
+ }
382
+ this.coroutines.length = 0;
383
+ }
384
+ /** Number of active coroutines. */
385
+ get count() {
386
+ return this.coroutines.length;
387
+ }
388
+ advance(state) {
389
+ const result = state.gen.next();
390
+ if (result.done) {
391
+ state.done = true;
392
+ return;
393
+ }
394
+ const value = result.value;
395
+ if (typeof value === "number") {
396
+ state.waitTime = value;
397
+ } else if (value instanceof Promise) {
398
+ state.waitingForPromise = true;
399
+ value.then(
400
+ () => {
401
+ state.waitingForPromise = false;
402
+ },
403
+ () => {
404
+ state.done = true;
405
+ }
406
+ );
407
+ }
408
+ }
409
+ };
410
+
411
+ // src/pool.ts
412
+ var Pool = class {
413
+ items = [];
414
+ factory;
415
+ resetFn;
416
+ /**
417
+ * @param factory Function to create a new instance.
418
+ * @param reset Optional function to reset an object before reuse.
419
+ */
420
+ constructor(factory, reset) {
421
+ this.factory = factory;
422
+ this.resetFn = reset;
423
+ }
424
+ /** Get an object from the pool (or create a new one). */
425
+ acquire() {
426
+ if (this.items.length > 0) {
427
+ return this.items.pop();
428
+ }
429
+ return this.factory();
430
+ }
431
+ /** Return an object to the pool. Calls reset if configured. */
432
+ release(item) {
433
+ if (this.resetFn) this.resetFn(item);
434
+ this.items.push(item);
435
+ }
436
+ /** Pre-allocate objects into the pool. */
437
+ prewarm(count) {
438
+ for (let i = 0; i < count; i++) {
439
+ this.items.push(this.factory());
440
+ }
441
+ }
442
+ /** Number of available objects in the pool. */
443
+ get available() {
444
+ return this.items.length;
445
+ }
446
+ /** Clear all pooled objects. */
447
+ clear() {
448
+ this.items.length = 0;
449
+ }
450
+ };
451
+ export {
452
+ AppLifecycle,
453
+ Clock,
454
+ CoroutineManager,
455
+ GameLoop,
456
+ Pool,
457
+ ScreenManager
458
+ };
459
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/clock.ts","../src/game-loop.ts","../src/app-lifecycle.ts","../src/screen.ts","../src/coroutine.ts","../src/pool.ts"],"sourcesContent":["/**\n * Clock tracks frame timing: delta time, elapsed time, fps, timescale.\n * One instance per GameLoop. Updated once per frame.\n */\n\n/** Scheduled callback entry. */\ninterface ScheduleEntry {\n remaining: number;\n callback: () => void;\n interval: number; // 0 = one-shot\n}\n\nexport class Clock {\n /** Unscaled delta time in seconds since last frame. */\n rawDt = 0;\n\n /** Scaled delta time in seconds (rawDt * timescale). */\n dt = 0;\n\n /** Fixed timestep in seconds for physics updates (default 1/60). */\n fixedDt = 1 / 60;\n\n /** Total elapsed time in seconds (scaled). */\n elapsed = 0;\n\n /** Smoothed frames per second. */\n fps = 0;\n\n /** Time scale multiplier. 1 = normal, 0 = paused, 0.5 = slow-mo. */\n timescale = 1;\n\n /** Current frame number (monotonically increasing). */\n frame = 0;\n\n private schedules: ScheduleEntry[] = [];\n private fpsAlpha = 0.9;\n\n /** Called once per frame by the GameLoop with raw unscaled dt. */\n update(rawDt: number): void {\n this.rawDt = rawDt;\n this.dt = rawDt * this.timescale;\n this.elapsed += this.dt;\n this.frame++;\n\n // Exponential moving average FPS\n if (rawDt > 0) {\n const instantFps = 1 / rawDt;\n this.fps =\n this.fps === 0 ? instantFps : this.fps * this.fpsAlpha + instantFps * (1 - this.fpsAlpha);\n }\n\n // Process scheduled callbacks\n this.tickSchedules(this.dt);\n }\n\n /** Schedule a one-shot callback after `delay` seconds (scaled time). */\n schedule(delay: number, callback: () => void): () => void {\n const entry: ScheduleEntry = { remaining: delay, callback, interval: 0 };\n this.schedules.push(entry);\n return () => {\n const idx = this.schedules.indexOf(entry);\n if (idx !== -1) this.schedules.splice(idx, 1);\n };\n }\n\n /** Schedule a repeating callback every `interval` seconds (scaled time). */\n repeat(interval: number, callback: () => void): () => void {\n const entry: ScheduleEntry = { remaining: interval, callback, interval };\n this.schedules.push(entry);\n return () => {\n const idx = this.schedules.indexOf(entry);\n if (idx !== -1) this.schedules.splice(idx, 1);\n };\n }\n\n /** Reset clock to initial state. */\n reset(): void {\n this.rawDt = 0;\n this.dt = 0;\n this.elapsed = 0;\n this.fps = 0;\n this.frame = 0;\n this.timescale = 1;\n this.schedules.length = 0;\n }\n\n private tickSchedules(dt: number): void {\n for (let i = this.schedules.length - 1; i >= 0; i--) {\n const entry = this.schedules[i]!;\n entry.remaining -= dt;\n if (entry.remaining <= 0) {\n entry.callback();\n if (entry.interval > 0) {\n entry.remaining += entry.interval;\n } else {\n this.schedules.splice(i, 1);\n }\n }\n }\n }\n}\n","import { Signal } from '@flare-engine/events';\nimport { Clock } from './clock.js';\n\n/** Configuration for the game loop. */\nexport interface GameLoopConfig {\n /** Fixed timestep in seconds (default 1/60). */\n fixedDt?: number;\n /** Maximum raw dt cap in seconds to prevent spiral of death (default 0.25). */\n maxDt?: number;\n}\n\n/**\n * GameLoop drives the update cycle using fixed + variable timestep.\n *\n * Fixed updates run at a constant rate (accumulator pattern).\n * Variable updates run once per frame with the actual dt.\n */\nexport class GameLoop {\n readonly clock = new Clock();\n\n /** Fixed-timestep update (physics, deterministic logic). */\n readonly onFixedUpdate = new Signal<number>();\n /** Variable-timestep update (movement, AI, game logic). */\n readonly onUpdate = new Signal<number>();\n /** Runs after onUpdate (camera follow, post-processing logic). */\n readonly onLateUpdate = new Signal<number>();\n /** Runs before rendering. */\n readonly onPreRender = new Signal<void>();\n /** Runs after rendering. */\n readonly onPostRender = new Signal<void>();\n\n private running = false;\n private paused = false;\n private accumulator = 0;\n private maxDt: number;\n private rafId = 0;\n private lastTime = 0;\n\n /** External tick function — set this for testing or custom scheduling. */\n tick: ((callback: (time: number) => void) => number) | undefined;\n /** External cancel function — paired with tick. */\n cancelTick: ((id: number) => void) | undefined;\n\n constructor(config?: GameLoopConfig) {\n this.maxDt = config?.maxDt ?? 0.25;\n if (config?.fixedDt !== undefined) {\n this.clock.fixedDt = config.fixedDt;\n }\n }\n\n /** Start the game loop. */\n start(): void {\n if (this.running) return;\n this.running = true;\n this.paused = false;\n this.lastTime = 0;\n this.accumulator = 0;\n this.scheduleFrame();\n }\n\n /** Stop the game loop entirely and reset. */\n stop(): void {\n this.running = false;\n this.paused = false;\n if (this.rafId !== 0) {\n const cancel = this.cancelTick ?? cancelAnimationFrame;\n cancel(this.rafId);\n this.rafId = 0;\n }\n }\n\n /** Pause — signals stop firing but loop stays alive. */\n pause(): void {\n if (!this.running || this.paused) return;\n this.paused = true;\n }\n\n /** Resume from pause. */\n resume(): void {\n if (!this.running || !this.paused) return;\n this.paused = false;\n this.lastTime = 0; // Reset so next frame doesn't have a huge dt\n }\n\n /** Whether the loop is currently running (started and not stopped). */\n get isRunning(): boolean {\n return this.running;\n }\n\n /** Whether the loop is paused. */\n get isPaused(): boolean {\n return this.paused;\n }\n\n /** Process a single frame. Exposed for testing. */\n step(rawDt: number): void {\n if (this.paused) return;\n\n // Cap the dt to avoid spiral of death\n const capped = Math.min(rawDt, this.maxDt);\n this.clock.update(capped);\n\n const dt = this.clock.dt;\n const fixedDt = this.clock.fixedDt;\n\n // Fixed update accumulator\n this.accumulator += dt;\n while (this.accumulator >= fixedDt) {\n this.onFixedUpdate.emit(fixedDt);\n this.accumulator -= fixedDt;\n }\n\n // Variable update\n this.onUpdate.emit(dt);\n this.onLateUpdate.emit(dt);\n\n // Render\n this.onPreRender.emit();\n this.onPostRender.emit();\n }\n\n private scheduleFrame(): void {\n const request = this.tick ?? requestAnimationFrame;\n this.rafId = request((time: number) => {\n if (!this.running) return;\n\n if (this.lastTime === 0) {\n this.lastTime = time;\n this.scheduleFrame();\n return;\n }\n\n const rawDt = (time - this.lastTime) / 1000;\n this.lastTime = time;\n\n this.step(rawDt);\n this.scheduleFrame();\n });\n }\n}\n","import { Signal } from '@flare-engine/events';\nimport type { GameLoop } from './game-loop.js';\n\n/**\n * AppLifecycle bridges React Native AppState to the game loop.\n *\n * - Auto-pauses the loop when app goes to background\n * - Auto-resumes when app returns to foreground\n * - Caps dt on resume to prevent huge time jumps\n *\n * In non-RN environments (tests, web), use the manual methods.\n */\nexport class AppLifecycle {\n /** Fires when app enters background. */\n readonly onBackground = new Signal<void>();\n /** Fires when app returns to foreground. */\n readonly onForeground = new Signal<void>();\n /** Fires on memory warning (RN-specific). */\n readonly onMemoryWarning = new Signal<void>();\n\n private loop: GameLoop;\n private wasRunningBeforeBackground = false;\n\n constructor(loop: GameLoop) {\n this.loop = loop;\n }\n\n /** Call when app goes to background. */\n background(): void {\n this.wasRunningBeforeBackground = this.loop.isRunning && !this.loop.isPaused;\n if (this.wasRunningBeforeBackground) {\n this.loop.pause();\n }\n this.onBackground.emit();\n }\n\n /** Call when app returns to foreground. */\n foreground(): void {\n if (this.wasRunningBeforeBackground) {\n this.loop.resume();\n }\n this.onForeground.emit();\n }\n\n /** Call on memory warning. */\n memoryWarning(): void {\n this.onMemoryWarning.emit();\n }\n}\n","import { Signal } from '@flare-engine/events';\nimport type { Rect, Vec2 } from '@flare-engine/math';\n\n/** Scale mode for mapping design resolution to device screen. */\nexport type ScaleMode = 'fit' | 'fill' | 'stretch';\n\n/** Screen configuration. */\nexport interface ScreenConfig {\n /** Design resolution width in logical pixels. */\n designWidth: number;\n /** Design resolution height in logical pixels. */\n designHeight: number;\n /** How to fit design resolution to device (default: 'fit'). */\n scaleMode?: ScaleMode;\n}\n\n/**\n * ScreenManager maps a fixed design resolution to the actual device screen.\n *\n * - FIT: letterbox (scale to fit, black bars)\n * - FILL: crop (scale to fill, content cropped)\n * - STRETCH: distort (stretch to fill, aspect ratio distorted)\n */\nexport class ScreenManager {\n /** Design resolution width. */\n readonly designWidth: number;\n /** Design resolution height. */\n readonly designHeight: number;\n /** Current scale mode. */\n scaleMode: ScaleMode;\n\n /** Device pixel ratio. */\n pixelRatio = 1;\n\n /** Safe area insets (top, right, bottom, left) in device pixels. */\n safeArea: Rect = { x: 0, y: 0, width: 0, height: 0 };\n\n /** Fires when screen dimensions change. */\n readonly onResize = new Signal<void>();\n\n /** Computed scale factor X (design → screen). */\n scaleX = 1;\n /** Computed scale factor Y (design → screen). */\n scaleY = 1;\n /** Offset X in screen pixels (for letterboxing). */\n offsetX = 0;\n /** Offset Y in screen pixels (for letterboxing). */\n offsetY = 0;\n\n private screenWidth = 0;\n private screenHeight = 0;\n\n constructor(config: ScreenConfig) {\n this.designWidth = config.designWidth;\n this.designHeight = config.designHeight;\n this.scaleMode = config.scaleMode ?? 'fit';\n }\n\n private safeInsetTop = 0;\n private safeInsetRight = 0;\n private safeInsetBottom = 0;\n private safeInsetLeft = 0;\n\n /** Update with actual device screen dimensions. Call on mount and resize. */\n resize(screenWidth: number, screenHeight: number, pixelRatio?: number): void {\n this.screenWidth = screenWidth;\n this.screenHeight = screenHeight;\n if (pixelRatio !== undefined) this.pixelRatio = pixelRatio;\n this.recalculate();\n this.recalculateSafeArea();\n this.onResize.emit();\n }\n\n /**\n * Set safe-area insets in screen pixels. Call this from the RN host with values from\n * `react-native-safe-area-context`. Populates `safeArea` as the usable region.\n */\n setSafeAreaInsets(top: number, right: number, bottom: number, left: number): void {\n this.safeInsetTop = top;\n this.safeInsetRight = right;\n this.safeInsetBottom = bottom;\n this.safeInsetLeft = left;\n this.recalculateSafeArea();\n this.onResize.emit();\n }\n\n private recalculateSafeArea(): void {\n this.safeArea.x = this.safeInsetLeft;\n this.safeArea.y = this.safeInsetTop;\n this.safeArea.width = Math.max(0, this.screenWidth - this.safeInsetLeft - this.safeInsetRight);\n this.safeArea.height = Math.max(\n 0,\n this.screenHeight - this.safeInsetTop - this.safeInsetBottom,\n );\n }\n\n /** Convert design-space point to screen-space. */\n designToScreen(point: Vec2): Vec2 {\n return {\n x: point.x * this.scaleX + this.offsetX,\n y: point.y * this.scaleY + this.offsetY,\n };\n }\n\n /** Convert screen-space point to design-space. */\n screenToDesign(point: Vec2): Vec2 {\n return {\n x: (point.x - this.offsetX) / this.scaleX,\n y: (point.y - this.offsetY) / this.scaleY,\n };\n }\n\n /** Viewport rect in design coordinates (visible area). */\n get viewport(): Rect {\n if (this.scaleMode === 'fill') {\n // In fill mode, the visible area is smaller than design\n const visibleW = this.screenWidth / this.scaleX;\n const visibleH = this.screenHeight / this.scaleY;\n return {\n x: (this.designWidth - visibleW) / 2,\n y: (this.designHeight - visibleH) / 2,\n width: visibleW,\n height: visibleH,\n };\n }\n return { x: 0, y: 0, width: this.designWidth, height: this.designHeight };\n }\n\n private recalculate(): void {\n const ratioX = this.screenWidth / this.designWidth;\n const ratioY = this.screenHeight / this.designHeight;\n\n switch (this.scaleMode) {\n case 'fit': {\n const scale = Math.min(ratioX, ratioY);\n this.scaleX = scale;\n this.scaleY = scale;\n this.offsetX = (this.screenWidth - this.designWidth * scale) / 2;\n this.offsetY = (this.screenHeight - this.designHeight * scale) / 2;\n break;\n }\n case 'fill': {\n const scale = Math.max(ratioX, ratioY);\n this.scaleX = scale;\n this.scaleY = scale;\n this.offsetX = (this.screenWidth - this.designWidth * scale) / 2;\n this.offsetY = (this.screenHeight - this.designHeight * scale) / 2;\n break;\n }\n case 'stretch': {\n this.scaleX = ratioX;\n this.scaleY = ratioY;\n this.offsetX = 0;\n this.offsetY = 0;\n break;\n }\n }\n }\n}\n","/**\n * Generator-based coroutines for game logic.\n *\n * - yield number → wait N seconds (scaled time)\n * - yield undefined → wait 1 frame\n * - yield Promise → wait until resolved\n */\n\n/** A running coroutine handle. */\nexport interface CoroutineHandle {\n /** Whether the coroutine has completed or been cancelled. */\n readonly done: boolean;\n /** Cancel the coroutine. It will not resume. */\n cancel(): void;\n}\n\n/** Yield type for coroutine generators. */\nexport type CoroutineYield = number | undefined | Promise<unknown>;\n\n/** A coroutine generator function. */\nexport type CoroutineGenerator = Generator<CoroutineYield, void, unknown>;\n\ninterface CoroutineState {\n gen: CoroutineGenerator;\n waitTime: number;\n waitingForPromise: boolean;\n done: boolean;\n}\n\n/**\n * CoroutineManager runs generator-based coroutines.\n * Call update(dt) each frame to advance all active coroutines.\n */\nexport class CoroutineManager {\n private coroutines: CoroutineState[] = [];\n\n /** Start a new coroutine. Returns a handle to check status or cancel. */\n start(gen: CoroutineGenerator): CoroutineHandle {\n const state: CoroutineState = {\n gen,\n waitTime: 0,\n waitingForPromise: false,\n done: false,\n };\n this.coroutines.push(state);\n\n // Advance to first yield immediately\n this.advance(state);\n\n const handle: CoroutineHandle = {\n get done() {\n return state.done;\n },\n cancel() {\n state.done = true;\n },\n };\n return handle;\n }\n\n /** Update all running coroutines. Call once per frame with scaled dt. */\n update(dt: number): void {\n for (let i = this.coroutines.length - 1; i >= 0; i--) {\n const state = this.coroutines[i]!;\n if (state.done) {\n this.coroutines.splice(i, 1);\n continue;\n }\n\n if (state.waitingForPromise) continue;\n\n if (state.waitTime > 0) {\n state.waitTime -= dt;\n if (state.waitTime > 0) continue;\n }\n\n this.advance(state);\n\n if (state.done) {\n this.coroutines.splice(i, 1);\n }\n }\n }\n\n /** Cancel all running coroutines. */\n clear(): void {\n for (const state of this.coroutines) {\n state.done = true;\n }\n this.coroutines.length = 0;\n }\n\n /** Number of active coroutines. */\n get count(): number {\n return this.coroutines.length;\n }\n\n private advance(state: CoroutineState): void {\n const result = state.gen.next();\n if (result.done) {\n state.done = true;\n return;\n }\n\n const value = result.value;\n if (typeof value === 'number') {\n state.waitTime = value;\n } else if (value instanceof Promise) {\n state.waitingForPromise = true;\n value.then(\n () => {\n state.waitingForPromise = false;\n },\n () => {\n // On rejection, stop the coroutine\n state.done = true;\n },\n );\n }\n // undefined → wait 1 frame (will advance next update)\n }\n}\n","/**\n * Generic object pool for zero-alloc gameplay.\n *\n * - acquire() returns a recycled or newly created object\n * - release(obj) returns it to the pool\n * - prewarm(count) pre-allocates objects\n */\nexport class Pool<T> {\n private items: T[] = [];\n private factory: () => T;\n private resetFn: ((item: T) => void) | undefined;\n\n /**\n * @param factory Function to create a new instance.\n * @param reset Optional function to reset an object before reuse.\n */\n constructor(factory: () => T, reset?: (item: T) => void) {\n this.factory = factory;\n this.resetFn = reset;\n }\n\n /** Get an object from the pool (or create a new one). */\n acquire(): T {\n if (this.items.length > 0) {\n return this.items.pop()!;\n }\n return this.factory();\n }\n\n /** Return an object to the pool. Calls reset if configured. */\n release(item: T): void {\n if (this.resetFn) this.resetFn(item);\n this.items.push(item);\n }\n\n /** Pre-allocate objects into the pool. */\n prewarm(count: number): void {\n for (let i = 0; i < count; i++) {\n this.items.push(this.factory());\n }\n }\n\n /** Number of available objects in the pool. */\n get available(): number {\n return this.items.length;\n }\n\n /** Clear all pooled objects. */\n clear(): void {\n this.items.length = 0;\n }\n}\n"],"mappings":";AAYO,IAAM,QAAN,MAAY;AAAA;AAAA,EAEjB,QAAQ;AAAA;AAAA,EAGR,KAAK;AAAA;AAAA,EAGL,UAAU,IAAI;AAAA;AAAA,EAGd,UAAU;AAAA;AAAA,EAGV,MAAM;AAAA;AAAA,EAGN,YAAY;AAAA;AAAA,EAGZ,QAAQ;AAAA,EAEA,YAA6B,CAAC;AAAA,EAC9B,WAAW;AAAA;AAAA,EAGnB,OAAO,OAAqB;AAC1B,SAAK,QAAQ;AACb,SAAK,KAAK,QAAQ,KAAK;AACvB,SAAK,WAAW,KAAK;AACrB,SAAK;AAGL,QAAI,QAAQ,GAAG;AACb,YAAM,aAAa,IAAI;AACvB,WAAK,MACH,KAAK,QAAQ,IAAI,aAAa,KAAK,MAAM,KAAK,WAAW,cAAc,IAAI,KAAK;AAAA,IACpF;AAGA,SAAK,cAAc,KAAK,EAAE;AAAA,EAC5B;AAAA;AAAA,EAGA,SAAS,OAAe,UAAkC;AACxD,UAAM,QAAuB,EAAE,WAAW,OAAO,UAAU,UAAU,EAAE;AACvE,SAAK,UAAU,KAAK,KAAK;AACzB,WAAO,MAAM;AACX,YAAM,MAAM,KAAK,UAAU,QAAQ,KAAK;AACxC,UAAI,QAAQ,GAAI,MAAK,UAAU,OAAO,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AAAA;AAAA,EAGA,OAAO,UAAkB,UAAkC;AACzD,UAAM,QAAuB,EAAE,WAAW,UAAU,UAAU,SAAS;AACvE,SAAK,UAAU,KAAK,KAAK;AACzB,WAAO,MAAM;AACX,YAAM,MAAM,KAAK,UAAU,QAAQ,KAAK;AACxC,UAAI,QAAQ,GAAI,MAAK,UAAU,OAAO,KAAK,CAAC;AAAA,IAC9C;AAAA,EACF;AAAA;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AK,MAAM,SAAS,GAAG;AACzB,aAAO,KAAK,MAAM,IAAI;AAAA,IACxB;AACA,WAAO,KAAK,QAAQ;AAAA,EACtB;AAAA;AAAA,EAGA,QAAQ,MAAe;AACrB,QAAI,KAAK,QAAS,MAAK,QAAQ,IAAI;AACnC,SAAK,MAAM,KAAK,IAAI;AAAA,EACtB;AAAA;AAAA,EAGA,QAAQ,OAAqB;AAC3B,aAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAC9B,WAAK,MAAM,KAAK,KAAK,QAAQ,CAAC;AAAA,IAChC;AAAA,EACF;AAAA;AAAA,EAGA,IAAI,YAAoB;AACtB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA;AAAA,EAGA,QAAc;AACZ,SAAK,MAAM,SAAS;AAAA,EACtB;AACF;","names":["Signal","Signal"]}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@flare-engine/core",
3
+ "version": "0.1.0",
4
+ "description": "GameLoop, Clock, AppLifecycle, Pool, Coroutines",
5
+ "keywords": ["flare-engine", "game-loop", "coroutines", "pool"],
6
+ "license": "MIT",
7
+ "author": "Grzegorz Otto",
8
+ "homepage": "https://github.com/grzott/flare-engine#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/grzott/flare-engine/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/grzott/flare-engine.git",
15
+ "directory": "packages/core"
16
+ },
17
+ "main": "dist/index.js",
18
+ "module": "dist/index.mjs",
19
+ "types": "dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.mjs",
24
+ "require": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": ["dist", "README.md", "LICENSE"],
28
+ "scripts": {
29
+ "build": "tsup",
30
+ "test": "bun test",
31
+ "lint": "biome check src/",
32
+ "typecheck": "tsc --noEmit"
33
+ },
34
+ "dependencies": {
35
+ "@flare-engine/math": "^0.1.0",
36
+ "@flare-engine/events": "^0.1.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "restricted",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "sideEffects": false
43
+ }