@jsii/kernel 1.84.0 → 1.86.0
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/api.d.ts +1 -1
- package/lib/disk-cache/disk-cache.d.ts +1 -4
- package/lib/disk-cache/disk-cache.js +30 -30
- package/lib/kernel.d.ts +5 -48
- package/lib/kernel.js +662 -655
- package/lib/link.d.ts +1 -1
- package/lib/link.js +12 -1
- package/lib/objects.d.ts +10 -11
- package/lib/objects.js +82 -43
- package/lib/serialization.d.ts +10 -5
- package/lib/serialization.js +73 -73
- package/lib/tar-cache/index.js +5 -3
- package/package.json +5 -5
package/lib/link.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* copy otherwise.
|
|
4
4
|
*
|
|
5
5
|
* @param existing is the original file or directory to link.
|
|
6
|
-
* @param destination is the
|
|
6
|
+
* @param destination is the new file or directory to create.
|
|
7
7
|
*/
|
|
8
8
|
export declare function link(existing: string, destination: string): void;
|
|
9
9
|
//# sourceMappingURL=link.d.ts.map
|
package/lib/link.js
CHANGED
|
@@ -3,14 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.link = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
/**
|
|
7
|
+
* If `node` is started with `--preserve-symlinks`, the module loaded will
|
|
8
|
+
* preserve symbolic links instead of resolving them, making it possible to
|
|
9
|
+
* symbolically link packages in place instead of fully copying them.
|
|
10
|
+
*/
|
|
11
|
+
const PRESERVE_SYMLINKS = process.execArgv.includes('--preserve-symlinks');
|
|
6
12
|
/**
|
|
7
13
|
* Creates directories containing hard links if possible, and falls back on
|
|
8
14
|
* copy otherwise.
|
|
9
15
|
*
|
|
10
16
|
* @param existing is the original file or directory to link.
|
|
11
|
-
* @param destination is the
|
|
17
|
+
* @param destination is the new file or directory to create.
|
|
12
18
|
*/
|
|
13
19
|
function link(existing, destination) {
|
|
20
|
+
if (PRESERVE_SYMLINKS) {
|
|
21
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(destination), { recursive: true });
|
|
22
|
+
(0, fs_1.symlinkSync)(existing, destination);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
14
25
|
const stat = (0, fs_1.statSync)(existing);
|
|
15
26
|
if (!stat.isDirectory()) {
|
|
16
27
|
try {
|
package/lib/objects.d.ts
CHANGED
|
@@ -6,8 +6,11 @@ import * as api from './api';
|
|
|
6
6
|
* This will return something if the object was constructed from a JSII-enabled
|
|
7
7
|
* class/constructor, or if a literal object was annotated with type
|
|
8
8
|
* information.
|
|
9
|
+
*
|
|
10
|
+
* @param obj the object for which a jsii FQN is requested.
|
|
11
|
+
* @param isVisibleType a function that determines if a type is visible.
|
|
9
12
|
*/
|
|
10
|
-
export declare function jsiiTypeFqn(obj: any):
|
|
13
|
+
export declare function jsiiTypeFqn(obj: any, isVisibleType: (fqn: spec.FQN) => boolean): spec.FQN | undefined;
|
|
11
14
|
/**
|
|
12
15
|
* If this object was previously serialized under a given reference, return the same reference
|
|
13
16
|
*
|
|
@@ -17,7 +20,7 @@ export declare function objectReference(obj: unknown): api.ObjRef | undefined;
|
|
|
17
20
|
/**
|
|
18
21
|
* Set the JSII FQN for classes produced by a given constructor
|
|
19
22
|
*/
|
|
20
|
-
export declare function tagJsiiConstructor(constructor: any, fqn:
|
|
23
|
+
export declare function tagJsiiConstructor(constructor: any, fqn: spec.FQN): void;
|
|
21
24
|
/**
|
|
22
25
|
* Table of JSII objects
|
|
23
26
|
*
|
|
@@ -25,16 +28,14 @@ export declare function tagJsiiConstructor(constructor: any, fqn: string): void;
|
|
|
25
28
|
* type.
|
|
26
29
|
*/
|
|
27
30
|
export declare class ObjectTable {
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
private nextid;
|
|
31
|
-
constructor(resolveType: (fqn: string) => spec.Type);
|
|
31
|
+
#private;
|
|
32
|
+
constructor(resolveType: (fqn: spec.FQN) => spec.Type);
|
|
32
33
|
/**
|
|
33
34
|
* Register the given object with the given type
|
|
34
35
|
*
|
|
35
36
|
* Return the existing registration if available.
|
|
36
37
|
*/
|
|
37
|
-
registerObject(obj: unknown, fqn:
|
|
38
|
+
registerObject(obj: unknown, fqn: spec.FQN, interfaces?: spec.FQN[]): api.ObjRef;
|
|
38
39
|
/**
|
|
39
40
|
* Find the object and registered type for the given ObjRef
|
|
40
41
|
*/
|
|
@@ -44,12 +45,10 @@ export declare class ObjectTable {
|
|
|
44
45
|
*/
|
|
45
46
|
deleteObject({ [api.TOKEN_REF]: objid }: api.ObjRef): void;
|
|
46
47
|
get count(): number;
|
|
47
|
-
private makeId;
|
|
48
|
-
private removeRedundant;
|
|
49
48
|
}
|
|
50
49
|
export interface RegisteredObject {
|
|
51
50
|
instance: any;
|
|
52
|
-
fqn:
|
|
53
|
-
interfaces?:
|
|
51
|
+
fqn: spec.FQN;
|
|
52
|
+
interfaces?: spec.FQN[];
|
|
54
53
|
}
|
|
55
54
|
//# sourceMappingURL=objects.d.ts.map
|
package/lib/objects.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ObjectTable_instances, _ObjectTable_resolveType, _ObjectTable_objects, _ObjectTable_nextid, _ObjectTable_makeId, _ObjectTable_removeRedundant, _InterfaceCollection_resolveType, _InterfaceCollection_interfaces;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.ObjectTable = exports.tagJsiiConstructor = exports.objectReference = exports.jsiiTypeFqn = void 0;
|
|
4
16
|
const spec = require("@jsii/spec");
|
|
@@ -15,18 +27,42 @@ const OBJID_SYMBOL = Symbol.for('$__jsii__objid__$');
|
|
|
15
27
|
*/
|
|
16
28
|
const IFACES_SYMBOL = Symbol.for('$__jsii__interfaces__$');
|
|
17
29
|
/**
|
|
18
|
-
* Symbol we use to tag constructors that are exported from a
|
|
30
|
+
* Symbol we use to tag constructors that are exported from a jsii module.
|
|
19
31
|
*/
|
|
20
32
|
const JSII_TYPE_FQN_SYMBOL = Symbol('$__jsii__fqn__$');
|
|
33
|
+
/**
|
|
34
|
+
* Symbol under which jsii runtime type information is stored.
|
|
35
|
+
*/
|
|
36
|
+
const JSII_RTTI_SYMBOL = Symbol.for('jsii.rtti');
|
|
21
37
|
/**
|
|
22
38
|
* Get the JSII fqn for an object (if available)
|
|
23
39
|
*
|
|
24
40
|
* This will return something if the object was constructed from a JSII-enabled
|
|
25
41
|
* class/constructor, or if a literal object was annotated with type
|
|
26
42
|
* information.
|
|
43
|
+
*
|
|
44
|
+
* @param obj the object for which a jsii FQN is requested.
|
|
45
|
+
* @param isVisibleType a function that determines if a type is visible.
|
|
27
46
|
*/
|
|
28
|
-
function jsiiTypeFqn(obj) {
|
|
29
|
-
|
|
47
|
+
function jsiiTypeFqn(obj, isVisibleType) {
|
|
48
|
+
var _a;
|
|
49
|
+
const ctor = obj.constructor;
|
|
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];
|
|
53
|
+
}
|
|
54
|
+
let curr = ctor;
|
|
55
|
+
while ((_a = curr[JSII_RTTI_SYMBOL]) === null || _a === void 0 ? void 0 : _a.fqn) {
|
|
56
|
+
if (isVisibleType(curr[JSII_RTTI_SYMBOL].fqn)) {
|
|
57
|
+
const fqn = curr[JSII_RTTI_SYMBOL].fqn;
|
|
58
|
+
tagJsiiConstructor(curr, fqn);
|
|
59
|
+
tagJsiiConstructor(ctor, fqn);
|
|
60
|
+
return fqn;
|
|
61
|
+
}
|
|
62
|
+
// Walk up the prototype chain...
|
|
63
|
+
curr = Object.getPrototypeOf(curr);
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
30
66
|
}
|
|
31
67
|
exports.jsiiTypeFqn = jsiiTypeFqn;
|
|
32
68
|
/**
|
|
@@ -75,7 +111,7 @@ function tagObject(obj, objid, interfaces) {
|
|
|
75
111
|
*/
|
|
76
112
|
function tagJsiiConstructor(constructor, fqn) {
|
|
77
113
|
if (Object.prototype.hasOwnProperty.call(constructor, JSII_TYPE_FQN_SYMBOL)) {
|
|
78
|
-
return assert(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]}`);
|
|
79
115
|
}
|
|
80
116
|
// Mark this constructor as exported from a jsii module, so we know we
|
|
81
117
|
// should be considering it's FQN as a valid exported type.
|
|
@@ -95,9 +131,11 @@ exports.tagJsiiConstructor = tagJsiiConstructor;
|
|
|
95
131
|
*/
|
|
96
132
|
class ObjectTable {
|
|
97
133
|
constructor(resolveType) {
|
|
98
|
-
this
|
|
99
|
-
this
|
|
100
|
-
this
|
|
134
|
+
_ObjectTable_instances.add(this);
|
|
135
|
+
_ObjectTable_resolveType.set(this, void 0);
|
|
136
|
+
_ObjectTable_objects.set(this, new Map());
|
|
137
|
+
_ObjectTable_nextid.set(this, 10000);
|
|
138
|
+
__classPrivateFieldSet(this, _ObjectTable_resolveType, resolveType, "f");
|
|
101
139
|
}
|
|
102
140
|
/**
|
|
103
141
|
* Register the given object with the given type
|
|
@@ -121,17 +159,17 @@ class ObjectTable {
|
|
|
121
159
|
if (!Object.prototype.hasOwnProperty.call(obj, IFACES_SYMBOL)) {
|
|
122
160
|
console.error(`[jsii/kernel] WARNING: referenced object ${existingRef[api.TOKEN_REF]} does not have the ${String(IFACES_SYMBOL)} property!`);
|
|
123
161
|
}
|
|
124
|
-
this.
|
|
162
|
+
__classPrivateFieldGet(this, _ObjectTable_objects, "f").get(existingRef[api.TOKEN_REF]).interfaces =
|
|
125
163
|
obj[IFACES_SYMBOL] =
|
|
126
164
|
existingRef[api.TOKEN_INTERFACES] =
|
|
127
165
|
interfaces =
|
|
128
|
-
this.
|
|
166
|
+
__classPrivateFieldGet(this, _ObjectTable_instances, "m", _ObjectTable_removeRedundant).call(this, Array.from(allIfaces), fqn);
|
|
129
167
|
}
|
|
130
168
|
return existingRef;
|
|
131
169
|
}
|
|
132
|
-
interfaces = this.
|
|
133
|
-
const objid = this.
|
|
134
|
-
this.
|
|
170
|
+
interfaces = __classPrivateFieldGet(this, _ObjectTable_instances, "m", _ObjectTable_removeRedundant).call(this, interfaces, fqn);
|
|
171
|
+
const objid = __classPrivateFieldGet(this, _ObjectTable_instances, "m", _ObjectTable_makeId).call(this, fqn);
|
|
172
|
+
__classPrivateFieldGet(this, _ObjectTable_objects, "f").set(objid, { instance: obj, fqn, interfaces });
|
|
135
173
|
tagObject(obj, objid, interfaces);
|
|
136
174
|
return { [api.TOKEN_REF]: objid, [api.TOKEN_INTERFACES]: interfaces };
|
|
137
175
|
}
|
|
@@ -144,7 +182,7 @@ class ObjectTable {
|
|
|
144
182
|
throw new kernel_1.JsiiFault(`Malformed object reference: ${JSON.stringify(objref)}`);
|
|
145
183
|
}
|
|
146
184
|
const objid = objref[api.TOKEN_REF];
|
|
147
|
-
const obj = this.
|
|
185
|
+
const obj = __classPrivateFieldGet(this, _ObjectTable_objects, "f").get(objid);
|
|
148
186
|
if (!obj) {
|
|
149
187
|
throw new kernel_1.JsiiFault(`Object ${objid} not found`);
|
|
150
188
|
}
|
|
@@ -172,40 +210,41 @@ class ObjectTable {
|
|
|
172
210
|
* Delete the registration with the given objref
|
|
173
211
|
*/
|
|
174
212
|
deleteObject({ [api.TOKEN_REF]: objid }) {
|
|
175
|
-
if (!this.
|
|
213
|
+
if (!__classPrivateFieldGet(this, _ObjectTable_objects, "f").delete(objid)) {
|
|
176
214
|
throw new kernel_1.JsiiFault(`Object ${objid} not found`);
|
|
177
215
|
}
|
|
178
216
|
}
|
|
179
217
|
get count() {
|
|
180
|
-
return this.
|
|
181
|
-
}
|
|
182
|
-
makeId(fqn) {
|
|
183
|
-
return `${fqn}@${this.nextid++}`;
|
|
184
|
-
}
|
|
185
|
-
removeRedundant(interfaces, fqn) {
|
|
186
|
-
if (!interfaces || interfaces.length === 0) {
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
const result = new Set(interfaces);
|
|
190
|
-
const builtIn = new InterfaceCollection(this.resolveType);
|
|
191
|
-
if (fqn !== serialization_1.EMPTY_OBJECT_FQN) {
|
|
192
|
-
builtIn.addFromClass(fqn);
|
|
193
|
-
}
|
|
194
|
-
interfaces.forEach(builtIn.addFromInterface.bind(builtIn));
|
|
195
|
-
for (const iface of builtIn) {
|
|
196
|
-
result.delete(iface);
|
|
197
|
-
}
|
|
198
|
-
return result.size > 0 ? Array.from(result).sort() : undefined;
|
|
218
|
+
return __classPrivateFieldGet(this, _ObjectTable_objects, "f").size;
|
|
199
219
|
}
|
|
200
220
|
}
|
|
201
221
|
exports.ObjectTable = ObjectTable;
|
|
222
|
+
_ObjectTable_resolveType = new WeakMap(), _ObjectTable_objects = new WeakMap(), _ObjectTable_nextid = new WeakMap(), _ObjectTable_instances = new WeakSet(), _ObjectTable_makeId = function _ObjectTable_makeId(fqn) {
|
|
223
|
+
var _a, _b;
|
|
224
|
+
return `${fqn}@${__classPrivateFieldSet(this, _ObjectTable_nextid, (_b = __classPrivateFieldGet(this, _ObjectTable_nextid, "f"), _a = _b++, _b), "f"), _a}`;
|
|
225
|
+
}, _ObjectTable_removeRedundant = function _ObjectTable_removeRedundant(interfaces, fqn) {
|
|
226
|
+
if (!interfaces || interfaces.length === 0) {
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
const result = new Set(interfaces);
|
|
230
|
+
const builtIn = new InterfaceCollection(__classPrivateFieldGet(this, _ObjectTable_resolveType, "f"));
|
|
231
|
+
if (fqn !== serialization_1.EMPTY_OBJECT_FQN) {
|
|
232
|
+
builtIn.addFromClass(fqn);
|
|
233
|
+
}
|
|
234
|
+
interfaces.forEach(builtIn.addFromInterface.bind(builtIn));
|
|
235
|
+
for (const iface of builtIn) {
|
|
236
|
+
result.delete(iface);
|
|
237
|
+
}
|
|
238
|
+
return result.size > 0 ? Array.from(result).sort() : undefined;
|
|
239
|
+
};
|
|
202
240
|
class InterfaceCollection {
|
|
203
241
|
constructor(resolveType) {
|
|
204
|
-
this
|
|
205
|
-
this
|
|
242
|
+
_InterfaceCollection_resolveType.set(this, void 0);
|
|
243
|
+
_InterfaceCollection_interfaces.set(this, new Set());
|
|
244
|
+
__classPrivateFieldSet(this, _InterfaceCollection_resolveType, resolveType, "f");
|
|
206
245
|
}
|
|
207
246
|
addFromClass(fqn) {
|
|
208
|
-
const ti = this.
|
|
247
|
+
const ti = __classPrivateFieldGet(this, _InterfaceCollection_resolveType, "f").call(this, fqn);
|
|
209
248
|
if (!spec.isClassType(ti)) {
|
|
210
249
|
throw new kernel_1.JsiiFault(`Expected a class, but received ${spec.describeTypeReference(ti)}`);
|
|
211
250
|
}
|
|
@@ -214,16 +253,16 @@ class InterfaceCollection {
|
|
|
214
253
|
}
|
|
215
254
|
if (ti.interfaces) {
|
|
216
255
|
for (const iface of ti.interfaces) {
|
|
217
|
-
if (this.
|
|
256
|
+
if (__classPrivateFieldGet(this, _InterfaceCollection_interfaces, "f").has(iface)) {
|
|
218
257
|
continue;
|
|
219
258
|
}
|
|
220
|
-
this.
|
|
259
|
+
__classPrivateFieldGet(this, _InterfaceCollection_interfaces, "f").add(iface);
|
|
221
260
|
this.addFromInterface(iface);
|
|
222
261
|
}
|
|
223
262
|
}
|
|
224
263
|
}
|
|
225
264
|
addFromInterface(fqn) {
|
|
226
|
-
const ti = this.
|
|
265
|
+
const ti = __classPrivateFieldGet(this, _InterfaceCollection_resolveType, "f").call(this, fqn);
|
|
227
266
|
if (!spec.isInterfaceType(ti)) {
|
|
228
267
|
throw new kernel_1.JsiiFault(`Expected an interface, but received ${spec.describeTypeReference(ti)}`);
|
|
229
268
|
}
|
|
@@ -231,15 +270,15 @@ class InterfaceCollection {
|
|
|
231
270
|
return;
|
|
232
271
|
}
|
|
233
272
|
for (const iface of ti.interfaces) {
|
|
234
|
-
if (this.
|
|
273
|
+
if (__classPrivateFieldGet(this, _InterfaceCollection_interfaces, "f").has(iface)) {
|
|
235
274
|
continue;
|
|
236
275
|
}
|
|
237
|
-
this.
|
|
276
|
+
__classPrivateFieldGet(this, _InterfaceCollection_interfaces, "f").add(iface);
|
|
238
277
|
this.addFromInterface(iface);
|
|
239
278
|
}
|
|
240
279
|
}
|
|
241
|
-
[Symbol.iterator]() {
|
|
242
|
-
return this
|
|
280
|
+
[(_InterfaceCollection_resolveType = new WeakMap(), _InterfaceCollection_interfaces = new WeakMap(), Symbol.iterator)]() {
|
|
281
|
+
return __classPrivateFieldGet(this, _InterfaceCollection_interfaces, "f")[Symbol.iterator]();
|
|
243
282
|
}
|
|
244
283
|
}
|
|
245
284
|
//# sourceMappingURL=objects.js.map
|
package/lib/serialization.d.ts
CHANGED
|
@@ -63,12 +63,15 @@ export declare const enum SerializationClass {
|
|
|
63
63
|
ReferenceType = "RefType",
|
|
64
64
|
Any = "Any"
|
|
65
65
|
}
|
|
66
|
-
declare type
|
|
66
|
+
declare type FindSymbol = (fqn: spec.FQN) => any;
|
|
67
|
+
declare type IsVisibleType = (fqn: spec.FQN) => boolean;
|
|
68
|
+
declare type LookupType = (fqn: spec.FQN) => spec.Type;
|
|
67
69
|
export interface SerializerHost {
|
|
68
70
|
readonly objects: ObjectTable;
|
|
69
71
|
debug(...args: any[]): void;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
isVisibleType: IsVisibleType;
|
|
73
|
+
lookupType: LookupType;
|
|
74
|
+
findSymbol: FindSymbol;
|
|
72
75
|
}
|
|
73
76
|
interface Serializer {
|
|
74
77
|
serialize(value: unknown, type: OptionalValueOrVoid, host: SerializerHost): any;
|
|
@@ -88,13 +91,15 @@ export interface TypeSerialization {
|
|
|
88
91
|
*
|
|
89
92
|
* There can be multiple, because the type can be a type union.
|
|
90
93
|
*/
|
|
91
|
-
export declare function serializationType(typeRef: OptionalValueOrVoid, lookup:
|
|
94
|
+
export declare function serializationType(typeRef: OptionalValueOrVoid, lookup: LookupType): TypeSerialization[];
|
|
92
95
|
export declare function process(host: SerializerHost, serde: keyof Serializer, value: unknown, type: OptionalValueOrVoid, context: string): any;
|
|
93
96
|
export declare class SerializationError extends Error {
|
|
94
97
|
readonly value: unknown;
|
|
95
98
|
readonly causes: readonly any[];
|
|
96
99
|
readonly name: string;
|
|
97
|
-
constructor(message: string, value: unknown,
|
|
100
|
+
constructor(message: string, value: unknown, { isVisibleType }: {
|
|
101
|
+
readonly isVisibleType: (fqn: string) => boolean;
|
|
102
|
+
}, causes?: readonly any[], { renderValue }?: {
|
|
98
103
|
renderValue?: boolean;
|
|
99
104
|
});
|
|
100
105
|
}
|