@zcomponent/core 1.29.0 → 2.0.0-alpha.2
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 +1 -0
- package/css/zcomponent.css +121 -122
- package/index.js +0 -3
- package/lib/actionbehavior.d.ts +3 -3
- package/lib/actionbehavior.js +20 -19
- package/lib/animation/animation.d.ts +13 -6
- package/lib/animation/animation.js +56 -43
- package/lib/animation/bezier.d.ts +6 -0
- package/lib/animation/bezier.js +8 -2
- package/lib/animation/clips/clip.d.ts +13 -1
- package/lib/animation/clips/clip.js +34 -14
- package/lib/animation/index.d.ts +4 -4
- package/lib/animation/index.js +4 -4
- package/lib/animation/layer.d.ts +9 -0
- package/lib/animation/layer.js +28 -12
- package/lib/animation/layerclip.d.ts +21 -0
- package/lib/animation/layerclip.js +82 -45
- package/lib/animation/tracks/cliptrack.d.ts +18 -0
- package/lib/animation/tracks/cliptrack.js +27 -6
- package/lib/animation/tracks/functiontrack.d.ts +9 -0
- package/lib/animation/tracks/functiontrack.js +16 -3
- package/lib/animation/tracks/propertytrack.d.ts +20 -1
- package/lib/animation/tracks/propertytrack.js +48 -11
- package/lib/animation/tracks/streamtrack.d.ts +18 -0
- package/lib/animation/tracks/streamtrack.js +32 -6
- package/lib/animation/tracks/track.d.ts +8 -2
- package/lib/animation/tracks/track.js +3 -2
- package/lib/behavior.js +13 -10
- package/lib/behaviors/ActivateState.d.ts +22 -24
- package/lib/behaviors/ActivateState.js +145 -35
- package/lib/behaviors/CallFunction.d.ts +2 -4
- package/lib/behaviors/CallFunction.js +69 -11
- package/lib/behaviors/ChangeRootScene.d.ts +35 -0
- package/lib/behaviors/ChangeRootScene.js +123 -0
- package/lib/behaviors/ConsoleLog.d.ts +6 -5
- package/lib/behaviors/ConsoleLog.js +95 -12
- package/lib/behaviors/DownloadSnapshot.d.ts +7 -12
- package/lib/behaviors/DownloadSnapshot.js +70 -19
- package/lib/behaviors/EmitComponentPropEvent.d.ts +1 -3
- package/lib/behaviors/EmitComponentPropEvent.js +80 -12
- package/lib/behaviors/LaunchURL.d.ts +5 -5
- package/lib/behaviors/LaunchURL.js +92 -10
- package/lib/behaviors/LogAnalyticsEvent.d.ts +10 -4
- package/lib/behaviors/LogAnalyticsEvent.js +88 -7
- package/lib/behaviors/PauseLayerClip.d.ts +7 -9
- package/lib/behaviors/PauseLayerClip.js +89 -21
- package/lib/behaviors/PlayLayerClip.d.ts +35 -32
- package/lib/behaviors/PlayLayerClip.js +202 -48
- package/lib/behaviors/PlaySound.d.ts +19 -25
- package/lib/behaviors/PlaySound.js +122 -28
- package/lib/behaviors/SetLayerOff.d.ts +7 -9
- package/lib/behaviors/SetLayerOff.js +88 -21
- package/lib/behaviors/ShareSnapshot.d.ts +5 -9
- package/lib/behaviors/ShareSnapshot.js +70 -17
- package/lib/behaviors/ShowTextAlert.d.ts +16 -29
- package/lib/behaviors/ShowTextAlert.js +116 -48
- package/lib/behaviors/TakeSnapshot.d.ts +22 -26
- package/lib/behaviors/TakeSnapshot.js +131 -56
- package/lib/behaviors/ToggleLayerClips.d.ts +45 -62
- package/lib/behaviors/ToggleLayerClips.js +233 -64
- package/lib/behaviors/stream/PauseStream.d.ts +5 -16
- package/lib/behaviors/stream/PauseStream.js +94 -34
- package/lib/behaviors/stream/PlayStream.d.ts +14 -27
- package/lib/behaviors/stream/PlayStream.js +123 -34
- package/lib/behaviors/stream/SeekStream.d.ts +8 -18
- package/lib/behaviors/stream/SeekStream.js +97 -31
- package/lib/behaviors/stream/StopStream.d.ts +6 -15
- package/lib/behaviors/stream/StopStream.js +89 -27
- package/lib/component.d.ts +36 -13
- package/lib/component.js +237 -151
- package/lib/components/AnimatedLoader.d.ts +51 -0
- package/lib/components/AnimatedLoader.js +159 -0
- package/lib/components/Audio.d.ts +35 -37
- package/lib/components/Audio.js +264 -151
- package/lib/components/AudioLayerSettings.d.ts +13 -11
- package/lib/components/AudioLayerSettings.js +76 -18
- package/lib/components/Children.d.ts +2 -1
- package/lib/components/Children.js +66 -13
- package/lib/components/ConditionalConstruct.d.ts +44 -0
- package/lib/components/ConditionalConstruct.js +142 -0
- package/lib/components/DefaultCookieConsent.d.ts +53 -73
- package/lib/components/DefaultCookieConsent.js +382 -264
- package/lib/components/DefaultLoader.d.ts +40 -28
- package/lib/components/DefaultLoader.js +198 -46
- package/lib/components/Gamepad.d.ts +5 -26
- package/lib/components/Gamepad.js +201 -65
- package/lib/components/LoaderScope.d.ts +15 -0
- package/lib/components/LoaderScope.js +71 -0
- package/lib/components/LongLoad.d.ts +11 -15
- package/lib/components/LongLoad.js +89 -34
- package/lib/components/SnapshotUI.d.ts +19 -24
- package/lib/components/SnapshotUI.js +202 -105
- package/lib/context.d.ts +23 -5
- package/lib/context.js +12 -6
- package/lib/contexts/analyticscontext.d.ts +12 -2
- package/lib/contexts/analyticscontext.js +68 -10
- package/lib/contexts/audiocontextcontext.d.ts +1 -1
- package/lib/contexts/audiocontextcontext.js +9 -8
- package/lib/contexts/canvascontext.d.ts +32 -18
- package/lib/contexts/canvascontext.js +195 -120
- package/lib/contexts/cookieconsentcontext.d.ts +38 -28
- package/lib/contexts/cookieconsentcontext.js +35 -32
- package/lib/contexts/documentflagmanager.js +15 -11
- package/lib/contexts/environmentcontext.d.ts +22 -6
- package/lib/contexts/environmentcontext.js +135 -21
- package/lib/contexts/gamepadcontext.d.ts +29 -26
- package/lib/contexts/gamepadcontext.js +46 -46
- package/lib/contexts/gesturecontext.d.ts +31 -6
- package/lib/contexts/gesturecontext.js +110 -85
- package/lib/contexts/globaltagcontext.d.ts +1 -1
- package/lib/contexts/globaltagcontext.js +8 -11
- package/lib/contexts/loadcontext.d.ts +45 -8
- package/lib/contexts/loadcontext.js +232 -82
- package/lib/contexts/orientationcontext.d.ts +13 -15
- package/lib/contexts/orientationcontext.js +150 -67
- package/lib/contexts/rootcomponentscontext.d.ts +16 -0
- package/lib/contexts/rootcomponentscontext.js +65 -0
- package/lib/contexts/snapshotContext.d.ts +0 -3
- package/lib/contexts/snapshotContext.js +78 -23
- package/lib/contexts/tagcontext.d.ts +5 -5
- package/lib/contexts/tagcontext.js +16 -16
- package/lib/contexts/textalertcontext.d.ts +1 -5
- package/lib/contexts/textalertcontext.js +1 -5
- package/lib/contexts/usereventcontext.d.ts +1 -1
- package/lib/contexts/usereventcontext.js +12 -12
- package/lib/data/animation.d.ts +10 -2
- package/lib/data/change.d.ts +1 -1
- package/lib/data/change.js +7 -0
- package/lib/data/core.d.ts +9 -1
- package/lib/data/index.d.ts +1 -1
- package/lib/data/index.js +1 -1
- package/lib/decorators.d.ts +348 -0
- package/lib/decorators.js +239 -0
- package/lib/decoratorutils.d.ts +3 -0
- package/lib/decoratorutils.js +8 -0
- package/lib/emitter.d.ts +15 -2
- package/lib/emitter.js +15 -6
- package/lib/entity.d.ts +43 -25
- package/lib/entity.js +104 -71
- package/lib/event.d.ts +2 -1
- package/lib/event.js +1 -4
- package/lib/groups.d.ts +18 -0
- package/lib/groups.js +19 -0
- package/lib/icons.d.ts +3372 -0
- package/lib/icons.js +1 -0
- package/lib/index.d.ts +18 -13
- package/lib/index.js +17 -13
- package/lib/inflate.d.ts +7 -7
- package/lib/inflate.js +5 -5
- package/lib/observable.d.ts +9 -2
- package/lib/observable.js +5 -4
- package/lib/observe.d.ts +18 -0
- package/lib/observe.js +177 -0
- package/lib/profile.d.ts +9 -5
- package/lib/profile.js +27 -17
- package/lib/selectors.d.ts +1 -1
- package/lib/selectors.js +5 -4
- package/lib/types.d.ts +161 -19
- package/lib/types.js +22 -1
- package/lib/values/values.d.ts +7 -8
- package/lib/values/values.js +1 -2
- package/lib/values/valuesmutator.d.ts +4 -1
- package/lib/values/valuesmutator.js +10 -8
- package/lib/zcomponent.d.ts +21 -10
- package/lib/zcomponent.js +717 -540
- package/package.json +22 -5
- package/lib/behaviors/ChangeCursor.d.ts +0 -39
- package/lib/behaviors/ChangeCursor.js +0 -44
|
@@ -1,4 +1,40 @@
|
|
|
1
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
2
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
3
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
4
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
5
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
6
|
+
var _, done = false;
|
|
7
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
8
|
+
var context = {};
|
|
9
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
10
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
11
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
12
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
13
|
+
if (kind === "accessor") {
|
|
14
|
+
if (result === void 0) continue;
|
|
15
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
16
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
17
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
18
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
19
|
+
}
|
|
20
|
+
else if (_ = accept(result)) {
|
|
21
|
+
if (kind === "field") initializers.unshift(_);
|
|
22
|
+
else descriptor[key] = _;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
26
|
+
done = true;
|
|
27
|
+
};
|
|
28
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
29
|
+
var useValue = arguments.length > 2;
|
|
30
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
31
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
32
|
+
}
|
|
33
|
+
return useValue ? value : void 0;
|
|
34
|
+
};
|
|
1
35
|
import { Context } from '../context';
|
|
36
|
+
import { zUI } from '../decorators';
|
|
37
|
+
import { Entity } from '../entity';
|
|
2
38
|
import { Observable } from '../observable';
|
|
3
39
|
/**
|
|
4
40
|
* LoadContext exposes to components and behaviors key moments during the initialization of the experience,
|
|
@@ -27,113 +63,162 @@ import { Observable } from '../observable';
|
|
|
27
63
|
* on any 'launch' button.
|
|
28
64
|
*
|
|
29
65
|
* @zcontext */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
66
|
+
let LoadContext = (() => {
|
|
67
|
+
let _classSuper = Context;
|
|
68
|
+
let _isConstructed_decorators;
|
|
69
|
+
let _isConstructed_initializers = [];
|
|
70
|
+
let _isConstructed_extraInitializers = [];
|
|
71
|
+
let _isLoaded_decorators;
|
|
72
|
+
let _isLoaded_initializers = [];
|
|
73
|
+
let _isLoaded_extraInitializers = [];
|
|
74
|
+
let _isStarted_decorators;
|
|
75
|
+
let _isStarted_initializers = [];
|
|
76
|
+
let _isStarted_extraInitializers = [];
|
|
77
|
+
let _isLaunched_decorators;
|
|
78
|
+
let _isLaunched_initializers = [];
|
|
79
|
+
let _isLaunched_extraInitializers = [];
|
|
80
|
+
let _progressPercent_decorators;
|
|
81
|
+
let _progressPercent_initializers = [];
|
|
82
|
+
let _progressPercent_extraInitializers = [];
|
|
83
|
+
return class LoadContext extends _classSuper {
|
|
84
|
+
static {
|
|
85
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
86
|
+
_isConstructed_decorators = [zUI()];
|
|
87
|
+
_isLoaded_decorators = [zUI()];
|
|
88
|
+
_isStarted_decorators = [zUI()];
|
|
89
|
+
_isLaunched_decorators = [zUI()];
|
|
90
|
+
_progressPercent_decorators = [zUI()];
|
|
91
|
+
__esDecorate(null, null, _isConstructed_decorators, { kind: "field", name: "isConstructed", static: false, private: false, access: { has: obj => "isConstructed" in obj, get: obj => obj.isConstructed, set: (obj, value) => { obj.isConstructed = value; } }, metadata: _metadata }, _isConstructed_initializers, _isConstructed_extraInitializers);
|
|
92
|
+
__esDecorate(null, null, _isLoaded_decorators, { kind: "field", name: "isLoaded", static: false, private: false, access: { has: obj => "isLoaded" in obj, get: obj => obj.isLoaded, set: (obj, value) => { obj.isLoaded = value; } }, metadata: _metadata }, _isLoaded_initializers, _isLoaded_extraInitializers);
|
|
93
|
+
__esDecorate(null, null, _isStarted_decorators, { kind: "field", name: "isStarted", static: false, private: false, access: { has: obj => "isStarted" in obj, get: obj => obj.isStarted, set: (obj, value) => { obj.isStarted = value; } }, metadata: _metadata }, _isStarted_initializers, _isStarted_extraInitializers);
|
|
94
|
+
__esDecorate(null, null, _isLaunched_decorators, { kind: "field", name: "isLaunched", static: false, private: false, access: { has: obj => "isLaunched" in obj, get: obj => obj.isLaunched, set: (obj, value) => { obj.isLaunched = value; } }, metadata: _metadata }, _isLaunched_initializers, _isLaunched_extraInitializers);
|
|
95
|
+
__esDecorate(null, null, _progressPercent_decorators, { kind: "field", name: "progressPercent", static: false, private: false, access: { has: obj => "progressPercent" in obj, get: obj => obj.progressPercent, set: (obj, value) => { obj.progressPercent = value; } }, metadata: _metadata }, _progressPercent_initializers, _progressPercent_extraInitializers);
|
|
96
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
97
|
+
}
|
|
33
98
|
/**
|
|
34
99
|
* Observable indicating whether the root component's construction is complete.
|
|
35
100
|
* This is typically set to true immediately after the root component and its children are constructed.
|
|
36
|
-
* @zui
|
|
37
101
|
*/
|
|
38
|
-
|
|
102
|
+
isConstructed = __runInitializers(this, _isConstructed_initializers, new Observable(false));
|
|
39
103
|
/**
|
|
40
104
|
* Observable indicating whether all loadable processes have completed.
|
|
41
105
|
* This is true when all assets and dependencies required for the experience are fully loaded.
|
|
42
|
-
* @zui
|
|
43
106
|
*/
|
|
44
|
-
|
|
107
|
+
isLoaded = (__runInitializers(this, _isConstructed_extraInitializers), __runInitializers(this, _isLoaded_initializers, new Observable(false)));
|
|
45
108
|
/**
|
|
46
109
|
* Observable indicating whether the experience has started.
|
|
47
110
|
* This becomes true at the point where the experience transitions from loading to active interaction.
|
|
48
|
-
* @zui
|
|
49
111
|
*/
|
|
50
|
-
|
|
112
|
+
isStarted = (__runInitializers(this, _isLoaded_extraInitializers), __runInitializers(this, _isStarted_initializers, new Observable(false)));
|
|
51
113
|
/**
|
|
52
114
|
* Observable indicating whether the experience has been launched.
|
|
53
115
|
* This is set to true typically when the user interacts with a splash screen or an initial launch button.
|
|
54
|
-
* @zui
|
|
55
116
|
*/
|
|
56
|
-
|
|
117
|
+
isLaunched = (__runInitializers(this, _isStarted_extraInitializers), __runInitializers(this, _isLaunched_initializers, new Observable(false)));
|
|
57
118
|
/**
|
|
58
119
|
* Observable representing the progress percentage of loadable processes.
|
|
59
120
|
* This provides a numerical value representing the completion percentage of all loading operations.
|
|
60
|
-
* @zui
|
|
61
121
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this._launchedResolved();
|
|
97
|
-
}
|
|
98
|
-
_update() {
|
|
99
|
-
if (this._loadables.size > 0 && this.isLoaded.value === true) {
|
|
100
|
-
this.isLoaded.value = false;
|
|
101
|
-
this._totalLoadables = this._loadables.size;
|
|
102
|
-
this._loadedCount = 0;
|
|
122
|
+
progressPercent = (__runInitializers(this, _isLaunched_extraInitializers), __runInitializers(this, _progressPercent_initializers, new Observable(0)));
|
|
123
|
+
_startedResolved = __runInitializers(this, _progressPercent_extraInitializers);
|
|
124
|
+
started = new Promise(resolve => {
|
|
125
|
+
this._startedResolved = resolve;
|
|
126
|
+
});
|
|
127
|
+
_constructedResolved;
|
|
128
|
+
constructed = new Promise(resolve => {
|
|
129
|
+
this._constructedResolved = resolve;
|
|
130
|
+
});
|
|
131
|
+
_launchedResolved;
|
|
132
|
+
launched = new Promise(resolve => {
|
|
133
|
+
this._launchedResolved = resolve;
|
|
134
|
+
});
|
|
135
|
+
_loadables = new Set();
|
|
136
|
+
/**
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
_startWhenLoaded = false;
|
|
140
|
+
/**
|
|
141
|
+
* @default 0
|
|
142
|
+
*/
|
|
143
|
+
_totalLoadables = 0;
|
|
144
|
+
/**
|
|
145
|
+
* @default 0
|
|
146
|
+
*/
|
|
147
|
+
_loadedCount = 0;
|
|
148
|
+
/**
|
|
149
|
+
* Start the experience.
|
|
150
|
+
*/
|
|
151
|
+
start() {
|
|
152
|
+
if (this.isStarted.value)
|
|
153
|
+
return;
|
|
154
|
+
this.isStarted.value = true;
|
|
155
|
+
this._startedResolved?.();
|
|
103
156
|
}
|
|
104
|
-
|
|
105
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Called when the root component's constructor (and thus any recursive children) has finished.
|
|
159
|
+
*/
|
|
160
|
+
constructionComplete() {
|
|
161
|
+
if (this.isConstructed.value)
|
|
162
|
+
return;
|
|
163
|
+
this.isConstructed.value = true;
|
|
164
|
+
this._constructedResolved();
|
|
106
165
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Called when the user taps on a splash screen's 'launch' button or, in the case that there's no launch
|
|
168
|
+
*/
|
|
169
|
+
launch() {
|
|
170
|
+
if (this.isLaunched.value)
|
|
171
|
+
return;
|
|
172
|
+
this.isLaunched.value = true;
|
|
173
|
+
this._launchedResolved();
|
|
110
174
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
175
|
+
_update() {
|
|
176
|
+
if (this._loadables.size > 0 && this.isLoaded.value === true) {
|
|
177
|
+
this.isLoaded.value = false;
|
|
178
|
+
this._totalLoadables = this._loadables.size;
|
|
179
|
+
this._loadedCount = 0;
|
|
180
|
+
}
|
|
181
|
+
if (this._loadables.size === 0 && this.isLoaded.value === false) {
|
|
182
|
+
this.isLoaded.value = true;
|
|
183
|
+
}
|
|
184
|
+
this.progressPercent.value = this.isLoaded.value ? 100 : (100 * this._loadedCount) / this._totalLoadables;
|
|
185
|
+
if (this._startWhenLoaded && this.isLoaded.value && !this.isStarted.value) {
|
|
186
|
+
this.start();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Start the experience when all loadables have completed.
|
|
191
|
+
*/
|
|
192
|
+
startWhenLoaded() {
|
|
193
|
+
this._startWhenLoaded = true;
|
|
194
|
+
this._update();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Register a loadable process.
|
|
198
|
+
*/
|
|
199
|
+
registerLoadable(p, entity) {
|
|
128
200
|
if (this.disposed)
|
|
129
201
|
return;
|
|
130
|
-
this.
|
|
131
|
-
this.
|
|
202
|
+
this._loadables.add(p);
|
|
203
|
+
this._totalLoadables++;
|
|
204
|
+
let isComplete = false;
|
|
205
|
+
const complete = () => {
|
|
206
|
+
if (this.disposed)
|
|
207
|
+
return;
|
|
208
|
+
if (isComplete)
|
|
209
|
+
return;
|
|
210
|
+
isComplete = true;
|
|
211
|
+
this._loadedCount++;
|
|
212
|
+
this._loadables.delete(p);
|
|
213
|
+
this._update();
|
|
214
|
+
};
|
|
215
|
+
entity?.onDispose.addListener(complete);
|
|
216
|
+
p.finally(complete);
|
|
132
217
|
this._update();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
})();
|
|
221
|
+
export { LoadContext };
|
|
137
222
|
/**
|
|
138
223
|
* Returns an observable that indicates whether the experience is loaded.
|
|
139
224
|
*/
|
|
@@ -192,7 +277,7 @@ export function useLoadPercent(mgr) {
|
|
|
192
277
|
* Register a loadable process.
|
|
193
278
|
*/
|
|
194
279
|
export function registerLoadable(mgr, p) {
|
|
195
|
-
return mgr.get(LoadContext).registerLoadable(p);
|
|
280
|
+
return (mgr instanceof Entity ? mgr.contextManager : mgr).get(LoadContext).registerLoadable(p, mgr instanceof Entity ? mgr : undefined);
|
|
196
281
|
}
|
|
197
282
|
/**
|
|
198
283
|
* Starts the experience.
|
|
@@ -237,3 +322,68 @@ export function launched(mgr) {
|
|
|
237
322
|
export function constructionComplete(mgr) {
|
|
238
323
|
return mgr.get(LoadContext).constructionComplete();
|
|
239
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* A decorator that registers its decorated function as a loadable process, and
|
|
327
|
+
* (by default) invokes it automatically once the experience has finished constructing.
|
|
328
|
+
*
|
|
329
|
+
* The loader will wait for the returned promise to resolve before hiding itself.
|
|
330
|
+
* The loadable is registered synchronously during construction so that `isLoaded`
|
|
331
|
+
* reflects the pending work from the moment the entity exists; the actual method
|
|
332
|
+
* call is deferred until after the full construction tree settles, so any fields
|
|
333
|
+
* assigned in subclass constructor bodies are available when it runs.
|
|
334
|
+
*
|
|
335
|
+
* Mirrors the structure of {@link zOnConstructed}, {@link zOnStart}, and {@link zOnLaunch};
|
|
336
|
+
* the only difference is that `zLoad` also registers the deferred work as a loadable.
|
|
337
|
+
*
|
|
338
|
+
* @param autoInvoke - If true (default), the method fires automatically after construction.
|
|
339
|
+
* If false, the method must be called manually but will still register as a loadable.
|
|
340
|
+
*/
|
|
341
|
+
export function zLoad(autoInvoke = true) {
|
|
342
|
+
return (originalMethod, context) => {
|
|
343
|
+
if (autoInvoke) {
|
|
344
|
+
context.addInitializer(function () {
|
|
345
|
+
const deferred = constructed(this.contextManager).then(() => this[context.name].call(this));
|
|
346
|
+
registerLoadable(this.contextManager, deferred);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return function (...args) {
|
|
350
|
+
const promise = originalMethod.call(this, ...args);
|
|
351
|
+
if (promise instanceof Promise)
|
|
352
|
+
registerLoadable(this.contextManager, promise);
|
|
353
|
+
return promise;
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* A decorator that will automatically call its decorated function when the experience has been started.
|
|
359
|
+
*/
|
|
360
|
+
export function zOnStart() {
|
|
361
|
+
return (originalMethod, context) => {
|
|
362
|
+
context.addInitializer(function () {
|
|
363
|
+
started(this.contextManager).then((...args) => this[context.name].call(this, ...args));
|
|
364
|
+
});
|
|
365
|
+
return originalMethod;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A decorator that will automatically call its decorated function when the experience has been constructed.
|
|
370
|
+
*/
|
|
371
|
+
export function zOnConstructed() {
|
|
372
|
+
return (originalMethod, context) => {
|
|
373
|
+
context.addInitializer(function () {
|
|
374
|
+
constructed(this.contextManager).then((...args) => this[context.name].call(this, ...args));
|
|
375
|
+
});
|
|
376
|
+
return originalMethod;
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* A decorator that will automatically call its decorated function when the experience has been launched.
|
|
381
|
+
*/
|
|
382
|
+
export function zOnLaunch() {
|
|
383
|
+
return (originalMethod, context) => {
|
|
384
|
+
context.addInitializer(function () {
|
|
385
|
+
launched(this.contextManager).then((...args) => this[context.name].call(this, ...args));
|
|
386
|
+
});
|
|
387
|
+
return originalMethod;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, ContextManager } from '../context';
|
|
2
2
|
import { Event } from '../event';
|
|
3
3
|
import { Observable } from '../observable';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { ValueOf } from '../types';
|
|
5
|
+
export declare const Orientation: {
|
|
6
|
+
readonly Portrait: "portrait";
|
|
7
|
+
readonly Landscape: "landscape";
|
|
8
|
+
readonly PortraitSecondary: "portrait-secondary";
|
|
9
|
+
readonly LandscapeSecondary: "landscape-secondary";
|
|
10
|
+
};
|
|
11
|
+
export type OrientationValue = ValueOf<typeof Orientation>;
|
|
10
12
|
/**
|
|
11
13
|
* Manages and tracks orientation changes in the application context.
|
|
12
14
|
* @zcontext
|
|
@@ -14,28 +16,24 @@ export declare enum Orientation {
|
|
|
14
16
|
export declare class OrientationContext extends Context {
|
|
15
17
|
/**
|
|
16
18
|
* Observable indicating whether the current orientation is portrait.
|
|
17
|
-
* @zui
|
|
18
19
|
*/
|
|
19
20
|
readonly isPortrait: Observable<boolean>;
|
|
20
21
|
/**
|
|
21
22
|
* Observable indicating whether the current orientation is landscape.
|
|
22
|
-
* @zui
|
|
23
23
|
*/
|
|
24
24
|
readonly isLandscape: Observable<boolean>;
|
|
25
25
|
/**
|
|
26
26
|
* Observable indicating whether the current orientation is secondary portrait.
|
|
27
|
-
* @zui
|
|
28
27
|
*/
|
|
29
28
|
readonly isPortraitSecondary: Observable<boolean>;
|
|
30
29
|
/**
|
|
31
30
|
* Observable indicating whether the current orientation is secondary landscape.
|
|
32
|
-
* @zui
|
|
33
31
|
*/
|
|
34
32
|
readonly isLandscapeSecondary: Observable<boolean>;
|
|
35
33
|
/**
|
|
36
34
|
* Observable representing the current orientation.
|
|
37
35
|
*/
|
|
38
|
-
readonly orientation: Observable<
|
|
36
|
+
readonly orientation: Observable<OrientationValue>;
|
|
39
37
|
/**
|
|
40
38
|
* Event triggered when the orientation changes to portrait.
|
|
41
39
|
*/
|
|
@@ -55,7 +53,7 @@ export declare class OrientationContext extends Context {
|
|
|
55
53
|
/**
|
|
56
54
|
* Event triggered when there is any orientation change.
|
|
57
55
|
*/
|
|
58
|
-
readonly onOrientationChange: Event<[
|
|
56
|
+
readonly onOrientationChange: Event<[OrientationValue]>;
|
|
59
57
|
/**
|
|
60
58
|
* Creates an instance of OrientationContext.
|
|
61
59
|
* @param contextManager - The current ContextManager
|
|
@@ -75,13 +73,13 @@ export declare class OrientationContext extends Context {
|
|
|
75
73
|
* @param mgr The ContextManager instance to access the OrientationContext.
|
|
76
74
|
* @returns Observable for orientation change events.
|
|
77
75
|
*/
|
|
78
|
-
export declare function useOnOrientationChange(mgr: ContextManager): Event<[
|
|
76
|
+
export declare function useOnOrientationChange(mgr: ContextManager): Event<[OrientationValue]>;
|
|
79
77
|
/**
|
|
80
78
|
* Retrieves the current orientation value.
|
|
81
79
|
* @param mgr The ContextManager instance to access the OrientationContext.
|
|
82
80
|
* @returns The current orientation as an Orientation enum value.
|
|
83
81
|
*/
|
|
84
|
-
export declare function getOrientation(mgr: ContextManager):
|
|
82
|
+
export declare function getOrientation(mgr: ContextManager): OrientationValue;
|
|
85
83
|
/**
|
|
86
84
|
* Determines if the current orientation is portrait.
|
|
87
85
|
* @param mgr The ContextManager instance to access the OrientationContext.
|