@msb235/blits 0.14.0 → 0.15.1

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.
Files changed (187) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/README.md +3 -3
  3. package/dist/ahead.d.ts +26 -0
  4. package/dist/ahead.js +264 -0
  5. package/dist/around.d.ts +11 -0
  6. package/dist/around.js +32 -0
  7. package/dist/bare.js +37 -14
  8. package/dist/blank.d.ts +10 -0
  9. package/dist/blank.js +26 -0
  10. package/dist/blend.d.ts +2 -1
  11. package/dist/blend.js +1 -6
  12. package/dist/bound.d.ts +70 -0
  13. package/dist/bound.js +351 -0
  14. package/dist/chain.d.ts +2 -1
  15. package/dist/chain.js +7 -5
  16. package/dist/changes.d.ts +24 -0
  17. package/dist/changes.js +189 -0
  18. package/dist/channels.d.ts +39 -13
  19. package/dist/channels.js +14 -5
  20. package/dist/color.d.ts +12 -10
  21. package/dist/color.js +25 -25
  22. package/dist/columns.d.ts +2 -1
  23. package/dist/columns.js +62 -38
  24. package/dist/contribution.d.ts +30 -0
  25. package/dist/contribution.js +374 -0
  26. package/dist/copyout.d.ts +10 -0
  27. package/dist/copyout.js +69 -24
  28. package/dist/crowd.d.ts +16 -6
  29. package/dist/crowd.js +20 -11
  30. package/dist/cue.d.ts +8 -1
  31. package/dist/cue.js +39 -13
  32. package/dist/cut.d.ts +8 -0
  33. package/dist/cut.js +4 -0
  34. package/dist/delay.d.ts +3 -0
  35. package/dist/delay.js +7 -0
  36. package/dist/drop.d.ts +9 -0
  37. package/dist/drop.js +84 -0
  38. package/dist/due.d.ts +24 -5
  39. package/dist/due.js +114 -34
  40. package/dist/easing.d.ts +6 -4
  41. package/dist/easing.js +7 -3
  42. package/dist/everyone.d.ts +8 -2
  43. package/dist/everyone.js +33 -3
  44. package/dist/fade.d.ts +2 -1
  45. package/dist/fade.js +2 -1
  46. package/dist/fill.d.ts +3 -2
  47. package/dist/fill.js +52 -20
  48. package/dist/fit.d.ts +44 -26
  49. package/dist/fit.js +10 -9
  50. package/dist/fold.d.ts +4 -37
  51. package/dist/fold.js +5 -513
  52. package/dist/gather.d.ts +12 -7
  53. package/dist/gather.js +179 -44
  54. package/dist/gone.js +2 -2
  55. package/dist/grid.d.ts +47 -0
  56. package/dist/grid.js +247 -0
  57. package/dist/handle.d.ts +2 -0
  58. package/dist/handle.js +14 -8
  59. package/dist/held.d.ts +2 -1
  60. package/dist/held.js +2 -1
  61. package/dist/history.d.ts +6 -5
  62. package/dist/history.js +7 -9
  63. package/dist/hosts.js +9 -15
  64. package/dist/index.d.ts +5 -4
  65. package/dist/keyfill.d.ts +1 -1
  66. package/dist/keyfill.js +5 -3
  67. package/dist/keyrows.d.ts +12 -0
  68. package/dist/keyrows.js +99 -12
  69. package/dist/lane.d.ts +38 -11
  70. package/dist/lane.js +46 -11
  71. package/dist/lanes.d.ts +30 -12
  72. package/dist/lanes.js +56 -36
  73. package/dist/leavings.d.ts +2 -2
  74. package/dist/leavings.js +1 -1
  75. package/dist/lives.d.ts +47 -0
  76. package/dist/lives.js +180 -0
  77. package/dist/meet.d.ts +2 -2
  78. package/dist/meet.js +95 -7
  79. package/dist/mixer.d.ts +56 -37
  80. package/dist/mixer.js +57 -171
  81. package/dist/motion.d.ts +14 -118
  82. package/dist/motion.js +16 -8
  83. package/dist/motions.d.ts +62 -155
  84. package/dist/motions.js +56 -370
  85. package/dist/moved.d.ts +1 -1
  86. package/dist/moved.js +16 -7
  87. package/dist/named.d.ts +6 -2
  88. package/dist/named.js +49 -3
  89. package/dist/numbers.d.ts +7 -0
  90. package/dist/numbers.js +33 -0
  91. package/dist/owed.d.ts +2 -0
  92. package/dist/owed.js +4 -0
  93. package/dist/pack.d.ts +2 -1
  94. package/dist/pack.js +2 -3
  95. package/dist/patch.d.ts +7 -3
  96. package/dist/patch.js +6 -2
  97. package/dist/places.d.ts +53 -0
  98. package/dist/places.js +171 -0
  99. package/dist/plot.d.ts +12 -0
  100. package/dist/plot.js +52 -0
  101. package/dist/project.d.ts +4 -4
  102. package/dist/project.js +9 -212
  103. package/dist/pull.js +22 -9
  104. package/dist/qualify.js +93 -31
  105. package/dist/reading.d.ts +6 -0
  106. package/dist/reading.js +5 -0
  107. package/dist/record.d.ts +5 -1
  108. package/dist/record.js +3 -2
  109. package/dist/relink.d.ts +1 -1
  110. package/dist/renumber.d.ts +10 -0
  111. package/dist/renumber.js +75 -0
  112. package/dist/restored.d.ts +2 -2
  113. package/dist/restored.js +1 -1
  114. package/dist/rests.d.ts +9 -0
  115. package/dist/rests.js +76 -0
  116. package/dist/revive.d.ts +3 -2
  117. package/dist/revive.js +2 -2
  118. package/dist/{locus.d.ts → role.d.ts} +10 -9
  119. package/dist/{locus.js → role.js} +3 -3
  120. package/dist/roles.d.ts +10 -0
  121. package/dist/roles.js +158 -0
  122. package/dist/roster.js +3 -3
  123. package/dist/rotation.d.ts +1 -1
  124. package/dist/rotation.js +1 -1
  125. package/dist/rows.js +28 -20
  126. package/dist/sample.d.ts +2 -2
  127. package/dist/sample.js +33 -7
  128. package/dist/seat.d.ts +17 -0
  129. package/dist/seat.js +25 -0
  130. package/dist/seek.js +5 -5
  131. package/dist/setting.d.ts +27 -0
  132. package/dist/setting.js +55 -0
  133. package/dist/shared.d.ts +1 -1
  134. package/dist/shared.js +1 -1
  135. package/dist/signals.d.ts +64 -32
  136. package/dist/signals.js +20 -18
  137. package/dist/stack.d.ts +5 -5
  138. package/dist/stack.js +5 -5
  139. package/dist/standing.d.ts +2 -1
  140. package/dist/standing.js +3 -2
  141. package/dist/store.d.ts +9 -0
  142. package/dist/store.js +24 -0
  143. package/dist/strays.d.ts +2 -1
  144. package/dist/strays.js +23 -15
  145. package/dist/stretch.d.ts +112 -0
  146. package/dist/stretch.js +9 -0
  147. package/dist/subject.d.ts +142 -0
  148. package/dist/subject.js +1 -0
  149. package/dist/tape.d.ts +9 -5
  150. package/dist/tape.js +5 -1
  151. package/dist/then.d.ts +9 -0
  152. package/dist/then.js +57 -0
  153. package/dist/ticker.d.ts +4 -4
  154. package/dist/trace.d.ts +4 -0
  155. package/dist/trace.js +255 -0
  156. package/dist/transport.d.ts +0 -8
  157. package/dist/transport.js +0 -4
  158. package/dist/turns.d.ts +4 -3
  159. package/dist/turns.js +4 -3
  160. package/dist/types/arc.d.ts +12 -11
  161. package/dist/types/channel.d.ts +12 -8
  162. package/dist/types/history.d.ts +35 -19
  163. package/dist/types/mix.d.ts +237 -163
  164. package/dist/types/motion.d.ts +151 -0
  165. package/dist/types/motion.js +1 -0
  166. package/dist/types/patch.d.ts +67 -34
  167. package/dist/types/place.d.ts +51 -36
  168. package/dist/types/trace.d.ts +51 -0
  169. package/dist/types/trace.js +1 -0
  170. package/dist/types/transport.d.ts +20 -18
  171. package/dist/types/voice.d.ts +144 -73
  172. package/dist/types/watch.d.ts +88 -40
  173. package/dist/types.d.ts +2 -0
  174. package/dist/unreached.d.ts +2 -0
  175. package/dist/unreached.js +7 -0
  176. package/dist/voice.d.ts +10 -143
  177. package/dist/voice.js +37 -82
  178. package/dist/warn.d.ts +2 -0
  179. package/dist/warn.js +1 -1
  180. package/dist/watch.d.ts +2 -2
  181. package/dist/watch.js +5 -3
  182. package/dist/wave.d.ts +4 -3
  183. package/dist/wave.js +3 -2
  184. package/dist/weigh.d.ts +7 -1
  185. package/dist/weigh.js +27 -0
  186. package/docs/schema.html +223 -34
  187. package/package.json +2 -2
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
- * One closed-form stretch: released at `at` (voice ms) from `x0` moving at `v0`, toward `to`, over
5
- * `ms` for a tween (0 for any other shape).
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 interface Segment {
8
- at: number;
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
- private readonly shape;
108
- private readonly numbers;
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
- private readonly slots;
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
- private stride;
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
- private pending;
134
- private older;
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
- private causes;
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
- private frame;
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
- private size;
83
+ size(n: number): void;
157
84
  /** Numbers `subject`, with room for its run. */
158
- private take;
85
+ take(subject: I): number;
159
86
  /** The patch's number for `subject`, undefined where it has none. */
160
- private known;
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
- private released;
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
- * Queues a retarget, set or push, untimed at the latest frame, for `subject`'s next read past its time.
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
- private write;
160
+ write(s: number, seg: Segment): void;
269
161
  /** The stretch subject `s` is playing now, as an object. */
270
- private latest;
162
+ latest(s: number): Segment;
271
163
  /** The stretch playing at voice time `t`: the latest released by then, else the first. */
272
- private playing;
273
- private applied;
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 {};