@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.
Files changed (141) hide show
  1. package/README.md +0 -6
  2. package/lib/actionbehavior.d.ts +12 -3
  3. package/lib/actionbehavior.js +12 -3
  4. package/lib/animation/animation.d.ts +96 -4
  5. package/lib/animation/animation.js +93 -0
  6. package/lib/animation/animationstate.d.ts +52 -2
  7. package/lib/animation/bezier.d.ts +12 -1
  8. package/lib/animation/bezier.js +15 -12
  9. package/lib/animation/clips/clip.d.ts +71 -0
  10. package/lib/animation/clips/clip.js +68 -0
  11. package/lib/animation/interpolate.d.ts +17 -0
  12. package/lib/animation/interpolate.js +71 -0
  13. package/lib/animation/keyframe.d.ts +24 -1
  14. package/lib/animation/layer.d.ts +73 -1
  15. package/lib/animation/layer.js +69 -0
  16. package/lib/animation/layerclip.d.ts +75 -0
  17. package/lib/animation/layerclip.js +69 -0
  18. package/lib/animation/stream.d.ts +49 -7
  19. package/lib/animation/stream.js +3 -0
  20. package/lib/animation/tracks/cliptrack.d.ts +64 -0
  21. package/lib/animation/tracks/cliptrack.js +65 -1
  22. package/lib/animation/tracks/functiontrack.d.ts +60 -0
  23. package/lib/animation/tracks/functiontrack.js +62 -3
  24. package/lib/animation/tracks/propertytrack.d.ts +84 -0
  25. package/lib/animation/tracks/propertytrack.js +75 -0
  26. package/lib/animation/tracks/streamtrack.d.ts +51 -0
  27. package/lib/animation/tracks/streamtrack.js +54 -3
  28. package/lib/animation/tracks/track.d.ts +56 -0
  29. package/lib/animation/tracks/track.js +40 -0
  30. package/lib/behavior.d.ts +37 -0
  31. package/lib/behavior.js +21 -0
  32. package/lib/behaviors/ActivateState.d.ts +10 -3
  33. package/lib/behaviors/ActivateState.js +8 -4
  34. package/lib/behaviors/CallFunction.d.ts +1 -1
  35. package/lib/behaviors/CallFunction.js +2 -2
  36. package/lib/behaviors/ConsoleLog.d.ts +1 -1
  37. package/lib/behaviors/ConsoleLog.js +2 -2
  38. package/lib/behaviors/DownloadSnapshot.d.ts +5 -2
  39. package/lib/behaviors/DownloadSnapshot.js +5 -2
  40. package/lib/behaviors/LaunchURL.d.ts +1 -1
  41. package/lib/behaviors/LaunchURL.js +1 -1
  42. package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -1
  43. package/lib/behaviors/LogAnalyticsEvent.js +2 -2
  44. package/lib/behaviors/PauseLayerClip.d.ts +5 -3
  45. package/lib/behaviors/PauseLayerClip.js +3 -2
  46. package/lib/behaviors/PlayLayerClip.d.ts +10 -4
  47. package/lib/behaviors/PlayLayerClip.js +7 -5
  48. package/lib/behaviors/PlaySound.d.ts +4 -4
  49. package/lib/behaviors/PlaySound.js +4 -4
  50. package/lib/behaviors/SetLayerOff.d.ts +4 -3
  51. package/lib/behaviors/SetLayerOff.js +3 -2
  52. package/lib/behaviors/ShowTextAlert.d.ts +2 -2
  53. package/lib/behaviors/ShowTextAlert.js +5 -5
  54. package/lib/behaviors/ToggleLayerClips.d.ts +4 -3
  55. package/lib/behaviors/ToggleLayerClips.js +5 -4
  56. package/lib/behaviors/stream/PauseStream.d.ts +15 -3
  57. package/lib/behaviors/stream/PauseStream.js +13 -2
  58. package/lib/behaviors/stream/PlayStream.d.ts +14 -4
  59. package/lib/behaviors/stream/PlayStream.js +10 -3
  60. package/lib/behaviors/stream/SeekStream.d.ts +12 -3
  61. package/lib/behaviors/stream/SeekStream.js +10 -2
  62. package/lib/behaviors/stream/StopStream.d.ts +11 -3
  63. package/lib/behaviors/stream/StopStream.js +9 -2
  64. package/lib/component.d.ts +85 -5
  65. package/lib/component.js +49 -1
  66. package/lib/components/Audio.d.ts +14 -5
  67. package/lib/components/Audio.js +19 -10
  68. package/lib/components/AudioLayerSettings.d.ts +9 -3
  69. package/lib/components/AudioLayerSettings.js +9 -3
  70. package/lib/components/Children.d.ts +7 -2
  71. package/lib/components/Children.js +6 -1
  72. package/lib/components/DefaultCookieConsent.d.ts +13 -3
  73. package/lib/components/DefaultCookieConsent.js +62 -38
  74. package/lib/components/DefaultLoader.d.ts +14 -9
  75. package/lib/components/DefaultLoader.js +25 -20
  76. package/lib/components/Gamepad.d.ts +12 -4
  77. package/lib/components/Gamepad.js +16 -8
  78. package/lib/components/LongLoad.d.ts +7 -1
  79. package/lib/components/LongLoad.js +7 -1
  80. package/lib/components/SnapshotUI.d.ts +10 -0
  81. package/lib/components/SnapshotUI.js +24 -0
  82. package/lib/context.d.ts +117 -0
  83. package/lib/context.js +50 -71
  84. package/lib/contexts/analyticscontext.d.ts +6 -0
  85. package/lib/contexts/analyticscontext.js +6 -0
  86. package/lib/contexts/audiocontextcontext.d.ts +26 -1
  87. package/lib/contexts/audiocontextcontext.js +26 -1
  88. package/lib/contexts/canvascontext.d.ts +59 -1
  89. package/lib/contexts/canvascontext.js +54 -1
  90. package/lib/contexts/cookieconsentcontext.d.ts +84 -10
  91. package/lib/contexts/cookieconsentcontext.js +71 -0
  92. package/lib/contexts/environmentcontext.d.ts +40 -5
  93. package/lib/contexts/environmentcontext.js +40 -5
  94. package/lib/contexts/gamepadcontext.d.ts +38 -0
  95. package/lib/contexts/gamepadcontext.js +38 -0
  96. package/lib/contexts/gesturecontext.d.ts +31 -4
  97. package/lib/contexts/gesturecontext.js +28 -4
  98. package/lib/contexts/globaltagcontext.d.ts +14 -2
  99. package/lib/contexts/globaltagcontext.js +13 -1
  100. package/lib/contexts/loadcontext.d.ts +92 -5
  101. package/lib/contexts/loadcontext.js +98 -11
  102. package/lib/contexts/orientationcontext.d.ts +58 -1
  103. package/lib/contexts/orientationcontext.js +51 -1
  104. package/lib/contexts/snapshotContext.d.ts +97 -4
  105. package/lib/contexts/snapshotContext.js +115 -4
  106. package/lib/contexts/tagcontext.d.ts +56 -2
  107. package/lib/contexts/tagcontext.js +77 -7
  108. package/lib/contexts/textalertcontext.d.ts +35 -2
  109. package/lib/contexts/textalertcontext.js +20 -2
  110. package/lib/contexts/usereventcontext.d.ts +29 -0
  111. package/lib/contexts/usereventcontext.js +30 -1
  112. package/lib/data/animation.d.ts +163 -0
  113. package/lib/data/animation.js +9 -0
  114. package/lib/data/change.d.ts +199 -0
  115. package/lib/data/change.js +190 -0
  116. package/lib/emitter.d.ts +8 -1
  117. package/lib/emitter.js +7 -0
  118. package/lib/entity.d.ts +30 -5
  119. package/lib/entity.js +23 -7
  120. package/lib/event.d.ts +19 -2
  121. package/lib/event.js +19 -2
  122. package/lib/fractionalindexing.js +38 -42
  123. package/lib/inflate.d.ts +68 -0
  124. package/lib/inflate.js +76 -0
  125. package/lib/observable.d.ts +3 -3
  126. package/lib/observable.js +4 -4
  127. package/lib/profile.d.ts +27 -0
  128. package/lib/profile.js +26 -0
  129. package/lib/selectors.d.ts +114 -0
  130. package/lib/selectors.js +159 -7
  131. package/lib/types.d.ts +215 -0
  132. package/lib/types.js +110 -1
  133. package/lib/validators.d.ts +27 -0
  134. package/lib/validators.js +27 -0
  135. package/lib/values/values.d.ts +5 -0
  136. package/lib/values/values.js +5 -0
  137. package/lib/zcomponent.d.ts +72 -0
  138. package/lib/zcomponent.js +81 -0
  139. package/lib/zcomponentconstruction.d.ts +11 -1
  140. package/lib/zcomponentconstruction.js +10 -0
  141. package/package.json +7 -2
@@ -3,14 +3,35 @@ import { Observable } from '../observable';
3
3
  import { AnimationEvents } from './animation';
4
4
  import { StreamState } from './stream';
5
5
  import { resolveClipTimeLoops } from './tracks/track';
6
+ /**
7
+ * Represents a clip within a layer of an animation.
8
+ * Manages playback, state transitions, and property computations for the clip.
9
+ *
10
+ */
6
11
  export class LayerClip {
12
+ /**
13
+ * Creates an instance of LayerClip.
14
+ * @param layer - The layer that this clip belongs to.
15
+ * @param clip - The clip that this layer clip is based on.
16
+ * @param scriptName - The name of the script that created this layer clip.
17
+ * @param id - The ID of the layer clip.
18
+ */
7
19
  constructor(layer, clip, scriptName, id) {
8
20
  this.layer = layer;
9
21
  this.clip = clip;
10
22
  this.scriptName = scriptName;
11
23
  this.id = id;
24
+ /**
25
+ * Default behavior for whether the clip loops when it reaches the end.
26
+ */
12
27
  this.defaultLoop = false;
28
+ /**
29
+ * Default speed at which the clip plays.
30
+ */
13
31
  this.defaultPlaySpeed = 1;
32
+ /**
33
+ * Indicates if the clip should automatically start playing at the beginning of the animation.
34
+ */
14
35
  this.playAtStart = false;
15
36
  this._t0 = 0;
16
37
  this._pauseTime = 0;
@@ -52,6 +73,7 @@ export class LayerClip {
52
73
  layer.animation.layerClipByID.set(id, this);
53
74
  this.state.addListener(this._stateUpdate);
54
75
  }
76
+ /** @internal */
55
77
  tick(touchedPaths, force) {
56
78
  const t = this._getTime();
57
79
  if (this._stallStartTime !== undefined) {
@@ -85,6 +107,13 @@ export class LayerClip {
85
107
  this.onLoop.emit(this);
86
108
  }
87
109
  }
110
+ /**
111
+ * Computes the property value for a specific path based on the current state of the clip.
112
+ *
113
+ * @param p The path of the property to compute.
114
+ * @param valueBefore The initial value before applying clip-specific computations.
115
+ * @returns The computed property value.
116
+ */
88
117
  computePathProperty(p, valueBefore) {
89
118
  const t = this._getTime();
90
119
  const t0 = this._t0 + (t - (this._pauseTime ?? t)) + (t - (this._stallStartTime ?? t));
@@ -93,6 +122,11 @@ export class LayerClip {
93
122
  this._lastClipTime = ct;
94
123
  return this.clip.computePathProperty(ct ?? 0, p, valueBefore);
95
124
  }
125
+ /**
126
+ * Estimates the remaining time for the clip to finish playing.
127
+ *
128
+ * @returns The estimated remaining time in milliseconds.
129
+ */
96
130
  getRemainingTimeEstimate() {
97
131
  const t = this._getTime();
98
132
  const t1 = this._t1 + (t - (this._pauseTime ?? t)) + (t - (this._stallStartTime ?? t));
@@ -101,12 +135,25 @@ export class LayerClip {
101
135
  _getTime() {
102
136
  return Math.floor(this.timeSource?.() ?? this.animation.timeSource?.() ?? performance.now());
103
137
  }
138
+ /**
139
+ * Queues the LayerClip for playback with optional play options.
140
+ *
141
+ * @param opts Optional play options to customize playback behavior.
142
+ */
104
143
  queue(opts) {
105
144
  this.layer.queue(this, opts);
106
145
  }
146
+ /**
147
+ * @returns The length of the clip.
148
+ */
107
149
  length() {
108
150
  return this.clip.length;
109
151
  }
152
+ /**
153
+ * Plays the clip, optionally with specified play options.
154
+ *
155
+ * @param opts Optional play options to customize playback behavior.
156
+ */
110
157
  play(opts) {
111
158
  if (opts?.speed === 0) {
112
159
  this.pause();
@@ -155,6 +202,9 @@ export class LayerClip {
155
202
  this._lastLoop = loop;
156
203
  this.state.value = this._state;
157
204
  }
205
+ /**
206
+ * Pauses the playback of the clip.
207
+ */
158
208
  pause() {
159
209
  delete this._lastLoop;
160
210
  if (this._pauseTime !== undefined || this._state !== StreamState.Playing)
@@ -175,6 +225,12 @@ export class LayerClip {
175
225
  delete this._stallStartTime;
176
226
  this.stalled.value = false;
177
227
  }
228
+ /**
229
+ * Seeks to a specific time within the clip and optionally applies fade parameters.
230
+ *
231
+ * @param ct The clip time to seek to.
232
+ * @param opts Optional seek options, including fade parameters.
233
+ */
178
234
  seek(ct, opts) {
179
235
  const t = this._getTime();
180
236
  this._stopped = false;
@@ -237,9 +293,17 @@ export class LayerClip {
237
293
  this._state = entry.state;
238
294
  this.state.value = this._state;
239
295
  }
296
+ /**
297
+ * Gets the current clip time.
298
+ *
299
+ * @returns The current time within the clip.
300
+ */
240
301
  get clipTime() {
241
302
  return this._lastTickTime !== undefined ? this._lastTickTime : this.defaultPlaySpeed > 0 ? 0 : this.clip.length;
242
303
  }
304
+ /**
305
+ * Stops the clip's playback.
306
+ */
243
307
  stop() {
244
308
  this._stopped = true;
245
309
  this._pauseTime = this._t0;
@@ -253,6 +317,11 @@ export class LayerClip {
253
317
  this.animation._pendingEvents.push({ evt: AnimationEvents.onLayerClipState, args: [this] });
254
318
  this.state.value = this._state;
255
319
  }
320
+ /**
321
+ * Determines if the clip is currently stalled.
322
+ *
323
+ * @returns True if the clip is stalled, false otherwise.
324
+ */
256
325
  isStalled() {
257
326
  return this._stallStartTime !== undefined;
258
327
  }
@@ -1,17 +1,59 @@
1
+ /**
2
+ * Enum representing the different states of a Stream.
3
+ */
1
4
  export declare enum StreamState {
2
- 'Playing' = "Playing",
3
- 'Paused' = "Paused",
4
- 'Ended' = "Ended"
5
+ Playing = "Playing",
6
+ Paused = "Paused",
7
+ Ended = "Ended"
5
8
  }
9
+ /**
10
+ * Interface defining the basic functionality of a Stream.
11
+ * Streams are typically associated with media playback, such as audio or animation.
12
+ */
6
13
  export interface Stream {
7
- play: (opts?: PlayOptions) => void;
8
- pause: () => void;
9
- seek: (t: number) => void;
10
- stop: () => void;
14
+ /**
15
+ * Starts or resumes playback of the Stream.
16
+ *
17
+ * @param opts Optional playback options to customize behavior.
18
+ */
19
+ play(opts?: PlayOptions): void;
20
+ /**
21
+ * Pauses playback of the Stream.
22
+ */
23
+ pause(): void;
24
+ /**
25
+ * Seeks to a specific time within the Stream.
26
+ *
27
+ * @param t The time (in milliseconds) to seek to.
28
+ */
29
+ seek(t: number): void;
30
+ /**
31
+ * Stops playback of the Stream and resets its position.
32
+ */
33
+ stop(): void;
34
+ /**
35
+ * Optionally defines a method to get the length of the Stream.
36
+ *
37
+ * @returns The length of the Stream in milliseconds.
38
+ */
11
39
  length?: () => number | undefined;
40
+ /**
41
+ * Optionally defines a method to check if the Stream is currently stalled.
42
+ *
43
+ * @returns True if the Stream is stalled, false otherwise.
44
+ */
12
45
  isStalled?: () => boolean;
13
46
  }
47
+ /**
48
+ * Interface defining options for playing a Stream.
49
+ */
14
50
  export interface PlayOptions {
51
+ /**
52
+ * Speed multiplier for playback. A value of 1 plays at normal speed.
53
+ */
15
54
  speed?: number;
55
+ /**
56
+ * Whether the Stream should loop when it reaches the end.
57
+ */
16
58
  loop?: boolean;
17
59
  }
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Enum representing the different states of a Stream.
3
+ */
1
4
  export var StreamState;
2
5
  (function (StreamState) {
3
6
  StreamState["Playing"] = "Playing";
@@ -4,6 +4,12 @@ import { Keyframe } from '../keyframe';
4
4
  import { LayerClip } from '../layerclip';
5
5
  import { StreamState } from '../stream';
6
6
  import { Track } from './track';
7
+ /**
8
+ * Embeds another clip as a track within a clip.
9
+ *
10
+ * @param clip The associated clip to embed.
11
+ * @param id Optional unique identifier for the ClipTrack.
12
+ */
7
13
  export declare class ClipTrack extends Track {
8
14
  readonly clip: Clip;
9
15
  private _weights;
@@ -14,22 +20,80 @@ export declare class ClipTrack extends Track {
14
20
  private _entitiesDirty;
15
21
  private _lastTick?;
16
22
  private _lastLoopNumber?;
23
+ /**
24
+ * Creates an instance of ClipTrack.
25
+ * @param clip - The associated Clip to embed.
26
+ * @param id - Optional unique identifier for the ClipTrack.
27
+ */
17
28
  constructor(clip: Clip, id?: string);
29
+ /**
30
+ * Getter for the list of paths influenced by the clip's tracks.
31
+ *
32
+ * @returns An array of influenced paths.
33
+ */
18
34
  get influencedPaths(): string[];
35
+ /**
36
+ * Adds a weight keyframe to the track.
37
+ *
38
+ * @param k The keyframe to be added.
39
+ */
19
40
  addWeight(k: Keyframe): void;
41
+ /**
42
+ * Sets the weight keyframes for the track using an id-indexed object.
43
+ *
44
+ * @param weights An object mapping keyframe IDs to keyframes.
45
+ */
20
46
  setWeightsById(weights: {
21
47
  [id: string]: Keyframe;
22
48
  }): void;
49
+ /**
50
+ * Getter for sorted weight keyframes by their time values.
51
+ *
52
+ * @returns A sorted array of keyframes.
53
+ */
23
54
  get sortedWeights(): Keyframe[];
55
+ /**
56
+ * Adds a block (ClipTrackEntity) representing an instance of the embedded clip in the timeline.
57
+ *
58
+ * @param k The block to be added.
59
+ */
24
60
  addBlock(k: ClipTrackEntity): void;
61
+ /**
62
+ * Sets the blocks for the track using an id-indexed object.
63
+ *
64
+ * @param blocks An object mapping block IDs to ClipTrackEntities.
65
+ */
25
66
  setBlocksById(weights: {
26
67
  [id: string]: ClipTrackEntity;
27
68
  }): void;
69
+ /**
70
+ * Getter for sorted blocks by their start time.
71
+ *
72
+ * @returns A sorted array of ClipTrackEntities.
73
+ */
28
74
  get sortedBlocks(): ClipTrackEntity[];
75
+ /**
76
+ * Computes the property value for a given path at a specific time.
77
+ * Incorporates weights and blocks to determine the final value.
78
+ *
79
+ * @param t The time at which to compute the property.
80
+ * @param p The path of the property to compute.
81
+ * @param valueBefore The initial value of the property before computation.
82
+ * @param parentWeight Optional weight from the parent track.
83
+ * @returns The computed property value.
84
+ */
29
85
  computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
86
+ /** @internal */
30
87
  streamPause(isActive: boolean, active: LayerClip | null | undefined): void;
88
+ /** @internal */
31
89
  streamSeek(t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined): void;
90
+ /** @internal */
32
91
  streamTick(clipState: StreamState, t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined, force?: boolean, stalled?: boolean, parentWeight?: number): void;
33
92
  private _resolveBlock;
93
+ /**
94
+ * Determines if the track is stalled.
95
+ *
96
+ * @returns A boolean indicating if the track is stalled.
97
+ */
34
98
  isStalled(): boolean;
35
99
  }
@@ -1,5 +1,16 @@
1
1
  import { resolveClipTimeLoops, resolveKeyframes, resolveKeyframeValue, Track } from './track';
2
+ /**
3
+ * Embeds another clip as a track within a clip.
4
+ *
5
+ * @param clip The associated clip to embed.
6
+ * @param id Optional unique identifier for the ClipTrack.
7
+ */
2
8
  export class ClipTrack extends Track {
9
+ /**
10
+ * Creates an instance of ClipTrack.
11
+ * @param clip - The associated Clip to embed.
12
+ * @param id - Optional unique identifier for the ClipTrack.
13
+ */
3
14
  constructor(clip, id) {
4
15
  super(clip.animation, id);
5
16
  this.clip = clip;
@@ -14,17 +25,37 @@ export class ClipTrack extends Track {
14
25
  this.influencedPathsDirty.value = true;
15
26
  });
16
27
  }
28
+ /**
29
+ * Getter for the list of paths influenced by the clip's tracks.
30
+ *
31
+ * @returns An array of influenced paths.
32
+ */
17
33
  get influencedPaths() {
18
34
  return this.clip.influencedPaths;
19
35
  }
36
+ /**
37
+ * Adds a weight keyframe to the track.
38
+ *
39
+ * @param k The keyframe to be added.
40
+ */
20
41
  addWeight(k) {
21
42
  this._weightsById[k.id] = k;
22
43
  this._weightsDirty = true;
23
44
  }
45
+ /**
46
+ * Sets the weight keyframes for the track using an id-indexed object.
47
+ *
48
+ * @param weights An object mapping keyframe IDs to keyframes.
49
+ */
24
50
  setWeightsById(weights) {
25
51
  this._weightsById = weights;
26
52
  this._weightsDirty = true;
27
53
  }
54
+ /**
55
+ * Getter for sorted weight keyframes by their time values.
56
+ *
57
+ * @returns A sorted array of keyframes.
58
+ */
28
59
  get sortedWeights() {
29
60
  if (!this._weightsDirty)
30
61
  return this._weights;
@@ -33,14 +64,29 @@ export class ClipTrack extends Track {
33
64
  this._weightsDirty = false;
34
65
  return this._weights;
35
66
  }
67
+ /**
68
+ * Adds a block (ClipTrackEntity) representing an instance of the embedded clip in the timeline.
69
+ *
70
+ * @param k The block to be added.
71
+ */
36
72
  addBlock(k) {
37
73
  this._entitiesById[k.id] = k;
38
74
  this._entitiesDirty = true;
39
75
  }
76
+ /**
77
+ * Sets the blocks for the track using an id-indexed object.
78
+ *
79
+ * @param blocks An object mapping block IDs to ClipTrackEntities.
80
+ */
40
81
  setBlocksById(weights) {
41
82
  this._entitiesById = weights;
42
83
  this._entitiesDirty = true;
43
84
  }
85
+ /**
86
+ * Getter for sorted blocks by their start time.
87
+ *
88
+ * @returns A sorted array of ClipTrackEntities.
89
+ */
44
90
  get sortedBlocks() {
45
91
  if (!this._entitiesDirty)
46
92
  return this._entities;
@@ -49,6 +95,16 @@ export class ClipTrack extends Track {
49
95
  this._entitiesDirty = false;
50
96
  return this._entities;
51
97
  }
98
+ /**
99
+ * Computes the property value for a given path at a specific time.
100
+ * Incorporates weights and blocks to determine the final value.
101
+ *
102
+ * @param t The time at which to compute the property.
103
+ * @param p The path of the property to compute.
104
+ * @param valueBefore The initial value of the property before computation.
105
+ * @param parentWeight Optional weight from the parent track.
106
+ * @returns The computed property value.
107
+ */
52
108
  computePathProperty(t, p, valueBefore, parentWeight) {
53
109
  let weight = 1;
54
110
  const [weightBefore, weightAfter] = resolveKeyframes(this.sortedWeights, t);
@@ -65,9 +121,11 @@ export class ClipTrack extends Track {
65
121
  }
66
122
  return valueBefore;
67
123
  }
124
+ /** @internal */
68
125
  streamPause(isActive, active) {
69
126
  this.clip.streamPause(isActive, active);
70
127
  }
128
+ /** @internal */
71
129
  streamSeek(t, rate, isActive, active) {
72
130
  const blocks = this.sortedBlocks;
73
131
  for (let i = blocks.length - 1; i >= 0; i--) {
@@ -79,6 +137,7 @@ export class ClipTrack extends Track {
79
137
  return;
80
138
  }
81
139
  }
140
+ /** @internal */
82
141
  streamTick(clipState, t, rate, isActive, active, force = false, stalled = false, parentWeight) {
83
142
  if (force)
84
143
  delete this._lastLoopNumber;
@@ -89,7 +148,7 @@ export class ClipTrack extends Track {
89
148
  this.clip.streamPause(isActive, active);
90
149
  }
91
150
  else {
92
- const [bt, loopNumber] = resolveClipTimeLoops(t, block.t0, block.s0, block.rate, this.clip.length, (rate * block.rate) < 0, block.t1);
151
+ const [bt, loopNumber] = resolveClipTimeLoops(t, block.t0, block.s0, block.rate, this.clip.length, rate * block.rate < 0, block.t1);
93
152
  if ((t === block.t1 && rate >= +0) || (t === block.t0 && rate < 0)) {
94
153
  this.clip.streamPause(isActive, active);
95
154
  }
@@ -113,6 +172,11 @@ export class ClipTrack extends Track {
113
172
  }
114
173
  return undefined;
115
174
  }
175
+ /**
176
+ * Determines if the track is stalled.
177
+ *
178
+ * @returns A boolean indicating if the track is stalled.
179
+ */
116
180
  isStalled() {
117
181
  return this.clip.isStalled();
118
182
  }
@@ -10,22 +10,82 @@ export interface ResolvedFunctionTrackEntity {
10
10
  t0: number;
11
11
  args: ByID<any>;
12
12
  }
13
+ /**
14
+ * Manages the execution of functions at specific times during animation playback.
15
+ * Maintains a sorted list of function entities, allowing for seeking, pausing, and ticking in the animation stream.
16
+ * Handles looping and track time boundaries, ensuring functions are triggered at the correct moments.
17
+ *
18
+ * @param animation The associated Animation instance.
19
+ */
13
20
  export declare class FunctionTrack extends Track {
14
21
  readonly animation: Animation;
15
22
  private _entities;
16
23
  private _entitiesById;
17
24
  private _entitiesDirty;
18
25
  private _lastTick?;
26
+ /**
27
+ * Creates an instance of FunctionTrack.
28
+ * @param animation The associated Animation instance.
29
+ */
19
30
  constructor(animation: Animation);
31
+ /**
32
+ * Getter for the list of paths influenced by the track.
33
+ * As this track does not influence any paths, it returns an empty array.
34
+ *
35
+ * @returns An empty array.
36
+ */
20
37
  get influencedPaths(): string[];
21
38
  computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
39
+ /**
40
+ * Adds a function entity to the track. Marks the entities list as dirty.
41
+ *
42
+ * @param k The ResolvedFunctionTrackEntity to be added.
43
+ */
22
44
  addBlock(k: ResolvedFunctionTrackEntity): void;
45
+ /**
46
+ * Sets the function entities for the track using an id-indexed object. Marks the entities list as dirty.
47
+ *
48
+ * @param entities An object mapping entity IDs to ResolvedFunctionTrackEntities.
49
+ */
23
50
  setBlocksById(weights: {
24
51
  [id: string]: ResolvedFunctionTrackEntity;
25
52
  }): void;
53
+ /**
54
+ * Getter for sorted function entities by their start time.
55
+ *
56
+ * @returns A sorted array of ResolvedFunctionTrackEntities.
57
+ */
26
58
  get sortedBlocks(): ResolvedFunctionTrackEntity[];
59
+ /**
60
+ * Seeks to a specific time in the track's stream.
61
+ * Updates the last tick time to the specified time.
62
+ *
63
+ * @param t The time to seek to.
64
+ * @param rate The rate of play.
65
+ * @param isActive Indicates if the streaming is active.
66
+ * @param active The current active LayerClip, null, or undefined.
67
+ */
27
68
  streamSeek(t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined): void;
69
+ /**
70
+ * Updates the track's stream based on the current state and time.
71
+ * Intended to trigger functions at specific times during the animation playback.
72
+ *
73
+ * @param clipState The current state of the stream.
74
+ * @param t The current time.
75
+ * @param rate The rate of play.
76
+ * @param isActive Indicates if the streaming is active.
77
+ * @param active The current active LayerClip, null, or undefined.
78
+ * @param force Optional flag to force an update.
79
+ * @param stalled Optional flag indicating if the stream is stalled.
80
+ * @param parentWeight Optional weight from the parent track.
81
+ */
28
82
  streamTick(clipState: StreamState, t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined, force?: boolean, stalled?: boolean, parentWeight?: number): void;
83
+ /**
84
+ * Pauses the streaming of this track. This implementation is a no-op for FunctionTrack.
85
+ *
86
+ * @param isActive Indicates if the streaming is active.
87
+ * @param active The current active LayerClip, null, or undefined.
88
+ */
29
89
  streamPause(isActive: boolean, active: LayerClip | null | undefined): void;
30
90
  private _resolveBlocksBetween;
31
91
  private _getBoundedT;
@@ -1,5 +1,16 @@
1
1
  import { Track } from './track';
2
+ /**
3
+ * Manages the execution of functions at specific times during animation playback.
4
+ * Maintains a sorted list of function entities, allowing for seeking, pausing, and ticking in the animation stream.
5
+ * Handles looping and track time boundaries, ensuring functions are triggered at the correct moments.
6
+ *
7
+ * @param animation The associated Animation instance.
8
+ */
2
9
  export class FunctionTrack extends Track {
10
+ /**
11
+ * Creates an instance of FunctionTrack.
12
+ * @param animation The associated Animation instance.
13
+ */
3
14
  constructor(animation) {
4
15
  super(animation);
5
16
  this.animation = animation;
@@ -7,20 +18,41 @@ export class FunctionTrack extends Track {
7
18
  this._entitiesById = {};
8
19
  this._entitiesDirty = false;
9
20
  }
21
+ /**
22
+ * Getter for the list of paths influenced by the track.
23
+ * As this track does not influence any paths, it returns an empty array.
24
+ *
25
+ * @returns An empty array.
26
+ */
10
27
  get influencedPaths() {
11
28
  return [];
12
29
  }
13
30
  computePathProperty(t, p, valueBefore, parentWeight) {
14
31
  // n/a
15
32
  }
33
+ /**
34
+ * Adds a function entity to the track. Marks the entities list as dirty.
35
+ *
36
+ * @param k The ResolvedFunctionTrackEntity to be added.
37
+ */
16
38
  addBlock(k) {
17
39
  this._entitiesById[k.id] = k;
18
40
  this._entitiesDirty = true;
19
41
  }
42
+ /**
43
+ * Sets the function entities for the track using an id-indexed object. Marks the entities list as dirty.
44
+ *
45
+ * @param entities An object mapping entity IDs to ResolvedFunctionTrackEntities.
46
+ */
20
47
  setBlocksById(weights) {
21
48
  this._entitiesById = weights;
22
49
  this._entitiesDirty = true;
23
50
  }
51
+ /**
52
+ * Getter for sorted function entities by their start time.
53
+ *
54
+ * @returns A sorted array of ResolvedFunctionTrackEntities.
55
+ */
24
56
  get sortedBlocks() {
25
57
  if (!this._entitiesDirty)
26
58
  return this._entities;
@@ -29,9 +61,31 @@ export class FunctionTrack extends Track {
29
61
  this._entitiesDirty = false;
30
62
  return this._entities;
31
63
  }
64
+ /**
65
+ * Seeks to a specific time in the track's stream.
66
+ * Updates the last tick time to the specified time.
67
+ *
68
+ * @param t The time to seek to.
69
+ * @param rate The rate of play.
70
+ * @param isActive Indicates if the streaming is active.
71
+ * @param active The current active LayerClip, null, or undefined.
72
+ */
32
73
  streamSeek(t, rate, isActive, active) {
33
74
  this._lastTick = t;
34
75
  }
76
+ /**
77
+ * Updates the track's stream based on the current state and time.
78
+ * Intended to trigger functions at specific times during the animation playback.
79
+ *
80
+ * @param clipState The current state of the stream.
81
+ * @param t The current time.
82
+ * @param rate The rate of play.
83
+ * @param isActive Indicates if the streaming is active.
84
+ * @param active The current active LayerClip, null, or undefined.
85
+ * @param force Optional flag to force an update.
86
+ * @param stalled Optional flag indicating if the stream is stalled.
87
+ * @param parentWeight Optional weight from the parent track.
88
+ */
35
89
  streamTick(clipState, t, rate, isActive, active, force = false, stalled = false, parentWeight) {
36
90
  // if (clipState !== StreamState.Playing || this._lastTick === undefined) {
37
91
  // this._lastTick = t;
@@ -50,8 +104,13 @@ export class FunctionTrack extends Track {
50
104
  // }
51
105
  // this._lastTick = t;
52
106
  }
53
- streamPause(isActive, active) {
54
- }
107
+ /**
108
+ * Pauses the streaming of this track. This implementation is a no-op for FunctionTrack.
109
+ *
110
+ * @param isActive Indicates if the streaming is active.
111
+ * @param active The current active LayerClip, null, or undefined.
112
+ */
113
+ streamPause(isActive, active) { }
55
114
  _resolveBlocksBetween(tstart, tend, rate, clipLength) {
56
115
  const blocks = this.sortedBlocks;
57
116
  if (rate < 0) {
@@ -63,7 +122,7 @@ export class FunctionTrack extends Track {
63
122
  let [bounded, loopNo] = this._getBoundedT(tstart, clipLength, rate);
64
123
  const ret = [];
65
124
  while (loopNo < loopNoEnd || (loopNo === loopNoEnd && bounded <= boundedEnd)) {
66
- const t1 = (loopNoEnd > loopNo) ? Infinity : boundedEnd;
125
+ const t1 = loopNoEnd > loopNo ? Infinity : boundedEnd;
67
126
  for (let i = 0; i < blocks.length; i++) {
68
127
  const b = blocks[i];
69
128
  if (b.t0 >= bounded && b.t0 <= t1) {