@zcomponent/core 1.14.3 → 1.15.0-beta

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 (143) hide show
  1. package/README.md +0 -6
  2. package/lib/actionbehavior.d.ts +12 -3
  3. package/lib/actionbehavior.js +12 -3
  4. package/lib/animation/animation.d.ts +96 -4
  5. package/lib/animation/animation.js +93 -0
  6. package/lib/animation/animationstate.d.ts +52 -2
  7. package/lib/animation/bezier.d.ts +12 -1
  8. package/lib/animation/bezier.js +15 -12
  9. package/lib/animation/clips/clip.d.ts +71 -0
  10. package/lib/animation/clips/clip.js +68 -0
  11. package/lib/animation/interpolate.d.ts +17 -0
  12. package/lib/animation/interpolate.js +71 -0
  13. package/lib/animation/keyframe.d.ts +24 -1
  14. package/lib/animation/layer.d.ts +73 -1
  15. package/lib/animation/layer.js +69 -0
  16. package/lib/animation/layerclip.d.ts +75 -0
  17. package/lib/animation/layerclip.js +69 -0
  18. package/lib/animation/stream.d.ts +49 -7
  19. package/lib/animation/stream.js +3 -0
  20. package/lib/animation/tracks/cliptrack.d.ts +64 -0
  21. package/lib/animation/tracks/cliptrack.js +65 -1
  22. package/lib/animation/tracks/functiontrack.d.ts +60 -0
  23. package/lib/animation/tracks/functiontrack.js +62 -3
  24. package/lib/animation/tracks/propertytrack.d.ts +84 -0
  25. package/lib/animation/tracks/propertytrack.js +75 -0
  26. package/lib/animation/tracks/streamtrack.d.ts +51 -0
  27. package/lib/animation/tracks/streamtrack.js +54 -3
  28. package/lib/animation/tracks/track.d.ts +56 -0
  29. package/lib/animation/tracks/track.js +40 -0
  30. package/lib/behavior.d.ts +37 -0
  31. package/lib/behavior.js +21 -0
  32. package/lib/behaviors/ActivateState.d.ts +10 -3
  33. package/lib/behaviors/ActivateState.js +8 -4
  34. package/lib/behaviors/CallFunction.d.ts +1 -1
  35. package/lib/behaviors/CallFunction.js +2 -2
  36. package/lib/behaviors/ConsoleLog.d.ts +1 -1
  37. package/lib/behaviors/ConsoleLog.js +2 -2
  38. package/lib/behaviors/DownloadSnapshot.d.ts +5 -2
  39. package/lib/behaviors/DownloadSnapshot.js +5 -2
  40. package/lib/behaviors/LaunchURL.d.ts +1 -1
  41. package/lib/behaviors/LaunchURL.js +1 -1
  42. package/lib/behaviors/LogAnalyticsEvent.d.ts +1 -1
  43. package/lib/behaviors/LogAnalyticsEvent.js +2 -2
  44. package/lib/behaviors/PauseLayerClip.d.ts +5 -3
  45. package/lib/behaviors/PauseLayerClip.js +3 -2
  46. package/lib/behaviors/PlayLayerClip.d.ts +10 -4
  47. package/lib/behaviors/PlayLayerClip.js +7 -5
  48. package/lib/behaviors/PlaySound.d.ts +4 -4
  49. package/lib/behaviors/PlaySound.js +4 -4
  50. package/lib/behaviors/SetLayerOff.d.ts +4 -3
  51. package/lib/behaviors/SetLayerOff.js +3 -2
  52. package/lib/behaviors/ShowTextAlert.d.ts +2 -2
  53. package/lib/behaviors/ShowTextAlert.js +5 -5
  54. package/lib/behaviors/ToggleLayerClips.d.ts +4 -3
  55. package/lib/behaviors/ToggleLayerClips.js +5 -4
  56. package/lib/behaviors/stream/PauseStream.d.ts +15 -3
  57. package/lib/behaviors/stream/PauseStream.js +13 -2
  58. package/lib/behaviors/stream/PlayStream.d.ts +14 -4
  59. package/lib/behaviors/stream/PlayStream.js +10 -3
  60. package/lib/behaviors/stream/SeekStream.d.ts +12 -3
  61. package/lib/behaviors/stream/SeekStream.js +10 -2
  62. package/lib/behaviors/stream/StopStream.d.ts +11 -3
  63. package/lib/behaviors/stream/StopStream.js +9 -2
  64. package/lib/component.d.ts +85 -5
  65. package/lib/component.js +49 -1
  66. package/lib/components/Audio.d.ts +14 -5
  67. package/lib/components/Audio.js +19 -10
  68. package/lib/components/AudioLayerSettings.d.ts +9 -3
  69. package/lib/components/AudioLayerSettings.js +9 -3
  70. package/lib/components/Children.d.ts +7 -2
  71. package/lib/components/Children.js +6 -1
  72. package/lib/components/DefaultCookieConsent.d.ts +13 -3
  73. package/lib/components/DefaultCookieConsent.js +62 -38
  74. package/lib/components/DefaultLoader.d.ts +14 -9
  75. package/lib/components/DefaultLoader.js +25 -20
  76. package/lib/components/Gamepad.d.ts +12 -4
  77. package/lib/components/Gamepad.js +16 -8
  78. package/lib/components/LongLoad.d.ts +7 -1
  79. package/lib/components/LongLoad.js +7 -1
  80. package/lib/components/SnapshotUI.d.ts +10 -0
  81. package/lib/components/SnapshotUI.js +24 -0
  82. package/lib/context.d.ts +117 -0
  83. package/lib/context.js +50 -71
  84. package/lib/contexts/analyticscontext.d.ts +6 -0
  85. package/lib/contexts/analyticscontext.js +6 -0
  86. package/lib/contexts/audiocontextcontext.d.ts +26 -1
  87. package/lib/contexts/audiocontextcontext.js +26 -1
  88. package/lib/contexts/canvascontext.d.ts +59 -1
  89. package/lib/contexts/canvascontext.js +54 -1
  90. package/lib/contexts/cookieconsentcontext.d.ts +84 -10
  91. package/lib/contexts/cookieconsentcontext.js +71 -0
  92. package/lib/contexts/environmentcontext.d.ts +40 -5
  93. package/lib/contexts/environmentcontext.js +40 -5
  94. package/lib/contexts/gamepadcontext.d.ts +38 -0
  95. package/lib/contexts/gamepadcontext.js +38 -0
  96. package/lib/contexts/gesturecontext.d.ts +31 -4
  97. package/lib/contexts/gesturecontext.js +28 -4
  98. package/lib/contexts/globaltagcontext.d.ts +14 -2
  99. package/lib/contexts/globaltagcontext.js +13 -1
  100. package/lib/contexts/loadcontext.d.ts +92 -5
  101. package/lib/contexts/loadcontext.js +98 -11
  102. package/lib/contexts/orientationcontext.d.ts +58 -1
  103. package/lib/contexts/orientationcontext.js +51 -1
  104. package/lib/contexts/snapshotContext.d.ts +97 -4
  105. package/lib/contexts/snapshotContext.js +115 -4
  106. package/lib/contexts/tagcontext.d.ts +56 -2
  107. package/lib/contexts/tagcontext.js +77 -7
  108. package/lib/contexts/textalertcontext.d.ts +35 -2
  109. package/lib/contexts/textalertcontext.js +20 -2
  110. package/lib/contexts/usereventcontext.d.ts +29 -0
  111. package/lib/contexts/usereventcontext.js +30 -1
  112. package/lib/data/animation.d.ts +163 -0
  113. package/lib/data/animation.js +9 -0
  114. package/lib/data/change.d.ts +199 -0
  115. package/lib/data/change.js +190 -0
  116. package/lib/emitter.d.ts +8 -1
  117. package/lib/emitter.js +7 -0
  118. package/lib/entity.d.ts +30 -5
  119. package/lib/entity.js +23 -7
  120. package/lib/event.d.ts +19 -2
  121. package/lib/event.js +19 -2
  122. package/lib/fractionalindexing.js +38 -42
  123. package/lib/index.d.ts +27 -1
  124. package/lib/index.js +27 -1
  125. package/lib/inflate.d.ts +68 -0
  126. package/lib/inflate.js +76 -0
  127. package/lib/observable.d.ts +3 -3
  128. package/lib/observable.js +4 -4
  129. package/lib/profile.d.ts +27 -0
  130. package/lib/profile.js +26 -0
  131. package/lib/selectors.d.ts +114 -0
  132. package/lib/selectors.js +159 -7
  133. package/lib/types.d.ts +215 -0
  134. package/lib/types.js +110 -1
  135. package/lib/validators.d.ts +27 -0
  136. package/lib/validators.js +27 -0
  137. package/lib/values/values.d.ts +5 -0
  138. package/lib/values/values.js +5 -0
  139. package/lib/zcomponent.d.ts +72 -0
  140. package/lib/zcomponent.js +81 -0
  141. package/lib/zcomponentconstruction.d.ts +11 -1
  142. package/lib/zcomponentconstruction.js +10 -0
  143. package/package.json +7 -2
package/lib/types.d.ts CHANGED
@@ -1,9 +1,19 @@
1
1
  import { EntityPropOverride } from './data/core';
2
+ /**
3
+ * Interface representing the base structure for a type definition.
4
+ *
5
+ * This interface is used as a foundation for more specific type definitions, providing common properties like comments and type hints.
6
+ */
2
7
  export interface BaseType {
3
8
  comments?: string[];
4
9
  typeHint?: TypeHint;
5
10
  isObservable?: boolean;
6
11
  }
12
+ /**
13
+ * Enumeration of type names used in type definitions.
14
+ *
15
+ * This enum lists different kinds of type names that can be used to represent various data types in a type definition.
16
+ */
7
17
  export declare enum TypeName {
8
18
  String = "string",
9
19
  Number = "number",
@@ -18,36 +28,81 @@ export declare enum TypeName {
18
28
  Event = "event",
19
29
  Entity = "entity"
20
30
  }
31
+ /**
32
+ * Type definition for a string primitive.
33
+ *
34
+ * This interface extends BaseType and is used specifically for defining a string type.
35
+ */
21
36
  export interface StringPrimitiveType extends BaseType {
22
37
  name: 'string';
23
38
  }
39
+ /**
40
+ * Type definition for a number primitive.
41
+ *
42
+ * This interface extends BaseType and is used specifically for defining a number type.
43
+ */
24
44
  export interface NumberPrimitiveType extends BaseType {
25
45
  name: 'number';
26
46
  }
47
+ /**
48
+ * Type definition for a boolean primitive.
49
+ *
50
+ * This interface extends BaseType and is used specifically for defining a boolean type.
51
+ */
27
52
  export interface BooleanPrimitiveType extends BaseType {
28
53
  name: 'boolean';
29
54
  }
55
+ /**
56
+ * Type definition for a literal type.
57
+ *
58
+ * This interface extends BaseType and is used for defining literal types, which represent specific values.
59
+ */
30
60
  export interface LiteralType extends BaseType {
31
61
  name: 'literal';
32
62
  value?: string | number | boolean | null;
33
63
  isUndefined?: boolean;
34
64
  }
65
+ /**
66
+ * Type definition for an array type.
67
+ *
68
+ * This interface extends BaseType and represents an array type, specifying the type of elements the array contains.
69
+ */
35
70
  export interface ArrayType extends BaseType {
36
71
  name: 'array';
37
72
  child: Type;
38
73
  }
74
+ /**
75
+ * Type definition for a tuple type.
76
+ *
77
+ * This interface extends BaseType and represents a tuple type, specifying the types of elements and their order in the tuple.
78
+ */
39
79
  export interface TupleType extends BaseType {
40
80
  name: 'tuple';
41
81
  children: Type[];
42
82
  names?: string[];
43
83
  }
84
+ /**
85
+ * Type definition for a union type.
86
+ *
87
+ * This interface extends BaseType and represents a union type, which can be one of several specified types.
88
+ */
44
89
  export interface UnionType extends BaseType {
45
90
  name: 'union';
46
91
  children: Type[];
47
92
  }
93
+ /**
94
+ * Type definition for an unknown type.
95
+ *
96
+ * This interface extends BaseType and represents a type that is unspecified or unknown.
97
+ */
48
98
  export interface UnknownType extends BaseType {
49
99
  name: 'unknown';
50
100
  }
101
+ /**
102
+ * Type definition for an enum type.
103
+ *
104
+ * This interface extends BaseType and is used for defining enumeration types, specifying the possible values an enum can take.
105
+ */
51
106
  export interface EnumType extends BaseType {
52
107
  name: 'enum';
53
108
  values: {
@@ -57,18 +112,42 @@ export interface EnumType extends BaseType {
57
112
  [id: string]: string[];
58
113
  };
59
114
  }
115
+ /**
116
+ * Type definition for a function type.
117
+ *
118
+ * This interface extends BaseType and represents a function type, detailing the function's arguments and return type.
119
+ */
60
120
  export interface FunctionType extends BaseType {
61
121
  name: 'function';
62
122
  args: Prop[];
63
123
  ret?: Type;
64
124
  }
125
+ /**
126
+ * Type definition for an event type.
127
+ *
128
+ * This interface extends BaseType and is used specifically for defining an event type.
129
+ */
65
130
  export interface EventType extends BaseType {
66
131
  name: 'event';
67
132
  }
133
+ /** Internal use comment is sufficient for EntityType
134
+ * @internal
135
+ * @notes for internal use
136
+ */
68
137
  export interface EntityType extends BaseType {
69
138
  name: 'entity';
70
139
  }
140
+ /**
141
+ * Union type representing all possible type definitions.
142
+ *
143
+ * This type aggregates all specific type interfaces into a single type that can represent any of them.
144
+ */
71
145
  export type Type = StringPrimitiveType | NumberPrimitiveType | BooleanPrimitiveType | ArrayType | TupleType | UnknownType | EnumType | UnionType | LiteralType | FunctionType | EventType | EntityType;
146
+ /**
147
+ * Enumeration of type hints used to provide additional information about a type.
148
+ *
149
+ * This enum provides specific hints that can be used to give more context about how a type should be interpreted or displayed.
150
+ */
72
151
  export declare enum TypeHint {
73
152
  'proportion' = "proportion",
74
153
  'color-norm-rgb' = "color-norm-rgb",
@@ -87,6 +166,11 @@ export declare enum TypeHint {
87
166
  'emailaddress' = "emailaddress",
88
167
  'url' = "url"
89
168
  }
169
+ /**
170
+ * Enumeration of values types used in a values definition.
171
+ *
172
+ * This enum lists different kinds of values types that can be used in a values definition, representing various data sources or formats.
173
+ */
90
174
  export declare enum ValuesType {
91
175
  'files' = "files",
92
176
  'animations' = "animations",
@@ -100,10 +184,20 @@ export declare enum ValuesType {
100
184
  'layerids' = "layerids",
101
185
  'streamids' = "streamids"
102
186
  }
187
+ /**
188
+ * Interface representing a values definition.
189
+ *
190
+ * This interface defines the structure for a values definition, specifying the type of values and any associated parameters.
191
+ */
103
192
  export interface Values {
104
193
  type: ValuesType;
105
194
  param: string;
106
195
  }
196
+ /**
197
+ * Interface representing a property definition.
198
+ *
199
+ * This interface defines the structure for a property, including its name, type, default value, and other optional settings.
200
+ */
107
201
  export interface Prop {
108
202
  name: string;
109
203
  type: Type;
@@ -121,6 +215,11 @@ export interface Prop {
121
215
  isConstructorProp?: boolean;
122
216
  deprecated?: boolean;
123
217
  }
218
+ /**
219
+ * Interface representing a default child object in a component or behavior definition.
220
+ *
221
+ * This interface defines the structure for specifying default children of a component or behavior, including their type and initial properties.
222
+ */
124
223
  export interface DefaultChild {
125
224
  label: string;
126
225
  type: string;
@@ -128,7 +227,17 @@ export interface DefaultChild {
128
227
  [id: string]: any;
129
228
  };
130
229
  }
230
+ /**
231
+ * Type representing the category of a component, behavior, or context.
232
+ *
233
+ * This type categorizes elements as either a component, behavior, or context.
234
+ */
131
235
  export type ComponentInfoType = 'component' | 'behavior' | 'context';
236
+ /**
237
+ * Interface representing information about a component.
238
+ *
239
+ * This interface defines the structure for specifying details about a component, including its name, file location, type, properties, and other attributes.
240
+ */
132
241
  export interface ComponentInfo {
133
242
  name: string;
134
243
  file: string;
@@ -153,6 +262,11 @@ export interface ComponentInfo {
153
262
  };
154
263
  deprecated?: boolean;
155
264
  }
265
+ /**
266
+ * Interface representing information about a value.
267
+ *
268
+ * This interface defines the structure for specifying details about a value, including its name, file location, type, and comments.
269
+ */
156
270
  export interface ValueInfo {
157
271
  name: string;
158
272
  file: string;
@@ -160,6 +274,11 @@ export interface ValueInfo {
160
274
  type: Type;
161
275
  comments?: string[];
162
276
  }
277
+ /**
278
+ * Interface representing information about a previewer.
279
+ *
280
+ * This interface defines the structure for specifying details about a previewer, including its name, file location, and file pattern.
281
+ */
163
282
  export interface PreviewInfo {
164
283
  name: string;
165
284
  file: string;
@@ -167,9 +286,19 @@ export interface PreviewInfo {
167
286
  comments?: string[];
168
287
  filePattern: string;
169
288
  }
289
+ /**
290
+ * Interface representing information about a stream.
291
+ *
292
+ * This interface defines the structure for specifying details about a stream, including the property path associated with the stream.
293
+ */
170
294
  export interface StreamInfo {
171
295
  property: (string | number)[];
172
296
  }
297
+ /**
298
+ * Interface representing information about types defined in a source file.
299
+ *
300
+ * This interface defines the structure for organizing information about components, values, and previewers defined in a source file.
301
+ */
173
302
  export interface SourceFileTypeInfo {
174
303
  components: {
175
304
  [id: string]: ComponentInfo;
@@ -181,29 +310,115 @@ export interface SourceFileTypeInfo {
181
310
  [id: string]: PreviewInfo;
182
311
  };
183
312
  }
313
+ /**
314
+ * Type representing a mapping of file names to their respective type information.
315
+ *
316
+ * This type maps file names to SourceFileTypeInfo, providing an organized structure for storing type information associated with different files.
317
+ */
184
318
  export type TypeInfoByFileName = {
185
319
  [id: string]: SourceFileTypeInfo;
186
320
  };
321
+ /**
322
+ * Checks if two types are compatible.
323
+ *
324
+ * This function compares two Type objects to determine if they are compatible, considering their names and specific type details.
325
+ * @param a - The first type for comparison.
326
+ * @param b - The second type for comparison.
327
+ * @returns True if the types are compatible, otherwise false.
328
+ */
187
329
  export declare function areTypesCompatible(a: Type, b: Type): boolean;
330
+ /**
331
+ * Merges two sets of values definitions.
332
+ *
333
+ * This function combines two arrays of Values objects, merging them into a single array while avoiding duplicates.
334
+ * @param a - The first array of values definitions.
335
+ * @param b - The second array of values definitions.
336
+ * @returns An array of merged values definitions, or undefined if both inputs are undefined.
337
+ */
188
338
  export declare function mergeValues(a: Values[] | undefined, b: Values[] | undefined): Values[] | undefined;
339
+ /**
340
+ * Merges two property definitions into one.
341
+ *
342
+ * This function combines two Prop objects into a single Prop object, merging their attributes where possible.
343
+ * @param a - The first property definition.
344
+ * @param b - The second property definition.
345
+ * @returns A merged property definition, or undefined if they cannot be merged.
346
+ */
189
347
  export declare function mergeProps(a: Prop, b: Prop): Prop | undefined;
348
+ /**
349
+ * Merges two types into one, if they are compatible.
350
+ *
351
+ * @param a - The first type to merge.
352
+ * @param b - The second type to merge.
353
+ * @returns A merged type, or undefined if the types are not compatible.
354
+ */
190
355
  export declare function mergeTypes(a: Type, b: Type): Type | undefined;
356
+ /**
357
+ * Represents information about a template, including its name, content, and optional file extension.
358
+ *
359
+ * @interface
360
+ * @property name - The name of the template.
361
+ * @property content - The content of the template.
362
+ * @property extn - Optional. The file extension associated with the template.
363
+ */
191
364
  export interface TemplateInfo {
192
365
  name: string;
193
366
  content: string;
194
367
  extn?: string;
195
368
  }
369
+ /**
370
+ * Describes a file generator with its name, URL, and an optional icon.
371
+ *
372
+ * @interface
373
+ * @property name - The name of the file generator.
374
+ * @property url - The URL where the file generator is located or can be accessed.
375
+ * @property icon - Optional. A URL or a path to an icon representing the file generator.
376
+ */
196
377
  export interface FileGenerator {
197
378
  name: string;
198
379
  url: string;
199
380
  icon?: string;
200
381
  }
382
+ /**
383
+ * Converts a filename to a symbol path by removing certain file extension patterns.
384
+ *
385
+ * @param f - The filename to convert.
386
+ * @returns A symbol path derived from the given filename.
387
+ */
201
388
  export declare function symbolPathFromFilename(f: string): string;
389
+ /**
390
+ * Checks if a given value is valid for a specified type.
391
+ *
392
+ * @param def - The value to validate.
393
+ * @param t - The type against which the value is to be validated.
394
+ * @param allowUndefined - A boolean indicating whether undefined values are allowed.
395
+ * @returns A boolean indicating whether the value is valid for the given type.
396
+ */
202
397
  export declare function isValidValueForType(def: any, t: Type, allowUndefined?: boolean): boolean;
398
+ /**
399
+ * Generates a TypeScript output string for a given type.
400
+ *
401
+ * @param t - The type to generate output for.
402
+ * @param alwaysBasic - A boolean indicating whether to always use the basic type representation.
403
+ * @returns A string representing the type in TypeScript syntax.
404
+ */
203
405
  export declare function outputForType(t: Type, alwaysBasic?: boolean): string;
406
+ /**
407
+ * Checks if overrides in two objects are compatible with each other.
408
+ *
409
+ * @param a - The first object containing entity prop overrides.
410
+ * @param b - The second object containing entity prop overrides.
411
+ * @returns A boolean indicating whether the overrides in both objects are compatible.
412
+ */
204
413
  export declare function overridesAreCompatible(a: {
205
414
  [path: string]: EntityPropOverride;
206
415
  }, b: {
207
416
  [path: string]: EntityPropOverride;
208
417
  }): boolean;
418
+ /**
419
+ * Generates a default value for a given type.
420
+ *
421
+ * @param t - The type for which to generate a default value.
422
+ * @returns A default value appropriate for the given type.
423
+ */
209
424
  export declare function defaultValueForType(t: Type): any;
package/lib/types.js CHANGED
@@ -1,5 +1,10 @@
1
- import { EntityPropOverrideType, FunctionCallType } from './data/core';
1
+ import { EntityPropOverrideType, FunctionCallType, } from './data/core';
2
2
  import { getSafeKeyName } from './selectors';
3
+ /**
4
+ * Enumeration of type names used in type definitions.
5
+ *
6
+ * This enum lists different kinds of type names that can be used to represent various data types in a type definition.
7
+ */
3
8
  export var TypeName;
4
9
  (function (TypeName) {
5
10
  TypeName["String"] = "string";
@@ -15,6 +20,11 @@ export var TypeName;
15
20
  TypeName["Event"] = "event";
16
21
  TypeName["Entity"] = "entity";
17
22
  })(TypeName || (TypeName = {}));
23
+ /**
24
+ * Enumeration of type hints used to provide additional information about a type.
25
+ *
26
+ * This enum provides specific hints that can be used to give more context about how a type should be interpreted or displayed.
27
+ */
18
28
  export var TypeHint;
19
29
  (function (TypeHint) {
20
30
  TypeHint["proportion"] = "proportion";
@@ -34,6 +44,11 @@ export var TypeHint;
34
44
  TypeHint["emailaddress"] = "emailaddress";
35
45
  TypeHint["url"] = "url";
36
46
  })(TypeHint || (TypeHint = {}));
47
+ /**
48
+ * Enumeration of values types used in a values definition.
49
+ *
50
+ * This enum lists different kinds of values types that can be used in a values definition, representing various data sources or formats.
51
+ */
37
52
  export var ValuesType;
38
53
  (function (ValuesType) {
39
54
  ValuesType["files"] = "files";
@@ -48,6 +63,14 @@ export var ValuesType;
48
63
  ValuesType["layerids"] = "layerids";
49
64
  ValuesType["streamids"] = "streamids";
50
65
  })(ValuesType || (ValuesType = {}));
66
+ /**
67
+ * Checks if values in two objects are compatible.
68
+ *
69
+ * This function compares two objects containing string or number values to determine if they are compatible.
70
+ * @param l - The first object for comparison.
71
+ * @param r - The second object for comparison.
72
+ * @returns True if the objects are compatible, otherwise false.
73
+ */
51
74
  function valuesCompatible(l, r) {
52
75
  if (!l && !r)
53
76
  return true;
@@ -59,6 +82,14 @@ function valuesCompatible(l, r) {
59
82
  }
60
83
  return true;
61
84
  }
85
+ /**
86
+ * Checks if two types are compatible.
87
+ *
88
+ * This function compares two Type objects to determine if they are compatible, considering their names and specific type details.
89
+ * @param a - The first type for comparison.
90
+ * @param b - The second type for comparison.
91
+ * @returns True if the types are compatible, otherwise false.
92
+ */
62
93
  export function areTypesCompatible(a, b) {
63
94
  if (a.name !== b.name)
64
95
  return false;
@@ -118,6 +149,14 @@ export function areTypesCompatible(a, b) {
118
149
  }
119
150
  return true;
120
151
  }
152
+ /**
153
+ * Merges two sets of values definitions.
154
+ *
155
+ * This function combines two arrays of Values objects, merging them into a single array while avoiding duplicates.
156
+ * @param a - The first array of values definitions.
157
+ * @param b - The second array of values definitions.
158
+ * @returns An array of merged values definitions, or undefined if both inputs are undefined.
159
+ */
121
160
  export function mergeValues(a, b) {
122
161
  if (a === undefined && b === undefined)
123
162
  return undefined;
@@ -137,6 +176,14 @@ export function mergeValues(a, b) {
137
176
  }
138
177
  return ret;
139
178
  }
179
+ /**
180
+ * Merges two property definitions into one.
181
+ *
182
+ * This function combines two Prop objects into a single Prop object, merging their attributes where possible.
183
+ * @param a - The first property definition.
184
+ * @param b - The second property definition.
185
+ * @returns A merged property definition, or undefined if they cannot be merged.
186
+ */
140
187
  export function mergeProps(a, b) {
141
188
  if (a.name !== b.name)
142
189
  return;
@@ -165,10 +212,24 @@ export function mergeProps(a, b) {
165
212
  readonly: a.readonly,
166
213
  };
167
214
  }
215
+ /**
216
+ * Merges comments from two sources into a unique set of comments.
217
+ *
218
+ * @param a - An array of strings representing the first set of comments.
219
+ * @param b - An array of strings representing the second set of comments.
220
+ * @returns An array of merged unique comments.
221
+ */
168
222
  function mergeComments(a, b) {
169
223
  const s = new Set([...a, ...b]);
170
224
  return [...s.values()];
171
225
  }
226
+ /**
227
+ * Merges value comments for each identifier in two given objects.
228
+ *
229
+ * @param a - An object where keys are identifiers and values are arrays of comments.
230
+ * @param b - Another object with the same structure to merge with.
231
+ * @returns An object with merged comments for each identifier.
232
+ */
172
233
  function mergeValueComments(a, b) {
173
234
  const ret = {};
174
235
  for (const [k, v] of Object.entries(a)) {
@@ -176,6 +237,13 @@ function mergeValueComments(a, b) {
176
237
  }
177
238
  return ret;
178
239
  }
240
+ /**
241
+ * Merges two tuple type names if they are identical.
242
+ *
243
+ * @param a - The first tuple type to merge.
244
+ * @param b - The second tuple type to merge.
245
+ * @returns An array of merged tuple names, or undefined if they cannot be merged.
246
+ */
179
247
  function mergeTupleNames(a, b) {
180
248
  if (!a.names || !b.names)
181
249
  return;
@@ -187,6 +255,13 @@ function mergeTupleNames(a, b) {
187
255
  }
188
256
  return a.names;
189
257
  }
258
+ /**
259
+ * Merges two types into one, if they are compatible.
260
+ *
261
+ * @param a - The first type to merge.
262
+ * @param b - The second type to merge.
263
+ * @returns A merged type, or undefined if the types are not compatible.
264
+ */
190
265
  export function mergeTypes(a, b) {
191
266
  if (!areTypesCompatible(a, b))
192
267
  return;
@@ -283,9 +358,23 @@ export function mergeTypes(a, b) {
283
358
  }
284
359
  }
285
360
  const regex = new RegExp(/((\.tsx?)|(\.d\.ts)|(\.jsx?))$/, 'i');
361
+ /**
362
+ * Converts a filename to a symbol path by removing certain file extension patterns.
363
+ *
364
+ * @param f - The filename to convert.
365
+ * @returns A symbol path derived from the given filename.
366
+ */
286
367
  export function symbolPathFromFilename(f) {
287
368
  return f.replace(regex, '');
288
369
  }
370
+ /**
371
+ * Checks if a given value is valid for a specified type.
372
+ *
373
+ * @param def - The value to validate.
374
+ * @param t - The type against which the value is to be validated.
375
+ * @param allowUndefined - A boolean indicating whether undefined values are allowed.
376
+ * @returns A boolean indicating whether the value is valid for the given type.
377
+ */
289
378
  export function isValidValueForType(def, t, allowUndefined) {
290
379
  if (allowUndefined && typeof def === 'undefined')
291
380
  return true;
@@ -366,6 +455,13 @@ export function isValidValueForType(def, t, allowUndefined) {
366
455
  }
367
456
  return false;
368
457
  }
458
+ /**
459
+ * Generates a TypeScript output string for a given type.
460
+ *
461
+ * @param t - The type to generate output for.
462
+ * @param alwaysBasic - A boolean indicating whether to always use the basic type representation.
463
+ * @returns A string representing the type in TypeScript syntax.
464
+ */
369
465
  export function outputForType(t, alwaysBasic = false) {
370
466
  if (t.isObservable && !alwaysBasic)
371
467
  return `Observable<${getBasicType(t)}>`;
@@ -401,6 +497,13 @@ function getBasicType(t) {
401
497
  return 'Event';
402
498
  }
403
499
  }
500
+ /**
501
+ * Checks if overrides in two objects are compatible with each other.
502
+ *
503
+ * @param a - The first object containing entity prop overrides.
504
+ * @param b - The second object containing entity prop overrides.
505
+ * @returns A boolean indicating whether the overrides in both objects are compatible.
506
+ */
404
507
  export function overridesAreCompatible(a, b) {
405
508
  const bkeys = new Set(Object.keys(b));
406
509
  for (const [p, obj] of Object.entries(a)) {
@@ -457,6 +560,12 @@ function overrideAreCompatible(a, b) {
457
560
  return false;
458
561
  return true;
459
562
  }
563
+ /**
564
+ * Generates a default value for a given type.
565
+ *
566
+ * @param t - The type for which to generate a default value.
567
+ * @returns A default value appropriate for the given type.
568
+ */
460
569
  export function defaultValueForType(t) {
461
570
  switch (t.name) {
462
571
  case 'array':
@@ -3,8 +3,35 @@ import type { ZValues } from './values/values';
3
3
  interface Issue {
4
4
  text: string;
5
5
  }
6
+ /**
7
+ * Validates the structure of an `Import`.
8
+ *
9
+ * @param i - The `Import` to validate.
10
+ * @returns An array of `Issue` objects, each representing a validation issue found.
11
+ */
6
12
  export declare const validateImport: (i: Import) => Issue[];
13
+ /**
14
+ * Validates the top-level structure of ZValues.
15
+ *
16
+ * @param url - The URL associated with the ZValues.
17
+ * @param values - The `ZValues` object to validate.
18
+ * @returns An array of `Issue` objects, each representing a validation issue found.
19
+ */
7
20
  export declare const validatorZValuesTopLevel: (url: string, values: ZValues) => Issue[];
21
+ /**
22
+ * Validates the top-level structure of a ZComponentData object.
23
+ *
24
+ * @param url - The URL associated with the ZComponentData.
25
+ * @param component - The `ZComponentData` object to validate.
26
+ * @returns An array of `Issue` objects, each representing a validation issue found.
27
+ */
8
28
  export declare const validatorZcomponentTopLevel: (url: string, component: ZComponentData) => Issue[];
29
+ /**
30
+ * Validates the structure and consistency of a ZComponent's node.
31
+ *
32
+ * @param node - The `NodeData` of the ZComponent's node to validate.
33
+ * @param nodeId - The expected ID of the node.
34
+ * @returns An array of `Issue` objects, each representing a validation issue found.
35
+ */
9
36
  export declare const validatorZcomponentComponent: (node: NodeData, nodeId: string) => Issue[];
10
37
  export {};
package/lib/validators.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Validates the structure of an `Import`.
3
+ *
4
+ * @param i - The `Import` to validate.
5
+ * @returns An array of `Issue` objects, each representing a validation issue found.
6
+ */
1
7
  export const validateImport = (i) => {
2
8
  if (typeof i !== 'string')
3
9
  return [{ text: 'Import structure is invalid' }];
@@ -5,12 +11,26 @@ export const validateImport = (i) => {
5
11
  return [{ text: 'Import structure is invalid' }];
6
12
  return [];
7
13
  };
14
+ /**
15
+ * Validates the top-level structure of ZValues.
16
+ *
17
+ * @param url - The URL associated with the ZValues.
18
+ * @param values - The `ZValues` object to validate.
19
+ * @returns An array of `Issue` objects, each representing a validation issue found.
20
+ */
8
21
  export const validatorZValuesTopLevel = (url, values) => {
9
22
  if (typeof values !== 'object' || typeof values.keys !== 'object' || typeof values.values !== 'object' || typeof values.variantsByID !== 'object') {
10
23
  return [{ text: 'values structure is invalid' }];
11
24
  }
12
25
  return [];
13
26
  };
27
+ /**
28
+ * Validates the top-level structure of a ZComponentData object.
29
+ *
30
+ * @param url - The URL associated with the ZComponentData.
31
+ * @param component - The `ZComponentData` object to validate.
32
+ * @returns An array of `Issue` objects, each representing a validation issue found.
33
+ */
14
34
  export const validatorZcomponentTopLevel = (url, component) => {
15
35
  if (typeof component !== 'object' ||
16
36
  typeof component.nodes !== 'object' ||
@@ -27,6 +47,13 @@ export const validatorZcomponentTopLevel = (url, component) => {
27
47
  return [{ text: 'Component root node does not exist' }];
28
48
  return [];
29
49
  };
50
+ /**
51
+ * Validates the structure and consistency of a ZComponent's node.
52
+ *
53
+ * @param node - The `NodeData` of the ZComponent's node to validate.
54
+ * @param nodeId - The expected ID of the node.
55
+ * @returns An array of `Issue` objects, each representing a validation issue found.
56
+ */
30
57
  export const validatorZcomponentComponent = (node, nodeId) => {
31
58
  if (typeof node !== 'object')
32
59
  return [{ text: 'Node not object' }];
@@ -37,6 +37,11 @@ export type ZVariant = LocaleVariant | QueryStringVariant | UserAgentVariant | D
37
37
  export declare class ValuesManager {
38
38
  private valuesString;
39
39
  private profile;
40
+ /**
41
+ * Creates an instance of ValuesManager.
42
+ * @param valuesString - The values string.
43
+ * @param states - The states.
44
+ */
40
45
  constructor(valuesString: string, states: Map<string, any>);
41
46
  private getValueForKey;
42
47
  private getEnabledStateOfVariant;
@@ -31,6 +31,11 @@ export function getTypeForVariant(variant) {
31
31
  }
32
32
  export class ValuesManager {
33
33
  // TODO: Fix this any
34
+ /**
35
+ * Creates an instance of ValuesManager.
36
+ * @param valuesString - The values string.
37
+ * @param states - The states.
38
+ */
34
39
  constructor(valuesString, states) {
35
40
  this.valuesString = valuesString;
36
41
  this.profile = new Profile();