@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
@@ -4,72 +4,72 @@ import { isDesignTime } from './environmentcontext';
4
4
  /**
5
5
  * Represents the axes of a gamepad.
6
6
  */
7
- export var GamepadAxis;
8
- (function (GamepadAxis) {
9
- GamepadAxis["LeftStickHorizontal"] = "LeftStickHorizontal";
10
- GamepadAxis["LeftStickVertical"] = "LeftStickVertical";
11
- GamepadAxis["RightStickHorizontal"] = "RightStickHorizontal";
12
- GamepadAxis["RightStickVertical"] = "RightStickVertical";
13
- })(GamepadAxis || (GamepadAxis = {}));
7
+ export const GamepadAxis = {
8
+ LeftStickHorizontal: 'LeftStickHorizontal',
9
+ LeftStickVertical: 'LeftStickVertical',
10
+ RightStickHorizontal: 'RightStickHorizontal',
11
+ RightStickVertical: 'RightStickVertical',
12
+ };
13
+ Object.freeze(GamepadAxis);
14
14
  /**
15
15
  * Represents the buttons on a gamepad.
16
16
  */
17
- export var GamepadButton;
18
- (function (GamepadButton) {
19
- GamepadButton["South"] = "South";
20
- GamepadButton["East"] = "East";
21
- GamepadButton["West"] = "West";
22
- GamepadButton["North"] = "North";
23
- GamepadButton["ShoulderLeft"] = "ShoulderLeft";
24
- GamepadButton["ShoulderRight"] = "ShoulderRight";
25
- GamepadButton["TriggerLeft"] = "TriggerLeft";
26
- GamepadButton["TriggerRight"] = "TriggerRight";
27
- GamepadButton["Select"] = "Select";
28
- GamepadButton["Start"] = "Start";
29
- GamepadButton["StickLeft"] = "StickLeft";
30
- GamepadButton["StickRight"] = "StickRight";
31
- GamepadButton["DUp"] = "DUp";
32
- GamepadButton["DDown"] = "DDown";
33
- GamepadButton["DLeft"] = "DLeft";
34
- GamepadButton["DRight"] = "DRight";
35
- GamepadButton["Center"] = "Center";
36
- })(GamepadButton || (GamepadButton = {}));
17
+ export const GamepadButton = {
18
+ South: 'South',
19
+ East: 'East',
20
+ West: 'West',
21
+ North: 'North',
22
+ ShoulderLeft: 'ShoulderLeft',
23
+ ShoulderRight: 'ShoulderRight',
24
+ TriggerLeft: 'TriggerLeft',
25
+ TriggerRight: 'TriggerRight',
26
+ Select: 'Select',
27
+ Start: 'Start',
28
+ StickLeft: 'StickLeft',
29
+ StickRight: 'StickRight',
30
+ DUp: 'DUp',
31
+ DDown: 'DDown',
32
+ DLeft: 'DLeft',
33
+ DRight: 'DRight',
34
+ Center: 'Center',
35
+ };
36
+ Object.freeze(GamepadButton);
37
37
  /**
38
38
  * Manages and tracks gamepad connections and states.
39
39
  * @zcontext
40
40
  */
41
41
  export class GamepadContext extends Context {
42
+ onGamepadsChange = new Event();
43
+ activeGamepads = new Set();
44
+ _registeredGamepads = new Map();
42
45
  /**
43
46
  * Creates an instance of GamepadContext.
44
47
  * @param contextManager - The current ContextManager
45
48
  */
46
49
  constructor(contextManager) {
47
50
  super(contextManager, {});
48
- this.onGamepadsChange = new Event();
49
- this.activeGamepads = new Set();
50
- this._registeredGamepads = new Map();
51
- this._update = () => {
52
- const gamepads = navigator.getGamepads();
53
- let changes = false;
54
- for (let i = 0; i < gamepads.length; i++) {
55
- if (gamepads[i] === null && this.activeGamepads.has(i)) {
56
- this.activeGamepads.delete(i);
57
- changes = true;
58
- }
59
- else if (gamepads[i] !== null && !this.activeGamepads.has(i)) {
60
- this.activeGamepads.add(i);
61
- changes = true;
62
- }
63
- }
64
- if (changes)
65
- this.onGamepadsChange.emit();
66
- };
67
51
  if (!isDesignTime(contextManager) && typeof navigator.getGamepads === 'function') {
68
52
  window.addEventListener('gamepadconnected', this._update);
69
53
  window.addEventListener('gamepaddisconnected', this._update);
70
54
  }
71
55
  this._update();
72
56
  }
57
+ _update = () => {
58
+ const gamepads = navigator.getGamepads();
59
+ let changes = false;
60
+ for (let i = 0; i < gamepads.length; i++) {
61
+ if (gamepads[i] === null && this.activeGamepads.has(i)) {
62
+ this.activeGamepads.delete(i);
63
+ changes = true;
64
+ }
65
+ else if (gamepads[i] !== null && !this.activeGamepads.has(i)) {
66
+ this.activeGamepads.add(i);
67
+ changes = true;
68
+ }
69
+ }
70
+ if (changes)
71
+ this.onGamepadsChange.emit();
72
+ };
73
73
  /**
74
74
  * Retrieves a gamepad instance by its index.
75
75
  * @param indx The index of the gamepad.
@@ -1,12 +1,13 @@
1
- import { Context, ContextManager, Event, Observable } from '../index';
1
+ import { Context, ContextManager, Event, Observable, ValueOf } from '../index';
2
2
  /**
3
3
  * Defines the modes for interpreting touch gestures.
4
4
  */
5
- export declare enum GestureMode {
6
- ScaleOnly = "Scale Only",
7
- RotateOnly = "Rotate Only",
8
- ScaleRotate = "Scale Rotate"
9
- }
5
+ export declare const GestureMode: {
6
+ readonly ScaleOnly: "Scale Only";
7
+ readonly RotateOnly: "Rotate Only";
8
+ readonly ScaleRotate: "Scale Rotate";
9
+ };
10
+ export type GestureModeValue = ValueOf<typeof GestureMode>;
10
11
  /**
11
12
  * Configuration options for GestureContext construction.
12
13
  */
@@ -24,12 +25,33 @@ interface ConstructionProps {
24
25
  **/
25
26
  export declare class GestureContext extends Context<ConstructionProps> {
26
27
  private element;
28
+ /**
29
+ * @default true
30
+ */
27
31
  private canScale;
32
+ /**
33
+ * @default "Scale Rotate"
34
+ */
28
35
  private gestureMode;
36
+ /**
37
+ * @default true
38
+ */
29
39
  private canRotate;
40
+ /**
41
+ * @default null
42
+ */
30
43
  private initialDistance;
44
+ /**
45
+ * @default null
46
+ */
31
47
  private initialAngle;
48
+ /**
49
+ * @default true
50
+ */
32
51
  private oneFingerRotateMode;
52
+ /**
53
+ * @default null
54
+ */
33
55
  private initialTouchX;
34
56
  /**
35
57
  * Observable representing the current rotation value.
@@ -54,14 +76,17 @@ export declare class GestureContext extends Context<ConstructionProps> {
54
76
  enabled: Observable<boolean, never>;
55
77
  /**
56
78
  * Minimum scale factor. Defaults to 0.5.
79
+ * @default 0.5
57
80
  */
58
81
  minScale: number;
59
82
  /**
60
83
  * Maximum scale factor. Defaults to 2.
84
+ * @default 2
61
85
  */
62
86
  maxScale: number;
63
87
  /**
64
88
  * Sensitivity of rotation. Defaults to 1.
89
+ * @default 1
65
90
  */
66
91
  rotationSensitivity: number;
67
92
  /**
@@ -1,19 +1,84 @@
1
- import { Context, Event, Observable, useCanvas, isDevelopmentBuild, isEditTime } from '../index';
1
+ import { Context, Event, isDevelopmentBuild, isEditTime, Observable, useCanvas } from '../index';
2
2
  /**
3
3
  * Defines the modes for interpreting touch gestures.
4
4
  */
5
- export var GestureMode;
6
- (function (GestureMode) {
7
- GestureMode["ScaleOnly"] = "Scale Only";
8
- GestureMode["RotateOnly"] = "Rotate Only";
9
- GestureMode["ScaleRotate"] = "Scale Rotate";
10
- })(GestureMode || (GestureMode = {}));
5
+ export const GestureMode = {
6
+ ScaleOnly: 'Scale Only',
7
+ RotateOnly: 'Rotate Only',
8
+ ScaleRotate: 'Scale Rotate',
9
+ };
10
+ Object.freeze(GestureMode);
11
11
  /**
12
12
  * Manages touch gestures for scaling and rotating elements.
13
13
  * @deprecated Use the GestureTransform component instead. This context will be removed in the next major version.
14
14
  * @zcontext
15
15
  **/
16
16
  export class GestureContext extends Context {
17
+ element;
18
+ /**
19
+ * @default true
20
+ */
21
+ canScale = true;
22
+ /**
23
+ * @default "Scale Rotate"
24
+ */
25
+ gestureMode = GestureMode.ScaleRotate;
26
+ /**
27
+ * @default true
28
+ */
29
+ canRotate = true;
30
+ /**
31
+ * @default null
32
+ */
33
+ initialDistance = null;
34
+ /**
35
+ * @default null
36
+ */
37
+ initialAngle = null;
38
+ /**
39
+ * @default true
40
+ */
41
+ oneFingerRotateMode = true;
42
+ /**
43
+ * @default null
44
+ */
45
+ initialTouchX = null;
46
+ /**
47
+ * Observable representing the current rotation value.
48
+ */
49
+ rotation = new Observable(0);
50
+ /**
51
+ * Observable representing the current scale value.
52
+ */
53
+ scale = new Observable(0);
54
+ /**
55
+ * Event triggered when rotation occurs.
56
+ */
57
+ onRotate = new Event();
58
+ /**
59
+ * Event triggered when scaling occurs.
60
+ */
61
+ onScale = new Event();
62
+ /**
63
+ * Observable indicating whether gesture interactions are enabled.
64
+ * Defaults to true.
65
+ */
66
+ enabled = new Observable(true);
67
+ /**
68
+ * Minimum scale factor. Defaults to 0.5.
69
+ * @default 0.5
70
+ */
71
+ minScale = 0.5;
72
+ /**
73
+ * Maximum scale factor. Defaults to 2.
74
+ * @default 2
75
+ */
76
+ maxScale = 2;
77
+ /**
78
+ * Sensitivity of rotation. Defaults to 1.
79
+ * @default 1
80
+ */
81
+ rotationSensitivity = 1;
17
82
  /**
18
83
  * Creates an instance of GestureContext.
19
84
  * @param contextManager - The current ContextManager
@@ -21,84 +86,6 @@ export class GestureContext extends Context {
21
86
  */
22
87
  constructor(contextManager, constructorProps) {
23
88
  super(contextManager, constructorProps);
24
- this.canScale = true;
25
- this.gestureMode = GestureMode.ScaleRotate;
26
- this.canRotate = true;
27
- this.initialDistance = null;
28
- this.initialAngle = null;
29
- this.oneFingerRotateMode = true;
30
- this.initialTouchX = null;
31
- /**
32
- * Observable representing the current rotation value.
33
- */
34
- this.rotation = new Observable(0);
35
- /**
36
- * Observable representing the current scale value.
37
- */
38
- this.scale = new Observable(0);
39
- /**
40
- * Event triggered when rotation occurs.
41
- */
42
- this.onRotate = new Event();
43
- /**
44
- * Event triggered when scaling occurs.
45
- */
46
- this.onScale = new Event();
47
- /**
48
- * Observable indicating whether gesture interactions are enabled.
49
- * Defaults to true.
50
- */
51
- this.enabled = new Observable(true);
52
- /**
53
- * Minimum scale factor. Defaults to 0.5.
54
- */
55
- this.minScale = 0.5;
56
- /**
57
- * Maximum scale factor. Defaults to 2.
58
- */
59
- this.maxScale = 2;
60
- /**
61
- * Sensitivity of rotation. Defaults to 1.
62
- */
63
- this.rotationSensitivity = 1;
64
- this.onTouchStart = (event) => {
65
- if (this.oneFingerRotateMode && event.touches.length === 1) {
66
- this.initialTouchX = event.touches[0].pageX;
67
- }
68
- else if (event.touches.length === 2) {
69
- this.initialDistance = this.getDistanceBetweenTouches(event.touches);
70
- this.initialAngle = this.getAngleBetweenTouches(event.touches);
71
- }
72
- };
73
- this.onTouchMove = (event) => {
74
- switch (this.gestureMode) {
75
- case GestureMode.ScaleOnly:
76
- if (event.touches.length === 2) {
77
- this.handleScale(event);
78
- }
79
- break;
80
- case GestureMode.RotateOnly:
81
- if (this.oneFingerRotateMode && event.touches.length === 1) {
82
- this.handleOneFingerRotate(event);
83
- }
84
- else if (event.touches.length === 2) {
85
- this.handleRotate(event);
86
- }
87
- break;
88
- case GestureMode.ScaleRotate:
89
- if (this.oneFingerRotateMode && event.touches.length === 1) {
90
- this.handleOneFingerRotate(event);
91
- }
92
- else if (event.touches.length === 2) {
93
- this.handleTwoFingerGestures(event);
94
- }
95
- break;
96
- }
97
- };
98
- this.onTouchEnd = (event) => {
99
- this.initialDistance = null;
100
- this.initialAngle = null;
101
- };
102
89
  if (isDevelopmentBuild(contextManager) || isEditTime(contextManager)) {
103
90
  console.warn('GestureContext is deprecated. Please use the GestureTransform component instead. GestureContext will be removed in the next major version.');
104
91
  }
@@ -112,6 +99,40 @@ export class GestureContext extends Context {
112
99
  }
113
100
  }, undefined, true);
114
101
  }
102
+ onTouchStart = (event) => {
103
+ if (this.oneFingerRotateMode && event.touches.length === 1) {
104
+ this.initialTouchX = event.touches[0].pageX;
105
+ }
106
+ else if (event.touches.length === 2) {
107
+ this.initialDistance = this.getDistanceBetweenTouches(event.touches);
108
+ this.initialAngle = this.getAngleBetweenTouches(event.touches);
109
+ }
110
+ };
111
+ onTouchMove = (event) => {
112
+ switch (this.gestureMode) {
113
+ case GestureMode.ScaleOnly:
114
+ if (event.touches.length === 2) {
115
+ this.handleScale(event);
116
+ }
117
+ break;
118
+ case GestureMode.RotateOnly:
119
+ if (this.oneFingerRotateMode && event.touches.length === 1) {
120
+ this.handleOneFingerRotate(event);
121
+ }
122
+ else if (event.touches.length === 2) {
123
+ this.handleRotate(event);
124
+ }
125
+ break;
126
+ case GestureMode.ScaleRotate:
127
+ if (this.oneFingerRotateMode && event.touches.length === 1) {
128
+ this.handleOneFingerRotate(event);
129
+ }
130
+ else if (event.touches.length === 2) {
131
+ this.handleTwoFingerGestures(event);
132
+ }
133
+ break;
134
+ }
135
+ };
115
136
  handleOneFingerRotate(event) {
116
137
  if (this.initialTouchX !== null) {
117
138
  const currentTouchX = event.touches[0].pageX;
@@ -141,6 +162,10 @@ export class GestureContext extends Context {
141
162
  this.rotation.value = -rotateAmount;
142
163
  }
143
164
  }
165
+ onTouchEnd = (event) => {
166
+ this.initialDistance = null;
167
+ this.initialAngle = null;
168
+ };
144
169
  getDistanceBetweenTouches(touches) {
145
170
  const dx = touches[0].pageX - touches[1].pageX;
146
171
  const dy = touches[0].pageY - touches[1].pageY;
@@ -9,7 +9,7 @@ export declare class GlobalTagContext extends Context {
9
9
  /**
10
10
  * A map storing the relationship between global tags and sets of components.
11
11
  */
12
- readonly componentsByGlobalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
12
+ readonly componentsByGlobalTag: Map<string, Set<Component<any, import("..").ConstructorProps>>>;
13
13
  /**
14
14
  * An event that's emitted when the set of components that constitute a tag changes.
15
15
  */
@@ -5,15 +5,12 @@ import { Event } from '../event';
5
5
  * @zcontext
6
6
  */
7
7
  export class GlobalTagContext extends Context {
8
- constructor() {
9
- super(...arguments);
10
- /**
11
- * A map storing the relationship between global tags and sets of components.
12
- */
13
- this.componentsByGlobalTag = new Map();
14
- /**
15
- * An event that's emitted when the set of components that constitute a tag changes.
16
- */
17
- this.onTagChange = new Event();
18
- }
8
+ /**
9
+ * A map storing the relationship between global tags and sets of components.
10
+ */
11
+ componentsByGlobalTag = new Map();
12
+ /**
13
+ * An event that's emitted when the set of components that constitute a tag changes.
14
+ */
15
+ onTagChange = new Event();
19
16
  }
@@ -1,4 +1,5 @@
1
- import { ContextManager, Context } from '../context';
1
+ import { Context, ContextManager } from '../context';
2
+ import { Entity } from '../entity';
2
3
  import { Observable } from '../observable';
3
4
  /**
4
5
  * LoadContext exposes to components and behaviors key moments during the initialization of the experience,
@@ -31,31 +32,26 @@ export declare class LoadContext extends Context {
31
32
  /**
32
33
  * Observable indicating whether the root component's construction is complete.
33
34
  * This is typically set to true immediately after the root component and its children are constructed.
34
- * @zui
35
35
  */
36
36
  readonly isConstructed: Observable<boolean, never>;
37
37
  /**
38
38
  * Observable indicating whether all loadable processes have completed.
39
39
  * This is true when all assets and dependencies required for the experience are fully loaded.
40
- * @zui
41
40
  */
42
41
  readonly isLoaded: Observable<boolean, never>;
43
42
  /**
44
43
  * Observable indicating whether the experience has started.
45
44
  * This becomes true at the point where the experience transitions from loading to active interaction.
46
- * @zui
47
45
  */
48
46
  readonly isStarted: Observable<boolean, never>;
49
47
  /**
50
48
  * Observable indicating whether the experience has been launched.
51
49
  * This is set to true typically when the user interacts with a splash screen or an initial launch button.
52
- * @zui
53
50
  */
54
51
  readonly isLaunched: Observable<boolean, never>;
55
52
  /**
56
53
  * Observable representing the progress percentage of loadable processes.
57
54
  * This provides a numerical value representing the completion percentage of all loading operations.
58
- * @zui
59
55
  */
60
56
  readonly progressPercent: Observable<number, never>;
61
57
  private _startedResolved;
@@ -65,8 +61,17 @@ export declare class LoadContext extends Context {
65
61
  private _launchedResolved;
66
62
  readonly launched: Promise<void>;
67
63
  private _loadables;
64
+ /**
65
+ * @default false
66
+ */
68
67
  private _startWhenLoaded;
68
+ /**
69
+ * @default 0
70
+ */
69
71
  private _totalLoadables;
72
+ /**
73
+ * @default 0
74
+ */
70
75
  private _loadedCount;
71
76
  /**
72
77
  * Start the experience.
@@ -88,7 +93,7 @@ export declare class LoadContext extends Context {
88
93
  /**
89
94
  * Register a loadable process.
90
95
  */
91
- registerLoadable(p: Promise<any>): void;
96
+ registerLoadable(p: Promise<any>, entity?: Entity): void;
92
97
  }
93
98
  /**
94
99
  * Returns an observable that indicates whether the experience is loaded.
@@ -129,7 +134,7 @@ export declare function useLoadPercent(mgr: ContextManager): Observable<number,
129
134
  /**
130
135
  * Register a loadable process.
131
136
  */
132
- export declare function registerLoadable(mgr: ContextManager, p: Promise<any>): void;
137
+ export declare function registerLoadable(mgr: ContextManager | Entity, p: Promise<any>): void;
133
138
  /**
134
139
  * Starts the experience.
135
140
  */
@@ -159,3 +164,35 @@ export declare function launched(mgr: ContextManager): Promise<void>;
159
164
  * Marks the root component's constructor (and thus any recursive children) as finished.
160
165
  */
161
166
  export declare function constructionComplete(mgr: ContextManager): void;
167
+ /**
168
+ * A decorator that registers its decorated function as a loadable process, and
169
+ * (by default) invokes it automatically once the experience has finished constructing.
170
+ *
171
+ * The loader will wait for the returned promise to resolve before hiding itself.
172
+ * The loadable is registered synchronously during construction so that `isLoaded`
173
+ * reflects the pending work from the moment the entity exists; the actual method
174
+ * call is deferred until after the full construction tree settles, so any fields
175
+ * assigned in subclass constructor bodies are available when it runs.
176
+ *
177
+ * Mirrors the structure of {@link zOnConstructed}, {@link zOnStart}, and {@link zOnLaunch};
178
+ * the only difference is that `zLoad` also registers the deferred work as a loadable.
179
+ *
180
+ * @param autoInvoke - If true (default), the method fires automatically after construction.
181
+ * If false, the method must be called manually but will still register as a loadable.
182
+ */
183
+ export declare function zLoad<EntityType extends Entity>(autoInvoke?: boolean): (originalMethod: (...args: any) => Promise<any>, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => Promise<any>>) => (this: EntityType, ...args: any[]) => Promise<any>;
184
+ /**
185
+ * A decorator that will automatically call its decorated function when the experience has been started.
186
+ */
187
+ export declare function zOnStart<EntityType extends Entity>(): (originalMethod: (...args: [
188
+ ]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;
189
+ /**
190
+ * A decorator that will automatically call its decorated function when the experience has been constructed.
191
+ */
192
+ export declare function zOnConstructed<EntityType extends Entity>(): (originalMethod: (...args: [
193
+ ]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;
194
+ /**
195
+ * A decorator that will automatically call its decorated function when the experience has been launched.
196
+ */
197
+ export declare function zOnLaunch<EntityType extends Entity>(): (originalMethod: (...args: [
198
+ ]) => any, context: ClassMethodDecoratorContext<EntityType>) => any;