@zcomponent/core 1.10.0-beta → 1.11.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/lib/behaviors/ActivateState.d.ts +2 -1
- package/lib/behaviors/ActivateState.js +2 -1
- package/lib/behaviors/CallFunction.d.ts +19 -0
- package/lib/behaviors/CallFunction.js +18 -0
- package/lib/behaviors/ConsoleLog.d.ts +1 -0
- package/lib/behaviors/ConsoleLog.js +1 -0
- package/lib/behaviors/DownloadSnapshot.d.ts +2 -1
- package/lib/behaviors/DownloadSnapshot.js +2 -1
- package/lib/behaviors/LaunchURL.d.ts +1 -0
- package/lib/behaviors/LaunchURL.js +1 -0
- package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -0
- package/lib/behaviors/LogAnalyticsEvent.js +1 -0
- package/lib/behaviors/PauseLayerClip.d.ts +2 -1
- package/lib/behaviors/PauseLayerClip.js +2 -1
- package/lib/behaviors/PlayLayerClip.d.ts +2 -1
- package/lib/behaviors/PlayLayerClip.js +2 -1
- package/lib/behaviors/PlaySound.d.ts +2 -1
- package/lib/behaviors/PlaySound.js +2 -1
- package/lib/behaviors/SetLayerOff.d.ts +2 -1
- package/lib/behaviors/SetLayerOff.js +2 -1
- package/lib/behaviors/ShareSnapshot.d.ts +2 -1
- package/lib/behaviors/ShareSnapshot.js +2 -1
- package/lib/behaviors/ShowTextAlert.d.ts +3 -1
- package/lib/behaviors/ShowTextAlert.js +3 -1
- package/lib/behaviors/TakeSnapshot.d.ts +1 -0
- package/lib/behaviors/TakeSnapshot.js +1 -0
- package/lib/behaviors/ToggleLayerClips.d.ts +2 -1
- package/lib/behaviors/ToggleLayerClips.js +2 -1
- package/lib/behaviors/stream/PauseStream.d.ts +4 -1
- package/lib/behaviors/stream/PauseStream.js +4 -1
- package/lib/behaviors/stream/PlayStream.d.ts +2 -1
- package/lib/behaviors/stream/PlayStream.js +2 -1
- package/lib/behaviors/stream/SeekStream.d.ts +2 -1
- package/lib/behaviors/stream/SeekStream.js +2 -1
- package/lib/behaviors/stream/StopStream.d.ts +2 -1
- package/lib/behaviors/stream/StopStream.js +2 -1
- package/lib/components/Audio.d.ts +17 -5
- package/lib/components/Audio.js +17 -5
- package/lib/contexts/analyticscontext.d.ts +2 -0
- package/lib/contexts/analyticscontext.js +2 -0
- package/lib/contexts/textalertcontext.d.ts +2 -0
- package/lib/contexts/textalertcontext.js +2 -0
- package/lib/data/core.d.ts +29 -0
- package/lib/data/core.js +6 -0
- package/lib/selectors.js +29 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +29 -1
- package/lib/zcomponent.d.ts +2 -0
- package/lib/zcomponent.js +68 -1
- package/package.json +1 -1
|
@@ -38,8 +38,9 @@ export declare class ActivateState extends ActionBehavior {
|
|
|
38
38
|
*/
|
|
39
39
|
easing?: string;
|
|
40
40
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
41
|
-
perform(): void;
|
|
42
41
|
/** @zprop */
|
|
42
|
+
perform(): void;
|
|
43
|
+
/** @zui */
|
|
43
44
|
preview(): void;
|
|
44
45
|
}
|
|
45
46
|
export declare enum Pin {
|
|
@@ -10,6 +10,7 @@ export class ActivateState extends ActionBehavior {
|
|
|
10
10
|
super(contextManager, instance, props);
|
|
11
11
|
this.zcomponent = this.getZComponentInstance();
|
|
12
12
|
}
|
|
13
|
+
/** @zprop */
|
|
13
14
|
perform() {
|
|
14
15
|
if (!this.state)
|
|
15
16
|
return;
|
|
@@ -25,7 +26,7 @@ export class ActivateState extends ActionBehavior {
|
|
|
25
26
|
};
|
|
26
27
|
layerclip.play(opts);
|
|
27
28
|
}
|
|
28
|
-
/** @
|
|
29
|
+
/** @zui */
|
|
29
30
|
preview() {
|
|
30
31
|
this.perform();
|
|
31
32
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionBehavior } from "../actionbehavior";
|
|
2
|
+
/**
|
|
3
|
+
* Calls an exposed function on a context
|
|
4
|
+
*
|
|
5
|
+
* @zbehavior
|
|
6
|
+
* @zicon function
|
|
7
|
+
* @zgroup Actions
|
|
8
|
+
*/
|
|
9
|
+
export declare class CallFunction extends ActionBehavior {
|
|
10
|
+
/**
|
|
11
|
+
* The function and arguments to call
|
|
12
|
+
* @zprop
|
|
13
|
+
*/
|
|
14
|
+
function: () => any;
|
|
15
|
+
/** @zui
|
|
16
|
+
* @zprop
|
|
17
|
+
*/
|
|
18
|
+
perform(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ActionBehavior } from "../actionbehavior";
|
|
2
|
+
import { registerBehaviorRunAtDesignTime } from "../behavior";
|
|
3
|
+
/**
|
|
4
|
+
* Calls an exposed function on a context
|
|
5
|
+
*
|
|
6
|
+
* @zbehavior
|
|
7
|
+
* @zicon function
|
|
8
|
+
* @zgroup Actions
|
|
9
|
+
*/
|
|
10
|
+
export class CallFunction extends ActionBehavior {
|
|
11
|
+
/** @zui
|
|
12
|
+
* @zprop
|
|
13
|
+
*/
|
|
14
|
+
perform() {
|
|
15
|
+
this.function();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
registerBehaviorRunAtDesignTime(CallFunction);
|
|
@@ -14,8 +14,9 @@ export declare class DownloadSnapshot extends ActionBehavior<DownloadSnapshotPro
|
|
|
14
14
|
/** @zui */
|
|
15
15
|
onSave: Event<[]>;
|
|
16
16
|
constructor(contextManager: ContextManager, instance: Component, props: DownloadSnapshotProps);
|
|
17
|
+
/** @zprop */
|
|
17
18
|
perform(): void;
|
|
18
19
|
private download;
|
|
19
|
-
/** @
|
|
20
|
+
/** @zui */
|
|
20
21
|
preview(): void;
|
|
21
22
|
}
|
|
@@ -14,7 +14,8 @@ export declare class PauseLayerClip extends ActionBehavior {
|
|
|
14
14
|
*/
|
|
15
15
|
layerClip: string | undefined;
|
|
16
16
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
17
|
-
perform(): void;
|
|
18
17
|
/** @zprop */
|
|
18
|
+
perform(): void;
|
|
19
|
+
/** @zui */
|
|
19
20
|
preview(): void;
|
|
20
21
|
}
|
|
@@ -10,6 +10,7 @@ export class PauseLayerClip extends ActionBehavior {
|
|
|
10
10
|
super(contextManager, instance, props);
|
|
11
11
|
this.zcomponent = this.getZComponentInstance();
|
|
12
12
|
}
|
|
13
|
+
/** @zprop */
|
|
13
14
|
perform() {
|
|
14
15
|
if (!this.layerClip)
|
|
15
16
|
return;
|
|
@@ -18,7 +19,7 @@ export class PauseLayerClip extends ActionBehavior {
|
|
|
18
19
|
return;
|
|
19
20
|
layerclip.pause();
|
|
20
21
|
}
|
|
21
|
-
/** @
|
|
22
|
+
/** @zui */
|
|
22
23
|
preview() {
|
|
23
24
|
this.perform();
|
|
24
25
|
}
|
|
@@ -68,8 +68,9 @@ export declare class PlayLayerClip extends ActionBehavior {
|
|
|
68
68
|
*/
|
|
69
69
|
easing?: string;
|
|
70
70
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
71
|
-
perform(): void;
|
|
72
71
|
/** @zprop */
|
|
72
|
+
perform(): void;
|
|
73
|
+
/** @zui */
|
|
73
74
|
preview(): void;
|
|
74
75
|
}
|
|
75
76
|
export declare enum Pin {
|
|
@@ -26,6 +26,7 @@ export class PlayLayerClip extends ActionBehavior {
|
|
|
26
26
|
*/
|
|
27
27
|
this.fromStart = false;
|
|
28
28
|
}
|
|
29
|
+
/** @zprop */
|
|
29
30
|
perform() {
|
|
30
31
|
if (!this.layerClip)
|
|
31
32
|
return;
|
|
@@ -48,7 +49,7 @@ export class PlayLayerClip extends ActionBehavior {
|
|
|
48
49
|
else
|
|
49
50
|
layerclip.play(opts);
|
|
50
51
|
}
|
|
51
|
-
/** @
|
|
52
|
+
/** @zui */
|
|
52
53
|
preview() {
|
|
53
54
|
this.perform();
|
|
54
55
|
}
|
|
@@ -44,8 +44,9 @@ export declare class PlaySound extends ActionBehavior<PlaySoundProps> {
|
|
|
44
44
|
speed: Observable<number, never>;
|
|
45
45
|
private _component;
|
|
46
46
|
constructor(contextManager: ContextManager, instance: Component, props: PlaySoundProps);
|
|
47
|
-
perform(): void;
|
|
48
47
|
/** @zprop */
|
|
48
|
+
perform(): void;
|
|
49
|
+
/** @zui */
|
|
49
50
|
preview(): void;
|
|
50
51
|
dispose(): never;
|
|
51
52
|
}
|
|
@@ -23,11 +23,12 @@ export class PlaySound extends ActionBehavior {
|
|
|
23
23
|
this.muted = this._component.muted;
|
|
24
24
|
this.volume = this._component.volume;
|
|
25
25
|
}
|
|
26
|
+
/** @zprop */
|
|
26
27
|
perform() {
|
|
27
28
|
this._component.seek(0);
|
|
28
29
|
this._component.play({ speed: this.speed.value });
|
|
29
30
|
}
|
|
30
|
-
/** @
|
|
31
|
+
/** @zui */
|
|
31
32
|
preview() {
|
|
32
33
|
this.perform();
|
|
33
34
|
}
|
|
@@ -14,7 +14,8 @@ export declare class SetLayerOff extends ActionBehavior {
|
|
|
14
14
|
*/
|
|
15
15
|
layer: string | undefined;
|
|
16
16
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
17
|
-
perform(): void;
|
|
18
17
|
/** @zprop */
|
|
18
|
+
perform(): void;
|
|
19
|
+
/** @zui */
|
|
19
20
|
preview(): void;
|
|
20
21
|
}
|
|
@@ -10,6 +10,7 @@ export class SetLayerOff extends ActionBehavior {
|
|
|
10
10
|
super(contextManager, instance, props);
|
|
11
11
|
this.zcomponent = this.getZComponentInstance();
|
|
12
12
|
}
|
|
13
|
+
/** @zprop */
|
|
13
14
|
perform() {
|
|
14
15
|
if (!this.layer)
|
|
15
16
|
return;
|
|
@@ -18,7 +19,7 @@ export class SetLayerOff extends ActionBehavior {
|
|
|
18
19
|
return;
|
|
19
20
|
layer.active = null;
|
|
20
21
|
}
|
|
21
|
-
/** @
|
|
22
|
+
/** @zui */
|
|
22
23
|
preview() {
|
|
23
24
|
this.perform();
|
|
24
25
|
}
|
|
@@ -14,8 +14,9 @@ export declare class ShareSnapshot extends ActionBehavior<ShareCanvasProps> {
|
|
|
14
14
|
/** @zui */
|
|
15
15
|
onShare: Event<[]>;
|
|
16
16
|
constructor(contextManager: ContextManager, instance: Component, props: ShareCanvasProps);
|
|
17
|
+
/** @zprop */
|
|
17
18
|
perform(): void;
|
|
18
19
|
private share;
|
|
19
|
-
/** @
|
|
20
|
+
/** @zui */
|
|
20
21
|
preview(): void;
|
|
21
22
|
}
|
|
@@ -56,8 +56,10 @@ export declare class ShowTextAlert extends ActionBehavior {
|
|
|
56
56
|
classNames: Observable<string[], never>;
|
|
57
57
|
/**
|
|
58
58
|
* How long the alert will apear on the screen
|
|
59
|
+
*
|
|
60
|
+
* @zprop
|
|
59
61
|
*/
|
|
60
62
|
perform(): void;
|
|
61
|
-
/** @
|
|
63
|
+
/** @zui */
|
|
62
64
|
preview(): void;
|
|
63
65
|
}
|
|
@@ -61,6 +61,8 @@ export class ShowTextAlert extends ActionBehavior {
|
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* How long the alert will apear on the screen
|
|
64
|
+
*
|
|
65
|
+
* @zprop
|
|
64
66
|
*/
|
|
65
67
|
perform() {
|
|
66
68
|
showTextAlert(this.contextManager, this.text.value, {
|
|
@@ -70,7 +72,7 @@ export class ShowTextAlert extends ActionBehavior {
|
|
|
70
72
|
timeout: this.timeout.value
|
|
71
73
|
});
|
|
72
74
|
}
|
|
73
|
-
/** @
|
|
75
|
+
/** @zui */
|
|
74
76
|
preview() {
|
|
75
77
|
this.perform();
|
|
76
78
|
}
|
|
@@ -90,8 +90,9 @@ export declare class ToggleLayerClips extends ActionBehavior {
|
|
|
90
90
|
easing?: string;
|
|
91
91
|
isA: boolean;
|
|
92
92
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
93
|
-
perform(): void;
|
|
94
93
|
/** @zprop */
|
|
94
|
+
perform(): void;
|
|
95
|
+
/** @zui */
|
|
95
96
|
preview(): void;
|
|
96
97
|
}
|
|
97
98
|
export declare enum Pin {
|
|
@@ -27,6 +27,7 @@ export class ToggleLayerClips extends ActionBehavior {
|
|
|
27
27
|
this.fromStart = false;
|
|
28
28
|
this.isA = true;
|
|
29
29
|
}
|
|
30
|
+
/** @zprop */
|
|
30
31
|
perform() {
|
|
31
32
|
this.isA = !this.isA;
|
|
32
33
|
const opts = {
|
|
@@ -62,7 +63,7 @@ export class ToggleLayerClips extends ActionBehavior {
|
|
|
62
63
|
layerclip.play(opts);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
/** @
|
|
66
|
+
/** @zui */
|
|
66
67
|
preview() {
|
|
67
68
|
this.perform();
|
|
68
69
|
}
|
|
@@ -17,6 +17,9 @@ export declare class PauseStream extends ActionBehavior {
|
|
|
17
17
|
stream: string | undefined;
|
|
18
18
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
19
19
|
perform(): void;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* @zprop
|
|
22
|
+
* @zui
|
|
23
|
+
*/
|
|
21
24
|
preview(): void;
|
|
22
25
|
}
|
|
@@ -39,7 +39,8 @@ export declare class PlayStream extends ActionBehavior {
|
|
|
39
39
|
*/
|
|
40
40
|
fromStart: boolean;
|
|
41
41
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
42
|
-
perform(): void;
|
|
43
42
|
/** @zprop */
|
|
43
|
+
perform(): void;
|
|
44
|
+
/** @zui */
|
|
44
45
|
preview(): void;
|
|
45
46
|
}
|
|
@@ -19,6 +19,7 @@ export class PlayStream extends ActionBehavior {
|
|
|
19
19
|
*/
|
|
20
20
|
this.fromStart = false;
|
|
21
21
|
}
|
|
22
|
+
/** @zprop */
|
|
22
23
|
perform() {
|
|
23
24
|
if (!this.stream)
|
|
24
25
|
return;
|
|
@@ -29,7 +30,7 @@ export class PlayStream extends ActionBehavior {
|
|
|
29
30
|
stream.seek(0);
|
|
30
31
|
stream.play({ loop: this.loop, speed: this.speed });
|
|
31
32
|
}
|
|
32
|
-
/** @
|
|
33
|
+
/** @zui */
|
|
33
34
|
preview() {
|
|
34
35
|
this.perform();
|
|
35
36
|
}
|
|
@@ -24,7 +24,8 @@ export declare class SeekStream extends ActionBehavior {
|
|
|
24
24
|
*/
|
|
25
25
|
time: number;
|
|
26
26
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
27
|
-
perform(): void;
|
|
28
27
|
/** @zprop */
|
|
28
|
+
perform(): void;
|
|
29
|
+
/** @zui */
|
|
29
30
|
preview(): void;
|
|
30
31
|
}
|
|
@@ -18,6 +18,7 @@ export class SeekStream extends ActionBehavior {
|
|
|
18
18
|
*/
|
|
19
19
|
this.time = 0;
|
|
20
20
|
}
|
|
21
|
+
/** @zprop */
|
|
21
22
|
perform() {
|
|
22
23
|
if (!this.stream)
|
|
23
24
|
return;
|
|
@@ -26,7 +27,7 @@ export class SeekStream extends ActionBehavior {
|
|
|
26
27
|
return;
|
|
27
28
|
stream.seek(this.time ?? 0);
|
|
28
29
|
}
|
|
29
|
-
/** @
|
|
30
|
+
/** @zui */
|
|
30
31
|
preview() {
|
|
31
32
|
this.perform();
|
|
32
33
|
}
|
|
@@ -16,7 +16,8 @@ export declare class StopStream extends ActionBehavior {
|
|
|
16
16
|
*/
|
|
17
17
|
stream: string | undefined;
|
|
18
18
|
constructor(contextManager: ContextManager, instance: Component, props: ActionBehaviorConstructorProps);
|
|
19
|
-
perform(): void;
|
|
20
19
|
/** @zprop */
|
|
20
|
+
perform(): void;
|
|
21
|
+
/** @zui */
|
|
21
22
|
preview(): void;
|
|
22
23
|
}
|
|
@@ -10,6 +10,7 @@ export class StopStream extends ActionBehavior {
|
|
|
10
10
|
super(contextManager, instance, props);
|
|
11
11
|
this.zcomponent = this.getZComponentInstance();
|
|
12
12
|
}
|
|
13
|
+
/** @zprop */
|
|
13
14
|
perform() {
|
|
14
15
|
if (!this.stream)
|
|
15
16
|
return;
|
|
@@ -18,7 +19,7 @@ export class StopStream extends ActionBehavior {
|
|
|
18
19
|
return;
|
|
19
20
|
stream.stop();
|
|
20
21
|
}
|
|
21
|
-
/** @
|
|
22
|
+
/** @zui */
|
|
22
23
|
preview() {
|
|
23
24
|
this.perform();
|
|
24
25
|
}
|
|
@@ -56,15 +56,27 @@ export declare class Audio extends Component<undefined, AudioConstructorProps> i
|
|
|
56
56
|
* @zdefault 1
|
|
57
57
|
*/
|
|
58
58
|
readonly volume: Observable<number, never>;
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* @zprop
|
|
61
|
+
* @zui
|
|
62
|
+
*/
|
|
60
63
|
play(opts?: PlayOptions): void;
|
|
61
64
|
private _pause;
|
|
62
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* @zprop
|
|
67
|
+
* @zui
|
|
68
|
+
*/
|
|
63
69
|
pause(): void;
|
|
64
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* @zprop
|
|
72
|
+
* @zui
|
|
73
|
+
*/
|
|
65
74
|
stop(): void;
|
|
66
|
-
/**
|
|
67
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @zprop
|
|
77
|
+
* @zui
|
|
78
|
+
*/
|
|
79
|
+
seek(/** @ztype time-milliseconds */ t: number): void;
|
|
68
80
|
length(): number | undefined;
|
|
69
81
|
dispose(): never;
|
|
70
82
|
}
|
package/lib/components/Audio.js
CHANGED
|
@@ -68,7 +68,10 @@ export class Audio extends Component {
|
|
|
68
68
|
}
|
|
69
69
|
return this._reversed;
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* @zprop
|
|
73
|
+
* @zui
|
|
74
|
+
*/
|
|
72
75
|
play(opts) {
|
|
73
76
|
if (!this.audioBuffer)
|
|
74
77
|
return;
|
|
@@ -105,19 +108,28 @@ export class Audio extends Component {
|
|
|
105
108
|
this._session.source.disconnect();
|
|
106
109
|
delete this._session;
|
|
107
110
|
}
|
|
108
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* @zprop
|
|
113
|
+
* @zui
|
|
114
|
+
*/
|
|
109
115
|
pause() {
|
|
110
116
|
this._pause();
|
|
111
117
|
this.onPause.emit(this);
|
|
112
118
|
}
|
|
113
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* @zprop
|
|
121
|
+
* @zui
|
|
122
|
+
*/
|
|
114
123
|
stop() {
|
|
115
124
|
this._pause();
|
|
116
125
|
this._playhead = 0;
|
|
117
126
|
this.onStop.emit(this);
|
|
118
127
|
}
|
|
119
|
-
/**
|
|
120
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @zprop
|
|
130
|
+
* @zui
|
|
131
|
+
*/
|
|
132
|
+
seek(/** @ztype time-milliseconds */ t) {
|
|
121
133
|
let previousSession = this._session;
|
|
122
134
|
if (previousSession)
|
|
123
135
|
this._pause();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ContextManager, Context } from '../context';
|
|
2
2
|
import { Event } from '../event';
|
|
3
|
+
/** @zcontext */
|
|
3
4
|
export declare class AnalyticsContext extends Context {
|
|
4
5
|
readonly onEvent: Event<[string, any]>;
|
|
6
|
+
/** @zprop */
|
|
5
7
|
logEvent(name: string, params?: any): void;
|
|
6
8
|
}
|
|
7
9
|
export declare function logEvent(mgr: ContextManager, name: string, params?: any): void;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Context } from '../context';
|
|
2
2
|
import { Event } from '../event';
|
|
3
|
+
/** @zcontext */
|
|
3
4
|
export class AnalyticsContext extends Context {
|
|
4
5
|
constructor() {
|
|
5
6
|
super(...arguments);
|
|
6
7
|
this.onEvent = new Event();
|
|
7
8
|
}
|
|
9
|
+
/** @zprop */
|
|
8
10
|
logEvent(name, params) {
|
|
9
11
|
this.onEvent.emit(name, params);
|
|
10
12
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ContextManager, Context } from '../context';
|
|
2
|
+
/** @zcontext */
|
|
2
3
|
export declare class TextAlertContext extends Context {
|
|
3
4
|
private _container;
|
|
4
5
|
constructor(contextManager: ContextManager);
|
|
6
|
+
/** @zprop */
|
|
5
7
|
showTextAlert(txt: string, options?: TextAlertOptions): void;
|
|
6
8
|
}
|
|
7
9
|
export interface TextAlertOptions {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context } from '../context';
|
|
2
2
|
import { useOverlay } from './canvascontext';
|
|
3
|
+
/** @zcontext */
|
|
3
4
|
export class TextAlertContext extends Context {
|
|
4
5
|
constructor(contextManager) {
|
|
5
6
|
super(contextManager, {});
|
|
@@ -9,6 +10,7 @@ export class TextAlertContext extends Context {
|
|
|
9
10
|
val.appendChild(this._container);
|
|
10
11
|
});
|
|
11
12
|
}
|
|
13
|
+
/** @zprop */
|
|
12
14
|
showTextAlert(txt, options) {
|
|
13
15
|
const entry = document.createElement('div');
|
|
14
16
|
entry.classList.add('zcomponent-textalert');
|
package/lib/data/core.d.ts
CHANGED
|
@@ -97,3 +97,32 @@ export interface ContextValueEntityPropOverride extends BaseEntityPropOverride {
|
|
|
97
97
|
val: string;
|
|
98
98
|
type: EntityPropOverrideType.ContextValue;
|
|
99
99
|
}
|
|
100
|
+
export declare enum FunctionCallType {
|
|
101
|
+
Entity = "entity",
|
|
102
|
+
Context = "context",
|
|
103
|
+
Import = "import"
|
|
104
|
+
}
|
|
105
|
+
export interface BaseFunctionCall {
|
|
106
|
+
_zfn: true;
|
|
107
|
+
t: FunctionCallType;
|
|
108
|
+
args: {
|
|
109
|
+
[id: number]: any;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface EntityFunctionCall extends BaseFunctionCall {
|
|
113
|
+
entityID: string;
|
|
114
|
+
t: FunctionCallType.Entity;
|
|
115
|
+
fn: string;
|
|
116
|
+
}
|
|
117
|
+
export interface ContextFunctionCall extends BaseFunctionCall {
|
|
118
|
+
imp: string;
|
|
119
|
+
fn: string;
|
|
120
|
+
t: FunctionCallType.Context;
|
|
121
|
+
resolved?: any;
|
|
122
|
+
}
|
|
123
|
+
export interface ImportFunctionCall extends BaseFunctionCall {
|
|
124
|
+
imp: string;
|
|
125
|
+
t: FunctionCallType.Import;
|
|
126
|
+
resolved?: any;
|
|
127
|
+
}
|
|
128
|
+
export type FunctionCall = EntityFunctionCall | ContextFunctionCall | ImportFunctionCall;
|
package/lib/data/core.js
CHANGED
|
@@ -4,3 +4,9 @@ export var EntityPropOverrideType;
|
|
|
4
4
|
EntityPropOverrideType["Import"] = "import";
|
|
5
5
|
EntityPropOverrideType["ContextValue"] = "contextvalue";
|
|
6
6
|
})(EntityPropOverrideType || (EntityPropOverrideType = {}));
|
|
7
|
+
export var FunctionCallType;
|
|
8
|
+
(function (FunctionCallType) {
|
|
9
|
+
FunctionCallType["Entity"] = "entity";
|
|
10
|
+
FunctionCallType["Context"] = "context";
|
|
11
|
+
FunctionCallType["Import"] = "import";
|
|
12
|
+
})(FunctionCallType || (FunctionCallType = {}));
|
package/lib/selectors.js
CHANGED
|
@@ -186,6 +186,35 @@ export function summaryForEntityPropOverrideDestination(o) {
|
|
|
186
186
|
}
|
|
187
187
|
return '?';
|
|
188
188
|
}
|
|
189
|
+
function typeContainsType(p, name) {
|
|
190
|
+
if (p.name === name)
|
|
191
|
+
return true;
|
|
192
|
+
switch (p.name) {
|
|
193
|
+
case 'array':
|
|
194
|
+
return typeContainsType(p.child, name);
|
|
195
|
+
case 'function':
|
|
196
|
+
for (const arg of p.args) {
|
|
197
|
+
if (typeContainsType(arg.type, name))
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (p.ret)
|
|
201
|
+
return typeContainsType(p.ret, name);
|
|
202
|
+
return false;
|
|
203
|
+
case 'tuple':
|
|
204
|
+
for (const c of p.children) {
|
|
205
|
+
if (typeContainsType(c, name))
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
case 'union':
|
|
210
|
+
for (const c of p.children) {
|
|
211
|
+
if (typeContainsType(c, name))
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
189
218
|
export const typeDefinitionForComponent = (nodes, props, constructorProps, scriptNames, layers, behaviors) => {
|
|
190
219
|
const importMapping = new Map();
|
|
191
220
|
let indx = 0;
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityPropOverrideType } from './data/core';
|
|
1
|
+
import { EntityPropOverrideType, FunctionCallType } from './data/core';
|
|
2
2
|
import { getSafeKeyName } from './selectors';
|
|
3
3
|
export var TypeName;
|
|
4
4
|
(function (TypeName) {
|
|
@@ -138,6 +138,8 @@ export function mergeValues(a, b) {
|
|
|
138
138
|
export function mergeProps(a, b) {
|
|
139
139
|
if (a.name !== b.name)
|
|
140
140
|
return;
|
|
141
|
+
if ((a.readonly && !b.readonly) || (b.readonly && !a.readonly))
|
|
142
|
+
return;
|
|
141
143
|
const type = mergeTypes(a.type, b.type);
|
|
142
144
|
if (!type)
|
|
143
145
|
return;
|
|
@@ -154,6 +156,7 @@ export function mergeProps(a, b) {
|
|
|
154
156
|
priority: Math.max(a.priority ?? 0, b.priority ?? 0),
|
|
155
157
|
values: mergeValues(a.values, b.values),
|
|
156
158
|
order: Math.min(a.order ?? 0, b.order ?? 0),
|
|
159
|
+
readonly: a.readonly,
|
|
157
160
|
};
|
|
158
161
|
}
|
|
159
162
|
function mergeComments(a, b) {
|
|
@@ -328,6 +331,31 @@ export function isValidValueForType(def, t, allowUndefined) {
|
|
|
328
331
|
return true;
|
|
329
332
|
return def === t.value;
|
|
330
333
|
case 'function':
|
|
334
|
+
if (typeof def !== 'object')
|
|
335
|
+
return false;
|
|
336
|
+
if (def['_zfn'] !== true)
|
|
337
|
+
return false;
|
|
338
|
+
if (typeof def['args'] !== 'object')
|
|
339
|
+
return false;
|
|
340
|
+
if (def['t'] === FunctionCallType.Context) {
|
|
341
|
+
if (typeof def['imp'] !== 'string' || def['imp'].length === 0)
|
|
342
|
+
return false;
|
|
343
|
+
if (typeof def['fn'] !== 'string' || def['fn'].length === 0)
|
|
344
|
+
return false;
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
if (def['t'] === FunctionCallType.Entity) {
|
|
348
|
+
if (typeof def['entityID'] !== 'string' || def['entityID'].length === 0)
|
|
349
|
+
return false;
|
|
350
|
+
if (typeof def['fn'] !== 'string' || def['fn'].length === 0)
|
|
351
|
+
return false;
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
if (def['t'] === FunctionCallType.Import) {
|
|
355
|
+
if (typeof def['imp'] !== 'string' || def['imp'].length === 0)
|
|
356
|
+
return false;
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
331
359
|
return false;
|
|
332
360
|
}
|
|
333
361
|
return false;
|
package/lib/zcomponent.d.ts
CHANGED
|
@@ -59,8 +59,10 @@ export declare class ZComponent<RootType = any> extends Component<RootType> {
|
|
|
59
59
|
private _constructorForNode;
|
|
60
60
|
private _constructorForBehavior;
|
|
61
61
|
resolveNodeID<T extends Component = Component>(id: string, type?: ConstructorForComponent<T>): T | undefined;
|
|
62
|
+
resolveEntityID<T extends Entity = Entity>(id: string): T | undefined;
|
|
62
63
|
private _inflateBehaviors;
|
|
63
64
|
private _wrapBehaviors;
|
|
65
|
+
private _wrapFunctionCall;
|
|
64
66
|
notifyPropsChanged(entries: Map<string, Set<string>>): void;
|
|
65
67
|
notifyClipsChanged(clips: Set<string>): void;
|
|
66
68
|
private _initializeOverrides;
|
package/lib/zcomponent.js
CHANGED
|
@@ -7,8 +7,9 @@ import { isDesignTime } from './contexts/environmentcontext';
|
|
|
7
7
|
import { isStarted, started } from './contexts/loadcontext';
|
|
8
8
|
import { TagContext } from './contexts/tagcontext';
|
|
9
9
|
import { computeBehaviorHierarchy, computeNodeHierarchy } from './data';
|
|
10
|
+
import { Entity } from './entity';
|
|
10
11
|
import { populateAnimationStructureFromData, populateAnimationTracksFromData, updateClipFromData } from './inflate';
|
|
11
|
-
import { EntityPropOverrideType } from './data/core';
|
|
12
|
+
import { EntityPropOverrideType, FunctionCallType } from './data/core';
|
|
12
13
|
import { Observable } from './observable';
|
|
13
14
|
import { setCurrentZComponentConstruction } from './zcomponentconstruction';
|
|
14
15
|
export class ZComponentContext extends Context {
|
|
@@ -188,6 +189,11 @@ export class ZComponent extends Component {
|
|
|
188
189
|
...(that._opts.constructorPropReplacement?.[behaviorId] ?? {}),
|
|
189
190
|
...(that._constructorPropOverridesByEntityID.get(behaviorId) ?? {}),
|
|
190
191
|
};
|
|
192
|
+
for (const key in constructorProps) {
|
|
193
|
+
const val = constructorProps[key];
|
|
194
|
+
if (val !== undefined && val !== null && val['_zfn'] === true)
|
|
195
|
+
constructorProps[key] = that._wrapFunctionCall(val);
|
|
196
|
+
}
|
|
191
197
|
setCurrentZComponentConstruction(that);
|
|
192
198
|
super(contextManager, instance, constructorProps);
|
|
193
199
|
that.entityByID.set(behaviorId, this);
|
|
@@ -227,6 +233,14 @@ export class ZComponent extends Component {
|
|
|
227
233
|
return entity;
|
|
228
234
|
return undefined;
|
|
229
235
|
}
|
|
236
|
+
resolveEntityID(id) {
|
|
237
|
+
const entity = this.entityByID.get(id);
|
|
238
|
+
if (!entity)
|
|
239
|
+
return this.getZComponentInstance()?.resolveEntityID(id);
|
|
240
|
+
if (!(entity instanceof Entity))
|
|
241
|
+
return undefined;
|
|
242
|
+
return entity;
|
|
243
|
+
}
|
|
230
244
|
_inflateBehaviors() {
|
|
231
245
|
for (const [nodeID, impl, ctx] of this._behaviorsToInitialize) {
|
|
232
246
|
this._wrapBehaviors(nodeID, impl, ctx);
|
|
@@ -248,6 +262,55 @@ export class ZComponent extends Component {
|
|
|
248
262
|
}
|
|
249
263
|
}
|
|
250
264
|
}
|
|
265
|
+
_wrapFunctionCall(c) {
|
|
266
|
+
switch (c.t) {
|
|
267
|
+
case FunctionCallType.Context:
|
|
268
|
+
return () => {
|
|
269
|
+
try {
|
|
270
|
+
if (typeof c.imp !== 'string' || typeof c.fn !== 'string' || typeof c.args !== 'object')
|
|
271
|
+
throw new Error('Invalid function call data');
|
|
272
|
+
const contextConstructor = c.resolved;
|
|
273
|
+
if (!contextConstructor)
|
|
274
|
+
throw new Error('Unable to find context');
|
|
275
|
+
const context = this.contextManager.get(contextConstructor);
|
|
276
|
+
if (!context)
|
|
277
|
+
throw new Error('Unable to get context');
|
|
278
|
+
const func = context[c.fn];
|
|
279
|
+
if (!func || typeof func !== 'function')
|
|
280
|
+
throw new Error('Unable to find function on enttiy');
|
|
281
|
+
const tf = func;
|
|
282
|
+
const converted = [];
|
|
283
|
+
for (const key in c.args)
|
|
284
|
+
converted[key] = c.args[key];
|
|
285
|
+
return tf.call(context, ...converted);
|
|
286
|
+
}
|
|
287
|
+
catch (err) {
|
|
288
|
+
console.error('Unable to call context function', err);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
case FunctionCallType.Entity:
|
|
292
|
+
return () => {
|
|
293
|
+
try {
|
|
294
|
+
if (typeof c.entityID !== 'string' || typeof c.fn !== 'string' || typeof c.args !== 'object')
|
|
295
|
+
throw new Error('Invalid function call data');
|
|
296
|
+
const entity = this.resolveEntityID(c.entityID);
|
|
297
|
+
if (!entity)
|
|
298
|
+
throw new Error('Unable to find entity');
|
|
299
|
+
const func = entity[c.fn];
|
|
300
|
+
if (!func || typeof func !== 'function')
|
|
301
|
+
throw new Error('Unable to find function on enttiy');
|
|
302
|
+
const tf = func;
|
|
303
|
+
const converted = [];
|
|
304
|
+
for (const key in c.args)
|
|
305
|
+
converted[key] = c.args[key];
|
|
306
|
+
return tf.call(entity, ...converted);
|
|
307
|
+
}
|
|
308
|
+
catch (err) {
|
|
309
|
+
console.error('Unable to call entity function', err);
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|
|
251
314
|
notifyPropsChanged(entries) {
|
|
252
315
|
for (const [entityID, propSet] of entries.entries()) {
|
|
253
316
|
const entity = this.entityByID.get(entityID);
|
|
@@ -354,6 +417,8 @@ export class ZComponent extends Component {
|
|
|
354
417
|
}
|
|
355
418
|
}
|
|
356
419
|
_setEntityProp(entity, prop, v) {
|
|
420
|
+
if (v !== undefined && v !== null && v['_zfn'] === true)
|
|
421
|
+
v = this._wrapFunctionCall(v);
|
|
357
422
|
if (entity[prop] instanceof Observable)
|
|
358
423
|
entity[prop].value = v;
|
|
359
424
|
else
|
|
@@ -373,6 +438,8 @@ export class ZComponent extends Component {
|
|
|
373
438
|
parent = parent[currentKey];
|
|
374
439
|
currentKey = propPath[i];
|
|
375
440
|
}
|
|
441
|
+
if (v !== undefined && v !== null && v['_zfn'] === true)
|
|
442
|
+
v = this._wrapFunctionCall(v);
|
|
376
443
|
parent[currentKey] = v;
|
|
377
444
|
}
|
|
378
445
|
_getNodeById(id) {
|