@msb235/blits 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +154 -0
- package/README.md +3 -3
- package/dist/ahead.d.ts +26 -0
- package/dist/ahead.js +264 -0
- package/dist/around.d.ts +11 -0
- package/dist/around.js +32 -0
- package/dist/bare.js +15 -7
- package/dist/blank.d.ts +10 -0
- package/dist/blank.js +26 -0
- package/dist/blend.d.ts +2 -1
- package/dist/blend.js +1 -6
- package/dist/bound.d.ts +70 -0
- package/dist/bound.js +351 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.js +7 -5
- package/dist/changes.d.ts +24 -0
- package/dist/changes.js +189 -0
- package/dist/channels.d.ts +39 -13
- package/dist/channels.js +14 -5
- package/dist/color.d.ts +12 -10
- package/dist/color.js +25 -25
- package/dist/columns.js +7 -3
- package/dist/contribution.d.ts +30 -0
- package/dist/contribution.js +374 -0
- package/dist/copyout.d.ts +10 -0
- package/dist/copyout.js +69 -24
- package/dist/crowd.d.ts +8 -2
- package/dist/crowd.js +4 -5
- package/dist/cue.d.ts +8 -1
- package/dist/cue.js +39 -13
- package/dist/cut.d.ts +8 -0
- package/dist/cut.js +4 -0
- package/dist/drop.d.ts +9 -0
- package/dist/drop.js +84 -0
- package/dist/due.d.ts +24 -5
- package/dist/due.js +113 -33
- package/dist/easing.d.ts +4 -4
- package/dist/easing.js +3 -3
- package/dist/everyone.d.ts +3 -2
- package/dist/everyone.js +3 -3
- package/dist/fade.d.ts +2 -1
- package/dist/fade.js +2 -1
- package/dist/fill.d.ts +3 -2
- package/dist/fill.js +51 -19
- package/dist/fit.d.ts +44 -26
- package/dist/fit.js +10 -9
- package/dist/fold.d.ts +4 -37
- package/dist/fold.js +5 -513
- package/dist/gather.d.ts +12 -7
- package/dist/gather.js +179 -44
- package/dist/gone.js +2 -2
- package/dist/grid.d.ts +47 -0
- package/dist/grid.js +247 -0
- package/dist/handle.d.ts +2 -0
- package/dist/handle.js +14 -8
- package/dist/held.d.ts +2 -1
- package/dist/history.d.ts +6 -5
- package/dist/history.js +7 -9
- package/dist/hosts.js +9 -15
- package/dist/index.d.ts +5 -4
- package/dist/keyfill.d.ts +1 -1
- package/dist/keyfill.js +5 -3
- package/dist/keyrows.d.ts +12 -0
- package/dist/keyrows.js +99 -12
- package/dist/lane.d.ts +36 -6
- package/dist/lane.js +32 -1
- package/dist/lanes.d.ts +23 -8
- package/dist/lanes.js +29 -8
- package/dist/leavings.d.ts +2 -2
- package/dist/leavings.js +1 -1
- package/dist/lives.d.ts +47 -0
- package/dist/lives.js +180 -0
- package/dist/meet.d.ts +2 -2
- package/dist/meet.js +90 -4
- package/dist/mixer.d.ts +54 -36
- package/dist/mixer.js +53 -171
- package/dist/motion.d.ts +14 -118
- package/dist/motion.js +16 -8
- package/dist/motions.d.ts +62 -155
- package/dist/motions.js +56 -370
- package/dist/moved.d.ts +1 -1
- package/dist/moved.js +16 -7
- package/dist/named.d.ts +0 -1
- package/dist/named.js +20 -2
- package/dist/numbers.d.ts +2 -0
- package/dist/numbers.js +4 -0
- package/dist/owed.d.ts +2 -0
- package/dist/owed.js +4 -0
- package/dist/pack.d.ts +2 -1
- package/dist/pack.js +2 -3
- package/dist/patch.d.ts +7 -3
- package/dist/patch.js +6 -2
- package/dist/places.d.ts +53 -0
- package/dist/places.js +171 -0
- package/dist/plot.d.ts +12 -0
- package/dist/plot.js +52 -0
- package/dist/project.d.ts +4 -4
- package/dist/project.js +9 -212
- package/dist/pull.js +11 -8
- package/dist/qualify.js +84 -21
- package/dist/reading.d.ts +6 -0
- package/dist/reading.js +5 -0
- package/dist/record.d.ts +5 -1
- package/dist/record.js +3 -2
- package/dist/relink.d.ts +1 -1
- package/dist/restored.d.ts +2 -2
- package/dist/restored.js +1 -1
- package/dist/rests.d.ts +9 -0
- package/dist/rests.js +76 -0
- package/dist/revive.d.ts +3 -2
- package/dist/revive.js +2 -2
- package/dist/{locus.d.ts → role.d.ts} +10 -9
- package/dist/{locus.js → role.js} +3 -3
- package/dist/roles.d.ts +10 -0
- package/dist/roles.js +158 -0
- package/dist/roster.js +3 -3
- package/dist/rotation.d.ts +1 -1
- package/dist/rotation.js +1 -1
- package/dist/rows.js +1 -1
- package/dist/sample.d.ts +2 -2
- package/dist/sample.js +33 -7
- package/dist/seek.js +5 -5
- package/dist/setting.d.ts +27 -0
- package/dist/setting.js +55 -0
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/signals.d.ts +64 -32
- package/dist/signals.js +20 -18
- package/dist/stack.d.ts +5 -5
- package/dist/stack.js +5 -5
- package/dist/standing.d.ts +2 -1
- package/dist/standing.js +3 -2
- package/dist/store.d.ts +9 -0
- package/dist/store.js +24 -0
- package/dist/strays.d.ts +2 -1
- package/dist/strays.js +20 -13
- package/dist/stretch.d.ts +112 -0
- package/dist/stretch.js +9 -0
- package/dist/subject.d.ts +142 -0
- package/dist/subject.js +1 -0
- package/dist/tape.d.ts +9 -5
- package/dist/tape.js +5 -1
- package/dist/then.d.ts +9 -0
- package/dist/then.js +57 -0
- package/dist/ticker.d.ts +4 -4
- package/dist/transport.d.ts +0 -8
- package/dist/transport.js +0 -4
- package/dist/turns.d.ts +4 -3
- package/dist/turns.js +4 -3
- package/dist/types/arc.d.ts +12 -11
- package/dist/types/channel.d.ts +12 -8
- package/dist/types/history.d.ts +35 -19
- package/dist/types/mix.d.ts +222 -163
- package/dist/types/motion.d.ts +151 -0
- package/dist/types/motion.js +1 -0
- package/dist/types/patch.d.ts +67 -34
- package/dist/types/place.d.ts +51 -36
- package/dist/types/transport.d.ts +20 -18
- package/dist/types/voice.d.ts +136 -70
- package/dist/types/watch.d.ts +88 -40
- package/dist/types.d.ts +1 -0
- package/dist/voice.d.ts +7 -143
- package/dist/voice.js +28 -79
- package/dist/warn.d.ts +2 -0
- package/dist/warn.js +1 -1
- package/dist/watch.d.ts +2 -2
- package/dist/watch.js +5 -3
- package/dist/wave.d.ts +4 -3
- package/dist/wave.js +3 -2
- package/dist/weigh.d.ts +7 -1
- package/dist/weigh.js +27 -0
- package/docs/schema.html +212 -34
- package/package.json +2 -2
package/dist/motion.d.ts
CHANGED
|
@@ -1,69 +1,11 @@
|
|
|
1
1
|
import { Motions } from './motions.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
* A number, or one number per axis.
|
|
5
|
-
*
|
|
6
|
-
* @category patch
|
|
7
|
-
*/
|
|
8
|
-
export type Value = number | readonly number[];
|
|
9
|
-
/**
|
|
10
|
-
* One value for every subject, or one per subject.
|
|
11
|
-
*
|
|
12
|
-
* @category patch
|
|
13
|
-
*/
|
|
14
|
-
export type PerSubject<I, V> = V | ((subject: I) => V);
|
|
15
|
-
/**
|
|
16
|
-
* Where a subject is and how fast it is moving, at one moment of voice time.
|
|
17
|
-
*
|
|
18
|
-
* @category patch
|
|
19
|
-
*/
|
|
20
|
-
export interface Motion<V extends Value = number> {
|
|
21
|
-
value: V;
|
|
22
|
-
/** Units per second. */
|
|
23
|
-
velocity: V;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A patch whose motion is a closed form per subject, so it lands in the same place at any frame
|
|
27
|
-
* rate, and whose changes mid-flight start from where the subject is and how fast it moves.
|
|
28
|
-
*
|
|
29
|
-
* @category patch
|
|
30
|
-
*/
|
|
31
|
-
export type Moving<I, O, V extends Value> = Patch<I, O, void> & {
|
|
32
|
-
/**
|
|
33
|
-
* Where `subject` is and how fast it moves at voice time `at`, default the mix's latest frame,
|
|
34
|
-
* counting every change due by then. With no time given, undefined until a frame of its voice
|
|
35
|
-
* has met the subject, while the subject is still inside its stagger, and once that voice is gone.
|
|
36
|
-
* At any time, undefined for a subject the patch has never met or changed, or that the mix
|
|
37
|
-
* dropped.
|
|
38
|
-
*/
|
|
39
|
-
read(subject: I, at?: number): Motion<V> | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Sets `subject` moving at `velocity`, units per second, from voice time `at`, default the mix's
|
|
42
|
-
* latest frame; for a subject no frame of its voice has met yet, or still inside its stagger, its
|
|
43
|
-
* first read, after any change with a time due by then. A subject faded out of the voice comes
|
|
44
|
-
* back at the latest frame too, however long it is before it is next read.
|
|
45
|
-
*/
|
|
46
|
-
push(subject: I, velocity: V, at?: number): void;
|
|
47
|
-
/**
|
|
48
|
-
* Puts `subject` at `value` from voice time `at`, keeping its velocity, with `at` defaulting as
|
|
49
|
-
* `push`'s does: a spring or tween heads for its target from there, a glide coasts on from there.
|
|
50
|
-
*/
|
|
51
|
-
set(subject: I, value: V, at?: number): void;
|
|
52
|
-
};
|
|
2
|
+
import type { Glide, GlideOptions, Spring, SpringOptions, Tween, TweenOptions, Value } from './types/motion.js';
|
|
3
|
+
export type { Glide, GlideOptions, Motion, MotionOptions, Moving, PerSubject, Spring, SpringOptions, Tween, TweenOptions, Value, } from './types/motion.js';
|
|
53
4
|
/**
|
|
54
5
|
* The state behind a `'motion'` patch, for an engine that reads it directly; a patch another copy
|
|
55
6
|
* of the same release made counts.
|
|
56
7
|
*/
|
|
57
8
|
export declare function motionOf<I>(p: object): Motions<I> | undefined;
|
|
58
|
-
interface Common<I, V extends Value> {
|
|
59
|
-
/** Units per second each subject starts moving at. Default 0. */
|
|
60
|
-
velocity?: PerSubject<I, V>;
|
|
61
|
-
/**
|
|
62
|
-
* Within this distance of where it heads, and this slow, a subject lands there exactly, so a mix
|
|
63
|
-
* can see it at rest. Default 1e-4; 0 keeps the curve exact.
|
|
64
|
-
*/
|
|
65
|
-
settle?: number;
|
|
66
|
-
}
|
|
67
9
|
/**
|
|
68
10
|
* A damped spring toward a target, solved in closed form. `to(subject, target)` retargets one
|
|
69
11
|
* subject mid-flight, and the new stretch starts from where it is and how fast it moves, so there is
|
|
@@ -72,28 +14,12 @@ interface Common<I, V extends Value> {
|
|
|
72
14
|
*
|
|
73
15
|
* @category patch
|
|
74
16
|
*/
|
|
75
|
-
export declare function spring<I, O, V extends Value = number>(writes: keyof O, opts:
|
|
76
|
-
to: PerSubject<I, V>;
|
|
77
|
-
/** Where each subject starts. Default: `to`, at rest. */
|
|
78
|
-
from?: PerSubject<I, V>;
|
|
79
|
-
/** Per second squared. Default 170. */
|
|
80
|
-
stiffness?: number;
|
|
81
|
-
/** Per second. Default 26, just short of critical at the default stiffness. */
|
|
82
|
-
damping?: number;
|
|
83
|
-
mass?: number;
|
|
84
|
-
}): Moving<I, O, V> & {
|
|
85
|
-
/**
|
|
86
|
-
* Heads `subject` for `target` from voice time `at`, keeping its velocity: by default the mix's
|
|
87
|
-
* latest frame, or for a subject no frame of its voice has met yet, or still inside its stagger,
|
|
88
|
-
* its first read, after any change with a time due by then. A subject faded out of the voice
|
|
89
|
-
* comes back at the latest frame too, however long it is before it is next read.
|
|
90
|
-
*/
|
|
91
|
-
to(subject: I, target: V, at?: number): void;
|
|
92
|
-
};
|
|
17
|
+
export declare function spring<I, O, V extends Value = number>(writes: keyof O, opts: SpringOptions<I, V>): Spring<I, O, V>;
|
|
93
18
|
/**
|
|
94
|
-
*
|
|
95
|
-
* `ms`, and comes to rest `velocity · ms / 1000` past
|
|
96
|
-
* again from wherever it is. Closed form, so frame
|
|
19
|
+
* A patch that coasts each subject to a stop under friction, as after a fling. A subject keeps its
|
|
20
|
+
* velocity, which falls by a factor of e every `ms`, and comes to rest `velocity · ms / 1000` past
|
|
21
|
+
* where it was released. `push` sets it moving again from wherever it is. Closed form, so frame
|
|
22
|
+
* rate does not change where it stops.
|
|
97
23
|
*
|
|
98
24
|
* With `bounds`, a coast that would stop past an edge springs back to it from where it crosses, at
|
|
99
25
|
* the speed it crosses at, on a critically damped spring of `stiffness`; one let go past an edge
|
|
@@ -102,44 +28,14 @@ export declare function spring<I, O, V extends Value = number>(writes: keyof O,
|
|
|
102
28
|
*
|
|
103
29
|
* @category patch
|
|
104
30
|
*/
|
|
105
|
-
export declare function glide<I, O, V extends Value = number>(writes: keyof O, opts:
|
|
106
|
-
/** Where each subject starts. */
|
|
107
|
-
from: PerSubject<I, V>;
|
|
108
|
-
/** The friction's time constant, ms. Default 325, a touch scroll's. */
|
|
109
|
-
ms?: number;
|
|
110
|
-
/** The least and greatest value a coast comes to rest at, per axis. Default none. */
|
|
111
|
-
bounds?: PerSubject<I, readonly [min: V, max: V]>;
|
|
112
|
-
/** The spring back's, per second squared, with `bounds`. Default 170, as a spring's. */
|
|
113
|
-
stiffness?: number;
|
|
114
|
-
}): Moving<I, O, V> & {
|
|
115
|
-
/** `subject`'s bounds, undefined for a glide without them. */
|
|
116
|
-
bounds(subject: I): readonly [min: V, max: V] | undefined;
|
|
117
|
-
};
|
|
31
|
+
export declare function glide<I, O, V extends Value = number>(writes: keyof O, opts: GlideOptions<I, V>): Glide<I, O, V>;
|
|
118
32
|
/**
|
|
119
|
-
* From one value to another over `ms` along an easing
|
|
120
|
-
* change where a subject is. `to(subject, target)` retargets one subject mid-flight: the new
|
|
121
|
-
* starts from where it is and takes the full `ms` again, so its velocity jumps where a
|
|
122
|
-
* would not. Time is the voice's, so `rate` and `seek` apply, and a voice's `loop` does
|
|
123
|
-
* it. Cue each tween on one voice. Every subject moves on the same number of axes.
|
|
33
|
+
* From one value to another over `ms` along an easing. Solved in closed form, so frame rate does
|
|
34
|
+
* not change where a subject is. `to(subject, target)` retargets one subject mid-flight: the new
|
|
35
|
+
* stretch starts from where it is and takes the full `ms` again, so its velocity jumps where a
|
|
36
|
+
* spring's would not. Time is the voice's, so `rate` and `seek` apply, and a voice's `loop` does
|
|
37
|
+
* not repeat it. Cue each tween on one voice. Every subject moves on the same number of axes.
|
|
124
38
|
*
|
|
125
39
|
* @category patch
|
|
126
40
|
*/
|
|
127
|
-
export declare function tween<I, O, V extends Value = number>(writes: keyof O, opts:
|
|
128
|
-
/** Where each subject starts. */
|
|
129
|
-
from: PerSubject<I, V>;
|
|
130
|
-
/** Where each subject ends. */
|
|
131
|
-
to: PerSubject<I, V>;
|
|
132
|
-
/** How long a stretch takes, ms: asked per subject each time one of its stretches starts. */
|
|
133
|
-
ms: PerSubject<I, number>;
|
|
134
|
-
/** The curve from `from` to `to`. Default `'ease'`, as CSS's. */
|
|
135
|
-
ease?: Easing;
|
|
136
|
-
}): Omit<Moving<I, O, V>, 'push'> & {
|
|
137
|
-
/**
|
|
138
|
-
* Heads `subject` for `target` from voice time `at`, over a full `ms` from where it is: by default
|
|
139
|
-
* the mix's latest frame, or for a subject no frame of its voice has met yet, or still inside its
|
|
140
|
-
* stagger, its first read, after any change with a time due by then. A subject faded out of the
|
|
141
|
-
* voice comes back at the latest frame too, however long it is before it is next read.
|
|
142
|
-
*/
|
|
143
|
-
to(subject: I, target: V, at?: number): void;
|
|
144
|
-
};
|
|
145
|
-
export {};
|
|
41
|
+
export declare function tween<I, O, V extends Value = number>(writes: keyof O, opts: TweenOptions<I, V>): Tween<I, O, V>;
|
package/dist/motion.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BOUND, COAST, CRITICAL, EASED, OVER, UNDER } from './closed.js';
|
|
2
2
|
import { curve } from './easing.js';
|
|
3
3
|
import { Motions } from './motions.js';
|
|
4
|
+
import { reading } from './reading.js';
|
|
4
5
|
import { release } from './shared.js';
|
|
6
|
+
import { sampleThen } from './then.js';
|
|
5
7
|
const axes = (v) => (typeof v === 'number' ? [v] : [...v]);
|
|
6
8
|
/** Zero on every axis `x` has: a motion's velocity where its options give none. */
|
|
7
9
|
const still = (x) => new Array(x.length).fill(0);
|
|
@@ -40,6 +42,11 @@ class MotionPatch {
|
|
|
40
42
|
}
|
|
41
43
|
at(_phase, subject, setting) {
|
|
42
44
|
const state = this.motions;
|
|
45
|
+
const back = reading.back;
|
|
46
|
+
if (back !== null) {
|
|
47
|
+
const flags = sampleThen(state, subject, setting.elapsed, back);
|
|
48
|
+
return { [this.writes[0]]: state.valueOf(flags, state.xs) };
|
|
49
|
+
}
|
|
43
50
|
const s = state.slot(subject);
|
|
44
51
|
state.sample(s, setting.elapsed, state.xs, state.vs);
|
|
45
52
|
return { [this.writes[0]]: state.value(s, state.xs) };
|
|
@@ -252,9 +259,10 @@ export function spring(writes, opts) {
|
|
|
252
259
|
return new SpringPatch(writes, new Motions(new SpringShape(law, motion, opts)));
|
|
253
260
|
}
|
|
254
261
|
/**
|
|
255
|
-
*
|
|
256
|
-
* `ms`, and comes to rest `velocity · ms / 1000` past
|
|
257
|
-
* again from wherever it is. Closed form, so frame
|
|
262
|
+
* A patch that coasts each subject to a stop under friction, as after a fling. A subject keeps its
|
|
263
|
+
* velocity, which falls by a factor of e every `ms`, and comes to rest `velocity · ms / 1000` past
|
|
264
|
+
* where it was released. `push` sets it moving again from wherever it is. Closed form, so frame
|
|
265
|
+
* rate does not change where it stops.
|
|
258
266
|
*
|
|
259
267
|
* With `bounds`, a coast that would stop past an edge springs back to it from where it crosses, at
|
|
260
268
|
* the speed it crosses at, on a critically damped spring of `stiffness`; one let go past an edge
|
|
@@ -277,11 +285,11 @@ export function glide(writes, opts) {
|
|
|
277
285
|
return new GlidePatch(writes, new Motions(shape), opts.bounds);
|
|
278
286
|
}
|
|
279
287
|
/**
|
|
280
|
-
* From one value to another over `ms` along an easing
|
|
281
|
-
* change where a subject is. `to(subject, target)` retargets one subject mid-flight: the new
|
|
282
|
-
* starts from where it is and takes the full `ms` again, so its velocity jumps where a
|
|
283
|
-
* would not. Time is the voice's, so `rate` and `seek` apply, and a voice's `loop` does
|
|
284
|
-
* it. Cue each tween on one voice. Every subject moves on the same number of axes.
|
|
288
|
+
* From one value to another over `ms` along an easing. Solved in closed form, so frame rate does
|
|
289
|
+
* not change where a subject is. `to(subject, target)` retargets one subject mid-flight: the new
|
|
290
|
+
* stretch starts from where it is and takes the full `ms` again, so its velocity jumps where a
|
|
291
|
+
* spring's would not. Time is the voice's, so `rate` and `seek` apply, and a voice's `loop` does
|
|
292
|
+
* not repeat it. Cue each tween on one voice. Every subject moves on the same number of axes.
|
|
285
293
|
*
|
|
286
294
|
* @category patch
|
|
287
295
|
*/
|
package/dist/motions.d.ts
CHANGED
|
@@ -1,97 +1,17 @@
|
|
|
1
|
+
import { applied, change, commit, cut, dueTo, insert, peek, queue, rewind } from './changes.js';
|
|
1
2
|
import type { Curve } from './easing.js';
|
|
3
|
+
import { made, pack, prune, type Released, reclaim, release, restretch, runAt, runThen, unpack, unrelease } from './lives.js';
|
|
4
|
+
import { Numbers } from './numbers.js';
|
|
5
|
+
import { Store } from './store.js';
|
|
6
|
+
import { type Change, type MotionOwner, type Run, type Segment, type Shape, type Watcher } from './stretch.js';
|
|
2
7
|
import type { MotionSpec } from './types.js';
|
|
3
8
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
9
|
+
* A patch's law, `[form, settle, k1, k2, k3]`: which closed form its stretches follow, its `settle`,
|
|
10
|
+
* and up to three constants that form reads. It heads the patch's `runs`, so `solve` finds them in
|
|
11
|
+
* the buffer a sample already reads rather than in an object of their own.
|
|
6
12
|
*/
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
ms: number;
|
|
10
|
-
x0: number[];
|
|
11
|
-
v0: number[];
|
|
12
|
-
to: number[];
|
|
13
|
-
/** The change that released it; undefined for a subject's first stretch. */
|
|
14
|
-
change?: Change;
|
|
15
|
-
}
|
|
16
|
-
export interface Change {
|
|
17
|
-
/**
|
|
18
|
-
* Voice ms it takes effect at; absent, until the subject's next read stamps it with that read's
|
|
19
|
-
* time, for one made while no frame had met the subject.
|
|
20
|
-
*/
|
|
21
|
-
at?: number;
|
|
22
|
-
to?: number[];
|
|
23
|
-
/** Where it moves from, in place of where its stretch has it then. */
|
|
24
|
-
x?: number[];
|
|
25
|
-
v?: number[];
|
|
26
|
-
/** The mix clock when it was made, NaN where no mix was playing the patch. */
|
|
27
|
-
made?: number;
|
|
28
|
-
/** The frame it was made in, which a rewind partitions by; NaN where no mix was playing the patch. */
|
|
29
|
-
seq?: number;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* The mix playing a patch, asked with its voice's id: an owner and an id, where a pair of closures
|
|
33
|
-
* cost two functions, their contexts and a weak reference per voice.
|
|
34
|
-
*/
|
|
35
|
-
export interface MotionOwner {
|
|
36
|
-
/** The subject's voice time at the mix's latest frame; NaN where no frame of the voice met it. */
|
|
37
|
-
frame(id: number, subject: unknown): number;
|
|
38
|
-
/**
|
|
39
|
-
* Brings a subject the voice faded out back to it, so a change is not made for nothing: its
|
|
40
|
-
* voice time now, which a change bringing it back is made at; NaN for any other subject.
|
|
41
|
-
*/
|
|
42
|
-
revive(id: number, subject: unknown): number;
|
|
43
|
-
/** The mix clock at its latest frame; NaN before the first. */
|
|
44
|
-
now(): number;
|
|
45
|
-
/** The number of the frame the mix is playing. */
|
|
46
|
-
seq(): number;
|
|
47
|
-
/**
|
|
48
|
-
* The host made a change, already given its time, which a seek makes again on the patch its
|
|
49
|
-
* voice plays then: a voice a history store paged out comes back with a patch of its own.
|
|
50
|
-
*/
|
|
51
|
-
changed<I>(id: number, motion: Motions<I>, subject: I, change: Change): void;
|
|
52
|
-
/** History leaving memory for a subject, which a mix with a history store pages out. */
|
|
53
|
-
page(id: number, stream: 'released' | 'stretch', subject: unknown, out: Paging[]): void;
|
|
54
|
-
}
|
|
55
|
-
/** A record of a motion patch's history leaving memory, at a mix time and frame. */
|
|
56
|
-
export interface Paging {
|
|
57
|
-
at: number;
|
|
58
|
-
seq: number;
|
|
59
|
-
data: unknown;
|
|
60
|
-
}
|
|
61
|
-
/** A subject's run as plain data: its flags, its stretches oldest first, and changes still to apply. */
|
|
62
|
-
export interface Run {
|
|
63
|
-
flags: number;
|
|
64
|
-
stretches: Segment[];
|
|
65
|
-
pending: Change[] | undefined;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* What a mix keeping copies of a patch's stretches is told, with its id and the subject's number,
|
|
69
|
-
* before one changes.
|
|
70
|
-
*/
|
|
71
|
-
export interface Watcher {
|
|
72
|
-
stretchChanged(id: number, s: number): void;
|
|
73
|
-
}
|
|
74
|
-
export interface Shape<I> {
|
|
75
|
-
from: (subject: I) => number[];
|
|
76
|
-
/** How fast each axis starts moving, given where it starts: still unless the options say. */
|
|
77
|
-
velocity: (subject: I, x: number[]) => number[];
|
|
78
|
-
/**
|
|
79
|
-
* Where it heads when released from `x` at `v`, given where it was heading; `put` for a stretch a
|
|
80
|
-
* `set` released.
|
|
81
|
-
*/
|
|
82
|
-
aim: (x: number[], v: number[], was: number[] | null, subject: I, put: boolean) => number[];
|
|
83
|
-
/** `[form, settle, k1, k2, k3]`. */
|
|
84
|
-
law: readonly number[];
|
|
85
|
-
/** Whether a subject's value is a number rather than an array. */
|
|
86
|
-
scalar: (subject: I) => boolean;
|
|
87
|
-
/** Whether every subject's value is a number; undefined where that depends on the subject. */
|
|
88
|
-
scalarEvery(): boolean | undefined;
|
|
89
|
-
/** A tween's easing, which its law cannot hold; undefined, but present, on every other shape. */
|
|
90
|
-
ease: Curve | undefined;
|
|
91
|
-
/** A tween's ms for a stretch the subject starts now; undefined, but present, on the rest. */
|
|
92
|
-
ms: ((subject: I) => number) | undefined;
|
|
93
|
-
/** The patch's kind and constants, as `Patch.motion` reports them. */
|
|
94
|
-
spec(): MotionSpec;
|
|
13
|
+
export declare const enum Law {
|
|
14
|
+
HEAD = 5
|
|
95
15
|
}
|
|
96
16
|
/**
|
|
97
17
|
* A motion patch's subjects: the stretch each is playing, in one flat array by a number the patch
|
|
@@ -104,16 +24,17 @@ export interface Shape<I> {
|
|
|
104
24
|
* object of its own took a call from 130 ns to 490.
|
|
105
25
|
*/
|
|
106
26
|
export declare class Motions<I> {
|
|
107
|
-
|
|
108
|
-
|
|
27
|
+
readonly shape: Shape<I>;
|
|
28
|
+
readonly numbers: Numbers<I>;
|
|
109
29
|
/** Numbers by subject once a second is numbered: till then the one subject is found by `numbers`. */
|
|
110
|
-
|
|
30
|
+
readonly slots: Store<I, number>;
|
|
111
31
|
/** How many numbers have been given up, so a number kept elsewhere can tell it is stale. */
|
|
112
32
|
freed: number;
|
|
113
33
|
/** Axes per subject; -1 until the first subject sets it. */
|
|
114
34
|
n: number;
|
|
115
35
|
private cap;
|
|
116
|
-
|
|
36
|
+
/** Numbers in each subject's run; a run starts at `base`. Written only here. */
|
|
37
|
+
stride: number;
|
|
117
38
|
/**
|
|
118
39
|
* The law, then each subject's run; empty until the first subject, the law read from `shape`.
|
|
119
40
|
* Read outside, at `bareAt`, and written only here.
|
|
@@ -130,10 +51,10 @@ export declare class Motions<I> {
|
|
|
130
51
|
* until a subject first has one, since many patches are never changed. Each starts with room for
|
|
131
52
|
* one: an empty array written at 0 reserves 17, and most patches have one subject.
|
|
132
53
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
54
|
+
pending: (Change[] | undefined)[] | null;
|
|
55
|
+
older: (Segment[] | undefined)[] | null;
|
|
135
56
|
/** By subject number, the change that released the stretch it is playing; null until one has. */
|
|
136
|
-
|
|
57
|
+
causes: (Change | undefined)[] | null;
|
|
137
58
|
/**
|
|
138
59
|
* The mix playing the patch and its voice's id, which an untimed change and a `read` with no time
|
|
139
60
|
* ask for the latest frame. Set by the mix that cues the patch, and cleared when its voice retires.
|
|
@@ -148,43 +69,29 @@ export declare class Motions<I> {
|
|
|
148
69
|
* where every subject's value is one kind, else on the first sample of a subject whose value is not.
|
|
149
70
|
*/
|
|
150
71
|
cuedOn(channel: string, holdsNumber: boolean): void;
|
|
151
|
-
|
|
72
|
+
frame(subject: I): number;
|
|
152
73
|
constructor(shape: Shape<I>);
|
|
153
74
|
/** The patch's number for `subject`, made with its first stretch on first ask. */
|
|
154
75
|
slot(subject: I): number;
|
|
76
|
+
/** The flags of the run `fresh` last started. */
|
|
77
|
+
private freshFlags;
|
|
78
|
+
/** The stretch a subject met afresh starts with, its axes and the law set up for it, numbering no one. */
|
|
79
|
+
fresh(subject: I): Segment;
|
|
80
|
+
/** The run `fresh` starts, as plain data. */
|
|
81
|
+
freshRun(subject: I): Run;
|
|
155
82
|
/** Sets the axes every subject moves on, at the first. */
|
|
156
|
-
|
|
83
|
+
size(n: number): void;
|
|
157
84
|
/** Numbers `subject`, with room for its run. */
|
|
158
|
-
|
|
85
|
+
take(subject: I): number;
|
|
159
86
|
/** The patch's number for `subject`, undefined where it has none. */
|
|
160
|
-
|
|
87
|
+
known(subject: I): number | undefined;
|
|
161
88
|
/**
|
|
162
89
|
* Subjects released at a mix time a rewind may still reach, with their run as it stood, so a
|
|
163
90
|
* rewind before the release plays them on from there. Empty without history.
|
|
164
91
|
*/
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Forgets a subject, so a later ask starts it afresh from `from`. Given the mix time `at` and frame
|
|
168
|
-
* `seq`, under history, its run is kept for a rewind before then, until `reach` passes it.
|
|
169
|
-
*/
|
|
170
|
-
release(subject: I, at?: number, reach?: number, seq?: number): void;
|
|
171
|
-
/** Puts back each subject released after frame `seq`, as it stood when released. */
|
|
172
|
-
private unrelease;
|
|
173
|
-
/** Subject `s`'s run as it stands. */
|
|
174
|
-
private runAt;
|
|
92
|
+
released: Released<I>[];
|
|
175
93
|
/** Whether the patch holds a run for `subject`. */
|
|
176
94
|
holds(subject: I): boolean;
|
|
177
|
-
/** A subject's run as plain data, for a voice leaving memory; undefined where it has none. */
|
|
178
|
-
pack(subject: I): Run | undefined;
|
|
179
|
-
/** Puts a subject's run back as `pack` or a release left it, replacing any it has now. */
|
|
180
|
-
unpack(subject: I, run: Run): void;
|
|
181
|
-
/** A released run a history store gave back, for a rewind to before its release. */
|
|
182
|
-
reclaim(subject: I, at: number, seq: number, run: Run): void;
|
|
183
|
-
/**
|
|
184
|
-
* Stretches a history store gave back, each by the frame it was in force by: each life of the
|
|
185
|
-
* subject, ended by a release, takes those from its own, ahead of the earliest it still keeps.
|
|
186
|
-
*/
|
|
187
|
-
restretch(subject: I, back: readonly Paging[]): void;
|
|
188
95
|
/**
|
|
189
96
|
* Told, with `watchId`, whenever a subject's stretch or what is pending for it changes, so a mix
|
|
190
97
|
* keeping a copy of it knows to read it again. Set by the mix, cleared when its voice retires. An
|
|
@@ -210,6 +117,8 @@ export declare class Motions<I> {
|
|
|
210
117
|
scalar(s: number): boolean;
|
|
211
118
|
/** The value `at` hands the mix: the first axis for a number, a fresh array otherwise. */
|
|
212
119
|
value(s: number, xs: Float64Array): number | number[];
|
|
120
|
+
/** The value `at` hands the mix for a run with `flags`. */
|
|
121
|
+
valueOf(flags: number, xs: Float64Array): number | number[];
|
|
213
122
|
/**
|
|
214
123
|
* Position and velocity at voice time `t` into `xo` and `vo`, a tween's velocity left at 0. A live
|
|
215
124
|
* read stamps every untimed change with `t` and commits every change due by then, in time order;
|
|
@@ -242,44 +151,42 @@ export declare class Motions<I> {
|
|
|
242
151
|
v: Float64Array;
|
|
243
152
|
s: number;
|
|
244
153
|
} | undefined;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
* The queue keeps the changes with a time in time order, ahead of any still waiting for one.
|
|
248
|
-
*/
|
|
249
|
-
change(subject: I, c: Change): void;
|
|
250
|
-
/** Files a change with a time after every one due by then, ahead of those still waiting for one. */
|
|
251
|
-
private queue;
|
|
252
|
-
/** Every change due by `t` applied to a copy of the stretch playing then, committing nothing. */
|
|
253
|
-
private peek;
|
|
254
|
-
/** Subject `s`'s changes waiting, with those a read ahead's tape made filed among them by time. */
|
|
255
|
-
private dueTo;
|
|
256
|
-
private check;
|
|
257
|
-
private flag;
|
|
154
|
+
check(a: readonly number[] | undefined, n: number): void;
|
|
155
|
+
flag(s: number, bit: number, on: boolean): void;
|
|
258
156
|
forget(s: number): void;
|
|
259
|
-
/**
|
|
260
|
-
* Takes back every change made after frame `seq`: each subject plays from its earliest stretch
|
|
261
|
-
* kept, with the changes made by then queued to be applied again.
|
|
262
|
-
*/
|
|
263
|
-
rewind(seq: number): void;
|
|
264
|
-
private cut;
|
|
265
157
|
/** Where subject `s`'s run starts in `runs`. */
|
|
266
158
|
base(s: number): number;
|
|
267
159
|
private grow;
|
|
268
|
-
|
|
160
|
+
write(s: number, seg: Segment): void;
|
|
269
161
|
/** The stretch subject `s` is playing now, as an object. */
|
|
270
|
-
|
|
162
|
+
latest(s: number): Segment;
|
|
271
163
|
/** The stretch playing at voice time `t`: the latest released by then, else the first. */
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
private commit;
|
|
275
|
-
private insert;
|
|
276
|
-
/**
|
|
277
|
-
* The mix time and frame a stretch was in force by, which a store keys it under: when the change
|
|
278
|
-
* that ended it was made, which falls in the same life of the subject.
|
|
279
|
-
*/
|
|
280
|
-
private made;
|
|
281
|
-
/** Lets go of stretches older than the one in force at `reading.horizon`. */
|
|
282
|
-
private prune;
|
|
283
|
-
private evaluateSegment;
|
|
164
|
+
playing(s: number, t: number): Segment;
|
|
165
|
+
evaluateSegment(seg: Segment, t: number, xo: Float64Array, vo: Float64Array): void;
|
|
284
166
|
private evaluate;
|
|
285
167
|
}
|
|
168
|
+
declare const methods: {
|
|
169
|
+
release: typeof release;
|
|
170
|
+
unrelease: typeof unrelease;
|
|
171
|
+
runAt: typeof runAt;
|
|
172
|
+
pack: typeof pack;
|
|
173
|
+
unpack: typeof unpack;
|
|
174
|
+
reclaim: typeof reclaim;
|
|
175
|
+
runThen: typeof runThen;
|
|
176
|
+
restretch: typeof restretch;
|
|
177
|
+
made: typeof made;
|
|
178
|
+
prune: typeof prune;
|
|
179
|
+
change: typeof change;
|
|
180
|
+
queue: typeof queue;
|
|
181
|
+
peek: typeof peek;
|
|
182
|
+
dueTo: typeof dueTo;
|
|
183
|
+
rewind: typeof rewind;
|
|
184
|
+
cut: typeof cut;
|
|
185
|
+
applied: typeof applied;
|
|
186
|
+
commit: typeof commit;
|
|
187
|
+
insert: typeof insert;
|
|
188
|
+
};
|
|
189
|
+
type Methods = typeof methods;
|
|
190
|
+
export interface Motions<I> extends Methods {
|
|
191
|
+
}
|
|
192
|
+
export {};
|