@travetto/registry 5.0.14 → 5.0.16
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/package.json +5 -5
- package/src/proxy.ts +3 -3
- package/src/service/metadata.ts +16 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/registry",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.16",
|
|
4
4
|
"description": "Patterns and utilities for handling registration of metadata and functionality for run-time use",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast-transformations",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
],
|
|
24
24
|
"main": "__index__.ts",
|
|
25
25
|
"repository": {
|
|
26
|
-
"url": "https://github.com/travetto/travetto.git",
|
|
26
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
27
27
|
"directory": "module/registry"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/runtime": "^5.0.
|
|
30
|
+
"@travetto/runtime": "^5.0.16"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@travetto/cli": "^5.0.
|
|
34
|
-
"@travetto/transformer": "^5.0.
|
|
33
|
+
"@travetto/cli": "^5.0.19",
|
|
34
|
+
"@travetto/transformer": "^5.0.13"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/transformer": {
|
package/src/proxy.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Any, castKey, castTo, classConstruct } from '@travetto/runtime';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ProxyTargetSymbol = Symbol.for('@travetto/runtime:proxy-target');
|
|
4
4
|
|
|
5
5
|
const AsyncGeneratorFunction = Object.getPrototypeOf(async function* () { });
|
|
6
6
|
const GeneratorFunction = Object.getPrototypeOf(function* () { });
|
|
@@ -50,7 +50,7 @@ export class RetargettingHandler<T> implements ProxyHandler<Any> {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
get(target: T, prop: PropertyKey, receiver: unknown): Any {
|
|
53
|
-
if (prop ===
|
|
53
|
+
if (prop === ProxyTargetSymbol) {
|
|
54
54
|
return this.target;
|
|
55
55
|
}
|
|
56
56
|
let ret = this.target[castKey<T>(prop)];
|
|
@@ -98,7 +98,7 @@ export class RetargettingProxy<T> {
|
|
|
98
98
|
* Unwrap proxy
|
|
99
99
|
*/
|
|
100
100
|
static unwrap<U>(el: U): U {
|
|
101
|
-
return castTo<{ [
|
|
101
|
+
return castTo<{ [ProxyTargetSymbol]: U }>(el)?.[ProxyTargetSymbol] ?? el;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
#handler: RetargettingHandler<T>;
|
package/src/service/metadata.ts
CHANGED
|
@@ -128,11 +128,12 @@ export abstract class MetadataRegistry<C extends { class: Class }, M = unknown,
|
|
|
128
128
|
*/
|
|
129
129
|
getOrCreatePendingField(cls: Class, field: F): Partial<M> {
|
|
130
130
|
this.getOrCreatePending(cls);
|
|
131
|
+
const classId = cls.Ⲑid;
|
|
131
132
|
|
|
132
|
-
if (!this.pendingFields.get(
|
|
133
|
-
this.pendingFields.get(
|
|
133
|
+
if (!this.pendingFields.get(classId)!.has(field)) {
|
|
134
|
+
this.pendingFields.get(classId)!.set(field, this.createPendingField(cls, field));
|
|
134
135
|
}
|
|
135
|
-
return this.pendingFields.get(
|
|
136
|
+
return this.pendingFields.get(classId)!.get(field)!;
|
|
136
137
|
}
|
|
137
138
|
|
|
138
139
|
/**
|
|
@@ -155,15 +156,16 @@ export abstract class MetadataRegistry<C extends { class: Class }, M = unknown,
|
|
|
155
156
|
* On an install event, finalize
|
|
156
157
|
*/
|
|
157
158
|
onInstall(cls: Class, e: ChangeEvent<Class>): void {
|
|
158
|
-
|
|
159
|
+
const classId = cls.Ⲑid;
|
|
160
|
+
if (this.pending.has(classId) || this.pendingFields.has(classId)) {
|
|
159
161
|
if (this.trace) {
|
|
160
|
-
console.debug('Installing', { service: this.constructor.name, id:
|
|
162
|
+
console.debug('Installing', { service: this.constructor.name, id: classId });
|
|
161
163
|
}
|
|
162
164
|
const result = this.onInstallFinalize(cls);
|
|
163
|
-
this.pendingFields.delete(
|
|
164
|
-
this.pending.delete(
|
|
165
|
+
this.pendingFields.delete(classId);
|
|
166
|
+
this.pending.delete(classId);
|
|
165
167
|
|
|
166
|
-
this.entries.set(
|
|
168
|
+
this.entries.set(classId, result);
|
|
167
169
|
this.emit(e);
|
|
168
170
|
}
|
|
169
171
|
}
|
|
@@ -172,17 +174,18 @@ export abstract class MetadataRegistry<C extends { class: Class }, M = unknown,
|
|
|
172
174
|
* On an uninstall event, remove
|
|
173
175
|
*/
|
|
174
176
|
onUninstall(cls: Class, e: ChangeEvent<Class>): void {
|
|
175
|
-
|
|
177
|
+
const classId = cls.Ⲑid;
|
|
178
|
+
if (this.entries.has(classId)) {
|
|
176
179
|
if (this.trace) {
|
|
177
|
-
console.debug('Uninstalling', { service: this.constructor.name, id:
|
|
180
|
+
console.debug('Uninstalling', { service: this.constructor.name, id: classId });
|
|
178
181
|
}
|
|
179
|
-
this.expired.set(
|
|
180
|
-
this.entries.delete(
|
|
182
|
+
this.expired.set(classId, this.entries.get(classId)!);
|
|
183
|
+
this.entries.delete(classId);
|
|
181
184
|
this.onUninstallFinalize(cls);
|
|
182
185
|
if (e.type === 'removing') {
|
|
183
186
|
this.emit(e);
|
|
184
187
|
}
|
|
185
|
-
process.nextTick(() => this.expired.delete(
|
|
188
|
+
process.nextTick(() => this.expired.delete(classId));
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
}
|