@zcomponent/core 1.14.3 → 1.16.0-beta
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 +0 -6
- package/lib/actionbehavior.d.ts +12 -3
- package/lib/actionbehavior.js +12 -3
- package/lib/animation/animation.d.ts +96 -4
- package/lib/animation/animation.js +93 -0
- package/lib/animation/animationstate.d.ts +52 -2
- package/lib/animation/bezier.d.ts +12 -1
- package/lib/animation/bezier.js +15 -12
- package/lib/animation/clips/clip.d.ts +71 -0
- package/lib/animation/clips/clip.js +68 -0
- package/lib/animation/interpolate.d.ts +17 -0
- package/lib/animation/interpolate.js +71 -0
- package/lib/animation/keyframe.d.ts +24 -1
- package/lib/animation/layer.d.ts +73 -1
- package/lib/animation/layer.js +69 -0
- package/lib/animation/layerclip.d.ts +75 -0
- package/lib/animation/layerclip.js +69 -0
- package/lib/animation/stream.d.ts +49 -7
- package/lib/animation/stream.js +3 -0
- package/lib/animation/tracks/cliptrack.d.ts +64 -0
- package/lib/animation/tracks/cliptrack.js +65 -1
- package/lib/animation/tracks/functiontrack.d.ts +60 -0
- package/lib/animation/tracks/functiontrack.js +62 -3
- package/lib/animation/tracks/propertytrack.d.ts +84 -0
- package/lib/animation/tracks/propertytrack.js +75 -0
- package/lib/animation/tracks/streamtrack.d.ts +51 -0
- package/lib/animation/tracks/streamtrack.js +54 -3
- package/lib/animation/tracks/track.d.ts +56 -0
- package/lib/animation/tracks/track.js +40 -0
- package/lib/behavior.d.ts +37 -0
- package/lib/behavior.js +21 -0
- package/lib/behaviors/ActivateState.d.ts +10 -3
- package/lib/behaviors/ActivateState.js +8 -4
- package/lib/behaviors/CallFunction.d.ts +1 -1
- package/lib/behaviors/CallFunction.js +2 -2
- package/lib/behaviors/ConsoleLog.d.ts +1 -1
- package/lib/behaviors/ConsoleLog.js +2 -2
- package/lib/behaviors/DownloadSnapshot.d.ts +5 -2
- package/lib/behaviors/DownloadSnapshot.js +5 -2
- package/lib/behaviors/LaunchURL.d.ts +1 -1
- package/lib/behaviors/LaunchURL.js +1 -1
- package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -1
- package/lib/behaviors/LogAnalyticsEvent.js +2 -2
- package/lib/behaviors/PauseLayerClip.d.ts +5 -3
- package/lib/behaviors/PauseLayerClip.js +3 -2
- package/lib/behaviors/PlayLayerClip.d.ts +10 -4
- package/lib/behaviors/PlayLayerClip.js +7 -5
- package/lib/behaviors/PlaySound.d.ts +4 -4
- package/lib/behaviors/PlaySound.js +4 -4
- package/lib/behaviors/SetLayerOff.d.ts +4 -3
- package/lib/behaviors/SetLayerOff.js +3 -2
- package/lib/behaviors/ShowTextAlert.d.ts +2 -2
- package/lib/behaviors/ShowTextAlert.js +5 -5
- package/lib/behaviors/ToggleLayerClips.d.ts +4 -3
- package/lib/behaviors/ToggleLayerClips.js +5 -4
- package/lib/behaviors/stream/PauseStream.d.ts +15 -3
- package/lib/behaviors/stream/PauseStream.js +13 -2
- package/lib/behaviors/stream/PlayStream.d.ts +14 -4
- package/lib/behaviors/stream/PlayStream.js +10 -3
- package/lib/behaviors/stream/SeekStream.d.ts +12 -3
- package/lib/behaviors/stream/SeekStream.js +10 -2
- package/lib/behaviors/stream/StopStream.d.ts +11 -3
- package/lib/behaviors/stream/StopStream.js +9 -2
- package/lib/component.d.ts +85 -5
- package/lib/component.js +49 -1
- package/lib/components/Audio.d.ts +14 -5
- package/lib/components/Audio.js +19 -10
- package/lib/components/AudioLayerSettings.d.ts +9 -3
- package/lib/components/AudioLayerSettings.js +9 -3
- package/lib/components/Children.d.ts +7 -2
- package/lib/components/Children.js +6 -1
- package/lib/components/DefaultCookieConsent.d.ts +13 -3
- package/lib/components/DefaultCookieConsent.js +62 -38
- package/lib/components/DefaultLoader.d.ts +14 -9
- package/lib/components/DefaultLoader.js +25 -20
- package/lib/components/Gamepad.d.ts +12 -4
- package/lib/components/Gamepad.js +16 -8
- package/lib/components/LongLoad.d.ts +7 -1
- package/lib/components/LongLoad.js +7 -1
- package/lib/components/SnapshotUI.d.ts +10 -0
- package/lib/components/SnapshotUI.js +24 -0
- package/lib/context.d.ts +117 -0
- package/lib/context.js +50 -71
- package/lib/contexts/analyticscontext.d.ts +6 -0
- package/lib/contexts/analyticscontext.js +6 -0
- package/lib/contexts/audiocontextcontext.d.ts +26 -1
- package/lib/contexts/audiocontextcontext.js +26 -1
- package/lib/contexts/canvascontext.d.ts +59 -1
- package/lib/contexts/canvascontext.js +54 -1
- package/lib/contexts/cookieconsentcontext.d.ts +84 -10
- package/lib/contexts/cookieconsentcontext.js +71 -0
- package/lib/contexts/environmentcontext.d.ts +40 -5
- package/lib/contexts/environmentcontext.js +40 -5
- package/lib/contexts/gamepadcontext.d.ts +38 -0
- package/lib/contexts/gamepadcontext.js +38 -0
- package/lib/contexts/gesturecontext.d.ts +31 -4
- package/lib/contexts/gesturecontext.js +28 -4
- package/lib/contexts/globaltagcontext.d.ts +14 -2
- package/lib/contexts/globaltagcontext.js +13 -1
- package/lib/contexts/loadcontext.d.ts +92 -5
- package/lib/contexts/loadcontext.js +98 -11
- package/lib/contexts/orientationcontext.d.ts +58 -1
- package/lib/contexts/orientationcontext.js +51 -1
- package/lib/contexts/snapshotContext.d.ts +97 -4
- package/lib/contexts/snapshotContext.js +115 -4
- package/lib/contexts/tagcontext.d.ts +56 -2
- package/lib/contexts/tagcontext.js +77 -7
- package/lib/contexts/textalertcontext.d.ts +35 -2
- package/lib/contexts/textalertcontext.js +20 -2
- package/lib/contexts/usereventcontext.d.ts +29 -0
- package/lib/contexts/usereventcontext.js +30 -1
- package/lib/data/animation.d.ts +163 -0
- package/lib/data/animation.js +9 -0
- package/lib/data/change.d.ts +199 -0
- package/lib/data/change.js +190 -0
- package/lib/emitter.d.ts +8 -1
- package/lib/emitter.js +7 -0
- package/lib/entity.d.ts +30 -5
- package/lib/entity.js +23 -7
- package/lib/event.d.ts +19 -2
- package/lib/event.js +19 -2
- package/lib/fractionalindexing.js +38 -42
- package/lib/inflate.d.ts +68 -0
- package/lib/inflate.js +76 -0
- package/lib/observable.d.ts +3 -3
- package/lib/observable.js +4 -4
- package/lib/profile.d.ts +27 -0
- package/lib/profile.js +26 -0
- package/lib/selectors.d.ts +114 -0
- package/lib/selectors.js +159 -7
- package/lib/types.d.ts +215 -0
- package/lib/types.js +110 -1
- package/lib/validators.d.ts +27 -0
- package/lib/validators.js +27 -0
- package/lib/values/values.d.ts +5 -0
- package/lib/values/values.js +5 -0
- package/lib/zcomponent.d.ts +72 -0
- package/lib/zcomponent.js +81 -0
- package/lib/zcomponentconstruction.d.ts +11 -1
- package/lib/zcomponentconstruction.js +10 -0
- package/package.json +7 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// License: CC0 (no rights reserved).
|
|
2
2
|
// From https://github.com/rocicorp/fractional-indexing
|
|
3
3
|
// This is based on https://observablehq.com/@dgreensp/implementing-fractional-indexing
|
|
4
|
-
export const BASE_62_DIGITS =
|
|
5
|
-
const SMALLEST_INTEGER =
|
|
6
|
-
const INTEGER_ZERO =
|
|
4
|
+
export const BASE_62_DIGITS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
5
|
+
const SMALLEST_INTEGER = 'A00000000000000000000000000';
|
|
6
|
+
const INTEGER_ZERO = 'a0';
|
|
7
7
|
// `a` may be empty string, `b` is null or non-empty string.
|
|
8
8
|
// `a < b` lexicographically if `b` is non-null.
|
|
9
9
|
// no trailing zeros allowed.
|
|
@@ -17,17 +17,17 @@ const INTEGER_ZERO = "a0";
|
|
|
17
17
|
*/
|
|
18
18
|
function midpoint(a, b, digits) {
|
|
19
19
|
if (b != null && a >= b) {
|
|
20
|
-
throw new Error(a +
|
|
20
|
+
throw new Error(a + ' >= ' + b);
|
|
21
21
|
}
|
|
22
|
-
if (a.slice(-1) ===
|
|
23
|
-
throw new Error(
|
|
22
|
+
if (a.slice(-1) === '0' || (b && b.slice(-1) === '0')) {
|
|
23
|
+
throw new Error('trailing zero');
|
|
24
24
|
}
|
|
25
25
|
if (b) {
|
|
26
26
|
// remove longest common prefix. pad `a` with 0s as we
|
|
27
27
|
// go. note that we don't need to pad `b`, because it can't
|
|
28
28
|
// end before `a` while traversing the common prefix.
|
|
29
29
|
let n = 0;
|
|
30
|
-
while ((a[n] ||
|
|
30
|
+
while ((a[n] || '0') === b[n]) {
|
|
31
31
|
n++;
|
|
32
32
|
}
|
|
33
33
|
if (n > 0) {
|
|
@@ -63,7 +63,7 @@ function midpoint(a, b, digits) {
|
|
|
63
63
|
*/
|
|
64
64
|
function validateInteger(int) {
|
|
65
65
|
if (int.length !== getIntegerLength(int[0])) {
|
|
66
|
-
throw new Error(
|
|
66
|
+
throw new Error('invalid integer part of order key: ' + int);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
@@ -71,14 +71,14 @@ function validateInteger(int) {
|
|
|
71
71
|
* @return {number}
|
|
72
72
|
*/
|
|
73
73
|
function getIntegerLength(head) {
|
|
74
|
-
if (head >=
|
|
75
|
-
return head.charCodeAt(0) -
|
|
74
|
+
if (head >= 'a' && head <= 'z') {
|
|
75
|
+
return head.charCodeAt(0) - 'a'.charCodeAt(0) + 2;
|
|
76
76
|
}
|
|
77
|
-
else if (head >=
|
|
78
|
-
return
|
|
77
|
+
else if (head >= 'A' && head <= 'Z') {
|
|
78
|
+
return 'Z'.charCodeAt(0) - head.charCodeAt(0) + 2;
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error('invalid order key head: ' + head);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -88,7 +88,7 @@ function getIntegerLength(head) {
|
|
|
88
88
|
function getIntegerPart(key) {
|
|
89
89
|
const integerPartLength = getIntegerLength(key[0]);
|
|
90
90
|
if (integerPartLength > key.length) {
|
|
91
|
-
throw new Error(
|
|
91
|
+
throw new Error('invalid order key: ' + key);
|
|
92
92
|
}
|
|
93
93
|
return key.slice(0, integerPartLength);
|
|
94
94
|
}
|
|
@@ -98,15 +98,15 @@ function getIntegerPart(key) {
|
|
|
98
98
|
*/
|
|
99
99
|
function validateOrderKey(key) {
|
|
100
100
|
if (key === SMALLEST_INTEGER) {
|
|
101
|
-
throw new Error(
|
|
101
|
+
throw new Error('invalid order key: ' + key);
|
|
102
102
|
}
|
|
103
103
|
// getIntegerPart will throw if the first character is bad,
|
|
104
104
|
// or the key is too short. we'd call it to check these things
|
|
105
105
|
// even if we didn't need the result
|
|
106
106
|
const i = getIntegerPart(key);
|
|
107
107
|
const f = key.slice(i.length);
|
|
108
|
-
if (f.slice(-1) ===
|
|
109
|
-
throw new Error(
|
|
108
|
+
if (f.slice(-1) === '0') {
|
|
109
|
+
throw new Error('invalid order key: ' + key);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
// note that this may return null, as there is a largest integer
|
|
@@ -117,12 +117,12 @@ function validateOrderKey(key) {
|
|
|
117
117
|
*/
|
|
118
118
|
function incrementInteger(x, digits) {
|
|
119
119
|
validateInteger(x);
|
|
120
|
-
const [head, ...digs] = x.split(
|
|
120
|
+
const [head, ...digs] = x.split('');
|
|
121
121
|
let carry = true;
|
|
122
122
|
for (let i = digs.length - 1; carry && i >= 0; i--) {
|
|
123
123
|
const d = digits.indexOf(digs[i]) + 1;
|
|
124
124
|
if (d === digits.length) {
|
|
125
|
-
digs[i] =
|
|
125
|
+
digs[i] = '0';
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
128
|
digs[i] = digits[d];
|
|
@@ -130,23 +130,23 @@ function incrementInteger(x, digits) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
if (carry) {
|
|
133
|
-
if (head ===
|
|
134
|
-
return
|
|
133
|
+
if (head === 'Z') {
|
|
134
|
+
return 'a0';
|
|
135
135
|
}
|
|
136
|
-
if (head ===
|
|
136
|
+
if (head === 'z') {
|
|
137
137
|
return null;
|
|
138
138
|
}
|
|
139
139
|
const h = String.fromCharCode(head.charCodeAt(0) + 1);
|
|
140
|
-
if (h >
|
|
141
|
-
digs.push(
|
|
140
|
+
if (h > 'a') {
|
|
141
|
+
digs.push('0');
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
144
144
|
digs.pop();
|
|
145
145
|
}
|
|
146
|
-
return h + digs.join(
|
|
146
|
+
return h + digs.join('');
|
|
147
147
|
}
|
|
148
148
|
else {
|
|
149
|
-
return head + digs.join(
|
|
149
|
+
return head + digs.join('');
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
// note that this may return null, as there is a smallest integer
|
|
@@ -157,7 +157,7 @@ function incrementInteger(x, digits) {
|
|
|
157
157
|
*/
|
|
158
158
|
function decrementInteger(x, digits) {
|
|
159
159
|
validateInteger(x);
|
|
160
|
-
const [head, ...digs] = x.split(
|
|
160
|
+
const [head, ...digs] = x.split('');
|
|
161
161
|
let borrow = true;
|
|
162
162
|
for (let i = digs.length - 1; borrow && i >= 0; i--) {
|
|
163
163
|
const d = digits.indexOf(digs[i]) - 1;
|
|
@@ -170,23 +170,23 @@ function decrementInteger(x, digits) {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
if (borrow) {
|
|
173
|
-
if (head ===
|
|
174
|
-
return
|
|
173
|
+
if (head === 'a') {
|
|
174
|
+
return 'Z' + digits.slice(-1);
|
|
175
175
|
}
|
|
176
|
-
if (head ===
|
|
176
|
+
if (head === 'A') {
|
|
177
177
|
return null;
|
|
178
178
|
}
|
|
179
179
|
const h = String.fromCharCode(head.charCodeAt(0) - 1);
|
|
180
|
-
if (h <
|
|
180
|
+
if (h < 'Z') {
|
|
181
181
|
digs.push(digits.slice(-1));
|
|
182
182
|
}
|
|
183
183
|
else {
|
|
184
184
|
digs.pop();
|
|
185
185
|
}
|
|
186
|
-
return h + digs.join(
|
|
186
|
+
return h + digs.join('');
|
|
187
187
|
}
|
|
188
188
|
else {
|
|
189
|
-
return head + digs.join(
|
|
189
|
+
return head + digs.join('');
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
// `a` is an order key or null (START).
|
|
@@ -208,7 +208,7 @@ export function generateKeyBetween(a, b, digits = BASE_62_DIGITS) {
|
|
|
208
208
|
validateOrderKey(b);
|
|
209
209
|
}
|
|
210
210
|
if (a != null && b != null && a >= b) {
|
|
211
|
-
throw new Error(a +
|
|
211
|
+
throw new Error(a + ' >= ' + b);
|
|
212
212
|
}
|
|
213
213
|
if (a == null) {
|
|
214
214
|
if (b == null) {
|
|
@@ -217,14 +217,14 @@ export function generateKeyBetween(a, b, digits = BASE_62_DIGITS) {
|
|
|
217
217
|
const ib = getIntegerPart(b);
|
|
218
218
|
const fb = b.slice(ib.length);
|
|
219
219
|
if (ib === SMALLEST_INTEGER) {
|
|
220
|
-
return ib + midpoint(
|
|
220
|
+
return ib + midpoint('', fb, digits);
|
|
221
221
|
}
|
|
222
222
|
if (ib < b) {
|
|
223
223
|
return ib;
|
|
224
224
|
}
|
|
225
225
|
const res = decrementInteger(ib, digits);
|
|
226
226
|
if (res == null) {
|
|
227
|
-
throw new Error(
|
|
227
|
+
throw new Error('cannot decrement any more');
|
|
228
228
|
}
|
|
229
229
|
return res;
|
|
230
230
|
}
|
|
@@ -243,7 +243,7 @@ export function generateKeyBetween(a, b, digits = BASE_62_DIGITS) {
|
|
|
243
243
|
}
|
|
244
244
|
const i = incrementInteger(ia, digits);
|
|
245
245
|
if (i == null) {
|
|
246
|
-
throw new Error(
|
|
246
|
+
throw new Error('cannot increment any more');
|
|
247
247
|
}
|
|
248
248
|
if (i < b) {
|
|
249
249
|
return i;
|
|
@@ -292,9 +292,5 @@ export function generateNKeysBetween(a, b, n, digits = BASE_62_DIGITS) {
|
|
|
292
292
|
}
|
|
293
293
|
const mid = Math.floor(n / 2);
|
|
294
294
|
const c = generateKeyBetween(a, b, digits);
|
|
295
|
-
return [
|
|
296
|
-
...generateNKeysBetween(a, c, mid, digits),
|
|
297
|
-
c,
|
|
298
|
-
...generateNKeysBetween(c, b, n - mid - 1, digits),
|
|
299
|
-
];
|
|
295
|
+
return [...generateNKeysBetween(a, c, mid, digits), c, ...generateNKeysBetween(c, b, n - mid - 1, digits)];
|
|
300
296
|
}
|
package/lib/inflate.d.ts
CHANGED
|
@@ -8,13 +8,81 @@ import { Layer } from './animation/layer';
|
|
|
8
8
|
import { ByID } from './data';
|
|
9
9
|
import { Bezier } from './animation/bezier';
|
|
10
10
|
import { Keyframe } from './animation/keyframe';
|
|
11
|
+
/**
|
|
12
|
+
* Creates a track from the provided data.
|
|
13
|
+
*
|
|
14
|
+
* This function processes the given track data and creates an appropriate track instance based on the track type.
|
|
15
|
+
* @param zcomp - The ZComponent instance.
|
|
16
|
+
* @param anim - The Animation instance to which the track will belong.
|
|
17
|
+
* @param data - The data object defining the track.
|
|
18
|
+
* @returns A Track instance if successful, or undefined if the track cannot be created.
|
|
19
|
+
*/
|
|
11
20
|
export declare function createTrackFromData(zcomp: ZComponent, anim: Animation, data: Data.Track): Track | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Processes keyframe data to handle easing via bezier curves.
|
|
23
|
+
*
|
|
24
|
+
* This function iterates over the provided keyframes and applies bezier curve transformations to keyframes with defined easing properties.
|
|
25
|
+
* @param keyframes - The object containing keyframe data.
|
|
26
|
+
* @param beziers - The object containing bezier curve definitions.
|
|
27
|
+
* @returns A transformed set of keyframes with bezier curves applied.
|
|
28
|
+
*/
|
|
12
29
|
export declare function processKeyframes(keyframes: ByID<Data.Keyframe>, beziers: ByID<Bezier>): {
|
|
13
30
|
[id: string]: Keyframe;
|
|
14
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates a Clip instance from provided data.
|
|
34
|
+
*
|
|
35
|
+
* This function constructs a new Clip instance using the given data, determining its length either from the data or by calculating it from track keyframes.
|
|
36
|
+
* @param zcomp - The ZComponent instance.
|
|
37
|
+
* @param anim - The Animation instance to which the clip will belong.
|
|
38
|
+
* @param data - The data object defining the clip.
|
|
39
|
+
* @returns A new Clip instance.
|
|
40
|
+
*/
|
|
15
41
|
export declare function createClipFromData(zcomp: ZComponent, anim: Animation, data: Data.Clip): Clip;
|
|
42
|
+
/**
|
|
43
|
+
* Updates a Clip instance with data from a Data.Clip object.
|
|
44
|
+
*
|
|
45
|
+
* This function modifies an existing Clip instance, updating its properties and tracks based on the provided data.
|
|
46
|
+
* @param zcomp - The ZComponent instance.
|
|
47
|
+
* @param clip - The Clip instance to update.
|
|
48
|
+
* @param data - The data object defining the updates for the clip.
|
|
49
|
+
*/
|
|
16
50
|
export declare function updateClipFromData(zcomp: ZComponent, clip: Clip, data: Data.Clip): void;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a LayerClip from provided data.
|
|
53
|
+
*
|
|
54
|
+
* This function constructs a new LayerClip instance using the given data, setting properties like playback speed, looping, and play-at-start.
|
|
55
|
+
* @param zcomp - The ZComponent instance.
|
|
56
|
+
* @param layer - The Layer instance to which the LayerClip will belong.
|
|
57
|
+
* @param data - The data object defining the LayerClip.
|
|
58
|
+
* @returns A new LayerClip instance if successful, or undefined if the clip cannot be created.
|
|
59
|
+
*/
|
|
17
60
|
export declare function createLayerClipFromData(zcomp: ZComponent, layer: Layer, data: Data.LayerClip): LayerClip | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a Layer from provided data.
|
|
63
|
+
*
|
|
64
|
+
* This function constructs a new Layer instance using the given data, setting properties like active state and default fade parameters.
|
|
65
|
+
* @param zcomp - The ZComponent instance.
|
|
66
|
+
* @param anim - The Animation instance to which the layer will belong.
|
|
67
|
+
* @param data - The data object defining the Layer.
|
|
68
|
+
* @returns A new Layer instance if successful, or undefined if the layer cannot be created.
|
|
69
|
+
*/
|
|
18
70
|
export declare function createLayerFromData(zcomp: ZComponent, anim: Animation, data: Data.Layer): Layer | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Populates an Animation instance with tracks from provided data.
|
|
73
|
+
*
|
|
74
|
+
* This function iterates over the provided animation data, creating and adding tracks to the animation's clips.
|
|
75
|
+
* @param zcomp - The ZComponent instance.
|
|
76
|
+
* @param anim - The Animation instance to populate.
|
|
77
|
+
* @param data - The data object containing information about the animation.
|
|
78
|
+
*/
|
|
19
79
|
export declare function populateAnimationTracksFromData(zcomp: ZComponent, anim: Animation, data: Data.Animation): void;
|
|
80
|
+
/**
|
|
81
|
+
* Constructs the structure of an Animation instance from provided data.
|
|
82
|
+
*
|
|
83
|
+
* This function builds the structure of an animation, including creating clips, layers, and setting up bezier curves.
|
|
84
|
+
* @param zcomp - The ZComponent instance.
|
|
85
|
+
* @param anim - The Animation instance to construct.
|
|
86
|
+
* @param data - The data object containing information about the animation.
|
|
87
|
+
*/
|
|
20
88
|
export declare function populateAnimationStructureFromData(zcomp: ZComponent, anim: Animation, data: Data.Animation): void;
|
package/lib/inflate.js
CHANGED
|
@@ -7,6 +7,15 @@ import { ClipTrack } from './animation/tracks/cliptrack';
|
|
|
7
7
|
import { Bezier } from './animation/bezier';
|
|
8
8
|
import { StreamTrack } from './animation/tracks/streamtrack';
|
|
9
9
|
import { FunctionTrack } from './animation/tracks/functiontrack';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a track from the provided data.
|
|
12
|
+
*
|
|
13
|
+
* This function processes the given track data and creates an appropriate track instance based on the track type.
|
|
14
|
+
* @param zcomp - The ZComponent instance.
|
|
15
|
+
* @param anim - The Animation instance to which the track will belong.
|
|
16
|
+
* @param data - The data object defining the track.
|
|
17
|
+
* @returns A Track instance if successful, or undefined if the track cannot be created.
|
|
18
|
+
*/
|
|
10
19
|
export function createTrackFromData(zcomp, anim, data) {
|
|
11
20
|
switch (data.type) {
|
|
12
21
|
case Data.TrackType.Property: {
|
|
@@ -63,6 +72,14 @@ export function createTrackFromData(zcomp, anim, data) {
|
|
|
63
72
|
}
|
|
64
73
|
return undefined;
|
|
65
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Processes keyframe data to handle easing via bezier curves.
|
|
77
|
+
*
|
|
78
|
+
* This function iterates over the provided keyframes and applies bezier curve transformations to keyframes with defined easing properties.
|
|
79
|
+
* @param keyframes - The object containing keyframe data.
|
|
80
|
+
* @param beziers - The object containing bezier curve definitions.
|
|
81
|
+
* @returns A transformed set of keyframes with bezier curves applied.
|
|
82
|
+
*/
|
|
66
83
|
export function processKeyframes(keyframes, beziers) {
|
|
67
84
|
let needsNew = false;
|
|
68
85
|
const keyframeArray = Object.values(keyframes);
|
|
@@ -97,6 +114,15 @@ export function processKeyframes(keyframes, beziers) {
|
|
|
97
114
|
}
|
|
98
115
|
return ret;
|
|
99
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates a Clip instance from provided data.
|
|
119
|
+
*
|
|
120
|
+
* This function constructs a new Clip instance using the given data, determining its length either from the data or by calculating it from track keyframes.
|
|
121
|
+
* @param zcomp - The ZComponent instance.
|
|
122
|
+
* @param anim - The Animation instance to which the clip will belong.
|
|
123
|
+
* @param data - The data object defining the clip.
|
|
124
|
+
* @returns A new Clip instance.
|
|
125
|
+
*/
|
|
100
126
|
export function createClipFromData(zcomp, anim, data) {
|
|
101
127
|
let length = data.length;
|
|
102
128
|
if (length === undefined) {
|
|
@@ -137,6 +163,14 @@ export function createClipFromData(zcomp, anim, data) {
|
|
|
137
163
|
zcomp.animation.clipByID.set(data.id, ret);
|
|
138
164
|
return ret;
|
|
139
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* Resolves fade parameters with bezier curves.
|
|
168
|
+
*
|
|
169
|
+
* This function checks if the provided fade parameters include easing and, if so, applies the corresponding bezier curve.
|
|
170
|
+
* @param fade - The fade parameters, potentially including easing.
|
|
171
|
+
* @param beziers - The object containing bezier curve definitions.
|
|
172
|
+
* @returns The resolved fade parameters.
|
|
173
|
+
*/
|
|
140
174
|
function resolvedFadeParameters(fade, beziers) {
|
|
141
175
|
if (!fade?.easing)
|
|
142
176
|
return fade;
|
|
@@ -148,6 +182,14 @@ function resolvedFadeParameters(fade, beziers) {
|
|
|
148
182
|
easing: bezier,
|
|
149
183
|
};
|
|
150
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Updates a Clip instance with data from a Data.Clip object.
|
|
187
|
+
*
|
|
188
|
+
* This function modifies an existing Clip instance, updating its properties and tracks based on the provided data.
|
|
189
|
+
* @param zcomp - The ZComponent instance.
|
|
190
|
+
* @param clip - The Clip instance to update.
|
|
191
|
+
* @param data - The data object defining the updates for the clip.
|
|
192
|
+
*/
|
|
151
193
|
export function updateClipFromData(zcomp, clip, data) {
|
|
152
194
|
clip.defaultFadeParameters = resolvedFadeParameters(data.defaultFadeParameters, zcomp.animation.curves);
|
|
153
195
|
clip.length = data.length;
|
|
@@ -170,6 +212,15 @@ export function updateClipFromData(zcomp, clip, data) {
|
|
|
170
212
|
clip.addTrack(instance);
|
|
171
213
|
}
|
|
172
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Creates a LayerClip from provided data.
|
|
217
|
+
*
|
|
218
|
+
* This function constructs a new LayerClip instance using the given data, setting properties like playback speed, looping, and play-at-start.
|
|
219
|
+
* @param zcomp - The ZComponent instance.
|
|
220
|
+
* @param layer - The Layer instance to which the LayerClip will belong.
|
|
221
|
+
* @param data - The data object defining the LayerClip.
|
|
222
|
+
* @returns A new LayerClip instance if successful, or undefined if the clip cannot be created.
|
|
223
|
+
*/
|
|
173
224
|
export function createLayerClipFromData(zcomp, layer, data) {
|
|
174
225
|
const clip = zcomp.animation.clipByID.get(data.clipId);
|
|
175
226
|
if (!clip)
|
|
@@ -182,6 +233,15 @@ export function createLayerClipFromData(zcomp, layer, data) {
|
|
|
182
233
|
ret.playAtStart = data.playAtStart ?? false;
|
|
183
234
|
return ret;
|
|
184
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Creates a Layer from provided data.
|
|
238
|
+
*
|
|
239
|
+
* This function constructs a new Layer instance using the given data, setting properties like active state and default fade parameters.
|
|
240
|
+
* @param zcomp - The ZComponent instance.
|
|
241
|
+
* @param anim - The Animation instance to which the layer will belong.
|
|
242
|
+
* @param data - The data object defining the Layer.
|
|
243
|
+
* @returns A new Layer instance if successful, or undefined if the layer cannot be created.
|
|
244
|
+
*/
|
|
185
245
|
export function createLayerFromData(zcomp, anim, data) {
|
|
186
246
|
const ret = new Layer(anim, data.scriptName, data.id);
|
|
187
247
|
ret.active = undefined;
|
|
@@ -199,6 +259,14 @@ export function createLayerFromData(zcomp, anim, data) {
|
|
|
199
259
|
}
|
|
200
260
|
return ret;
|
|
201
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Populates an Animation instance with tracks from provided data.
|
|
264
|
+
*
|
|
265
|
+
* This function iterates over the provided animation data, creating and adding tracks to the animation's clips.
|
|
266
|
+
* @param zcomp - The ZComponent instance.
|
|
267
|
+
* @param anim - The Animation instance to populate.
|
|
268
|
+
* @param data - The data object containing information about the animation.
|
|
269
|
+
*/
|
|
202
270
|
export function populateAnimationTracksFromData(zcomp, anim, data) {
|
|
203
271
|
const clips = resolveClipDependencies(data.clips).reverse();
|
|
204
272
|
for (const clipData of Object.values(clips)) {
|
|
@@ -224,6 +292,14 @@ export function populateAnimationTracksFromData(zcomp, anim, data) {
|
|
|
224
292
|
}
|
|
225
293
|
}
|
|
226
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Constructs the structure of an Animation instance from provided data.
|
|
297
|
+
*
|
|
298
|
+
* This function builds the structure of an animation, including creating clips, layers, and setting up bezier curves.
|
|
299
|
+
* @param zcomp - The ZComponent instance.
|
|
300
|
+
* @param anim - The Animation instance to construct.
|
|
301
|
+
* @param data - The data object containing information about the animation.
|
|
302
|
+
*/
|
|
227
303
|
export function populateAnimationStructureFromData(zcomp, anim, data) {
|
|
228
304
|
const clips = resolveClipDependencies(data.clips).reverse();
|
|
229
305
|
for (const clip of Object.values(clips)) {
|
package/lib/observable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Emitter } from
|
|
1
|
+
import { Emitter } from './emitter';
|
|
2
2
|
type Resolved<T, M> = [T] extends [never] ? M : T;
|
|
3
3
|
/**
|
|
4
4
|
* A class that holds a value and watches it for changes (deeply by default).
|
|
@@ -44,8 +44,8 @@ export declare class Observable<Type = never, TypeInternal extends any[] | [] |
|
|
|
44
44
|
* @param withHandler - A function that will be called when the value (or any of its recursive descendent keys or elements) is changed
|
|
45
45
|
* @param deep - Set to false to only track changes to the top level `value` itself (and not any of its descendent keys or elements)
|
|
46
46
|
*/
|
|
47
|
-
constructor(def: TypeInternal, withHandler?: (
|
|
48
|
-
constructor(def: Type, withHandler?: (
|
|
47
|
+
constructor(def: TypeInternal, withHandler?: (v: TypeInternal) => void, deep?: boolean, callWithImmediately?: boolean);
|
|
48
|
+
constructor(def: Type, withHandler?: (v: Type) => void, deep?: boolean, callWithImmediately?: boolean);
|
|
49
49
|
/**
|
|
50
50
|
* Access the current value for this Observable. Changing this value (or, unless deep inspection is disabled, its recursive elements and keys) will trigger any registered handlers to be called with the new value.
|
|
51
51
|
*
|
package/lib/observable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Emitter } from
|
|
1
|
+
import { Emitter } from './emitter';
|
|
2
2
|
/**
|
|
3
3
|
* A class that holds a value and watches it for changes (deeply by default).
|
|
4
4
|
*
|
|
@@ -60,7 +60,7 @@ export class Observable extends Emitter {
|
|
|
60
60
|
const val = target[p];
|
|
61
61
|
if (!shouldWrap(val))
|
|
62
62
|
return val;
|
|
63
|
-
if (Array.isArray(target) && p ===
|
|
63
|
+
if (Array.isArray(target) && p === 'splice') {
|
|
64
64
|
return function (...args) {
|
|
65
65
|
for (let i = 2; i < args.length; i++) {
|
|
66
66
|
args[i] = clone(args[i], true);
|
|
@@ -88,8 +88,8 @@ export class Observable extends Emitter {
|
|
|
88
88
|
if (changed)
|
|
89
89
|
that._emitValue();
|
|
90
90
|
return true;
|
|
91
|
-
}
|
|
92
|
-
})
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
set value(v) {
|
package/lib/profile.d.ts
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user device type. Can be either desktop or mobile.
|
|
3
|
+
*/
|
|
1
4
|
export declare enum DeviceType {
|
|
2
5
|
DESKTOP = "desktop",
|
|
3
6
|
MOBILE = "mobile"
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A helper class to store the user device type and other profile related information.
|
|
10
|
+
*/
|
|
5
11
|
export declare class Profile {
|
|
12
|
+
/**
|
|
13
|
+
* Whether the user is using a desktop device.
|
|
14
|
+
*/
|
|
6
15
|
isDesktop: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the user is muted by default.
|
|
18
|
+
*/
|
|
7
19
|
muteByDefault: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The client language. This is the language of the browser.
|
|
22
|
+
*/
|
|
8
23
|
clientLanguage: string;
|
|
24
|
+
/**
|
|
25
|
+
* The URL search parameters from the current window location.
|
|
26
|
+
*/
|
|
9
27
|
urlSearchParams: URLSearchParams;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the debug mode is enabled. This is enabled by adding the `debug=true` query parameter to the URL.
|
|
30
|
+
*/
|
|
10
31
|
debugMode: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of Profile.
|
|
34
|
+
*/
|
|
11
35
|
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Returns the user agent type.
|
|
38
|
+
*/
|
|
12
39
|
get userAgent(): DeviceType;
|
|
13
40
|
}
|
package/lib/profile.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user device type. Can be either desktop or mobile.
|
|
3
|
+
*/
|
|
1
4
|
export var DeviceType;
|
|
2
5
|
(function (DeviceType) {
|
|
3
6
|
DeviceType["DESKTOP"] = "desktop";
|
|
4
7
|
DeviceType["MOBILE"] = "mobile";
|
|
5
8
|
})(DeviceType || (DeviceType = {}));
|
|
9
|
+
/**
|
|
10
|
+
* Determines the device type based on the user agent string.
|
|
11
|
+
*
|
|
12
|
+
* @returns The detected `DeviceType`.
|
|
13
|
+
*/
|
|
6
14
|
function getDeviceType() {
|
|
7
15
|
const userAgent = window.navigator.userAgent;
|
|
8
16
|
const mobileKeywords = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
|
|
@@ -11,15 +19,33 @@ function getDeviceType() {
|
|
|
11
19
|
}
|
|
12
20
|
return DeviceType.DESKTOP;
|
|
13
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A helper class to store the user device type and other profile related information.
|
|
24
|
+
*/
|
|
14
25
|
export class Profile {
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of Profile.
|
|
28
|
+
*/
|
|
15
29
|
constructor() {
|
|
30
|
+
/**
|
|
31
|
+
* Whether the user is muted by default.
|
|
32
|
+
*/
|
|
16
33
|
this.muteByDefault = false;
|
|
34
|
+
/**
|
|
35
|
+
* The client language. This is the language of the browser.
|
|
36
|
+
*/
|
|
17
37
|
this.clientLanguage = window.navigator.language;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the debug mode is enabled. This is enabled by adding the `debug=true` query parameter to the URL.
|
|
40
|
+
*/
|
|
18
41
|
this.debugMode = false;
|
|
19
42
|
this.urlSearchParams = new URLSearchParams(window.location.search);
|
|
20
43
|
this.debugMode = this.urlSearchParams.has('debug') && this.urlSearchParams.get('debug') === 'true';
|
|
21
44
|
this.isDesktop = getDeviceType() === DeviceType.DESKTOP;
|
|
22
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the user agent type.
|
|
48
|
+
*/
|
|
23
49
|
get userAgent() {
|
|
24
50
|
return this.isDesktop ? DeviceType.DESKTOP : DeviceType.MOBILE;
|
|
25
51
|
}
|