@wardic/core 1.3.2 → 1.5.0-next.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/Arc.d.ts +2 -2
- package/dist/Arc.js +1 -1
- package/dist/BaseValue.d.ts +11 -10
- package/dist/BaseValue.d.ts.map +1 -1
- package/dist/BaseValue.js +12 -15
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +15 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +218 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +7 -7
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +17 -16
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +8 -6
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +51 -16
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +1 -1
- package/dist/InputFeed.js +2 -2
- package/dist/InputSource.d.ts +9 -3
- package/dist/InputSource.d.ts.map +1 -1
- package/dist/InputSource.js +2 -2
- package/dist/InputSource.js.map +1 -1
- package/dist/Interpolator.d.ts +2 -2
- package/dist/Interpolator.js +2 -2
- package/dist/InterpolatorRegistry.d.ts +29 -15
- package/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +17 -8
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts +7 -6
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +45 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +7 -4
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +146 -45
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +6 -1
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +8 -19
- package/dist/Projection.d.ts.map +1 -1
- package/dist/Projection.js +3 -19
- package/dist/Projection.js.map +1 -1
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +22 -7
- package/dist/Recognizer.js.map +1 -1
- package/dist/ReducedMotion.d.ts +4 -4
- package/dist/ReducedMotion.js +6 -6
- package/dist/Renderer.d.ts +5 -5
- package/dist/Renderer.js +6 -6
- package/dist/Renderer.js.map +1 -1
- package/dist/Reorder.d.ts +12 -2
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +65 -37
- package/dist/Reorder.js.map +1 -1
- package/dist/ScrollSource.d.ts +1 -1
- package/dist/ScrollSource.d.ts.map +1 -1
- package/dist/Sequence.d.ts +1 -1
- package/dist/SharedSource.d.ts +3 -3
- package/dist/SharedSource.js +5 -5
- package/dist/SharedSource.js.map +1 -1
- package/dist/Spring.d.ts.map +1 -1
- package/dist/Spring.js +2 -1
- package/dist/Spring.js.map +1 -1
- package/dist/Values.d.ts +2 -2
- package/dist/Values.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/carried.d.ts +13 -0
- package/dist/internal/carried.d.ts.map +1 -0
- package/dist/internal/carried.js +23 -0
- package/dist/internal/carried.js.map +1 -0
- package/dist/internal/firstSteps.d.ts +66 -0
- package/dist/internal/firstSteps.d.ts.map +1 -0
- package/dist/internal/firstSteps.js +107 -0
- package/dist/internal/firstSteps.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +1 -1
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +102 -81
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/projectionRest.d.ts +22 -0
- package/dist/internal/projectionRest.d.ts.map +1 -0
- package/dist/internal/projectionRest.js +20 -0
- package/dist/internal/projectionRest.js.map +1 -0
- package/dist/internal/stepper.d.ts +13 -2
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +16 -1
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +37 -38
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +39 -36
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +5 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +19 -19
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +53 -51
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +56 -49
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +2 -2
- package/dist/unstable/FrameEffects.js +2 -2
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +29 -9
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +79 -47
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +31 -27
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js +8 -8
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Projector.d.ts +34 -0
- package/dist/unstable/Projector.d.ts.map +1 -0
- package/dist/unstable/Projector.js +9 -0
- package/dist/unstable/Projector.js.map +1 -0
- package/dist/unstable/Report.d.ts +1 -1
- package/dist/unstable/Report.js +1 -1
- package/dist/unstable/RetargetLegs.d.ts +1 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +9 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +81 -72
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +171 -164
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +7 -7
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +11 -11
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +43 -36
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +34 -34
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +236 -22
- package/src/Clock.ts +18 -17
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +65 -23
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +2 -2
- package/src/InputSource.ts +12 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +47 -17
- package/src/Machine.ts +199 -61
- package/src/Playback.ts +5 -1
- package/src/Projection.ts +10 -28
- package/src/Recognizer.ts +24 -8
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +84 -38
- package/src/ScrollSource.ts +1 -1
- package/src/Sequence.ts +1 -1
- package/src/SharedSource.ts +5 -5
- package/src/Spring.ts +2 -1
- package/src/Values.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internal/carried.ts +22 -0
- package/src/internal/firstSteps.ts +139 -0
- package/src/internal/frameLoop.ts +103 -87
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/projectionRest.ts +31 -0
- package/src/internal/stepper.ts +20 -2
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +59 -56
- package/src/unstable/AppearHandoff.ts +6 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +19 -19
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +92 -82
- package/src/unstable/FrameEffects.ts +2 -2
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +126 -56
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +34 -30
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +1 -1
- package/src/unstable/RetargetLegs.ts +10 -9
- package/src/unstable/Spine.ts +210 -201
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +13 -13
- package/src/unstable/VariantTree.ts +50 -43
- package/src/unstable/WardicConfigValue.ts +13 -13
package/dist/Batch.js
CHANGED
|
@@ -24,15 +24,18 @@ import * as Effect from "effect/Effect";
|
|
|
24
24
|
import { identity } from "effect/Function";
|
|
25
25
|
import * as Inspectable from "effect/Inspectable";
|
|
26
26
|
import * as Match from "effect/Match";
|
|
27
|
+
import * as Option from "effect/Option";
|
|
27
28
|
import { pipeArguments } from "effect/Pipeable";
|
|
28
29
|
import * as Predicate from "effect/Predicate";
|
|
29
30
|
import * as UndefinedOr from "effect/UndefinedOr";
|
|
31
|
+
import * as FrameLoop from "./FrameLoop.js";
|
|
30
32
|
import * as Machine from "./Machine.js";
|
|
31
33
|
import * as Scalar from "./Scalar.js";
|
|
32
34
|
import * as Spring from "./Spring.js";
|
|
33
35
|
import * as UnitScale from "./UnitScale.js";
|
|
34
36
|
import * as Report from "./unstable/Report.js";
|
|
35
37
|
import { dual } from "./internal/dual.js";
|
|
38
|
+
import * as FirstSteps from "./internal/firstSteps.js";
|
|
36
39
|
import { tickOf, writableOf } from "./internal/playhead.js";
|
|
37
40
|
import { resolveKeyframes } from "./internal/keyframes.js";
|
|
38
41
|
import { checked, fn, literals, nonNegative, positive, union } from "./internal/options.js";
|
|
@@ -73,7 +76,7 @@ const COUNTED = 8;
|
|
|
73
76
|
* `elapsed` `NaN` until then. It's in `startList`, which each step's start pass reads before the loops.
|
|
74
77
|
*/
|
|
75
78
|
const STARTS = 16;
|
|
76
|
-
/** The start pass drew it this step: its loop keeps it, unstepped, and clears the flag. */
|
|
79
|
+
/** The start pass or the owing pass drew it this step: its loop keeps it, unstepped, and clears the flag. */
|
|
77
80
|
const STARTED = 32;
|
|
78
81
|
/**
|
|
79
82
|
* Its values changed outside a step (it entered, took a new Subject, a change started it from a given value,
|
|
@@ -249,6 +252,10 @@ export const make = (options) => {
|
|
|
249
252
|
movers: new Int32Array(capacity),
|
|
250
253
|
flags: new Uint8Array(capacity),
|
|
251
254
|
free: [],
|
|
255
|
+
owed: new Float64Array(capacity),
|
|
256
|
+
owing: 0,
|
|
257
|
+
startOwing: 0,
|
|
258
|
+
ticks: undefined,
|
|
252
259
|
startAts: [],
|
|
253
260
|
startList: [],
|
|
254
261
|
plainList: new Int32Array(capacity),
|
|
@@ -271,6 +278,7 @@ export const make = (options) => {
|
|
|
271
278
|
flush: UndefinedOr.match(options.writer.flush, { onUndefined: () => noop, onDefined: identity }),
|
|
272
279
|
onFrame: UndefinedOr.match(options.onFrame, { onUndefined: () => noop, onDefined: identity }),
|
|
273
280
|
frame: 0,
|
|
281
|
+
frameDt: 0,
|
|
274
282
|
running: 0,
|
|
275
283
|
runs: 0,
|
|
276
284
|
services: Context.empty(),
|
|
@@ -332,7 +340,12 @@ export const enter = dual(3, (self, subject, start) => {
|
|
|
332
340
|
state.subjects[slot] = subject;
|
|
333
341
|
// A start a member that left never took isn't this one's.
|
|
334
342
|
// Drawn at its first step, at its start, though a delay holds it there.
|
|
335
|
-
|
|
343
|
+
const flag = (state.flags[slot] & ~(STARTS | STARTED)) | LIVE | DUE;
|
|
344
|
+
state.flags[slot] = flag;
|
|
345
|
+
// A slot the member before left while it moved is still in its list, stepped as a moving member's: the new
|
|
346
|
+
// one owes its first steps from now while the run goes on (#1028), as one set off is; a run's start counts it.
|
|
347
|
+
if ((flag & (IN_PLAIN | IN_RULED)) !== 0 && state.running !== 0)
|
|
348
|
+
owes(state, slot, owingNow(state));
|
|
336
349
|
const base = slot * state.stride;
|
|
337
350
|
Arr.forEach(state.keys, (key, k) => {
|
|
338
351
|
const given = start[key];
|
|
@@ -367,14 +380,15 @@ export const leave = dual(2, (self, slot) => {
|
|
|
367
380
|
return;
|
|
368
381
|
state.flags[slot] = state.flags[slot] & ~LIVE;
|
|
369
382
|
state.subjects[slot] = undefined;
|
|
383
|
+
owesNothing(state, slot);
|
|
370
384
|
state.free.push(slot);
|
|
371
385
|
});
|
|
372
386
|
/**
|
|
373
387
|
* The member at `slot` is drawn on `subject` from now on: its values, speed, targets and delays carry
|
|
374
|
-
* on as they were. For
|
|
388
|
+
* on as they were. For a Subject its framework made again for the same member.
|
|
375
389
|
*
|
|
376
390
|
* @example
|
|
377
|
-
* Batch.replace(grid, slot,
|
|
391
|
+
* Batch.replace(grid, slot, subject)
|
|
378
392
|
*/
|
|
379
393
|
export const replace = dual(3, (self, slot, subject) => {
|
|
380
394
|
const state = stateOf(self);
|
|
@@ -418,6 +432,7 @@ const grow = (state, capacity) => {
|
|
|
418
432
|
state.pending = grown(state.pending, size);
|
|
419
433
|
state.movers = grown(state.movers, capacity);
|
|
420
434
|
state.flags = grown(state.flags, capacity);
|
|
435
|
+
state.owed = grown(state.owed, capacity);
|
|
421
436
|
state.plainList = grown(state.plainList, capacity);
|
|
422
437
|
state.ruledList = grown(state.ruledList, capacity);
|
|
423
438
|
};
|
|
@@ -529,6 +544,10 @@ export const retarget = dual(isBatch, (self, slots, targetOf, options) => {
|
|
|
529
544
|
const driven = state.animations.size > 0;
|
|
530
545
|
// Started partway (#706): each key it turns waits, `elapsed` `NaN`, for its member's first step to read where.
|
|
531
546
|
const startAt = UndefinedOr.map(options, (bag) => bag.startAt);
|
|
547
|
+
// While its run goes on, a member it sets off from rest owes its first steps (#1028), read once.
|
|
548
|
+
let owing = 0;
|
|
549
|
+
if (state.running !== 0)
|
|
550
|
+
owing = owingNow(state);
|
|
532
551
|
let fresh = 0;
|
|
533
552
|
if (Predicate.isNotUndefined(startAt))
|
|
534
553
|
fresh = Number.NaN;
|
|
@@ -583,8 +602,12 @@ export const retarget = dual(isBatch, (self, slots, targetOf, options) => {
|
|
|
583
602
|
state.startAts[slot] = startAt;
|
|
584
603
|
}
|
|
585
604
|
flags[slot] = flag;
|
|
586
|
-
if ((flag & (IN_PLAIN | IN_RULED)) === 0)
|
|
605
|
+
if ((flag & (IN_PLAIN | IN_RULED)) === 0) {
|
|
587
606
|
setOff++;
|
|
607
|
+
// Set off from rest while its run goes on: it owes its first steps (#1028), unless its first step
|
|
608
|
+
// takes an Appear animation over (`startedPartway`). A run that starts owes its members' at its start.
|
|
609
|
+
owes(state, slot, owing);
|
|
610
|
+
}
|
|
588
611
|
// Into the ruled list, out of the plain one (which drops it at its next step); else into the plain
|
|
589
612
|
// list, if it's in neither.
|
|
590
613
|
if (ruled && (flag & IN_RULED) === 0) {
|
|
@@ -601,6 +624,98 @@ export const retarget = dual(isBatch, (self, slots, targetOf, options) => {
|
|
|
601
624
|
Arr.forEach(held, (rule) => release(state, rule));
|
|
602
625
|
return setOff;
|
|
603
626
|
});
|
|
627
|
+
// --- A member's first steps (#1028) ------------------------------------------------
|
|
628
|
+
//
|
|
629
|
+
// A Batch is one run on the Frame loop, on the frame timeline, so the late-frame rule a run of its own keeps
|
|
630
|
+
// (`FirstSteps`, #1026) is kept here per member: a member set off from rest takes none of a long task's time
|
|
631
|
+
// from before it moved. Per member at a change and at a run's start; per frame, only while one owes.
|
|
632
|
+
/** What a member or a Playhead set off now owes (`FirstSteps.madeOwing`): 0, nothing, before the Batch's first run. */
|
|
633
|
+
const owingNow = (state) => {
|
|
634
|
+
const ticks = state.ticks;
|
|
635
|
+
if (Predicate.isUndefined(ticks))
|
|
636
|
+
return 0;
|
|
637
|
+
return ticks.madeOwing();
|
|
638
|
+
};
|
|
639
|
+
/** The member at `slot` owes `owing` (0, nothing). */
|
|
640
|
+
// Per member at a change, what they owe read once for all of them.
|
|
641
|
+
const owes = (state, slot, owing) => {
|
|
642
|
+
if (owing === 0)
|
|
643
|
+
return;
|
|
644
|
+
if (state.owed[slot] === 0)
|
|
645
|
+
state.owing = state.owing + 1;
|
|
646
|
+
state.owed[slot] = owing;
|
|
647
|
+
};
|
|
648
|
+
/** The member at `slot` owes nothing: it rests, left, or keeps the frame timeline's time. */
|
|
649
|
+
const owesNothing = (state, slot) => {
|
|
650
|
+
if (state.owed[slot] === 0)
|
|
651
|
+
return;
|
|
652
|
+
state.owed[slot] = 0;
|
|
653
|
+
state.owing = state.owing - 1;
|
|
654
|
+
};
|
|
655
|
+
/** The dt now of a member or a Playhead that owes `owed`: the step's, what it owes left out, clamped. */
|
|
656
|
+
// Per member or Playhead that owes, in a step: twice a play or a set-off at most.
|
|
657
|
+
const owingDt = (state, owed) => {
|
|
658
|
+
const ticks = state.ticks;
|
|
659
|
+
let dt = state.frameDt;
|
|
660
|
+
if (Predicate.isNotUndefined(ticks))
|
|
661
|
+
dt = ticks.owingDt(owed, dt);
|
|
662
|
+
return Math.min(dt, Machine.MAX_DT);
|
|
663
|
+
};
|
|
664
|
+
/** What a member or a Playhead that owed `owed` owes after its step now. */
|
|
665
|
+
const owedAfter = (state, owed) => {
|
|
666
|
+
const ticks = state.ticks;
|
|
667
|
+
if (Predicate.isUndefined(ticks))
|
|
668
|
+
return 0;
|
|
669
|
+
return ticks.owedAfter(owed);
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* A run's start: the members it starts with owe their first steps from now, all alike, kept once for the
|
|
673
|
+
* Batch (`startOwing`) until its first step tells whether they owe each. What one owed of a run before is
|
|
674
|
+
* forgotten.
|
|
675
|
+
*/
|
|
676
|
+
// Once a run: nothing per member, so a run that starts on time costs what it did.
|
|
677
|
+
const runStarts = (state) => {
|
|
678
|
+
if (state.owing > 0) {
|
|
679
|
+
state.owed.fill(0);
|
|
680
|
+
state.owing = 0;
|
|
681
|
+
}
|
|
682
|
+
state.startOwing = owingNow(state);
|
|
683
|
+
};
|
|
684
|
+
/**
|
|
685
|
+
* The run's first step: whether the members it started with take the tick's dt. Where they don't, each one
|
|
686
|
+
* moving owes its first steps as they did, and each change a Playhead drives its first ticks: one taking an
|
|
687
|
+
* Appear animation over (the start pass drew it) and one set off or played since, owing its own, aside.
|
|
688
|
+
*/
|
|
689
|
+
// Once a run, at its first step; per member only where that step's frame came late.
|
|
690
|
+
const startOwes = (state) => {
|
|
691
|
+
const owing = state.startOwing;
|
|
692
|
+
state.startOwing = 0;
|
|
693
|
+
if (owingDt(state, owing) === Math.min(state.frameDt, Machine.MAX_DT) && owedAfter(state, owing) === 0)
|
|
694
|
+
return;
|
|
695
|
+
owesFromNow(state, state.plainList, state.plainCount, IN_PLAIN, owing);
|
|
696
|
+
owesFromNow(state, state.ruledList, state.ruledCount, IN_RULED, owing);
|
|
697
|
+
// And each change a Playhead drives that it started with, played before it, but one played since.
|
|
698
|
+
for (const animation of state.animations) {
|
|
699
|
+
if (animation.owed !== 0)
|
|
700
|
+
continue;
|
|
701
|
+
animation.owed = owing;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
/** Each live member of `list`'s first `count` still in it (`inList`), not drawn this step nor owing, owes as `owing`. */
|
|
705
|
+
const owesFromNow = (state, list, count, inList, owing) => {
|
|
706
|
+
const { flags, owed } = state;
|
|
707
|
+
let added = 0;
|
|
708
|
+
for (let a = 0; a < count; a++) {
|
|
709
|
+
const slot = list[a];
|
|
710
|
+
if ((flags[slot] & (LIVE | inList | STARTED)) !== (LIVE | inList))
|
|
711
|
+
continue;
|
|
712
|
+
if (owed[slot] !== 0)
|
|
713
|
+
continue;
|
|
714
|
+
owed[slot] = owing;
|
|
715
|
+
added++;
|
|
716
|
+
}
|
|
717
|
+
state.owing = state.owing + added;
|
|
718
|
+
};
|
|
604
719
|
/**
|
|
605
720
|
* `defect`, a failure on the Batch's path named by `message`, logged and handed to the ErrorReporters of
|
|
606
721
|
* what it runs on, annotated with its member's slot where it's one member's.
|
|
@@ -667,11 +782,17 @@ export const step = (self, dt) => {
|
|
|
667
782
|
const state = stateOf(self);
|
|
668
783
|
const clamped = Math.min(dt, Machine.MAX_DT);
|
|
669
784
|
state.frame = state.frame + 1;
|
|
785
|
+
state.frameDt = dt;
|
|
670
786
|
// Whether a member's write or start throws in this step: a `draw`'s between steps isn't one (#977).
|
|
671
787
|
state.writeThrewInStep = false;
|
|
672
788
|
state.startThrewInStep = false;
|
|
673
789
|
if (state.startList.length > 0)
|
|
674
790
|
startPass(state, clamped);
|
|
791
|
+
// A member that owes its first steps steps by its own dt, out of the loops (#1028).
|
|
792
|
+
if (state.startOwing !== 0)
|
|
793
|
+
startOwes(state);
|
|
794
|
+
if (state.owing > 0)
|
|
795
|
+
owingPass(state, clamped);
|
|
675
796
|
if (state.plainCount > 0)
|
|
676
797
|
stepPlain(state, clamped);
|
|
677
798
|
if (state.ruledCount > 0)
|
|
@@ -714,7 +835,7 @@ export const step = (self, dt) => {
|
|
|
714
835
|
};
|
|
715
836
|
/**
|
|
716
837
|
* Writes every member where it is now, with no step, then flushes the writer: a change that started its
|
|
717
|
-
* members from their targets (`retarget`'s `from`),
|
|
838
|
+
* members from their targets (`retarget`'s `from`), committed now, before the frame is drawn, where the run would
|
|
718
839
|
* draw it at its next tick.
|
|
719
840
|
*/
|
|
720
841
|
// #712: a Batch Reorder group's first read of its element places its items at once. Once a change, over
|
|
@@ -1143,18 +1264,25 @@ const drivenStep = (animation, clamped, frame) => {
|
|
|
1143
1264
|
return animation.dt;
|
|
1144
1265
|
animation.frame = frame;
|
|
1145
1266
|
const head = animation.options.head;
|
|
1267
|
+
// Its tick: the frame's, less a long task's time while its Playhead owes its first ticks (#1028).
|
|
1268
|
+
let tick = clamped;
|
|
1269
|
+
const owed = animation.owed;
|
|
1270
|
+
if (owed !== 0) {
|
|
1271
|
+
tick = owingDt(animation.state, owed);
|
|
1272
|
+
animation.owed = owedAfter(animation.state, owed);
|
|
1273
|
+
}
|
|
1146
1274
|
let by = 0;
|
|
1147
1275
|
// Played from partway through, its first step lands there, whatever the `dt`, as `Playback.drive`'s does.
|
|
1148
1276
|
const landing = animation.landing;
|
|
1149
1277
|
animation.landing = false;
|
|
1150
1278
|
if (!landing && !head.paused)
|
|
1151
|
-
by = tickOf(head,
|
|
1279
|
+
by = tickOf(head, tick, Machine.MAX_DT);
|
|
1152
1280
|
animation.dt = by;
|
|
1153
1281
|
animation.time = Math.max(0, animation.time + by);
|
|
1154
1282
|
writableOf(head).time = animation.time;
|
|
1155
1283
|
return by;
|
|
1156
1284
|
};
|
|
1157
|
-
/** Whether the key at `at` is held by a paused Playhead: it hands on no speed, as a held
|
|
1285
|
+
/** Whether the key at `at` is held by a paused Playhead: it hands on no speed, as a held Subject's frames read 0 (#464). */
|
|
1158
1286
|
// Per key per change, while a driven change plays.
|
|
1159
1287
|
const heldAt = (state, at) => {
|
|
1160
1288
|
const driver = state.drivers[state.rules[at]];
|
|
@@ -1257,6 +1385,10 @@ const startedPartway = (state, slot, dt) => {
|
|
|
1257
1385
|
}
|
|
1258
1386
|
const base = slot * stride;
|
|
1259
1387
|
const started = !Number.isNaN(time);
|
|
1388
|
+
// Taking its Appear animation over, it keeps the frame timeline's time, where that animation's is (#1026);
|
|
1389
|
+
// from its start, `NaN`, it takes over nothing and owes its first steps as any member set off (#1028).
|
|
1390
|
+
if (started)
|
|
1391
|
+
owesNothing(state, slot);
|
|
1260
1392
|
for (let k = 0; k < stride; k++) {
|
|
1261
1393
|
const at = base + k;
|
|
1262
1394
|
const turned = Number.isNaN(elapsed[at]);
|
|
@@ -1287,11 +1419,72 @@ const startedPartway = (state, slot, dt) => {
|
|
|
1287
1419
|
}
|
|
1288
1420
|
return started;
|
|
1289
1421
|
};
|
|
1422
|
+
/**
|
|
1423
|
+
* Each step's owing pass, before the loops and after the start pass: each member that owes its first steps
|
|
1424
|
+
* takes its step's dt (the tick's, less what it owes). One whose dt that leaves less is
|
|
1425
|
+
* stepped by it here, drawn, and flagged `STARTED` so its loop keeps it unstepped; one at the tick's, by its
|
|
1426
|
+
* loop. A key a Playhead drives keeps its Playhead's step.
|
|
1427
|
+
*/
|
|
1428
|
+
// #1028: once or twice a member, after a change that sets it off, so out of the loops, as the start pass is
|
|
1429
|
+
// (#706): with a member's own dt read in them, Bun's ruled step ran 5% slower with no member owing.
|
|
1430
|
+
const owingPass = (state, clamped) => {
|
|
1431
|
+
owingIn(state, state.plainList, state.plainCount, clamped);
|
|
1432
|
+
owingIn(state, state.ruledList, state.ruledCount, clamped);
|
|
1433
|
+
};
|
|
1434
|
+
/** The owing pass over `list`'s first `count`: a member that left, or one drawn this step already, skipped. */
|
|
1435
|
+
const owingIn = (state, list, count, clamped) => {
|
|
1436
|
+
const { flags, owed } = state;
|
|
1437
|
+
for (let a = 0; a < count; a++) {
|
|
1438
|
+
const slot = list[a];
|
|
1439
|
+
const was = owed[slot];
|
|
1440
|
+
if (was === 0)
|
|
1441
|
+
continue;
|
|
1442
|
+
if ((flags[slot] & (LIVE | STARTED)) !== LIVE)
|
|
1443
|
+
continue;
|
|
1444
|
+
const own = owingDt(state, was);
|
|
1445
|
+
const after = owedAfter(state, was);
|
|
1446
|
+
owed[slot] = after;
|
|
1447
|
+
if (after === 0)
|
|
1448
|
+
state.owing = state.owing - 1;
|
|
1449
|
+
// At the tick's own dt (an on-time first step), its loop steps it.
|
|
1450
|
+
if (own !== clamped)
|
|
1451
|
+
stepOwing(state, slot, clamped, own);
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
/** The member at `slot` a step of `own` on, each key as the loops step it, drawn, and kept from its loop this step. */
|
|
1455
|
+
const stepOwing = (state, slot, clamped, own) => {
|
|
1456
|
+
const { stride, rules, drivers } = state;
|
|
1457
|
+
const base = slot * stride;
|
|
1458
|
+
for (let k = 0; k < stride; k++) {
|
|
1459
|
+
const at = base + k;
|
|
1460
|
+
const rule = rules[at];
|
|
1461
|
+
const driver = drivers[rule];
|
|
1462
|
+
if (Predicate.isUndefined(driver)) {
|
|
1463
|
+
stepKey(state, at, rule, own);
|
|
1464
|
+
continue;
|
|
1465
|
+
}
|
|
1466
|
+
// Its Playhead's step this frame, worked out once a step whichever reads it first.
|
|
1467
|
+
const driven = drivenStep(driver, clamped, state.frame);
|
|
1468
|
+
if (driven < 0) {
|
|
1469
|
+
stepBack(state, at, rule, driven);
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
stepKey(state, at, rule, driven);
|
|
1473
|
+
}
|
|
1474
|
+
state.flags[slot] = (state.flags[slot] & ~DUE) | STARTED;
|
|
1475
|
+
try {
|
|
1476
|
+
state.write(state.subjects[slot], state.positions, base);
|
|
1477
|
+
}
|
|
1478
|
+
catch (defect) {
|
|
1479
|
+
writeFailed(state, slot, defect);
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1290
1482
|
/**
|
|
1291
1483
|
* The key at `at` a step of `dt` on, as the loops step it: a tween's, keyframes', or a spring's by its
|
|
1292
1484
|
* matrix for the part past its delay, landing by its thresholds or its duration.
|
|
1293
1485
|
*/
|
|
1294
|
-
// Rare: a key the loops don't reach this step, of a member started partway that another change moves
|
|
1486
|
+
// Rare: a key the loops don't reach this step, of a member started partway that another change moves, or of
|
|
1487
|
+
// a member that owes its first steps (#1028).
|
|
1295
1488
|
const stepKey = (state, at, rule, dt) => {
|
|
1296
1489
|
const entry = state.entries[rule];
|
|
1297
1490
|
const time = state.elapsed[at] + dt;
|
|
@@ -1542,6 +1735,7 @@ const animationFor = (state, options, slots, moves) => {
|
|
|
1542
1735
|
frame: 0,
|
|
1543
1736
|
dt: 0,
|
|
1544
1737
|
landing: false,
|
|
1738
|
+
owed: 0,
|
|
1545
1739
|
tracks: [],
|
|
1546
1740
|
indexAt: new Int32Array(0),
|
|
1547
1741
|
firsts: new Int32Array(0),
|
|
@@ -1830,7 +2024,7 @@ const playRules = (animation) => {
|
|
|
1830
2024
|
/**
|
|
1831
2025
|
* Plays `animation` from its Playhead's time: from its start at 0, its change worked out then, and from
|
|
1832
2026
|
* wherever a seek put the time, every key it moves taken again there. It returns how many members it
|
|
1833
|
-
* sets off from rest. One that moves nothing lands at once, as
|
|
2027
|
+
* sets off from rest. One that moves nothing lands at once, as a Subject's call with no key does.
|
|
1834
2028
|
*/
|
|
1835
2029
|
export const play = (self) => {
|
|
1836
2030
|
const animation = animationOf(self);
|
|
@@ -1848,6 +2042,11 @@ export const play = (self) => {
|
|
|
1848
2042
|
animation.playing = true;
|
|
1849
2043
|
animation.time = time;
|
|
1850
2044
|
animation.landing = time > 0;
|
|
2045
|
+
// Played while the run goes on, its Playhead owes its first ticks from now (#1028); played at rest, from
|
|
2046
|
+
// the run's start, as the run's members.
|
|
2047
|
+
animation.owed = 0;
|
|
2048
|
+
if (state.running !== 0)
|
|
2049
|
+
animation.owed = owingNow(state);
|
|
1851
2050
|
state.animations.add(animation);
|
|
1852
2051
|
// Once a play, per key it moves: each key's entry, then each entry held once for it and driven by it.
|
|
1853
2052
|
playRules(animation);
|
|
@@ -2036,6 +2235,9 @@ const machineOf = (self, id) => {
|
|
|
2036
2235
|
},
|
|
2037
2236
|
});
|
|
2038
2237
|
};
|
|
2238
|
+
/** A Batch run's options: on the frame timeline, its members keeping the late-frame rule each. */
|
|
2239
|
+
// #1026, #1028.
|
|
2240
|
+
const ON_THE_FRAME_TIMELINE = { onFrameTimeline: true };
|
|
2039
2241
|
/**
|
|
2040
2242
|
* Runs `self` on the Frame loop while any member moves, from the next tick: each tick steps every
|
|
2041
2243
|
* moving member and writes it. It succeeds once nothing moves. While one runs, another does nothing,
|
|
@@ -2046,9 +2248,6 @@ const machineOf = (self, id) => {
|
|
|
2046
2248
|
* Batch.retarget(grid, slots, targetOf)
|
|
2047
2249
|
* runtime.runFork(Batch.run(grid))
|
|
2048
2250
|
*/
|
|
2049
|
-
/** A Batch run's options (#1026): on the frame timeline while members take their Appear animations over, or not. */
|
|
2050
|
-
const TAKING_OVER = { onFrameTimeline: true };
|
|
2051
|
-
const ON_ITS_OWN = {};
|
|
2052
2251
|
// One run, not a fiber per member (ADR-0069, decision 10). Its span is `wardic.batch`.
|
|
2053
2252
|
export const run = (self) => Effect.contextWith((services) => {
|
|
2054
2253
|
const state = stateOf(self);
|
|
@@ -2062,13 +2261,12 @@ export const run = (self) => Effect.contextWith((services) => {
|
|
|
2062
2261
|
const id = state.runs + 1;
|
|
2063
2262
|
state.runs = id;
|
|
2064
2263
|
state.running = id;
|
|
2065
|
-
//
|
|
2066
|
-
//
|
|
2067
|
-
//
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
return Effect.ensuring(Effect.asVoid(Machine.run(machineOf(self, id), ignore, options)), Effect.sync(() => {
|
|
2264
|
+
// The run keeps the frame timeline's time, where a member taking its Appear animation over has its
|
|
2265
|
+
// `currentTime` (#1026). Every other member takes no long task's time from before it moved (#1028):
|
|
2266
|
+
// those moving now owe their first steps, and those set off while it runs, at their change.
|
|
2267
|
+
state.ticks = Option.getOrUndefined(FirstSteps.readerOf(Context.get(services, FrameLoop.FrameLoop)));
|
|
2268
|
+
runStarts(state);
|
|
2269
|
+
return Effect.ensuring(Effect.asVoid(Machine.run(machineOf(self, id), ignore, ON_THE_FRAME_TIMELINE)), Effect.sync(() => {
|
|
2072
2270
|
if (state.running === id)
|
|
2073
2271
|
state.running = 0;
|
|
2074
2272
|
}));
|