@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
package/lib/types.d.ts CHANGED
@@ -26,7 +26,9 @@ export declare enum TypeName {
26
26
  Enum = "enum",
27
27
  Function = "function",
28
28
  Event = "event",
29
- Entity = "entity"
29
+ Entity = "entity",
30
+ ClassInstance = "classinstance",
31
+ ConstructorForComponent = "constructorforcomponent"
30
32
  }
31
33
  /**
32
34
  * Type definition for a string primitive.
@@ -36,6 +38,9 @@ export declare enum TypeName {
36
38
  export interface StringPrimitiveType extends BaseType {
37
39
  name: 'string';
38
40
  }
41
+ export interface ClassInstanceType extends BaseType {
42
+ name: 'classinstance';
43
+ }
39
44
  /**
40
45
  * Type definition for a number primitive.
41
46
  *
@@ -137,19 +142,23 @@ export interface EventType extends BaseType {
137
142
  export interface EntityType extends BaseType {
138
143
  name: 'entity';
139
144
  }
145
+ export interface ConstructorForComponentType extends BaseType {
146
+ name: 'constructorforcomponent';
147
+ }
140
148
  /**
141
149
  * Union type representing all possible type definitions.
142
150
  *
143
151
  * This type aggregates all specific type interfaces into a single type that can represent any of them.
144
152
  */
145
- export type Type = StringPrimitiveType | NumberPrimitiveType | BooleanPrimitiveType | ArrayType | TupleType | UnknownType | EnumType | UnionType | LiteralType | FunctionType | EventType | EntityType;
153
+ export type Type = StringPrimitiveType | NumberPrimitiveType | BooleanPrimitiveType | ArrayType | TupleType | UnknownType | EnumType | UnionType | LiteralType | FunctionType | EventType | EntityType | ClassInstanceType | ConstructorForComponentType;
146
154
  /**
147
155
  * Enumeration of type hints used to provide additional information about a type.
148
156
  *
149
157
  * This enum provides specific hints that can be used to give more context about how a type should be interpreted or displayed.
150
158
  */
151
159
  export declare enum TypeHint {
152
- 'proportion' = "proportion",
160
+ proportion = "proportion",
161
+ range = "range",
153
162
  'color-norm-rgb' = "color-norm-rgb",
154
163
  'color-norm-rgb-srgb' = "color-norm-rgb-srgb",
155
164
  'color-norm-rgb-linear' = "color-norm-rgb-linear",
@@ -165,10 +174,10 @@ export declare enum TypeHint {
165
174
  'time-seconds' = "time-seconds",
166
175
  'time-milliseconds' = "time-milliseconds",
167
176
  'time-hertz' = "time-hertz",
168
- 'emailaddress' = "emailaddress",
169
- 'url' = "url",
177
+ emailaddress = "emailaddress",
178
+ url = "url",
170
179
  'function-emit-component-prop-event' = "function-emit-component-prop-event",
171
- 'animationcurve' = "animationcurve"
180
+ animationcurve = "animationcurve"
172
181
  }
173
182
  /**
174
183
  * Enumeration of values types used in a values definition.
@@ -176,19 +185,20 @@ export declare enum TypeHint {
176
185
  * This enum lists different kinds of values types that can be used in a values definition, representing various data sources or formats.
177
186
  */
178
187
  export declare enum ValuesType {
179
- 'files' = "files",
180
- 'animations' = "animations",
181
- 'morphTargets' = "morphTargets",
182
- 'events' = "events",
183
- 'parentNodes' = "parentNodes",
184
- 'parentMaterials' = "parentMaterials",
185
- 'nodelabels' = "nodelabels",
186
- 'nodeids' = "nodeids",
187
- 'layerclipids' = "layerclipids",
188
- 'easings' = "easings",
189
- 'layerids' = "layerids",
190
- 'streamids' = "streamids",
191
- 'behaviorids' = "behaviorids"
188
+ files = "files",
189
+ animations = "animations",
190
+ morphTargets = "morphTargets",
191
+ events = "events",
192
+ parentNodes = "parentNodes",
193
+ parentMaterials = "parentMaterials",
194
+ nodelabels = "nodelabels",
195
+ nodeids = "nodeids",
196
+ layerclipids = "layerclipids",
197
+ easings = "easings",
198
+ layerids = "layerids",
199
+ streamids = "streamids",
200
+ behaviorids = "behaviorids",
201
+ components = "components"
192
202
  }
193
203
  /**
194
204
  * Interface representing a values definition.
@@ -428,3 +438,135 @@ export declare function overridesAreCompatible(a: {
428
438
  * @returns A default value appropriate for the given type.
429
439
  */
430
440
  export declare function defaultValueForType(t: Type): any;
441
+ export type ValueOf<T> = T[keyof T];
442
+ /**
443
+ * Represents a numeric range with specified minimum and maximum bounds.
444
+ *
445
+ * @template MIN - The minimum value (defaults to 0)
446
+ * @template MAX - The maximum value (defaults to 1)
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * interface Props {
451
+ * opacity: Range<0, 1>; // 0-1 range for opacity
452
+ * volume: Range<0, 100>; // 0-100 range for volume
453
+ * temperature: Range<-20, 50>; // -20 to 50 range for temperature
454
+ * }
455
+ * ```
456
+ */
457
+ export type Range<MIN extends number = 0, MAX extends number = 1> = number;
458
+ /**
459
+ * Represents an angular measurement with specified units.
460
+ *
461
+ * @template UNITS - The angular units ('radians' | 'degrees'), defaults to 'radians'
462
+ *
463
+ * @example
464
+ * ```typescript
465
+ * interface Props {
466
+ * rotation: Angle<'degrees'>; // Angle in degrees
467
+ * phase: Angle<'radians'>; // Angle in radians (default)
468
+ * heading: Angle; // Defaults to radians
469
+ * }
470
+ * ```
471
+ */
472
+ export type Angle<UNITS extends 'radians' | 'degrees' = 'radians'> = number;
473
+ /**
474
+ * Represents a project file path with optional glob pattern constraint.
475
+ *
476
+ * @template GLOB - The glob pattern to match files against (defaults to '**\/*')
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * interface Props {
481
+ * model: ProjectFile<'*.glb'>; // Only .glb files
482
+ * texture: ProjectFile<'*.{png,jpg}'>; // PNG or JPG files
483
+ * config: ProjectFile<'config/*.json'>; // JSON files in config folder
484
+ * any: ProjectFile; // Any file (defaults to '**\/*')
485
+ * }
486
+ * ```
487
+ */
488
+ export type ProjectFile<GLOB extends string = '**/*'> = string;
489
+ /**
490
+ * Represents a color value with specified format and color space.
491
+ *
492
+ * Colors default to unnormalized (0-255) range unless 'norm' is specified.
493
+ *
494
+ * @template FORMAT - The color format ('hex' | 'hexa' | 'rgb' | 'rgba' | 'norm-rgb' | 'norm-rgba' | 'css')
495
+ * @template SPACE - The color space ('srgb' | 'linear'), defaults to 'srgb'
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * interface Props {
500
+ * background: Color<'hex'>; // Hex color like "#FF0000"
501
+ * tint: Color<'norm-rgb', 'linear'>; // Normalized RGB [0,0,0] in linear space
502
+ * overlay: Color<'rgba'>; // RGBA array [255,0,0,255] (unnormalized default)
503
+ * transparent: Color<'hexa'>; // Hex with alpha "#FF0000FF"
504
+ * material: Color<'norm-rgba'>; // Normalized RGBA [1,0,0,1]
505
+ * theme: Color<'css'>; // Any CSS color string
506
+ * }
507
+ * ```
508
+ */
509
+ export type Color<FORMAT extends 'hex' | 'hexa' | 'rgb' | 'rgba' | 'norm-rgb' | 'norm-rgba' | 'css' = 'rgb', SPACE extends 'srgb' | 'linear' = 'srgb'> = FORMAT extends 'hex' | 'hexa' | 'css' ? string : FORMAT extends 'rgb' | 'norm-rgb' ? [
510
+ number,
511
+ number,
512
+ number
513
+ ] : FORMAT extends 'rgba' | 'norm-rgba' ? [
514
+ number,
515
+ number,
516
+ number,
517
+ number
518
+ ] : never;
519
+ /**
520
+ * Represents a time duration with specified units.
521
+ *
522
+ * @template UNITS - The time units ('seconds' | 'milliseconds' | 'hertz')
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * interface Props {
527
+ * duration: Time<'seconds'>; // Duration in seconds
528
+ * delay: Time<'milliseconds'>; // Delay in milliseconds
529
+ * frequency: Time<'hertz'>; // Frequency in Hz
530
+ * }
531
+ * ```
532
+ */
533
+ export type Time<UNITS extends 'seconds' | 'milliseconds' | 'hertz' = 'seconds'> = number;
534
+ /**
535
+ * Represents a proportion value (0-1 range).
536
+ *
537
+ * @example
538
+ * ```typescript
539
+ * interface Props {
540
+ * opacity: Proportion; // 0-1 decimal value
541
+ * progress: Proportion; // 0-1 decimal value
542
+ * }
543
+ * ```
544
+ */
545
+ export type Proportion = Range<0, 1>;
546
+ /**
547
+ * The type system can validate URL format.
548
+ */
549
+ export type Url = string;
550
+ /**
551
+ * Represents multiline text content.
552
+ *
553
+ * @example
554
+ * ```typescript
555
+ * interface Props {
556
+ * description: MultilineText; // Renders as textarea
557
+ * code: MultilineText; // Multiline code input
558
+ * }
559
+ * ```
560
+ */
561
+ export type MultilineText = string;
562
+ /**
563
+ * Represents an email address with automatic validation.
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * interface Props {
568
+ * contact: EmailAddress; // Email input with validation
569
+ * }
570
+ * ```
571
+ */
572
+ export type EmailAddress = string;
package/lib/types.js CHANGED
@@ -20,6 +20,8 @@ export var TypeName;
20
20
  TypeName["Function"] = "function";
21
21
  TypeName["Event"] = "event";
22
22
  TypeName["Entity"] = "entity";
23
+ TypeName["ClassInstance"] = "classinstance";
24
+ TypeName["ConstructorForComponent"] = "constructorforcomponent";
23
25
  })(TypeName || (TypeName = {}));
24
26
  /**
25
27
  * Enumeration of type hints used to provide additional information about a type.
@@ -29,6 +31,7 @@ export var TypeName;
29
31
  export var TypeHint;
30
32
  (function (TypeHint) {
31
33
  TypeHint["proportion"] = "proportion";
34
+ TypeHint["range"] = "range";
32
35
  TypeHint["color-norm-rgb"] = "color-norm-rgb";
33
36
  TypeHint["color-norm-rgb-srgb"] = "color-norm-rgb-srgb";
34
37
  TypeHint["color-norm-rgb-linear"] = "color-norm-rgb-linear";
@@ -70,6 +73,7 @@ export var ValuesType;
70
73
  ValuesType["layerids"] = "layerids";
71
74
  ValuesType["streamids"] = "streamids";
72
75
  ValuesType["behaviorids"] = "behaviorids";
76
+ ValuesType["components"] = "components";
73
77
  })(ValuesType || (ValuesType = {}));
74
78
  /**
75
79
  * Checks if values in two objects are compatible.
@@ -102,6 +106,8 @@ export function areTypesCompatible(a, b) {
102
106
  if (a.name !== b.name)
103
107
  return false;
104
108
  switch (a.name) {
109
+ case 'classinstance':
110
+ return false;
105
111
  case 'array':
106
112
  return areTypesCompatible(a.child, b.child);
107
113
  case 'literal':
@@ -368,7 +374,7 @@ export function mergeTypes(a, b) {
368
374
  ret: a.ret,
369
375
  comments: mergeComments(a.comments ?? [], b.comments ?? []),
370
376
  };
371
- case 'event':
377
+ case 'event': {
372
378
  const children = [];
373
379
  for (let i = 0; i < a.children.length; i++) {
374
380
  const merged = mergeTypes(a.children[i], b.children[i]);
@@ -383,6 +389,12 @@ export function mergeTypes(a, b) {
383
389
  comments: mergeComments(a.comments ?? [], b.comments ?? []),
384
390
  names: mergeTupleNames(a, b),
385
391
  };
392
+ }
393
+ case 'classinstance':
394
+ return {
395
+ name: a.name,
396
+ comments: mergeComments(a.comments ?? [], b.comments ?? []),
397
+ };
386
398
  }
387
399
  }
388
400
  const regex = new RegExp(/((\.tsx?)|(\.d\.ts)|(\.jsx?))$/, 'i');
@@ -485,6 +497,12 @@ export function isValidValueForType(def, t, allowUndefined) {
485
497
  return true;
486
498
  }
487
499
  return false;
500
+ case 'constructorforcomponent':
501
+ if (typeof def !== 'string')
502
+ return false;
503
+ if (!def.startsWith('import://'))
504
+ return false;
505
+ return true;
488
506
  }
489
507
  return false;
490
508
  }
@@ -510,6 +528,7 @@ function getBasicType(t) {
510
528
  }
511
529
  return `[${t.children.map(c => outputForType(c)).join(', ')}]`;
512
530
  case 'unknown':
531
+ case 'classinstance':
513
532
  return 'any';
514
533
  case 'number':
515
534
  case 'enum':
@@ -531,6 +550,8 @@ function getBasicType(t) {
531
550
  return `Event<[${t.children.map((c, indx) => `${getSafeKeyName(t.names[indx])}: ${outputForType(c)}`).join(', ')}]>`;
532
551
  }
533
552
  return `Event<[${t.children.map(c => outputForType(c)).join(', ')}]>`;
553
+ case 'constructorforcomponent':
554
+ return 'ConstructorForComponent<any>';
534
555
  }
535
556
  }
536
557
  /**
@@ -1,11 +1,11 @@
1
- import { DeviceType } from '../profile';
1
+ import { DeviceTypeValue } from '../profile';
2
2
  import type { Type } from '../types';
3
3
  export declare enum ConditionType {
4
- 'Locale' = "Locale",
5
- 'QueryString' = "Query String",
6
- 'UserAgent' = "User Agent",
7
- 'Debug' = "Debug",
8
- 'Default' = "Default"
4
+ Locale = "Locale",
5
+ QueryString = "Query String",
6
+ UserAgent = "User Agent",
7
+ Debug = "Debug",
8
+ Default = "Default"
9
9
  }
10
10
  export declare function getTypeForVariant(variant: ConditionType): Type;
11
11
  export interface BaseVariant {
@@ -27,7 +27,7 @@ export interface QueryStringVariant extends BaseVariant {
27
27
  }
28
28
  export interface UserAgentVariant extends BaseVariant {
29
29
  conditionType: ConditionType.UserAgent;
30
- agent?: DeviceType;
30
+ agent?: DeviceTypeValue;
31
31
  }
32
32
  export interface DebugVariant extends BaseVariant {
33
33
  conditionType: ConditionType.Debug;
@@ -35,7 +35,6 @@ export interface DebugVariant extends BaseVariant {
35
35
  }
36
36
  export type ZVariant = LocaleVariant | QueryStringVariant | UserAgentVariant | DebugVariant | DefaultVariant;
37
37
  export declare class ValuesManager {
38
- private valuesString;
39
38
  private profile;
40
39
  /**
41
40
  * Creates an instance of ValuesManager.
@@ -30,6 +30,7 @@ export function getTypeForVariant(variant) {
30
30
  }
31
31
  }
32
32
  export class ValuesManager {
33
+ profile = new Profile();
33
34
  // TODO: Fix this any
34
35
  /**
35
36
  * Creates an instance of ValuesManager.
@@ -37,8 +38,6 @@ export class ValuesManager {
37
38
  * @param states - The states.
38
39
  */
39
40
  constructor(valuesString, states) {
40
- this.valuesString = valuesString;
41
- this.profile = new Profile();
42
41
  if (valuesString === undefined)
43
42
  throw new Error('Values are not defined');
44
43
  if (states === undefined)
@@ -67,7 +67,10 @@ export declare function getTypesByKey(values: ZValues): Map<string, Type>;
67
67
  * @param values The values to check.
68
68
  * @returns Returns a map of key names to their [type representations, default values].
69
69
  */
70
- export declare function getTypesAndDefaultsByKey(values: ZValues): Map<string, [Type, any]>;
70
+ export declare function getTypesAndDefaultsByKey(values: ZValues): Map<string, [
71
+ Type,
72
+ any
73
+ ]>;
71
74
  /**
72
75
  * Adds a new key to the values.
73
76
  * @param keyname The name of the key.
@@ -1,11 +1,9 @@
1
1
  import { ConditionType } from './values';
2
2
  export function changeKeyAndType(values, oldKeyName, newKeyName, type) {
3
- if (!values.keys.hasOwnProperty(oldKeyName)) {
3
+ if (!Object.hasOwn(values.keys, oldKeyName))
4
4
  throw new Error(`The old key name '${oldKeyName}' does not exist in the 'keys' object.`);
5
- }
6
- if (values.keys.hasOwnProperty(newKeyName)) {
5
+ if (Object.hasOwn(values.keys, newKeyName))
7
6
  throw new Error(`The new key name '${newKeyName}' already exists in the 'keys' object.`);
8
- }
9
7
  // Clone the old key and value properties
10
8
  values.keys[newKeyName] = JSON.parse(JSON.stringify(values.keys[oldKeyName]));
11
9
  values.values[newKeyName] = JSON.parse(JSON.stringify(values.values[oldKeyName]));
@@ -469,7 +467,7 @@ export function mergeCSVStringIntoTarget(csvString, currentValues) {
469
467
  function parseStringToVariant(str, priority) {
470
468
  const [param, ...value] = str.split(':');
471
469
  switch (param) {
472
- case 'qs':
470
+ case 'qs': {
473
471
  const qsVariant = {
474
472
  conditionType: ConditionType.QueryString,
475
473
  param: value[0].split('=')[0],
@@ -477,27 +475,31 @@ function parseStringToVariant(str, priority) {
477
475
  priority,
478
476
  };
479
477
  return qsVariant;
480
- case 'ua':
478
+ }
479
+ case 'ua': {
481
480
  const uaVariant = {
482
481
  conditionType: ConditionType.UserAgent,
483
482
  agent: value[0],
484
483
  priority,
485
484
  };
486
485
  return uaVariant;
487
- case 'locale':
486
+ }
487
+ case 'locale': {
488
488
  const localeVariant = {
489
489
  conditionType: ConditionType.Locale,
490
490
  code: value[0],
491
491
  priority,
492
492
  };
493
493
  return localeVariant;
494
- case 'debug':
494
+ }
495
+ case 'debug': {
495
496
  const debugVariant = {
496
497
  conditionType: ConditionType.Debug,
497
498
  isEnabled: value[0] === 'true',
498
499
  priority,
499
500
  };
500
501
  return debugVariant;
502
+ }
501
503
  case 'default': {
502
504
  const defaultVariant = {
503
505
  conditionType: ConditionType.Default,
@@ -1,9 +1,9 @@
1
1
  import { Animation, Stream } from './animation/index';
2
2
  import { Behavior, ConstructorForBehavior } from './behavior';
3
3
  import { Component, ComponentChildren, ConstructorForComponent, ConstructorProps } from './component';
4
- import { ContextManager, Context } from './context';
5
- import { Entity } from './entity';
4
+ import { Context, ContextManager } from './context';
6
5
  import { ZComponentData } from './data/core';
6
+ import { Entity } from './entity';
7
7
  export interface ZComponentOptions {
8
8
  data: ZComponentData;
9
9
  importMapping: {
@@ -41,49 +41,59 @@ export declare class ZComponent<RootType = any> extends Component<RootType> {
41
41
  /**
42
42
  * The id of the component.
43
43
  */
44
- id: string;
44
+ readonly id: string;
45
45
  /**
46
46
  * A map of elements to node IDs.
47
47
  */
48
- idByElement: Map<any, string>;
48
+ readonly idByElement: Map<any, string>;
49
49
  /**
50
50
  * Object that maps node script names to scripts.
51
+ * @default {}
51
52
  */
52
- nodes: {
53
+ readonly nodes: {
53
54
  [id: string]: Component | Component[];
54
55
  };
55
56
  /**
56
57
  * Map of entites by ID.
57
58
  */
58
- entityByID: Map<string, Entity>;
59
+ readonly entityByID: Map<string, Entity>;
59
60
  /**
60
61
  * A map of entity labels to components.
61
62
  */
62
- entityByLabel: Map<string, Entity>;
63
+ readonly entityByLabel: Map<string, Entity>;
63
64
  /**
64
65
  * A map of node labels to components.
65
66
  */
66
- nodeByLabel: Map<string, Component<any, ConstructorProps>>;
67
+ readonly nodeByLabel: Map<string, Component<any, ConstructorProps>>;
67
68
  private _constructedResolve;
68
69
  /**
69
70
  * A promise that is resolved once construction of this component is complete.
70
71
  */
71
72
  constructed: Promise<void>;
73
+ /**
74
+ * @default false
75
+ */
76
+ private _isConstructed;
72
77
  /**
73
78
  * A boolean indicating if construction of this component is complete.
74
79
  */
75
- isConstructed: boolean;
80
+ get isConstructed(): boolean;
76
81
  /**
77
82
  * The animation object for this component.
83
+ * @zignore
78
84
  */
79
85
  animation: Animation;
80
86
  /**
81
87
  * @zstreams layerclipids
88
+ * @default {}
82
89
  */
83
- streams: {
90
+ readonly streams: {
84
91
  [id: string]: Stream;
85
92
  };
86
93
  private _nodesById;
94
+ /**
95
+ * @default []
96
+ */
87
97
  private _behaviorsToInitialize;
88
98
  private _constructorPropOverridesByEntityID;
89
99
  /**
@@ -171,5 +181,6 @@ export declare class ZComponent<RootType = any> extends Component<RootType> {
171
181
  traverse(callback: (comp: Component<any>) => void, breadthFirst?: boolean): void;
172
182
  private _traverseBFS;
173
183
  private _traverseDFS;
184
+ private _constructTopLevelComponents;
174
185
  dispose(): never;
175
186
  }