@endo/compartment-mapper 1.5.0 → 1.6.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/README.md +278 -111
- package/bundle.d.ts +1 -1
- package/bundle.js +4 -1
- package/functor-lite.d.ts +3 -0
- package/functor-lite.d.ts.map +1 -0
- package/functor-lite.js +4 -0
- package/functor.d.ts +3 -0
- package/functor.d.ts.map +1 -0
- package/functor.js +4 -0
- package/index.d.ts +1 -1
- package/index.js +4 -1
- package/package.json +8 -4
- package/script-lite.d.ts +3 -0
- package/script-lite.d.ts.map +1 -0
- package/script-lite.js +4 -0
- package/script.d.ts +3 -0
- package/script.d.ts.map +1 -0
- package/script.js +4 -0
- package/src/archive-lite.js +1 -1
- package/src/bundle-cjs.d.ts +1 -1
- package/src/bundle-cjs.d.ts.map +1 -1
- package/src/bundle-cjs.js +57 -28
- package/src/bundle-json.d.ts.map +1 -1
- package/src/bundle-json.js +2 -3
- package/src/bundle-lite.d.ts +91 -0
- package/src/bundle-lite.d.ts.map +1 -0
- package/src/bundle-lite.js +668 -0
- package/src/bundle-mjs.d.ts +2 -2
- package/src/bundle-mjs.d.ts.map +1 -1
- package/src/bundle-mjs.js +36 -19
- package/src/bundle.d.ts +48 -10
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +391 -125
- package/src/capture-lite.js +1 -1
- package/src/import-hook.d.ts +3 -16
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +11 -18
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +4 -2
- package/src/node-modules.d.ts +4 -47
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +121 -121
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +8 -3
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +2 -10
- package/src/parse-cjs.js +1 -1
- package/src/parse-mjs.js +2 -2
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +4 -7
- package/src/search.d.ts +6 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +29 -12
- package/src/types/compartment-map-schema.d.ts +5 -0
- package/src/types/compartment-map-schema.d.ts.map +1 -1
- package/src/types/compartment-map-schema.ts +5 -0
- package/src/types/external.d.ts +112 -8
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +127 -8
- package/src/types/internal.d.ts +85 -13
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +106 -13
- package/src/types/node-modules.d.ts +79 -0
- package/src/types/node-modules.d.ts.map +1 -0
- package/src/types/node-modules.ts +89 -0
- package/src/types/node-powers.d.ts +4 -4
- package/src/types/node-powers.d.ts.map +1 -1
- package/src/types/node-powers.ts +4 -4
- package/src/types/powers.d.ts +2 -2
- package/src/types/powers.d.ts.map +1 -1
- package/src/types/powers.ts +2 -2
package/src/capture-lite.js
CHANGED
|
@@ -123,7 +123,7 @@ export const captureFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
123
123
|
searchSuffixes,
|
|
124
124
|
entryCompartmentName,
|
|
125
125
|
entryModuleSpecifier,
|
|
126
|
-
|
|
126
|
+
importHook: consolidatedExitModuleImportHook,
|
|
127
127
|
sourceMapHook,
|
|
128
128
|
});
|
|
129
129
|
// Induce importHook to record all the necessary modules to import the given module specifier.
|
package/src/import-hook.d.ts
CHANGED
|
@@ -6,32 +6,19 @@
|
|
|
6
6
|
* @param {MakeImportNowHookMakerOptions} options
|
|
7
7
|
* @returns {ImportNowHookMaker}
|
|
8
8
|
*/
|
|
9
|
-
export function makeImportNowHookMaker(readPowers: ReadNowPowers, baseLocation: string, { sources, compartmentDescriptors, computeSha512, searchSuffixes, sourceMapHook, exitModuleImportNowHook, }: MakeImportNowHookMakerOptions): ImportNowHookMaker;
|
|
9
|
+
export function makeImportNowHookMaker(readPowers: ReadNowPowers, baseLocation: string, { sources, compartmentDescriptors, computeSha512, searchSuffixes, archiveOnly, sourceMapHook, importNowHook: exitModuleImportNowHook, }: MakeImportNowHookMakerOptions): ImportNowHookMaker;
|
|
10
10
|
export function exitModuleImportHookMaker({ modules, exitModuleImportHook, entryCompartmentName, }: {
|
|
11
11
|
modules?: Record<string, any> | undefined;
|
|
12
12
|
exitModuleImportHook?: ExitModuleImportHook | undefined;
|
|
13
13
|
entryCompartmentName: string;
|
|
14
14
|
}): ExitModuleImportHook | undefined;
|
|
15
|
-
export function makeImportHookMaker(readPowers: ReadFn | ReadPowers, baseLocation: string, { sources, compartmentDescriptors, archiveOnly, computeSha512, searchSuffixes, sourceMapHook, entryCompartmentName, entryModuleSpecifier, exitModuleImportHook, }:
|
|
16
|
-
sources?: Sources | undefined;
|
|
17
|
-
compartmentDescriptors?: Record<string, CompartmentDescriptor> | undefined;
|
|
18
|
-
archiveOnly?: boolean | undefined;
|
|
19
|
-
computeSha512?: HashFn | undefined;
|
|
20
|
-
searchSuffixes?: string[] | undefined;
|
|
21
|
-
entryCompartmentName: string;
|
|
22
|
-
entryModuleSpecifier: string;
|
|
23
|
-
exitModuleImportHook?: ExitModuleImportHook | undefined;
|
|
24
|
-
sourceMapHook?: SourceMapHook | undefined;
|
|
25
|
-
}): ImportHookMaker;
|
|
15
|
+
export function makeImportHookMaker(readPowers: ReadFn | ReadPowers, baseLocation: string, { sources, compartmentDescriptors, archiveOnly, computeSha512, searchSuffixes, sourceMapHook, entryCompartmentName, entryModuleSpecifier, importHook: exitModuleImportHook, }: MakeImportHookMakerOptions): ImportHookMaker;
|
|
26
16
|
import type { ReadNowPowers } from './types.js';
|
|
27
17
|
import type { MakeImportNowHookMakerOptions } from './types.js';
|
|
28
18
|
import type { ImportNowHookMaker } from './types.js';
|
|
29
19
|
import type { ExitModuleImportHook } from './types.js';
|
|
30
20
|
import type { ReadFn } from './types.js';
|
|
31
21
|
import type { ReadPowers } from './types.js';
|
|
32
|
-
import type {
|
|
33
|
-
import type { CompartmentDescriptor } from './types.js';
|
|
34
|
-
import type { HashFn } from './types.js';
|
|
35
|
-
import type { SourceMapHook } from './types.js';
|
|
22
|
+
import type { MakeImportHookMakerOptions } from './types.js';
|
|
36
23
|
import type { ImportHookMaker } from './types.js';
|
|
37
24
|
//# sourceMappingURL=import-hook.d.ts.map
|
package/src/import-hook.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-hook.d.ts","sourceRoot":"","sources":["import-hook.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import-hook.d.ts","sourceRoot":"","sources":["import-hook.js"],"names":[],"mappings":"AAklBA;;;;;;;GAOG;AACH,mDALW,aAAa,gBACb,MAAM,2IACN,6BAA6B,GAC3B,kBAAkB,CAyJ9B;AApjBM,oGALJ;IAAqC,OAAO;IACN,oBAAoB;IACnC,oBAAoB,EAAnC,MAAM;CACd,GAAU,oBAAoB,GAAC,SAAS,CA8B1C;AAiMM,gDALI,MAAM,GAAC,UAAU,gBACjB,MAAM,iLACN,0BAA0B,GACxB,eAAe,CAwL3B;mCA5iBS,YAAY;mDAAZ,YAAY;wCAAZ,YAAY;0CAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;gDAAZ,YAAY;qCAAZ,YAAY"}
|
package/src/import-hook.js
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* HashFn,
|
|
26
26
|
* ImportHookMaker,
|
|
27
27
|
* ImportNowHookMaker,
|
|
28
|
+
* MakeImportHookMakerOptions,
|
|
28
29
|
* MakeImportNowHookMakerOptions,
|
|
29
30
|
* ModuleDescriptor,
|
|
30
31
|
* ParseResult,
|
|
@@ -267,11 +268,13 @@ function* chooseModuleDescriptor(
|
|
|
267
268
|
packageLocation,
|
|
268
269
|
packageSources,
|
|
269
270
|
readPowers,
|
|
271
|
+
archiveOnly,
|
|
270
272
|
sourceMapHook,
|
|
271
273
|
strictlyRequiredForCompartment,
|
|
272
274
|
},
|
|
273
275
|
{ maybeRead, parse, shouldDeferError = () => false },
|
|
274
276
|
) {
|
|
277
|
+
const { sourceDirname } = compartmentDescriptor;
|
|
275
278
|
for (const candidateSpecifier of candidates) {
|
|
276
279
|
const candidateModuleDescriptor = moduleDescriptors[candidateSpecifier];
|
|
277
280
|
if (candidateModuleDescriptor !== undefined) {
|
|
@@ -327,6 +330,7 @@ function* chooseModuleDescriptor(
|
|
|
327
330
|
packageLocation,
|
|
328
331
|
{
|
|
329
332
|
readPowers,
|
|
333
|
+
archiveOnly,
|
|
330
334
|
sourceMapHook:
|
|
331
335
|
sourceMapHook &&
|
|
332
336
|
(nextSourceMapObject => {
|
|
@@ -378,6 +382,7 @@ function* chooseModuleDescriptor(
|
|
|
378
382
|
packageSources[candidateSpecifier] = {
|
|
379
383
|
location: packageRelativeLocation,
|
|
380
384
|
sourceLocation: moduleLocation,
|
|
385
|
+
sourceDirname,
|
|
381
386
|
parser,
|
|
382
387
|
bytes: transformedBytes,
|
|
383
388
|
record: concreteRecord,
|
|
@@ -400,22 +405,7 @@ function* chooseModuleDescriptor(
|
|
|
400
405
|
/**
|
|
401
406
|
* @param {ReadFn|ReadPowers} readPowers
|
|
402
407
|
* @param {string} baseLocation
|
|
403
|
-
* @param {
|
|
404
|
-
* @param {Sources} [options.sources]
|
|
405
|
-
* @param {Record<string, CompartmentDescriptor>} [options.compartmentDescriptors]
|
|
406
|
-
* @param {boolean} [options.archiveOnly]
|
|
407
|
-
* @param {HashFn} [options.computeSha512]
|
|
408
|
-
* @param {Array<string>} [options.searchSuffixes] - Suffixes to search if the
|
|
409
|
-
* unmodified specifier is not found.
|
|
410
|
-
* Pass [] to emulate Node.js' strict behavior.
|
|
411
|
-
* The default handles Node.js' CommonJS behavior.
|
|
412
|
-
* Unlike Node.js, the Compartment Mapper lifts CommonJS up, more like a
|
|
413
|
-
* bundler, and does not attempt to vary the behavior of resolution depending
|
|
414
|
-
* on the language of the importing module.
|
|
415
|
-
* @param {string} options.entryCompartmentName
|
|
416
|
-
* @param {string} options.entryModuleSpecifier
|
|
417
|
-
* @param {ExitModuleImportHook} [options.exitModuleImportHook]
|
|
418
|
-
* @param {SourceMapHook} [options.sourceMapHook]
|
|
408
|
+
* @param {MakeImportHookMakerOptions} options
|
|
419
409
|
* @returns {ImportHookMaker}
|
|
420
410
|
*/
|
|
421
411
|
export const makeImportHookMaker = (
|
|
@@ -430,7 +420,7 @@ export const makeImportHookMaker = (
|
|
|
430
420
|
sourceMapHook = undefined,
|
|
431
421
|
entryCompartmentName,
|
|
432
422
|
entryModuleSpecifier,
|
|
433
|
-
exitModuleImportHook = undefined,
|
|
423
|
+
importHook: exitModuleImportHook = undefined,
|
|
434
424
|
},
|
|
435
425
|
) => {
|
|
436
426
|
// Set of specifiers for modules (scoped to compartment) whose parser is not
|
|
@@ -575,6 +565,7 @@ export const makeImportHookMaker = (
|
|
|
575
565
|
packageLocation,
|
|
576
566
|
packageSources,
|
|
577
567
|
readPowers,
|
|
568
|
+
archiveOnly,
|
|
578
569
|
sourceMapHook,
|
|
579
570
|
strictlyRequiredForCompartment,
|
|
580
571
|
},
|
|
@@ -617,8 +608,9 @@ export function makeImportNowHookMaker(
|
|
|
617
608
|
compartmentDescriptors = create(null),
|
|
618
609
|
computeSha512 = undefined,
|
|
619
610
|
searchSuffixes = nodejsConventionSearchSuffixes,
|
|
611
|
+
archiveOnly = false,
|
|
620
612
|
sourceMapHook = undefined,
|
|
621
|
-
exitModuleImportNowHook,
|
|
613
|
+
importNowHook: exitModuleImportNowHook = undefined,
|
|
622
614
|
},
|
|
623
615
|
) {
|
|
624
616
|
// Set of specifiers for modules (scoped to compartment) whose parser is not
|
|
@@ -720,6 +712,7 @@ export function makeImportNowHookMaker(
|
|
|
720
712
|
packageLocation,
|
|
721
713
|
packageSources,
|
|
722
714
|
readPowers,
|
|
715
|
+
archiveOnly,
|
|
723
716
|
sourceMapHook,
|
|
724
717
|
strictlyRequiredForCompartment,
|
|
725
718
|
},
|
package/src/import-lite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-lite.d.ts","sourceRoot":"","sources":["import-lite.js"],"names":[],"mappings":";;;;;;;AAuEG,wCACQ,aAAa,kBACb,wBAAwB,iDAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;AAGE,wCACQ,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;
|
|
1
|
+
{"version":3,"file":"import-lite.d.ts","sourceRoot":"","sources":["import-lite.js"],"names":[],"mappings":";;;;;;;AAuEG,wCACQ,aAAa,kBACb,wBAAwB,iDAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;AAGE,wCACQ,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,WAAW,CAAC,CAChC;AA4JM,0CANI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,gDAEtB,OAAO,CAAC,UAAU,CAAC,CAU/B;mCAxNS,YAAY;8CAAZ,YAAY;+CAAZ,YAAY;iCAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;2CAAZ,YAAY;gCAAZ,YAAY"}
|
package/src/import-lite.js
CHANGED
|
@@ -169,7 +169,7 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
169
169
|
archiveOnly: false,
|
|
170
170
|
entryCompartmentName,
|
|
171
171
|
entryModuleSpecifier,
|
|
172
|
-
|
|
172
|
+
importHook: compartmentExitModuleImportHook,
|
|
173
173
|
},
|
|
174
174
|
);
|
|
175
175
|
|
|
@@ -188,9 +188,11 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
188
188
|
/** @type {ReadNowPowers} */ (readPowers),
|
|
189
189
|
entryCompartmentName,
|
|
190
190
|
{
|
|
191
|
+
entryCompartmentName,
|
|
192
|
+
entryModuleSpecifier,
|
|
191
193
|
compartmentDescriptors: compartmentMap.compartments,
|
|
192
194
|
searchSuffixes,
|
|
193
|
-
exitModuleImportNowHook,
|
|
195
|
+
importNowHook: exitModuleImportNowHook,
|
|
194
196
|
},
|
|
195
197
|
);
|
|
196
198
|
({ compartment, pendingJobsPromise } = link(compartmentMap, {
|
package/src/node-modules.d.ts
CHANGED
|
@@ -1,54 +1,11 @@
|
|
|
1
|
-
export function
|
|
2
|
-
export function
|
|
3
|
-
|
|
4
|
-
* The graph is an intermediate object model that the functions of this module
|
|
5
|
-
* build by exploring the `node_modules` tree dropped by tools like npm and
|
|
6
|
-
* consumed by tools like Node.js.
|
|
7
|
-
* This gets translated finally into a compartment map.
|
|
8
|
-
*/
|
|
9
|
-
export type Graph = Record<string, Node>;
|
|
10
|
-
export type Node = {
|
|
11
|
-
label: string;
|
|
12
|
-
name: string;
|
|
13
|
-
path: Array<string>;
|
|
14
|
-
logicalPath: Array<string>;
|
|
15
|
-
explicitExports: boolean;
|
|
16
|
-
internalAliases: Record<string, string>;
|
|
17
|
-
externalAliases: Record<string, string>;
|
|
18
|
-
/**
|
|
19
|
-
* - from module name to
|
|
20
|
-
* location in storage.
|
|
21
|
-
*/
|
|
22
|
-
dependencyLocations: Record<string, string>;
|
|
23
|
-
/**
|
|
24
|
-
* - the parser for
|
|
25
|
-
* modules based on their extension.
|
|
26
|
-
*/
|
|
27
|
-
parsers: LanguageForExtension;
|
|
28
|
-
/**
|
|
29
|
-
* - the parser for specific
|
|
30
|
-
* modules.
|
|
31
|
-
*/
|
|
32
|
-
types: Record<string, Language>;
|
|
33
|
-
};
|
|
34
|
-
export type LanguageOptions = {
|
|
35
|
-
commonjsLanguageForExtension: LanguageForExtension;
|
|
36
|
-
moduleLanguageForExtension: LanguageForExtension;
|
|
37
|
-
workspaceCommonjsLanguageForExtension: LanguageForExtension;
|
|
38
|
-
workspaceModuleLanguageForExtension: LanguageForExtension;
|
|
39
|
-
languages: Set<string>;
|
|
40
|
-
};
|
|
41
|
-
export type CommonDependencyDescriptors = Record<string, {
|
|
42
|
-
spec: string;
|
|
43
|
-
alias: string;
|
|
44
|
-
}>;
|
|
45
|
-
export type ReadDescriptorFn = (packageLocation: string) => Promise<object>;
|
|
1
|
+
export function basename(location: string): string;
|
|
2
|
+
export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string, conditionsOption: Set<string>, packageDescriptor: PackageDescriptor, moduleSpecifier: string, options?: CompartmentMapForNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>;
|
|
3
|
+
export function mapNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, { tags, conditions, log, ...otherOptions }?: MapNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>;
|
|
46
4
|
import type { ReadFn } from './types.js';
|
|
47
5
|
import type { ReadPowers } from './types.js';
|
|
48
6
|
import type { MaybeReadPowers } from './types.js';
|
|
7
|
+
import type { PackageDescriptor } from './types.js';
|
|
49
8
|
import type { CompartmentMapForNodeModulesOptions } from './types.js';
|
|
50
9
|
import type { CompartmentMapDescriptor } from './types.js';
|
|
51
10
|
import type { MapNodeModulesOptions } from './types.js';
|
|
52
|
-
import type { LanguageForExtension } from './types.js';
|
|
53
|
-
import type { Language } from './types.js';
|
|
54
11
|
//# sourceMappingURL=node-modules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.js"],"names":[],"mappings":"AAiFO,mCAHI,MAAM,GACJ,MAAM,CAYlB;AAuwBM,yDATI,MAAM,GAAG,UAAU,GAAG,eAAe,mBACrC,MAAM,oBACN,GAAG,CAAC,MAAM,CAAC,qBACX,iBAAiB,mBACjB,MAAM,8DAEJ,OAAO,CAAC,wBAAwB,CAAC,CAkE7C;AAaM,2CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,mFAEJ,OAAO,CAAC,wBAAwB,CAAC,CA0B7C;4BAz6BS,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;uCAAZ,YAAY;yDAAZ,YAAY;8CAAZ,YAAY;2CAAZ,YAAY"}
|