@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.
- package/README.md +0 -6
- package/lib/actionbehavior.d.ts +12 -3
- package/lib/actionbehavior.js +12 -3
- package/lib/animation/animation.d.ts +96 -4
- package/lib/animation/animation.js +93 -0
- package/lib/animation/animationstate.d.ts +52 -2
- package/lib/animation/bezier.d.ts +12 -1
- package/lib/animation/bezier.js +15 -12
- package/lib/animation/clips/clip.d.ts +71 -0
- package/lib/animation/clips/clip.js +68 -0
- package/lib/animation/interpolate.d.ts +17 -0
- package/lib/animation/interpolate.js +71 -0
- package/lib/animation/keyframe.d.ts +24 -1
- package/lib/animation/layer.d.ts +73 -1
- package/lib/animation/layer.js +69 -0
- package/lib/animation/layerclip.d.ts +75 -0
- package/lib/animation/layerclip.js +69 -0
- package/lib/animation/stream.d.ts +49 -7
- package/lib/animation/stream.js +3 -0
- package/lib/animation/tracks/cliptrack.d.ts +64 -0
- package/lib/animation/tracks/cliptrack.js +65 -1
- package/lib/animation/tracks/functiontrack.d.ts +60 -0
- package/lib/animation/tracks/functiontrack.js +62 -3
- package/lib/animation/tracks/propertytrack.d.ts +84 -0
- package/lib/animation/tracks/propertytrack.js +75 -0
- package/lib/animation/tracks/streamtrack.d.ts +51 -0
- package/lib/animation/tracks/streamtrack.js +54 -3
- package/lib/animation/tracks/track.d.ts +56 -0
- package/lib/animation/tracks/track.js +40 -0
- package/lib/behavior.d.ts +37 -0
- package/lib/behavior.js +21 -0
- package/lib/behaviors/ActivateState.d.ts +10 -3
- package/lib/behaviors/ActivateState.js +8 -4
- package/lib/behaviors/CallFunction.d.ts +1 -1
- package/lib/behaviors/CallFunction.js +2 -2
- package/lib/behaviors/ConsoleLog.d.ts +1 -1
- package/lib/behaviors/ConsoleLog.js +2 -2
- package/lib/behaviors/DownloadSnapshot.d.ts +5 -2
- package/lib/behaviors/DownloadSnapshot.js +5 -2
- package/lib/behaviors/LaunchURL.d.ts +1 -1
- package/lib/behaviors/LaunchURL.js +1 -1
- package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -1
- package/lib/behaviors/LogAnalyticsEvent.js +2 -2
- package/lib/behaviors/PauseLayerClip.d.ts +5 -3
- package/lib/behaviors/PauseLayerClip.js +3 -2
- package/lib/behaviors/PlayLayerClip.d.ts +10 -4
- package/lib/behaviors/PlayLayerClip.js +7 -5
- package/lib/behaviors/PlaySound.d.ts +4 -4
- package/lib/behaviors/PlaySound.js +4 -4
- package/lib/behaviors/SetLayerOff.d.ts +4 -3
- package/lib/behaviors/SetLayerOff.js +3 -2
- package/lib/behaviors/ShowTextAlert.d.ts +2 -2
- package/lib/behaviors/ShowTextAlert.js +5 -5
- package/lib/behaviors/ToggleLayerClips.d.ts +4 -3
- package/lib/behaviors/ToggleLayerClips.js +5 -4
- package/lib/behaviors/stream/PauseStream.d.ts +15 -3
- package/lib/behaviors/stream/PauseStream.js +13 -2
- package/lib/behaviors/stream/PlayStream.d.ts +14 -4
- package/lib/behaviors/stream/PlayStream.js +10 -3
- package/lib/behaviors/stream/SeekStream.d.ts +12 -3
- package/lib/behaviors/stream/SeekStream.js +10 -2
- package/lib/behaviors/stream/StopStream.d.ts +11 -3
- package/lib/behaviors/stream/StopStream.js +9 -2
- package/lib/component.d.ts +85 -5
- package/lib/component.js +49 -1
- package/lib/components/Audio.d.ts +14 -5
- package/lib/components/Audio.js +19 -10
- package/lib/components/AudioLayerSettings.d.ts +9 -3
- package/lib/components/AudioLayerSettings.js +9 -3
- package/lib/components/Children.d.ts +7 -2
- package/lib/components/Children.js +6 -1
- package/lib/components/DefaultCookieConsent.d.ts +13 -3
- package/lib/components/DefaultCookieConsent.js +62 -38
- package/lib/components/DefaultLoader.d.ts +14 -9
- package/lib/components/DefaultLoader.js +25 -20
- package/lib/components/Gamepad.d.ts +12 -4
- package/lib/components/Gamepad.js +16 -8
- package/lib/components/LongLoad.d.ts +7 -1
- package/lib/components/LongLoad.js +7 -1
- package/lib/components/SnapshotUI.d.ts +10 -0
- package/lib/components/SnapshotUI.js +24 -0
- package/lib/context.d.ts +117 -0
- package/lib/context.js +50 -71
- package/lib/contexts/analyticscontext.d.ts +6 -0
- package/lib/contexts/analyticscontext.js +6 -0
- package/lib/contexts/audiocontextcontext.d.ts +26 -1
- package/lib/contexts/audiocontextcontext.js +26 -1
- package/lib/contexts/canvascontext.d.ts +59 -1
- package/lib/contexts/canvascontext.js +54 -1
- package/lib/contexts/cookieconsentcontext.d.ts +84 -10
- package/lib/contexts/cookieconsentcontext.js +71 -0
- package/lib/contexts/environmentcontext.d.ts +40 -5
- package/lib/contexts/environmentcontext.js +40 -5
- package/lib/contexts/gamepadcontext.d.ts +38 -0
- package/lib/contexts/gamepadcontext.js +38 -0
- package/lib/contexts/gesturecontext.d.ts +31 -4
- package/lib/contexts/gesturecontext.js +28 -4
- package/lib/contexts/globaltagcontext.d.ts +14 -2
- package/lib/contexts/globaltagcontext.js +13 -1
- package/lib/contexts/loadcontext.d.ts +92 -5
- package/lib/contexts/loadcontext.js +98 -11
- package/lib/contexts/orientationcontext.d.ts +58 -1
- package/lib/contexts/orientationcontext.js +51 -1
- package/lib/contexts/snapshotContext.d.ts +97 -4
- package/lib/contexts/snapshotContext.js +115 -4
- package/lib/contexts/tagcontext.d.ts +56 -2
- package/lib/contexts/tagcontext.js +77 -7
- package/lib/contexts/textalertcontext.d.ts +35 -2
- package/lib/contexts/textalertcontext.js +20 -2
- package/lib/contexts/usereventcontext.d.ts +29 -0
- package/lib/contexts/usereventcontext.js +30 -1
- package/lib/data/animation.d.ts +163 -0
- package/lib/data/animation.js +9 -0
- package/lib/data/change.d.ts +199 -0
- package/lib/data/change.js +190 -0
- package/lib/emitter.d.ts +8 -1
- package/lib/emitter.js +7 -0
- package/lib/entity.d.ts +30 -5
- package/lib/entity.js +23 -7
- package/lib/event.d.ts +19 -2
- package/lib/event.js +19 -2
- package/lib/fractionalindexing.js +38 -42
- package/lib/index.d.ts +27 -1
- package/lib/index.js +27 -1
- package/lib/inflate.d.ts +68 -0
- package/lib/inflate.js +76 -0
- package/lib/observable.d.ts +3 -3
- package/lib/observable.js +4 -4
- package/lib/profile.d.ts +27 -0
- package/lib/profile.js +26 -0
- package/lib/selectors.d.ts +114 -0
- package/lib/selectors.js +159 -7
- package/lib/types.d.ts +215 -0
- package/lib/types.js +110 -1
- package/lib/validators.d.ts +27 -0
- package/lib/validators.js +27 -0
- package/lib/values/values.d.ts +5 -0
- package/lib/values/values.js +5 -0
- package/lib/zcomponent.d.ts +72 -0
- package/lib/zcomponent.js +81 -0
- package/lib/zcomponentconstruction.d.ts +11 -1
- package/lib/zcomponentconstruction.js +10 -0
- package/package.json +7 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ActionBehavior, ActionBehaviorConstructorProps } from
|
|
2
|
-
import { Component } from
|
|
3
|
-
import { ContextManager } from
|
|
1
|
+
import { ActionBehavior, ActionBehaviorConstructorProps } from '../../actionbehavior';
|
|
2
|
+
import { Component } from '../../component';
|
|
3
|
+
import { ContextManager } from '../../context';
|
|
4
4
|
/**
|
|
5
|
+
* Behavior to seek a specified stream to a specific time.
|
|
5
6
|
* @zbehavior
|
|
6
7
|
* @zicon fast_forward
|
|
7
8
|
* @zgroup Stream Actions
|
|
@@ -9,6 +10,7 @@ import { ContextManager } from "../../context";
|
|
|
9
10
|
export declare class SeekStream extends ActionBehavior {
|
|
10
11
|
private zcomponent;
|
|
11
12
|
/**
|
|
13
|
+
* The ID of the stream to seek.
|
|
12
14
|
* @zprop
|
|
13
15
|
* @zgroup Stop Settings
|
|
14
16
|
* @zgrouppriority 20
|
|
@@ -16,6 +18,7 @@ export declare class SeekStream extends ActionBehavior {
|
|
|
16
18
|
*/
|
|
17
19
|
stream: string | undefined;
|
|
18
20
|
/**
|
|
21
|
+
* The time in milliseconds to seek to in the stream.
|
|
19
22
|
* @zprop
|
|
20
23
|
* @zgroup Stop Settings
|
|
21
24
|
* @zgrouppriority 20
|
|
@@ -23,6 +26,12 @@ export declare class SeekStream extends ActionBehavior {
|
|
|
23
26
|
* @ztype time-milliseconds
|
|
24
27
|
*/
|
|
25
28
|
time: number;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of SeekStream.
|
|
31
|
+
* @param contextManager - The current ContextManager
|
|
32
|
+
* @param instance - The instance of the component that this behavior is attached to
|
|
33
|
+
* @param props - The constructor properties.
|
|
34
|
+
*/
|
|
26
35
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
27
36
|
/** @zprop */
|
|
28
37
|
perform(): void;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { ActionBehavior
|
|
2
|
-
import { registerBehaviorRunAtDesignTime } from
|
|
1
|
+
import { ActionBehavior } from '../../actionbehavior';
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from '../../behavior';
|
|
3
3
|
/**
|
|
4
|
+
* Behavior to seek a specified stream to a specific time.
|
|
4
5
|
* @zbehavior
|
|
5
6
|
* @zicon fast_forward
|
|
6
7
|
* @zgroup Stream Actions
|
|
7
8
|
*/
|
|
8
9
|
export class SeekStream extends ActionBehavior {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of SeekStream.
|
|
12
|
+
* @param contextManager - The current ContextManager
|
|
13
|
+
* @param instance - The instance of the component that this behavior is attached to
|
|
14
|
+
* @param props - The constructor properties.
|
|
15
|
+
*/
|
|
9
16
|
constructor(contextManager, instance, props) {
|
|
10
17
|
super(contextManager, instance, props);
|
|
11
18
|
this.zcomponent = this.getZComponentInstance();
|
|
12
19
|
/**
|
|
20
|
+
* The time in milliseconds to seek to in the stream.
|
|
13
21
|
* @zprop
|
|
14
22
|
* @zgroup Stop Settings
|
|
15
23
|
* @zgrouppriority 20
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ActionBehavior, ActionBehaviorConstructorProps } from
|
|
2
|
-
import { Component } from
|
|
3
|
-
import { ContextManager } from
|
|
1
|
+
import { ActionBehavior, ActionBehaviorConstructorProps } from '../../actionbehavior';
|
|
2
|
+
import { Component } from '../../component';
|
|
3
|
+
import { ContextManager } from '../../context';
|
|
4
4
|
/**
|
|
5
|
+
* Behavior to stop a specified stream.
|
|
5
6
|
* @zbehavior
|
|
6
7
|
* @zicon stop_circle
|
|
7
8
|
* @zgroup Stream Actions
|
|
@@ -9,12 +10,19 @@ import { ContextManager } from "../../context";
|
|
|
9
10
|
export declare class StopStream extends ActionBehavior {
|
|
10
11
|
private zcomponent;
|
|
11
12
|
/**
|
|
13
|
+
* The ID of the stream to be stopped.
|
|
12
14
|
* @zprop
|
|
13
15
|
* @zgroup Stop Settings
|
|
14
16
|
* @zgrouppriority 20
|
|
15
17
|
* @zvalues streamids
|
|
16
18
|
*/
|
|
17
19
|
stream: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an instance of StopStream.
|
|
22
|
+
* @param contextManager - The current ContextManager
|
|
23
|
+
* @param instance - The instance of the component that this behavior is attached to
|
|
24
|
+
* @param props - The constructor properties.
|
|
25
|
+
*/
|
|
18
26
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
19
27
|
/** @zprop */
|
|
20
28
|
perform(): void;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { ActionBehavior
|
|
2
|
-
import { registerBehaviorRunAtDesignTime } from
|
|
1
|
+
import { ActionBehavior } from '../../actionbehavior';
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from '../../behavior';
|
|
3
3
|
/**
|
|
4
|
+
* Behavior to stop a specified stream.
|
|
4
5
|
* @zbehavior
|
|
5
6
|
* @zicon stop_circle
|
|
6
7
|
* @zgroup Stream Actions
|
|
7
8
|
*/
|
|
8
9
|
export class StopStream extends ActionBehavior {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of StopStream.
|
|
12
|
+
* @param contextManager - The current ContextManager
|
|
13
|
+
* @param instance - The instance of the component that this behavior is attached to
|
|
14
|
+
* @param props - The constructor properties.
|
|
15
|
+
*/
|
|
9
16
|
constructor(contextManager, instance, props) {
|
|
10
17
|
super(contextManager, instance, props);
|
|
11
18
|
this.zcomponent = this.getZComponentInstance();
|
package/lib/component.d.ts
CHANGED
|
@@ -2,29 +2,86 @@ import { ContextManager } from './context';
|
|
|
2
2
|
import { Entity } from './entity';
|
|
3
3
|
import { Observable } from './observable';
|
|
4
4
|
import type { Behavior, BehaviorConstructor } from './behavior';
|
|
5
|
+
/**
|
|
6
|
+
* Type representing the constructor properties of a given component type.
|
|
7
|
+
*
|
|
8
|
+
* This type extracts the constructor properties of a component if the component extends from `Component<any, R>`. Otherwise, it results in `never`.
|
|
9
|
+
* @typeParam ComponentType - The component type to extract the constructor properties from.
|
|
10
|
+
*/
|
|
5
11
|
export type ConstructorPropsOfComponent<ComponentType> = ComponentType extends Component<any, infer R> ? R : never;
|
|
12
|
+
/**
|
|
13
|
+
* Type representing the constructor function for a component.
|
|
14
|
+
*
|
|
15
|
+
* It defines a constructor type for a component given its constructor properties and component type.
|
|
16
|
+
* @typeParam ConstructorPropsType - The constructor properties type.
|
|
17
|
+
* @typeParam ComponentType - The type of the component.
|
|
18
|
+
*/
|
|
6
19
|
export type ComponentConstructor<ConstructorPropsType extends ConstructorProps, ComponentType extends Component> = new (props: ConstructorPropsType, contextManager: ContextManager) => ComponentType;
|
|
20
|
+
/**
|
|
21
|
+
* Type representing a constructor for a specific component.
|
|
22
|
+
*
|
|
23
|
+
* It defines a constructor type that takes a context manager and the constructor properties of the component.
|
|
24
|
+
* @typeParam ComponentType - The component type for which the constructor is defined.
|
|
25
|
+
*/
|
|
7
26
|
export type ConstructorForComponent<ComponentType extends Component = Component> = new (contextManager: ContextManager, props: ComponentType extends Component<any, infer PropsType> ? PropsType : never) => ComponentType;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Type representing a child of a component.
|
|
29
|
+
*
|
|
30
|
+
* It defines a tuple representing a child component, which includes its constructor, properties, and an optional observable reference.
|
|
31
|
+
* @typeParam ComponentType - The type of the component which the child belongs to.
|
|
32
|
+
*/
|
|
33
|
+
export type ComponentChild<ComponentType extends Component> = [ConstructorForComponent<ComponentType>, ComponentType extends Component<any, infer U> ? U : never] | [ConstructorForComponent<ComponentType>, ComponentType extends Component<any, infer U> ? U : never, Observable<ComponentType | undefined>];
|
|
34
|
+
/**
|
|
35
|
+
* Type representing an array of component children.
|
|
36
|
+
*
|
|
37
|
+
* This type is used to define an array of children for a component, where each child is represented by the `ComponentChild` type.
|
|
38
|
+
*/
|
|
13
39
|
export type ComponentChildren = ComponentChild<Component>[];
|
|
40
|
+
/**
|
|
41
|
+
* Interface representing the constructor properties of a component.
|
|
42
|
+
*
|
|
43
|
+
* This interface defines a standard structure for properties that can be passed to a component's constructor, including an optional `children` property.
|
|
44
|
+
*/
|
|
14
45
|
export interface ConstructorProps {
|
|
15
46
|
[id: string]: any;
|
|
16
47
|
children?: ComponentChildren;
|
|
17
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Base class for all components.
|
|
51
|
+
*
|
|
52
|
+
* Components define the different types of nodes you can have in your project.
|
|
53
|
+
* Each component provides a set of functionalities and properties that you can add as nodes in your project’s Hierarchy, as many times as you like.
|
|
54
|
+
* While there are many components included with Mattercraft (such as `Box` and `Group`), you can also create your own by extending the Component class.
|
|
55
|
+
*
|
|
56
|
+
* @link [custom-components](https://docs.zap.works/mattercraft/scripting/custom-components/)
|
|
57
|
+
*/
|
|
18
58
|
export declare class Component<ElementType = any, ConstructorPropsType extends ConstructorProps = ConstructorProps> extends Entity {
|
|
19
59
|
protected constructorProps?: ConstructorPropsType | undefined;
|
|
20
60
|
/**
|
|
21
61
|
* The raw element(s) that this component exposes
|
|
22
62
|
*/
|
|
23
63
|
element?: ElementType;
|
|
64
|
+
/**
|
|
65
|
+
* The children of this component.
|
|
66
|
+
*/
|
|
24
67
|
readonly children: Component[];
|
|
68
|
+
/**
|
|
69
|
+
* The behaviors attached to this component.
|
|
70
|
+
*/
|
|
25
71
|
readonly behaviors: Behavior[];
|
|
72
|
+
/**
|
|
73
|
+
* The parent of this component.
|
|
74
|
+
*/
|
|
26
75
|
parent?: Component;
|
|
76
|
+
/**
|
|
77
|
+
* Creates an instance of Component.
|
|
78
|
+
* @param contextManager The current ContextManager
|
|
79
|
+
* @param constructorProps - The constructor properties.
|
|
80
|
+
*/
|
|
27
81
|
constructor(contextManager: ContextManager, constructorProps?: ConstructorPropsType | undefined);
|
|
82
|
+
/**
|
|
83
|
+
* Constructs the children of this component.
|
|
84
|
+
*/
|
|
28
85
|
constructChildren(children: ComponentChildren, contextManager?: ContextManager): void;
|
|
29
86
|
/**
|
|
30
87
|
* Adds the supplied component instance as a child of this component, removing it from any existing parent.
|
|
@@ -41,9 +98,29 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
|
|
|
41
98
|
* Removes this component from its parent component.
|
|
42
99
|
*/
|
|
43
100
|
remove(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Adds a behavior to the component.
|
|
103
|
+
* @param {Behavior} b - The behavior to add.
|
|
104
|
+
*/
|
|
44
105
|
addBehavior(b: Behavior): void;
|
|
106
|
+
/**
|
|
107
|
+
* Removes a behavior from the component.
|
|
108
|
+
* @param {Behavior} b - The behavior to remove.
|
|
109
|
+
*/
|
|
45
110
|
removeBehavior(b: Behavior): void;
|
|
111
|
+
/**
|
|
112
|
+
* Gets a behavior of a specific type from the component.
|
|
113
|
+
* @param {T} type - The type of behavior to get.
|
|
114
|
+
* @returns {InstanceType<T> | undefined} The behavior of the specified type, or undefined if no such behavior exists.
|
|
115
|
+
* @template T The behavior type.
|
|
116
|
+
*/
|
|
46
117
|
getBehavior<T extends BehaviorConstructor>(type: T): InstanceType<T> | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Gets all behaviors of a specific type from the component.
|
|
120
|
+
* @param {T} type - The type of behaviors to get.
|
|
121
|
+
* @returns {InstanceType<T>[]} An array of behaviors of the specified type.
|
|
122
|
+
* @template T The behavior type.
|
|
123
|
+
*/
|
|
47
124
|
getBehaviors<T extends BehaviorConstructor>(type: T): InstanceType<T>[];
|
|
48
125
|
/**
|
|
49
126
|
* An array of the elements that this component instance exposes. In the case that this component
|
|
@@ -68,5 +145,8 @@ export declare class Component<ElementType = any, ConstructorPropsType extends C
|
|
|
68
145
|
readonly tags: Observable<string[], never>;
|
|
69
146
|
private _updateEnabledResolved;
|
|
70
147
|
private _updateTags;
|
|
148
|
+
/**
|
|
149
|
+
* Dispose of this component and all of its children.
|
|
150
|
+
*/
|
|
71
151
|
dispose(): never;
|
|
72
152
|
}
|
package/lib/component.js
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { TagContext } from './contexts/tagcontext';
|
|
2
2
|
import { Entity } from './entity';
|
|
3
3
|
import { Observable } from './observable';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all components.
|
|
6
|
+
*
|
|
7
|
+
* Components define the different types of nodes you can have in your project.
|
|
8
|
+
* Each component provides a set of functionalities and properties that you can add as nodes in your project’s Hierarchy, as many times as you like.
|
|
9
|
+
* While there are many components included with Mattercraft (such as `Box` and `Group`), you can also create your own by extending the Component class.
|
|
10
|
+
*
|
|
11
|
+
* @link [custom-components](https://docs.zap.works/mattercraft/scripting/custom-components/)
|
|
12
|
+
*/
|
|
4
13
|
export class Component extends Entity {
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of Component.
|
|
16
|
+
* @param contextManager The current ContextManager
|
|
17
|
+
* @param constructorProps - The constructor properties.
|
|
18
|
+
*/
|
|
5
19
|
constructor(contextManager, constructorProps) {
|
|
6
20
|
super(contextManager);
|
|
7
21
|
this.constructorProps = constructorProps;
|
|
22
|
+
/**
|
|
23
|
+
* The children of this component.
|
|
24
|
+
*/
|
|
8
25
|
this.children = [];
|
|
26
|
+
/**
|
|
27
|
+
* The behaviors attached to this component.
|
|
28
|
+
*/
|
|
9
29
|
this.behaviors = [];
|
|
10
30
|
/**
|
|
11
31
|
* An array of string 'tags' assocated with this component.
|
|
@@ -40,6 +60,9 @@ export class Component extends Entity {
|
|
|
40
60
|
this.register(this.enabled, this._updateEnabledResolved, { bindWhenDisabled: true });
|
|
41
61
|
this.register(this.tags, this._updateTags, { bindWhenDisabled: true });
|
|
42
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Constructs the children of this component.
|
|
65
|
+
*/
|
|
43
66
|
constructChildren(children, contextManager) {
|
|
44
67
|
contextManager = contextManager ?? this.contextManager;
|
|
45
68
|
for (const [constructor, props, ref] of children) {
|
|
@@ -82,20 +105,40 @@ export class Component extends Entity {
|
|
|
82
105
|
remove() {
|
|
83
106
|
this.parent?.removeChild(this);
|
|
84
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Adds a behavior to the component.
|
|
110
|
+
* @param {Behavior} b - The behavior to add.
|
|
111
|
+
*/
|
|
85
112
|
addBehavior(b) {
|
|
86
113
|
this.behaviors.push(b);
|
|
87
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Removes a behavior from the component.
|
|
117
|
+
* @param {Behavior} b - The behavior to remove.
|
|
118
|
+
*/
|
|
88
119
|
removeBehavior(b) {
|
|
89
120
|
const indx = this.behaviors.indexOf(b);
|
|
90
121
|
if (indx >= 0)
|
|
91
122
|
this.behaviors.splice(indx, 1);
|
|
92
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Gets a behavior of a specific type from the component.
|
|
126
|
+
* @param {T} type - The type of behavior to get.
|
|
127
|
+
* @returns {InstanceType<T> | undefined} The behavior of the specified type, or undefined if no such behavior exists.
|
|
128
|
+
* @template T The behavior type.
|
|
129
|
+
*/
|
|
93
130
|
getBehavior(type) {
|
|
94
131
|
for (const behavior of this.behaviors) {
|
|
95
132
|
if (behavior instanceof type)
|
|
96
133
|
return behavior;
|
|
97
134
|
}
|
|
98
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets all behaviors of a specific type from the component.
|
|
138
|
+
* @param {T} type - The type of behaviors to get.
|
|
139
|
+
* @returns {InstanceType<T>[]} An array of behaviors of the specified type.
|
|
140
|
+
* @template T The behavior type.
|
|
141
|
+
*/
|
|
99
142
|
getBehaviors(type) {
|
|
100
143
|
return this.behaviors.filter(entry => entry instanceof type);
|
|
101
144
|
}
|
|
@@ -116,12 +159,17 @@ export class Component extends Entity {
|
|
|
116
159
|
}
|
|
117
160
|
return ret;
|
|
118
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Dispose of this component and all of its children.
|
|
164
|
+
*/
|
|
119
165
|
dispose() {
|
|
120
166
|
for (const child of this.children) {
|
|
121
167
|
try {
|
|
122
168
|
child.dispose();
|
|
123
169
|
}
|
|
124
|
-
catch (err) {
|
|
170
|
+
catch (err) {
|
|
171
|
+
// Fail silently
|
|
172
|
+
}
|
|
125
173
|
}
|
|
126
174
|
this.children.length = 0;
|
|
127
175
|
this.contextManager.get(TagContext).unregisterComponent(this);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PlayOptions, Stream } from
|
|
2
|
-
import { Component } from
|
|
3
|
-
import { ContextManager } from
|
|
4
|
-
import { Event } from
|
|
5
|
-
import { Observable } from
|
|
1
|
+
import { PlayOptions, Stream } from '../animation';
|
|
2
|
+
import { Component } from '../component';
|
|
3
|
+
import { ContextManager } from '../context';
|
|
4
|
+
import { Event } from '../event';
|
|
5
|
+
import { Observable } from '../observable';
|
|
6
6
|
export interface AudioConstructorProps {
|
|
7
7
|
/** @zprop
|
|
8
8
|
* @zvalues files *.+(mp3|wav)
|
|
@@ -19,6 +19,10 @@ export interface AudioConstructorProps {
|
|
|
19
19
|
autoplay?: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
+
* The Audio class represents an audio component that can be controlled.
|
|
23
|
+
* It provides methods to play, pause, stop, and seek the audio.
|
|
24
|
+
* It also provides observables for volume and mute state, and events for when the audio ends, stops, pauses, and plays.
|
|
25
|
+
*
|
|
22
26
|
* @zcomponent
|
|
23
27
|
* @ztag core/audio
|
|
24
28
|
* @zgroup Media
|
|
@@ -38,6 +42,11 @@ export declare class Audio extends Component<undefined, AudioConstructorProps> i
|
|
|
38
42
|
private _playhead;
|
|
39
43
|
private _rate;
|
|
40
44
|
private _session?;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new Audio component.
|
|
47
|
+
* @param mgr - The current ContextManager
|
|
48
|
+
* @param props - The constructor properties.
|
|
49
|
+
*/
|
|
41
50
|
constructor(mgr: ContextManager, props: AudioConstructorProps);
|
|
42
51
|
private _load;
|
|
43
52
|
private _updateVolume;
|
package/lib/components/Audio.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import { AudioContextContext, useAudioContext } from
|
|
3
|
-
import { isDesignTime } from
|
|
4
|
-
import { registerLoadable, started } from
|
|
5
|
-
import { Event } from
|
|
6
|
-
import { Observable } from
|
|
1
|
+
import { Component } from '../component';
|
|
2
|
+
import { AudioContextContext, useAudioContext } from '../contexts/audiocontextcontext';
|
|
3
|
+
import { isDesignTime } from '../contexts/environmentcontext';
|
|
4
|
+
import { registerLoadable, started } from '../contexts/loadcontext';
|
|
5
|
+
import { Event } from '../event';
|
|
6
|
+
import { Observable } from '../observable';
|
|
7
7
|
/**
|
|
8
|
+
* The Audio class represents an audio component that can be controlled.
|
|
9
|
+
* It provides methods to play, pause, stop, and seek the audio.
|
|
10
|
+
* It also provides observables for volume and mute state, and events for when the audio ends, stops, pauses, and plays.
|
|
11
|
+
*
|
|
8
12
|
* @zcomponent
|
|
9
13
|
* @ztag core/audio
|
|
10
14
|
* @zgroup Media
|
|
@@ -12,6 +16,11 @@ import { Observable } from "../observable";
|
|
|
12
16
|
* @zstream
|
|
13
17
|
*/
|
|
14
18
|
export class Audio extends Component {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new Audio component.
|
|
21
|
+
* @param mgr - The current ContextManager
|
|
22
|
+
* @param props - The constructor properties.
|
|
23
|
+
*/
|
|
15
24
|
constructor(mgr, props) {
|
|
16
25
|
super(mgr, props);
|
|
17
26
|
/** @zui */ this.onEnded = new Event();
|
|
@@ -92,9 +101,9 @@ export class Audio extends Component {
|
|
|
92
101
|
source.playbackRate.value = Math.abs(this._rate);
|
|
93
102
|
source.buffer = this._rate < 0 ? this._getReversed(this.audioBuffer) : this.audioBuffer;
|
|
94
103
|
source.connect(this.destination);
|
|
95
|
-
const startedAt = this.audioContext.currentTime -
|
|
104
|
+
const startedAt = this.audioContext.currentTime - resolvedPlayhead / source.playbackRate.value;
|
|
96
105
|
source.start(0, resolvedPlayhead);
|
|
97
|
-
source.addEventListener(
|
|
106
|
+
source.addEventListener('ended', () => this.onEnded.emit(this));
|
|
98
107
|
this._session = { source, startedAt };
|
|
99
108
|
this.onPlay.emit(this);
|
|
100
109
|
}
|
|
@@ -130,7 +139,7 @@ export class Audio extends Component {
|
|
|
130
139
|
* @zui
|
|
131
140
|
*/
|
|
132
141
|
seek(/** @ztype time-milliseconds */ t) {
|
|
133
|
-
|
|
142
|
+
const previousSession = this._session;
|
|
134
143
|
if (previousSession)
|
|
135
144
|
this._pause();
|
|
136
145
|
this._playhead = t / 1000;
|
|
@@ -138,7 +147,7 @@ export class Audio extends Component {
|
|
|
138
147
|
this.play({ speed: this._rate });
|
|
139
148
|
}
|
|
140
149
|
length() {
|
|
141
|
-
return this.audioBuffer ?
|
|
150
|
+
return this.audioBuffer ? this.audioBuffer.duration * 1000 : undefined;
|
|
142
151
|
}
|
|
143
152
|
dispose() {
|
|
144
153
|
this.stop();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import { ContextManager } from
|
|
3
|
-
import { Observable } from
|
|
1
|
+
import { Component } from '../component';
|
|
2
|
+
import { ContextManager } from '../context';
|
|
3
|
+
import { Observable } from '../observable';
|
|
4
4
|
interface AudioLayerSettingsConstuctorProps {
|
|
5
5
|
/**
|
|
6
6
|
* @zprop
|
|
@@ -9,12 +9,18 @@ interface AudioLayerSettingsConstuctorProps {
|
|
|
9
9
|
layer?: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
+
* Audio layer settings.
|
|
12
13
|
* @zcomponent
|
|
13
14
|
* @ztag core/audiolayersettings
|
|
14
15
|
* @zgroup Media
|
|
15
16
|
* @zicon volume_up
|
|
16
17
|
*/
|
|
17
18
|
export declare class AudioLayerSettings extends Component<undefined, AudioLayerSettingsConstuctorProps> {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new AudioLayerSettings component.
|
|
21
|
+
* @param contextManager - The current ContextManager
|
|
22
|
+
* @param props - The constructor properties.
|
|
23
|
+
*/
|
|
18
24
|
constructor(contextManager: ContextManager, props: AudioLayerSettingsConstuctorProps);
|
|
19
25
|
/**
|
|
20
26
|
* @zprop
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import { AudioContextContext } from
|
|
3
|
-
import { Observable } from
|
|
1
|
+
import { Component } from '../component';
|
|
2
|
+
import { AudioContextContext } from '../contexts/audiocontextcontext';
|
|
3
|
+
import { Observable } from '../observable';
|
|
4
4
|
/**
|
|
5
|
+
* Audio layer settings.
|
|
5
6
|
* @zcomponent
|
|
6
7
|
* @ztag core/audiolayersettings
|
|
7
8
|
* @zgroup Media
|
|
8
9
|
* @zicon volume_up
|
|
9
10
|
*/
|
|
10
11
|
export class AudioLayerSettings extends Component {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new AudioLayerSettings component.
|
|
14
|
+
* @param contextManager - The current ContextManager
|
|
15
|
+
* @param props - The constructor properties.
|
|
16
|
+
*/
|
|
11
17
|
constructor(contextManager, props) {
|
|
12
18
|
super(contextManager, props);
|
|
13
19
|
/**
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { Component, ConstructorProps } from
|
|
2
|
-
import { ContextManager } from
|
|
1
|
+
import { Component, ConstructorProps } from '../component';
|
|
2
|
+
import { ContextManager } from '../context';
|
|
3
3
|
/**
|
|
4
4
|
* @zcomponent
|
|
5
5
|
* @zgroup Advanced
|
|
6
6
|
* @zicon list
|
|
7
7
|
*/
|
|
8
8
|
export declare class Children extends Component {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of Children.
|
|
11
|
+
* @param contextManager - The current ContextManager
|
|
12
|
+
* @param props - The constructor properties.
|
|
13
|
+
*/
|
|
9
14
|
constructor(contextManager: ContextManager, props: ConstructorProps);
|
|
10
15
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { Component } from
|
|
1
|
+
import { Component } from '../component';
|
|
2
2
|
/**
|
|
3
3
|
* @zcomponent
|
|
4
4
|
* @zgroup Advanced
|
|
5
5
|
* @zicon list
|
|
6
6
|
*/
|
|
7
7
|
export class Children extends Component {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of Children.
|
|
10
|
+
* @param contextManager - The current ContextManager
|
|
11
|
+
* @param props - The constructor properties.
|
|
12
|
+
*/
|
|
8
13
|
constructor(contextManager, props) {
|
|
9
14
|
super(contextManager, props);
|
|
10
15
|
const zcomponent = this.getZComponentInstance();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import { ContextManager } from
|
|
3
|
-
import { Observable } from
|
|
1
|
+
import { Component } from '../component';
|
|
2
|
+
import { ContextManager } from '../context';
|
|
3
|
+
import { Observable } from '../observable';
|
|
4
4
|
export interface DefaultCookieConsentConstructorProps {
|
|
5
5
|
/**
|
|
6
6
|
* Show the cookie consent dialog when the experience starts, rather than when the component is initialized.
|
|
@@ -22,6 +22,11 @@ export interface DefaultCookieConsentConstructorProps {
|
|
|
22
22
|
preview: boolean;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
+
* The CookieConsent component is responsible for displaying a cookie consent banner to the user.
|
|
26
|
+
*
|
|
27
|
+
* This banner informs the user about the use of cookies on the website and asks for their consent.
|
|
28
|
+
* The component handles the logic for displaying the banner, receiving the user's consent, and storing this consent.
|
|
29
|
+
* It also provides methods to check if the user has already given their consent.
|
|
25
30
|
* @zcomponent
|
|
26
31
|
* @zgroup Cookie Consent
|
|
27
32
|
* @zicon cookie
|
|
@@ -144,6 +149,11 @@ export declare class DefaultCookieConsent extends Component {
|
|
|
144
149
|
private _functional;
|
|
145
150
|
private _performance;
|
|
146
151
|
private _marketing;
|
|
152
|
+
/**
|
|
153
|
+
* Creates an instance of DefaultCookieConsent.
|
|
154
|
+
* @param contextManager - The current ContextManager
|
|
155
|
+
* @param constructorProps - The properties of the component
|
|
156
|
+
*/
|
|
147
157
|
constructor(contextManager: ContextManager, constructorProps: DefaultCookieConsentConstructorProps);
|
|
148
158
|
private _loadDOM;
|
|
149
159
|
private _save;
|