@jsii/kernel 1.86.0 → 1.86.1

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 (2) hide show
  1. package/lib/objects.js +10 -14
  2. package/package.json +5 -5
package/lib/objects.js CHANGED
@@ -26,14 +26,14 @@ const OBJID_SYMBOL = Symbol.for('$__jsii__objid__$');
26
26
  * Symbol under which we store the interfaces implemented by instances
27
27
  */
28
28
  const IFACES_SYMBOL = Symbol.for('$__jsii__interfaces__$');
29
- /**
30
- * Symbol we use to tag constructors that are exported from a jsii module.
31
- */
32
- const JSII_TYPE_FQN_SYMBOL = Symbol('$__jsii__fqn__$');
33
29
  /**
34
30
  * Symbol under which jsii runtime type information is stored.
35
31
  */
36
32
  const JSII_RTTI_SYMBOL = Symbol.for('jsii.rtti');
33
+ /**
34
+ * Cache for resolved associations between constructors and FQNs.
35
+ */
36
+ const RESOLVED_TYPE_FQN = new WeakMap();
37
37
  /**
38
38
  * Get the JSII fqn for an object (if available)
39
39
  *
@@ -48,8 +48,8 @@ function jsiiTypeFqn(obj, isVisibleType) {
48
48
  var _a;
49
49
  const ctor = obj.constructor;
50
50
  // We've already resolved for this type, return the cached value.
51
- if (ctor[JSII_TYPE_FQN_SYMBOL] != null) {
52
- return ctor[JSII_TYPE_FQN_SYMBOL];
51
+ if (RESOLVED_TYPE_FQN.has(ctor)) {
52
+ return RESOLVED_TYPE_FQN.get(ctor);
53
53
  }
54
54
  let curr = ctor;
55
55
  while ((_a = curr[JSII_RTTI_SYMBOL]) === null || _a === void 0 ? void 0 : _a.fqn) {
@@ -110,17 +110,13 @@ function tagObject(obj, objid, interfaces) {
110
110
  * Set the JSII FQN for classes produced by a given constructor
111
111
  */
112
112
  function tagJsiiConstructor(constructor, fqn) {
113
- if (Object.prototype.hasOwnProperty.call(constructor, JSII_TYPE_FQN_SYMBOL)) {
114
- return assert.strictEqual(constructor[JSII_TYPE_FQN_SYMBOL], fqn, `Unable to register ${constructor.name} as ${fqn}: it is already registerd with FQN ${constructor[JSII_TYPE_FQN_SYMBOL]}`);
113
+ const existing = RESOLVED_TYPE_FQN.get(constructor);
114
+ if (existing != null) {
115
+ return assert.strictEqual(existing, fqn, `Unable to register ${constructor.name} as ${fqn}: it is already registerd with FQN ${existing}`);
115
116
  }
116
117
  // Mark this constructor as exported from a jsii module, so we know we
117
118
  // should be considering it's FQN as a valid exported type.
118
- Object.defineProperty(constructor, JSII_TYPE_FQN_SYMBOL, {
119
- configurable: false,
120
- enumerable: false,
121
- writable: false,
122
- value: fqn,
123
- });
119
+ RESOLVED_TYPE_FQN.set(constructor, fqn);
124
120
  }
125
121
  exports.tagJsiiConstructor = tagJsiiConstructor;
126
122
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsii/kernel",
3
- "version": "1.86.0",
3
+ "version": "1.86.1",
4
4
  "description": "kernel for jsii execution environment",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -31,19 +31,19 @@
31
31
  "package": "package-js"
32
32
  },
33
33
  "dependencies": {
34
- "@jsii/spec": "^1.86.0",
34
+ "@jsii/spec": "^1.86.1",
35
35
  "fs-extra": "^10.1.0",
36
36
  "lockfile": "^1.0.4",
37
37
  "tar": "^6.1.15"
38
38
  },
39
39
  "devDependencies": {
40
- "@scope/jsii-calc-base": "^1.86.0",
41
- "@scope/jsii-calc-lib": "^1.86.0",
40
+ "@scope/jsii-calc-base": "^1.86.1",
41
+ "@scope/jsii-calc-lib": "^1.86.1",
42
42
  "@types/fs-extra": "^9.0.13",
43
43
  "@types/lockfile": "^1.0.2",
44
44
  "@types/tar": "^6.1.5",
45
45
  "jest-expect-message": "^1.1.3",
46
- "jsii-build-tools": "^1.86.0",
46
+ "jsii-build-tools": "^1.86.1",
47
47
  "jsii-calc": "^3.20.120"
48
48
  }
49
49
  }