@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
package/README.md CHANGED
@@ -1,7 +1 @@
1
1
  # @zcomponent/core
2
-
3
- ## Tests
4
-
5
- - Requires node 16 for ESM support.
6
- - `npx playwright install`
7
- - `npm run test`
@@ -1,6 +1,6 @@
1
- import { Behavior } from "./behavior";
2
- import { Component } from "./component";
3
- import { ContextManager } from "./context";
1
+ import { Behavior } from './behavior';
2
+ import { Component } from './component';
3
+ import { ContextManager } from './context';
4
4
  export interface ActionBehaviorConstructorProps {
5
5
  /** @zprop
6
6
  * @zvalues events
@@ -12,8 +12,17 @@ export interface ActionBehaviorConstructorProps {
12
12
  */
13
13
  runAtEditTime: boolean;
14
14
  }
15
+ /**
16
+ * Base class for all behaviors that perform an action in response to an event.
17
+ */
15
18
  export declare abstract class ActionBehavior<ConstructorProps extends ActionBehaviorConstructorProps = ActionBehaviorConstructorProps> extends Behavior<Component> {
16
19
  protected constructorProps: ConstructorProps;
20
+ /**
21
+ * Creates an instance of ActionBehavior.
22
+ * @param contextManager The current ContextManager
23
+ * @param instance The instance of the component that this behavior is attached to
24
+ * @param constructorProps - The constructor properties.
25
+ */
17
26
  constructor(contextManager: ContextManager, instance: Component, constructorProps: ConstructorProps);
18
27
  private _updateRegistration;
19
28
  private _perform;
@@ -1,7 +1,16 @@
1
- import { Behavior } from "./behavior";
2
- import { EnvironmentContext, isEditTime } from "./contexts/environmentcontext";
3
- import { Event } from "./event";
1
+ import { Behavior } from './behavior';
2
+ import { EnvironmentContext, isEditTime } from './contexts/environmentcontext';
3
+ import { Event } from './event';
4
+ /**
5
+ * Base class for all behaviors that perform an action in response to an event.
6
+ */
4
7
  export class ActionBehavior extends Behavior {
8
+ /**
9
+ * Creates an instance of ActionBehavior.
10
+ * @param contextManager The current ContextManager
11
+ * @param instance The instance of the component that this behavior is attached to
12
+ * @param constructorProps - The constructor properties.
13
+ */
5
14
  constructor(contextManager, instance, constructorProps) {
6
15
  super(contextManager, instance);
7
16
  this.constructorProps = constructorProps;
@@ -11,11 +11,23 @@ export declare enum AnimationEvents {
11
11
  onLayerClipActive = "onLayerClipActive",
12
12
  onLayerClipState = "onLayerClipState"
13
13
  }
14
+ /**
15
+ * Manages animations through layers, clips, and tracks.
16
+ * Provides functionality for serialization and restoration of animation states.
17
+ * Handles adding and removing layers, and controls animation updates via a tick method.
18
+ * Ensures proper initialization, disposal, and entity property influence, and emits events based on animation progression.
19
+ */
14
20
  export declare class Animation {
15
21
  private _initialize;
22
+ /**
23
+ * Collection of layers indexed by ID.
24
+ */
16
25
  layers: {
17
26
  [id: string]: Layer;
18
27
  };
28
+ /**
29
+ * Collection of clips indexed by ID.
30
+ */
19
31
  clips: {
20
32
  [id: string]: Clip;
21
33
  };
@@ -25,13 +37,31 @@ export declare class Animation {
25
37
  onTick: Event<[]>;
26
38
  onLayerClipActive: Event<[layerClip: LayerClip]>;
27
39
  onLayerClipState: Event<[layerClip: LayerClip]>;
40
+ /**
41
+ * Map for quick access to animation elements by ID.
42
+ */
28
43
  clipByID: Map<string, Clip>;
44
+ /**
45
+ * Map for quick access to animation elements by ID.
46
+ */
29
47
  layerByID: Map<string, Layer>;
48
+ /**
49
+ * Map for quick access to animation elements by ID.
50
+ */
30
51
  layerClipByID: Map<string, LayerClip>;
52
+ /**
53
+ * Map for quick access to animation elements by ID.
54
+ */
31
55
  trackByID: Map<string, Track>;
56
+ /**
57
+ * Observable indicating whether there are any layers.
58
+ */
32
59
  hasLayers: Observable<boolean, never>;
33
60
  private _layers;
34
61
  private _spotlightLayer?;
62
+ /**
63
+ * Source of time for the animation.
64
+ */
35
65
  timeSource: (() => number) | undefined;
36
66
  private _entityPaths;
37
67
  private _defaultValuesByPath;
@@ -40,24 +70,86 @@ export declare class Animation {
40
70
  evt: AnimationEvents;
41
71
  args: any[];
42
72
  }[];
73
+ /**
74
+ * Creates an instance of Animation.
75
+ * @param _initialize Whether to initialize the animation. Defaults to true.
76
+ */
43
77
  constructor(_initialize?: boolean);
78
+ /**
79
+ * Serializes the current state of the animation.
80
+ *
81
+ * @returns The serialized state of the animation.
82
+ */
44
83
  serializeState(): AnimationState;
84
+ /**
85
+ * Restores the animation state from a serialized state.
86
+ *
87
+ * @param state The serialized state to restore.
88
+ */
45
89
  restoreState(state: AnimationState): void;
90
+ /**
91
+ * Disposes of the animation, clearing listeners and internal state.
92
+ */
46
93
  dispose(): void;
94
+ /**
95
+ * Adds a new layer to the animation.
96
+ *
97
+ * @param l The layer to add.
98
+ */
47
99
  addLayer(l: Layer): void;
100
+ /**
101
+ * Inserts a layer at a specified index.
102
+ *
103
+ * @param l The layer to insert.
104
+ * @param indx The index at which to insert the layer.
105
+ */
48
106
  insertLayer(l: Layer, indx: number): void;
107
+ /**
108
+ * Removes a layer from the animation.
109
+ *
110
+ * @param l The layer to remove.
111
+ */
49
112
  removeLayer(l: Layer): void;
113
+ /**
114
+ * Initializes the animation, evaluating paths and preparing state.
115
+ */
50
116
  initialize(): void;
117
+ /**
118
+ * Updates the animation state based on the current time.
119
+ */
51
120
  tick(): void;
121
+ /** @internal */
52
122
  registerEntityProperty(path: string, entity: any, property: string | number): void;
123
+ /**
124
+ * Evaluates touched paths and updates entity values based on the current time.
125
+ *
126
+ * @param paths The paths to evaluate.
127
+ * @param t Optional current time.
128
+ */
53
129
  evaluateTouchedPaths(paths: string[], t?: number): void;
130
+ /**
131
+ * Gets the current spotlight layer.
132
+ *
133
+ * @returns The current spotlight layer, if any.
134
+ */
54
135
  get spotlightLayer(): Layer | undefined;
136
+ /**
137
+ * Sets the spotlight layer, influencing the rendering of layers.
138
+ *
139
+ * @param l The layer to set as the spotlight layer.
140
+ */
55
141
  set spotlightLayer(l: Layer | undefined);
142
+ /**
143
+ * Clears cached default values for a specified entity and property.
144
+ *
145
+ * @param entityID The ID of the entity.
146
+ * @param prop The property to clear.
147
+ */
56
148
  clearCachedDefault(entityID: string, prop: string): void;
57
149
  private _emitPendingEvents;
150
+ /**
151
+ *
152
+ * Starts the animation, playing clips that are set to play at the start.
153
+ */
58
154
  start(): void;
59
155
  }
60
- export interface EntityPath {
61
- entity: any;
62
- property: string | number;
63
- }
@@ -6,19 +6,50 @@ export var AnimationEvents;
6
6
  AnimationEvents["onLayerClipActive"] = "onLayerClipActive";
7
7
  AnimationEvents["onLayerClipState"] = "onLayerClipState";
8
8
  })(AnimationEvents || (AnimationEvents = {}));
9
+ /**
10
+ * Manages animations through layers, clips, and tracks.
11
+ * Provides functionality for serialization and restoration of animation states.
12
+ * Handles adding and removing layers, and controls animation updates via a tick method.
13
+ * Ensures proper initialization, disposal, and entity property influence, and emits events based on animation progression.
14
+ */
9
15
  export class Animation {
16
+ /**
17
+ * Creates an instance of Animation.
18
+ * @param _initialize Whether to initialize the animation. Defaults to true.
19
+ */
10
20
  constructor(_initialize = true) {
11
21
  this._initialize = _initialize;
22
+ /**
23
+ * Collection of layers indexed by ID.
24
+ */
12
25
  this.layers = Object.create(null);
26
+ /**
27
+ * Collection of clips indexed by ID.
28
+ */
13
29
  this.clips = Object.create(null);
14
30
  this.curves = Object.create(null);
15
31
  this.onTick = new Event();
16
32
  this.onLayerClipActive = new Event();
17
33
  this.onLayerClipState = new Event();
34
+ /**
35
+ * Map for quick access to animation elements by ID.
36
+ */
18
37
  this.clipByID = new Map();
38
+ /**
39
+ * Map for quick access to animation elements by ID.
40
+ */
19
41
  this.layerByID = new Map();
42
+ /**
43
+ * Map for quick access to animation elements by ID.
44
+ */
20
45
  this.layerClipByID = new Map();
46
+ /**
47
+ * Map for quick access to animation elements by ID.
48
+ */
21
49
  this.trackByID = new Map();
50
+ /**
51
+ * Observable indicating whether there are any layers.
52
+ */
22
53
  this.hasLayers = new Observable(false);
23
54
  this._layers = [];
24
55
  this._entityPaths = new Map();
@@ -26,6 +57,11 @@ export class Animation {
26
57
  /** @internal */
27
58
  this._pendingEvents = [];
28
59
  }
60
+ /**
61
+ * Serializes the current state of the animation.
62
+ *
63
+ * @returns The serialized state of the animation.
64
+ */
29
65
  serializeState() {
30
66
  const state = {
31
67
  byLayer: {},
@@ -37,17 +73,30 @@ export class Animation {
37
73
  this._spotlightLayer?._serialize(state);
38
74
  return state;
39
75
  }
76
+ /**
77
+ * Restores the animation state from a serialized state.
78
+ *
79
+ * @param state The serialized state to restore.
80
+ */
40
81
  restoreState(state) {
41
82
  for (const layer of this._layers) {
42
83
  layer._restore(state);
43
84
  }
44
85
  this._spotlightLayer?._restore(state);
45
86
  }
87
+ /**
88
+ * Disposes of the animation, clearing listeners and internal state.
89
+ */
46
90
  dispose() {
47
91
  this.onTick.clearListeners();
48
92
  this.onLayerClipActive.clearListeners();
49
93
  this.onLayerClipState.clearListeners();
50
94
  }
95
+ /**
96
+ * Adds a new layer to the animation.
97
+ *
98
+ * @param l The layer to add.
99
+ */
51
100
  addLayer(l) {
52
101
  this._layers.push(l);
53
102
  if (!this.hasLayers.value)
@@ -57,6 +106,12 @@ export class Animation {
57
106
  if (l.id)
58
107
  this.layerByID.set(l.id, l);
59
108
  }
109
+ /**
110
+ * Inserts a layer at a specified index.
111
+ *
112
+ * @param l The layer to insert.
113
+ * @param indx The index at which to insert the layer.
114
+ */
60
115
  insertLayer(l, indx) {
61
116
  this._layers.splice(indx, 0, l);
62
117
  if (!this.hasLayers.value)
@@ -66,6 +121,11 @@ export class Animation {
66
121
  if (l.id)
67
122
  this.layerByID.set(l.id, l);
68
123
  }
124
+ /**
125
+ * Removes a layer from the animation.
126
+ *
127
+ * @param l The layer to remove.
128
+ */
69
129
  removeLayer(l) {
70
130
  const indx = this._layers.indexOf(l);
71
131
  if (indx >= 0)
@@ -78,12 +138,18 @@ export class Animation {
78
138
  if (l.id)
79
139
  this.layerByID.delete(l.id);
80
140
  }
141
+ /**
142
+ * Initializes the animation, evaluating paths and preparing state.
143
+ */
81
144
  initialize() {
82
145
  if (this._initialize === true)
83
146
  return;
84
147
  this._initialize = true;
85
148
  this.evaluateTouchedPaths(Object.keys(this._entityPaths));
86
149
  }
150
+ /**
151
+ * Updates the animation state based on the current time.
152
+ */
87
153
  tick() {
88
154
  if (!this._initialize)
89
155
  return;
@@ -100,9 +166,16 @@ export class Animation {
100
166
  this.evaluateTouchedPaths(touchedPaths, t);
101
167
  this.onTick.emit();
102
168
  }
169
+ /** @internal */
103
170
  registerEntityProperty(path, entity, property) {
104
171
  this._entityPaths.set(path, { entity, property });
105
172
  }
173
+ /**
174
+ * Evaluates touched paths and updates entity values based on the current time.
175
+ *
176
+ * @param paths The paths to evaluate.
177
+ * @param t Optional current time.
178
+ */
106
179
  evaluateTouchedPaths(paths, t) {
107
180
  if (!this._initialize)
108
181
  return;
@@ -134,9 +207,19 @@ export class Animation {
134
207
  }
135
208
  this._emitPendingEvents();
136
209
  }
210
+ /**
211
+ * Gets the current spotlight layer.
212
+ *
213
+ * @returns The current spotlight layer, if any.
214
+ */
137
215
  get spotlightLayer() {
138
216
  return this._spotlightLayer;
139
217
  }
218
+ /**
219
+ * Sets the spotlight layer, influencing the rendering of layers.
220
+ *
221
+ * @param l The layer to set as the spotlight layer.
222
+ */
140
223
  set spotlightLayer(l) {
141
224
  if (l === this._spotlightLayer)
142
225
  return;
@@ -154,6 +237,12 @@ export class Animation {
154
237
  if (this.hasLayers.value !== hasLayers)
155
238
  this.hasLayers.value = hasLayers;
156
239
  }
240
+ /**
241
+ * Clears cached default values for a specified entity and property.
242
+ *
243
+ * @param entityID The ID of the entity.
244
+ * @param prop The property to clear.
245
+ */
157
246
  clearCachedDefault(entityID, prop) {
158
247
  this._defaultValuesByPath.delete(entityID + '.' + prop);
159
248
  }
@@ -165,6 +254,10 @@ export class Animation {
165
254
  this[entry.evt].emit(...entry.args);
166
255
  }
167
256
  }
257
+ /**
258
+ *
259
+ * Starts the animation, playing clips that are set to play at the start.
260
+ */
168
261
  start() {
169
262
  for (const layer of this._layers) {
170
263
  for (const clip of Object.values(layer.clips)) {
@@ -1,27 +1,77 @@
1
- import { QueueEntry } from "./layer";
2
- import { StreamState } from "./stream";
1
+ import { QueueEntry } from './layer';
2
+ import { StreamState } from './stream';
3
+ /**
4
+ * Defines the structure for storing the state of an animation.
5
+ * Contains information about the state of layers and layer clips within the animation.
6
+ */
3
7
  export interface AnimationState {
8
+ /**
9
+ * Stores the state of each layer by its ID.
10
+ */
4
11
  byLayer: {
5
12
  [id: string]: LayerState;
6
13
  };
14
+ /**
15
+ * Stores the state of each layer clip by its ID.
16
+ */
7
17
  byLayerClip: {
8
18
  [id: string]: LayerClipState;
9
19
  };
20
+ /**
21
+ * ptional ID of the spotlight layer, if any.
22
+ */
10
23
  spotlightLayer?: string;
11
24
  }
25
+ /**
26
+ * Represents the state of an individual layer within an animation.
27
+ */
12
28
  export interface LayerState {
29
+ /**
30
+ * Queue state entries for the layer.
31
+ */
13
32
  queue: LayerQueueEntryState[];
33
+ /**
34
+ * Index of the currently active queue entry, if any.
35
+ */
14
36
  active?: number | null;
15
37
  }
38
+ /**
39
+ * Defines the state of a queue entry within a layer.
40
+ * Excludes the 'layerClip' object itself, instead referencing it by ID.
41
+ */
16
42
  export type LayerQueueEntryState = Omit<QueueEntry, 'layerClip'> & {
17
43
  layerClip: string | null | undefined;
18
44
  };
45
+ /**
46
+ * Describes the state of a LayerClip within an animation.
47
+ */
19
48
  export interface LayerClipState {
49
+ /**
50
+ * Start time of the clip.
51
+ */
20
52
  t0: number;
53
+ /**
54
+ * End time of the clip, or null to indicate an indefinite duration.
55
+ */
21
56
  t1: number | null;
57
+ /**
58
+ * The time at which the clip was paused, if applicable.
59
+ */
22
60
  pauseTime?: number;
61
+ /**
62
+ * Playback rate of the clip.
63
+ */
23
64
  rate: number;
65
+ /**
66
+ * Indicates whether the clip is set to loop.
67
+ */
24
68
  loop: boolean;
69
+ /**
70
+ * Indicates whether the clip is stopped.
71
+ */
25
72
  stopped: boolean;
73
+ /**
74
+ * The current stream state of the clip.
75
+ */
26
76
  state: StreamState;
27
77
  }
@@ -1,9 +1,20 @@
1
- import { Bezier as BezierData, predefinedCurve } from "../data";
1
+ import { Bezier as BezierData, predefinedCurve } from '../data';
2
2
  export type Easing = keyof typeof predefinedCurve | null | Bezier;
3
+ /**
4
+ * Cass to generate and evaluate multiple Bezier curve segments based on provided control points.
5
+ */
3
6
  export declare class Bezier {
4
7
  private _curves;
5
8
  private _curveEvaluator;
9
+ /**
10
+ * Creates an instance of Bezier.
11
+ * @param _curves An array of control points for each Bezier curve segment.
12
+ */
6
13
  constructor(_curves: BezierData[]);
7
14
  evaluate(t: number, epsilon?: number): number;
8
15
  }
16
+ /**
17
+ * Applies easing to a given time value using pre-defined curves, custom Bezier instances, or returns linear progression if no easing is specified.
18
+ * A cache is implemented to store and reuse Bezier instances for pre-defined easing types to enhance performance.
19
+ */
9
20
  export declare function computeEasing(t: number, easing?: Easing): number;
@@ -1,21 +1,13 @@
1
- import { predefinedCurve } from "../data";
1
+ import { predefinedCurve } from '../data';
2
2
  function BezierFactory(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
3
3
  function sampleCurveX(t) {
4
- return (Math.pow(1 - t, 3) * p0x +
5
- 3 * Math.pow(1 - t, 2) * t * p1x +
6
- 3 * (1 - t) * t * t * p2x +
7
- t * t * t * p3x);
4
+ return Math.pow(1 - t, 3) * p0x + 3 * Math.pow(1 - t, 2) * t * p1x + 3 * (1 - t) * t * t * p2x + t * t * t * p3x;
8
5
  }
9
6
  function sampleCurveY(t) {
10
- return (Math.pow(1 - t, 3) * p0y +
11
- 3 * Math.pow(1 - t, 2) * t * p1y +
12
- 3 * (1 - t) * t * t * p2y +
13
- t * t * t * p3y);
7
+ return Math.pow(1 - t, 3) * p0y + 3 * Math.pow(1 - t, 2) * t * p1y + 3 * (1 - t) * t * t * p2y + t * t * t * p3y;
14
8
  }
15
9
  function sampleCurveDerivativeX(t) {
16
- return (3 * Math.pow(1 - t, 2) * (p1x - p0x) +
17
- 6 * (1 - t) * t * (p2x - p1x) +
18
- 3 * t * t * (p3x - p2x));
10
+ return 3 * Math.pow(1 - t, 2) * (p1x - p0x) + 6 * (1 - t) * t * (p2x - p1x) + 3 * t * t * (p3x - p2x);
19
11
  }
20
12
  function solveCurveX(x, epsilon) {
21
13
  let t2 = x;
@@ -57,7 +49,14 @@ function BezierFactory(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
57
49
  return sampleCurveY(solveCurveX(x, epsilon));
58
50
  };
59
51
  }
52
+ /**
53
+ * Cass to generate and evaluate multiple Bezier curve segments based on provided control points.
54
+ */
60
55
  export class Bezier {
56
+ /**
57
+ * Creates an instance of Bezier.
58
+ * @param _curves An array of control points for each Bezier curve segment.
59
+ */
61
60
  constructor(_curves) {
62
61
  this._curves = _curves;
63
62
  this._curveEvaluator = [];
@@ -74,6 +73,10 @@ export class Bezier {
74
73
  }
75
74
  }
76
75
  const bezierCache = new Map();
76
+ /**
77
+ * Applies easing to a given time value using pre-defined curves, custom Bezier instances, or returns linear progression if no easing is specified.
78
+ * A cache is implemented to store and reuse Bezier instances for pre-defined easing types to enhance performance.
79
+ */
77
80
  export function computeEasing(t, easing) {
78
81
  if (easing === null || easing === undefined)
79
82
  return 0;
@@ -7,12 +7,26 @@ import { ClipTrack } from '../tracks/cliptrack';
7
7
  import { FunctionTrack } from '../tracks/functiontrack';
8
8
  import { StreamTrack } from '../tracks/streamtrack';
9
9
  import { Track } from '../tracks/track';
10
+ /**
11
+ * Represents an animation clip managing a collection of animation tracks within an animation sequence.
12
+ * Handles adding and clearing tracks, computing property values, and managing streaming content.
13
+ * Utilizes observables for change notifications and supports identification through optional script names and IDs.
14
+ *
15
+ * @param animation The associated Animation instance.
16
+ * @param length The duration of the clip.
17
+ * @param scriptName Optional name for script identification.
18
+ * @param id Optional unique identifier for the clip.
19
+ */
10
20
  export declare class Clip {
11
21
  animation: Animation;
12
22
  length: number;
13
23
  readonly scriptName?: string | undefined;
14
24
  readonly id?: string | undefined;
25
+ /** @internal */
15
26
  influencedPathsDirty: Observable<boolean, never>;
27
+ /**
28
+ * Optional default parameters for fading animation properties.
29
+ */
16
30
  defaultFadeParameters?: Partial<Data.FadeParameters>;
17
31
  /** @internal */
18
32
  _streamTracks: (StreamTrack | ClipTrack | FunctionTrack)[];
@@ -20,19 +34,76 @@ export declare class Clip {
20
34
  private _tracksByPath;
21
35
  private _tracksByPathDirty;
22
36
  private _tracks;
37
+ /**
38
+ * Creates an instance of Clip.
39
+ * @param animation - The associated Animation instance.
40
+ * @param length - The duration of the clip.
41
+ * @param scriptName - Optional name for script identification.
42
+ * @param id - Optional unique identifier for the clip.
43
+ */
23
44
  constructor(animation: Animation, length: number, scriptName?: string | undefined, id?: string | undefined);
45
+ /**
46
+ * Computes the property value for a given path at a specific time.
47
+ *
48
+ * @param t The time at which to compute the property.
49
+ * @param p The path of the property to compute.
50
+ * @param valueBefore The initial value of the property before computation.
51
+ * @param parentWeight Optional weight from the parent track.
52
+ * @returns The computed property value.
53
+ */
24
54
  computePathProperty(t: number, p: string, valueBefore: any, parentWeight?: number): any;
55
+ /**
56
+ * Adds a track to the clip and updates the influenced paths.
57
+ *
58
+ * @param t The track to be added.
59
+ */
25
60
  addTrack(t: Track): void;
61
+ /**
62
+ * Clears all tracks from the clip and resets influenced paths.
63
+ */
26
64
  clearTracks(): void;
27
65
  private _dirty;
66
+ /**
67
+ * Getter for the mapping of tracks by path.
68
+ *
69
+ * @returns A map of paths to their respective tracks.
70
+ */
28
71
  get tracksByPath(): Map<string, Track[]>;
72
+ /**
73
+ * Getter for the list of paths influenced by the clip's tracks.
74
+ *
75
+ * @returns An array of influenced paths.
76
+ */
29
77
  get influencedPaths(): string[];
78
+ /**
79
+ * Applies fading parameters to properties by their path.
80
+ *
81
+ * @param props A dictionary of paths and their associated fade parameters.
82
+ */
30
83
  fadePropertiesByPath(props: {
31
84
  [id: string]: Partial<Data.FadeParameters>;
32
85
  }): void;
86
+ /**
87
+ * Resolves the clip time considering looping and play rate.
88
+ *
89
+ * @param t The current time.
90
+ * @param t0 The start time.
91
+ * @param s0 The initial state time.
92
+ * @param rate The rate of play.
93
+ * @param t1 Optional end time.
94
+ * @returns The resolved clip time.
95
+ */
33
96
  resolveClipTime(t: number, t0: number, s0: number, rate: number, t1?: number): number;
97
+ /** @internal */
34
98
  streamPause(isActive: boolean, active: LayerClip | null | undefined): void;
99
+ /** @internal */
35
100
  streamSeek(t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined): void;
101
+ /** @internal */
36
102
  streamTick(clipState: StreamState, t: number, rate: number, isActive: boolean, active: LayerClip | null | undefined, force?: boolean, stalled?: boolean, parentWeight?: number): void;
103
+ /**
104
+ * Determines if any track within the clip is stalled.
105
+ *
106
+ * @returns A boolean indicating if the clip is stalled.
107
+ */
37
108
  isStalled(): boolean;
38
109
  }