@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.
Files changed (168) hide show
  1. package/README.md +1 -0
  2. package/css/zcomponent.css +121 -122
  3. package/index.js +0 -3
  4. package/lib/actionbehavior.d.ts +3 -3
  5. package/lib/actionbehavior.js +20 -19
  6. package/lib/animation/animation.d.ts +13 -6
  7. package/lib/animation/animation.js +56 -43
  8. package/lib/animation/bezier.d.ts +6 -0
  9. package/lib/animation/bezier.js +8 -2
  10. package/lib/animation/clips/clip.d.ts +13 -1
  11. package/lib/animation/clips/clip.js +34 -14
  12. package/lib/animation/index.d.ts +4 -4
  13. package/lib/animation/index.js +4 -4
  14. package/lib/animation/layer.d.ts +9 -0
  15. package/lib/animation/layer.js +28 -12
  16. package/lib/animation/layerclip.d.ts +21 -0
  17. package/lib/animation/layerclip.js +82 -45
  18. package/lib/animation/tracks/cliptrack.d.ts +18 -0
  19. package/lib/animation/tracks/cliptrack.js +27 -6
  20. package/lib/animation/tracks/functiontrack.d.ts +9 -0
  21. package/lib/animation/tracks/functiontrack.js +16 -3
  22. package/lib/animation/tracks/propertytrack.d.ts +20 -1
  23. package/lib/animation/tracks/propertytrack.js +48 -11
  24. package/lib/animation/tracks/streamtrack.d.ts +18 -0
  25. package/lib/animation/tracks/streamtrack.js +32 -6
  26. package/lib/animation/tracks/track.d.ts +8 -2
  27. package/lib/animation/tracks/track.js +3 -2
  28. package/lib/behavior.js +13 -10
  29. package/lib/behaviors/ActivateState.d.ts +22 -24
  30. package/lib/behaviors/ActivateState.js +145 -35
  31. package/lib/behaviors/CallFunction.d.ts +2 -4
  32. package/lib/behaviors/CallFunction.js +69 -11
  33. package/lib/behaviors/ChangeRootScene.d.ts +35 -0
  34. package/lib/behaviors/ChangeRootScene.js +123 -0
  35. package/lib/behaviors/ConsoleLog.d.ts +6 -5
  36. package/lib/behaviors/ConsoleLog.js +95 -12
  37. package/lib/behaviors/DownloadSnapshot.d.ts +7 -12
  38. package/lib/behaviors/DownloadSnapshot.js +70 -19
  39. package/lib/behaviors/EmitComponentPropEvent.d.ts +1 -3
  40. package/lib/behaviors/EmitComponentPropEvent.js +80 -12
  41. package/lib/behaviors/LaunchURL.d.ts +5 -5
  42. package/lib/behaviors/LaunchURL.js +92 -10
  43. package/lib/behaviors/LogAnalyticsEvent.d.ts +10 -4
  44. package/lib/behaviors/LogAnalyticsEvent.js +88 -7
  45. package/lib/behaviors/PauseLayerClip.d.ts +7 -9
  46. package/lib/behaviors/PauseLayerClip.js +89 -21
  47. package/lib/behaviors/PlayLayerClip.d.ts +35 -32
  48. package/lib/behaviors/PlayLayerClip.js +202 -48
  49. package/lib/behaviors/PlaySound.d.ts +19 -25
  50. package/lib/behaviors/PlaySound.js +122 -28
  51. package/lib/behaviors/SetLayerOff.d.ts +7 -9
  52. package/lib/behaviors/SetLayerOff.js +88 -21
  53. package/lib/behaviors/ShareSnapshot.d.ts +5 -9
  54. package/lib/behaviors/ShareSnapshot.js +70 -17
  55. package/lib/behaviors/ShowTextAlert.d.ts +16 -29
  56. package/lib/behaviors/ShowTextAlert.js +116 -48
  57. package/lib/behaviors/TakeSnapshot.d.ts +22 -26
  58. package/lib/behaviors/TakeSnapshot.js +131 -56
  59. package/lib/behaviors/ToggleLayerClips.d.ts +45 -62
  60. package/lib/behaviors/ToggleLayerClips.js +233 -64
  61. package/lib/behaviors/stream/PauseStream.d.ts +5 -16
  62. package/lib/behaviors/stream/PauseStream.js +94 -34
  63. package/lib/behaviors/stream/PlayStream.d.ts +14 -27
  64. package/lib/behaviors/stream/PlayStream.js +123 -34
  65. package/lib/behaviors/stream/SeekStream.d.ts +8 -18
  66. package/lib/behaviors/stream/SeekStream.js +97 -31
  67. package/lib/behaviors/stream/StopStream.d.ts +6 -15
  68. package/lib/behaviors/stream/StopStream.js +89 -27
  69. package/lib/component.d.ts +36 -13
  70. package/lib/component.js +237 -151
  71. package/lib/components/AnimatedLoader.d.ts +51 -0
  72. package/lib/components/AnimatedLoader.js +159 -0
  73. package/lib/components/Audio.d.ts +35 -37
  74. package/lib/components/Audio.js +264 -151
  75. package/lib/components/AudioLayerSettings.d.ts +13 -11
  76. package/lib/components/AudioLayerSettings.js +76 -18
  77. package/lib/components/Children.d.ts +2 -1
  78. package/lib/components/Children.js +66 -13
  79. package/lib/components/ConditionalConstruct.d.ts +44 -0
  80. package/lib/components/ConditionalConstruct.js +142 -0
  81. package/lib/components/DefaultCookieConsent.d.ts +53 -73
  82. package/lib/components/DefaultCookieConsent.js +382 -264
  83. package/lib/components/DefaultLoader.d.ts +40 -28
  84. package/lib/components/DefaultLoader.js +198 -46
  85. package/lib/components/Gamepad.d.ts +5 -26
  86. package/lib/components/Gamepad.js +201 -65
  87. package/lib/components/LoaderScope.d.ts +15 -0
  88. package/lib/components/LoaderScope.js +71 -0
  89. package/lib/components/LongLoad.d.ts +11 -15
  90. package/lib/components/LongLoad.js +89 -34
  91. package/lib/components/SnapshotUI.d.ts +19 -24
  92. package/lib/components/SnapshotUI.js +202 -105
  93. package/lib/context.d.ts +23 -5
  94. package/lib/context.js +12 -6
  95. package/lib/contexts/analyticscontext.d.ts +12 -2
  96. package/lib/contexts/analyticscontext.js +68 -10
  97. package/lib/contexts/audiocontextcontext.d.ts +1 -1
  98. package/lib/contexts/audiocontextcontext.js +9 -8
  99. package/lib/contexts/canvascontext.d.ts +32 -18
  100. package/lib/contexts/canvascontext.js +195 -120
  101. package/lib/contexts/cookieconsentcontext.d.ts +38 -28
  102. package/lib/contexts/cookieconsentcontext.js +35 -32
  103. package/lib/contexts/documentflagmanager.js +15 -11
  104. package/lib/contexts/environmentcontext.d.ts +22 -6
  105. package/lib/contexts/environmentcontext.js +135 -21
  106. package/lib/contexts/gamepadcontext.d.ts +29 -26
  107. package/lib/contexts/gamepadcontext.js +46 -46
  108. package/lib/contexts/gesturecontext.d.ts +31 -6
  109. package/lib/contexts/gesturecontext.js +110 -85
  110. package/lib/contexts/globaltagcontext.d.ts +1 -1
  111. package/lib/contexts/globaltagcontext.js +8 -11
  112. package/lib/contexts/loadcontext.d.ts +45 -8
  113. package/lib/contexts/loadcontext.js +232 -82
  114. package/lib/contexts/orientationcontext.d.ts +13 -15
  115. package/lib/contexts/orientationcontext.js +150 -67
  116. package/lib/contexts/rootcomponentscontext.d.ts +16 -0
  117. package/lib/contexts/rootcomponentscontext.js +65 -0
  118. package/lib/contexts/snapshotContext.d.ts +0 -3
  119. package/lib/contexts/snapshotContext.js +78 -23
  120. package/lib/contexts/tagcontext.d.ts +5 -5
  121. package/lib/contexts/tagcontext.js +16 -16
  122. package/lib/contexts/textalertcontext.d.ts +1 -5
  123. package/lib/contexts/textalertcontext.js +1 -5
  124. package/lib/contexts/usereventcontext.d.ts +1 -1
  125. package/lib/contexts/usereventcontext.js +12 -12
  126. package/lib/data/animation.d.ts +10 -2
  127. package/lib/data/change.d.ts +1 -1
  128. package/lib/data/change.js +7 -0
  129. package/lib/data/core.d.ts +9 -1
  130. package/lib/data/index.d.ts +1 -1
  131. package/lib/data/index.js +1 -1
  132. package/lib/decorators.d.ts +348 -0
  133. package/lib/decorators.js +239 -0
  134. package/lib/decoratorutils.d.ts +3 -0
  135. package/lib/decoratorutils.js +8 -0
  136. package/lib/emitter.d.ts +15 -2
  137. package/lib/emitter.js +15 -6
  138. package/lib/entity.d.ts +43 -25
  139. package/lib/entity.js +104 -71
  140. package/lib/event.d.ts +2 -1
  141. package/lib/event.js +1 -4
  142. package/lib/groups.d.ts +18 -0
  143. package/lib/groups.js +19 -0
  144. package/lib/icons.d.ts +3372 -0
  145. package/lib/icons.js +1 -0
  146. package/lib/index.d.ts +18 -13
  147. package/lib/index.js +17 -13
  148. package/lib/inflate.d.ts +7 -7
  149. package/lib/inflate.js +5 -5
  150. package/lib/observable.d.ts +9 -2
  151. package/lib/observable.js +5 -4
  152. package/lib/observe.d.ts +18 -0
  153. package/lib/observe.js +177 -0
  154. package/lib/profile.d.ts +9 -5
  155. package/lib/profile.js +27 -17
  156. package/lib/selectors.d.ts +1 -1
  157. package/lib/selectors.js +5 -4
  158. package/lib/types.d.ts +161 -19
  159. package/lib/types.js +22 -1
  160. package/lib/values/values.d.ts +7 -8
  161. package/lib/values/values.js +1 -2
  162. package/lib/values/valuesmutator.d.ts +4 -1
  163. package/lib/values/valuesmutator.js +10 -8
  164. package/lib/zcomponent.d.ts +21 -10
  165. package/lib/zcomponent.js +717 -540
  166. package/package.json +22 -5
  167. package/lib/behaviors/ChangeCursor.d.ts +0 -39
  168. package/lib/behaviors/ChangeCursor.js +0 -44
@@ -1,58 +1,70 @@
1
- import { Component, Observable, ContextManager } from '..';
1
+ import { Component, ContextManager, ProjectFile } from '..';
2
2
  export interface DefaultLoaderConstructorProps {
3
- /** @zprop
3
+ /**
4
4
  * @zgroup Appearance
5
5
  * @zgrouppriority 10
6
- * @zvalues files *.+(jpg|jpeg|png|webp)
7
6
  */
8
- backgroundImage: string;
7
+ backgroundImage: ProjectFile<'*.+(jpg|jpeg|png|webp)'>;
9
8
  }
10
9
  /**
11
10
  * The DefaultLoader shows a customizable loading bar while the assets of your experience are being downloaded and parsed by the browser.
12
- *
13
11
  * @zcomponent
14
- * @zicon loader
12
+ * @zicon hourglass_bottom
15
13
  * @zgroup Advanced
16
14
  */
17
15
  export declare class DefaultLoader extends Component {
16
+ /**
17
+ * @zignore
18
+ */
18
19
  element: HTMLDivElement;
19
- /** @zprop
20
- * @zdefault false
20
+ /**
21
+ * @default false
22
+ * @zui
21
23
  * @zgroup Design Time
22
- * @zgrouppriority 30
23
24
  */
24
- readonly preview: Observable<boolean, never>;
25
- /** @zprop
25
+ preview: boolean;
26
+ /**
27
+ * @default ""
28
+ * @zui
26
29
  * @zgroup Text
27
- * @zgrouppriority 20
28
30
  */
29
- readonly title: Observable<string>;
30
- /** @zprop
31
+ title: string;
32
+ /**
33
+ * @default ""
34
+ * @zui
31
35
  * @zgroup Text
32
- * @zgrouppriority 20
33
36
  */
34
- readonly subtitle: Observable<string>;
35
- /** @zprop
36
- * @zdefault #000000
37
+ subtitle: string;
38
+ /**
39
+ * @default "#000000"
40
+ * @zui
37
41
  * @zgroup Appearance
38
- * @zgrouppriority 10
39
42
  * @ztype color-hex
40
43
  */
41
- readonly backgroundColor: Observable<string>;
42
- /** @zprop
43
- * @zdefault #ffffff
44
+ backgroundColor: string;
45
+ /**
46
+ * @default "#ffffff"
47
+ * @zui
44
48
  * @zgroup Appearance
45
- * @zgrouppriority 10
46
49
  * @ztype color-hex
47
50
  */
48
- readonly textColor: Observable<string>;
49
- /** @zprop
50
- * @zdefault 1000
51
+ textColor: string;
52
+ /**
53
+ * @default 1000
54
+ * @zui
55
+ * @zgroup Appearance
56
+ */
57
+ zIndex: number;
58
+ /**
59
+ * @default false
60
+ * @zui
51
61
  * @zgroup Appearance
52
- * @zgrouppriority 10
53
62
  */
54
- readonly zIndex: Observable<number>;
63
+ showIfLoadingAfterStart: boolean;
55
64
  private _percentageElement;
65
+ /**
66
+ * @default false
67
+ */
56
68
  private _attached;
57
69
  /**
58
70
  * Creates a new DefaultLoader component.
@@ -1,36 +1,204 @@
1
- import { Component, useCanvas, Observable, isDesignTime, useIsLoaded, useLoadPercent, isStarted } from '..';
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
+ };
35
+ import { Component, isDesignTime, isStarted, useCanvas, useIsLoaded, useLoadPercent, zComponent, zIgnore, zObserve, zUI } from '..';
2
36
  /**
3
37
  * The DefaultLoader shows a customizable loading bar while the assets of your experience are being downloaded and parsed by the browser.
4
- *
5
38
  * @zcomponent
6
- * @zicon loader
39
+ * @zicon hourglass_bottom
7
40
  * @zgroup Advanced
8
41
  */
9
- export class DefaultLoader extends Component {
10
- /**
11
- * Creates a new DefaultLoader component.
12
- * @param contextManager - The current ContextManager
13
- * @param constructorProps - The constructor properties.
14
- */
15
- constructor(contextManager, constructorProps) {
16
- super(contextManager, constructorProps);
17
- this.element = document.createElement('div');
18
- /** @zprop
19
- * @zdefault false
42
+ let DefaultLoader = (() => {
43
+ let _classDecorators = [zComponent({ icon: 'hourglass_bottom', group: 'Advanced' })];
44
+ let _classDescriptor;
45
+ let _classExtraInitializers = [];
46
+ let _classThis;
47
+ let _classSuper = Component;
48
+ let _element_decorators;
49
+ let _element_initializers = [];
50
+ let _element_extraInitializers = [];
51
+ let _preview_decorators;
52
+ let _preview_initializers = [];
53
+ let _preview_extraInitializers = [];
54
+ let _title_decorators;
55
+ let _title_initializers = [];
56
+ let _title_extraInitializers = [];
57
+ let _subtitle_decorators;
58
+ let _subtitle_initializers = [];
59
+ let _subtitle_extraInitializers = [];
60
+ let _backgroundColor_decorators;
61
+ let _backgroundColor_initializers = [];
62
+ let _backgroundColor_extraInitializers = [];
63
+ let _textColor_decorators;
64
+ let _textColor_initializers = [];
65
+ let _textColor_extraInitializers = [];
66
+ let _zIndex_decorators;
67
+ let _zIndex_initializers = [];
68
+ let _zIndex_extraInitializers = [];
69
+ let _showIfLoadingAfterStart_decorators;
70
+ let _showIfLoadingAfterStart_initializers = [];
71
+ let _showIfLoadingAfterStart_extraInitializers = [];
72
+ var DefaultLoader = class extends _classSuper {
73
+ static { _classThis = this; }
74
+ static {
75
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
76
+ _element_decorators = [zIgnore()];
77
+ _preview_decorators = [zUI({ group: 'Design Time', priority: 30 }), zObserve(function () {
78
+ this._updateVisibility();
79
+ })];
80
+ _title_decorators = [zUI({ group: 'Text', priority: 20 }), zObserve(function (value) {
81
+ const titleElement = this.element.querySelector('#zcomponent-defaultloader-title');
82
+ if (titleElement)
83
+ titleElement.innerText = value;
84
+ })];
85
+ _subtitle_decorators = [zUI({ group: 'Text', priority: 20 }), zObserve(function (value) {
86
+ const subtitleElement = this.element.querySelector('#zcomponent-defaultloader-subtitle');
87
+ if (subtitleElement)
88
+ subtitleElement.innerText = value;
89
+ })];
90
+ _backgroundColor_decorators = [zUI({ group: 'Appearance', priority: 10, type: 'color-hex' }), zObserve(function (value) {
91
+ this.element.style.backgroundColor = value;
92
+ })];
93
+ _textColor_decorators = [zUI({ group: 'Appearance', priority: 10, type: 'color-hex' }), zObserve(function (value) {
94
+ this.element.style.color = value;
95
+ })];
96
+ _zIndex_decorators = [zUI({ group: 'Appearance', priority: 10 }), zObserve(function (value) {
97
+ this.element.style.zIndex = value.toString();
98
+ })];
99
+ _showIfLoadingAfterStart_decorators = [zUI({ group: 'Appearance', priority: 10 }), zObserve((v, instance) => () => instance._updateVisibility())];
100
+ __esDecorate(null, null, _element_decorators, { kind: "field", name: "element", static: false, private: false, access: { has: obj => "element" in obj, get: obj => obj.element, set: (obj, value) => { obj.element = value; } }, metadata: _metadata }, _element_initializers, _element_extraInitializers);
101
+ __esDecorate(null, null, _preview_decorators, { kind: "field", name: "preview", static: false, private: false, access: { has: obj => "preview" in obj, get: obj => obj.preview, set: (obj, value) => { obj.preview = value; } }, metadata: _metadata }, _preview_initializers, _preview_extraInitializers);
102
+ __esDecorate(null, null, _title_decorators, { kind: "field", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
103
+ __esDecorate(null, null, _subtitle_decorators, { kind: "field", name: "subtitle", static: false, private: false, access: { has: obj => "subtitle" in obj, get: obj => obj.subtitle, set: (obj, value) => { obj.subtitle = value; } }, metadata: _metadata }, _subtitle_initializers, _subtitle_extraInitializers);
104
+ __esDecorate(null, null, _backgroundColor_decorators, { kind: "field", name: "backgroundColor", static: false, private: false, access: { has: obj => "backgroundColor" in obj, get: obj => obj.backgroundColor, set: (obj, value) => { obj.backgroundColor = value; } }, metadata: _metadata }, _backgroundColor_initializers, _backgroundColor_extraInitializers);
105
+ __esDecorate(null, null, _textColor_decorators, { kind: "field", name: "textColor", static: false, private: false, access: { has: obj => "textColor" in obj, get: obj => obj.textColor, set: (obj, value) => { obj.textColor = value; } }, metadata: _metadata }, _textColor_initializers, _textColor_extraInitializers);
106
+ __esDecorate(null, null, _zIndex_decorators, { kind: "field", name: "zIndex", static: false, private: false, access: { has: obj => "zIndex" in obj, get: obj => obj.zIndex, set: (obj, value) => { obj.zIndex = value; } }, metadata: _metadata }, _zIndex_initializers, _zIndex_extraInitializers);
107
+ __esDecorate(null, null, _showIfLoadingAfterStart_decorators, { kind: "field", name: "showIfLoadingAfterStart", static: false, private: false, access: { has: obj => "showIfLoadingAfterStart" in obj, get: obj => obj.showIfLoadingAfterStart, set: (obj, value) => { obj.showIfLoadingAfterStart = value; } }, metadata: _metadata }, _showIfLoadingAfterStart_initializers, _showIfLoadingAfterStart_extraInitializers);
108
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
109
+ DefaultLoader = _classThis = _classDescriptor.value;
110
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
111
+ __runInitializers(_classThis, _classExtraInitializers);
112
+ }
113
+ /**
114
+ * @zignore
115
+ */
116
+ element = __runInitializers(this, _element_initializers, document.createElement('div'));
117
+ /**
118
+ * @default false
119
+ * @zui
20
120
  * @zgroup Design Time
21
- * @zgrouppriority 30
22
121
  */
23
- this.preview = new Observable(false);
24
- this._attached = false;
25
- this._updatePercentage = () => {
26
- const p = isDesignTime(this.contextManager) && this.preview.value ? 30 : useLoadPercent(this.contextManager).value;
122
+ preview = (__runInitializers(this, _element_extraInitializers), __runInitializers(this, _preview_initializers, false));
123
+ /**
124
+ * @default ""
125
+ * @zui
126
+ * @zgroup Text
127
+ */
128
+ title = (__runInitializers(this, _preview_extraInitializers), __runInitializers(this, _title_initializers, ''));
129
+ /**
130
+ * @default ""
131
+ * @zui
132
+ * @zgroup Text
133
+ */
134
+ subtitle = (__runInitializers(this, _title_extraInitializers), __runInitializers(this, _subtitle_initializers, ''));
135
+ /**
136
+ * @default "#000000"
137
+ * @zui
138
+ * @zgroup Appearance
139
+ * @ztype color-hex
140
+ */
141
+ backgroundColor = (__runInitializers(this, _subtitle_extraInitializers), __runInitializers(this, _backgroundColor_initializers, '#000000'));
142
+ /**
143
+ * @default "#ffffff"
144
+ * @zui
145
+ * @zgroup Appearance
146
+ * @ztype color-hex
147
+ */
148
+ textColor = (__runInitializers(this, _backgroundColor_extraInitializers), __runInitializers(this, _textColor_initializers, '#ffffff'));
149
+ /**
150
+ * @default 1000
151
+ * @zui
152
+ * @zgroup Appearance
153
+ */
154
+ zIndex = (__runInitializers(this, _textColor_extraInitializers), __runInitializers(this, _zIndex_initializers, 1000));
155
+ /**
156
+ * @default false
157
+ * @zui
158
+ * @zgroup Appearance
159
+ */
160
+ showIfLoadingAfterStart = (__runInitializers(this, _zIndex_extraInitializers), __runInitializers(this, _showIfLoadingAfterStart_initializers, false));
161
+ _percentageElement = __runInitializers(this, _showIfLoadingAfterStart_extraInitializers);
162
+ /**
163
+ * @default false
164
+ */
165
+ _attached = false;
166
+ /**
167
+ * Creates a new DefaultLoader component.
168
+ * @param contextManager - The current ContextManager
169
+ * @param constructorProps - The constructor properties.
170
+ */
171
+ constructor(contextManager, constructorProps) {
172
+ super(contextManager, constructorProps);
173
+ this.element.innerHTML = loaderHTML;
174
+ this.element.className = 'zcomponent-defaultloader';
175
+ if (constructorProps.backgroundImage)
176
+ this.element.style.backgroundImage = `url(${constructorProps.backgroundImage})`;
177
+ const titleElement = this.element.querySelector('#zcomponent-defaultloader-title') || document.createElement('h1');
178
+ const subtitleElement = this.element.querySelector('#zcomponent-defaultloader-subtitle') || document.createElement('h1');
179
+ this._percentageElement = this.element.querySelector('#zcomponent-defaultloader-progress-percentage') || document.createElement('div');
180
+ // Set initial values
181
+ if (this.title)
182
+ titleElement.innerText = this.title;
183
+ if (this.subtitle)
184
+ subtitleElement.innerText = this.subtitle;
185
+ this.element.style.color = this.textColor;
186
+ this.element.style.backgroundColor = this.backgroundColor;
187
+ this.element.style.zIndex = this.zIndex.toString();
188
+ // Register event handlers
189
+ this.register(useIsLoaded(contextManager), this._updateVisibility);
190
+ this.register(useLoadPercent(contextManager), this._updatePercentage);
191
+ this._update();
192
+ }
193
+ _updatePercentage = () => {
194
+ const p = isDesignTime(this.contextManager) && this.preview ? 30 : useLoadPercent(this.contextManager).value;
27
195
  this._percentageElement.style.width = p.toString() + '%';
28
196
  };
29
- this._updateVisibility = () => {
197
+ _updateVisibility = () => {
30
198
  let shouldBeAttached = false;
31
- if (!isDesignTime(this.contextManager) && !useIsLoaded(this.contextManager).value && !isStarted(this.contextManager))
199
+ if (!isDesignTime(this.contextManager) && !useIsLoaded(this.contextManager).value && (!isStarted(this.contextManager) || this.showIfLoadingAfterStart))
32
200
  shouldBeAttached = true;
33
- if (isDesignTime(this.contextManager) && this.preview.value)
201
+ if (isDesignTime(this.contextManager) && this.preview)
34
202
  shouldBeAttached = true;
35
203
  if (!this._attached && shouldBeAttached) {
36
204
  document.body.appendChild(this.element);
@@ -41,7 +209,7 @@ export class DefaultLoader extends Component {
41
209
  this._attached = false;
42
210
  }
43
211
  };
44
- this._update = () => {
212
+ _update = () => {
45
213
  if (this.disposed)
46
214
  return;
47
215
  const rect = useCanvas(this.contextManager).getBoundingClientRect();
@@ -51,30 +219,14 @@ export class DefaultLoader extends Component {
51
219
  this.element.style.height = rect.height.toString() + 'px';
52
220
  requestAnimationFrame(this._update);
53
221
  };
54
- this.element.innerHTML = loaderHTML;
55
- this.element.className = 'zcomponent-defaultloader';
56
- if (constructorProps.backgroundImage) {
57
- this.element.style.backgroundImage = `url(${constructorProps.backgroundImage})`;
222
+ dispose() {
223
+ this.element.remove();
224
+ return super.dispose();
58
225
  }
59
- const titleElement = this.element.querySelector('#zcomponent-defaultloader-title') || document.createElement('h1');
60
- const subtitleElement = this.element.querySelector('#zcomponent-defaultloader-subtitle') || document.createElement('h1');
61
- this._percentageElement = this.element.querySelector('#zcomponent-defaultloader-progress-percentage') || document.createElement('div');
62
- this.title = new Observable('', t => (titleElement.innerText = t));
63
- this.subtitle = new Observable('', t => (subtitleElement.innerText = t));
64
- this.textColor = new Observable('#ffffff', t => (this.element.style.color = t));
65
- this.backgroundColor = new Observable('#000000', t => (this.element.style.backgroundColor = t));
66
- this.zIndex = new Observable(1000, t => (this.element.style.zIndex = t.toString()));
67
- this.register(this.preview, this._updatePercentage);
68
- this.register(this.preview, this._updateVisibility);
69
- this.register(useIsLoaded(contextManager), this._updateVisibility);
70
- this.register(useLoadPercent(contextManager), this._updatePercentage);
71
- this._update();
72
- }
73
- dispose() {
74
- this.element.remove();
75
- return super.dispose();
76
- }
77
- }
226
+ };
227
+ return DefaultLoader = _classThis;
228
+ })();
229
+ export { DefaultLoader };
78
230
  const loaderHTML = `
79
231
  <div id="zcomponent-defaultloader-container">
80
232
  <h1 id="zcomponent-defaultloader-title"></h1>
@@ -1,7 +1,6 @@
1
1
  import { Component } from '../component';
2
2
  import { ContextManager } from '../context';
3
3
  import { Event } from '../event';
4
- import { Observable } from '../observable';
5
4
  export interface GamepadButtonEvent {
6
5
  button: number;
7
6
  gamepad: number;
@@ -17,54 +16,34 @@ export interface GamepadButtonEvent {
17
16
  * @zicon sports_esports
18
17
  */
19
18
  export declare class Gamepad extends Component {
20
- /** @zprop */
21
19
  readonly onButtonDown: Event<[GamepadButtonEvent]>;
22
- /** @zprop */
23
20
  readonly onButtonUp: Event<[GamepadButtonEvent]>;
24
- /** @zprop */
25
21
  readonly onButtonSouth: Event<[GamepadButtonEvent]>;
26
- /** @zprop */
27
22
  readonly onButtonWest: Event<[GamepadButtonEvent]>;
28
- /** @zprop */
29
23
  readonly onButtonNorth: Event<[GamepadButtonEvent]>;
30
- /** @zprop */
31
24
  readonly onButtonEast: Event<[GamepadButtonEvent]>;
32
- /** @zprop */
33
25
  readonly onButtonShoulderLeft: Event<[GamepadButtonEvent]>;
34
- /** @zprop */
35
26
  readonly onButtonShoulderRight: Event<[GamepadButtonEvent]>;
36
- /** @zprop */
37
27
  readonly onButtonTriggerLeft: Event<[GamepadButtonEvent]>;
38
- /** @zprop */
39
28
  readonly onButtonTriggerRight: Event<[GamepadButtonEvent]>;
40
- /** @zprop */
41
29
  readonly onButtonDLeft: Event<[GamepadButtonEvent]>;
42
- /** @zprop */
43
30
  readonly onButtonDRight: Event<[GamepadButtonEvent]>;
44
- /** @zprop */
45
31
  readonly onButtonDUp: Event<[GamepadButtonEvent]>;
46
- /** @zprop */
47
32
  readonly onButtonDDown: Event<[GamepadButtonEvent]>;
48
- /** @zprop */
49
33
  readonly onButtonSelect: Event<[GamepadButtonEvent]>;
50
- /** @zprop */
51
34
  readonly onButtonStart: Event<[GamepadButtonEvent]>;
52
- /** @zprop */
53
35
  readonly onButtonCenter: Event<[GamepadButtonEvent]>;
54
- /** @zprop */
55
36
  readonly onButtonStickLeft: Event<[GamepadButtonEvent]>;
56
- /** @zprop */
57
37
  readonly onButtonStickRight: Event<[GamepadButtonEvent]>;
58
- private _indexMapping;
59
38
  /**
60
- * @zprop
39
+ * @default []
61
40
  */
62
- readonly controllerIndex: Observable<number | undefined, never>;
41
+ private _indexMapping;
42
+ controllerIndex?: number;
63
43
  /**
64
- * @zprop
65
- * @zdefault 0.1
44
+ * @default 0.1
66
45
  */
67
- readonly analogPressedThreshold: Observable<number, never>;
46
+ analogPressedThreshold: number;
68
47
  private _downLastFrame;
69
48
  /**
70
49
  * Creates a new Gamepad component.