@flighthq/clock 0.5.1-next.1450.5738463 → 0.5.1-next.1467.7e2fc7d
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/README.md +2 -2
- package/dist/clock.d.ts +1 -1
- package/dist/clock.d.ts.map +1 -1
- package/dist/clock.js +6 -6
- package/dist/clock.js.map +1 -1
- package/package.json +4 -4
- package/src/clock.test.ts +32 -32
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/clock`. The `@flight
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/clock@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/clock@0.5.1-next.1467.7e2fc7d](https://github.com/flighthq/flight/tree/7e2fc7df5378313ceaf21ba8d6ef39cc18a6f4ad/packages/clock)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/7e2fc7df5378313ceaf21ba8d6ef39cc18a6f4ad/LICENSE.md)
|
package/dist/clock.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Clock, ClockOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function addClockChild(parent: Clock, child: Clock): void;
|
|
3
|
-
export declare function advanceClock(clock: Clock,
|
|
3
|
+
export declare function advanceClock(clock: Clock, deltaTime: number): void;
|
|
4
4
|
export declare function createChildClock(parent: Clock, options?: Readonly<ClockOptions>): Clock;
|
|
5
5
|
export declare function createClock(options?: Readonly<ClockOptions>): Clock;
|
|
6
6
|
export declare function disposeClock(clock: Clock): void;
|
package/dist/clock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../src/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,CAOxE;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE7C;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAKlE;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAG7C;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAE9C;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/D"}
|
package/dist/clock.js
CHANGED
|
@@ -10,14 +10,14 @@ export function addClockChild(parent, child) {
|
|
|
10
10
|
child.parent = parent;
|
|
11
11
|
parent.children.push(child);
|
|
12
12
|
}
|
|
13
|
-
// Advances a clock tree by one step. `
|
|
13
|
+
// Advances a clock tree by one step. `deltaTime` is the real elapsed milliseconds for a root clock (the
|
|
14
14
|
// value the frame loop supplies); the cascade feeds each child its parent's already-scaled delta. Each
|
|
15
|
-
// clock's scaled delta is `paused ? 0 :
|
|
15
|
+
// clock's scaled delta is `paused ? 0 : deltaTime * scale`; that becomes its deltaTime, accumulates
|
|
16
16
|
// into elapsed, emits its (opt-in) onTick, and drives its children — so scale and pause compose down the
|
|
17
17
|
// whole subtree in one pass. Pre-order: a clock's onTick fires before its children advance. Call once per
|
|
18
|
-
// frame on the root: advanceClock(root,
|
|
19
|
-
export function advanceClock(clock,
|
|
20
|
-
const scaledDelta = clock.paused ? 0 :
|
|
18
|
+
// frame on the root: advanceClock(root, dtMs).
|
|
19
|
+
export function advanceClock(clock, deltaTime) {
|
|
20
|
+
const scaledDelta = clock.paused ? 0 : deltaTime * clock.scale;
|
|
21
21
|
clock.deltaTime = scaledDelta;
|
|
22
22
|
clock.elapsed += scaledDelta;
|
|
23
23
|
if (clock.onTick !== null)
|
|
@@ -72,7 +72,7 @@ export function getClockParent(clock) {
|
|
|
72
72
|
return clock.parent;
|
|
73
73
|
}
|
|
74
74
|
// Allocates a root clock (no parent). Defaults to realtime and running; pass options to start scaled or
|
|
75
|
-
// paused. Drive it each frame with advanceClock(clock,
|
|
75
|
+
// paused. Drive it each frame with advanceClock(clock, dtMs).
|
|
76
76
|
export function initializeClock(out, options) {
|
|
77
77
|
out.scale = options?.scale ?? 1;
|
|
78
78
|
out.paused = options?.paused ?? false;
|
package/dist/clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGrE,sGAAsG;AACtG,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,MAAa,EAAE,KAAY;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,gBAAgB,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../src/clock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGrE,sGAAsG;AACtG,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,MAAa,EAAE,KAAY;IACvD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO;IACpC,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;QAAE,gBAAgB,CA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C,KAAY;IACtC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;AACvB,CAAC;AAED,wGAAwG;AACxG,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAAC,KAAY,EAAE,KAAa;IACvD,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/clock",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1467.7e2fc7d",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/signals": "0.5.1-next.
|
|
43
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1467.7e2fc7d",
|
|
42
|
+
"@flighthq/signals": "0.5.1-next.1467.7e2fc7d",
|
|
43
|
+
"@flighthq/types": "0.5.1-next.1467.7e2fc7d"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
package/src/clock.test.ts
CHANGED
|
@@ -50,24 +50,24 @@ describe('addClockChild', () => {
|
|
|
50
50
|
describe('advanceClock', () => {
|
|
51
51
|
it('sets deltaTime to the real delta and accumulates elapsed on a realtime root', () => {
|
|
52
52
|
const clock = createClock();
|
|
53
|
-
advanceClock(clock,
|
|
54
|
-
expect(clock.deltaTime).toBe(
|
|
55
|
-
expect(clock.elapsed).toBe(
|
|
56
|
-
advanceClock(clock,
|
|
57
|
-
expect(clock.deltaTime).toBe(
|
|
58
|
-
expect(clock.elapsed).toBe(
|
|
53
|
+
advanceClock(clock, 500);
|
|
54
|
+
expect(clock.deltaTime).toBe(500);
|
|
55
|
+
expect(clock.elapsed).toBe(500);
|
|
56
|
+
advanceClock(clock, 250);
|
|
57
|
+
expect(clock.deltaTime).toBe(250);
|
|
58
|
+
expect(clock.elapsed).toBe(750);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('applies the local scale', () => {
|
|
62
62
|
const clock = createClock({ scale: 2 });
|
|
63
|
-
advanceClock(clock,
|
|
64
|
-
expect(clock.deltaTime).toBe(
|
|
65
|
-
expect(clock.elapsed).toBe(
|
|
63
|
+
advanceClock(clock, 1000);
|
|
64
|
+
expect(clock.deltaTime).toBe(2000);
|
|
65
|
+
expect(clock.elapsed).toBe(2000);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it('feeds a zero delta while paused, freezing elapsed', () => {
|
|
69
69
|
const clock = createClock({ paused: true });
|
|
70
|
-
advanceClock(clock,
|
|
70
|
+
advanceClock(clock, 1000);
|
|
71
71
|
expect(clock.deltaTime).toBe(0);
|
|
72
72
|
expect(clock.elapsed).toBe(0);
|
|
73
73
|
});
|
|
@@ -76,26 +76,26 @@ describe('advanceClock', () => {
|
|
|
76
76
|
const grandparent = createClock({ scale: 2 });
|
|
77
77
|
const parent = createChildClock(grandparent, { scale: 3 });
|
|
78
78
|
const child = createChildClock(parent, { scale: 0.5 });
|
|
79
|
-
advanceClock(grandparent,
|
|
80
|
-
expect(grandparent.deltaTime).toBe(
|
|
81
|
-
expect(parent.deltaTime).toBe(
|
|
82
|
-
expect(child.deltaTime).toBe(
|
|
83
|
-
expect(child.elapsed).toBe(
|
|
79
|
+
advanceClock(grandparent, 1000);
|
|
80
|
+
expect(grandparent.deltaTime).toBe(2000); // 1000 * 2
|
|
81
|
+
expect(parent.deltaTime).toBe(6000); // 2000 * 3
|
|
82
|
+
expect(child.deltaTime).toBe(3000); // 6000 * 0.5
|
|
83
|
+
expect(child.elapsed).toBe(3000);
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('composes scale down the hierarchy — a child rate is the product of the chain', () => {
|
|
87
87
|
const parent = createClock({ scale: 2 });
|
|
88
88
|
const child = createChildClock(parent, { scale: 0.5 });
|
|
89
|
-
advanceClock(parent,
|
|
90
|
-
expect(parent.deltaTime).toBe(
|
|
91
|
-
expect(child.deltaTime).toBe(
|
|
92
|
-
expect(child.elapsed).toBe(
|
|
89
|
+
advanceClock(parent, 1000);
|
|
90
|
+
expect(parent.deltaTime).toBe(2000);
|
|
91
|
+
expect(child.deltaTime).toBe(1000); // 1000 * 2 * 0.5
|
|
92
|
+
expect(child.elapsed).toBe(1000);
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('freezes a subtree when an ancestor is paused even if the child is running', () => {
|
|
96
96
|
const parent = createClock({ paused: true });
|
|
97
97
|
const child = createChildClock(parent);
|
|
98
|
-
advanceClock(parent,
|
|
98
|
+
advanceClock(parent, 1000);
|
|
99
99
|
expect(parent.deltaTime).toBe(0);
|
|
100
100
|
expect(child.deltaTime).toBe(0);
|
|
101
101
|
expect(child.elapsed).toBe(0);
|
|
@@ -106,29 +106,29 @@ describe('advanceClock', () => {
|
|
|
106
106
|
const received: number[] = [];
|
|
107
107
|
const onTick = enableClockSignals(clock);
|
|
108
108
|
connectSignal(onTick, (deltaTime) => received.push(deltaTime));
|
|
109
|
-
advanceClock(clock,
|
|
110
|
-
expect(received).toEqual([
|
|
109
|
+
advanceClock(clock, 500);
|
|
110
|
+
expect(received).toEqual([1000]); // 500 * 2
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it('applies a negative deltaTime, producing negative deltaTime and decreasing elapsed', () => {
|
|
114
114
|
const clock = createClock();
|
|
115
|
-
advanceClock(clock,
|
|
116
|
-
expect(clock.elapsed).toBe(
|
|
117
|
-
advanceClock(clock, -
|
|
118
|
-
expect(clock.deltaTime).toBe(-
|
|
119
|
-
expect(clock.elapsed).toBe(
|
|
115
|
+
advanceClock(clock, 1000);
|
|
116
|
+
expect(clock.elapsed).toBe(1000);
|
|
117
|
+
advanceClock(clock, -500);
|
|
118
|
+
expect(clock.deltaTime).toBe(-500);
|
|
119
|
+
expect(clock.elapsed).toBe(500);
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
it('applies a negative scale, reversing the effective delta direction', () => {
|
|
123
123
|
const clock = createClock({ scale: -1 });
|
|
124
|
-
advanceClock(clock,
|
|
125
|
-
expect(clock.deltaTime).toBe(-
|
|
126
|
-
expect(clock.elapsed).toBe(-
|
|
124
|
+
advanceClock(clock, 1000);
|
|
125
|
+
expect(clock.deltaTime).toBe(-1000);
|
|
126
|
+
expect(clock.elapsed).toBe(-1000);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
129
|
it('does not emit or throw when signals are not enabled', () => {
|
|
130
130
|
const clock = createClock();
|
|
131
|
-
expect(() => advanceClock(clock,
|
|
131
|
+
expect(() => advanceClock(clock, 1000)).not.toThrow();
|
|
132
132
|
expect(clock.onTick).toBeNull();
|
|
133
133
|
});
|
|
134
134
|
});
|
|
@@ -279,7 +279,7 @@ describe('removeClockChild', () => {
|
|
|
279
279
|
describe('resetClock', () => {
|
|
280
280
|
it('clears elapsed and deltaTime without touching scale or pause', () => {
|
|
281
281
|
const clock = createClock({ scale: 2 });
|
|
282
|
-
advanceClock(clock,
|
|
282
|
+
advanceClock(clock, 1000);
|
|
283
283
|
resetClock(clock);
|
|
284
284
|
expect(clock.elapsed).toBe(0);
|
|
285
285
|
expect(clock.deltaTime).toBe(0);
|