@typecaast/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 +201 -0
- package/dist/chunk-WIDXYJSW.js +152 -0
- package/dist/chunk-WIDXYJSW.js.map +1 -0
- package/dist/create-player-CEAzKJn1.d.cts +207 -0
- package/dist/create-player-CEAzKJn1.d.ts +207 -0
- package/dist/index.cjs +522 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +206 -0
- package/dist/index.d.ts +206 -0
- package/dist/index.js +358 -0
- package/dist/index.js.map +1 -0
- package/dist/mocks/index.cjs +319 -0
- package/dist/mocks/index.cjs.map +1 -0
- package/dist/mocks/index.d.cts +24 -0
- package/dist/mocks/index.d.ts +24 -0
- package/dist/mocks/index.js +161 -0
- package/dist/mocks/index.js.map +1 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/engine/create-player.ts
|
|
2
|
+
function now() {
|
|
3
|
+
const perf = globalThis.performance;
|
|
4
|
+
return perf ? perf.now() : Date.now();
|
|
5
|
+
}
|
|
6
|
+
function schedule(cb) {
|
|
7
|
+
const g = globalThis;
|
|
8
|
+
if (g.requestAnimationFrame) return g.requestAnimationFrame(() => cb());
|
|
9
|
+
return g.setTimeout ? g.setTimeout(cb, 16) : 0;
|
|
10
|
+
}
|
|
11
|
+
function unschedule(handle) {
|
|
12
|
+
const g = globalThis;
|
|
13
|
+
if (g.cancelAnimationFrame) g.cancelAnimationFrame(handle);
|
|
14
|
+
else if (g.clearTimeout) g.clearTimeout(handle);
|
|
15
|
+
}
|
|
16
|
+
var TimelinePlayer = class {
|
|
17
|
+
getStateAt;
|
|
18
|
+
_durationMs;
|
|
19
|
+
steps;
|
|
20
|
+
_currentMs = 0;
|
|
21
|
+
_rate;
|
|
22
|
+
_loop;
|
|
23
|
+
_playing = false;
|
|
24
|
+
_state;
|
|
25
|
+
anchor = 0;
|
|
26
|
+
frame = null;
|
|
27
|
+
listeners = /* @__PURE__ */ new Map();
|
|
28
|
+
constructor(getStateAt, options) {
|
|
29
|
+
this.getStateAt = getStateAt;
|
|
30
|
+
this._durationMs = options.durationMs;
|
|
31
|
+
this.steps = (options.steps ?? [0, options.durationMs]).slice().sort((a, b) => a - b);
|
|
32
|
+
this._rate = options.rate ?? 1;
|
|
33
|
+
this._loop = options.loop ?? false;
|
|
34
|
+
this._state = getStateAt(0);
|
|
35
|
+
if (options.autoplay) this.play();
|
|
36
|
+
}
|
|
37
|
+
get state() {
|
|
38
|
+
return this._state;
|
|
39
|
+
}
|
|
40
|
+
get durationMs() {
|
|
41
|
+
return this._durationMs;
|
|
42
|
+
}
|
|
43
|
+
get currentMs() {
|
|
44
|
+
return this._currentMs;
|
|
45
|
+
}
|
|
46
|
+
get rate() {
|
|
47
|
+
return this._rate;
|
|
48
|
+
}
|
|
49
|
+
get playing() {
|
|
50
|
+
return this._playing;
|
|
51
|
+
}
|
|
52
|
+
get loop() {
|
|
53
|
+
return this._loop;
|
|
54
|
+
}
|
|
55
|
+
play() {
|
|
56
|
+
if (this._playing) return;
|
|
57
|
+
this._playing = true;
|
|
58
|
+
this.anchor = now() - this._currentMs / this._rate;
|
|
59
|
+
this.emit("play", void 0);
|
|
60
|
+
this.tick();
|
|
61
|
+
}
|
|
62
|
+
pause() {
|
|
63
|
+
if (!this._playing) return;
|
|
64
|
+
this._playing = false;
|
|
65
|
+
if (this.frame !== null) {
|
|
66
|
+
unschedule(this.frame);
|
|
67
|
+
this.frame = null;
|
|
68
|
+
}
|
|
69
|
+
this.emit("pause", void 0);
|
|
70
|
+
}
|
|
71
|
+
tick = () => {
|
|
72
|
+
if (!this._playing) return;
|
|
73
|
+
const elapsed = (now() - this.anchor) * this._rate;
|
|
74
|
+
if (elapsed >= this._durationMs) {
|
|
75
|
+
if (this._loop) {
|
|
76
|
+
this._currentMs = 0;
|
|
77
|
+
this.anchor = now();
|
|
78
|
+
this.sampleAndEmit();
|
|
79
|
+
this.frame = schedule(this.tick);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this._currentMs = this._durationMs;
|
|
83
|
+
this.sampleAndEmit();
|
|
84
|
+
this.pause();
|
|
85
|
+
this.emit("end", void 0);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this._currentMs = elapsed;
|
|
89
|
+
this.sampleAndEmit();
|
|
90
|
+
this.frame = schedule(this.tick);
|
|
91
|
+
};
|
|
92
|
+
sampleAndEmit() {
|
|
93
|
+
this._state = this.getStateAt(this._currentMs);
|
|
94
|
+
this.emit("tick", this._state);
|
|
95
|
+
}
|
|
96
|
+
clamp(t) {
|
|
97
|
+
return t < 0 ? 0 : t > this._durationMs ? this._durationMs : t;
|
|
98
|
+
}
|
|
99
|
+
seek(timeMs) {
|
|
100
|
+
this._currentMs = this.clamp(timeMs);
|
|
101
|
+
this.anchor = now() - this._currentMs / this._rate;
|
|
102
|
+
this.sampleAndEmit();
|
|
103
|
+
this.emit("seek", this._currentMs);
|
|
104
|
+
}
|
|
105
|
+
scrubTo(timeMs) {
|
|
106
|
+
this.seek(timeMs);
|
|
107
|
+
}
|
|
108
|
+
setRate(rate) {
|
|
109
|
+
this._rate = rate <= 0 ? 1 : rate;
|
|
110
|
+
this.anchor = now() - this._currentMs / this._rate;
|
|
111
|
+
}
|
|
112
|
+
setLoop(loop) {
|
|
113
|
+
this._loop = loop;
|
|
114
|
+
}
|
|
115
|
+
stepNext() {
|
|
116
|
+
const next = this.steps.find((s) => s > this._currentMs + 1e-6);
|
|
117
|
+
this.seek(next ?? this._durationMs);
|
|
118
|
+
}
|
|
119
|
+
stepPrev() {
|
|
120
|
+
const prev = [...this.steps].reverse().find((s) => s < this._currentMs - 1e-6);
|
|
121
|
+
this.seek(prev ?? 0);
|
|
122
|
+
}
|
|
123
|
+
on(event, listener) {
|
|
124
|
+
let set = this.listeners.get(event);
|
|
125
|
+
if (!set) {
|
|
126
|
+
set = /* @__PURE__ */ new Set();
|
|
127
|
+
this.listeners.set(event, set);
|
|
128
|
+
}
|
|
129
|
+
set.add(listener);
|
|
130
|
+
return () => this.off(event, listener);
|
|
131
|
+
}
|
|
132
|
+
off(event, listener) {
|
|
133
|
+
this.listeners.get(event)?.delete(listener);
|
|
134
|
+
}
|
|
135
|
+
emit(event, payload) {
|
|
136
|
+
const set = this.listeners.get(event);
|
|
137
|
+
if (!set) return;
|
|
138
|
+
for (const listener of set)
|
|
139
|
+
listener(payload);
|
|
140
|
+
}
|
|
141
|
+
destroy() {
|
|
142
|
+
this.pause();
|
|
143
|
+
this.listeners.clear();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function createPlayer(getStateAt, options) {
|
|
147
|
+
return new TimelinePlayer(getStateAt, options);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { TimelinePlayer, createPlayer };
|
|
151
|
+
//# sourceMappingURL=chunk-WIDXYJSW.js.map
|
|
152
|
+
//# sourceMappingURL=chunk-WIDXYJSW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/create-player.ts"],"names":[],"mappings":";AAkBA,SAAS,GAAA,GAAc;AACrB,EAAA,MAAM,OAAQ,UAAA,CACX,WAAA;AACH,EAAA,OAAO,IAAA,GAAO,IAAA,CAAK,GAAA,EAAI,GAAI,KAAK,GAAA,EAAI;AACtC;AAWA,SAAS,SAAS,EAAA,EAA6B;AAC7C,EAAA,MAAM,CAAA,GAAI,UAAA;AACV,EAAA,I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AA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA;AAAA,IAC/B;AACA,IAAA,GAAA,CAAI,IAAI,QAAoC,CAAA;AAC5C,IAAA,OAAO,MAAM,IAAA,CAAK,GAAA,CAAI,KAAA,EAAO,QAAQ,CAAA;AAAA,EACvC;AAAA,EAEA,GAAA,CACE,OACA,QAAA,EACM;AACN,IAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,KAAK,CAAA,EAAG,OAAO,QAAoC,CAAA;AAAA,EACxE;AAAA,EAEQ,IAAA,CACN,OACA,OAAA,EACM;AACN,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,KAAK,CAAA;AACpC,IAAA,IAAI,CAAC,GAAA,EAAK;AACV,IAAA,KAAA,MAAW,QAAA,IAAY,GAAA;AACrB,MAAC,SAA4C,OAAO,CAAA;AAAA,EACxD;AAAA,EAEA,OAAA,GAAgB;AACd,IAAA,IAAA,CAAK,KAAA,EAAM;AACX,IAAA,IAAA,CAAK,UAAU,KAAA,EAAM;AAAA,EACvB;AACF;AAGO,SAAS,YAAA,CACd,YACA,OAAA,EACQ;AACR,EAAA,OAAO,IAAI,cAAA,CAAe,UAAA,EAAY,OAAO,CAAA;AAC/C","file":"chunk-WIDXYJSW.js","sourcesContent":["import type {\n GetStateAt,\n Player,\n PlayerEvent,\n PlayerEventMap,\n} from \"../player.js\";\nimport type { SimState } from \"../sim-state.js\";\n\nexport interface PlayerOptions {\n durationMs: number;\n /** Step boundaries (ms) for stepNext/stepPrev. */\n steps?: number[];\n autoplay?: boolean;\n loop?: boolean;\n rate?: number;\n}\n\n/** A monotonic time source; reading it doesn't affect `getStateAt` determinism. */\nfunction now(): number {\n const perf = (globalThis as unknown as { performance?: { now(): number } })\n .performance;\n return perf ? perf.now() : Date.now();\n}\n\ntype FrameHandle = number;\n\ninterface SchedulerGlobals {\n requestAnimationFrame?: (cb: (time: number) => void) => number;\n cancelAnimationFrame?: (handle: number) => void;\n setTimeout?: (cb: () => void, ms: number) => number;\n clearTimeout?: (handle: number) => void;\n}\n\nfunction schedule(cb: () => void): FrameHandle {\n const g = globalThis as unknown as SchedulerGlobals;\n if (g.requestAnimationFrame) return g.requestAnimationFrame(() => cb());\n return g.setTimeout ? g.setTimeout(cb, 16) : 0;\n}\nfunction unschedule(handle: FrameHandle): void {\n const g = globalThis as unknown as SchedulerGlobals;\n if (g.cancelAnimationFrame) g.cancelAnimationFrame(handle);\n else if (g.clearTimeout) g.clearTimeout(handle);\n}\n\n/**\n * The real-time `Player`: a thin clock wrapper around a pure `GetStateAt`\n * (PLAN §5). It owns the only wall-clock in the system (rAF in the browser, a\n * timeout fallback elsewhere) and samples the engine each tick. The same class\n * drove the UI over the mock and now drives it over the real engine — identical\n * surface, so swapping the engine changes nothing here.\n */\nexport class TimelinePlayer implements Player {\n private readonly getStateAt: GetStateAt;\n private readonly _durationMs: number;\n private readonly steps: number[];\n private _currentMs = 0;\n private _rate: number;\n private _loop: boolean;\n private _playing = false;\n private _state: SimState;\n private anchor = 0;\n private frame: FrameHandle | null = null;\n private listeners = new Map<PlayerEvent, Set<(payload: never) => void>>();\n\n constructor(getStateAt: GetStateAt, options: PlayerOptions) {\n this.getStateAt = getStateAt;\n this._durationMs = options.durationMs;\n this.steps = (options.steps ?? [0, options.durationMs])\n .slice()\n .sort((a, b) => a - b);\n this._rate = options.rate ?? 1;\n this._loop = options.loop ?? false;\n this._state = getStateAt(0);\n if (options.autoplay) this.play();\n }\n\n get state(): SimState {\n return this._state;\n }\n get durationMs(): number {\n return this._durationMs;\n }\n get currentMs(): number {\n return this._currentMs;\n }\n get rate(): number {\n return this._rate;\n }\n get playing(): boolean {\n return this._playing;\n }\n get loop(): boolean {\n return this._loop;\n }\n\n play(): void {\n if (this._playing) return;\n this._playing = true;\n this.anchor = now() - this._currentMs / this._rate;\n this.emit(\"play\", undefined);\n this.tick();\n }\n\n pause(): void {\n if (!this._playing) return;\n this._playing = false;\n if (this.frame !== null) {\n unschedule(this.frame);\n this.frame = null;\n }\n this.emit(\"pause\", undefined);\n }\n\n private tick = (): void => {\n if (!this._playing) return;\n const elapsed = (now() - this.anchor) * this._rate;\n if (elapsed >= this._durationMs) {\n if (this._loop) {\n this._currentMs = 0;\n this.anchor = now();\n this.sampleAndEmit();\n this.frame = schedule(this.tick);\n return;\n }\n this._currentMs = this._durationMs;\n this.sampleAndEmit();\n this.pause();\n this.emit(\"end\", undefined);\n return;\n }\n this._currentMs = elapsed;\n this.sampleAndEmit();\n this.frame = schedule(this.tick);\n };\n\n private sampleAndEmit(): void {\n this._state = this.getStateAt(this._currentMs);\n this.emit(\"tick\", this._state);\n }\n\n private clamp(t: number): number {\n return t < 0 ? 0 : t > this._durationMs ? this._durationMs : t;\n }\n\n seek(timeMs: number): void {\n this._currentMs = this.clamp(timeMs);\n this.anchor = now() - this._currentMs / this._rate;\n this.sampleAndEmit();\n this.emit(\"seek\", this._currentMs);\n }\n\n scrubTo(timeMs: number): void {\n this.seek(timeMs);\n }\n\n setRate(rate: number): void {\n this._rate = rate <= 0 ? 1 : rate;\n this.anchor = now() - this._currentMs / this._rate;\n }\n\n setLoop(loop: boolean): void {\n this._loop = loop;\n }\n\n stepNext(): void {\n const next = this.steps.find((s) => s > this._currentMs + 1e-6);\n this.seek(next ?? this._durationMs);\n }\n\n stepPrev(): void {\n const prev = [...this.steps]\n .reverse()\n .find((s) => s < this._currentMs - 1e-6);\n this.seek(prev ?? 0);\n }\n\n on<E extends PlayerEvent>(\n event: E,\n listener: (payload: PlayerEventMap[E]) => void,\n ): () => void {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(listener as (payload: never) => void);\n return () => this.off(event, listener);\n }\n\n off<E extends PlayerEvent>(\n event: E,\n listener: (payload: PlayerEventMap[E]) => void,\n ): void {\n this.listeners.get(event)?.delete(listener as (payload: never) => void);\n }\n\n private emit<E extends PlayerEvent>(\n event: E,\n payload: PlayerEventMap[E],\n ): void {\n const set = this.listeners.get(event);\n if (!set) return;\n for (const listener of set)\n (listener as (p: PlayerEventMap[E]) => void)(payload);\n }\n\n destroy(): void {\n this.pause();\n this.listeners.clear();\n }\n}\n\n/** Create a real-time player over a `GetStateAt`. */\nexport function createPlayer(\n getStateAt: GetStateAt,\n options: PlayerOptions,\n): Player {\n return new TimelinePlayer(getStateAt, options);\n}\n"]}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { ContentNode } from '@typecaast/schema';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The resolved theme for a render. `auto` is resolved to a concrete mode before
|
|
5
|
+
* it reaches `SimState` / skins.
|
|
6
|
+
*/
|
|
7
|
+
type ResolvedTheme = "light" | "dark";
|
|
8
|
+
/** Lifecycle state of a rendered thread item. */
|
|
9
|
+
type MessageState = "typing" | "sending" | "sent" | "edited" | "deleted";
|
|
10
|
+
/** Whether a thread item is a regular message or an app/system card. */
|
|
11
|
+
type MessageVariant = "message" | "system";
|
|
12
|
+
/** A system/app card payload (e.g. "Pull request opened" + action buttons). */
|
|
13
|
+
interface SystemCard {
|
|
14
|
+
/** Named card variant the skin renders, e.g. `"pr-opened"`. */
|
|
15
|
+
card?: string;
|
|
16
|
+
actions?: {
|
|
17
|
+
label: string;
|
|
18
|
+
href?: string;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
/** A reaction currently shown on a message. */
|
|
22
|
+
interface RenderedReaction {
|
|
23
|
+
emoji: string;
|
|
24
|
+
count: number;
|
|
25
|
+
/** Participant ids who reacted (for grouping/tooltips). */
|
|
26
|
+
by: string[];
|
|
27
|
+
/** 0..1 pop-in progress. */
|
|
28
|
+
progress: number;
|
|
29
|
+
}
|
|
30
|
+
/** A message in the visible thread, with animation progress. */
|
|
31
|
+
interface RenderedMessage {
|
|
32
|
+
id: string;
|
|
33
|
+
/** Author participant id. */
|
|
34
|
+
from: string;
|
|
35
|
+
variant: MessageVariant;
|
|
36
|
+
/** Resolved body content nodes (sugar already compiled). */
|
|
37
|
+
content: ContentNode[];
|
|
38
|
+
/**
|
|
39
|
+
* 0..1 reveal/typing progress: 0 = just appearing, 1 = fully shown. Skins
|
|
40
|
+
* drive all motion from this value (never CSS transition timing), so the live
|
|
41
|
+
* preview and the exported video animate identically.
|
|
42
|
+
*/
|
|
43
|
+
revealProgress: number;
|
|
44
|
+
state: MessageState;
|
|
45
|
+
reactions: RenderedReaction[];
|
|
46
|
+
/** From the self participant — rendered on the "self" side. */
|
|
47
|
+
isSelf: boolean;
|
|
48
|
+
/** Visually grouped with the previous item (same author, close in time). */
|
|
49
|
+
isGrouped: boolean;
|
|
50
|
+
/** Display time in ms from timeline start. */
|
|
51
|
+
atMs: number;
|
|
52
|
+
/** Present when `variant === "system"`. */
|
|
53
|
+
system?: SystemCard;
|
|
54
|
+
}
|
|
55
|
+
/** A typing indicator currently shown. */
|
|
56
|
+
interface TypingState {
|
|
57
|
+
/** Participant id who is typing. */
|
|
58
|
+
from: string;
|
|
59
|
+
/** 0..1 progress through the indicator's shown duration. */
|
|
60
|
+
progress: number;
|
|
61
|
+
}
|
|
62
|
+
/** The composer (input) state. */
|
|
63
|
+
interface ComposerState {
|
|
64
|
+
/** Participant id currently using the composer (usually the self participant). */
|
|
65
|
+
from?: string;
|
|
66
|
+
/** Text typed so far. */
|
|
67
|
+
text: string;
|
|
68
|
+
/** Caret index within `text`. */
|
|
69
|
+
caret: number;
|
|
70
|
+
/** A send is committing this frame. */
|
|
71
|
+
sending: boolean;
|
|
72
|
+
}
|
|
73
|
+
type ScrollReason = "new-message" | "reaction" | "none";
|
|
74
|
+
interface ScrollState {
|
|
75
|
+
/** Target scroll offset the renderer animates toward as the thread grows. */
|
|
76
|
+
targetOffset: number;
|
|
77
|
+
reason: ScrollReason;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The complete renderable state of the conversation at an instant — the return
|
|
81
|
+
* type of the engine's pure `getStateAt(t)` and the single contract every
|
|
82
|
+
* renderer (React, Remotion) and skin consumes.
|
|
83
|
+
*/
|
|
84
|
+
interface SimState {
|
|
85
|
+
/** Visible thread items with reveal/typing progress. */
|
|
86
|
+
messages: RenderedMessage[];
|
|
87
|
+
/** Typing indicators currently shown. */
|
|
88
|
+
typingIndicators: TypingState[];
|
|
89
|
+
composer: ComposerState;
|
|
90
|
+
scroll: ScrollState;
|
|
91
|
+
/** Total timeline length in ms (drives video duration). */
|
|
92
|
+
durationMs: number;
|
|
93
|
+
/** Resolved theme (`auto` already resolved to light/dark). */
|
|
94
|
+
theme: ResolvedTheme;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The load-bearing contract of the whole system (PLAN §3): the engine is a
|
|
99
|
+
* **pure function of time**. Given a timestamp, it returns the complete state
|
|
100
|
+
* of the conversation at that instant — no internal wall-clock timers, no
|
|
101
|
+
* `Date.now()`, no `Math.random()` (jitter is seeded). Because the React clock
|
|
102
|
+
* and the Remotion frame loop both call this, live preview and exported video
|
|
103
|
+
* are identical frame for frame.
|
|
104
|
+
*/
|
|
105
|
+
type GetStateAt = (timeMs: number) => SimState;
|
|
106
|
+
type PlayerEvent = "tick" | "end" | "play" | "pause" | "seek";
|
|
107
|
+
/** Payload delivered with each player event. */
|
|
108
|
+
interface PlayerEventMap {
|
|
109
|
+
/** Fired each clock tick with the freshly sampled state. */
|
|
110
|
+
tick: SimState;
|
|
111
|
+
/** Fired once when playback reaches the end (non-looping). */
|
|
112
|
+
end: void;
|
|
113
|
+
play: void;
|
|
114
|
+
pause: void;
|
|
115
|
+
/** Fired on seek/scrub, with the new time in ms. */
|
|
116
|
+
seek: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* A thin clock wrapper around `GetStateAt`. The React renderer drives this via
|
|
120
|
+
* `requestAnimationFrame`; the builder uses the same surface for
|
|
121
|
+
* preview-as-you-go editing. Remotion bypasses the player and samples
|
|
122
|
+
* `GetStateAt` directly per frame.
|
|
123
|
+
*/
|
|
124
|
+
interface Player {
|
|
125
|
+
/** The most recently sampled state. */
|
|
126
|
+
readonly state: SimState;
|
|
127
|
+
/** Total timeline length in ms. */
|
|
128
|
+
readonly durationMs: number;
|
|
129
|
+
/** Current playback time in ms. */
|
|
130
|
+
readonly currentMs: number;
|
|
131
|
+
/** Playback rate multiplier (1 = realtime). */
|
|
132
|
+
readonly rate: number;
|
|
133
|
+
readonly playing: boolean;
|
|
134
|
+
readonly loop: boolean;
|
|
135
|
+
play(): void;
|
|
136
|
+
pause(): void;
|
|
137
|
+
/** Seek to an absolute time in ms (clamped to `[0, durationMs]`). */
|
|
138
|
+
seek(timeMs: number): void;
|
|
139
|
+
/** Alias for `seek`, used by builder scrubbing. */
|
|
140
|
+
scrubTo(timeMs: number): void;
|
|
141
|
+
setRate(rate: number): void;
|
|
142
|
+
setLoop(loop: boolean): void;
|
|
143
|
+
/** Jump to the next step boundary in the compiled timeline. */
|
|
144
|
+
stepNext(): void;
|
|
145
|
+
/** Jump to the previous step boundary. */
|
|
146
|
+
stepPrev(): void;
|
|
147
|
+
/** Subscribe to an event; returns an unsubscribe function. */
|
|
148
|
+
on<E extends PlayerEvent>(event: E, listener: (payload: PlayerEventMap[E]) => void): () => void;
|
|
149
|
+
off<E extends PlayerEvent>(event: E, listener: (payload: PlayerEventMap[E]) => void): void;
|
|
150
|
+
/** Stop the clock and release resources. */
|
|
151
|
+
destroy(): void;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
interface PlayerOptions {
|
|
155
|
+
durationMs: number;
|
|
156
|
+
/** Step boundaries (ms) for stepNext/stepPrev. */
|
|
157
|
+
steps?: number[];
|
|
158
|
+
autoplay?: boolean;
|
|
159
|
+
loop?: boolean;
|
|
160
|
+
rate?: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The real-time `Player`: a thin clock wrapper around a pure `GetStateAt`
|
|
164
|
+
* (PLAN §5). It owns the only wall-clock in the system (rAF in the browser, a
|
|
165
|
+
* timeout fallback elsewhere) and samples the engine each tick. The same class
|
|
166
|
+
* drove the UI over the mock and now drives it over the real engine — identical
|
|
167
|
+
* surface, so swapping the engine changes nothing here.
|
|
168
|
+
*/
|
|
169
|
+
declare class TimelinePlayer implements Player {
|
|
170
|
+
private readonly getStateAt;
|
|
171
|
+
private readonly _durationMs;
|
|
172
|
+
private readonly steps;
|
|
173
|
+
private _currentMs;
|
|
174
|
+
private _rate;
|
|
175
|
+
private _loop;
|
|
176
|
+
private _playing;
|
|
177
|
+
private _state;
|
|
178
|
+
private anchor;
|
|
179
|
+
private frame;
|
|
180
|
+
private listeners;
|
|
181
|
+
constructor(getStateAt: GetStateAt, options: PlayerOptions);
|
|
182
|
+
get state(): SimState;
|
|
183
|
+
get durationMs(): number;
|
|
184
|
+
get currentMs(): number;
|
|
185
|
+
get rate(): number;
|
|
186
|
+
get playing(): boolean;
|
|
187
|
+
get loop(): boolean;
|
|
188
|
+
play(): void;
|
|
189
|
+
pause(): void;
|
|
190
|
+
private tick;
|
|
191
|
+
private sampleAndEmit;
|
|
192
|
+
private clamp;
|
|
193
|
+
seek(timeMs: number): void;
|
|
194
|
+
scrubTo(timeMs: number): void;
|
|
195
|
+
setRate(rate: number): void;
|
|
196
|
+
setLoop(loop: boolean): void;
|
|
197
|
+
stepNext(): void;
|
|
198
|
+
stepPrev(): void;
|
|
199
|
+
on<E extends PlayerEvent>(event: E, listener: (payload: PlayerEventMap[E]) => void): () => void;
|
|
200
|
+
off<E extends PlayerEvent>(event: E, listener: (payload: PlayerEventMap[E]) => void): void;
|
|
201
|
+
private emit;
|
|
202
|
+
destroy(): void;
|
|
203
|
+
}
|
|
204
|
+
/** Create a real-time player over a `GetStateAt`. */
|
|
205
|
+
declare function createPlayer(getStateAt: GetStateAt, options: PlayerOptions): Player;
|
|
206
|
+
|
|
207
|
+
export { type ComposerState as C, type GetStateAt as G, type MessageVariant as M, type Player as P, type ResolvedTheme as R, type SystemCard as S, type TypingState as T, type RenderedMessage as a, type RenderedReaction as b, type SimState as c, type MessageState as d, type PlayerEvent as e, type PlayerEventMap as f, type PlayerOptions as g, type ScrollReason as h, type ScrollState as i, TimelinePlayer as j, createPlayer as k };
|