@zcomponent/core 1.14.3 → 1.15.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 (143) 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/index.d.ts +27 -1
  124. package/lib/index.js +27 -1
  125. package/lib/inflate.d.ts +68 -0
  126. package/lib/inflate.js +76 -0
  127. package/lib/observable.d.ts +3 -3
  128. package/lib/observable.js +4 -4
  129. package/lib/profile.d.ts +27 -0
  130. package/lib/profile.js +26 -0
  131. package/lib/selectors.d.ts +114 -0
  132. package/lib/selectors.js +159 -7
  133. package/lib/types.d.ts +215 -0
  134. package/lib/types.js +110 -1
  135. package/lib/validators.d.ts +27 -0
  136. package/lib/validators.js +27 -0
  137. package/lib/values/values.d.ts +5 -0
  138. package/lib/values/values.js +5 -0
  139. package/lib/zcomponent.d.ts +72 -0
  140. package/lib/zcomponent.js +81 -0
  141. package/lib/zcomponentconstruction.d.ts +11 -1
  142. package/lib/zcomponentconstruction.js +10 -0
  143. package/package.json +7 -2
@@ -3,12 +3,30 @@ import { ClipTrack } from '../tracks/cliptrack';
3
3
  import { FunctionTrack } from '../tracks/functiontrack';
4
4
  import { PropertyTrack } from '../tracks/propertytrack';
5
5
  import { StreamTrack } from '../tracks/streamtrack';
6
+ /**
7
+ * Represents an animation clip managing a collection of animation tracks within an animation sequence.
8
+ * Handles adding and clearing tracks, computing property values, and managing streaming content.
9
+ * Utilizes observables for change notifications and supports identification through optional script names and IDs.
10
+ *
11
+ * @param animation The associated Animation instance.
12
+ * @param length The duration of the clip.
13
+ * @param scriptName Optional name for script identification.
14
+ * @param id Optional unique identifier for the clip.
15
+ */
6
16
  export class Clip {
17
+ /**
18
+ * Creates an instance of Clip.
19
+ * @param animation - The associated Animation instance.
20
+ * @param length - The duration of the clip.
21
+ * @param scriptName - Optional name for script identification.
22
+ * @param id - Optional unique identifier for the clip.
23
+ */
7
24
  constructor(animation, length, scriptName, id) {
8
25
  this.animation = animation;
9
26
  this.length = length;
10
27
  this.scriptName = scriptName;
11
28
  this.id = id;
29
+ /** @internal */
12
30
  this.influencedPathsDirty = new Observable(false);
13
31
  /** @internal */
14
32
  this._streamTracks = [];
@@ -25,6 +43,15 @@ export class Clip {
25
43
  if (scriptName)
26
44
  this.animation.clips[scriptName] = this;
27
45
  }
46
+ /**
47
+ * Computes the property value for a given path at a specific time.
48
+ *
49
+ * @param t The time at which to compute the property.
50
+ * @param p The path of the property to compute.
51
+ * @param valueBefore The initial value of the property before computation.
52
+ * @param parentWeight Optional weight from the parent track.
53
+ * @returns The computed property value.
54
+ */
28
55
  computePathProperty(t, p, valueBefore, parentWeight) {
29
56
  const tracks = this.tracksByPath.get(p);
30
57
  if (!tracks)
@@ -34,6 +61,11 @@ export class Clip {
34
61
  }
35
62
  return valueBefore;
36
63
  }
64
+ /**
65
+ * Adds a track to the clip and updates the influenced paths.
66
+ *
67
+ * @param t The track to be added.
68
+ */
37
69
  addTrack(t) {
38
70
  this._tracks.push(t);
39
71
  t.influencedPathsDirty.addListener(this._dirty);
@@ -42,6 +74,9 @@ export class Clip {
42
74
  if (t instanceof StreamTrack || t instanceof ClipTrack || t instanceof FunctionTrack)
43
75
  this._streamTracks.push(t);
44
76
  }
77
+ /**
78
+ * Clears all tracks from the clip and resets influenced paths.
79
+ */
45
80
  clearTracks() {
46
81
  const existingPaths = this._influencedPaths;
47
82
  for (const track of this._tracks) {
@@ -53,6 +88,11 @@ export class Clip {
53
88
  this._streamTracks = [];
54
89
  this.animation.evaluateTouchedPaths(existingPaths);
55
90
  }
91
+ /**
92
+ * Getter for the mapping of tracks by path.
93
+ *
94
+ * @returns A map of paths to their respective tracks.
95
+ */
56
96
  get tracksByPath() {
57
97
  if (!this._tracksByPathDirty)
58
98
  return this._tracksByPath;
@@ -68,6 +108,11 @@ export class Clip {
68
108
  this._tracksByPathDirty = false;
69
109
  return this._tracksByPath;
70
110
  }
111
+ /**
112
+ * Getter for the list of paths influenced by the clip's tracks.
113
+ *
114
+ * @returns An array of influenced paths.
115
+ */
71
116
  get influencedPaths() {
72
117
  if (!this.influencedPathsDirty.value)
73
118
  return this._influencedPaths;
@@ -79,6 +124,11 @@ export class Clip {
79
124
  this.influencedPathsDirty.value = false;
80
125
  return this._influencedPaths;
81
126
  }
127
+ /**
128
+ * Applies fading parameters to properties by their path.
129
+ *
130
+ * @param props A dictionary of paths and their associated fade parameters.
131
+ */
82
132
  fadePropertiesByPath(props) {
83
133
  if (this.defaultFadeParameters) {
84
134
  // Replace any existing fade properties with our defaults
@@ -101,6 +151,16 @@ export class Clip {
101
151
  }
102
152
  }
103
153
  }
154
+ /**
155
+ * Resolves the clip time considering looping and play rate.
156
+ *
157
+ * @param t The current time.
158
+ * @param t0 The start time.
159
+ * @param s0 The initial state time.
160
+ * @param rate The rate of play.
161
+ * @param t1 Optional end time.
162
+ * @returns The resolved clip time.
163
+ */
104
164
  resolveClipTime(t, t0, s0, rate, t1 = Infinity) {
105
165
  // return this.resolveClipTimeLoops(t, t0, s0, rate, t1)[0];
106
166
  if (this.length === 0)
@@ -116,21 +176,29 @@ export class Clip {
116
176
  bounded += this.length;
117
177
  return bounded;
118
178
  }
179
+ /** @internal */
119
180
  streamPause(isActive, active) {
120
181
  for (const track of this._streamTracks) {
121
182
  track.streamPause(isActive, active);
122
183
  }
123
184
  }
185
+ /** @internal */
124
186
  streamSeek(t, rate, isActive, active) {
125
187
  for (const track of this._streamTracks) {
126
188
  track.streamSeek(t, rate, isActive, active);
127
189
  }
128
190
  }
191
+ /** @internal */
129
192
  streamTick(clipState, t, rate, isActive, active, force = false, stalled = false, parentWeight) {
130
193
  for (const track of this._streamTracks) {
131
194
  track.streamTick(clipState, t, rate, isActive, active, force, stalled, parentWeight);
132
195
  }
133
196
  }
197
+ /**
198
+ * Determines if any track within the clip is stalled.
199
+ *
200
+ * @returns A boolean indicating if the clip is stalled.
201
+ */
134
202
  isStalled() {
135
203
  for (const track of this._tracks) {
136
204
  if (track.isStalled())
@@ -1,2 +1,19 @@
1
+ /**
2
+ * Interpolates between two values based on a given proportion.
3
+ * Supports interpolation of numbers, arrays, or defaults to step interpolation for other types.
4
+ *
5
+ * @param a The starting value.
6
+ * @param b The ending value.
7
+ * @param prop The proportion for interpolation (0 to 1).
8
+ * @returns The interpolated value.
9
+ */
1
10
  export declare function interpolate(a: any, b: any, prop: number): any;
11
+ /**
12
+ * Adds a scaled value to another value, supporting numbers, arrays, or step addition for other types.
13
+ *
14
+ * @param a - The base value.
15
+ * @param b - The value to add, scaled by the proportion.
16
+ * @param prop - The scaling proportion for the value to add.
17
+ * @returns The result of adding the scaled value to the base value.
18
+ */
2
19
  export declare function addBlend(a: any, b: any, prop: number): any;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * Interpolates between two values based on a given proportion.
3
+ * Supports interpolation of numbers, arrays, or defaults to step interpolation for other types.
4
+ *
5
+ * @param a The starting value.
6
+ * @param b The ending value.
7
+ * @param prop The proportion for interpolation (0 to 1).
8
+ * @returns The interpolated value.
9
+ */
1
10
  export function interpolate(a, b, prop) {
2
11
  if (typeof a === 'number' && typeof b === 'number')
3
12
  return interpNumber(a, b, prop);
@@ -5,12 +14,39 @@ export function interpolate(a, b, prop) {
5
14
  return interpArray(a, b, prop);
6
15
  return interpStep(a, b, prop);
7
16
  }
17
+ /**
18
+ * Performs linear interpolation between two numbers.
19
+ *
20
+ * @param a - The starting number.
21
+ * @param b - The ending number.
22
+ * @param prop - The proportion for interpolation (0 to 1).
23
+ * @returns The interpolated number.
24
+ */
8
25
  function interpNumber(a, b, prop) {
9
26
  return (1 - prop) * a + prop * b;
10
27
  }
28
+ /**
29
+ * Performs step interpolation between two values.
30
+ * Returns the second value if the proportion is greater than 0, otherwise returns the first value.
31
+ *
32
+ * @typeParam T - The type of the first value.
33
+ * @typeParam Q - The type of the second value.
34
+ * @param a - The first value.
35
+ * @param b - The second value.
36
+ * @param prop - The proportion for interpolation.
37
+ * @returns Either the first or second value based on the proportion.
38
+ */
11
39
  function interpStep(a, b, prop) {
12
40
  return prop > 0 ? b : a;
13
41
  }
42
+ /**
43
+ * Performs interpolation between two arrays element-wise.
44
+ *
45
+ * @param a - The starting array.
46
+ * @param b - The ending array.
47
+ * @param prop - The proportion for interpolation (0 to 1).
48
+ * @returns An array containing interpolated values.
49
+ */
14
50
  function interpArray(a, b, prop) {
15
51
  if (a.length !== b.length)
16
52
  return interpStep(a, b, prop);
@@ -20,6 +56,14 @@ function interpArray(a, b, prop) {
20
56
  }
21
57
  return ret;
22
58
  }
59
+ /**
60
+ * Adds a scaled value to another value, supporting numbers, arrays, or step addition for other types.
61
+ *
62
+ * @param a - The base value.
63
+ * @param b - The value to add, scaled by the proportion.
64
+ * @param prop - The scaling proportion for the value to add.
65
+ * @returns The result of adding the scaled value to the base value.
66
+ */
23
67
  export function addBlend(a, b, prop) {
24
68
  if (typeof a === 'number' && typeof b === 'number')
25
69
  return addBlendNumber(a, b, prop);
@@ -27,12 +71,39 @@ export function addBlend(a, b, prop) {
27
71
  return addBlendArray(a, b, prop);
28
72
  return addBlendStep(a, b, prop);
29
73
  }
74
+ /**
75
+ * Adds a scaled number to another number.
76
+ *
77
+ * @param a - The base number.
78
+ * @param b - The number to add, scaled by the proportion.
79
+ * @param prop - The scaling proportion for the number to add.
80
+ * @returns The sum of the base number and the scaled number.
81
+ */
30
82
  function addBlendNumber(a, b, prop) {
31
83
  return a + prop * b;
32
84
  }
85
+ /**
86
+ * Performs step addition between two values.
87
+ * Returns the second value if the proportion is equal to or greater than 0.5, otherwise returns the first value.
88
+ *
89
+ * @typeParam T - The type of the first value.
90
+ * @typeParam Q - The type of the second value.
91
+ * @param a - The first value.
92
+ * @param b - The second value.
93
+ * @param prop - The proportion for addition.
94
+ * @returns Either the first or second value based on the proportion.
95
+ */
33
96
  function addBlendStep(a, b, prop) {
34
97
  return prop >= 0.5 ? b : a;
35
98
  }
99
+ /**
100
+ * Adds a scaled array to another array element-wise.
101
+ *
102
+ * @param a - The base array.
103
+ * @param b - The array to add, with each element scaled by the proportion.
104
+ * @param prop - The scaling proportion for the array to add.
105
+ * @returns An array containing the sum of the base array and the scaled array.
106
+ */
36
107
  function addBlendArray(a, b, prop) {
37
108
  if (a.length !== b.length)
38
109
  return interpStep(a, b, prop);
@@ -1,8 +1,31 @@
1
- import { Easing } from "./bezier";
1
+ import { Easing } from './bezier';
2
+ /**
3
+ * Represents a single keyframe in an animation sequence.
4
+ * @property {string} id - Unique identifier for the keyframe.
5
+ * @property {any} v - The value of the property being animated at this keyframe.
6
+ * @property {number} t - The timestamp of the keyframe in the animation.
7
+ * @property {string} [label] - Optional label for the keyframe.
8
+ * @property {Easing} [easing] - Optional easing function to apply between this keyframe and the next.
9
+ */
2
10
  export interface Keyframe {
11
+ /**
12
+ * Unique identifier for the keyframe.
13
+ */
3
14
  id: string;
15
+ /**
16
+ * The value of the property being animated at this keyframe.
17
+ */
4
18
  v: any;
19
+ /**
20
+ * The timestamp of the keyframe in the animation.
21
+ */
5
22
  t: number;
23
+ /**
24
+ * Optional label for the keyframe.
25
+ */
6
26
  label?: string;
27
+ /**
28
+ * Optional easing function to apply between this keyframe and the next.
29
+ */
7
30
  easing?: Easing;
8
31
  }
@@ -3,34 +3,98 @@ import { Animation } from './animation';
3
3
  import { AnimationState } from './animationstate';
4
4
  import { Easing } from './bezier';
5
5
  import { LayerClip, LayerClipPlayOptions } from './layerclip';
6
+ /**
7
+ * Defines the parameters for a fade effect.
8
+ *
9
+ * @interface
10
+ * @property time - The duration of the fade effect in seconds.
11
+ * @property pin - Optional. This value (between 0 and 1) indicates if this fade takes place at the beginning (0), middle (0.5) or end (1) of the transition.
12
+ * @property easing - Optional. The easing function to be used for the fade effect.
13
+ * @property reverse - Optional. A boolean indicating if the fade effect should be reversed.
14
+ */
6
15
  export interface FadeParameters {
7
16
  time: number;
8
17
  pin?: number;
9
18
  easing?: Easing;
10
19
  reverse?: boolean;
11
20
  }
21
+ /**
22
+ * Represents a layer within an animation. Manages a collection of LayerClips and their playback within the layer.
23
+ * Supports queuing of clips, computation of path properties, and handling fade parameters.
24
+ */
12
25
  export declare class Layer {
13
26
  readonly animation: Animation;
14
27
  readonly scriptName?: string | undefined;
15
28
  readonly id?: string | undefined;
29
+ /**
30
+ * Collection of LayerClips indexed by ID.
31
+ */
16
32
  clips: {
17
33
  [id: string]: LayerClip;
18
34
  };
35
+ /**
36
+ * Optional default fade parameters for the layer.
37
+ */
19
38
  defaultFadeParameters?: FadeParameters;
39
+ /**
40
+ * Observable indicating if the influenced paths are dirty.
41
+ */
20
42
  influencedPathsDirty: Observable<boolean, never>;
21
43
  private _influencedPaths;
22
44
  private _active;
23
45
  private _queue;
24
46
  private _layerClips;
47
+ /**
48
+ * Creates an instance of Layer.
49
+ * @param animation - The animation that the layer belongs to.
50
+ * @param scriptName - Optional. The name of the script that the layer belongs to.
51
+ * @param id - Optional. The ID of the layer.
52
+ */
25
53
  constructor(animation: Animation, scriptName?: string | undefined, id?: string | undefined);
54
+ /**
55
+ * Computes the property value for a given path at a specified time.
56
+ * Applies fade parameters and clip-specific computations.
57
+ *
58
+ * @param t The current time.
59
+ * @param p The path of the property to compute.
60
+ * @param valueBefore The initial value of the property before computation.
61
+ * @returns The computed property value.
62
+ */
26
63
  computePathProperty(t: number, p: string, valueBefore: any): any;
64
+ /** @internal */
27
65
  tick(t: number, touchedPaths: string[]): void;
66
+ /**
67
+ * Pauses the currently active LayerClip, if any.
68
+ */
28
69
  pause(): void;
29
70
  /** @internal */
30
71
  _registerLayerClip(layerClip: LayerClip): void;
72
+ /**
73
+ * Queues a LayerClip for playback with optional play options.
74
+ *
75
+ * @param layerClip The LayerClip to queue.
76
+ * @param playOptions Optional play options for the clip.
77
+ * @returns The created QueueEntry.
78
+ */
31
79
  queue(layerClip: LayerClip | null, playOptions?: LayerClipPlayOptions): QueueEntry;
80
+ /**
81
+ * Gets the currently active LayerClip.
82
+ *
83
+ * @returns The active LayerClip, if any.
84
+ */
32
85
  get active(): LayerClip | null | undefined;
86
+ /**
87
+ * Sets the active LayerClip for the layer.
88
+ *
89
+ * @param layerClip The LayerClip to set as active.
90
+ */
33
91
  set active(layerClip: LayerClip | null | undefined);
92
+ /**
93
+ * Sets the active LayerClip with optional play options.
94
+ *
95
+ * @param layerClip The LayerClip to set as active.
96
+ * @param playOptions Optional play options for the clip.
97
+ */
34
98
  setActive(layerClip: LayerClip | null, playOptions?: LayerClipPlayOptions): void;
35
99
  /** @internal */
36
100
  _activateLayerClip(layerClip: LayerClip | null | undefined, playOptions?: LayerClipPlayOptions): void;
@@ -40,9 +104,17 @@ export declare class Layer {
40
104
  _serialize(state: AnimationState): void;
41
105
  /** @internal */
42
106
  _restore(state: AnimationState): void;
107
+ /**
108
+ * Gets the set of paths influenced by the layer.
109
+ *
110
+ * @returns A set of strings representing the influenced paths.
111
+ */
43
112
  get influencedPaths(): Set<string>;
44
113
  }
45
- /** @internal */
114
+ /**
115
+ * Represents an entry in the queue of a Layer, containing a LayerClip and related playback options.
116
+ * @internal
117
+ */
46
118
  export interface QueueEntry {
47
119
  layerClip: LayerClip | null;
48
120
  playOptions?: LayerClipPlayOptions;
@@ -3,18 +3,43 @@ import { AnimationEvents } from './animation';
3
3
  import { computeEasing } from './bezier';
4
4
  import { interpolate } from './interpolate';
5
5
  import { StreamState } from './stream';
6
+ /**
7
+ * Represents a layer within an animation. Manages a collection of LayerClips and their playback within the layer.
8
+ * Supports queuing of clips, computation of path properties, and handling fade parameters.
9
+ */
6
10
  export class Layer {
11
+ /**
12
+ * Creates an instance of Layer.
13
+ * @param animation - The animation that the layer belongs to.
14
+ * @param scriptName - Optional. The name of the script that the layer belongs to.
15
+ * @param id - Optional. The ID of the layer.
16
+ */
7
17
  constructor(animation, scriptName, id) {
8
18
  this.animation = animation;
9
19
  this.scriptName = scriptName;
10
20
  this.id = id;
21
+ /**
22
+ * Collection of LayerClips indexed by ID.
23
+ */
11
24
  this.clips = Object.create(null);
25
+ /**
26
+ * Observable indicating if the influenced paths are dirty.
27
+ */
12
28
  this.influencedPathsDirty = new Observable(false);
13
29
  this._influencedPaths = new Set();
14
30
  this._active = null;
15
31
  this._queue = [];
16
32
  this._layerClips = [];
17
33
  }
34
+ /**
35
+ * Computes the property value for a given path at a specified time.
36
+ * Applies fade parameters and clip-specific computations.
37
+ *
38
+ * @param t The current time.
39
+ * @param p The path of the property to compute.
40
+ * @param valueBefore The initial value of the property before computation.
41
+ * @returns The computed property value.
42
+ */
18
43
  computePathProperty(t, p, valueBefore) {
19
44
  let fadeValue = valueBefore;
20
45
  for (let i = 0; i < this._queue.length; i++) {
@@ -35,6 +60,7 @@ export class Layer {
35
60
  }
36
61
  return fadeValue;
37
62
  }
63
+ /** @internal */
38
64
  tick(t, touchedPaths) {
39
65
  for (let i = this._queue.length - 1; i >= 0; i--) {
40
66
  const entry = this._queue[i];
@@ -54,6 +80,9 @@ export class Layer {
54
80
  }
55
81
  }
56
82
  }
83
+ /**
84
+ * Pauses the currently active LayerClip, if any.
85
+ */
57
86
  pause() {
58
87
  if (!this._active)
59
88
  return;
@@ -70,6 +99,13 @@ export class Layer {
70
99
  });
71
100
  this.influencedPathsDirty.value = true;
72
101
  }
102
+ /**
103
+ * Queues a LayerClip for playback with optional play options.
104
+ *
105
+ * @param layerClip The LayerClip to queue.
106
+ * @param playOptions Optional play options for the clip.
107
+ * @returns The created QueueEntry.
108
+ */
73
109
  queue(layerClip, playOptions) {
74
110
  const fadeByPath = {};
75
111
  layerClip?.clip?.fadePropertiesByPath(fadeByPath);
@@ -89,13 +125,29 @@ export class Layer {
89
125
  this._queue.push(ret);
90
126
  return ret;
91
127
  }
128
+ /**
129
+ * Gets the currently active LayerClip.
130
+ *
131
+ * @returns The active LayerClip, if any.
132
+ */
92
133
  get active() {
93
134
  return this._active?.layerClip;
94
135
  }
136
+ /**
137
+ * Sets the active LayerClip for the layer.
138
+ *
139
+ * @param layerClip The LayerClip to set as active.
140
+ */
95
141
  set active(layerClip) {
96
142
  this._activateLayerClip(layerClip);
97
143
  this._evaulate();
98
144
  }
145
+ /**
146
+ * Sets the active LayerClip with optional play options.
147
+ *
148
+ * @param layerClip The LayerClip to set as active.
149
+ * @param playOptions Optional play options for the clip.
150
+ */
99
151
  setActive(layerClip, playOptions) {
100
152
  this._activateLayerClip(layerClip, playOptions);
101
153
  this._evaulate();
@@ -181,6 +233,11 @@ export class Layer {
181
233
  else
182
234
  this._active = entry.active;
183
235
  }
236
+ /**
237
+ * Gets the set of paths influenced by the layer.
238
+ *
239
+ * @returns A set of strings representing the influenced paths.
240
+ */
184
241
  get influencedPaths() {
185
242
  if (!this.influencedPathsDirty.value)
186
243
  return this._influencedPaths;
@@ -192,6 +249,18 @@ export class Layer {
192
249
  return this._influencedPaths;
193
250
  }
194
251
  }
252
+ /**
253
+ * Computes the faded value of a property based on the provided parameters and current time.
254
+ *
255
+ * @param defaults Default fade parameters.
256
+ * @param params Specific fade parameters for a path.
257
+ * @param override Override parameters for fading.
258
+ * @param t The current time.
259
+ * @param fadeTime The total fade time.
260
+ * @param before The value before fading.
261
+ * @param after The value after fading.
262
+ * @returns The faded value.
263
+ */
195
264
  function computeFade(defaults, params, override, t, fadeTime, before, after) {
196
265
  // TODO further implementation
197
266
  const paramTime = override?.time ?? params?.time ?? defaults?.time ?? 0;
@@ -6,15 +6,35 @@ import { AnimationState } from './animationstate';
6
6
  import { Clip } from './clips/clip';
7
7
  import { Layer } from './layer';
8
8
  import { PlayOptions, Stream, StreamState } from './stream';
9
+ /**
10
+ * Represents a clip within a layer of an animation.
11
+ * Manages playback, state transitions, and property computations for the clip.
12
+ *
13
+ */
9
14
  export declare class LayerClip implements Stream {
10
15
  readonly layer: Layer;
11
16
  readonly clip: Clip;
12
17
  readonly scriptName?: string | undefined;
13
18
  readonly id?: string | undefined;
19
+ /**
20
+ * Default behavior for whether the clip loops when it reaches the end.
21
+ */
14
22
  defaultLoop: boolean;
23
+ /**
24
+ * Default speed at which the clip plays.
25
+ */
15
26
  defaultPlaySpeed: number;
27
+ /**
28
+ * Indicates if the clip should automatically start playing at the beginning of the animation.
29
+ */
16
30
  playAtStart: boolean;
31
+ /**
32
+ * Function providing the current time, used for synchronizing the clip's playback.
33
+ */
17
34
  timeSource: (() => number) | undefined;
35
+ /**
36
+ * Reference to the animation that this layer clip is a part of.
37
+ */
18
38
  readonly animation: Animation;
19
39
  private _t0;
20
40
  private _pauseTime;
@@ -34,25 +54,80 @@ export declare class LayerClip implements Stream {
34
54
  onPaused: Event<[LayerClip]>;
35
55
  onEnded: Event<[LayerClip]>;
36
56
  onLoop: Event<[LayerClip]>;
57
+ /**
58
+ * Creates an instance of LayerClip.
59
+ * @param layer - The layer that this clip belongs to.
60
+ * @param clip - The clip that this layer clip is based on.
61
+ * @param scriptName - The name of the script that created this layer clip.
62
+ * @param id - The ID of the layer clip.
63
+ */
37
64
  constructor(layer: Layer, clip: Clip, scriptName?: string | undefined, id?: string | undefined);
38
65
  private _clipDirty;
66
+ /** @internal */
39
67
  tick(touchedPaths: string[], force?: boolean): void;
68
+ /**
69
+ * Computes the property value for a specific path based on the current state of the clip.
70
+ *
71
+ * @param p The path of the property to compute.
72
+ * @param valueBefore The initial value before applying clip-specific computations.
73
+ * @returns The computed property value.
74
+ */
40
75
  computePathProperty(p: string, valueBefore: any): any;
76
+ /**
77
+ * Estimates the remaining time for the clip to finish playing.
78
+ *
79
+ * @returns The estimated remaining time in milliseconds.
80
+ */
41
81
  getRemainingTimeEstimate(): number;
42
82
  private _getTime;
43
83
  private _stateUpdate;
84
+ /**
85
+ * Queues the LayerClip for playback with optional play options.
86
+ *
87
+ * @param opts Optional play options to customize playback behavior.
88
+ */
44
89
  queue(opts?: LayerClipPlayOptions): void;
90
+ /**
91
+ * @returns The length of the clip.
92
+ */
45
93
  length(): number;
94
+ /**
95
+ * Plays the clip, optionally with specified play options.
96
+ *
97
+ * @param opts Optional play options to customize playback behavior.
98
+ */
46
99
  play(opts?: LayerClipPlayOptions): void;
100
+ /**
101
+ * Pauses the playback of the clip.
102
+ */
47
103
  pause(): void;
48
104
  private _cancelStall;
105
+ /**
106
+ * Seeks to a specific time within the clip and optionally applies fade parameters.
107
+ *
108
+ * @param ct The clip time to seek to.
109
+ * @param opts Optional seek options, including fade parameters.
110
+ */
49
111
  seek(ct: number, opts?: LayerClipSeekOptions): void;
50
112
  /** @internal */
51
113
  _serialize(state: AnimationState): void;
52
114
  /** @internal */
53
115
  _restore(state: AnimationState): void;
116
+ /**
117
+ * Gets the current clip time.
118
+ *
119
+ * @returns The current time within the clip.
120
+ */
54
121
  get clipTime(): number;
122
+ /**
123
+ * Stops the clip's playback.
124
+ */
55
125
  stop(): void;
126
+ /**
127
+ * Determines if the clip is currently stalled.
128
+ *
129
+ * @returns True if the clip is stalled, false otherwise.
130
+ */
56
131
  isStalled(): boolean;
57
132
  }
58
133
  export interface LayerClipSeekOptions {