coily 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/README.md +9 -3
- package/dist/config-OOMMRdK8.d.ts +312 -0
- package/dist/css.d.ts +175 -0
- package/dist/css.js +294 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +16 -3
- package/dist/nuxt.d.ts +8 -0
- package/dist/nuxt.js +1 -0
- package/dist/solver-CVXOTDkZ.js +235 -0
- package/dist/{system-BXxAHM2a.js → system-Br_cPnaN.js} +678 -248
- package/dist/{system-Ci-R4RaI.d.ts → system-Du_fXXmO.d.ts} +185 -277
- package/dist/vue.d.ts +2 -1
- package/dist/vue.js +1 -1
- package/package.json +2 -1
|
@@ -1,276 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A spring's instantaneous motion, measured relative to its target.
|
|
4
|
-
* `SpringDefinition.computeTimeRemaining` takes one; build it from a live
|
|
5
|
-
* spring as `{ position: spring.value - spring.target, velocity: spring.velocity }`.
|
|
6
|
-
*/
|
|
7
|
-
interface SpringState {
|
|
8
|
-
/** Displacement from the target in value units. 0 means at the target. */
|
|
9
|
-
readonly position: number;
|
|
10
|
-
/** Rate of change of the displacement, in value units per second. */
|
|
11
|
-
readonly velocity: number;
|
|
12
|
-
}
|
|
13
|
-
interface BaseOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Decimal places of the resting threshold. A spring rests once its
|
|
16
|
-
* remaining motion cannot reach half a unit in the last place —
|
|
17
|
-
* `0.5 * 10^-precision`, or 0.005 at the default.
|
|
18
|
-
*
|
|
19
|
-
* Values are never rounded; precision only decides rest. See
|
|
20
|
-
* https://github.com/tkofh/coily/blob/main/PRECISION.md.
|
|
21
|
-
*
|
|
22
|
-
* @default 2
|
|
23
|
-
*/
|
|
24
|
-
readonly precision?: number | undefined;
|
|
25
|
-
}
|
|
26
|
-
interface WithMass {
|
|
27
|
-
/**
|
|
28
|
-
* Mass of the moving value. Heavier springs accelerate more slowly and
|
|
29
|
-
* carry more momentum through the target. Must be greater than 0.
|
|
30
|
-
* @default 1
|
|
31
|
-
*/
|
|
32
|
-
readonly mass?: number | undefined;
|
|
33
|
-
}
|
|
34
|
-
interface WithoutMass {
|
|
35
|
-
/**
|
|
36
|
-
* Mass is derived from the other parameters in this input shape
|
|
37
|
-
* and cannot be provided.
|
|
38
|
-
*/
|
|
39
|
-
readonly mass?: undefined;
|
|
40
|
-
}
|
|
41
|
-
interface WithTension {
|
|
42
|
-
/**
|
|
43
|
-
* Spring stiffness. Higher tension pulls toward the target harder,
|
|
44
|
-
* making the whole motion faster. Must be greater than 0.
|
|
45
|
-
*/
|
|
46
|
-
readonly tension: number;
|
|
47
|
-
}
|
|
48
|
-
interface WithDamping {
|
|
49
|
-
/**
|
|
50
|
-
* Friction strength. Higher damping bleeds off velocity faster and
|
|
51
|
-
* reduces bounce; at 0 the spring oscillates forever. Must be greater
|
|
52
|
-
* than or equal to 0.
|
|
53
|
-
*/
|
|
54
|
-
readonly damping: number;
|
|
55
|
-
}
|
|
56
|
-
interface WithDampingRatio {
|
|
57
|
-
/**
|
|
58
|
-
* Damping as a fraction of critical damping — the character of the
|
|
59
|
-
* motion, independent of its speed. Below 1 the spring overshoots and
|
|
60
|
-
* bounces. At 1 it settles as fast as possible without overshooting.
|
|
61
|
-
* Above 1 it settles slower, still without overshooting. At 0 it never
|
|
62
|
-
* settles. Must be greater than or equal to 0.
|
|
63
|
-
*/
|
|
64
|
-
readonly dampingRatio: number;
|
|
65
|
-
}
|
|
66
|
-
interface WithBounce {
|
|
67
|
-
/**
|
|
68
|
-
* Bounciness, converted to a damping ratio as `1 - bounce`. 0 settles
|
|
69
|
-
* as fast as possible without overshooting. Positive values overshoot
|
|
70
|
-
* and bounce; 1, maximum bounce, is clamped just short of undamped so
|
|
71
|
-
* the spring still settles. Negative values settle without bounce, more
|
|
72
|
-
* slowly. Must be between -1 and 1.
|
|
73
|
-
*/
|
|
74
|
-
readonly bounce: number;
|
|
75
|
-
}
|
|
76
|
-
interface WithDuration {
|
|
77
|
-
/**
|
|
78
|
-
* Target settle time in milliseconds. The spring is tuned so its motion
|
|
79
|
-
* decays into the resting threshold within this time, assuming it
|
|
80
|
-
* starts `displacement` away from the target. Actual rest lands at or
|
|
81
|
-
* before the requested duration. Must be greater than 0.
|
|
82
|
-
*/
|
|
83
|
-
readonly duration: number;
|
|
84
|
-
}
|
|
85
|
-
interface WithDisplacement {
|
|
86
|
-
/**
|
|
87
|
-
* The initial displacement the duration tuning assumes. Set it to your
|
|
88
|
-
* animation's range — 300 when animating 0 to 300 — so the settle
|
|
89
|
-
* timing holds; timing skews as the real displacement diverges from
|
|
90
|
-
* this value. Must not be 0.
|
|
91
|
-
* @default 1
|
|
92
|
-
*/
|
|
93
|
-
readonly displacement?: number | undefined;
|
|
94
|
-
}
|
|
95
|
-
interface DirectOptions extends BaseOptions, WithMass, WithTension, WithDamping {}
|
|
96
|
-
interface TensionRatioOptions extends BaseOptions, WithMass, WithTension, WithDampingRatio {}
|
|
97
|
-
interface TensionBounceOptions extends BaseOptions, WithMass, WithTension, WithBounce {}
|
|
98
|
-
interface DampingRatioOptions extends BaseOptions, WithMass, WithDamping, WithDampingRatio {}
|
|
99
|
-
interface DampingBounceOptions extends BaseOptions, WithMass, WithDamping, WithBounce {}
|
|
100
|
-
interface TensionDampingRatioOptions extends BaseOptions, WithoutMass, WithTension, WithDamping, WithDampingRatio {}
|
|
101
|
-
interface TensionDampingBounceOptions extends BaseOptions, WithoutMass, WithTension, WithDamping, WithBounce {}
|
|
102
|
-
interface DurationOptions extends BaseOptions, WithMass, WithDampingRatio, WithDuration, WithDisplacement {}
|
|
103
|
-
interface BounceDurationOptions extends BaseOptions, WithMass, WithBounce, WithDuration, WithDisplacement {}
|
|
104
|
-
interface TensionDurationOptions extends BaseOptions, WithoutMass, WithTension, WithDampingRatio, WithDuration, WithDisplacement {}
|
|
105
|
-
interface TensionBounceDurationOptions extends BaseOptions, WithoutMass, WithTension, WithBounce, WithDuration, WithDisplacement {}
|
|
106
|
-
interface DampingDurationOptions extends BaseOptions, WithoutMass, WithDamping, WithDampingRatio, WithDuration, WithDisplacement {}
|
|
107
|
-
interface DampingBounceDurationOptions extends BaseOptions, WithoutMass, WithDamping, WithBounce, WithDuration, WithDisplacement {}
|
|
108
|
-
/** Every option key accepted by at least one `defineSpring` input shape. */
|
|
109
|
-
type SpringOptionKeys = 'mass' | 'tension' | 'damping' | 'dampingRatio' | 'bounce' | 'duration' | 'displacement' | 'precision';
|
|
110
|
-
/**
|
|
111
|
-
* Marks every option key foreign to `T` as "absent or undefined", so mixing
|
|
112
|
-
* properties from different input shapes fails to type-check instead of
|
|
113
|
-
* silently resolving to an unintended shape at runtime.
|
|
114
|
-
*/
|
|
115
|
-
type Exact<T> = T & { [K in Exclude<SpringOptionKeys, keyof T>]?: undefined; };
|
|
116
|
-
/**
|
|
117
|
-
* Every input `defineSpring` accepts: one of the documented parameter
|
|
118
|
-
* combinations, exactly as written — keys from different combinations
|
|
119
|
-
* don't mix.
|
|
120
|
-
*/
|
|
121
|
-
type SpringDefinitionOptions = Exact<DirectOptions> | Exact<TensionRatioOptions> | Exact<TensionBounceOptions> | Exact<DampingRatioOptions> | Exact<DampingBounceOptions> | Exact<TensionDampingRatioOptions> | Exact<TensionDampingBounceOptions> | Exact<DurationOptions> | Exact<BounceDurationOptions> | Exact<TensionDurationOptions> | Exact<TensionBounceDurationOptions> | Exact<DampingDurationOptions> | Exact<DampingBounceDurationOptions>;
|
|
122
|
-
/**
|
|
123
|
-
* Immutable, resolved spring parameters. Whatever `defineSpring` input
|
|
124
|
-
* shape produced it, a config carries concrete `mass`, `tension`,
|
|
125
|
-
* `damping`, and `precision`, plus the quantities derived from them.
|
|
126
|
-
* Instances are frozen and safe to share between springs; to change a
|
|
127
|
-
* spring's behavior, assign a new config via `spring.config`.
|
|
128
|
-
*/
|
|
129
|
-
declare class SpringDefinition {
|
|
130
|
-
/** The config for springs created without one: critically damped, settling in about 500ms. */
|
|
131
|
-
static readonly default: SpringDefinition;
|
|
132
|
-
/** Mass of the moving value, as provided or derived. */
|
|
133
|
-
readonly mass: number;
|
|
134
|
-
/** Spring stiffness, as provided or derived. */
|
|
135
|
-
readonly tension: number;
|
|
136
|
-
/** Friction strength, as provided or derived. */
|
|
137
|
-
readonly damping: number;
|
|
138
|
-
/** Decimal places of the resting threshold — see `restingMagnitude`. */
|
|
139
|
-
readonly precision: number;
|
|
140
|
-
/** Oscillation rate with no damping: `sqrt(tension / mass)`, in radians per second. */
|
|
141
|
-
readonly naturalFrequency: number;
|
|
142
|
-
/** The damping at which bounce disappears: `2 * mass * naturalFrequency`. */
|
|
143
|
-
readonly criticalDamping: number;
|
|
144
|
-
/**
|
|
145
|
-
* `damping / criticalDamping`. Below 1 the spring overshoots and
|
|
146
|
-
* bounces, at 1 it settles fastest without overshooting, above 1 it
|
|
147
|
-
* settles slower.
|
|
148
|
-
*/
|
|
149
|
-
readonly dampingRatio: number;
|
|
150
|
-
/** Resting threshold in value units: half a unit in the last `precision` place. */
|
|
151
|
-
readonly restingMagnitude: number;
|
|
152
|
-
constructor(input: SpringDefinitionOptions);
|
|
153
|
-
/**
|
|
154
|
-
* Estimates how long a spring with this config takes to come to rest
|
|
155
|
-
* from `state`, in milliseconds.
|
|
156
|
-
*
|
|
157
|
-
* The estimate follows the motion's decay envelope with a 2x safety
|
|
158
|
-
* margin, so actual rest usually lands earlier. Returns 0 when `state`
|
|
159
|
-
* is already inside the resting threshold, and Infinity when the config
|
|
160
|
-
* never settles (a `dampingRatio` of 0).
|
|
161
|
-
*/
|
|
162
|
-
computeTimeRemaining(state: SpringState): number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Creates a config from direct physical parameters: you set stiffness
|
|
166
|
-
* and friction exactly.
|
|
167
|
-
*/
|
|
168
|
-
declare function defineSpring(input: Exact<DirectOptions>): SpringDefinition;
|
|
169
|
-
/**
|
|
170
|
-
* Creates a config from stiffness and motion character. Damping is
|
|
171
|
-
* derived as `2 * dampingRatio * sqrt(mass * tension)`.
|
|
172
|
-
*/
|
|
173
|
-
declare function defineSpring(input: Exact<TensionRatioOptions>): SpringDefinition;
|
|
174
|
-
/**
|
|
175
|
-
* Creates a config from stiffness and bounciness. Damping is derived to
|
|
176
|
-
* match the requested bounce, from -1 (no bounce, slow settle) to 1
|
|
177
|
-
* (maximum bounce).
|
|
178
|
-
*/
|
|
179
|
-
declare function defineSpring(input: Exact<TensionBounceOptions>): SpringDefinition;
|
|
180
|
-
/**
|
|
181
|
-
* Creates a config from friction and motion character. Tension is
|
|
182
|
-
* derived as `damping^2 / (4 * dampingRatio^2 * mass)`; `dampingRatio`
|
|
183
|
-
* must be greater than 0.
|
|
184
|
-
*/
|
|
185
|
-
declare function defineSpring(input: Exact<DampingRatioOptions>): SpringDefinition;
|
|
186
|
-
/**
|
|
187
|
-
* Creates a config from friction and bounciness. Tension is derived to
|
|
188
|
-
* match the requested bounce; `bounce` must be less than 1.
|
|
189
|
-
*/
|
|
190
|
-
declare function defineSpring(input: Exact<DampingBounceOptions>): SpringDefinition;
|
|
191
|
-
/**
|
|
192
|
-
* Creates a config from all three physical knobs. Mass is derived as
|
|
193
|
-
* `damping^2 / (4 * dampingRatio^2 * tension)` and cannot be provided;
|
|
194
|
-
* `dampingRatio` must be greater than 0.
|
|
195
|
-
*/
|
|
196
|
-
declare function defineSpring(input: Exact<TensionDampingRatioOptions>): SpringDefinition;
|
|
197
|
-
/**
|
|
198
|
-
* Creates a config from all three physical knobs. Mass is derived from
|
|
199
|
-
* tension, damping, and the requested bounce, and cannot be provided;
|
|
200
|
-
* `bounce` must be less than 1.
|
|
201
|
-
*/
|
|
202
|
-
declare function defineSpring(input: Exact<TensionDampingBounceOptions>): SpringDefinition;
|
|
203
|
-
/**
|
|
204
|
-
* Tunes the spring to settle within `duration` milliseconds, with
|
|
205
|
-
* `dampingRatio` setting the motion's character. Tension and damping are
|
|
206
|
-
* both derived.
|
|
207
|
-
*
|
|
208
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
209
|
-
* from the target — pass a `displacement` matching your animation range
|
|
210
|
-
* for accurate timing.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
* ```ts
|
|
214
|
-
* // Tuned for a 300px move; rests within 750ms
|
|
215
|
-
* defineSpring({ duration: 750, dampingRatio: 1, displacement: 300 })
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
declare function defineSpring(input: Exact<DurationOptions>): SpringDefinition;
|
|
219
|
-
/**
|
|
220
|
-
* Tunes the spring to settle within `duration` milliseconds, with
|
|
221
|
-
* `bounce` setting how oscillatory the settling motion is. Tension and
|
|
222
|
-
* damping are both derived.
|
|
223
|
-
*
|
|
224
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
225
|
-
* from the target — pass a `displacement` matching your animation range
|
|
226
|
-
* for accurate timing.
|
|
227
|
-
*/
|
|
228
|
-
declare function defineSpring(input: Exact<BounceDurationOptions>): SpringDefinition;
|
|
229
|
-
/**
|
|
230
|
-
* Tunes a spring of the given stiffness to settle within `duration`
|
|
231
|
-
* milliseconds. Mass is derived from tension and the computed natural
|
|
232
|
-
* frequency, then damping from mass and `dampingRatio`; mass cannot be
|
|
233
|
-
* provided.
|
|
234
|
-
*
|
|
235
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
236
|
-
* from the target — pass a `displacement` matching your animation range
|
|
237
|
-
* for accurate timing.
|
|
238
|
-
*/
|
|
239
|
-
declare function defineSpring(input: Exact<TensionDurationOptions>): SpringDefinition;
|
|
240
|
-
/**
|
|
241
|
-
* Tunes a spring of the given stiffness to settle within `duration`
|
|
242
|
-
* milliseconds, with `bounce` setting how oscillatory the settling motion
|
|
243
|
-
* is. Mass is derived from tension and the computed natural frequency,
|
|
244
|
-
* and cannot be provided.
|
|
245
|
-
*
|
|
246
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
247
|
-
* from the target — pass a `displacement` matching your animation range
|
|
248
|
-
* for accurate timing.
|
|
249
|
-
*/
|
|
250
|
-
declare function defineSpring(input: Exact<TensionBounceDurationOptions>): SpringDefinition;
|
|
251
|
-
/**
|
|
252
|
-
* Tunes a spring of the given friction to settle within `duration`
|
|
253
|
-
* milliseconds. Mass is derived from damping, `dampingRatio`, and the
|
|
254
|
-
* computed natural frequency, then tension from mass; mass cannot be
|
|
255
|
-
* provided.
|
|
256
|
-
*
|
|
257
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
258
|
-
* from the target — pass a `displacement` matching your animation range
|
|
259
|
-
* for accurate timing.
|
|
260
|
-
*/
|
|
261
|
-
declare function defineSpring(input: Exact<DampingDurationOptions>): SpringDefinition;
|
|
262
|
-
/**
|
|
263
|
-
* Tunes a spring of the given friction to settle within `duration`
|
|
264
|
-
* milliseconds, with `bounce` setting how oscillatory the settling motion
|
|
265
|
-
* is. Mass is derived from damping and the computed natural frequency,
|
|
266
|
-
* and cannot be provided.
|
|
267
|
-
*
|
|
268
|
-
* The timing assumes the motion starts `displacement` (default 1) away
|
|
269
|
-
* from the target — pass a `displacement` matching your animation range
|
|
270
|
-
* for accurate timing.
|
|
271
|
-
*/
|
|
272
|
-
declare function defineSpring(input: Exact<DampingBounceDurationOptions>): SpringDefinition;
|
|
273
|
-
//#endregion
|
|
1
|
+
import { t as SpringDefinition } from "./config-OOMMRdK8.js";
|
|
274
2
|
//#region src/flush-queue.d.ts
|
|
275
3
|
/**
|
|
276
4
|
* Defers callbacks while inside a batch or tick: `request` runs the
|
|
@@ -295,8 +23,41 @@ declare class FlushQueue {
|
|
|
295
23
|
*/
|
|
296
24
|
declare class Motion {
|
|
297
25
|
#private;
|
|
26
|
+
/** Monotone creation id: breaks ties wherever motions need a deterministic order. */
|
|
27
|
+
readonly _id: number;
|
|
298
28
|
/** Tick-pass marker written by `MotionSet` so a motion re-added mid-pass isn't ticked twice. */
|
|
299
29
|
_pass: number;
|
|
30
|
+
/**
|
|
31
|
+
* Frame marker written by `MotionSet`: sub-steps share one frame, and
|
|
32
|
+
* the first advance in it queues the motion for the settle sweep.
|
|
33
|
+
*/
|
|
34
|
+
_frame: number;
|
|
35
|
+
/**
|
|
36
|
+
* Dependency rank written by `FollowGraph`: motions the follow graph
|
|
37
|
+
* touches count up from 0, leaders before followers; -1 marks a motion
|
|
38
|
+
* outside the graph.
|
|
39
|
+
*/
|
|
40
|
+
_rank: number;
|
|
41
|
+
/**
|
|
42
|
+
* The edge this motion follows through, or null. Written by
|
|
43
|
+
* `FollowGraph` on edge add/remove so the tick's hot loop reads a
|
|
44
|
+
* field instead of a map.
|
|
45
|
+
*/
|
|
46
|
+
_edge: FollowEdge | null;
|
|
47
|
+
/**
|
|
48
|
+
* A first-order-hold ramp slope in value units per second, armed by a
|
|
49
|
+
* ramped `recouple` immediately before the `_advance` that consumes
|
|
50
|
+
* it (read-and-clear; no user code runs between the two). 0 means the
|
|
51
|
+
* target holds still across the step — every path but a ramped
|
|
52
|
+
* recouple.
|
|
53
|
+
*/
|
|
54
|
+
_ramp: number;
|
|
55
|
+
/**
|
|
56
|
+
* The edges reading this motion, or null when none. Written by
|
|
57
|
+
* `FollowGraph` with the rank cache, so it can lag a mid-pass edge
|
|
58
|
+
* change until the next recompute; the tick tolerates stale entries.
|
|
59
|
+
*/
|
|
60
|
+
_followers: FollowEdge[] | null;
|
|
300
61
|
respectsReducedMotion: boolean;
|
|
301
62
|
constructor(config: SpringDefinition, position: number, velocity: number);
|
|
302
63
|
get position(): number;
|
|
@@ -307,7 +68,42 @@ declare class Motion {
|
|
|
307
68
|
get isResting(): boolean;
|
|
308
69
|
configure(config: SpringDefinition): void;
|
|
309
70
|
tick(dt: number, emit?: boolean): void;
|
|
71
|
+
/**
|
|
72
|
+
* Advances the simulation and emits nothing. The tick pass advances
|
|
73
|
+
* every motion through this, then delivers the frame's events with
|
|
74
|
+
* `_settleFrame`; the synchronous `tick` wraps the two.
|
|
75
|
+
*
|
|
76
|
+
* A pending `_ramp` integrates the step against a target moving at
|
|
77
|
+
* that slope instead of holding still: one affine transform around
|
|
78
|
+
* the unchanged solver. With the target at `p(t) = p0 + g*t`, the
|
|
79
|
+
* displacement u = x - p(t) obeys the homogeneous equation shifted by
|
|
80
|
+
* the constant u_ss = -(2*zeta/wn)*g = -(damping/tension)*g, so the
|
|
81
|
+
* solver ticks w = u - u_ss exactly and the results shift back.
|
|
82
|
+
* Measuring u from the moving target makes the ramp endpoint and the
|
|
83
|
+
* new target coincide — the armer assigns the target, no rebase
|
|
84
|
+
* arithmetic exists. The ramp is an argument of the step, never
|
|
85
|
+
* persistent solver state: g = 0 takes the plain step below, so a
|
|
86
|
+
* motion that never ramps steps bit-exactly like an isolated spring.
|
|
87
|
+
*/
|
|
88
|
+
_advance(dt: number): void;
|
|
89
|
+
/**
|
|
90
|
+
* Emits the frame's `update`, then reconciles `stop`/`start`. The tick
|
|
91
|
+
* pass calls this in dependency order after every motion has advanced,
|
|
92
|
+
* so update callbacks read frame-final values everywhere.
|
|
93
|
+
*/
|
|
94
|
+
_settleFrame(): void;
|
|
310
95
|
finish(): void;
|
|
96
|
+
/**
|
|
97
|
+
* The sub-step controller's shock signal, read by a follower's `plan`
|
|
98
|
+
* with this motion as its leader: deviation from the quasi-steady
|
|
99
|
+
* tracking manifold x = -(damping/tension) * v, where damping/tension
|
|
100
|
+
* is 2*zeta/wn. Near zero while chasing any smoothly moving target at
|
|
101
|
+
* any speed; the full displacement after a target teleport;
|
|
102
|
+
* (damping/tension) * |v| after a fling.
|
|
103
|
+
*/
|
|
104
|
+
_manifoldDeviation(): number;
|
|
105
|
+
/** Acceleration from current state, for `plan`'s kinematic bound on a shock frame. */
|
|
106
|
+
_acceleration(): number;
|
|
311
107
|
onUpdate(callback: () => void): () => void;
|
|
312
108
|
onStart(callback: () => void): () => void;
|
|
313
109
|
onStop(callback: () => void): () => void;
|
|
@@ -315,6 +111,86 @@ declare class Motion {
|
|
|
315
111
|
dispose(): void;
|
|
316
112
|
}
|
|
317
113
|
//#endregion
|
|
114
|
+
//#region src/follow-graph.d.ts
|
|
115
|
+
/**
|
|
116
|
+
* One follow relationship, as the system sees it: which motion
|
|
117
|
+
* retargets, which motions it reads, how to re-anchor it, and the
|
|
118
|
+
* sub-step controller's per-edge state. `Spring` registers an edge when
|
|
119
|
+
* a follow is wired to a source with resolvable motions, and
|
|
120
|
+
* unregisters it on unfollow and dispose.
|
|
121
|
+
*/
|
|
122
|
+
interface FollowEdge {
|
|
123
|
+
/** The motion that retargets when its leaders advance. */
|
|
124
|
+
readonly follower: Motion;
|
|
125
|
+
/** The distinct motions behind the followed source, per `resolveLeaderMotions`. */
|
|
126
|
+
readonly leaders: readonly Motion[];
|
|
127
|
+
/**
|
|
128
|
+
* Whether the follower shares a Tarjan SCC with any of its leaders,
|
|
129
|
+
* self-follow included. Written by `FollowGraph` on recompute. Routes
|
|
130
|
+
* `plan` to the ZOH sub-step law: FOH destabilizes cycles that are
|
|
131
|
+
* stable under ZOH, so no ramp may ever arm inside an SCC.
|
|
132
|
+
*/
|
|
133
|
+
_cyclic: boolean;
|
|
134
|
+
/** The follower's target as of the last `plan` call. */
|
|
135
|
+
_prevValue: number;
|
|
136
|
+
/** The followed value's frame delta observed by the last `plan` call. */
|
|
137
|
+
_d1: number;
|
|
138
|
+
/** The frame delta one older than `_d1`; their difference estimates curvature. */
|
|
139
|
+
_d2: number;
|
|
140
|
+
/**
|
|
141
|
+
* Re-anchors the follower to the followed source's current value.
|
|
142
|
+
* `h` is the step the follower is about to advance by, in seconds
|
|
143
|
+
* (the internal tick unit). On an edge where a ramp may arm —
|
|
144
|
+
* acyclic, passthrough arrival, `h > 0`, not a reduced-motion jump —
|
|
145
|
+
* it retargets and arms the follower's `_ramp` with the delta over
|
|
146
|
+
* `h`, so the coming advance integrates against the leader's motion.
|
|
147
|
+
* Every other edge retargets with the exact semantics of the
|
|
148
|
+
* leader-update handler (finite guard, reduced-motion jump).
|
|
149
|
+
*/
|
|
150
|
+
recouple(h: number): void;
|
|
151
|
+
/**
|
|
152
|
+
* Refreshes the estimator from the follower's current target and
|
|
153
|
+
* returns this edge's sub-step demand for a frame of `dt` seconds —
|
|
154
|
+
* unclamped; the caller maxes over edges and clamps. Runs no user
|
|
155
|
+
* code: history is the target trail, freshness reads leader motion
|
|
156
|
+
* state. Call at most once per edge per frame, before any motion
|
|
157
|
+
* advances.
|
|
158
|
+
*/
|
|
159
|
+
plan(dt: number): number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The follow graph as a walkable structure: one edge per following
|
|
163
|
+
* motion, and a cached dependency rank over every motion the edges
|
|
164
|
+
* touch. `MotionSet` owns one; springs register and unregister edges as
|
|
165
|
+
* follows are wired and torn down. What the tick reads per motion —
|
|
166
|
+
* `_edge`, `_followers`, `_rank` — lives on the motions themselves;
|
|
167
|
+
* this class is their writer.
|
|
168
|
+
*/
|
|
169
|
+
declare class FollowGraph {
|
|
170
|
+
#private;
|
|
171
|
+
/** Whether no edges are registered, letting the tick skip ordering work entirely. */
|
|
172
|
+
get isEmpty(): boolean;
|
|
173
|
+
/** Every registered edge, valid after `ensureOrder`; the plan pass walks this once per frame. */
|
|
174
|
+
get edges(): readonly FollowEdge[];
|
|
175
|
+
/**
|
|
176
|
+
* Registers `edge`, replacing any edge with the same follower: a
|
|
177
|
+
* spring follows at most one source at a time.
|
|
178
|
+
*/
|
|
179
|
+
addEdge(edge: FollowEdge): void;
|
|
180
|
+
/** Drops the edge whose follower is `motion`, if one is registered. */
|
|
181
|
+
removeEdge(follower: Motion): void;
|
|
182
|
+
/**
|
|
183
|
+
* Recomputes ranks if an edge was added or removed since the last
|
|
184
|
+
* call; clean calls return immediately. Afterward, motions the graph
|
|
185
|
+
* touches hold ranks counting up from 0 with every leader ranked
|
|
186
|
+
* before its followers, members of a cycle rank in ascending creation
|
|
187
|
+
* id, and motions outside the graph hold -1. Ranks are canonical: a
|
|
188
|
+
* function of graph structure and creation order, never of wiring
|
|
189
|
+
* order.
|
|
190
|
+
*/
|
|
191
|
+
ensureOrder(): void;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
318
194
|
//#region src/motion-set.d.ts
|
|
319
195
|
/**
|
|
320
196
|
* The set of motions currently moving. Motions leave the set as they
|
|
@@ -325,7 +201,16 @@ declare class MotionSet {
|
|
|
325
201
|
#private;
|
|
326
202
|
reduced: boolean;
|
|
327
203
|
onWake: (() => void) | null;
|
|
204
|
+
/**
|
|
205
|
+
* The coupling error budget, in value units: the local per-frame error
|
|
206
|
+
* the sub-step controller targets on each follow edge, floored by the
|
|
207
|
+
* follower's resting magnitude. `SpringSystem` exposes it as the
|
|
208
|
+
* `couplingTolerance` option and property; validation lives there.
|
|
209
|
+
*/
|
|
210
|
+
couplingTolerance: number;
|
|
328
211
|
readonly flushes: FlushQueue;
|
|
212
|
+
/** Follow edges registered by following springs, with the dependency rank over their motions. */
|
|
213
|
+
readonly graph: FollowGraph;
|
|
329
214
|
constructor(debug?: boolean);
|
|
330
215
|
get size(): number;
|
|
331
216
|
add(motion: Motion): void;
|
|
@@ -608,11 +493,16 @@ declare class Spring implements KinematicSource {
|
|
|
608
493
|
get dampingRatio(): number;
|
|
609
494
|
/** The config's resting precision. */
|
|
610
495
|
get precision(): number;
|
|
496
|
+
/** The config's arrival multiplier. */
|
|
497
|
+
get arrival(): number;
|
|
611
498
|
set config(value: SpringDefinition | null);
|
|
612
499
|
/**
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
500
|
+
* Milliseconds until the spring rests: 0 while resting, Infinity when
|
|
501
|
+
* the motion never settles. The time is solved from the motion, not
|
|
502
|
+
* estimated — the spring is resting at the first tick at or after it,
|
|
503
|
+
* and a bouncy spring can rest up to one oscillation earlier when a
|
|
504
|
+
* frame samples a low pulse. When the config's `arrival` is 0, it is
|
|
505
|
+
* capped at the exact ms of the first target crossing.
|
|
616
506
|
*/
|
|
617
507
|
get timeRemaining(): number;
|
|
618
508
|
/**
|
|
@@ -919,6 +809,17 @@ interface CompositeSpringOptions<T extends object> {
|
|
|
919
809
|
purpose?: PurposeShape<T> | undefined;
|
|
920
810
|
}
|
|
921
811
|
interface SpringSystemOptions extends TickerOptions {
|
|
812
|
+
/**
|
|
813
|
+
* How far a spring may trail a source it follows within one frame, in
|
|
814
|
+
* the value's own units. A frame whose motion would exceed it is split
|
|
815
|
+
* into internal sub-steps (at most 8), so followed chains stay
|
|
816
|
+
* accurate through slow frames and sudden retargets. Smaller is
|
|
817
|
+
* tighter and costs more solver work; it never goes finer than the
|
|
818
|
+
* follower's resting precision, and listeners still fire once per
|
|
819
|
+
* frame. Springs that follow nothing are unaffected.
|
|
820
|
+
* @default 0.1
|
|
821
|
+
*/
|
|
822
|
+
couplingTolerance?: number | undefined;
|
|
922
823
|
/**
|
|
923
824
|
* Log active motion counts to the console whenever they change.
|
|
924
825
|
* @default false
|
|
@@ -996,6 +897,13 @@ interface SpringSystem {
|
|
|
996
897
|
* created with `purpose: 'appearance'` animate regardless.
|
|
997
898
|
*/
|
|
998
899
|
readonly reducedMotion: boolean;
|
|
900
|
+
/**
|
|
901
|
+
* How far a spring may trail a source it follows within one frame, in
|
|
902
|
+
* the value's own units — see the `couplingTolerance` option.
|
|
903
|
+
* Assignment accepts any finite number >= 0 and applies from the next
|
|
904
|
+
* frame; 0 means as fine as the follower's resting precision allows.
|
|
905
|
+
*/
|
|
906
|
+
couplingTolerance: number;
|
|
999
907
|
/**
|
|
1000
908
|
* Frame-rate cap. 0 means uncapped: one tick per displayed frame,
|
|
1001
909
|
* whatever rate the screen runs at. Capped ticks land on whole display
|
|
@@ -1029,4 +937,4 @@ interface SpringSystem {
|
|
|
1029
937
|
*/
|
|
1030
938
|
declare function createSpringSystem(options?: SpringSystemOptions): SpringSystem;
|
|
1031
939
|
//#endregion
|
|
1032
|
-
export {
|
|
940
|
+
export { accelerationOf as _, createSpringSystem as a, SpringSourceSymbol as b, ConfigShape as c, ReadonlyShape as d, Shape as f, KinematicSource as g, SpringTarget as h, SpringSystemOptions as i, PartialShape as l, Spring as m, SpringOptions as n, CompositeSpring as o, Purpose as p, SpringSystem as r, CompositeSpringTarget as s, CompositeSpringOptions as t, PurposeShape as u, velocityOf as v, mapSpring as x, SpringSource as y };
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as SpringDefinitionOptions, t as SpringDefinition } from "./config-OOMMRdK8.js";
|
|
2
|
+
import { c as ConfigShape, d as ReadonlyShape, f as Shape, i as SpringSystemOptions, l as PartialShape, m as Spring, n as SpringOptions, o as CompositeSpring, p as Purpose, r as SpringSystem, t as CompositeSpringOptions, y as SpringSource } from "./system-Du_fXXmO.js";
|
|
2
3
|
import { App, MaybeRefOrGetter, Ref, SlotsType } from "vue";
|
|
3
4
|
//#region src/vue/reactive-spring.d.ts
|
|
4
5
|
/**
|
package/dist/vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as SpringSourceSymbol, o as SpringDefinition, r as isSpringSource, t as createSpringSystem } from "./system-Br_cPnaN.js";
|
|
2
2
|
import { computed, customRef, defineComponent, getCurrentInstance, getCurrentScope, inject, onBeforeUnmount, onMounted, onScopeDispose, provide, toRefs, toValue, watchSyncEffect } from "vue";
|
|
3
3
|
//#region src/vue/local.ts
|
|
4
4
|
const localProvides = /* @__PURE__ */ new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coily",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Simulate values using spring physics",
|
|
5
5
|
"homepage": "https://github.com/tkofh/coily#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"exports": {
|
|
21
21
|
".": "./dist/index.js",
|
|
22
|
+
"./css": "./dist/css.js",
|
|
22
23
|
"./nuxt": "./dist/nuxt.js",
|
|
23
24
|
"./vue": "./dist/vue.js",
|
|
24
25
|
"./package.json": "./package.json"
|