@zcomponent/core 2.0.0-alpha.2 → 2.0.0-alpha.4
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.
- package/lib/animation/layer.js +5 -0
- package/lib/animation/tracks/streamtrack.js +12 -1
- package/lib/behavior.d.ts +7 -1
- package/lib/behavior.js +6 -1
- package/lib/behaviors/ConsoleLog.d.ts +2 -0
- package/lib/behaviors/ConsoleLog.js +2 -0
- package/lib/behaviors/LaunchURL.d.ts +2 -0
- package/lib/behaviors/LaunchURL.js +2 -0
- package/lib/behaviors/LogAnalyticsEvent.d.ts +2 -0
- package/lib/behaviors/LogAnalyticsEvent.js +2 -0
- package/lib/behaviors/PlaySound.d.ts +3 -0
- package/lib/behaviors/PlaySound.js +7 -1
- package/lib/behaviors/ShowTextAlert.d.ts +1 -0
- package/lib/behaviors/ShowTextAlert.js +1 -0
- package/lib/behaviors/ToggleLayerClips.d.ts +1 -0
- package/lib/behaviors/ToggleLayerClips.js +9 -3
- package/lib/component.d.ts +7 -0
- package/lib/component.js +6 -0
- package/lib/components/AnimatedLoader.d.ts +6 -0
- package/lib/components/AnimatedLoader.js +6 -0
- package/lib/components/Audio.d.ts +28 -2
- package/lib/components/Audio.js +55 -8
- package/lib/components/DefaultCookieConsent.d.ts +11 -0
- package/lib/components/DefaultCookieConsent.js +33 -9
- package/lib/components/DefaultLoader.d.ts +3 -0
- package/lib/components/DefaultLoader.js +15 -8
- package/lib/components/Gamepad.d.ts +61 -0
- package/lib/components/Gamepad.js +61 -0
- package/lib/components/LongLoad.d.ts +3 -0
- package/lib/components/LongLoad.js +3 -0
- package/lib/components/SnapshotUI.d.ts +14 -0
- package/lib/components/SnapshotUI.js +27 -9
- package/lib/context.d.ts +11 -1
- package/lib/context.js +9 -1
- package/lib/contexts/analyticscontext.d.ts +3 -0
- package/lib/contexts/analyticscontext.js +14 -2
- package/lib/contexts/audiocontextcontext.d.ts +12 -0
- package/lib/contexts/audiocontextcontext.js +131 -56
- package/lib/contexts/canvascontext.d.ts +25 -0
- package/lib/contexts/canvascontext.js +75 -15
- package/lib/contexts/cookieconsentcontext.d.ts +19 -0
- package/lib/contexts/cookieconsentcontext.js +135 -27
- package/lib/contexts/environmentcontext.d.ts +13 -5
- package/lib/contexts/environmentcontext.js +26 -14
- package/lib/contexts/gamepadcontext.d.ts +17 -0
- package/lib/contexts/gamepadcontext.js +160 -74
- package/lib/contexts/gesturecontext.d.ts +11 -0
- package/lib/contexts/gesturecontext.js +266 -169
- package/lib/contexts/globaltagcontext.d.ts +2 -0
- package/lib/contexts/globaltagcontext.js +69 -10
- package/lib/contexts/loadcontext.d.ts +19 -0
- package/lib/contexts/loadcontext.js +68 -18
- package/lib/contexts/orientationcontext.d.ts +13 -0
- package/lib/contexts/orientationcontext.js +60 -11
- package/lib/contexts/snapshotContext.d.ts +10 -0
- package/lib/contexts/snapshotContext.js +55 -9
- package/lib/contexts/tagcontext.d.ts +14 -0
- package/lib/contexts/tagcontext.js +186 -98
- package/lib/entity.d.ts +5 -1
- package/lib/entity.js +4 -1
- package/lib/zcomponent.d.ts +20 -0
- package/lib/zcomponent.js +81 -12
- package/package.json +84 -84
|
@@ -33,7 +33,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
33
33
|
return useValue ? value : void 0;
|
|
34
34
|
};
|
|
35
35
|
import { Context } from '../context';
|
|
36
|
-
import { zUI } from '../decorators';
|
|
36
|
+
import { zIgnore, zUI } from '../decorators';
|
|
37
37
|
import { Observable } from '../observable';
|
|
38
38
|
/**
|
|
39
39
|
* Context containing snapshot information.
|
|
@@ -50,67 +50,113 @@ let SnapshotContext = (() => {
|
|
|
50
50
|
let _canShare_decorators;
|
|
51
51
|
let _canShare_initializers = [];
|
|
52
52
|
let _canShare_extraInitializers = [];
|
|
53
|
+
let _canvasFile_decorators;
|
|
54
|
+
let _canvasFile_initializers = [];
|
|
55
|
+
let _canvasFile_extraInitializers = [];
|
|
56
|
+
let _fileName_decorators;
|
|
57
|
+
let _fileName_initializers = [];
|
|
58
|
+
let _fileName_extraInitializers = [];
|
|
59
|
+
let _text_decorators;
|
|
60
|
+
let _text_initializers = [];
|
|
61
|
+
let _text_extraInitializers = [];
|
|
62
|
+
let _title_decorators;
|
|
63
|
+
let _title_initializers = [];
|
|
64
|
+
let _title_extraInitializers = [];
|
|
65
|
+
let _fileType_decorators;
|
|
66
|
+
let _fileType_initializers = [];
|
|
67
|
+
let _fileType_extraInitializers = [];
|
|
68
|
+
let _quality_decorators;
|
|
69
|
+
let _quality_initializers = [];
|
|
70
|
+
let _quality_extraInitializers = [];
|
|
71
|
+
let _updateFile_decorators;
|
|
72
|
+
let _updateFile_initializers = [];
|
|
73
|
+
let _updateFile_extraInitializers = [];
|
|
53
74
|
return class SnapshotContext extends _classSuper {
|
|
54
75
|
static {
|
|
55
76
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
56
77
|
_canvasImage_decorators = [zUI()];
|
|
57
78
|
_shareAPISupported_decorators = [zUI()];
|
|
58
79
|
_canShare_decorators = [zUI()];
|
|
80
|
+
_canvasFile_decorators = [zIgnore()];
|
|
81
|
+
_fileName_decorators = [zIgnore()];
|
|
82
|
+
_text_decorators = [zIgnore()];
|
|
83
|
+
_title_decorators = [zIgnore()];
|
|
84
|
+
_fileType_decorators = [zIgnore()];
|
|
85
|
+
_quality_decorators = [zIgnore()];
|
|
86
|
+
_updateFile_decorators = [zIgnore()];
|
|
59
87
|
__esDecorate(null, null, _canvasImage_decorators, { kind: "field", name: "canvasImage", static: false, private: false, access: { has: obj => "canvasImage" in obj, get: obj => obj.canvasImage, set: (obj, value) => { obj.canvasImage = value; } }, metadata: _metadata }, _canvasImage_initializers, _canvasImage_extraInitializers);
|
|
60
88
|
__esDecorate(null, null, _shareAPISupported_decorators, { kind: "field", name: "shareAPISupported", static: false, private: false, access: { has: obj => "shareAPISupported" in obj, get: obj => obj.shareAPISupported, set: (obj, value) => { obj.shareAPISupported = value; } }, metadata: _metadata }, _shareAPISupported_initializers, _shareAPISupported_extraInitializers);
|
|
61
89
|
__esDecorate(null, null, _canShare_decorators, { kind: "field", name: "canShare", static: false, private: false, access: { has: obj => "canShare" in obj, get: obj => obj.canShare, set: (obj, value) => { obj.canShare = value; } }, metadata: _metadata }, _canShare_initializers, _canShare_extraInitializers);
|
|
90
|
+
__esDecorate(null, null, _canvasFile_decorators, { kind: "field", name: "canvasFile", static: false, private: false, access: { has: obj => "canvasFile" in obj, get: obj => obj.canvasFile, set: (obj, value) => { obj.canvasFile = value; } }, metadata: _metadata }, _canvasFile_initializers, _canvasFile_extraInitializers);
|
|
91
|
+
__esDecorate(null, null, _fileName_decorators, { kind: "field", name: "fileName", static: false, private: false, access: { has: obj => "fileName" in obj, get: obj => obj.fileName, set: (obj, value) => { obj.fileName = value; } }, metadata: _metadata }, _fileName_initializers, _fileName_extraInitializers);
|
|
92
|
+
__esDecorate(null, null, _text_decorators, { kind: "field", name: "text", static: false, private: false, access: { has: obj => "text" in obj, get: obj => obj.text, set: (obj, value) => { obj.text = value; } }, metadata: _metadata }, _text_initializers, _text_extraInitializers);
|
|
93
|
+
__esDecorate(null, null, _title_decorators, { kind: "field", name: "title", static: false, private: false, access: { has: obj => "title" in obj, get: obj => obj.title, set: (obj, value) => { obj.title = value; } }, metadata: _metadata }, _title_initializers, _title_extraInitializers);
|
|
94
|
+
__esDecorate(null, null, _fileType_decorators, { kind: "field", name: "fileType", static: false, private: false, access: { has: obj => "fileType" in obj, get: obj => obj.fileType, set: (obj, value) => { obj.fileType = value; } }, metadata: _metadata }, _fileType_initializers, _fileType_extraInitializers);
|
|
95
|
+
__esDecorate(null, null, _quality_decorators, { kind: "field", name: "quality", static: false, private: false, access: { has: obj => "quality" in obj, get: obj => obj.quality, set: (obj, value) => { obj.quality = value; } }, metadata: _metadata }, _quality_initializers, _quality_extraInitializers);
|
|
96
|
+
__esDecorate(null, null, _updateFile_decorators, { kind: "field", name: "updateFile", static: false, private: false, access: { has: obj => "updateFile" in obj, get: obj => obj.updateFile, set: (obj, value) => { obj.updateFile = value; } }, metadata: _metadata }, _updateFile_initializers, _updateFile_extraInitializers);
|
|
62
97
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
63
98
|
}
|
|
64
99
|
/**
|
|
65
100
|
* Observable holding the current canvas image data URL.
|
|
101
|
+
* @zui
|
|
66
102
|
*/
|
|
67
103
|
canvasImage = __runInitializers(this, _canvasImage_initializers, new Observable(''));
|
|
68
104
|
/**
|
|
69
105
|
* Observable indicating whether the Share API is supported in the current environment.
|
|
106
|
+
* @zui
|
|
70
107
|
*/
|
|
71
108
|
shareAPISupported = (__runInitializers(this, _canvasImage_extraInitializers), __runInitializers(this, _shareAPISupported_initializers, new Observable('share' in navigator)));
|
|
72
109
|
/**
|
|
73
110
|
* Observable determining if the current canvas content can be shared.
|
|
111
|
+
* @zui
|
|
74
112
|
*/
|
|
75
113
|
canShare = (__runInitializers(this, _shareAPISupported_extraInitializers), __runInitializers(this, _canShare_initializers, new Observable(false)));
|
|
76
114
|
/**
|
|
77
115
|
* Observable containing the canvas image as a File object.
|
|
116
|
+
* @zignore
|
|
78
117
|
*/
|
|
79
|
-
canvasFile = (__runInitializers(this, _canShare_extraInitializers), new Observable(null));
|
|
118
|
+
canvasFile = (__runInitializers(this, _canShare_extraInitializers), __runInitializers(this, _canvasFile_initializers, new Observable(null)));
|
|
80
119
|
/**
|
|
81
120
|
* Observable storing the file name for the snapshot.
|
|
82
121
|
* Updates the file upon change.
|
|
122
|
+
* @zignore
|
|
83
123
|
*/
|
|
84
|
-
fileName = new Observable('canvas', fileName => this.updateFile());
|
|
124
|
+
fileName = (__runInitializers(this, _canvasFile_extraInitializers), __runInitializers(this, _fileName_initializers, new Observable('canvas', fileName => this.updateFile())));
|
|
85
125
|
/**
|
|
86
126
|
* Observable holding the text content to be shared with the snapshot.
|
|
127
|
+
* @zignore
|
|
87
128
|
*/
|
|
88
|
-
text = new Observable('Check this out!');
|
|
129
|
+
text = (__runInitializers(this, _fileName_extraInitializers), __runInitializers(this, _text_initializers, new Observable('Check this out!')));
|
|
89
130
|
/**
|
|
90
131
|
* Observable containing the title for the snapshot.
|
|
132
|
+
* @zignore
|
|
91
133
|
*/
|
|
92
|
-
title = new Observable('Canvas');
|
|
134
|
+
title = (__runInitializers(this, _text_extraInitializers), __runInitializers(this, _title_initializers, new Observable('Canvas')));
|
|
93
135
|
/**
|
|
94
136
|
* Observable storing the file type for the snapshot (e.g., 'image/png').
|
|
95
137
|
* Updates the file upon change.
|
|
138
|
+
* @zignore
|
|
96
139
|
*/
|
|
97
|
-
fileType = new Observable('image/png', fileType => this.updateFile());
|
|
140
|
+
fileType = (__runInitializers(this, _title_extraInitializers), __runInitializers(this, _fileType_initializers, new Observable('image/png', fileType => this.updateFile())));
|
|
98
141
|
/**
|
|
99
142
|
* Observable representing the quality setting of the snapshot image.
|
|
143
|
+
* @zignore
|
|
100
144
|
*/
|
|
101
|
-
quality = new Observable(0.92);
|
|
145
|
+
quality = (__runInitializers(this, _fileType_extraInitializers), __runInitializers(this, _quality_initializers, new Observable(0.92)));
|
|
102
146
|
/**
|
|
103
147
|
* Creates an instance of SnapshotContext.
|
|
104
148
|
* @param contextManager - The current ContextManager
|
|
105
149
|
*/
|
|
106
150
|
constructor(contextManager) {
|
|
107
151
|
super(contextManager, {});
|
|
152
|
+
__runInitializers(this, _updateFile_extraInitializers);
|
|
108
153
|
this.canvasImage.addListener(this.updateFile);
|
|
109
154
|
}
|
|
110
155
|
/**
|
|
111
156
|
* Converts the canvas image to a file.
|
|
157
|
+
* @zignore
|
|
112
158
|
*/
|
|
113
|
-
updateFile = async () => {
|
|
159
|
+
updateFile = (__runInitializers(this, _quality_extraInitializers), __runInitializers(this, _updateFile_initializers, async () => {
|
|
114
160
|
if (!this.canvasImage.value)
|
|
115
161
|
return;
|
|
116
162
|
const response = await fetch(this.canvasImage.value);
|
|
@@ -123,7 +169,7 @@ let SnapshotContext = (() => {
|
|
|
123
169
|
files: [file],
|
|
124
170
|
});
|
|
125
171
|
this.canvasFile.value = file;
|
|
126
|
-
};
|
|
172
|
+
}));
|
|
127
173
|
};
|
|
128
174
|
})();
|
|
129
175
|
export { SnapshotContext };
|
|
@@ -8,14 +8,17 @@ import { Event } from '../event';
|
|
|
8
8
|
export declare class TagContext extends Context {
|
|
9
9
|
/**
|
|
10
10
|
* A map storing the relationship between components and their associated tags.
|
|
11
|
+
* @zignore
|
|
11
12
|
*/
|
|
12
13
|
readonly tagsByComponent: Map<Component<any, import("..").ConstructorProps>, Set<string>>;
|
|
13
14
|
/**
|
|
14
15
|
* A map storing the relationship between local tags and their associated components.
|
|
16
|
+
* @zignore
|
|
15
17
|
*/
|
|
16
18
|
readonly componentsByLocalTag: Map<string, Set<Component<any, import("..").ConstructorProps>>>;
|
|
17
19
|
/**
|
|
18
20
|
* An event that's emitted when the set of components that constitute a tag changes.
|
|
21
|
+
* @zignore
|
|
19
22
|
*/
|
|
20
23
|
readonly onTagChange: Event<[string]>;
|
|
21
24
|
private _global;
|
|
@@ -24,31 +27,42 @@ export declare class TagContext extends Context {
|
|
|
24
27
|
/**
|
|
25
28
|
* Registers a component with specified tags.
|
|
26
29
|
* Updates both local and global tag maps accordingly.
|
|
30
|
+
*
|
|
27
31
|
* @param component The component to register.
|
|
28
32
|
* @param tags The tags to associate with the component.
|
|
33
|
+
* @zignore
|
|
29
34
|
*/
|
|
30
35
|
registerComponent(component: Component, tags: string[]): void;
|
|
31
36
|
/**
|
|
32
37
|
* Registers a component with specified tags.
|
|
33
38
|
* Updates both local and global tag maps accordingly.
|
|
39
|
+
*
|
|
34
40
|
* @param component The component to register.
|
|
35
41
|
* @param tags The tags to associate with the component.
|
|
42
|
+
* @zignore
|
|
36
43
|
*/
|
|
37
44
|
unregisterComponent(component: Component): void;
|
|
38
45
|
/**
|
|
39
46
|
* Retrieves components associated with a specific tag.
|
|
40
47
|
* Searches both local and global tag maps.
|
|
48
|
+
*
|
|
41
49
|
* @param tag The tag to search for.
|
|
42
50
|
* @returns A set of components associated with the specified tag.
|
|
51
|
+
* @zignore
|
|
43
52
|
*/
|
|
44
53
|
getComponentsByTag(tag: string): Set<Component>;
|
|
45
54
|
/**
|
|
46
55
|
* Retrieves components associated with a list of tags.
|
|
47
56
|
* Consolidates results from both local and global tag maps.
|
|
57
|
+
*
|
|
48
58
|
* @param tags An array of tags to search for.
|
|
49
59
|
* @returns A set of components associated with the specified tags.
|
|
60
|
+
* @zignore
|
|
50
61
|
*/
|
|
51
62
|
getComponentsByTags(tags: string[]): Set<Component>;
|
|
63
|
+
/**
|
|
64
|
+
* @zignore
|
|
65
|
+
*/
|
|
52
66
|
dispose(): never;
|
|
53
67
|
}
|
|
54
68
|
/**
|
|
@@ -1,113 +1,201 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
1
35
|
import { Context } from '../context';
|
|
36
|
+
import { zIgnore } from '../decorators';
|
|
2
37
|
import { Event } from '../event';
|
|
3
38
|
import { GlobalTagContext } from './globaltagcontext';
|
|
4
39
|
/**
|
|
5
40
|
* Manages and tracks tags associated with components.
|
|
6
41
|
* @zcontext
|
|
7
42
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
let TagContext = (() => {
|
|
44
|
+
let _classSuper = Context;
|
|
45
|
+
let _instanceExtraInitializers = [];
|
|
46
|
+
let _tagsByComponent_decorators;
|
|
47
|
+
let _tagsByComponent_initializers = [];
|
|
48
|
+
let _tagsByComponent_extraInitializers = [];
|
|
49
|
+
let _componentsByLocalTag_decorators;
|
|
50
|
+
let _componentsByLocalTag_initializers = [];
|
|
51
|
+
let _componentsByLocalTag_extraInitializers = [];
|
|
52
|
+
let _onTagChange_decorators;
|
|
53
|
+
let _onTagChange_initializers = [];
|
|
54
|
+
let _onTagChange_extraInitializers = [];
|
|
55
|
+
let _registerComponent_decorators;
|
|
56
|
+
let _unregisterComponent_decorators;
|
|
57
|
+
let _getComponentsByTag_decorators;
|
|
58
|
+
let _getComponentsByTags_decorators;
|
|
59
|
+
let _dispose_decorators;
|
|
60
|
+
return class TagContext extends _classSuper {
|
|
61
|
+
static {
|
|
62
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
63
|
+
_tagsByComponent_decorators = [zIgnore()];
|
|
64
|
+
_componentsByLocalTag_decorators = [zIgnore()];
|
|
65
|
+
_onTagChange_decorators = [zIgnore()];
|
|
66
|
+
_registerComponent_decorators = [zIgnore()];
|
|
67
|
+
_unregisterComponent_decorators = [zIgnore()];
|
|
68
|
+
_getComponentsByTag_decorators = [zIgnore()];
|
|
69
|
+
_getComponentsByTags_decorators = [zIgnore()];
|
|
70
|
+
_dispose_decorators = [zIgnore()];
|
|
71
|
+
__esDecorate(this, null, _registerComponent_decorators, { kind: "method", name: "registerComponent", static: false, private: false, access: { has: obj => "registerComponent" in obj, get: obj => obj.registerComponent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
72
|
+
__esDecorate(this, null, _unregisterComponent_decorators, { kind: "method", name: "unregisterComponent", static: false, private: false, access: { has: obj => "unregisterComponent" in obj, get: obj => obj.unregisterComponent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
73
|
+
__esDecorate(this, null, _getComponentsByTag_decorators, { kind: "method", name: "getComponentsByTag", static: false, private: false, access: { has: obj => "getComponentsByTag" in obj, get: obj => obj.getComponentsByTag }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
74
|
+
__esDecorate(this, null, _getComponentsByTags_decorators, { kind: "method", name: "getComponentsByTags", static: false, private: false, access: { has: obj => "getComponentsByTags" in obj, get: obj => obj.getComponentsByTags }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
75
|
+
__esDecorate(this, null, _dispose_decorators, { kind: "method", name: "dispose", static: false, private: false, access: { has: obj => "dispose" in obj, get: obj => obj.dispose }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
76
|
+
__esDecorate(null, null, _tagsByComponent_decorators, { kind: "field", name: "tagsByComponent", static: false, private: false, access: { has: obj => "tagsByComponent" in obj, get: obj => obj.tagsByComponent, set: (obj, value) => { obj.tagsByComponent = value; } }, metadata: _metadata }, _tagsByComponent_initializers, _tagsByComponent_extraInitializers);
|
|
77
|
+
__esDecorate(null, null, _componentsByLocalTag_decorators, { kind: "field", name: "componentsByLocalTag", static: false, private: false, access: { has: obj => "componentsByLocalTag" in obj, get: obj => obj.componentsByLocalTag, set: (obj, value) => { obj.componentsByLocalTag = value; } }, metadata: _metadata }, _componentsByLocalTag_initializers, _componentsByLocalTag_extraInitializers);
|
|
78
|
+
__esDecorate(null, null, _onTagChange_decorators, { kind: "field", name: "onTagChange", static: false, private: false, access: { has: obj => "onTagChange" in obj, get: obj => obj.onTagChange, set: (obj, value) => { obj.onTagChange = value; } }, metadata: _metadata }, _onTagChange_initializers, _onTagChange_extraInitializers);
|
|
79
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
42
80
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
/**
|
|
82
|
+
* A map storing the relationship between components and their associated tags.
|
|
83
|
+
* @zignore
|
|
84
|
+
*/
|
|
85
|
+
tagsByComponent = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _tagsByComponent_initializers, new Map()));
|
|
86
|
+
/**
|
|
87
|
+
* A map storing the relationship between local tags and their associated components.
|
|
88
|
+
* @zignore
|
|
89
|
+
*/
|
|
90
|
+
componentsByLocalTag = (__runInitializers(this, _tagsByComponent_extraInitializers), __runInitializers(this, _componentsByLocalTag_initializers, new Map()));
|
|
91
|
+
/**
|
|
92
|
+
* An event that's emitted when the set of components that constitute a tag changes.
|
|
93
|
+
* @zignore
|
|
94
|
+
*/
|
|
95
|
+
onTagChange = (__runInitializers(this, _componentsByLocalTag_extraInitializers), __runInitializers(this, _onTagChange_initializers, new Event()));
|
|
96
|
+
_global = (__runInitializers(this, _onTagChange_extraInitializers), this.contextManager.get(GlobalTagContext));
|
|
97
|
+
constructor(contextManager) {
|
|
98
|
+
super(contextManager, {});
|
|
99
|
+
this._global.onTagChange.addListener(this._globalTagChange);
|
|
49
100
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
101
|
+
_globalTagChange = (tag) => {
|
|
102
|
+
this.onTagChange.emit(tag);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Registers a component with specified tags.
|
|
106
|
+
* Updates both local and global tag maps accordingly.
|
|
107
|
+
*
|
|
108
|
+
* @param component The component to register.
|
|
109
|
+
* @param tags The tags to associate with the component.
|
|
110
|
+
* @zignore
|
|
111
|
+
*/
|
|
112
|
+
registerComponent(component, tags) {
|
|
113
|
+
this.unregisterComponent(component);
|
|
114
|
+
for (const tag of tags) {
|
|
115
|
+
const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
|
|
116
|
+
const set = map.get(tag) ?? new Set();
|
|
117
|
+
set.add(component);
|
|
118
|
+
map.set(tag, set);
|
|
119
|
+
}
|
|
120
|
+
this.tagsByComponent.set(component, new Set(tags));
|
|
121
|
+
for (const tag of tags) {
|
|
122
|
+
if (tag.startsWith('local:'))
|
|
123
|
+
this.onTagChange.emit(tag);
|
|
124
|
+
else
|
|
125
|
+
this._global.onTagChange.emit(tag);
|
|
126
|
+
}
|
|
67
127
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Registers a component with specified tags.
|
|
130
|
+
* Updates both local and global tag maps accordingly.
|
|
131
|
+
*
|
|
132
|
+
* @param component The component to register.
|
|
133
|
+
* @param tags The tags to associate with the component.
|
|
134
|
+
* @zignore
|
|
135
|
+
*/
|
|
136
|
+
unregisterComponent(component) {
|
|
137
|
+
const tags = this.tagsByComponent.get(component);
|
|
138
|
+
if (!tags)
|
|
139
|
+
return;
|
|
140
|
+
for (const tag of tags.values()) {
|
|
141
|
+
const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
|
|
142
|
+
const entry = map.get(tag);
|
|
143
|
+
if (!entry)
|
|
144
|
+
continue;
|
|
145
|
+
entry.delete(component);
|
|
146
|
+
}
|
|
147
|
+
this.tagsByComponent.delete(component);
|
|
148
|
+
for (const tag of tags) {
|
|
149
|
+
if (tag.startsWith('local:'))
|
|
150
|
+
this.onTagChange.emit(tag);
|
|
151
|
+
else
|
|
152
|
+
this._global.onTagChange.emit(tag);
|
|
153
|
+
}
|
|
74
154
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
*/
|
|
91
|
-
getComponentsByTags(tags) {
|
|
92
|
-
if (tags.length === 0)
|
|
93
|
-
return new Set();
|
|
94
|
-
if (tags.length === 1)
|
|
95
|
-
return this.getComponentsByTag(tags[0]);
|
|
96
|
-
const ret = new Set();
|
|
97
|
-
for (const tag of tags) {
|
|
98
|
-
const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
|
|
99
|
-
const entries = map.get(tag);
|
|
100
|
-
if (!entries)
|
|
101
|
-
continue;
|
|
102
|
-
entries.forEach(entry => ret.add(entry));
|
|
155
|
+
/**
|
|
156
|
+
* Retrieves components associated with a specific tag.
|
|
157
|
+
* Searches both local and global tag maps.
|
|
158
|
+
*
|
|
159
|
+
* @param tag The tag to search for.
|
|
160
|
+
* @returns A set of components associated with the specified tag.
|
|
161
|
+
* @zignore
|
|
162
|
+
*/
|
|
163
|
+
getComponentsByTag(tag) {
|
|
164
|
+
return (!tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag).get(tag) ?? new Set();
|
|
103
165
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves components associated with a list of tags.
|
|
168
|
+
* Consolidates results from both local and global tag maps.
|
|
169
|
+
*
|
|
170
|
+
* @param tags An array of tags to search for.
|
|
171
|
+
* @returns A set of components associated with the specified tags.
|
|
172
|
+
* @zignore
|
|
173
|
+
*/
|
|
174
|
+
getComponentsByTags(tags) {
|
|
175
|
+
if (tags.length === 0)
|
|
176
|
+
return new Set();
|
|
177
|
+
if (tags.length === 1)
|
|
178
|
+
return this.getComponentsByTag(tags[0]);
|
|
179
|
+
const ret = new Set();
|
|
180
|
+
for (const tag of tags) {
|
|
181
|
+
const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
|
|
182
|
+
const entries = map.get(tag);
|
|
183
|
+
if (!entries)
|
|
184
|
+
continue;
|
|
185
|
+
entries.forEach(entry => ret.add(entry));
|
|
186
|
+
}
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @zignore
|
|
191
|
+
*/
|
|
192
|
+
dispose() {
|
|
193
|
+
this._global.onTagChange.removeListener(this._globalTagChange);
|
|
194
|
+
return super.dispose();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
})();
|
|
198
|
+
export { TagContext };
|
|
111
199
|
/**
|
|
112
200
|
* Retrieves components associated with a specific tag.
|
|
113
201
|
* @param mgr The ContextManager instance to access the TagContext.
|
package/lib/entity.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ZComponent } from './zcomponent';
|
|
|
8
8
|
* Base class for all components and behaviors.
|
|
9
9
|
*/
|
|
10
10
|
export declare class Entity {
|
|
11
|
+
/** @zignore */
|
|
11
12
|
readonly contextManager: ContextManager;
|
|
12
13
|
/**
|
|
13
14
|
* @default []
|
|
@@ -32,13 +33,16 @@ export declare class Entity {
|
|
|
32
33
|
protected _enabledResolved: boolean;
|
|
33
34
|
/**
|
|
34
35
|
* An event that is fired as the last act of this entity being destroyed.
|
|
36
|
+
* @zignore
|
|
35
37
|
*/
|
|
36
38
|
readonly onDispose: Event<[]>;
|
|
37
39
|
/**
|
|
38
40
|
* Creates an instance of Entity.
|
|
39
41
|
* @param contextManager The current ContextManager
|
|
40
42
|
*/
|
|
41
|
-
constructor(
|
|
43
|
+
constructor(
|
|
44
|
+
/** @zignore */
|
|
45
|
+
contextManager: ContextManager);
|
|
42
46
|
/**
|
|
43
47
|
* Gets the disposed status of the entity.
|
|
44
48
|
* @returns {boolean} The disposed status.
|
package/lib/entity.js
CHANGED
|
@@ -30,13 +30,16 @@ export class Entity {
|
|
|
30
30
|
_enabledResolved = true;
|
|
31
31
|
/**
|
|
32
32
|
* An event that is fired as the last act of this entity being destroyed.
|
|
33
|
+
* @zignore
|
|
33
34
|
*/
|
|
34
35
|
onDispose = new Event();
|
|
35
36
|
/**
|
|
36
37
|
* Creates an instance of Entity.
|
|
37
38
|
* @param contextManager The current ContextManager
|
|
38
39
|
*/
|
|
39
|
-
constructor(
|
|
40
|
+
constructor(
|
|
41
|
+
/** @zignore */
|
|
42
|
+
contextManager) {
|
|
40
43
|
this.contextManager = contextManager;
|
|
41
44
|
this._zcomponent = getCurrentZComponentConstruction();
|
|
42
45
|
observe(this, 'enabledResolved', this._updateHandlers, { callImmediately: true });
|