@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,30 +1,34 @@
1
- import { ContextManager, Context } from '../context';
1
+ import { Context, ContextManager } from '../context';
2
2
  import { Observable } from '../observable';
3
+ import { ValueOf } from '../types';
3
4
  /**
4
- * Enum representing the overall status of the cookie consent process: 'unknown', 'initializing', 'initialized'.
5
+ * Representing the overall status of the cookie consent process: 'unknown', 'initializing', 'initialized'.
5
6
  */
6
- export declare enum Status {
7
- 'unknown' = "unknown",
8
- 'initializing' = "initializing",
9
- 'initialized' = "initialized"
10
- }
7
+ export declare const Status: {
8
+ readonly unknown: "unknown";
9
+ readonly initializing: "initializing";
10
+ readonly initialized: "initialized";
11
+ };
12
+ export type StatusValue = ValueOf<typeof Status>;
11
13
  /**
12
- * Enum representing the consent status for different types of cookies: 'unknown', 'granted', 'rejected'.
14
+ * Representing the consent status for different types of cookies: 'unknown', 'granted', 'rejected'.
13
15
  */
14
- export declare enum ConsentStatus {
15
- 'unknown' = "unknown",
16
- 'granted' = "granted",
17
- 'rejected' = "rejected"
18
- }
16
+ export declare const ConsentStatus: {
17
+ readonly unknown: "unknown";
18
+ readonly granted: "granted";
19
+ readonly rejected: "rejected";
20
+ };
21
+ export type ConsentStatusValue = ValueOf<typeof ConsentStatus>;
19
22
  /**
20
- * Enum representing different types of cookies: 'essential', 'functional', 'performance', 'marketing'.
23
+ * Representing different types of cookies: 'essential', 'functional', 'performance', 'marketing'.
21
24
  */
22
- export declare enum CookieType {
23
- 'essential' = "essential",
24
- 'functional' = "functional",
25
- 'performance' = "performance",
26
- 'marketing' = "marketing"
27
- }
25
+ export declare const CookieType: {
26
+ readonly essential: "essential";
27
+ readonly functional: "functional";
28
+ readonly performance: "performance";
29
+ readonly marketing: "marketing";
30
+ };
31
+ export type CookieTypeValue = ValueOf<typeof CookieType>;
28
32
  /**
29
33
  * Defines the structure of a vendor's information including name, description, and privacy policy URL.
30
34
  */
@@ -45,12 +49,18 @@ export interface Vendor {
45
49
  * @zcontext
46
50
  */
47
51
  export declare class CookieConsentContext extends Context {
48
- readonly status: Observable<Status, never>;
49
- readonly functionalCookies: Observable<ConsentStatus, never>;
50
- readonly performanceCookies: Observable<ConsentStatus, never>;
51
- readonly marketingCookies: Observable<ConsentStatus, never>;
52
+ readonly status: Observable<StatusValue, never>;
53
+ readonly functionalCookies: Observable<ConsentStatusValue, never>;
54
+ readonly performanceCookies: Observable<ConsentStatusValue, never>;
55
+ readonly marketingCookies: Observable<ConsentStatusValue, never>;
52
56
  readonly showSettings: Observable<(() => void) | undefined, never>;
57
+ /**
58
+ * @default []
59
+ */
53
60
  readonly performanceVendors: Vendor[];
61
+ /**
62
+ * @default []
63
+ */
54
64
  readonly marketingVendors: Vendor[];
55
65
  /**
56
66
  * Registers a performance vendor.
@@ -66,25 +76,25 @@ export declare class CookieConsentContext extends Context {
66
76
  * @param {ContextManager} mgr The context manager instance.
67
77
  * @returns {Observable<ConsentStatus>} The observable representing the consent status of functional cookies.
68
78
  */
69
- export declare function useCookieConsentFunctional(mgr: ContextManager): Observable<ConsentStatus, never>;
79
+ export declare function useCookieConsentFunctional(mgr: ContextManager): Observable<ConsentStatusValue, never>;
70
80
  /**
71
81
  * Retrieves the consent status for performance cookies.
72
82
  * @param {ContextManager} mgr The context manager instance.
73
83
  * @returns {Observable<ConsentStatus>} The observable representing the consent status of performance cookies.
74
84
  */
75
- export declare function useCookieConsentPerformance(mgr: ContextManager): Observable<ConsentStatus, never>;
85
+ export declare function useCookieConsentPerformance(mgr: ContextManager): Observable<ConsentStatusValue, never>;
76
86
  /**
77
87
  * Retrieves the consent status for marketing cookies.
78
88
  * @param {ContextManager} mgr The context manager instance.
79
89
  * @returns {Observable<ConsentStatus>} The observable representing the consent status of marketing cookies.
80
90
  */
81
- export declare function useCookieConsentMarketing(mgr: ContextManager): Observable<ConsentStatus, never>;
91
+ export declare function useCookieConsentMarketing(mgr: ContextManager): Observable<ConsentStatusValue, never>;
82
92
  /**
83
93
  * Retrieves the overall cookie consent status.
84
94
  * @param {ContextManager} mgr The context manager instance.
85
95
  * @returns {Observable<Status>} The observable representing the overall cookie consent status.
86
96
  */
87
- export declare function useCookieConsentStatus(mgr: ContextManager): Observable<Status, never>;
97
+ export declare function useCookieConsentStatus(mgr: ContextManager): Observable<StatusValue, never>;
88
98
  /**
89
99
  * Registers a performance vendor in the `CookieConsentContext`.
90
100
  * @param {ContextManager} mgr The context manager instance.
@@ -1,33 +1,33 @@
1
1
  import { Context } from '../context';
2
2
  import { Observable } from '../observable';
3
3
  /**
4
- * Enum representing the overall status of the cookie consent process: 'unknown', 'initializing', 'initialized'.
4
+ * Representing the overall status of the cookie consent process: 'unknown', 'initializing', 'initialized'.
5
5
  */
6
- export var Status;
7
- (function (Status) {
8
- Status["unknown"] = "unknown";
9
- Status["initializing"] = "initializing";
10
- Status["initialized"] = "initialized";
11
- })(Status || (Status = {}));
6
+ export const Status = {
7
+ unknown: 'unknown',
8
+ initializing: 'initializing',
9
+ initialized: 'initialized',
10
+ };
11
+ Object.freeze(Status);
12
12
  /**
13
- * Enum representing the consent status for different types of cookies: 'unknown', 'granted', 'rejected'.
13
+ * Representing the consent status for different types of cookies: 'unknown', 'granted', 'rejected'.
14
14
  */
15
- export var ConsentStatus;
16
- (function (ConsentStatus) {
17
- ConsentStatus["unknown"] = "unknown";
18
- ConsentStatus["granted"] = "granted";
19
- ConsentStatus["rejected"] = "rejected";
20
- })(ConsentStatus || (ConsentStatus = {}));
15
+ export const ConsentStatus = {
16
+ unknown: 'unknown',
17
+ granted: 'granted',
18
+ rejected: 'rejected',
19
+ };
20
+ Object.freeze(ConsentStatus);
21
21
  /**
22
- * Enum representing different types of cookies: 'essential', 'functional', 'performance', 'marketing'.
22
+ * Representing different types of cookies: 'essential', 'functional', 'performance', 'marketing'.
23
23
  */
24
- export var CookieType;
25
- (function (CookieType) {
26
- CookieType["essential"] = "essential";
27
- CookieType["functional"] = "functional";
28
- CookieType["performance"] = "performance";
29
- CookieType["marketing"] = "marketing";
30
- })(CookieType || (CookieType = {}));
24
+ export const CookieType = {
25
+ essential: 'essential',
26
+ functional: 'functional',
27
+ performance: 'performance',
28
+ marketing: 'marketing',
29
+ };
30
+ Object.freeze(CookieType);
31
31
  /**
32
32
  * Manages the state and information related to cookie consent within a context.
33
33
  * - `status`: Observable representing the overall status of the cookie consent.
@@ -40,16 +40,19 @@ export var CookieType;
40
40
  * @zcontext
41
41
  */
42
42
  export class CookieConsentContext extends Context {
43
- constructor() {
44
- super(...arguments);
45
- this.status = new Observable(Status.unknown);
46
- this.functionalCookies = new Observable(ConsentStatus.unknown);
47
- this.performanceCookies = new Observable(ConsentStatus.unknown);
48
- this.marketingCookies = new Observable(ConsentStatus.unknown);
49
- this.showSettings = new Observable(undefined);
50
- this.performanceVendors = [];
51
- this.marketingVendors = [];
52
- }
43
+ status = new Observable(Status.unknown);
44
+ functionalCookies = new Observable(ConsentStatus.unknown);
45
+ performanceCookies = new Observable(ConsentStatus.unknown);
46
+ marketingCookies = new Observable(ConsentStatus.unknown);
47
+ showSettings = new Observable(undefined);
48
+ /**
49
+ * @default []
50
+ */
51
+ performanceVendors = [];
52
+ /**
53
+ * @default []
54
+ */
55
+ marketingVendors = [];
53
56
  /**
54
57
  * Registers a performance vendor.
55
58
  */
@@ -2,20 +2,11 @@
2
2
  * Internal context that manages the document flags.
3
3
  */
4
4
  export class DocumentFlagManager {
5
+ _environmentContext;
6
+ _loadContext;
5
7
  constructor(_environmentContext, _loadContext) {
6
8
  this._environmentContext = _environmentContext;
7
9
  this._loadContext = _loadContext;
8
- this._update = () => {
9
- if (!document?.body)
10
- return;
11
- document.body.classList.toggle('zcomponent-designtime', this._environmentContext.designTime.value);
12
- document.body.classList.toggle('zcomponent-runtime', this._environmentContext.runTime.value);
13
- document.body.classList.toggle('zcomponent-development', this._environmentContext.developmentBuild.value);
14
- document.body.classList.toggle('zcomponent-production', this._environmentContext.productionBuild.value);
15
- document.body.classList.toggle('zcomponent-started', this._loadContext.isStarted.value);
16
- document.body.classList.toggle('zcomponent-launched', this._loadContext.isLaunched.value);
17
- document.body.classList.toggle('zcomponent-loaded', this._loadContext.isLoaded.value);
18
- };
19
10
  this._update();
20
11
  this._environmentContext.designTime.addListener(this._update);
21
12
  this._environmentContext.runTime.addListener(this._update);
@@ -25,6 +16,19 @@ export class DocumentFlagManager {
25
16
  this._loadContext.isLaunched.addListener(this._update);
26
17
  this._loadContext.isLoaded.addListener(this._update);
27
18
  }
19
+ _update = () => {
20
+ if (typeof document === 'undefined')
21
+ return;
22
+ if (!document?.body)
23
+ return;
24
+ document.body.classList.toggle('zcomponent-designtime', this._environmentContext.designTime.value);
25
+ document.body.classList.toggle('zcomponent-runtime', this._environmentContext.runTime.value);
26
+ document.body.classList.toggle('zcomponent-development', this._environmentContext.developmentBuild.value);
27
+ document.body.classList.toggle('zcomponent-production', this._environmentContext.productionBuild.value);
28
+ document.body.classList.toggle('zcomponent-started', this._loadContext.isStarted.value);
29
+ document.body.classList.toggle('zcomponent-launched', this._loadContext.isLaunched.value);
30
+ document.body.classList.toggle('zcomponent-loaded', this._loadContext.isLoaded.value);
31
+ };
28
32
  dispose() {
29
33
  this._environmentContext.designTime.removeListener(this._update);
30
34
  this._environmentContext.runTime.removeListener(this._update);
@@ -1,30 +1,26 @@
1
- import { ContextManager, Context } from '../context';
1
+ import { Context, ContextManager } from '../context';
2
+ import type { Entity } from '../entity';
2
3
  import { Observable } from '../observable';
3
4
  /** @zcontext */
4
5
  export declare class EnvironmentContext extends Context {
5
6
  /**
6
7
  * Observable indicating if the application is in design time.
7
- * @zprop
8
8
  **/
9
9
  readonly designTime: Observable<boolean, never>;
10
10
  /**
11
11
  * Observable indicating if the application is in edit time.
12
- * @zprop
13
12
  * */
14
13
  readonly editTime: Observable<boolean, never>;
15
14
  /**
16
15
  * Observable indicating if the application is in run time.
17
- * @zprop
18
16
  **/
19
17
  readonly runTime: Observable<boolean, never>;
20
18
  /**
21
19
  * Observable indicating if the application is a development build.
22
- * @zprop
23
20
  **/
24
21
  readonly developmentBuild: Observable<boolean, never>;
25
22
  /**
26
23
  * Observable indicating if the application is a production build.
27
- * @zprop
28
24
  * */
29
25
  readonly productionBuild: Observable<boolean, never>;
30
26
  private readonly _documentFlagManager;
@@ -55,3 +51,23 @@ export declare function isDevelopmentBuild(ctx: ContextManager): boolean;
55
51
  * @returns {boolean} True if it's a production build, otherwise false.
56
52
  */
57
53
  export declare function isProductionBuild(ctx: ContextManager): boolean;
54
+ /**
55
+ * A decorator that will permit its decorated function to be called only durning runtime (and not design or edit time). If execution is prevented, the function will return `undefined` to the caller.
56
+ */
57
+ export declare function zOnlyRuntime<EntityType extends Entity>(): (originalMethod: (...args: any) => void, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => void>) => void;
58
+ /**
59
+ * A decorator that will permit its decorated function to be called only durning edit time. If execution is prevented, the function will return `undefined` to the caller.
60
+ */
61
+ export declare function zOnlyEditTime<EntityType extends Entity>(): (originalMethod: (...args: any) => void, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => void>) => void;
62
+ /**
63
+ * A decorator that will permit its decorated function to be called only durning design time. If execution is prevented, the function will return `undefined` to the caller.
64
+ */
65
+ export declare function zOnlyDesignTime<EntityType extends Entity>(): (originalMethod: (...args: any) => void, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => void>) => void;
66
+ /**
67
+ * A decorator that will permit its decorated function to be called only in production builds. If execution is prevented, the function will return `undefined` to the caller.
68
+ */
69
+ export declare function zOnlyProduction<EntityType extends Entity>(): (originalMethod: (...args: any) => void, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => void>) => void;
70
+ /**
71
+ * A decorator that will permit its decorated function to be called only in development builds. If execution is prevented, the function will return `undefined` to the caller.
72
+ */
73
+ export declare function zOnlyDevelopment<EntityType extends Entity>(): (originalMethod: (...args: any) => void, context: ClassMethodDecoratorContext<EntityType, (this: EntityType, ...args: any[]) => void>) => void;
@@ -1,44 +1,108 @@
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
  import { DocumentFlagManager } from './documentflagmanager';
4
39
  import { LoadContext } from './loadcontext';
5
40
  /** @zcontext */
6
- export class EnvironmentContext extends Context {
7
- constructor(contextManager, props) {
8
- super(contextManager, props);
41
+ let EnvironmentContext = (() => {
42
+ let _classSuper = Context;
43
+ let _designTime_decorators;
44
+ let _designTime_initializers = [];
45
+ let _designTime_extraInitializers = [];
46
+ let _editTime_decorators;
47
+ let _editTime_initializers = [];
48
+ let _editTime_extraInitializers = [];
49
+ let _runTime_decorators;
50
+ let _runTime_initializers = [];
51
+ let _runTime_extraInitializers = [];
52
+ let _developmentBuild_decorators;
53
+ let _developmentBuild_initializers = [];
54
+ let _developmentBuild_extraInitializers = [];
55
+ let _productionBuild_decorators;
56
+ let _productionBuild_initializers = [];
57
+ let _productionBuild_extraInitializers = [];
58
+ return class EnvironmentContext extends _classSuper {
59
+ static {
60
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
61
+ _designTime_decorators = [zUI()];
62
+ _editTime_decorators = [zUI()];
63
+ _runTime_decorators = [zUI()];
64
+ _developmentBuild_decorators = [zUI()];
65
+ _productionBuild_decorators = [zUI()];
66
+ __esDecorate(null, null, _designTime_decorators, { kind: "field", name: "designTime", static: false, private: false, access: { has: obj => "designTime" in obj, get: obj => obj.designTime, set: (obj, value) => { obj.designTime = value; } }, metadata: _metadata }, _designTime_initializers, _designTime_extraInitializers);
67
+ __esDecorate(null, null, _editTime_decorators, { kind: "field", name: "editTime", static: false, private: false, access: { has: obj => "editTime" in obj, get: obj => obj.editTime, set: (obj, value) => { obj.editTime = value; } }, metadata: _metadata }, _editTime_initializers, _editTime_extraInitializers);
68
+ __esDecorate(null, null, _runTime_decorators, { kind: "field", name: "runTime", static: false, private: false, access: { has: obj => "runTime" in obj, get: obj => obj.runTime, set: (obj, value) => { obj.runTime = value; } }, metadata: _metadata }, _runTime_initializers, _runTime_extraInitializers);
69
+ __esDecorate(null, null, _developmentBuild_decorators, { kind: "field", name: "developmentBuild", static: false, private: false, access: { has: obj => "developmentBuild" in obj, get: obj => obj.developmentBuild, set: (obj, value) => { obj.developmentBuild = value; } }, metadata: _metadata }, _developmentBuild_initializers, _developmentBuild_extraInitializers);
70
+ __esDecorate(null, null, _productionBuild_decorators, { kind: "field", name: "productionBuild", static: false, private: false, access: { has: obj => "productionBuild" in obj, get: obj => obj.productionBuild, set: (obj, value) => { obj.productionBuild = value; } }, metadata: _metadata }, _productionBuild_initializers, _productionBuild_extraInitializers);
71
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
72
+ }
9
73
  /**
10
74
  * Observable indicating if the application is in design time.
11
- * @zprop
12
75
  **/
13
- this.designTime = new Observable(false);
76
+ designTime = __runInitializers(this, _designTime_initializers, new Observable(false));
14
77
  /**
15
78
  * Observable indicating if the application is in edit time.
16
- * @zprop
17
79
  * */
18
- this.editTime = new Observable(false);
80
+ editTime = (__runInitializers(this, _designTime_extraInitializers), __runInitializers(this, _editTime_initializers, new Observable(false)));
19
81
  /**
20
82
  * Observable indicating if the application is in run time.
21
- * @zprop
22
83
  **/
23
- this.runTime = new Observable(true);
84
+ runTime = (__runInitializers(this, _editTime_extraInitializers), __runInitializers(this, _runTime_initializers, new Observable(true)));
24
85
  /**
25
86
  * Observable indicating if the application is a development build.
26
- * @zprop
27
87
  **/
28
- this.developmentBuild = new Observable(typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development');
88
+ developmentBuild = (__runInitializers(this, _runTime_extraInitializers), __runInitializers(this, _developmentBuild_initializers, new Observable(typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development')));
29
89
  /**
30
90
  * Observable indicating if the application is a production build.
31
- * @zprop
32
91
  * */
33
- this.productionBuild = new Observable(!this.developmentBuild.value);
34
- const loadContext = this.contextManager.get(LoadContext);
35
- this._documentFlagManager = new DocumentFlagManager(this, loadContext);
36
- }
37
- dispose() {
38
- this._documentFlagManager.dispose();
39
- return super.dispose();
40
- }
41
- }
92
+ productionBuild = (__runInitializers(this, _developmentBuild_extraInitializers), __runInitializers(this, _productionBuild_initializers, new Observable(!this.developmentBuild.value)));
93
+ _documentFlagManager = __runInitializers(this, _productionBuild_extraInitializers);
94
+ constructor(contextManager, props) {
95
+ super(contextManager, props);
96
+ const loadContext = this.contextManager.get(LoadContext);
97
+ this._documentFlagManager = new DocumentFlagManager(this, loadContext);
98
+ }
99
+ dispose() {
100
+ this._documentFlagManager.dispose();
101
+ return super.dispose();
102
+ }
103
+ };
104
+ })();
105
+ export { EnvironmentContext };
42
106
  /**
43
107
  * Determines if the application is in design time.
44
108
  * @param ctx The context manager to query.
@@ -71,3 +135,53 @@ export function isDevelopmentBuild(ctx) {
71
135
  export function isProductionBuild(ctx) {
72
136
  return ctx.get(EnvironmentContext).productionBuild.value;
73
137
  }
138
+ /**
139
+ * A decorator that will permit its decorated function to be called only durning runtime (and not design or edit time). If execution is prevented, the function will return `undefined` to the caller.
140
+ */
141
+ export function zOnlyRuntime() {
142
+ return (originalMethod, context) => function (...args) {
143
+ if (isDesignTime(this.contextManager) || isEditTime(this.contextManager))
144
+ return;
145
+ originalMethod.call(this, ...args);
146
+ };
147
+ }
148
+ /**
149
+ * A decorator that will permit its decorated function to be called only durning edit time. If execution is prevented, the function will return `undefined` to the caller.
150
+ */
151
+ export function zOnlyEditTime() {
152
+ return (originalMethod, context) => function (...args) {
153
+ if (!isEditTime(this.contextManager))
154
+ return;
155
+ originalMethod.call(this, ...args);
156
+ };
157
+ }
158
+ /**
159
+ * A decorator that will permit its decorated function to be called only durning design time. If execution is prevented, the function will return `undefined` to the caller.
160
+ */
161
+ export function zOnlyDesignTime() {
162
+ return (originalMethod, context) => function (...args) {
163
+ if (!isDesignTime(this.contextManager))
164
+ return;
165
+ originalMethod.call(this, ...args);
166
+ };
167
+ }
168
+ /**
169
+ * A decorator that will permit its decorated function to be called only in production builds. If execution is prevented, the function will return `undefined` to the caller.
170
+ */
171
+ export function zOnlyProduction() {
172
+ return (originalMethod, context) => function (...args) {
173
+ if (!isProductionBuild(this.contextManager))
174
+ return;
175
+ originalMethod.call(this, ...args);
176
+ };
177
+ }
178
+ /**
179
+ * A decorator that will permit its decorated function to be called only in development builds. If execution is prevented, the function will return `undefined` to the caller.
180
+ */
181
+ export function zOnlyDevelopment() {
182
+ return (originalMethod, context) => function (...args) {
183
+ if (!isDevelopmentBuild(this.contextManager))
184
+ return;
185
+ originalMethod.call(this, ...args);
186
+ };
187
+ }
@@ -1,36 +1,39 @@
1
1
  import { Context, ContextManager } from '../context';
2
2
  import { Event } from '../event';
3
+ import { ValueOf } from '../types';
3
4
  /**
4
5
  * Represents the axes of a gamepad.
5
6
  */
6
- export declare enum GamepadAxis {
7
- LeftStickHorizontal = "LeftStickHorizontal",
8
- LeftStickVertical = "LeftStickVertical",
9
- RightStickHorizontal = "RightStickHorizontal",
10
- RightStickVertical = "RightStickVertical"
11
- }
7
+ export declare const GamepadAxis: {
8
+ readonly LeftStickHorizontal: "LeftStickHorizontal";
9
+ readonly LeftStickVertical: "LeftStickVertical";
10
+ readonly RightStickHorizontal: "RightStickHorizontal";
11
+ readonly RightStickVertical: "RightStickVertical";
12
+ };
13
+ export type GamepadAxisValue = ValueOf<typeof GamepadAxis>;
12
14
  /**
13
15
  * Represents the buttons on a gamepad.
14
16
  */
15
- export declare enum GamepadButton {
16
- South = "South",
17
- East = "East",
18
- West = "West",
19
- North = "North",
20
- ShoulderLeft = "ShoulderLeft",
21
- ShoulderRight = "ShoulderRight",
22
- TriggerLeft = "TriggerLeft",
23
- TriggerRight = "TriggerRight",
24
- Select = "Select",
25
- Start = "Start",
26
- StickLeft = "StickLeft",
27
- StickRight = "StickRight",
28
- DUp = "DUp",
29
- DDown = "DDown",
30
- DLeft = "DLeft",
31
- DRight = "DRight",
32
- Center = "Center"
33
- }
17
+ export declare const GamepadButton: {
18
+ readonly South: "South";
19
+ readonly East: "East";
20
+ readonly West: "West";
21
+ readonly North: "North";
22
+ readonly ShoulderLeft: "ShoulderLeft";
23
+ readonly ShoulderRight: "ShoulderRight";
24
+ readonly TriggerLeft: "TriggerLeft";
25
+ readonly TriggerRight: "TriggerRight";
26
+ readonly Select: "Select";
27
+ readonly Start: "Start";
28
+ readonly StickLeft: "StickLeft";
29
+ readonly StickRight: "StickRight";
30
+ readonly DUp: "DUp";
31
+ readonly DDown: "DDown";
32
+ readonly DLeft: "DLeft";
33
+ readonly DRight: "DRight";
34
+ readonly Center: "Center";
35
+ };
36
+ export type GamepadButtonValue = ValueOf<typeof GamepadButton>;
34
37
  /**
35
38
  * Manages and tracks gamepad connections and states.
36
39
  * @zcontext
@@ -75,4 +78,4 @@ export declare class GamepadContext extends Context {
75
78
  * @param axis The gamepad axis to translate.
76
79
  * @returns The numeric representation of the gamepad axis.
77
80
  */
78
- export declare function translateGamepadAxis(axis: GamepadAxis): number;
81
+ export declare function translateGamepadAxis(axis: GamepadAxisValue): number;