@zcomponent/core 1.14.3 → 1.16.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 (141) 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/inflate.d.ts +68 -0
  124. package/lib/inflate.js +76 -0
  125. package/lib/observable.d.ts +3 -3
  126. package/lib/observable.js +4 -4
  127. package/lib/profile.d.ts +27 -0
  128. package/lib/profile.js +26 -0
  129. package/lib/selectors.d.ts +114 -0
  130. package/lib/selectors.js +159 -7
  131. package/lib/types.d.ts +215 -0
  132. package/lib/types.js +110 -1
  133. package/lib/validators.d.ts +27 -0
  134. package/lib/validators.js +27 -0
  135. package/lib/values/values.d.ts +5 -0
  136. package/lib/values/values.js +5 -0
  137. package/lib/zcomponent.d.ts +72 -0
  138. package/lib/zcomponent.js +81 -0
  139. package/lib/zcomponentconstruction.d.ts +11 -1
  140. package/lib/zcomponentconstruction.js +10 -0
  141. package/package.json +7 -2
@@ -1,19 +1,112 @@
1
1
  import { Context, ContextManager } from '../context';
2
2
  import { Observable } from '../observable';
3
- /** @zcontext */
3
+ /**
4
+ * Context containing snapshot information.
5
+ * @zcontext
6
+ * */
4
7
  export declare class SnapshotContext extends Context {
5
- /** @zui */
8
+ /**
9
+ * Observable holding the current canvas image data URL.
10
+ * @zui
11
+ */
6
12
  readonly canvasImage: Observable<string, never>;
7
- /**@zui */
13
+ /**
14
+ * Observable indicating whether the Share API is supported in the current environment.
15
+ * @zui
16
+ */
8
17
  readonly shareAPISupported: Observable<boolean, never>;
9
- /** @zui */
18
+ /**
19
+ * Observable determining if the current canvas content can be shared.
20
+ * @zui
21
+ */
10
22
  readonly canShare: Observable<boolean, never>;
23
+ /**
24
+ * Observable containing the canvas image as a File object.
25
+ */
11
26
  readonly canvasFile: Observable<File | null, never>;
27
+ /**
28
+ * Observable storing the file name for the snapshot.
29
+ * Updates the file upon change.
30
+ */
12
31
  readonly fileName: Observable<string, never>;
32
+ /**
33
+ * Observable holding the text content to be shared with the snapshot.
34
+ */
13
35
  readonly text: Observable<string, never>;
36
+ /**
37
+ * Observable containing the title for the snapshot.
38
+ */
14
39
  readonly title: Observable<string, never>;
40
+ /**
41
+ * Observable storing the file type for the snapshot (e.g., 'image/png').
42
+ * Updates the file upon change.
43
+ */
15
44
  readonly fileType: Observable<string, never>;
45
+ /**
46
+ * Observable representing the quality setting of the snapshot image.
47
+ */
16
48
  readonly quality: Observable<number, never>;
49
+ /**
50
+ * Creates an instance of SnapshotContext.
51
+ * @param contextManager - The current ContextManager
52
+ */
17
53
  constructor(contextManager: ContextManager);
54
+ /**
55
+ * Converts the canvas image to a file.
56
+ */
18
57
  updateFile: () => Promise<void>;
19
58
  }
59
+ /**
60
+ * Retrieves the current canvas image as a data URL.
61
+ * @param ctx The ContextManager instance to access the SnapshotContext.
62
+ * @returns An Observable containing the canvas image data URL.
63
+ */
64
+ export declare function useCanvasImage(ctx: ContextManager): Observable<string, never>;
65
+ /**
66
+ * Checks if the Share API is supported in the current environment.
67
+ * @param ctx The ContextManager instance to access the SnapshotContext.
68
+ * @returns An Observable indicating whether the Share API is supported.
69
+ */
70
+ export declare function useShareAPISupported(ctx: ContextManager): Observable<boolean, never>;
71
+ /**
72
+ * Determines if the current canvas content can be shared via the Share API.
73
+ * @param ctx The ContextManager instance to access the SnapshotContext.
74
+ * @returns An Observable indicating whether the canvas can be shared.
75
+ */
76
+ export declare function useCanShare(ctx: ContextManager): Observable<boolean, never>;
77
+ /**
78
+ * Retrieves the file representation of the canvas image.
79
+ * @param ctx The ContextManager instance to access the SnapshotContext.
80
+ * @returns An Observable containing the canvas image as a File object.
81
+ */
82
+ export declare function useCanvasFile(ctx: ContextManager): Observable<File | null, never>;
83
+ /**
84
+ * Retrieves the file name for the snapshot to be shared.
85
+ * @param ctx The ContextManager instance to access the SnapshotContext.
86
+ * @returns An Observable containing the file name.
87
+ */
88
+ export declare function useFileName(ctx: ContextManager): Observable<string, never>;
89
+ /**
90
+ * Retrieves the text content to be shared along with the snapshot.
91
+ * @param ctx The ContextManager instance to access the SnapshotContext.
92
+ * @returns An Observable containing the share text.
93
+ */
94
+ export declare function useText(ctx: ContextManager): Observable<string, never>;
95
+ /**
96
+ * Retrieves the title for the snapshot to be shared.
97
+ * @param ctx The ContextManager instance to access the SnapshotContext.
98
+ * @returns An Observable containing the share title.
99
+ */
100
+ export declare function useTitle(ctx: ContextManager): Observable<string, never>;
101
+ /**
102
+ * Retrieves the file type for the snapshot to be shared.
103
+ * @param ctx The ContextManager instance to access the SnapshotContext.
104
+ * @returns An Observable containing the file type (e.g., 'image/png').
105
+ */
106
+ export declare function useFileType(ctx: ContextManager): Observable<string, never>;
107
+ /**
108
+ * Retrieves the quality setting for the snapshot image.
109
+ * @param ctx The ContextManager instance to access the SnapshotContext.
110
+ * @returns An Observable containing the image quality value.
111
+ */
112
+ export declare function useQuality(ctx: ContextManager): Observable<number, never>;
@@ -1,21 +1,60 @@
1
1
  import { Context } from '../context';
2
2
  import { Observable } from '../observable';
3
- /** @zcontext */
3
+ /**
4
+ * Context containing snapshot information.
5
+ * @zcontext
6
+ * */
4
7
  export class SnapshotContext extends Context {
8
+ /**
9
+ * Creates an instance of SnapshotContext.
10
+ * @param contextManager - The current ContextManager
11
+ */
5
12
  constructor(contextManager) {
6
13
  super(contextManager, {});
7
- /** @zui */
14
+ /**
15
+ * Observable holding the current canvas image data URL.
16
+ * @zui
17
+ */
8
18
  this.canvasImage = new Observable('');
9
- /**@zui */
19
+ /**
20
+ * Observable indicating whether the Share API is supported in the current environment.
21
+ * @zui
22
+ */
10
23
  this.shareAPISupported = new Observable('share' in navigator);
11
- /** @zui */
24
+ /**
25
+ * Observable determining if the current canvas content can be shared.
26
+ * @zui
27
+ */
12
28
  this.canShare = new Observable(false);
29
+ /**
30
+ * Observable containing the canvas image as a File object.
31
+ */
13
32
  this.canvasFile = new Observable(null);
33
+ /**
34
+ * Observable storing the file name for the snapshot.
35
+ * Updates the file upon change.
36
+ */
14
37
  this.fileName = new Observable('canvas', fileName => this.updateFile());
38
+ /**
39
+ * Observable holding the text content to be shared with the snapshot.
40
+ */
15
41
  this.text = new Observable('Check this out!');
42
+ /**
43
+ * Observable containing the title for the snapshot.
44
+ */
16
45
  this.title = new Observable('Canvas');
46
+ /**
47
+ * Observable storing the file type for the snapshot (e.g., 'image/png').
48
+ * Updates the file upon change.
49
+ */
17
50
  this.fileType = new Observable('image/png', fileType => this.updateFile());
51
+ /**
52
+ * Observable representing the quality setting of the snapshot image.
53
+ */
18
54
  this.quality = new Observable(0.92);
55
+ /**
56
+ * Converts the canvas image to a file.
57
+ */
19
58
  this.updateFile = async () => {
20
59
  const response = await fetch(this.canvasImage.value);
21
60
  const blob = await response.blob();
@@ -31,3 +70,75 @@ export class SnapshotContext extends Context {
31
70
  this.canvasImage.addListener(this.updateFile);
32
71
  }
33
72
  }
73
+ /**
74
+ * Retrieves the current canvas image as a data URL.
75
+ * @param ctx The ContextManager instance to access the SnapshotContext.
76
+ * @returns An Observable containing the canvas image data URL.
77
+ */
78
+ export function useCanvasImage(ctx) {
79
+ return ctx.get(SnapshotContext).canvasImage;
80
+ }
81
+ /**
82
+ * Checks if the Share API is supported in the current environment.
83
+ * @param ctx The ContextManager instance to access the SnapshotContext.
84
+ * @returns An Observable indicating whether the Share API is supported.
85
+ */
86
+ export function useShareAPISupported(ctx) {
87
+ return ctx.get(SnapshotContext).shareAPISupported;
88
+ }
89
+ /**
90
+ * Determines if the current canvas content can be shared via the Share API.
91
+ * @param ctx The ContextManager instance to access the SnapshotContext.
92
+ * @returns An Observable indicating whether the canvas can be shared.
93
+ */
94
+ export function useCanShare(ctx) {
95
+ return ctx.get(SnapshotContext).canShare;
96
+ }
97
+ /**
98
+ * Retrieves the file representation of the canvas image.
99
+ * @param ctx The ContextManager instance to access the SnapshotContext.
100
+ * @returns An Observable containing the canvas image as a File object.
101
+ */
102
+ export function useCanvasFile(ctx) {
103
+ return ctx.get(SnapshotContext).canvasFile;
104
+ }
105
+ /**
106
+ * Retrieves the file name for the snapshot to be shared.
107
+ * @param ctx The ContextManager instance to access the SnapshotContext.
108
+ * @returns An Observable containing the file name.
109
+ */
110
+ export function useFileName(ctx) {
111
+ return ctx.get(SnapshotContext).fileName;
112
+ }
113
+ /**
114
+ * Retrieves the text content to be shared along with the snapshot.
115
+ * @param ctx The ContextManager instance to access the SnapshotContext.
116
+ * @returns An Observable containing the share text.
117
+ */
118
+ export function useText(ctx) {
119
+ return ctx.get(SnapshotContext).text;
120
+ }
121
+ /**
122
+ * Retrieves the title for the snapshot to be shared.
123
+ * @param ctx The ContextManager instance to access the SnapshotContext.
124
+ * @returns An Observable containing the share title.
125
+ */
126
+ export function useTitle(ctx) {
127
+ return ctx.get(SnapshotContext).title;
128
+ }
129
+ /**
130
+ * Retrieves the file type for the snapshot to be shared.
131
+ * @param ctx The ContextManager instance to access the SnapshotContext.
132
+ * @returns An Observable containing the file type (e.g., 'image/png').
133
+ */
134
+ export function useFileType(ctx) {
135
+ return ctx.get(SnapshotContext).fileType;
136
+ }
137
+ /**
138
+ * Retrieves the quality setting for the snapshot image.
139
+ * @param ctx The ContextManager instance to access the SnapshotContext.
140
+ * @returns An Observable containing the image quality value.
141
+ */
142
+ export function useQuality(ctx) {
143
+ return ctx.get(SnapshotContext).quality;
144
+ }
@@ -1,13 +1,67 @@
1
- import { Component } from "../component";
2
- import { ContextManager, Context } from "../context";
1
+ import { Component } from '../component';
2
+ import { ContextManager, Context } from '../context';
3
+ import { Event } from '../event';
4
+ /**
5
+ * Manages and tracks tags associated with components.
6
+ * @zcontext
7
+ */
3
8
  export declare class TagContext extends Context {
9
+ /**
10
+ * A map storing the relationship between components and their associated tags.
11
+ */
4
12
  readonly tagsByComponent: Map<Component<any, import("../component").ConstructorProps>, Set<string>>;
13
+ /**
14
+ * A map storing the relationship between local tags and their associated components.
15
+ */
5
16
  readonly componentsByLocalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
17
+ /**
18
+ * An event that's emitted when the set of components that constitute a tag changes.
19
+ */
20
+ readonly onTagChange: Event<[string]>;
6
21
  private _global;
22
+ constructor(contextManager: ContextManager);
23
+ private _globalTagChange;
24
+ /**
25
+ * Registers a component with specified tags.
26
+ * Updates both local and global tag maps accordingly.
27
+ * @param component The component to register.
28
+ * @param tags The tags to associate with the component.
29
+ */
7
30
  registerComponent(component: Component, tags: string[]): void;
31
+ /**
32
+ * Registers a component with specified tags.
33
+ * Updates both local and global tag maps accordingly.
34
+ * @param component The component to register.
35
+ * @param tags The tags to associate with the component.
36
+ */
8
37
  unregisterComponent(component: Component): void;
38
+ /**
39
+ * Retrieves components associated with a specific tag.
40
+ * Searches both local and global tag maps.
41
+ * @param tag The tag to search for.
42
+ * @returns A set of components associated with the specified tag.
43
+ */
9
44
  getComponentsByTag(tag: string): Set<Component>;
45
+ /**
46
+ * Retrieves components associated with a list of tags.
47
+ * Consolidates results from both local and global tag maps.
48
+ * @param tags An array of tags to search for.
49
+ * @returns A set of components associated with the specified tags.
50
+ */
10
51
  getComponentsByTags(tags: string[]): Set<Component>;
52
+ dispose(): never;
11
53
  }
54
+ /**
55
+ * Retrieves components associated with a specific tag.
56
+ * @param mgr The ContextManager instance to access the TagContext.
57
+ * @param tag The tag to search for.
58
+ * @returns A set of components associated with the specified tag.
59
+ */
12
60
  export declare function getComponentsByTag(mgr: ContextManager, tag: string): Set<Component<any, import("../component").ConstructorProps>>;
61
+ /**
62
+ * Retrieves components associated with a list of tags.
63
+ * @param mgr The ContextManager instance to access the TagContext.
64
+ * @param tags An array of tags to search for.
65
+ * @returns A set of components associated with the specified tags.
66
+ */
13
67
  export declare function getComponentsByTags(mgr: ContextManager, tags: string[]): Set<Component<any, import("../component").ConstructorProps>>;
@@ -1,12 +1,37 @@
1
- import { Context } from "../context";
2
- import { GlobalTagContext } from "./globaltagcontext";
1
+ import { Context } from '../context';
2
+ import { Event } from '../event';
3
+ import { GlobalTagContext } from './globaltagcontext';
4
+ /**
5
+ * Manages and tracks tags associated with components.
6
+ * @zcontext
7
+ */
3
8
  export class TagContext extends Context {
4
- constructor() {
5
- super(...arguments);
9
+ constructor(contextManager) {
10
+ super(contextManager, {});
11
+ /**
12
+ * A map storing the relationship between components and their associated tags.
13
+ */
6
14
  this.tagsByComponent = new Map();
15
+ /**
16
+ * A map storing the relationship between local tags and their associated components.
17
+ */
7
18
  this.componentsByLocalTag = new Map();
19
+ /**
20
+ * An event that's emitted when the set of components that constitute a tag changes.
21
+ */
22
+ this.onTagChange = new Event();
8
23
  this._global = this.contextManager.get(GlobalTagContext);
24
+ this._globalTagChange = (tag) => {
25
+ this.onTagChange.emit(tag);
26
+ };
27
+ this._global.onTagChange.addListener(this._globalTagChange);
9
28
  }
29
+ /**
30
+ * Registers a component with specified tags.
31
+ * Updates both local and global tag maps accordingly.
32
+ * @param component The component to register.
33
+ * @param tags The tags to associate with the component.
34
+ */
10
35
  registerComponent(component, tags) {
11
36
  this.unregisterComponent(component);
12
37
  for (const tag of tags) {
@@ -16,10 +41,21 @@ export class TagContext extends Context {
16
41
  map.set(tag, set);
17
42
  }
18
43
  this.tagsByComponent.set(component, new Set(tags));
44
+ for (const tag of tags) {
45
+ if (tag.startsWith('local:'))
46
+ this.onTagChange.emit(tag);
47
+ else
48
+ this._global.onTagChange.emit(tag);
49
+ }
19
50
  }
20
- ;
51
+ /**
52
+ * Registers a component with specified tags.
53
+ * Updates both local and global tag maps accordingly.
54
+ * @param component The component to register.
55
+ * @param tags The tags to associate with the component.
56
+ */
21
57
  unregisterComponent(component) {
22
- let tags = this.tagsByComponent.get(component);
58
+ const tags = this.tagsByComponent.get(component);
23
59
  if (!tags)
24
60
  return;
25
61
  for (const tag of tags.values()) {
@@ -30,10 +66,28 @@ export class TagContext extends Context {
30
66
  entry.delete(component);
31
67
  }
32
68
  this.tagsByComponent.delete(component);
69
+ for (const tag of tags) {
70
+ if (tag.startsWith('local:'))
71
+ this.onTagChange.emit(tag);
72
+ else
73
+ this._global.onTagChange.emit(tag);
74
+ }
33
75
  }
76
+ /**
77
+ * Retrieves components associated with a specific tag.
78
+ * Searches both local and global tag maps.
79
+ * @param tag The tag to search for.
80
+ * @returns A set of components associated with the specified tag.
81
+ */
34
82
  getComponentsByTag(tag) {
35
- return ((!tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag).get(tag)) ?? new Set();
83
+ return (!tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag).get(tag) ?? new Set();
36
84
  }
85
+ /**
86
+ * Retrieves components associated with a list of tags.
87
+ * Consolidates results from both local and global tag maps.
88
+ * @param tags An array of tags to search for.
89
+ * @returns A set of components associated with the specified tags.
90
+ */
37
91
  getComponentsByTags(tags) {
38
92
  if (tags.length === 0)
39
93
  return new Set();
@@ -49,10 +103,26 @@ export class TagContext extends Context {
49
103
  }
50
104
  return ret;
51
105
  }
106
+ dispose() {
107
+ this._global.onTagChange.removeListener(this._globalTagChange);
108
+ return super.dispose();
109
+ }
52
110
  }
111
+ /**
112
+ * Retrieves components associated with a specific tag.
113
+ * @param mgr The ContextManager instance to access the TagContext.
114
+ * @param tag The tag to search for.
115
+ * @returns A set of components associated with the specified tag.
116
+ */
53
117
  export function getComponentsByTag(mgr, tag) {
54
118
  return mgr.get(TagContext).getComponentsByTag(tag);
55
119
  }
120
+ /**
121
+ * Retrieves components associated with a list of tags.
122
+ * @param mgr The ContextManager instance to access the TagContext.
123
+ * @param tags An array of tags to search for.
124
+ * @returns A set of components associated with the specified tags.
125
+ */
56
126
  export function getComponentsByTags(mgr, tags) {
57
127
  return mgr.get(TagContext).getComponentsByTags(tags);
58
128
  }
@@ -1,15 +1,48 @@
1
1
  import { ContextManager, Context } from '../context';
2
- /** @zcontext */
2
+ /**
3
+ * Manages the display of text alerts.
4
+ * @zcontext
5
+ */
3
6
  export declare class TextAlertContext extends Context {
4
7
  private _container;
8
+ /**
9
+ * Creates an instance of TextAlertContext.
10
+ * @param contextManager - The current ContextManager
11
+ */
5
12
  constructor(contextManager: ContextManager);
6
- /** @zprop */
13
+ /**
14
+ * Displays a text alert with specified options.
15
+ * @zprop
16
+ * @param txt The text content for the alert.
17
+ * @param options Optional configuration for the text alert appearance and behavior.
18
+ */
7
19
  showTextAlert(txt: string, options?: TextAlertOptions): void;
8
20
  }
21
+ /**
22
+ * Configuration options for displaying a text alert.
23
+ */
9
24
  export interface TextAlertOptions {
25
+ /**
26
+ * Custom class names to apply to the text alert.
27
+ */
10
28
  classNames?: string[];
29
+ /**
30
+ * Duration in milliseconds before the text alert automatically disappears. Defaults to 3000 (3 seconds).
31
+ */
11
32
  timeout?: number;
33
+ /**
34
+ * Background color of the text alert.
35
+ */
12
36
  backgroundColor?: string;
37
+ /**
38
+ * Text color of the text alert.
39
+ */
13
40
  textColor?: string;
14
41
  }
42
+ /**
43
+ * Triggers the display of a text alert.
44
+ * @param mgr The ContextManager instance to access the TextAlertContext.
45
+ * @param txt The text content for the alert.
46
+ * @param options Optional configuration for the text alert appearance and behavior.
47
+ */
15
48
  export declare function showTextAlert(mgr: ContextManager, txt: string, options?: TextAlertOptions): void;
@@ -1,7 +1,14 @@
1
1
  import { Context } from '../context';
2
2
  import { useOverlay } from './canvascontext';
3
- /** @zcontext */
3
+ /**
4
+ * Manages the display of text alerts.
5
+ * @zcontext
6
+ */
4
7
  export class TextAlertContext extends Context {
8
+ /**
9
+ * Creates an instance of TextAlertContext.
10
+ * @param contextManager - The current ContextManager
11
+ */
5
12
  constructor(contextManager) {
6
13
  super(contextManager, {});
7
14
  this._container = document.createElement('div');
@@ -10,7 +17,12 @@ export class TextAlertContext extends Context {
10
17
  val.appendChild(this._container);
11
18
  });
12
19
  }
13
- /** @zprop */
20
+ /**
21
+ * Displays a text alert with specified options.
22
+ * @zprop
23
+ * @param txt The text content for the alert.
24
+ * @param options Optional configuration for the text alert appearance and behavior.
25
+ */
14
26
  showTextAlert(txt, options) {
15
27
  const entry = document.createElement('div');
16
28
  entry.classList.add('zcomponent-textalert');
@@ -33,6 +45,12 @@ export class TextAlertContext extends Context {
33
45
  }, timeout);
34
46
  }
35
47
  }
48
+ /**
49
+ * Triggers the display of a text alert.
50
+ * @param mgr The ContextManager instance to access the TextAlertContext.
51
+ * @param txt The text content for the alert.
52
+ * @param options Optional configuration for the text alert appearance and behavior.
53
+ */
36
54
  export function showTextAlert(mgr, txt, options) {
37
55
  return mgr.get(TextAlertContext).showTextAlert(txt, options);
38
56
  }
@@ -1,12 +1,41 @@
1
1
  import { ContextManager, Context } from '../context';
2
2
  import { Event as EventClass } from '../event';
3
3
  import { Observable } from '../observable';
4
+ /**
5
+ * Manages and tracks user events within the application context.
6
+ */
4
7
  export declare class UserEventContext extends Context {
8
+ /**
9
+ * Event triggered when a user event occurs.
10
+ */
5
11
  readonly onUserEvent: EventClass<[Event]>;
6
12
  private _resolveNextUserEvent;
13
+ /**
14
+ * An observable that emits the next user event as a promise.
15
+ * It gets resolved with the event object when a user event occurs.
16
+ */
7
17
  readonly nextUserEvent: Observable<Promise<Event>, never>;
18
+ /**
19
+ * Registers and emits a user event.
20
+ * @param evt The user event to register.
21
+ */
8
22
  registerUserEvent(evt: Event): void;
9
23
  }
24
+ /**
25
+ * Provides access to the event that gets triggered on a user event.
26
+ * @param mgr The ContextManager instance to access the UserEventContext.
27
+ * @returns The EventClass instance representing user events.
28
+ */
10
29
  export declare function useOnUserEvent(mgr: ContextManager): EventClass<[Event]>;
30
+ /**
31
+ * Retrieves the next user event as a promise.
32
+ * @param mgr The ContextManager instance to access the UserEventContext.
33
+ * @returns A promise that resolves with the next user event.
34
+ */
11
35
  export declare function nextUserEvent(mgr: ContextManager): Promise<Event>;
36
+ /**
37
+ * Registers a user event in the UserEventContext.
38
+ * @param mgr The ContextManager instance to access the UserEventContext.
39
+ * @param evt The user event to register.
40
+ */
12
41
  export declare function registerUserEvent(mgr: ContextManager, evt: Event): void;
@@ -1,12 +1,26 @@
1
1
  import { Context } from '../context';
2
2
  import { Event as EventClass } from '../event';
3
3
  import { Observable } from '../observable';
4
+ /**
5
+ * Manages and tracks user events within the application context.
6
+ */
4
7
  export class UserEventContext extends Context {
5
8
  constructor() {
6
9
  super(...arguments);
10
+ /**
11
+ * Event triggered when a user event occurs.
12
+ */
7
13
  this.onUserEvent = new EventClass();
8
- this.nextUserEvent = new Observable(new Promise(resolve => this._resolveNextUserEvent = resolve), undefined, false);
14
+ /**
15
+ * An observable that emits the next user event as a promise.
16
+ * It gets resolved with the event object when a user event occurs.
17
+ */
18
+ this.nextUserEvent = new Observable(new Promise(resolve => (this._resolveNextUserEvent = resolve)), undefined, false);
9
19
  }
20
+ /**
21
+ * Registers and emits a user event.
22
+ * @param evt The user event to register.
23
+ */
10
24
  registerUserEvent(evt) {
11
25
  const currentResolve = this._resolveNextUserEvent;
12
26
  this.nextUserEvent.value = new Promise(resolve => {
@@ -16,12 +30,27 @@ export class UserEventContext extends Context {
16
30
  this.onUserEvent.emit(evt);
17
31
  }
18
32
  }
33
+ /**
34
+ * Provides access to the event that gets triggered on a user event.
35
+ * @param mgr The ContextManager instance to access the UserEventContext.
36
+ * @returns The EventClass instance representing user events.
37
+ */
19
38
  export function useOnUserEvent(mgr) {
20
39
  return mgr.get(UserEventContext).onUserEvent;
21
40
  }
41
+ /**
42
+ * Retrieves the next user event as a promise.
43
+ * @param mgr The ContextManager instance to access the UserEventContext.
44
+ * @returns A promise that resolves with the next user event.
45
+ */
22
46
  export function nextUserEvent(mgr) {
23
47
  return mgr.get(UserEventContext).nextUserEvent.value;
24
48
  }
49
+ /**
50
+ * Registers a user event in the UserEventContext.
51
+ * @param mgr The ContextManager instance to access the UserEventContext.
52
+ * @param evt The user event to register.
53
+ */
25
54
  export function registerUserEvent(mgr, evt) {
26
55
  return mgr.get(UserEventContext).registerUserEvent(evt);
27
56
  }