@endo/compartment-mapper 1.2.2 → 1.3.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/archive-lite.d.ts.map +1 -0
- package/archive-parsers.d.ts.map +1 -0
- package/archive.d.ts.map +1 -0
- package/bundle.d.ts.map +1 -0
- package/capture-lite.d.ts.map +1 -0
- package/import-archive-lite.d.ts.map +1 -0
- package/import-archive-parsers.d.ts.map +1 -0
- package/import-archive.d.ts.map +1 -0
- package/import-lite.d.ts.map +1 -0
- package/import-parsers.d.ts.map +1 -0
- package/import.d.ts.map +1 -0
- package/index.d.ts.map +1 -0
- package/node-modules.d.ts.map +1 -0
- package/node-powers.d.ts +1 -1
- package/node-powers.d.ts.map +1 -0
- package/node-powers.js +5 -1
- package/package.json +15 -11
- package/src/compartment-map.d.ts +1 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +1 -1
- package/src/import-hook.d.ts +14 -1
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +493 -144
- package/src/import-lite.d.ts +20 -3
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +137 -15
- package/src/import.d.ts +45 -5
- package/src/import.d.ts.map +1 -1
- package/src/import.js +52 -6
- package/src/link.d.ts +2 -11
- package/src/link.d.ts.map +1 -1
- package/src/link.js +76 -154
- package/src/map-parser.d.ts +4 -0
- package/src/map-parser.d.ts.map +1 -0
- package/src/map-parser.js +339 -0
- package/src/node-modules.d.ts +2 -5
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +12 -5
- package/src/node-powers.d.ts +29 -23
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +102 -25
- package/src/parse-archive-cjs.js +2 -1
- package/src/parse-archive-mjs.js +2 -1
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +2 -6
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +23 -6
- package/src/parse-cjs.js +3 -2
- package/src/parse-json.d.ts +5 -3
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-json.js +9 -9
- package/src/parse-mjs.js +2 -1
- package/src/parse-pre-cjs.js +3 -2
- package/src/parse-pre-mjs.js +2 -1
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +2 -6
- package/src/policy.d.ts +21 -14
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +53 -43
- package/src/powers.d.ts +8 -1
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +60 -10
- package/src/search.d.ts.map +1 -1
- package/src/search.js +1 -2
- package/src/types.d.ts +343 -21
- package/src/types.d.ts.map +1 -1
- package/src/types.js +369 -22
package/src/types.js
CHANGED
|
@@ -4,6 +4,7 @@ export {};
|
|
|
4
4
|
|
|
5
5
|
/** @import {FinalStaticModuleType} from 'ses' */
|
|
6
6
|
/** @import {ImportHook} from 'ses' */
|
|
7
|
+
/** @import {ImportNowHook} from 'ses' */
|
|
7
8
|
/** @import {StaticModuleType} from 'ses' */
|
|
8
9
|
/** @import {ThirdPartyStaticModuleInterface} from 'ses' */
|
|
9
10
|
/** @import {Transform} from 'ses' */
|
|
@@ -34,7 +35,7 @@ export {};
|
|
|
34
35
|
/**
|
|
35
36
|
* A compartment descriptor corresponds to a single Compartment
|
|
36
37
|
* of an assembled Application and describes how to construct
|
|
37
|
-
* one for a given library or application package.json
|
|
38
|
+
* one for a given library or application `package.json`.
|
|
38
39
|
*
|
|
39
40
|
* @typedef {object} CompartmentDescriptor
|
|
40
41
|
* @property {string} label
|
|
@@ -52,11 +53,12 @@ export {};
|
|
|
52
53
|
* @property {LanguageForExtension} parsers - language for extension
|
|
53
54
|
* @property {LanguageForModuleSpecifier} types - language for module specifier
|
|
54
55
|
* @property {SomePackagePolicy} policy - policy specific to compartment
|
|
56
|
+
* @property {Set<string>} compartments - List of compartment names this Compartment depends upon
|
|
55
57
|
*/
|
|
56
58
|
|
|
57
59
|
/**
|
|
58
60
|
* For every module explicitly mentioned in an `exports` field of a
|
|
59
|
-
* package.json
|
|
61
|
+
* `package.json`, there is a corresponding module descriptor.
|
|
60
62
|
*
|
|
61
63
|
* @typedef {object} ModuleDescriptor
|
|
62
64
|
* @property {string=} [compartment]
|
|
@@ -72,7 +74,7 @@ export {};
|
|
|
72
74
|
* Scope descriptors link all names under a prefix to modules in another
|
|
73
75
|
* compartment, like a wildcard.
|
|
74
76
|
* These are employed to link any module not explicitly mentioned
|
|
75
|
-
* in a package.json file, when that package.json file does not have
|
|
77
|
+
* in a `package.json` file, when that `package.json` file does not have
|
|
76
78
|
* an explicit `exports` map.
|
|
77
79
|
*
|
|
78
80
|
* @typedef {object} ScopeDescriptor
|
|
@@ -120,6 +122,12 @@ export {};
|
|
|
120
122
|
* @returns {Promise<Uint8Array>} bytes
|
|
121
123
|
*/
|
|
122
124
|
|
|
125
|
+
/**
|
|
126
|
+
* @callback ReadNowFn
|
|
127
|
+
* @param {string} location
|
|
128
|
+
* @returns {Uint8Array} bytes
|
|
129
|
+
*/
|
|
130
|
+
|
|
123
131
|
/**
|
|
124
132
|
* A resolution of `undefined` indicates `ENOENT` or the equivalent.
|
|
125
133
|
*
|
|
@@ -128,6 +136,14 @@ export {};
|
|
|
128
136
|
* @returns {Promise<Uint8Array | undefined>} bytes
|
|
129
137
|
*/
|
|
130
138
|
|
|
139
|
+
/**
|
|
140
|
+
* A resolution of `undefined` indicates `ENOENT` or the equivalent.
|
|
141
|
+
*
|
|
142
|
+
* @callback MaybeReadNowFn
|
|
143
|
+
* @param {string} location
|
|
144
|
+
* @returns {Uint8Array | undefined} bytes
|
|
145
|
+
*/
|
|
146
|
+
|
|
131
147
|
/**
|
|
132
148
|
* Returns a canonical URL for a given URL, following redirects or symbolic
|
|
133
149
|
* links if any exist along the path.
|
|
@@ -161,19 +177,80 @@ export {};
|
|
|
161
177
|
* @returns {Promise<Uint8Array>}
|
|
162
178
|
*/
|
|
163
179
|
|
|
180
|
+
/**
|
|
181
|
+
* @callback FileURLToPathFn
|
|
182
|
+
* @param {string|URL} location
|
|
183
|
+
* @returns {string}
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @callback IsAbsoluteFn
|
|
188
|
+
* @param {string} location
|
|
189
|
+
* @returns {boolean}
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Node.js' `url.pathToFileURL` only returns a {@link URL}.
|
|
194
|
+
* @callback PathToFileURLFn
|
|
195
|
+
* @param {string} location
|
|
196
|
+
* @returns {URL|string}
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @callback RequireResolveFn
|
|
201
|
+
* @param {string} fromLocation
|
|
202
|
+
* @param {string} specifier
|
|
203
|
+
* @param {{paths?: string[]}} [options]
|
|
204
|
+
*/
|
|
205
|
+
|
|
164
206
|
/**
|
|
165
207
|
* @typedef {object} ReadPowers
|
|
166
208
|
* @property {ReadFn} read
|
|
167
209
|
* @property {CanonicalFn} canonical
|
|
210
|
+
* @property {MaybeReadNowFn} [maybeReadNow]
|
|
211
|
+
* @property {HashFn} [computeSha512]
|
|
212
|
+
* @property {FileURLToPathFn} [fileURLToPath]
|
|
213
|
+
* @property {PathToFileURLFn} [pathToFileURL]
|
|
214
|
+
* @property {RequireResolveFn} [requireResolve]
|
|
215
|
+
* @property {IsAbsoluteFn} [isAbsolute]
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* These properties are necessary for dynamic require support
|
|
220
|
+
*
|
|
221
|
+
* @typedef {'fileURLToPath' | 'isAbsolute' | 'maybeReadNow'} ReadNowPowersProp
|
|
222
|
+
* @see {@link ReadNowPowers}
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The extension of {@link ReadPowers} necessary for dynamic require support
|
|
227
|
+
*
|
|
228
|
+
* For a `ReadPowers` to be a `ReadNowPowers`:
|
|
229
|
+
*
|
|
230
|
+
* 1. It must be an object (not a {@link ReadFn})
|
|
231
|
+
* 2. Prop `maybeReadNow` is a function
|
|
232
|
+
* 3. Prop `fileURLToPath` is a function
|
|
233
|
+
* 4. Prop `isAbsolute` is a function
|
|
234
|
+
*
|
|
235
|
+
* @typedef {Omit<ReadPowers, ReadNowPowersProp> & Required<Pick<ReadPowers, ReadNowPowersProp>>} ReadNowPowers
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @typedef MakeImportNowHookMakerOptions
|
|
240
|
+
* @property {Sources} [sources]
|
|
241
|
+
* @property {Record<string, CompartmentDescriptor>} [compartmentDescriptors]
|
|
168
242
|
* @property {HashFn} [computeSha512]
|
|
169
|
-
* @property {
|
|
170
|
-
*
|
|
171
|
-
*
|
|
243
|
+
* @property {string[]} [searchSuffixes] Suffixes to search if the unmodified
|
|
244
|
+
* specifier is not found. Pass `[]` to emulate Node.js' strict behavior. The
|
|
245
|
+
* default handles Node.js' CommonJS behavior. Unlike Node.js, the Compartment
|
|
246
|
+
* Mapper lifts CommonJS up, more like a bundler, and does not attempt to vary
|
|
247
|
+
* the behavior of resolution depending on the language of the importing module.
|
|
248
|
+
* @property {SourceMapHook} [sourceMapHook]
|
|
249
|
+
* @property {ExitModuleImportNowHook} [exitModuleImportNowHook]
|
|
172
250
|
*/
|
|
173
251
|
|
|
174
252
|
/**
|
|
175
|
-
* @typedef {ReadPowers
|
|
176
|
-
* @property {MaybeReadFn} maybeRead
|
|
253
|
+
* @typedef {ReadPowers & {maybeRead: MaybeReadFn}} MaybeReadPowers
|
|
177
254
|
*/
|
|
178
255
|
|
|
179
256
|
/**
|
|
@@ -210,7 +287,7 @@ export {};
|
|
|
210
287
|
* @property {string} packageLocation
|
|
211
288
|
* @property {string} packageName
|
|
212
289
|
* @property {DeferredAttenuatorsProvider} attenuators
|
|
213
|
-
* @property {ParseFn} parse
|
|
290
|
+
* @property {ParseFn|ParseFnAsync} parse
|
|
214
291
|
* @property {ShouldDeferError} shouldDeferError
|
|
215
292
|
* @property {Record<string, Compartment>} compartments
|
|
216
293
|
*/
|
|
@@ -221,6 +298,20 @@ export {};
|
|
|
221
298
|
* @returns {ImportHook}
|
|
222
299
|
*/
|
|
223
300
|
|
|
301
|
+
/**
|
|
302
|
+
* @typedef {object} ImportNowHookMakerParams
|
|
303
|
+
* @property {string} packageLocation
|
|
304
|
+
* @property {string} packageName
|
|
305
|
+
* @property {ParseFn|ParseFnAsync} parse
|
|
306
|
+
* @property {Record<string, Compartment>} compartments
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @callback ImportNowHookMaker
|
|
311
|
+
* @param {ImportNowHookMakerParams} params
|
|
312
|
+
* @returns {ImportNowHook}
|
|
313
|
+
*/
|
|
314
|
+
|
|
224
315
|
/**
|
|
225
316
|
* @typedef {object} SourceMapHookDetails
|
|
226
317
|
* @property {string} compartment
|
|
@@ -250,7 +341,17 @@ export {};
|
|
|
250
341
|
*/
|
|
251
342
|
|
|
252
343
|
/**
|
|
253
|
-
* @
|
|
344
|
+
* Result of a {@link ParseFn}
|
|
345
|
+
*
|
|
346
|
+
* @typedef ParseResult
|
|
347
|
+
* @property {Uint8Array} bytes
|
|
348
|
+
* @property {Language} parser
|
|
349
|
+
* @property {FinalStaticModuleType} record
|
|
350
|
+
* @property {string} [sourceMap]
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @callback ParseFn_
|
|
254
355
|
* @param {Uint8Array} bytes
|
|
255
356
|
* @param {string} specifier
|
|
256
357
|
* @param {string} location
|
|
@@ -261,12 +362,25 @@ export {};
|
|
|
261
362
|
* @param {string} [options.sourceMapUrl]
|
|
262
363
|
* @param {ReadFn | ReadPowers} [options.readPowers]
|
|
263
364
|
* @param {CompartmentDescriptor} [options.compartmentDescriptor]
|
|
264
|
-
* @returns {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
*
|
|
269
|
-
|
|
365
|
+
* @returns {ParseResult}
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @typedef {ParseFn_ & {isSyncParser?: true}} ParseFn
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @callback ParseFnAsync
|
|
374
|
+
* @param {Uint8Array} bytes
|
|
375
|
+
* @param {string} specifier
|
|
376
|
+
* @param {string} location
|
|
377
|
+
* @param {string} packageLocation
|
|
378
|
+
* @param {object} [options]
|
|
379
|
+
* @param {string} [options.sourceMap]
|
|
380
|
+
* @param {SourceMapHook} [options.sourceMapHook]
|
|
381
|
+
* @param {string} [options.sourceMapUrl]
|
|
382
|
+
* @param {ReadFn | ReadPowers} [options.readPowers]
|
|
383
|
+
* @returns {Promise<ParseResult>}
|
|
270
384
|
*/
|
|
271
385
|
|
|
272
386
|
/**
|
|
@@ -275,6 +389,7 @@ export {};
|
|
|
275
389
|
*
|
|
276
390
|
* @typedef {object} ParserImplementation
|
|
277
391
|
* @property {boolean} heuristicImports
|
|
392
|
+
* @property {boolean} [synchronous]
|
|
278
393
|
* @property {ParseFn} parse
|
|
279
394
|
*/
|
|
280
395
|
|
|
@@ -291,6 +406,13 @@ export {};
|
|
|
291
406
|
* @returns {Promise<ThirdPartyStaticModuleInterface|undefined>} module namespace
|
|
292
407
|
*/
|
|
293
408
|
|
|
409
|
+
/**
|
|
410
|
+
* @callback ExitModuleImportNowHook
|
|
411
|
+
* @param {string} specifier
|
|
412
|
+
* @param {string} referrer
|
|
413
|
+
* @returns {ThirdPartyStaticModuleInterface|undefined} module namespace
|
|
414
|
+
*/
|
|
415
|
+
|
|
294
416
|
/**
|
|
295
417
|
* @see {@link LoadArchiveOptions}
|
|
296
418
|
* @typedef {object} ExtraLoadArchiveOptions
|
|
@@ -345,7 +467,7 @@ export {};
|
|
|
345
467
|
/**
|
|
346
468
|
* Options for `loadLocation()`
|
|
347
469
|
*
|
|
348
|
-
* @typedef {ArchiveOptions} LoadLocationOptions
|
|
470
|
+
* @typedef {ArchiveOptions|SyncArchiveOptions} LoadLocationOptions
|
|
349
471
|
*/
|
|
350
472
|
|
|
351
473
|
/**
|
|
@@ -353,12 +475,22 @@ export {};
|
|
|
353
475
|
* @typedef {object} ExtraLinkOptions
|
|
354
476
|
* @property {ResolveHook} [resolve]
|
|
355
477
|
* @property {ImportHookMaker} makeImportHook
|
|
478
|
+
* @property {ImportNowHookMaker} [makeImportNowHook]
|
|
356
479
|
* @property {ParserForLanguage} [parserForLanguage]
|
|
357
480
|
* @property {LanguageForExtension} [languageForExtension]
|
|
358
481
|
* @property {ModuleTransforms} [moduleTransforms]
|
|
482
|
+
* @property {SyncModuleTransforms} [syncModuleTransforms]
|
|
359
483
|
* @property {boolean} [archiveOnly]
|
|
360
484
|
*/
|
|
361
485
|
|
|
486
|
+
/**
|
|
487
|
+
* @typedef LinkResult
|
|
488
|
+
* @property {Compartment} compartment,
|
|
489
|
+
* @property {Record<string, Compartment>} compartments
|
|
490
|
+
* @property {Compartment} attenuatorsCompartment
|
|
491
|
+
* @property {Promise<void>} pendingJobsPromise
|
|
492
|
+
*/
|
|
493
|
+
|
|
362
494
|
/**
|
|
363
495
|
* Options for `link()`
|
|
364
496
|
*
|
|
@@ -369,17 +501,32 @@ export {};
|
|
|
369
501
|
* @typedef {Record<string, ModuleTransform>} ModuleTransforms
|
|
370
502
|
*/
|
|
371
503
|
|
|
504
|
+
/**
|
|
505
|
+
* @typedef {Record<string, SyncModuleTransform>} SyncModuleTransforms
|
|
506
|
+
*/
|
|
507
|
+
|
|
372
508
|
/**
|
|
373
509
|
* @callback ModuleTransform
|
|
374
510
|
* @param {Uint8Array} bytes
|
|
375
511
|
* @param {string} specifier
|
|
376
512
|
* @param {string} location
|
|
377
513
|
* @param {string} packageLocation
|
|
378
|
-
* @param {object} [
|
|
379
|
-
* @param {string} [
|
|
514
|
+
* @param {object} [params]
|
|
515
|
+
* @param {string} [params.sourceMap]
|
|
380
516
|
* @returns {Promise<{bytes: Uint8Array, parser: Language, sourceMap?: string}>}
|
|
381
517
|
*/
|
|
382
518
|
|
|
519
|
+
/**
|
|
520
|
+
* @callback SyncModuleTransform
|
|
521
|
+
* @param {Uint8Array} bytes
|
|
522
|
+
* @param {string} specifier
|
|
523
|
+
* @param {string} location
|
|
524
|
+
* @param {string} packageLocation
|
|
525
|
+
* @param {object} [params]
|
|
526
|
+
* @param {string} [params.sourceMap]
|
|
527
|
+
* @returns {{bytes: Uint8Array, parser: Language, sourceMap?: string}}
|
|
528
|
+
*/
|
|
529
|
+
|
|
383
530
|
// /////////////////////////////////////////////////////////////////////////////
|
|
384
531
|
|
|
385
532
|
// Communicating source files from an archive snapshot, from archive.js to
|
|
@@ -421,6 +568,7 @@ export {};
|
|
|
421
568
|
/**
|
|
422
569
|
* @typedef {object} ArchiveOptions
|
|
423
570
|
* @property {ModuleTransforms} [moduleTransforms]
|
|
571
|
+
* @property {SyncModuleTransforms} [syncModuleTransforms]
|
|
424
572
|
* @property {Record<string, any>} [modules]
|
|
425
573
|
* @property {boolean} [dev]
|
|
426
574
|
* @property {SomePolicy} [policy]
|
|
@@ -435,6 +583,23 @@ export {};
|
|
|
435
583
|
* @property {LanguageForExtension} [languageForExtension]
|
|
436
584
|
*/
|
|
437
585
|
|
|
586
|
+
/**
|
|
587
|
+
* @typedef SyncArchiveOptions
|
|
588
|
+
* @property {SyncModuleTransforms} [syncModuleTransforms]
|
|
589
|
+
* @property {Record<string, any>} [modules]
|
|
590
|
+
* @property {boolean} [dev]
|
|
591
|
+
* @property {object} [policy]
|
|
592
|
+
* @property {Set<string>} [tags]
|
|
593
|
+
* @property {CaptureSourceLocationHook} [captureSourceLocation]
|
|
594
|
+
* @property {ExitModuleImportHook} [importHook]
|
|
595
|
+
* @property {Array<string>} [searchSuffixes]
|
|
596
|
+
* @property {Record<string, string>} [commonDependencies]
|
|
597
|
+
* @property {SourceMapHook} [sourceMapHook]
|
|
598
|
+
* @property {ExitModuleImportNowHook} [importNowHook]
|
|
599
|
+
* @property {Record<string, ParserImplementation>} [parserForLanguage]
|
|
600
|
+
* @property {LanguageForExtension} [languageForExtension]
|
|
601
|
+
*/
|
|
602
|
+
|
|
438
603
|
// /////////////////////////////////////////////////////////////////////////////
|
|
439
604
|
|
|
440
605
|
// Policy enforcement infrastructure
|
|
@@ -490,7 +655,7 @@ export {};
|
|
|
490
655
|
|
|
491
656
|
/**
|
|
492
657
|
* @template {[any, ...any[]]} [Params=[any, ...any[]]]
|
|
493
|
-
* @template [T=
|
|
658
|
+
* @template [T=SomeObject]
|
|
494
659
|
* @template [U=T]
|
|
495
660
|
* @callback ModuleAttenuatorFn
|
|
496
661
|
* @param {Params} params
|
|
@@ -509,7 +674,7 @@ export {};
|
|
|
509
674
|
*/
|
|
510
675
|
|
|
511
676
|
/**
|
|
512
|
-
* A type representing a property policy, which is a record of string keys and boolean values
|
|
677
|
+
* A type representing a property policy, which is a record of string keys and boolean values
|
|
513
678
|
* @typedef {Record<string, boolean>} PropertyPolicy
|
|
514
679
|
*/
|
|
515
680
|
|
|
@@ -537,6 +702,7 @@ export {};
|
|
|
537
702
|
* @property {PolicyItem<GlobalsPolicyItem>|AttenuationDefinition} [globals] - The policy item or full attenuation definition for globals.
|
|
538
703
|
* @property {PolicyItem<BuiltinsPolicyItem>|NestedAttenuationDefinition} [builtins] - The policy item or nested attenuation definition for builtins.
|
|
539
704
|
* @property {boolean} [noGlobalFreeze] - Whether to disable global freeze.
|
|
705
|
+
* @property {boolean} [dynamic] - Whether to allow dynamic imports
|
|
540
706
|
* @property {ExtraOptions} [options] - Any additional user-defined options can be added to the policy here
|
|
541
707
|
*/
|
|
542
708
|
|
|
@@ -558,10 +724,82 @@ export {};
|
|
|
558
724
|
* @typedef {Record<PropertyKey, any>} SomeObject
|
|
559
725
|
*/
|
|
560
726
|
|
|
727
|
+
/**
|
|
728
|
+
* Function in {@link CryptoInterface}
|
|
729
|
+
*
|
|
730
|
+
* @callback CreateHashFn
|
|
731
|
+
* @param {'sha512'} algorithm
|
|
732
|
+
* @returns {Hash}
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Object returned by function in {@link CryptoInterface}
|
|
737
|
+
*
|
|
738
|
+
* @typedef Hash
|
|
739
|
+
* @property {(data: Uint8Array|string) => Hash} update
|
|
740
|
+
* @property {() => Buffer} digest
|
|
741
|
+
* @see {@link https://nodejs.org/api/crypto.html#class-hash}
|
|
742
|
+
*/
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Function in {@link FsPromisesInterface}
|
|
746
|
+
*
|
|
747
|
+
* @callback RealpathFn
|
|
748
|
+
* @param {string} filepath
|
|
749
|
+
* @returns {Promise<string>}
|
|
750
|
+
*/
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Object within {@link FsPromisesInterface}
|
|
754
|
+
*
|
|
755
|
+
* @typedef FsPromisesInterface
|
|
756
|
+
* @property {RealpathFn} realpath
|
|
757
|
+
* @property {WriteFn} writeFile
|
|
758
|
+
* @property {ReadFn} readFile
|
|
759
|
+
* @see {@link https://nodejs.org/api/fs.html#promises-api}
|
|
760
|
+
*/
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* For creating {@link ReadPowers}
|
|
764
|
+
*
|
|
765
|
+
* @typedef FsInterface
|
|
766
|
+
* @property {FsPromisesInterface} promises
|
|
767
|
+
* @property {ReadNowFn} readFileSync
|
|
768
|
+
* @see {@link https://nodejs.org/api/fs.html}
|
|
769
|
+
*/
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* For creating {@link ReadPowers}
|
|
773
|
+
*
|
|
774
|
+
* @typedef UrlInterface
|
|
775
|
+
* @property {FileURLToPathFn} fileURLToPath
|
|
776
|
+
* @property {PathToFileURLFn} pathToFileURL
|
|
777
|
+
* @see {@link https://nodejs.org/api/url.html}
|
|
778
|
+
*/
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* For creating {@link ReadPowers}
|
|
782
|
+
* @typedef CryptoInterface
|
|
783
|
+
* @property {CreateHashFn} createHash
|
|
784
|
+
* @see {@link https://nodejs.org/api/crypto.html}
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* @typedef PathInterface
|
|
789
|
+
* @property {IsAbsoluteFn} isAbsolute
|
|
790
|
+
* @see {@link https://nodejs.org/api/path.html}
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Options for `compartmentMapForNodeModules`
|
|
795
|
+
*
|
|
796
|
+
* @typedef {Pick<ArchiveOptions, 'dev' | 'commonDependencies' | 'policy'>} CompartmentMapForNodeModulesOptions
|
|
797
|
+
*/
|
|
798
|
+
|
|
561
799
|
/**
|
|
562
800
|
* Any {@link PackagePolicy}
|
|
563
801
|
*
|
|
564
|
-
* @typedef {PackagePolicy<
|
|
802
|
+
* @typedef {PackagePolicy<PolicyItem, PolicyItem, PolicyItem, unknown>} SomePackagePolicy
|
|
565
803
|
*/
|
|
566
804
|
|
|
567
805
|
/**
|
|
@@ -620,11 +858,19 @@ export {};
|
|
|
620
858
|
* @typedef {ExecuteOptions & ArchiveOptions} ImportLocationOptions
|
|
621
859
|
*/
|
|
622
860
|
|
|
861
|
+
/**
|
|
862
|
+
* Options for `importLocation()` necessary (but not sufficient--see
|
|
863
|
+
* {@link ReadNowPowers}) for dynamic require support
|
|
864
|
+
*
|
|
865
|
+
* @typedef {ExecuteOptions & SyncArchiveOptions} SyncImportLocationOptions
|
|
866
|
+
*/
|
|
867
|
+
|
|
623
868
|
/**
|
|
624
869
|
* Options for `captureFromMap()`
|
|
625
870
|
*
|
|
626
871
|
* @typedef CaptureOptions
|
|
627
872
|
* @property {ModuleTransforms} [moduleTransforms]
|
|
873
|
+
* @property {SyncModuleTransforms} [syncModuleTransforms]
|
|
628
874
|
* @property {Record<string, any>} [modules]
|
|
629
875
|
* @property {boolean} [dev]
|
|
630
876
|
* @property {SomePolicy} [policy]
|
|
@@ -636,6 +882,7 @@ export {};
|
|
|
636
882
|
* @property {SourceMapHook} [sourceMapHook]
|
|
637
883
|
* @property {Record<string, ParserImplementation>} [parserForLanguage]
|
|
638
884
|
* @property {LanguageForExtension} [languageForExtension]
|
|
885
|
+
* @property {ExitModuleImportNowHook} [importNowHook]
|
|
639
886
|
*/
|
|
640
887
|
|
|
641
888
|
/**
|
|
@@ -646,3 +893,103 @@ export {};
|
|
|
646
893
|
* @property {Sources} captureSources
|
|
647
894
|
* @property {Record<string, string>} compartmentRenames
|
|
648
895
|
*/
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Options object for `chooseModuleDescriptor`.
|
|
899
|
+
*
|
|
900
|
+
* @typedef ChooseModuleDescriptorOptions
|
|
901
|
+
* @property {string[]} candidates List of `moduleSpecifier` with search
|
|
902
|
+
* suffixes appended
|
|
903
|
+
* @property {CompartmentDescriptor} compartmentDescriptor Compartment
|
|
904
|
+
* descriptor
|
|
905
|
+
* @property {Record<string, CompartmentDescriptor>} compartmentDescriptors All
|
|
906
|
+
* compartment descriptors
|
|
907
|
+
* @property {Record<string, Compartment>} compartments All compartments
|
|
908
|
+
* @property {HashFn} [computeSha512] Function to compute SHA-512 hash
|
|
909
|
+
* @property {Record<string, ModuleDescriptor>} moduleDescriptors All module
|
|
910
|
+
* descriptors
|
|
911
|
+
* @property {string} moduleSpecifier Module specifier
|
|
912
|
+
* @property {string} packageLocation Package location
|
|
913
|
+
* @property {CompartmentSources} packageSources Sources
|
|
914
|
+
* @property {ReadPowers|ReadFn} readPowers Powers
|
|
915
|
+
* @property {SourceMapHook} [sourceMapHook] Source map hook
|
|
916
|
+
* @property {(compartmentName: string) => Set<string>} strictlyRequiredForCompartment Function
|
|
917
|
+
* returning a set of module names (scoped to the compartment) whose parser is not using
|
|
918
|
+
* heuristics to determine imports.
|
|
919
|
+
*/
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Operators for `chooseModuleDescriptor` representing synchronous operation.
|
|
923
|
+
*
|
|
924
|
+
* @typedef SyncChooseModuleDescriptorOperators
|
|
925
|
+
* @property {MaybeReadNowFn} maybeRead A function that reads a file, returning
|
|
926
|
+
* its binary contents _or_ `undefined` if the file is not found
|
|
927
|
+
* @property {ParseFn} parse A function which parses the (defined) binary
|
|
928
|
+
* contents from `maybeRead` into a `ParseResult`
|
|
929
|
+
* @property {never} [shouldDeferError] Should be omitted.
|
|
930
|
+
*/
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Operators for `chooseModuleDescriptor` representing asynchronous operation.
|
|
934
|
+
*
|
|
935
|
+
* @typedef AsyncChooseModuleDescriptorOperators
|
|
936
|
+
* @property {MaybeReadFn} maybeRead A function that reads a file, resolving w/
|
|
937
|
+
* its binary contents _or_ `undefined` if the file is not found
|
|
938
|
+
* @property {ParseFnAsync|ParseFn} parse A function which parses the (defined)
|
|
939
|
+
* binary contents from `maybeRead` into a `ParseResult`
|
|
940
|
+
* @property {(language: Language) => boolean} shouldDeferError A function that
|
|
941
|
+
* returns `true` if the language returned by `parse` should defer errors.
|
|
942
|
+
*/
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Either synchronous or asynchronous operators for `chooseModuleDescriptor`.
|
|
946
|
+
*
|
|
947
|
+
* @typedef {AsyncChooseModuleDescriptorOperators | SyncChooseModuleDescriptorOperators} ChooseModuleDescriptorOperators
|
|
948
|
+
*/
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* The agglomeration of things that the `chooseModuleDescriptor` generator can
|
|
952
|
+
* yield.
|
|
953
|
+
*
|
|
954
|
+
* The generator does not necessarily yield _all_ of these; it depends on
|
|
955
|
+
* whether the operators are {@link AsyncChooseModuleDescriptorOperators} or
|
|
956
|
+
* {@link SyncChooseModuleDescriptorOperators}.
|
|
957
|
+
*
|
|
958
|
+
* @typedef {ReturnType<ChooseModuleDescriptorOperators['maybeRead']> |
|
|
959
|
+
* ReturnType<ChooseModuleDescriptorOperators['parse']>} ChooseModuleDescriptorYieldables
|
|
960
|
+
*/
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Parameters for `findRedirect()`.
|
|
964
|
+
*
|
|
965
|
+
* @typedef FindRedirectParams
|
|
966
|
+
* @property {CompartmentDescriptor} compartmentDescriptor
|
|
967
|
+
* @property {Record<string, CompartmentDescriptor>} compartmentDescriptors
|
|
968
|
+
* @property {Record<string, Compartment>} compartments
|
|
969
|
+
* @property {string} absoluteModuleSpecifier A module specifier which is an absolute path. NOT a file:// URL.
|
|
970
|
+
* @property {string} packageLocation Location of the compartment descriptor's package
|
|
971
|
+
*/
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Options for `makeMapParsers()`
|
|
975
|
+
*
|
|
976
|
+
* @typedef MakeMapParsersOptions
|
|
977
|
+
* @property {ParserForLanguage} parserForLanguage Mapping of language to
|
|
978
|
+
* {@link ParserImplementation}
|
|
979
|
+
* @property {ModuleTransforms} [moduleTransforms] Async or sync module
|
|
980
|
+
* transforms. If non-empty, dynamic requires are unsupported.
|
|
981
|
+
* @property {SyncModuleTransforms} [syncModuleTransforms] Sync module
|
|
982
|
+
* transforms
|
|
983
|
+
*/
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* The value returned by `makeMapParsers()`
|
|
987
|
+
*
|
|
988
|
+
* @template {ParseFn|ParseFnAsync} [T=ParseFn|ParseFnAsync]
|
|
989
|
+
* @callback MapParsersFn
|
|
990
|
+
* @param {LanguageForExtension} languageForExtension Mapping of file extension
|
|
991
|
+
* to {@link Language}
|
|
992
|
+
* @param {LanguageForModuleSpecifier} languageForModuleSpecifier Mapping of
|
|
993
|
+
* module specifier to {@link Language}
|
|
994
|
+
* @returns {T} Parser function
|
|
995
|
+
*/
|