@glissade/core 0.1.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/LICENSE +202 -0
- package/dist/index.d.ts +462 -0
- package/dist/index.js +1331 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
//#region src/signal.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Pull-based reactive signals: lazy, cached, dependency-tracked (DESIGN.md §2.1).
|
|
4
|
+
*
|
|
5
|
+
* Staleness uses the two-flag scheme: a write marks direct dependents DIRTY and
|
|
6
|
+
* transitive dependents CHECK. A CHECK node re-validates dependency versions on
|
|
7
|
+
* read and only recomputes if one actually changed; a recompute that produces an
|
|
8
|
+
* equal value keeps its version, so dirtiness stops propagating at that node.
|
|
9
|
+
*/
|
|
10
|
+
type Equals<T> = (a: T, b: T) => boolean;
|
|
11
|
+
declare class WriteDuringEvaluationError extends Error {
|
|
12
|
+
constructor();
|
|
13
|
+
}
|
|
14
|
+
declare class CircularDependencyError extends Error {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
/** Begin the pure read phase; any signal write until {@link endReadPhase} throws. */
|
|
18
|
+
declare function beginReadPhase(): void;
|
|
19
|
+
declare function endReadPhase(): void;
|
|
20
|
+
declare function inReadPhase(): boolean;
|
|
21
|
+
interface ReadonlySignal<T> {
|
|
22
|
+
(): T;
|
|
23
|
+
peek(): T;
|
|
24
|
+
subscribe(cb: () => void): () => void;
|
|
25
|
+
}
|
|
26
|
+
interface Signal<T> extends ReadonlySignal<T> {
|
|
27
|
+
set(value: T): void;
|
|
28
|
+
}
|
|
29
|
+
/** Internal surface used by the evaluation driver and timeline binding. */
|
|
30
|
+
interface BindableSignal<T> extends Signal<T> {
|
|
31
|
+
bindSource(fn: () => T): void;
|
|
32
|
+
unbindSource(): void;
|
|
33
|
+
readonly isBound: boolean;
|
|
34
|
+
/** Sanctioned entry write — exempt from the read-phase guard (§2.5). */
|
|
35
|
+
forceSet(value: T): void;
|
|
36
|
+
}
|
|
37
|
+
interface SignalOptions<T> {
|
|
38
|
+
equals?: Equals<T>;
|
|
39
|
+
}
|
|
40
|
+
declare function signal<T>(initial: T, options?: SignalOptions<T>): BindableSignal<T>;
|
|
41
|
+
declare function computed<T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>;
|
|
42
|
+
/** Run `fn` without registering dependencies on the active consumer. */
|
|
43
|
+
declare function untracked<T>(fn: () => T): T;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/valueTypes.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Value-type registry with pluggable per-type interpolation (DESIGN.md §2.2).
|
|
48
|
+
* `extrapolates` declares whether a type's lerp accepts easedT outside [0,1]
|
|
49
|
+
* (spring overshoot); non-extrapolating types clamp.
|
|
50
|
+
*/
|
|
51
|
+
type Vec2 = readonly [number, number];
|
|
52
|
+
interface ValueType<T> {
|
|
53
|
+
id: string;
|
|
54
|
+
lerp(a: T, b: T, t: number): T;
|
|
55
|
+
/** Accepts easedT outside [0,1] (spring overshoot)? Otherwise clamped. */
|
|
56
|
+
extrapolates: boolean;
|
|
57
|
+
equals(a: T, b: T): boolean;
|
|
58
|
+
}
|
|
59
|
+
type ValueTypeId = 'number' | 'vec2' | 'color' | 'string' | 'boolean' | (string & {});
|
|
60
|
+
declare function registerValueType<T>(vt: ValueType<T>): void;
|
|
61
|
+
declare class UnknownValueTypeError extends Error {
|
|
62
|
+
constructor(id: string);
|
|
63
|
+
}
|
|
64
|
+
declare function getValueType<T = unknown>(id: ValueTypeId): ValueType<T>;
|
|
65
|
+
declare const numberType: ValueType<number>;
|
|
66
|
+
declare const vec2Equals: (a: Vec2, b: Vec2) => boolean;
|
|
67
|
+
declare const vec2Type: ValueType<Vec2>;
|
|
68
|
+
declare const colorType: ValueType<string>;
|
|
69
|
+
declare const stringType: ValueType<string>;
|
|
70
|
+
declare const booleanType: ValueType<boolean>;
|
|
71
|
+
declare class ValueTypeInferenceError extends Error {
|
|
72
|
+
constructor(value: unknown);
|
|
73
|
+
}
|
|
74
|
+
/** Infer a registered type id from a sample value (builder + bake authoring surfaces). */
|
|
75
|
+
declare function inferValueType(value: unknown): ValueTypeId;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/vec2Signal.d.ts
|
|
78
|
+
interface Vec2Signal extends ReadonlySignal<Vec2> {
|
|
79
|
+
readonly x: BindableSignal<number>;
|
|
80
|
+
readonly y: BindableSignal<number>;
|
|
81
|
+
set(value: Vec2): void;
|
|
82
|
+
/** Bind the compound level; component bindings on .x/.y override per component. */
|
|
83
|
+
bindSource(fn: () => Vec2): void;
|
|
84
|
+
unbindSource(): void;
|
|
85
|
+
}
|
|
86
|
+
declare function vec2Signal(initial: Vec2 | {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
}): Vec2Signal;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/easing.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* Easing registry + cubic bézier (DESIGN.md §2.2). All functions map [0,1]→ℝ
|
|
94
|
+
* with f(0)=0 and f(1)=1; back/elastic intentionally leave [0,1].
|
|
95
|
+
*/
|
|
96
|
+
type EasingFn = (t: number) => number;
|
|
97
|
+
type EaseSpec = string | {
|
|
98
|
+
kind: 'cubicBezier';
|
|
99
|
+
pts: [number, number, number, number];
|
|
100
|
+
} | {
|
|
101
|
+
kind: 'spring';
|
|
102
|
+
stiffness: number;
|
|
103
|
+
damping: number;
|
|
104
|
+
mass: number;
|
|
105
|
+
};
|
|
106
|
+
declare const easings: Record<string, EasingFn>;
|
|
107
|
+
/** Default property-tween ease (Motion Canvas precedent). */
|
|
108
|
+
declare const DEFAULT_EASE = "easeInOutCubic";
|
|
109
|
+
/**
|
|
110
|
+
* CSS-style cubic bézier where x is time and y is progress. Newton's method
|
|
111
|
+
* with a bisection fallback for the flat-derivative regions.
|
|
112
|
+
*/
|
|
113
|
+
declare function cubicBezier(p1x: number, p1y: number, p2x: number, p2y: number): EasingFn;
|
|
114
|
+
declare class UnknownEasingError extends Error {
|
|
115
|
+
constructor(name: string);
|
|
116
|
+
}
|
|
117
|
+
declare function namedEasing(name: string): EasingFn;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/spring.d.ts
|
|
120
|
+
interface SpringConfig {
|
|
121
|
+
stiffness: number;
|
|
122
|
+
damping: number;
|
|
123
|
+
mass?: number;
|
|
124
|
+
}
|
|
125
|
+
interface SpringEase {
|
|
126
|
+
kind: 'spring';
|
|
127
|
+
stiffness: number;
|
|
128
|
+
damping: number;
|
|
129
|
+
mass: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Settle duration: the earliest time after which |x - 1| stays within
|
|
133
|
+
* settleTolerance. Closed-form via the decay envelope for the underdamped
|
|
134
|
+
* case; bisection on the monotone tail otherwise. Deterministic.
|
|
135
|
+
*/
|
|
136
|
+
declare function duration(cfg: SpringConfig, opts?: {
|
|
137
|
+
settleTolerance?: number;
|
|
138
|
+
}): number;
|
|
139
|
+
/**
|
|
140
|
+
* Spring progress at local time t, affinely rescaled so value(duration) = 1
|
|
141
|
+
* exactly — the raw form only approaches 1, and an unscaled curve would snap
|
|
142
|
+
* at the key (§2.7 "endpoint continuity"). May exceed 1 (overshoot).
|
|
143
|
+
*/
|
|
144
|
+
declare function value(cfg: SpringConfig, t: number, opts?: {
|
|
145
|
+
settleTolerance?: number;
|
|
146
|
+
}): number;
|
|
147
|
+
interface SpringFactory {
|
|
148
|
+
(cfg: SpringConfig): SpringEase;
|
|
149
|
+
duration: typeof duration;
|
|
150
|
+
value: typeof value;
|
|
151
|
+
}
|
|
152
|
+
declare const spring: SpringFactory;
|
|
153
|
+
/**
|
|
154
|
+
* The spring as a normalized easing over a segment whose length must equal
|
|
155
|
+
* spring.duration(cfg) (validated at the document layer, §2.7).
|
|
156
|
+
*/
|
|
157
|
+
declare function springEasing(cfg: SpringConfig): EasingFn;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/color.d.ts
|
|
160
|
+
/**
|
|
161
|
+
* Minimal color support for tracks: hex/rgb(a) parsing, OKLab interpolation
|
|
162
|
+
* (DESIGN.md §2.2 — naive sRGB lerp rejected for its gray dead zones),
|
|
163
|
+
* canonical lowercase-hex serialization.
|
|
164
|
+
*/
|
|
165
|
+
interface Rgba {
|
|
166
|
+
r: number;
|
|
167
|
+
g: number;
|
|
168
|
+
b: number;
|
|
169
|
+
a: number;
|
|
170
|
+
}
|
|
171
|
+
declare class ColorParseError extends Error {
|
|
172
|
+
constructor(input: string);
|
|
173
|
+
}
|
|
174
|
+
declare function parseColor(input: string): Rgba;
|
|
175
|
+
declare function formatColor(c: Rgba): string;
|
|
176
|
+
interface OkLab {
|
|
177
|
+
L: number;
|
|
178
|
+
a: number;
|
|
179
|
+
b: number;
|
|
180
|
+
alpha: number;
|
|
181
|
+
}
|
|
182
|
+
declare function rgbaToOklab(c: Rgba): OkLab;
|
|
183
|
+
declare function oklabToRgba(c: OkLab): Rgba;
|
|
184
|
+
/** Interpolate two CSS color strings in OKLab; t may extrapolate. */
|
|
185
|
+
declare function lerpColor(from: string, to: string, t: number): string;
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/track.d.ts
|
|
188
|
+
interface Key<T = unknown> {
|
|
189
|
+
t: number;
|
|
190
|
+
value: T;
|
|
191
|
+
/** Shape of the segment ARRIVING at this key (from the previous key). */
|
|
192
|
+
ease?: EaseSpec;
|
|
193
|
+
interp?: 'default' | 'hold';
|
|
194
|
+
/** Stable key id (studio-assigned); optional in code-authored documents. */
|
|
195
|
+
id?: string;
|
|
196
|
+
/** Builder-resolved implicit from-value; re-resolved on merge (§2.6, §6.2). */
|
|
197
|
+
derived?: boolean;
|
|
198
|
+
}
|
|
199
|
+
interface Track<T = unknown> {
|
|
200
|
+
/** Canonical path: '<nodeId>/<prop.path>', e.g. 'circle/position.x'. */
|
|
201
|
+
target: string;
|
|
202
|
+
type: ValueTypeId;
|
|
203
|
+
/** Sorted by t; enforced by validateTrack(). */
|
|
204
|
+
keys: Key<T>[];
|
|
205
|
+
/** Studio may own this track's keys via sidecar (§6.2). */
|
|
206
|
+
editable?: boolean;
|
|
207
|
+
}
|
|
208
|
+
declare class TrackValidationError extends Error {
|
|
209
|
+
constructor(target: string, message: string);
|
|
210
|
+
}
|
|
211
|
+
declare function validateTrack(track: Track): void;
|
|
212
|
+
type KeyOpts<T> = Partial<Omit<Key<T>, 't' | 'value'>>;
|
|
213
|
+
declare function key<T>(t: number, value: T, easeOrOpts?: EaseSpec | KeyOpts<T>): Key<T>;
|
|
214
|
+
declare function track<T>(target: string, type: ValueTypeId, keys: Key<T>[], opts?: {
|
|
215
|
+
editable?: boolean;
|
|
216
|
+
}): Track<T>;
|
|
217
|
+
declare function resolveEase(spec: EaseSpec | undefined): EasingFn;
|
|
218
|
+
/** Pure sample of a track at time t (§2.4). */
|
|
219
|
+
declare function sampleTrack<T>(tr: Track<T>, t: number): T;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/timeline.d.ts
|
|
222
|
+
type Json = null | boolean | number | string | Json[] | {
|
|
223
|
+
[k: string]: Json;
|
|
224
|
+
};
|
|
225
|
+
interface Marker {
|
|
226
|
+
t: number;
|
|
227
|
+
name: string;
|
|
228
|
+
data?: Json;
|
|
229
|
+
}
|
|
230
|
+
interface AssetRef {
|
|
231
|
+
kind: 'font' | 'image' | 'audio' | 'video' | 'timeline';
|
|
232
|
+
url: string;
|
|
233
|
+
}
|
|
234
|
+
/** Audio is timeline metadata, never a render product (§5.3). */
|
|
235
|
+
interface AudioClip {
|
|
236
|
+
asset: AssetRef;
|
|
237
|
+
/** timeline seconds (frame-quantized at export via sample-position arithmetic) */
|
|
238
|
+
at: number;
|
|
239
|
+
/** seconds within the source asset */
|
|
240
|
+
trim?: {
|
|
241
|
+
start: number;
|
|
242
|
+
end: number;
|
|
243
|
+
};
|
|
244
|
+
/** gain envelope: a Track whose keys are linear gain multipliers */
|
|
245
|
+
gain?: Track;
|
|
246
|
+
playbackRate?: number;
|
|
247
|
+
}
|
|
248
|
+
interface ChildEntry {
|
|
249
|
+
timeline: Timeline;
|
|
250
|
+
/** Offset on the parent time axis. */
|
|
251
|
+
at: number;
|
|
252
|
+
/**
|
|
253
|
+
* 'add': flattened at compile time into the parent's track space.
|
|
254
|
+
* 'sync': opaque sub-timeline with its own clock (parent t maps through
|
|
255
|
+
* at/timeScale); never coalesced against parent tracks.
|
|
256
|
+
*/
|
|
257
|
+
mode: 'add' | 'sync';
|
|
258
|
+
/** sync-mode only: child plays at this rate. */
|
|
259
|
+
timeScale?: number;
|
|
260
|
+
}
|
|
261
|
+
interface Timeline {
|
|
262
|
+
version: 1;
|
|
263
|
+
duration?: number;
|
|
264
|
+
fps?: number;
|
|
265
|
+
posterTime?: number;
|
|
266
|
+
tracks: Track[];
|
|
267
|
+
labels?: Record<string, number>;
|
|
268
|
+
markers?: Marker[];
|
|
269
|
+
children?: ChildEntry[];
|
|
270
|
+
audio?: AudioClip[];
|
|
271
|
+
assets?: Record<string, AssetRef>;
|
|
272
|
+
}
|
|
273
|
+
interface TimelineInit {
|
|
274
|
+
tracks?: Track[];
|
|
275
|
+
duration?: number;
|
|
276
|
+
fps?: number;
|
|
277
|
+
posterTime?: number;
|
|
278
|
+
labels?: Record<string, number>;
|
|
279
|
+
markers?: Marker[];
|
|
280
|
+
children?: ChildEntry[];
|
|
281
|
+
audio?: AudioClip[];
|
|
282
|
+
assets?: Record<string, AssetRef>;
|
|
283
|
+
}
|
|
284
|
+
declare class TimelineValidationError extends Error {
|
|
285
|
+
constructor(message: string);
|
|
286
|
+
}
|
|
287
|
+
interface CompiledTimeline {
|
|
288
|
+
duration: number;
|
|
289
|
+
labels: Record<string, number>;
|
|
290
|
+
markers: Marker[];
|
|
291
|
+
/** One track per target (§2.2), keys rebased to the root time axis. */
|
|
292
|
+
tracks: Map<string, Track>;
|
|
293
|
+
/** Audio clips rebased to the root time axis (§5.3); sync timeScale scales playbackRate. */
|
|
294
|
+
audio: AudioClip[];
|
|
295
|
+
}
|
|
296
|
+
type DevWarning = (message: string) => void;
|
|
297
|
+
declare function setDevWarning(fn: DevWarning): void;
|
|
298
|
+
/** Internal: emit through the configurable dev-warning channel. */
|
|
299
|
+
|
|
300
|
+
declare function compileTimeline(doc: Timeline): CompiledTimeline;
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/targetRef.d.ts
|
|
303
|
+
/**
|
|
304
|
+
* Target references (DESIGN.md §2.6): the builder accepts either a canonical
|
|
305
|
+
* target string ('circle/opacity') or a property signal that carries its own
|
|
306
|
+
* path — attached by the scene package at node construction via TARGET_PATH.
|
|
307
|
+
*/
|
|
308
|
+
declare const TARGET_PATH: unique symbol;
|
|
309
|
+
interface TargetCarrier {
|
|
310
|
+
[TARGET_PATH]?: string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A target string, or any object carrying TARGET_PATH (property signals of
|
|
314
|
+
* id-bearing nodes). Typed as `object` because signals are callables and the
|
|
315
|
+
* symbol prop is attached dynamically; resolution is checked at build time.
|
|
316
|
+
*/
|
|
317
|
+
type TweenTarget = string | object;
|
|
318
|
+
declare class UnresolvableTargetError extends Error {
|
|
319
|
+
constructor();
|
|
320
|
+
}
|
|
321
|
+
declare function resolveTweenTarget(target: TweenTarget): string;
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/builder.d.ts
|
|
324
|
+
type Position = number | string;
|
|
325
|
+
interface TweenOpts<T = unknown> {
|
|
326
|
+
duration?: number;
|
|
327
|
+
ease?: EaseSpec;
|
|
328
|
+
at?: Position;
|
|
329
|
+
/** Explicit start value — sugar for fromTo; required ergonomics for string targets. */
|
|
330
|
+
from?: T;
|
|
331
|
+
}
|
|
332
|
+
interface TimelineBuilder {
|
|
333
|
+
to<T>(target: TweenTarget, value: T, opts?: TweenOpts<T>): TimelineBuilder;
|
|
334
|
+
fromTo<T>(target: TweenTarget, from: T, to: T, opts?: TweenOpts<T>): TimelineBuilder;
|
|
335
|
+
/** Hold key: the value snaps at the resolved position (§2.6). */
|
|
336
|
+
set<T>(target: TweenTarget, value: T, opts?: {
|
|
337
|
+
at?: Position;
|
|
338
|
+
}): TimelineBuilder;
|
|
339
|
+
label(name: string, at?: Position): TimelineBuilder;
|
|
340
|
+
add(child: Timeline, at?: Position, opts?: {
|
|
341
|
+
mode?: 'add' | 'sync';
|
|
342
|
+
timeScale?: number;
|
|
343
|
+
}): TimelineBuilder;
|
|
344
|
+
/** Compiles to a marker; the callback is Player-registered, never serialized (§4.2). */
|
|
345
|
+
call(fn: () => void, at?: Position): TimelineBuilder;
|
|
346
|
+
/** Mark the preceding track editable for the studio (§6.2). */
|
|
347
|
+
editable(): TimelineBuilder;
|
|
348
|
+
}
|
|
349
|
+
declare class PositionError extends Error {
|
|
350
|
+
constructor(pos: string, detail: string);
|
|
351
|
+
}
|
|
352
|
+
declare function getTimelineCallbacks(doc: Timeline): ReadonlyMap<string, () => void>;
|
|
353
|
+
declare function buildTimeline(build: (tl: TimelineBuilder) => void, init?: Omit<TimelineInit, 'tracks' | 'children' | 'markers'>): Timeline;
|
|
354
|
+
/** The two authoring surfaces, one entry point (§2.6). */
|
|
355
|
+
declare function timeline(init: TimelineInit): Timeline;
|
|
356
|
+
declare function timeline(build: (tl: TimelineBuilder) => void, init?: Omit<TimelineInit, 'tracks' | 'children' | 'markers'>): Timeline;
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/binding.d.ts
|
|
359
|
+
type Playhead = BindableSignal<number>;
|
|
360
|
+
declare function createPlayhead(initial?: number): Playhead;
|
|
361
|
+
declare class UnboundTargetError extends Error {
|
|
362
|
+
constructor(target: string);
|
|
363
|
+
}
|
|
364
|
+
interface BindTarget {
|
|
365
|
+
bindSource(fn: () => unknown): void;
|
|
366
|
+
unbindSource(): void;
|
|
367
|
+
}
|
|
368
|
+
interface BoundTimeline {
|
|
369
|
+
playhead: Playhead;
|
|
370
|
+
/** Detach every track binding, freezing signals at their last values. */
|
|
371
|
+
unbind(): void;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Bind a compiled timeline's tracks to property signals. `resolve` returns
|
|
375
|
+
* the signal for a target path, or undefined — which is a compile-time-style
|
|
376
|
+
* error (§2.2: unbound tracks are build errors, not silent no-ops).
|
|
377
|
+
*/
|
|
378
|
+
declare function bindTimeline(compiled: CompiledTimeline, resolve: (target: string) => BindTarget | undefined, playhead?: Playhead): BoundTimeline;
|
|
379
|
+
/**
|
|
380
|
+
* The evaluation entry discipline (§2.5): the playhead write is the sanctioned
|
|
381
|
+
* entry mutation, then the read phase begins and `read` must be pure.
|
|
382
|
+
*/
|
|
383
|
+
declare function evaluateAt<R>(playhead: Playhead, t: number, read: () => R): R;
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/rng.d.ts
|
|
386
|
+
/**
|
|
387
|
+
* Seeded RNG (DESIGN.md §5.5): the only sanctioned randomness in scene code.
|
|
388
|
+
* splitmix32 — deterministic, fast, good enough distribution for motion.
|
|
389
|
+
*/
|
|
390
|
+
type Rng = () => number;
|
|
391
|
+
/** Returns a deterministic [0,1) generator for the given integer seed. */
|
|
392
|
+
declare function random(seed: number): Rng;
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/bake.d.ts
|
|
395
|
+
interface BakeConfig<W> {
|
|
396
|
+
/** seconds of simulation; keys land on the frame grid */
|
|
397
|
+
duration: number;
|
|
398
|
+
/** fixed dt = 1/fps — never wall clock */
|
|
399
|
+
fps: number;
|
|
400
|
+
seed?: number;
|
|
401
|
+
setup: (rng: Rng) => W;
|
|
402
|
+
/** Advance one fixed step. Return the next world, or mutate in place and return nothing. */
|
|
403
|
+
step: (world: W, dt: number, rng: Rng) => W | undefined | void;
|
|
404
|
+
/** One value per target path; sampled every frame. */
|
|
405
|
+
sample: (world: W) => Record<string, unknown>;
|
|
406
|
+
}
|
|
407
|
+
declare class BakeError extends Error {
|
|
408
|
+
constructor(detail: string);
|
|
409
|
+
}
|
|
410
|
+
declare function bake<W>(cfg: BakeConfig<W>): Track[];
|
|
411
|
+
interface CheckpointedBakeConfig<W, S = W> extends BakeConfig<W> {
|
|
412
|
+
/** snapshot every K frames */
|
|
413
|
+
every: number;
|
|
414
|
+
snapshot: (world: W) => S;
|
|
415
|
+
restore: (snap: S) => W;
|
|
416
|
+
}
|
|
417
|
+
interface CheckpointedSim {
|
|
418
|
+
/**
|
|
419
|
+
* Re-simulate from the nearest checkpoint and emit tracks covering
|
|
420
|
+
* [fromFrame, toFrame] (inclusive). Bit-identical to the same slice of a
|
|
421
|
+
* full bake() — only the memory/latency profile differs (§2.8). Export
|
|
422
|
+
* shards call this per range.
|
|
423
|
+
*/
|
|
424
|
+
bakeRange(fromFrame: number, toFrame: number): Track[];
|
|
425
|
+
readonly frames: number;
|
|
426
|
+
}
|
|
427
|
+
declare function bakeCheckpointed<W, S = W>(cfg: CheckpointedBakeConfig<W, S>): CheckpointedSim;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/sidecar.d.ts
|
|
430
|
+
interface SidecarDoc {
|
|
431
|
+
sidecarVersion: 1;
|
|
432
|
+
/** Editor-owned tracks, replacing same-target code tracks wholesale. */
|
|
433
|
+
tracks: Track[];
|
|
434
|
+
/** Editor-owned labels; merged over code labels by name. */
|
|
435
|
+
labels?: Record<string, number>;
|
|
436
|
+
}
|
|
437
|
+
declare class SidecarVersionError extends Error {
|
|
438
|
+
constructor(version: unknown);
|
|
439
|
+
}
|
|
440
|
+
declare function emptySidecar(): SidecarDoc;
|
|
441
|
+
/**
|
|
442
|
+
* Editor-edit normalization (§2.7 invariant): a spring-eased key's t is
|
|
443
|
+
* intrinsic — prev.t + spring.duration(cfg) — so after any retime, sort and
|
|
444
|
+
* re-pin spring keys to their predecessors. Dragging a spring key itself
|
|
445
|
+
* therefore snaps back; retiming its predecessor carries it along. Returns a
|
|
446
|
+
* new array. Colliding keys are NUDGED apart (+1ms), never deleted — an
|
|
447
|
+
* editor must not silently destroy keyframe data on an exact-t collision.
|
|
448
|
+
*/
|
|
449
|
+
declare function normalizeEditedKeys(keys: Key[]): Key[];
|
|
450
|
+
/**
|
|
451
|
+
* Merge rules (§6.2, schema-drift resolution):
|
|
452
|
+
* - a sidecar track whose target exists in code REPLACES that track's keys
|
|
453
|
+
* (the editor owns it; `editable` is preserved on the result);
|
|
454
|
+
* - a sidecar track with no code counterpart is ADDED (editor-created track);
|
|
455
|
+
* - sidecar tracks targeting nothing the scene can bind fail later at
|
|
456
|
+
* bindTimeline with UnboundTargetError — surfaced, never silently dropped;
|
|
457
|
+
* - code tracks without sidecar counterparts pass through untouched.
|
|
458
|
+
* The input documents are not mutated.
|
|
459
|
+
*/
|
|
460
|
+
declare function mergeSidecar(code: Timeline, sidecar: SidecarDoc | null | undefined): Timeline;
|
|
461
|
+
//#endregion
|
|
462
|
+
export { type AssetRef, type AudioClip, type BakeConfig, BakeError, type BindTarget, type BindableSignal, type BoundTimeline, type CheckpointedBakeConfig, type CheckpointedSim, type ChildEntry, CircularDependencyError, ColorParseError, type CompiledTimeline, DEFAULT_EASE, type DevWarning, type EaseSpec, type EasingFn, type Equals, type Json, type Key, type KeyOpts, type Marker, type OkLab, type Playhead, type Position, PositionError, type ReadonlySignal, type Rgba, type Rng, type SidecarDoc, SidecarVersionError, type Signal, type SignalOptions, type SpringConfig, type SpringEase, TARGET_PATH, type TargetCarrier, type Timeline, type TimelineBuilder, type TimelineInit, TimelineValidationError, type Track, TrackValidationError, type TweenOpts, type TweenTarget, UnboundTargetError, UnknownEasingError, UnknownValueTypeError, UnresolvableTargetError, type ValueType, type ValueTypeId, ValueTypeInferenceError, type Vec2, type Vec2Signal, WriteDuringEvaluationError, bake, bakeCheckpointed, beginReadPhase, bindTimeline, booleanType, buildTimeline, colorType, compileTimeline, computed, createPlayhead, cubicBezier, easings, emptySidecar, endReadPhase, evaluateAt, formatColor, getTimelineCallbacks, getValueType, inReadPhase, inferValueType, key, lerpColor, mergeSidecar, namedEasing, normalizeEditedKeys, numberType, oklabToRgba, parseColor, random, registerValueType, resolveEase, resolveTweenTarget, rgbaToOklab, sampleTrack, setDevWarning, signal, spring, springEasing, stringType, timeline, track, untracked, validateTrack, vec2Equals, vec2Signal, vec2Type };
|