@jsii/kernel 1.85.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.
@@ -1,21 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  export declare class DiskCache {
3
3
  #private;
4
- private static readonly CACHE;
5
4
  static inDirectory(path: string): DiskCache;
6
5
  private constructor();
7
6
  entry(...key: readonly string[]): Entry;
8
7
  entryFor(path: string, ...comments: readonly string[]): Entry;
9
8
  pruneExpiredEntries(): void;
10
- private entries;
11
9
  }
12
10
  export declare class Entry {
11
+ #private;
13
12
  readonly path: string;
14
13
  constructor(path: string);
15
14
  get atime(): Date;
16
15
  get pathExists(): boolean;
17
- private get lockFile();
18
- private get markerFile();
19
16
  lock<T>(cb: (entry: LockedEntry) => T): T;
20
17
  read(file: string): Buffer | undefined;
21
18
  }
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
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
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _DiskCache_root;
13
+ var _DiskCache_instances, _a, _DiskCache_CACHE, _DiskCache_root, _DiskCache_entries, _Entry_instances, _Entry_lockFile_get, _Entry_markerFile_get;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Entry = exports.DiskCache = void 0;
16
16
  const fs_1 = require("fs");
@@ -24,6 +24,7 @@ const PRUNE_AFTER_MILLISECONDS = process.env.JSII_RUNTIME_PACKAGE_CACHE_TTL
24
24
  : 30 * ONE_DAY_IN_MS;
25
25
  class DiskCache {
26
26
  constructor(root) {
27
+ _DiskCache_instances.add(this);
27
28
  _DiskCache_root.set(this, void 0);
28
29
  __classPrivateFieldSet(this, _DiskCache_root, root, "f");
29
30
  process.once('beforeExit', () => this.pruneExpiredEntries());
@@ -38,10 +39,10 @@ class DiskCache {
38
39
  (0, fs_1.writeFileSync)((0, path_1.join)(path, '.nosync'), '');
39
40
  }
40
41
  path = (0, fs_1.realpathSync)(path);
41
- if (!this.CACHE.has(path)) {
42
- this.CACHE.set(path, new DiskCache(path));
42
+ if (!__classPrivateFieldGet(this, _a, "f", _DiskCache_CACHE).has(path)) {
43
+ __classPrivateFieldGet(this, _a, "f", _DiskCache_CACHE).set(path, new DiskCache(path));
43
44
  }
44
- return this.CACHE.get(path);
45
+ return __classPrivateFieldGet(this, _a, "f", _DiskCache_CACHE).get(path);
45
46
  }
46
47
  entry(...key) {
47
48
  if (key.length === 0) {
@@ -63,7 +64,7 @@ class DiskCache {
63
64
  }
64
65
  pruneExpiredEntries() {
65
66
  const cutOff = new Date(Date.now() - PRUNE_AFTER_MILLISECONDS);
66
- for (const entry of this.entries()) {
67
+ for (const entry of __classPrivateFieldGet(this, _DiskCache_instances, "m", _DiskCache_entries).call(this)) {
67
68
  if (entry.atime < cutOff) {
68
69
  entry.lock((lockedEntry) => {
69
70
  // Check again in case it's been accessed which we waited for the lock...
@@ -93,28 +94,28 @@ class DiskCache {
93
94
  }
94
95
  }
95
96
  }
96
- *entries() {
97
- yield* inDirectory(__classPrivateFieldGet(this, _DiskCache_root, "f"));
98
- function* inDirectory(dir) {
99
- if ((0, fs_1.existsSync)((0, path_1.join)(dir, MARKER_FILE_NAME))) {
100
- return yield new Entry(dir);
101
- }
102
- for (const file of directoriesUnder(dir)) {
103
- yield* inDirectory(file);
104
- }
105
- }
106
- }
107
97
  }
108
98
  exports.DiskCache = DiskCache;
109
- _DiskCache_root = new WeakMap();
110
- DiskCache.CACHE = new Map();
99
+ _a = DiskCache, _DiskCache_root = new WeakMap(), _DiskCache_instances = new WeakSet(), _DiskCache_entries = function* _DiskCache_entries() {
100
+ yield* inDirectory(__classPrivateFieldGet(this, _DiskCache_root, "f"));
101
+ function* inDirectory(dir) {
102
+ if ((0, fs_1.existsSync)((0, path_1.join)(dir, MARKER_FILE_NAME))) {
103
+ return yield new Entry(dir);
104
+ }
105
+ for (const file of directoriesUnder(dir)) {
106
+ yield* inDirectory(file);
107
+ }
108
+ }
109
+ };
110
+ _DiskCache_CACHE = { value: new Map() };
111
111
  class Entry {
112
112
  constructor(path) {
113
113
  this.path = path;
114
+ _Entry_instances.add(this);
114
115
  }
115
116
  get atime() {
116
117
  try {
117
- const stat = (0, fs_1.statSync)(this.markerFile);
118
+ const stat = (0, fs_1.statSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_markerFile_get));
118
119
  return stat.atime;
119
120
  }
120
121
  catch (err) {
@@ -127,15 +128,9 @@ class Entry {
127
128
  get pathExists() {
128
129
  return (0, fs_1.existsSync)(this.path);
129
130
  }
130
- get lockFile() {
131
- return `${this.path}.lock`;
132
- }
133
- get markerFile() {
134
- return (0, path_1.join)(this.path, MARKER_FILE_NAME);
135
- }
136
131
  lock(cb) {
137
132
  (0, fs_1.mkdirSync)((0, path_1.dirname)(this.path), { recursive: true });
138
- (0, lockfile_1.lockSync)(this.lockFile, { retries: 12, stale: 5000 });
133
+ (0, lockfile_1.lockSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_lockFile_get), { retries: 12, stale: 5000 });
139
134
  let disposed = false;
140
135
  try {
141
136
  return cb({
@@ -157,12 +152,12 @@ class Entry {
157
152
  throw new Error(`Cannot touch ${this.path} once the lock block was returned!`);
158
153
  }
159
154
  if (this.pathExists) {
160
- if ((0, fs_1.existsSync)(this.markerFile)) {
155
+ if ((0, fs_1.existsSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_markerFile_get))) {
161
156
  const now = new Date();
162
- (0, fs_1.utimesSync)(this.markerFile, now, now);
157
+ (0, fs_1.utimesSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_markerFile_get), now, now);
163
158
  }
164
159
  else {
165
- (0, fs_1.writeFileSync)(this.markerFile, '');
160
+ (0, fs_1.writeFileSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_markerFile_get), '');
166
161
  }
167
162
  }
168
163
  },
@@ -170,7 +165,7 @@ class Entry {
170
165
  }
171
166
  finally {
172
167
  disposed = true;
173
- (0, lockfile_1.unlockSync)(this.lockFile);
168
+ (0, lockfile_1.unlockSync)(__classPrivateFieldGet(this, _Entry_instances, "a", _Entry_lockFile_get));
174
169
  }
175
170
  }
176
171
  read(file) {
@@ -186,6 +181,11 @@ class Entry {
186
181
  }
187
182
  }
188
183
  exports.Entry = Entry;
184
+ _Entry_instances = new WeakSet(), _Entry_lockFile_get = function _Entry_lockFile_get() {
185
+ return `${this.path}.lock`;
186
+ }, _Entry_markerFile_get = function _Entry_markerFile_get() {
187
+ return (0, path_1.join)(this.path, MARKER_FILE_NAME);
188
+ };
189
189
  function* directoriesUnder(root, recursive = false, ignoreErrors = true) {
190
190
  for (const file of (0, fs_1.readdirSync)(root)) {
191
191
  const path = (0, path_1.join)(root, file);
package/lib/kernel.d.ts CHANGED
@@ -15,6 +15,7 @@ export declare class RuntimeError extends Error implements JsiiError {
15
15
  constructor(message: string);
16
16
  }
17
17
  export declare class Kernel {
18
+ #private;
18
19
  callbackHandler: (callback: api.Callback) => any;
19
20
  /**
20
21
  * Set to true for verbose debugging.
@@ -24,16 +25,10 @@ export declare class Kernel {
24
25
  * Set to true for timing data to be emitted.
25
26
  */
26
27
  debugTimingEnabled: boolean;
27
- private readonly assemblies;
28
- private readonly objects;
29
- private readonly cbs;
30
- private readonly waiting;
31
- private readonly promises;
32
- private nextid;
33
- private syncInProgress?;
34
- private installDir?;
35
- /** The internal require function, used instead of the global "require" so that webpack does not transform it... */
36
- private require?;
28
+ /**
29
+ * Set to true to validate assemblies upon loading (slow).
30
+ */
31
+ validateAssemblies: boolean;
37
32
  /**
38
33
  * Creates a jsii kernel object.
39
34
  *
@@ -43,7 +38,6 @@ export declare class Kernel {
43
38
  */
44
39
  constructor(callbackHandler: (callback: api.Callback) => any);
45
40
  load(req: api.LoadRequest): api.LoadResponse;
46
- private _load;
47
41
  getBinScriptCommand(req: api.GetScriptCommandRequest): api.GetScriptCommandResponse;
48
42
  invokeBinScript(req: api.InvokeScriptRequest): api.InvokeScriptResponse;
49
43
  create(req: api.CreateRequest): api.CreateResponse;
@@ -64,42 +58,5 @@ export declare class Kernel {
64
58
  */
65
59
  naming(req: api.NamingRequest): api.NamingResponse;
66
60
  stats(_req?: api.StatsRequest): api.StatsResponse;
67
- private _addAssembly;
68
- private _findCtor;
69
- private _getPackageDir;
70
- private _create;
71
- private _getSuperPropertyName;
72
- private _applyPropertyOverride;
73
- private _defineOverridenProperty;
74
- private _applyMethodOverride;
75
- private _defineOverridenMethod;
76
- private _findInvokeTarget;
77
- private _validateMethodArguments;
78
- private _assemblyFor;
79
- private _findSymbol;
80
- private _typeInfoForFqn;
81
- private _typeInfoForMethod;
82
- private _tryTypeInfoForMethod;
83
- private _tryTypeInfoForProperty;
84
- private _typeInfoForProperty;
85
- private _toSandbox;
86
- private _fromSandbox;
87
- private _toSandboxValues;
88
- private _fromSandboxValues;
89
- private _boxUnboxParameters;
90
- private _debug;
91
- private _debugTime;
92
- /**
93
- * Ensures that `fn` is called and defends against beginning to invoke
94
- * async methods until fn finishes (successfully or not).
95
- */
96
- private _ensureSync;
97
- private _findPropertyTarget;
98
- /**
99
- * Shared (non-public implementation) to as not to break API recording.
100
- */
101
- private _getBinScriptCommand;
102
- private _makecbid;
103
- private _makeprid;
104
61
  }
105
62
  //# sourceMappingURL=kernel.d.ts.map