@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,52 +1,141 @@
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';
2
37
  import { Event } from '../event';
3
38
  import { Observable } from '../observable';
4
- export var Orientation;
5
- (function (Orientation) {
6
- Orientation["Portrait"] = "portrait";
7
- Orientation["Landscape"] = "landscape";
8
- Orientation["PortraitSecondary"] = "portrait-secondary";
9
- Orientation["LandscapeSecondary"] = "landscape-secondary";
10
- })(Orientation || (Orientation = {}));
39
+ export const Orientation = {
40
+ Portrait: 'portrait',
41
+ Landscape: 'landscape',
42
+ PortraitSecondary: 'portrait-secondary',
43
+ LandscapeSecondary: 'landscape-secondary',
44
+ };
45
+ Object.freeze(Orientation);
11
46
  /**
12
47
  * Manages and tracks orientation changes in the application context.
13
48
  * @zcontext
14
49
  */
15
- export class OrientationContext extends Context {
16
- /**
17
- * Creates an instance of OrientationContext.
18
- * @param contextManager - The current ContextManager
19
- */
20
- constructor(contextManager) {
21
- super(contextManager, {});
50
+ let OrientationContext = (() => {
51
+ let _classSuper = Context;
52
+ let _isPortrait_decorators;
53
+ let _isPortrait_initializers = [];
54
+ let _isPortrait_extraInitializers = [];
55
+ let _isLandscape_decorators;
56
+ let _isLandscape_initializers = [];
57
+ let _isLandscape_extraInitializers = [];
58
+ let _isPortraitSecondary_decorators;
59
+ let _isPortraitSecondary_initializers = [];
60
+ let _isPortraitSecondary_extraInitializers = [];
61
+ let _isLandscapeSecondary_decorators;
62
+ let _isLandscapeSecondary_initializers = [];
63
+ let _isLandscapeSecondary_extraInitializers = [];
64
+ return class OrientationContext extends _classSuper {
65
+ static {
66
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
67
+ _isPortrait_decorators = [zUI()];
68
+ _isLandscape_decorators = [zUI()];
69
+ _isPortraitSecondary_decorators = [zUI()];
70
+ _isLandscapeSecondary_decorators = [zUI()];
71
+ __esDecorate(null, null, _isPortrait_decorators, { kind: "field", name: "isPortrait", static: false, private: false, access: { has: obj => "isPortrait" in obj, get: obj => obj.isPortrait, set: (obj, value) => { obj.isPortrait = value; } }, metadata: _metadata }, _isPortrait_initializers, _isPortrait_extraInitializers);
72
+ __esDecorate(null, null, _isLandscape_decorators, { kind: "field", name: "isLandscape", static: false, private: false, access: { has: obj => "isLandscape" in obj, get: obj => obj.isLandscape, set: (obj, value) => { obj.isLandscape = value; } }, metadata: _metadata }, _isLandscape_initializers, _isLandscape_extraInitializers);
73
+ __esDecorate(null, null, _isPortraitSecondary_decorators, { kind: "field", name: "isPortraitSecondary", static: false, private: false, access: { has: obj => "isPortraitSecondary" in obj, get: obj => obj.isPortraitSecondary, set: (obj, value) => { obj.isPortraitSecondary = value; } }, metadata: _metadata }, _isPortraitSecondary_initializers, _isPortraitSecondary_extraInitializers);
74
+ __esDecorate(null, null, _isLandscapeSecondary_decorators, { kind: "field", name: "isLandscapeSecondary", static: false, private: false, access: { has: obj => "isLandscapeSecondary" in obj, get: obj => obj.isLandscapeSecondary, set: (obj, value) => { obj.isLandscapeSecondary = value; } }, metadata: _metadata }, _isLandscapeSecondary_initializers, _isLandscapeSecondary_extraInitializers);
75
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
76
+ }
77
+ /**
78
+ * Observable indicating whether the current orientation is portrait.
79
+ */
80
+ isPortrait = __runInitializers(this, _isPortrait_initializers, void 0);
81
+ /**
82
+ * Observable indicating whether the current orientation is landscape.
83
+ */
84
+ isLandscape = (__runInitializers(this, _isPortrait_extraInitializers), __runInitializers(this, _isLandscape_initializers, void 0));
85
+ /**
86
+ * Observable indicating whether the current orientation is secondary portrait.
87
+ */
88
+ isPortraitSecondary = (__runInitializers(this, _isLandscape_extraInitializers), __runInitializers(this, _isPortraitSecondary_initializers, void 0));
89
+ /**
90
+ * Observable indicating whether the current orientation is secondary landscape.
91
+ */
92
+ isLandscapeSecondary = (__runInitializers(this, _isPortraitSecondary_extraInitializers), __runInitializers(this, _isLandscapeSecondary_initializers, void 0));
93
+ /**
94
+ * Observable representing the current orientation.
95
+ */
96
+ orientation = __runInitializers(this, _isLandscapeSecondary_extraInitializers);
22
97
  /**
23
98
  * Event triggered when the orientation changes to portrait.
24
99
  */
25
- this.onPortrait = new Event();
100
+ onPortrait = new Event();
26
101
  /**
27
102
  * Event triggered when the orientation changes to landscape.
28
103
  */
29
- this.onLandscape = new Event();
104
+ onLandscape = new Event();
30
105
  /**
31
106
  * Event triggered when the orientation changes to secondary portrait.
32
107
  */
33
- this.onPortraitSecondary = new Event();
108
+ onPortraitSecondary = new Event();
34
109
  /**
35
110
  * Event triggered when the orientation changes to secondary landscape.
36
111
  */
37
- this.onLandscapeSecondary = new Event();
112
+ onLandscapeSecondary = new Event();
38
113
  /**
39
114
  * Event triggered when there is any orientation change.
40
115
  */
41
- this.onOrientationChange = new Event();
42
- this.attachListeners = () => {
116
+ onOrientationChange = new Event();
117
+ /**
118
+ * Creates an instance of OrientationContext.
119
+ * @param contextManager - The current ContextManager
120
+ */
121
+ constructor(contextManager) {
122
+ super(contextManager, {});
123
+ const currentOrientation = this.getOrientation();
124
+ this.orientation = new Observable(currentOrientation);
125
+ this.isPortrait = new Observable(currentOrientation === Orientation.Portrait);
126
+ this.isLandscape = new Observable(currentOrientation === Orientation.Landscape);
127
+ this.isPortraitSecondary = new Observable(currentOrientation === Orientation.PortraitSecondary);
128
+ this.isLandscapeSecondary = new Observable(currentOrientation === Orientation.LandscapeSecondary);
129
+ this.attachListeners();
130
+ }
131
+ attachListeners = () => {
43
132
  this.orientation.addListener(this._onOrientationChange);
44
133
  window.addEventListener('resize', this.orientationChangeHandler);
45
134
  if ('orientation' in screen && screen.orientation) {
46
135
  screen.orientation.addEventListener('change', this.orientationChangeHandler);
47
136
  }
48
137
  };
49
- this._onOrientationChange = (orientation) => {
138
+ _onOrientationChange = (orientation) => {
50
139
  this.onOrientationChange.emit(orientation);
51
140
  this.isPortrait.value = orientation === Orientation.Portrait;
52
141
  this.isLandscape.value = orientation === Orientation.Landscape;
@@ -67,63 +156,57 @@ export class OrientationContext extends Context {
67
156
  break;
68
157
  }
69
158
  };
70
- this.orientationChangeHandler = () => {
159
+ orientationChangeHandler = () => {
71
160
  const newOrientation = this.getOrientation();
72
161
  if (this.orientation.value === newOrientation)
73
162
  return;
74
163
  this.orientation.value = newOrientation;
75
164
  };
76
- this.dispose = () => {
165
+ getOrientation() {
166
+ const orientation = this.getOrientationFromScreen() ?? this.getOrientationFromWindow() ?? this.getOrientationFromDimensions();
167
+ return orientation;
168
+ }
169
+ getOrientationFromScreen() {
170
+ const orientationType = screen?.orientation?.type;
171
+ if (orientationType) {
172
+ if (orientationType.includes('portrait')) {
173
+ return orientationType.includes('secondary') ? Orientation.PortraitSecondary : Orientation.Portrait;
174
+ }
175
+ else {
176
+ return orientationType.includes('secondary') ? Orientation.LandscapeSecondary : Orientation.Landscape;
177
+ }
178
+ }
179
+ return null;
180
+ }
181
+ getOrientationFromWindow() {
182
+ const windowOrientation = window?.orientation;
183
+ if (typeof windowOrientation === 'number') {
184
+ switch (windowOrientation) {
185
+ case 0:
186
+ return Orientation.Portrait;
187
+ case 90:
188
+ return Orientation.Landscape;
189
+ case 180:
190
+ return Orientation.PortraitSecondary;
191
+ case -90:
192
+ return Orientation.LandscapeSecondary;
193
+ }
194
+ }
195
+ return null;
196
+ }
197
+ getOrientationFromDimensions() {
198
+ return window.innerWidth > window.innerHeight ? Orientation.Landscape : Orientation.Portrait;
199
+ }
200
+ dispose = () => {
77
201
  window.removeEventListener('resize', this.orientationChangeHandler);
78
202
  if ('orientation' in screen && screen.orientation)
79
203
  screen.orientation.removeEventListener('change', this.orientationChangeHandler);
80
204
  this.orientation.removeListener(this._onOrientationChange);
81
205
  return super.dispose();
82
206
  };
83
- const currentOrientation = this.getOrientation();
84
- this.orientation = new Observable(currentOrientation);
85
- this.isPortrait = new Observable(currentOrientation === Orientation.Portrait);
86
- this.isLandscape = new Observable(currentOrientation === Orientation.Landscape);
87
- this.isPortraitSecondary = new Observable(currentOrientation === Orientation.PortraitSecondary);
88
- this.isLandscapeSecondary = new Observable(currentOrientation === Orientation.LandscapeSecondary);
89
- this.attachListeners();
90
- }
91
- getOrientation() {
92
- const orientation = this.getOrientationFromScreen() ?? this.getOrientationFromWindow() ?? this.getOrientationFromDimensions();
93
- return orientation;
94
- }
95
- getOrientationFromScreen() {
96
- const orientationType = screen?.orientation?.type;
97
- if (orientationType) {
98
- if (orientationType.includes('portrait')) {
99
- return orientationType.includes('secondary') ? Orientation.PortraitSecondary : Orientation.Portrait;
100
- }
101
- else {
102
- return orientationType.includes('secondary') ? Orientation.LandscapeSecondary : Orientation.Landscape;
103
- }
104
- }
105
- return null;
106
- }
107
- getOrientationFromWindow() {
108
- const windowOrientation = window?.orientation;
109
- if (typeof windowOrientation === 'number') {
110
- switch (windowOrientation) {
111
- case 0:
112
- return Orientation.Portrait;
113
- case 90:
114
- return Orientation.Landscape;
115
- case 180:
116
- return Orientation.PortraitSecondary;
117
- case -90:
118
- return Orientation.LandscapeSecondary;
119
- }
120
- }
121
- return null;
122
- }
123
- getOrientationFromDimensions() {
124
- return window.innerWidth > window.innerHeight ? Orientation.Landscape : Orientation.Portrait;
125
- }
126
- }
207
+ };
208
+ })();
209
+ export { OrientationContext };
127
210
  /**
128
211
  * Returns an observable that notifies when the orientation changes.
129
212
  * @param mgr The ContextManager instance to access the OrientationContext.
@@ -0,0 +1,16 @@
1
+ import { Component, ConstructorForComponent, ConstructorPropsOfComponent } from '../component';
2
+ import { Context } from '../context';
3
+ export declare class RootComponentsContext extends Context {
4
+ rootComponent: Component | undefined;
5
+ private _topLevelComponents;
6
+ private _topLevelComponentOwners;
7
+ /**
8
+ * @default false
9
+ */
10
+ private _suppressCleanup;
11
+ constructAndReplaceRootComponent<T extends Component>(_constructor: ConstructorForComponent<T>, constructorProps: ConstructorPropsOfComponent<T>): T;
12
+ replaceRootComponent<T extends Component>(newRoot: T): T;
13
+ lockTopLevelComponent<T extends Component>(_constructor: ConstructorForComponent<T>, constructorProps: ConstructorPropsOfComponent<T>, owner: any): T;
14
+ unlockTopLevelComponent<T extends Component>(_constructor: ConstructorForComponent<T>, owner: any): void;
15
+ private _cleanup;
16
+ }
@@ -0,0 +1,65 @@
1
+ import { Context } from '../context';
2
+ export class RootComponentsContext extends Context {
3
+ rootComponent;
4
+ _topLevelComponents = new Map();
5
+ _topLevelComponentOwners = new Map();
6
+ /**
7
+ * @default false
8
+ */
9
+ _suppressCleanup = false;
10
+ constructAndReplaceRootComponent(_constructor, constructorProps) {
11
+ this._suppressCleanup = true;
12
+ if (this.rootComponent) {
13
+ this.rootComponent.dispose();
14
+ }
15
+ const newRoot = new _constructor(this.contextManager, constructorProps);
16
+ this.rootComponent = newRoot;
17
+ this._suppressCleanup = false;
18
+ this._cleanup();
19
+ return newRoot;
20
+ }
21
+ replaceRootComponent(newRoot) {
22
+ if (this.rootComponent) {
23
+ this.rootComponent.dispose();
24
+ }
25
+ this.rootComponent = newRoot;
26
+ return newRoot;
27
+ }
28
+ lockTopLevelComponent(_constructor, constructorProps, owner) {
29
+ let existing = this._topLevelComponents.get(_constructor);
30
+ if (!existing) {
31
+ existing = new _constructor(this.contextManager, constructorProps);
32
+ existing.connectElements();
33
+ this._topLevelComponents.set(_constructor, existing);
34
+ }
35
+ const owners = this._topLevelComponentOwners.get(_constructor) ?? new Set();
36
+ owners.add(owner);
37
+ this._topLevelComponentOwners.set(_constructor, owners);
38
+ return existing;
39
+ }
40
+ unlockTopLevelComponent(_constructor, owner) {
41
+ const owners = this._topLevelComponentOwners.get(_constructor);
42
+ if (!owners || !owners.has(owner)) {
43
+ return;
44
+ }
45
+ owners.delete(owner);
46
+ this._cleanup();
47
+ }
48
+ _cleanup() {
49
+ if (this._suppressCleanup)
50
+ return;
51
+ for (const [_constructor, owners] of this._topLevelComponentOwners.entries()) {
52
+ if (owners.size === 0) {
53
+ try {
54
+ const component = this._topLevelComponents.get(_constructor);
55
+ component?.dispose();
56
+ }
57
+ catch (err) {
58
+ console.error('Error disposing top-level component:', err);
59
+ }
60
+ this._topLevelComponents.delete(_constructor);
61
+ this._topLevelComponentOwners.delete(_constructor);
62
+ }
63
+ }
64
+ }
65
+ }
@@ -7,17 +7,14 @@ import { Observable } from '../observable';
7
7
  export declare class SnapshotContext extends Context {
8
8
  /**
9
9
  * Observable holding the current canvas image data URL.
10
- * @zui
11
10
  */
12
11
  readonly canvasImage: Observable<string, never>;
13
12
  /**
14
13
  * Observable indicating whether the Share API is supported in the current environment.
15
- * @zui
16
14
  */
17
15
  readonly shareAPISupported: Observable<boolean, never>;
18
16
  /**
19
17
  * Observable determining if the current canvas content can be shared.
20
- * @zui
21
18
  */
22
19
  readonly canShare: Observable<boolean, never>;
23
20
  /**
@@ -1,61 +1,116 @@
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';
2
37
  import { Observable } from '../observable';
3
38
  /**
4
39
  * Context containing snapshot information.
5
40
  * @zcontext
6
41
  * */
7
- export class SnapshotContext extends Context {
8
- /**
9
- * Creates an instance of SnapshotContext.
10
- * @param contextManager - The current ContextManager
11
- */
12
- constructor(contextManager) {
13
- super(contextManager, {});
42
+ let SnapshotContext = (() => {
43
+ let _classSuper = Context;
44
+ let _canvasImage_decorators;
45
+ let _canvasImage_initializers = [];
46
+ let _canvasImage_extraInitializers = [];
47
+ let _shareAPISupported_decorators;
48
+ let _shareAPISupported_initializers = [];
49
+ let _shareAPISupported_extraInitializers = [];
50
+ let _canShare_decorators;
51
+ let _canShare_initializers = [];
52
+ let _canShare_extraInitializers = [];
53
+ return class SnapshotContext extends _classSuper {
54
+ static {
55
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
56
+ _canvasImage_decorators = [zUI()];
57
+ _shareAPISupported_decorators = [zUI()];
58
+ _canShare_decorators = [zUI()];
59
+ __esDecorate(null, null, _canvasImage_decorators, { kind: "field", name: "canvasImage", static: false, private: false, access: { has: obj => "canvasImage" in obj, get: obj => obj.canvasImage, set: (obj, value) => { obj.canvasImage = value; } }, metadata: _metadata }, _canvasImage_initializers, _canvasImage_extraInitializers);
60
+ __esDecorate(null, null, _shareAPISupported_decorators, { kind: "field", name: "shareAPISupported", static: false, private: false, access: { has: obj => "shareAPISupported" in obj, get: obj => obj.shareAPISupported, set: (obj, value) => { obj.shareAPISupported = value; } }, metadata: _metadata }, _shareAPISupported_initializers, _shareAPISupported_extraInitializers);
61
+ __esDecorate(null, null, _canShare_decorators, { kind: "field", name: "canShare", static: false, private: false, access: { has: obj => "canShare" in obj, get: obj => obj.canShare, set: (obj, value) => { obj.canShare = value; } }, metadata: _metadata }, _canShare_initializers, _canShare_extraInitializers);
62
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
63
+ }
14
64
  /**
15
65
  * Observable holding the current canvas image data URL.
16
- * @zui
17
66
  */
18
- this.canvasImage = new Observable('');
67
+ canvasImage = __runInitializers(this, _canvasImage_initializers, new Observable(''));
19
68
  /**
20
69
  * Observable indicating whether the Share API is supported in the current environment.
21
- * @zui
22
70
  */
23
- this.shareAPISupported = new Observable('share' in navigator);
71
+ shareAPISupported = (__runInitializers(this, _canvasImage_extraInitializers), __runInitializers(this, _shareAPISupported_initializers, new Observable('share' in navigator)));
24
72
  /**
25
73
  * Observable determining if the current canvas content can be shared.
26
- * @zui
27
74
  */
28
- this.canShare = new Observable(false);
75
+ canShare = (__runInitializers(this, _shareAPISupported_extraInitializers), __runInitializers(this, _canShare_initializers, new Observable(false)));
29
76
  /**
30
77
  * Observable containing the canvas image as a File object.
31
78
  */
32
- this.canvasFile = new Observable(null);
79
+ canvasFile = (__runInitializers(this, _canShare_extraInitializers), new Observable(null));
33
80
  /**
34
81
  * Observable storing the file name for the snapshot.
35
82
  * Updates the file upon change.
36
83
  */
37
- this.fileName = new Observable('canvas', fileName => this.updateFile());
84
+ fileName = new Observable('canvas', fileName => this.updateFile());
38
85
  /**
39
86
  * Observable holding the text content to be shared with the snapshot.
40
87
  */
41
- this.text = new Observable('Check this out!');
88
+ text = new Observable('Check this out!');
42
89
  /**
43
90
  * Observable containing the title for the snapshot.
44
91
  */
45
- this.title = new Observable('Canvas');
92
+ title = new Observable('Canvas');
46
93
  /**
47
94
  * Observable storing the file type for the snapshot (e.g., 'image/png').
48
95
  * Updates the file upon change.
49
96
  */
50
- this.fileType = new Observable('image/png', fileType => this.updateFile());
97
+ fileType = new Observable('image/png', fileType => this.updateFile());
51
98
  /**
52
99
  * Observable representing the quality setting of the snapshot image.
53
100
  */
54
- this.quality = new Observable(0.92);
101
+ quality = new Observable(0.92);
102
+ /**
103
+ * Creates an instance of SnapshotContext.
104
+ * @param contextManager - The current ContextManager
105
+ */
106
+ constructor(contextManager) {
107
+ super(contextManager, {});
108
+ this.canvasImage.addListener(this.updateFile);
109
+ }
55
110
  /**
56
111
  * Converts the canvas image to a file.
57
112
  */
58
- this.updateFile = async () => {
113
+ updateFile = async () => {
59
114
  if (!this.canvasImage.value)
60
115
  return;
61
116
  const response = await fetch(this.canvasImage.value);
@@ -69,9 +124,9 @@ export class SnapshotContext extends Context {
69
124
  });
70
125
  this.canvasFile.value = file;
71
126
  };
72
- this.canvasImage.addListener(this.updateFile);
73
- }
74
- }
127
+ };
128
+ })();
129
+ export { SnapshotContext };
75
130
  /**
76
131
  * Retrieves the current canvas image as a data URL.
77
132
  * @param ctx The ContextManager instance to access the SnapshotContext.
@@ -1,5 +1,5 @@
1
1
  import { Component } from '../component';
2
- import { ContextManager, Context } from '../context';
2
+ import { Context, ContextManager } from '../context';
3
3
  import { Event } from '../event';
4
4
  /**
5
5
  * Manages and tracks tags associated with components.
@@ -9,11 +9,11 @@ export declare class TagContext extends Context {
9
9
  /**
10
10
  * A map storing the relationship between components and their associated tags.
11
11
  */
12
- readonly tagsByComponent: Map<Component<any, import("../component").ConstructorProps>, Set<string>>;
12
+ readonly tagsByComponent: Map<Component<any, import("..").ConstructorProps>, Set<string>>;
13
13
  /**
14
14
  * A map storing the relationship between local tags and their associated components.
15
15
  */
16
- readonly componentsByLocalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
16
+ readonly componentsByLocalTag: Map<string, Set<Component<any, import("..").ConstructorProps>>>;
17
17
  /**
18
18
  * An event that's emitted when the set of components that constitute a tag changes.
19
19
  */
@@ -57,11 +57,11 @@ export declare class TagContext extends Context {
57
57
  * @param tag The tag to search for.
58
58
  * @returns A set of components associated with the specified tag.
59
59
  */
60
- export declare function getComponentsByTag(mgr: ContextManager, tag: string): Set<Component<any, import("../component").ConstructorProps>>;
60
+ export declare function getComponentsByTag(mgr: ContextManager, tag: string): Set<Component<any, import("..").ConstructorProps>>;
61
61
  /**
62
62
  * Retrieves components associated with a list of tags.
63
63
  * @param mgr The ContextManager instance to access the TagContext.
64
64
  * @param tags An array of tags to search for.
65
65
  * @returns A set of components associated with the specified tags.
66
66
  */
67
- export declare function getComponentsByTags(mgr: ContextManager, tags: string[]): Set<Component<any, import("../component").ConstructorProps>>;
67
+ export declare function getComponentsByTags(mgr: ContextManager, tags: string[]): Set<Component<any, import("..").ConstructorProps>>;
@@ -6,26 +6,26 @@ import { GlobalTagContext } from './globaltagcontext';
6
6
  * @zcontext
7
7
  */
8
8
  export class TagContext extends Context {
9
+ /**
10
+ * A map storing the relationship between components and their associated tags.
11
+ */
12
+ tagsByComponent = new Map();
13
+ /**
14
+ * A map storing the relationship between local tags and their associated components.
15
+ */
16
+ componentsByLocalTag = new Map();
17
+ /**
18
+ * An event that's emitted when the set of components that constitute a tag changes.
19
+ */
20
+ onTagChange = new Event();
21
+ _global = this.contextManager.get(GlobalTagContext);
9
22
  constructor(contextManager) {
10
23
  super(contextManager, {});
11
- /**
12
- * A map storing the relationship between components and their associated tags.
13
- */
14
- this.tagsByComponent = new Map();
15
- /**
16
- * A map storing the relationship between local tags and their associated components.
17
- */
18
- this.componentsByLocalTag = new Map();
19
- /**
20
- * An event that's emitted when the set of components that constitute a tag changes.
21
- */
22
- this.onTagChange = new Event();
23
- this._global = this.contextManager.get(GlobalTagContext);
24
- this._globalTagChange = (tag) => {
25
- this.onTagChange.emit(tag);
26
- };
27
24
  this._global.onTagChange.addListener(this._globalTagChange);
28
25
  }
26
+ _globalTagChange = (tag) => {
27
+ this.onTagChange.emit(tag);
28
+ };
29
29
  /**
30
30
  * Registers a component with specified tags.
31
31
  * Updates both local and global tag maps accordingly.
@@ -1,4 +1,4 @@
1
- import { ContextManager, Context } from '../context';
1
+ import { Context, ContextManager } from '../context';
2
2
  /**
3
3
  * Manages the display of text alerts.
4
4
  * @zcontext
@@ -12,10 +12,6 @@ export declare class TextAlertContext extends Context {
12
12
  constructor(contextManager: ContextManager);
13
13
  /**
14
14
  * Displays a text alert with specified options.
15
- * @zprop
16
- * @param txt The text content for the alert.
17
- * @param options Optional configuration for the text alert appearance and behavior.
18
- * @returns An object that allows for manually closing the text alert
19
15
  */
20
16
  showTextAlert(txt: string, options?: TextAlertOptions): {
21
17
  close: () => void;
@@ -5,13 +5,13 @@ import { useOverlay } from './canvascontext';
5
5
  * @zcontext
6
6
  */
7
7
  export class TextAlertContext extends Context {
8
+ _container = document.createElement('div');
8
9
  /**
9
10
  * Creates an instance of TextAlertContext.
10
11
  * @param contextManager - The current ContextManager
11
12
  */
12
13
  constructor(contextManager) {
13
14
  super(contextManager, {});
14
- this._container = document.createElement('div');
15
15
  this._container.classList.add('zcomponent-textalert-container');
16
16
  useOverlay(contextManager).addListener(val => {
17
17
  val.appendChild(this._container);
@@ -19,10 +19,6 @@ export class TextAlertContext extends Context {
19
19
  }
20
20
  /**
21
21
  * Displays a text alert with specified options.
22
- * @zprop
23
- * @param txt The text content for the alert.
24
- * @param options Optional configuration for the text alert appearance and behavior.
25
- * @returns An object that allows for manually closing the text alert
26
22
  */
27
23
  showTextAlert(txt, options) {
28
24
  const entry = document.createElement('div');
@@ -1,4 +1,4 @@
1
- import { ContextManager, Context } from '../context';
1
+ import { Context, ContextManager } from '../context';
2
2
  import { Event as EventClass } from '../event';
3
3
  import { Observable } from '../observable';
4
4
  /**