@travetto/registry 5.0.13 → 5.0.15

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 ArcSine Technologies
3
+ Copyright (c) 2020 ArcSine Technologies
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/registry",
3
- "version": "5.0.13",
3
+ "version": "5.0.15",
4
4
  "description": "Patterns and utilities for handling registration of metadata and functionality for run-time use",
5
5
  "keywords": [
6
6
  "ast-transformations",
@@ -27,11 +27,11 @@
27
27
  "directory": "module/registry"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/runtime": "^5.0.13"
30
+ "@travetto/runtime": "^5.0.15"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/cli": "^5.0.16",
34
- "@travetto/transformer": "^5.0.10"
33
+ "@travetto/cli": "^5.0.18",
34
+ "@travetto/transformer": "^5.0.12"
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 ProxyTargetⲐ = Symbol.for('@travetto/runtime:proxy-target');
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 === ProxyTargetⲐ) {
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<{ [ProxyTargetⲐ]: U }>(el)?.[ProxyTargetⲐ] ?? el;
101
+ return castTo<{ [ProxyTargetSymbol]: U }>(el)?.[ProxyTargetSymbol] ?? el;
102
102
  }
103
103
 
104
104
  #handler: RetargettingHandler<T>;
@@ -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(cls.Ⲑid)!.has(field)) {
133
- this.pendingFields.get(cls.Ⲑid)!.set(field, this.createPendingField(cls, field));
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(cls.Ⲑid)!.get(field)!;
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
- if (this.pending.has(cls.Ⲑid) || this.pendingFields.has(cls.Ⲑid)) {
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: cls.Ⲑid });
162
+ console.debug('Installing', { service: this.constructor.name, id: classId });
161
163
  }
162
164
  const result = this.onInstallFinalize(cls);
163
- this.pendingFields.delete(cls.Ⲑid);
164
- this.pending.delete(cls.Ⲑid);
165
+ this.pendingFields.delete(classId);
166
+ this.pending.delete(classId);
165
167
 
166
- this.entries.set(cls.Ⲑid, result);
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
- if (this.entries.has(cls.Ⲑid)) {
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: cls.Ⲑid });
180
+ console.debug('Uninstalling', { service: this.constructor.name, id: classId });
178
181
  }
179
- this.expired.set(cls.Ⲑid, this.entries.get(cls.Ⲑid)!);
180
- this.entries.delete(cls.Ⲑid);
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(cls.Ⲑid));
188
+ process.nextTick(() => this.expired.delete(classId));
186
189
  }
187
190
  }
188
191
  }