@endo/compartment-mapper 1.3.1 → 1.4.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 +50 -27
- package/archive-lite.d.ts +1 -0
- package/archive-lite.js +3 -0
- package/archive-parsers.d.ts +1 -0
- package/archive-parsers.js +3 -0
- package/archive.d.ts +1 -0
- package/archive.js +3 -0
- package/bundle.d.ts +1 -0
- package/bundle.js +3 -0
- package/capture-lite.d.ts +1 -0
- package/capture-lite.js +3 -0
- package/import-archive-lite.d.ts +1 -0
- package/import-archive-lite.js +3 -0
- package/import-archive-parsers.d.ts +1 -0
- package/import-archive-parsers.js +3 -0
- package/import-archive.d.ts +1 -0
- package/import-archive.js +3 -0
- package/import-lite.d.ts +1 -0
- package/import-lite.js +3 -0
- package/import-parsers.d.ts +1 -0
- package/import-parsers.js +3 -0
- package/import.d.ts +1 -0
- package/import.js +3 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/node-modules.d.ts +1 -0
- package/node-modules.js +3 -0
- package/node-powers.d.ts +1 -0
- package/node-powers.js +3 -0
- package/package.json +10 -14
- package/src/archive-lite.d.ts +6 -6
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +35 -33
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +132 -28
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +54 -14
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +21 -17
- package/src/compartment-map.d.ts +2 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +11 -3
- package/src/extension.d.ts.map +1 -1
- package/src/extension.js +1 -3
- package/src/import-archive-lite.d.ts +3 -19
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +43 -57
- package/src/import-archive-parsers.d.ts.map +1 -1
- package/src/import-archive-parsers.js +1 -0
- package/src/import-archive.d.ts +2 -2
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +15 -12
- package/src/import-hook.d.ts +2 -1
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +87 -76
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +23 -23
- package/src/import.d.ts.map +1 -1
- package/src/import.js +47 -23
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +2 -3
- package/src/json.d.ts.map +1 -1
- package/src/json.js +1 -2
- package/src/link.d.ts.map +1 -1
- package/src/link.js +12 -29
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +21 -16
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +2 -3
- package/src/node-modules.d.ts +9 -7
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +176 -87
- package/src/node-powers.d.ts +8 -8
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +29 -24
- package/src/parse-archive-cjs.d.ts +3 -2
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +5 -4
- package/src/parse-archive-mjs.d.ts +3 -2
- package/src/parse-archive-mjs.d.ts.map +1 -1
- package/src/parse-archive-mjs.js +7 -5
- package/src/parse-bytes.d.ts +3 -2
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +7 -5
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +7 -6
- package/src/parse-cjs.d.ts +3 -2
- package/src/parse-cjs.d.ts.map +1 -1
- package/src/parse-cjs.js +14 -5
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-json.js +6 -6
- package/src/parse-mjs.d.ts +3 -2
- package/src/parse-mjs.d.ts.map +1 -1
- package/src/parse-mjs.js +3 -3
- package/src/parse-pre-cjs.d.ts +3 -2
- package/src/parse-pre-cjs.d.ts.map +1 -1
- package/src/parse-pre-cjs.js +14 -4
- package/src/parse-pre-mjs.d.ts +3 -2
- package/src/parse-pre-mjs.d.ts.map +1 -1
- package/src/parse-pre-mjs.js +4 -3
- package/src/parse-text.d.ts +3 -2
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +6 -5
- package/src/policy-format.d.ts +1 -1
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +5 -7
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +15 -10
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +15 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +10 -7
- package/src/types/compartment-map-schema.d.ts +98 -0
- package/src/types/compartment-map-schema.d.ts.map +1 -0
- package/src/types/compartment-map-schema.ts +116 -0
- package/src/types/external.d.ts +256 -0
- package/src/types/external.d.ts.map +1 -0
- package/src/types/external.ts +379 -0
- package/src/types/internal.d.ts +161 -0
- package/src/types/internal.d.ts.map +1 -0
- package/src/types/internal.ts +216 -0
- package/src/types/node-powers.d.ts +46 -0
- package/src/types/node-powers.d.ts.map +1 -0
- package/src/types/node-powers.ts +52 -0
- package/src/types/policy-schema.d.ts +81 -0
- package/src/types/policy-schema.d.ts.map +1 -0
- package/src/types/policy-schema.ts +131 -0
- package/src/types/policy.d.ts +20 -0
- package/src/types/policy.d.ts.map +1 -0
- package/src/types/policy.ts +42 -0
- package/src/types/powers.d.ts +83 -0
- package/src/types/powers.d.ts.map +1 -0
- package/src/types/powers.ts +120 -0
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -0
- package/src/types/typescript.ts +41 -0
- package/src/types-external.d.ts +14 -0
- package/src/types-external.js +2 -0
- package/src/types.d.ts +9 -787
- package/src/url.d.ts.map +1 -1
- package/src/url.js +2 -3
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -995
- package/types.d.ts +0 -19
package/src/import-lite.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides functions for evaluating a module and its transitive
|
|
3
|
+
* dependencies given a partially completed compartment map.
|
|
3
4
|
* The compartment map needs to describe every reachable compartment, where to
|
|
4
5
|
* find modules in that compartment, and how to link modules between
|
|
5
6
|
* compartments, but does not need to capture a module descriptor for every
|
|
@@ -14,19 +15,22 @@
|
|
|
14
15
|
* `@endo/compartment-mapper/import-parsers.js` or similar.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
|
-
// @ts-check
|
|
18
18
|
/* eslint no-shadow: "off" */
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @import {
|
|
22
|
+
* CompartmentMapDescriptor,
|
|
23
|
+
* SyncImportLocationOptions,
|
|
24
|
+
* ImportNowHookMaker,
|
|
25
|
+
* ReadNowPowers,
|
|
26
|
+
* Application,
|
|
27
|
+
* ImportLocationOptions,
|
|
28
|
+
* ExecuteFn,
|
|
29
|
+
* ReadFn,
|
|
30
|
+
* ReadPowers,
|
|
31
|
+
* SomeObject,
|
|
32
|
+
* } from './types.js'
|
|
33
|
+
*/
|
|
30
34
|
|
|
31
35
|
import { link } from './link.js';
|
|
32
36
|
import {
|
|
@@ -91,15 +95,12 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
91
95
|
const {
|
|
92
96
|
searchSuffixes = undefined,
|
|
93
97
|
parserForLanguage: parserForLanguageOption = {},
|
|
94
|
-
|
|
98
|
+
Compartment: LoadCompartmentOption = Compartment,
|
|
95
99
|
} = options;
|
|
96
100
|
|
|
97
101
|
const parserForLanguage = freeze(
|
|
98
102
|
assign(create(null), parserForLanguageOption),
|
|
99
103
|
);
|
|
100
|
-
const languageForExtension = freeze(
|
|
101
|
-
assign(create(null), languageForExtensionOption),
|
|
102
|
-
);
|
|
103
104
|
|
|
104
105
|
/**
|
|
105
106
|
* Object containing options and read powers that fulfills all requirements
|
|
@@ -150,12 +151,13 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
150
151
|
modules,
|
|
151
152
|
transforms,
|
|
152
153
|
__shimTransforms__,
|
|
153
|
-
Compartment,
|
|
154
|
+
Compartment: CompartmentOption = LoadCompartmentOption,
|
|
154
155
|
importHook: exitModuleImportHook,
|
|
155
156
|
} = options;
|
|
156
157
|
const compartmentExitModuleImportHook = exitModuleImportHookMaker({
|
|
157
158
|
modules,
|
|
158
159
|
exitModuleImportHook,
|
|
160
|
+
entryCompartmentName,
|
|
159
161
|
});
|
|
160
162
|
const makeImportHook = makeImportHookMaker(
|
|
161
163
|
readPowers,
|
|
@@ -194,12 +196,11 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
194
196
|
makeImportHook,
|
|
195
197
|
makeImportNowHook,
|
|
196
198
|
parserForLanguage,
|
|
197
|
-
languageForExtension,
|
|
198
199
|
globals,
|
|
199
200
|
transforms,
|
|
200
201
|
syncModuleTransforms,
|
|
201
202
|
__shimTransforms__,
|
|
202
|
-
Compartment,
|
|
203
|
+
Compartment: CompartmentOption,
|
|
203
204
|
}));
|
|
204
205
|
} else {
|
|
205
206
|
// sync module transforms are allowed, because they are "compatible"
|
|
@@ -208,13 +209,12 @@ export const loadFromMap = async (readPowers, compartmentMap, options = {}) => {
|
|
|
208
209
|
({ compartment, pendingJobsPromise } = link(compartmentMap, {
|
|
209
210
|
makeImportHook,
|
|
210
211
|
parserForLanguage,
|
|
211
|
-
languageForExtension,
|
|
212
212
|
globals,
|
|
213
213
|
transforms,
|
|
214
214
|
moduleTransforms,
|
|
215
215
|
syncModuleTransforms,
|
|
216
216
|
__shimTransforms__,
|
|
217
|
-
Compartment,
|
|
217
|
+
Compartment: CompartmentOption,
|
|
218
218
|
}));
|
|
219
219
|
}
|
|
220
220
|
|
package/src/import.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["import.js"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["import.js"],"names":[],"mappings":";;;;;;;AAiDG,yCACQ,aAAa,kBACb,MAAM,WACN,kBAAkB,GAChB,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;AAGE,yCACQ,MAAM,GAAG,UAAU,kBACnB,MAAM,8CAEJ,OAAO,CAAC,WAAW,CAAC,CAChC;;;;;;;;;;;AAqDE,2CACQ,aAAa,kBACb,MAAM,WACN,yBAAyB,GACvB,OAAO,CAAC,UAAU,CAAC,CAE/B;;;;;;;;;;;AAKE,2CACQ,UAAU,GAAC,MAAM,kBACjB,MAAM,gDAEJ,OAAO,CAAC,UAAU,CAAC,CAE/B;mCA3GS,YAAY;wCAAZ,YAAY;iCAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;yCAAZ,YAAY;+CAAZ,YAAY;gCAAZ,YAAY;2CAAZ,YAAY"}
|
package/src/import.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides functions for evaluating a module and its transitive
|
|
3
|
+
* dependencies given the URL of the entry module and assuming packages laid
|
|
4
|
+
* out according to the `node_modules` conventions.
|
|
4
5
|
*
|
|
5
6
|
* To import modules according to any other convention, use `import-lite.js`
|
|
6
7
|
* and provide a compartment map with a custom analog to `mapNodeModules` from
|
|
@@ -10,7 +11,20 @@
|
|
|
10
11
|
* for most cases.
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @import {
|
|
16
|
+
* Application,
|
|
17
|
+
* SyncImportLocationOptions,
|
|
18
|
+
* ImportLocationOptions,
|
|
19
|
+
* SyncArchiveOptions,
|
|
20
|
+
* LoadLocationOptions,
|
|
21
|
+
* SomeObject,
|
|
22
|
+
* ReadNowPowers,
|
|
23
|
+
* ArchiveOptions,
|
|
24
|
+
* ReadFn,
|
|
25
|
+
* ReadPowers,
|
|
26
|
+
* } from './types.js'
|
|
27
|
+
*/
|
|
14
28
|
|
|
15
29
|
import { defaultParserForLanguage } from './import-parsers.js';
|
|
16
30
|
import { mapNodeModules } from './node-modules.js';
|
|
@@ -18,17 +32,6 @@ import { loadFromMap } from './import-lite.js';
|
|
|
18
32
|
|
|
19
33
|
const { assign, create, freeze } = Object;
|
|
20
34
|
|
|
21
|
-
/** @import {Application} from './types.js' */
|
|
22
|
-
/** @import {ImportLocationOptions} from './types.js' */
|
|
23
|
-
/** @import {SyncArchiveOptions} from './types.js' */
|
|
24
|
-
/** @import {LoadLocationOptions} from './types.js' */
|
|
25
|
-
/** @import {SyncImportLocationOptions} from './types.js' */
|
|
26
|
-
/** @import {SomeObject} from './types.js' */
|
|
27
|
-
/** @import {ReadNowPowers} from './types.js' */
|
|
28
|
-
/** @import {ArchiveOptions} from './types.js' */
|
|
29
|
-
/** @import {ReadFn} from './types.js' */
|
|
30
|
-
/** @import {ReadPowers} from './types.js' */
|
|
31
|
-
|
|
32
35
|
/**
|
|
33
36
|
* Add the default parserForLanguage option.
|
|
34
37
|
* @param {ArchiveOptions} [options]
|
|
@@ -39,7 +42,8 @@ const assignParserForLanguage = (options = {}) => {
|
|
|
39
42
|
const parserForLanguage = freeze(
|
|
40
43
|
assign(create(null), defaultParserForLanguage, parserForLanguageOption),
|
|
41
44
|
);
|
|
42
|
-
|
|
45
|
+
const languages = Object.keys(parserForLanguage);
|
|
46
|
+
return { ...rest, parserForLanguage, languages };
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
/**
|
|
@@ -69,7 +73,21 @@ export const loadLocation = async (
|
|
|
69
73
|
moduleLocation,
|
|
70
74
|
options = {},
|
|
71
75
|
) => {
|
|
72
|
-
const {
|
|
76
|
+
const {
|
|
77
|
+
dev,
|
|
78
|
+
tags,
|
|
79
|
+
commonDependencies,
|
|
80
|
+
policy,
|
|
81
|
+
parserForLanguage,
|
|
82
|
+
languages,
|
|
83
|
+
languageForExtension,
|
|
84
|
+
commonjsLanguageForExtension,
|
|
85
|
+
moduleLanguageForExtension,
|
|
86
|
+
workspaceLanguageForExtension,
|
|
87
|
+
workspaceCommonjsLanguageForExtension,
|
|
88
|
+
workspaceModuleLanguageForExtension,
|
|
89
|
+
...otherOptions
|
|
90
|
+
} = assignParserForLanguage(options);
|
|
73
91
|
// conditions are not present in SyncArchiveOptions
|
|
74
92
|
const conditions =
|
|
75
93
|
'conditions' in options ? options.conditions || tags : tags;
|
|
@@ -78,12 +96,18 @@ export const loadLocation = async (
|
|
|
78
96
|
conditions,
|
|
79
97
|
commonDependencies,
|
|
80
98
|
policy,
|
|
99
|
+
languageForExtension,
|
|
100
|
+
commonjsLanguageForExtension,
|
|
101
|
+
moduleLanguageForExtension,
|
|
102
|
+
workspaceLanguageForExtension,
|
|
103
|
+
workspaceCommonjsLanguageForExtension,
|
|
104
|
+
workspaceModuleLanguageForExtension,
|
|
105
|
+
languages,
|
|
106
|
+
});
|
|
107
|
+
return loadFromMap(readPowers, compartmentMap, {
|
|
108
|
+
parserForLanguage,
|
|
109
|
+
...otherOptions,
|
|
81
110
|
});
|
|
82
|
-
return loadFromMap(
|
|
83
|
-
readPowers,
|
|
84
|
-
compartmentMap,
|
|
85
|
-
assignParserForLanguage(options),
|
|
86
|
-
);
|
|
87
111
|
};
|
|
88
112
|
|
|
89
113
|
/**
|
|
@@ -111,7 +135,7 @@ export const loadLocation = async (
|
|
|
111
135
|
/**
|
|
112
136
|
* @param {ReadPowers|ReadFn|ReadNowPowers} readPowers
|
|
113
137
|
* @param {string} moduleLocation
|
|
114
|
-
* @param {ImportLocationOptions} [options]
|
|
138
|
+
* @param {ImportLocationOptions|SyncImportLocationOptions} [options]
|
|
115
139
|
* @returns {Promise<SomeObject>} the object of the imported modules exported
|
|
116
140
|
* names.
|
|
117
141
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infer-exports.d.ts","sourceRoot":"","sources":["infer-exports.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"infer-exports.d.ts","sourceRoot":"","sources":["infer-exports.js"],"names":[],"mappings":"AAqHO,+DATJ;IAAkC,IAAI,EAA9B,MAAM;IACqB,MAAM;IACN,OAAO,GAAlC,MAAM;CACd,cAAQ,GAAG,CAAC,MAAM,CAAC,SAEX,oBAAoB,kCA2B9B;AAkBM,yCAPI,MAAM,cACN,GAAG,CAAC,MAAM,CAAC,SAEX,oBAAoB,GAElB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG8B;AAE1D,uIA2CN;0CApMuC,YAAY"}
|
package/src/infer-exports.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides functions needed by `node-modules.js` for building
|
|
2
3
|
* inter-compartment linkage according to the specifications in a
|
|
3
4
|
* `package.json` as laid out in the `node_modules` convention.
|
|
4
5
|
* These functions implement the behavior for a package's `"main"`,
|
|
5
6
|
* `"browser"`, `"imports"`, and `"exports"` properties in a `package.json`.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
// @ts-check
|
|
9
|
-
|
|
10
9
|
/** @import {LanguageForExtension} from './types.js' */
|
|
11
10
|
|
|
12
11
|
import { join, relativize } from './node-module-specifier.js';
|
package/src/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["json.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["json.js"],"names":[],"mappings":"AASO,yCAHI,MAAM,YACN,MAAM,OAWhB"}
|
package/src/json.js
CHANGED
package/src/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.js"],"names":[],"mappings":"AAsPO,sEAJI,wBAAwB,WACxB,WAAW,GACT,UAAU,CAwKtB;AAOM,yCAJI,wBAAwB,WACxB,WAAW,eAIqB;8CA5YjC,YAAY;iCAAZ,YAAY;gCAAZ,YAAY"}
|
package/src/link.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides the linking behavior shared by all Compartment Mapper
|
|
3
|
+
* workflows.
|
|
2
4
|
* This involves creating and configuring compartments according to the
|
|
3
5
|
* specifications in a compartment map, and is suitable for compartment maps
|
|
4
6
|
* that just outline the locations of compartments and their inter-linkage and
|
|
@@ -6,26 +8,22 @@
|
|
|
6
8
|
* dependencies of their entry module.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
|
-
// @ts-check
|
|
10
|
-
|
|
11
|
-
/** @import {ModuleMapHook} from 'ses' */
|
|
12
11
|
/**
|
|
12
|
+
* @import {ModuleMapHook} from 'ses'
|
|
13
13
|
* @import {
|
|
14
14
|
* CompartmentDescriptor,
|
|
15
15
|
* CompartmentMapDescriptor,
|
|
16
16
|
* ImportNowHookMaker,
|
|
17
|
-
* LanguageForExtension,
|
|
18
17
|
* LinkOptions,
|
|
19
18
|
* LinkResult,
|
|
20
19
|
* ModuleDescriptor,
|
|
21
20
|
* ParseFn,
|
|
22
|
-
*
|
|
21
|
+
* AsyncParseFn,
|
|
23
22
|
* ParserForLanguage,
|
|
24
23
|
* ParserImplementation,
|
|
25
24
|
* ShouldDeferError,
|
|
26
25
|
* } from './types.js'
|
|
27
26
|
*/
|
|
28
|
-
/** @import {ERef} from '@endo/eventual-send' */
|
|
29
27
|
|
|
30
28
|
import { makeMapParsers } from './map-parser.js';
|
|
31
29
|
import { resolve as resolveFallback } from './node-module-specifier.js';
|
|
@@ -43,7 +41,7 @@ const { allSettled } = Promise;
|
|
|
43
41
|
|
|
44
42
|
/**
|
|
45
43
|
* @template T
|
|
46
|
-
* @type {(iterable: Iterable<
|
|
44
|
+
* @type {(iterable: Iterable<Promise<T>>) => Promise<Array<PromiseSettledResult<T>>>}
|
|
47
45
|
*/
|
|
48
46
|
const promiseAllSettled = allSettled.bind(Promise);
|
|
49
47
|
|
|
@@ -112,6 +110,8 @@ const makeModuleMapHook = (
|
|
|
112
110
|
|
|
113
111
|
const moduleDescriptor = moduleDescriptors[moduleSpecifier];
|
|
114
112
|
if (moduleDescriptor !== undefined) {
|
|
113
|
+
moduleDescriptor.retained = true;
|
|
114
|
+
|
|
115
115
|
// "foreignCompartmentName" refers to the compartment which
|
|
116
116
|
// may differ from the current compartment
|
|
117
117
|
const {
|
|
@@ -193,6 +193,7 @@ const makeModuleMapHook = (
|
|
|
193
193
|
// a moduleMapHook when we assemble compartments from the resulting
|
|
194
194
|
// archive.
|
|
195
195
|
moduleDescriptors[moduleSpecifier] = {
|
|
196
|
+
retained: true,
|
|
196
197
|
compartment: foreignCompartmentName,
|
|
197
198
|
module: foreignModuleSpecifier,
|
|
198
199
|
};
|
|
@@ -252,7 +253,6 @@ export const link = (
|
|
|
252
253
|
makeImportHook,
|
|
253
254
|
makeImportNowHook = impossibleImportNowHookMaker,
|
|
254
255
|
parserForLanguage: parserForLanguageOption = {},
|
|
255
|
-
languageForExtension: languageForExtensionOption = {},
|
|
256
256
|
globals = {},
|
|
257
257
|
transforms = [],
|
|
258
258
|
moduleTransforms,
|
|
@@ -277,10 +277,6 @@ export const link = (
|
|
|
277
277
|
|
|
278
278
|
const pendingJobs = [];
|
|
279
279
|
|
|
280
|
-
/** @type {LanguageForExtension} */
|
|
281
|
-
const defaultLanguageForExtension = freeze(
|
|
282
|
-
assign(create(null), languageForExtensionOption),
|
|
283
|
-
);
|
|
284
280
|
/** @type {ParserForLanguage} */
|
|
285
281
|
const parserForLanguage = freeze(
|
|
286
282
|
assign(create(null), parserForLanguageOption),
|
|
@@ -298,8 +294,8 @@ export const link = (
|
|
|
298
294
|
const {
|
|
299
295
|
location,
|
|
300
296
|
name,
|
|
301
|
-
parsers:
|
|
302
|
-
types:
|
|
297
|
+
parsers: languageForExtension = {},
|
|
298
|
+
types: languageForModuleSpecifier = {},
|
|
303
299
|
} = compartmentDescriptor;
|
|
304
300
|
|
|
305
301
|
// this is for retaining the correct type inference about these values
|
|
@@ -312,22 +308,9 @@ export const link = (
|
|
|
312
308
|
// The `moduleMapHook` writes back to the compartment map.
|
|
313
309
|
compartmentDescriptor.modules = modules;
|
|
314
310
|
|
|
315
|
-
/** @type {Record<string, string>} */
|
|
316
|
-
const languageForModuleSpecifier = freeze(
|
|
317
|
-
assign(create(null), languageForModuleSpecifierOverrides),
|
|
318
|
-
);
|
|
319
|
-
/** @type {LanguageForExtension} */
|
|
320
|
-
const languageForExtension = freeze(
|
|
321
|
-
assign(
|
|
322
|
-
create(null),
|
|
323
|
-
defaultLanguageForExtension,
|
|
324
|
-
languageForExtensionOverrides,
|
|
325
|
-
),
|
|
326
|
-
);
|
|
327
|
-
|
|
328
311
|
// TS is kind of dumb about this, so we can use a type assertion to avoid a
|
|
329
312
|
// pointless ternary.
|
|
330
|
-
const parse = /** @type {ParseFn|
|
|
313
|
+
const parse = /** @type {ParseFn|AsyncParseFn} */ (
|
|
331
314
|
mapParsers(languageForExtension, languageForModuleSpecifier)
|
|
332
315
|
);
|
|
333
316
|
|
package/src/map-parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-parser.d.ts","sourceRoot":"","sources":["map-parser.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map-parser.d.ts","sourceRoot":"","sources":["map-parser.js"],"names":[],"mappings":"AA0SO,+FAHI,qBAAqB,GACnB,YAAY,CA+CxB;2CApUS,YAAY;kCAAZ,YAAY"}
|
package/src/map-parser.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Exports {@link makeMapParsers}, which creates a function which matches a
|
|
2
|
+
* @module Exports {@link makeMapParsers}, which creates a function which matches a
|
|
3
3
|
* module to a parser based on reasons.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
4
|
*/
|
|
7
5
|
|
|
8
|
-
// @ts-check
|
|
9
|
-
|
|
10
|
-
import { syncTrampoline, asyncTrampoline } from '@endo/trampoline';
|
|
11
|
-
import { parseExtension } from './extension.js';
|
|
12
|
-
|
|
13
6
|
/**
|
|
14
7
|
* @import {
|
|
15
8
|
* LanguageForExtension,
|
|
@@ -19,7 +12,7 @@ import { parseExtension } from './extension.js';
|
|
|
19
12
|
* ModuleTransform,
|
|
20
13
|
* ModuleTransforms,
|
|
21
14
|
* ParseFn,
|
|
22
|
-
*
|
|
15
|
+
* AsyncParseFn,
|
|
23
16
|
* ParseResult,
|
|
24
17
|
* ParserForLanguage,
|
|
25
18
|
* SyncModuleTransform,
|
|
@@ -27,6 +20,9 @@ import { parseExtension } from './extension.js';
|
|
|
27
20
|
* } from './types.js';
|
|
28
21
|
*/
|
|
29
22
|
|
|
23
|
+
import { syncTrampoline, asyncTrampoline } from '@endo/trampoline';
|
|
24
|
+
import { parseExtension } from './extension.js';
|
|
25
|
+
|
|
30
26
|
const { entries, fromEntries, keys, hasOwnProperty, values } = Object;
|
|
31
27
|
const { apply } = Reflect;
|
|
32
28
|
// q, as in quote, for strings in error messages.
|
|
@@ -64,7 +60,7 @@ const extensionImpliesLanguage = extension => extension !== 'js';
|
|
|
64
60
|
* @param {ParserForLanguage} parserForLanguage
|
|
65
61
|
* @param {ModuleTransforms} moduleTransforms
|
|
66
62
|
* @param {SyncModuleTransforms} syncModuleTransforms
|
|
67
|
-
* @returns {
|
|
63
|
+
* @returns {AsyncParseFn|ParseFn}
|
|
68
64
|
*/
|
|
69
65
|
const makeExtensionParser = (
|
|
70
66
|
preferSynchronous,
|
|
@@ -78,7 +74,8 @@ const makeExtensionParser = (
|
|
|
78
74
|
let transforms;
|
|
79
75
|
|
|
80
76
|
/**
|
|
81
|
-
* Function returning a generator which executes a parser for a module in
|
|
77
|
+
* Function returning a generator which executes a parser for a module in
|
|
78
|
+
* either sync or async context.
|
|
82
79
|
*
|
|
83
80
|
* @param {Uint8Array} bytes
|
|
84
81
|
* @param {string} specifier
|
|
@@ -104,6 +101,14 @@ const makeExtensionParser = (
|
|
|
104
101
|
) {
|
|
105
102
|
language = languageForModuleSpecifier[specifier];
|
|
106
103
|
} else {
|
|
104
|
+
// We should revisit this design decision:
|
|
105
|
+
// Defaulting the language to the extension conflates those namespaces.
|
|
106
|
+
// So, a transform keyed by extension can be used to coerce a language
|
|
107
|
+
// (e.g., .mts to mjs) as a shorthand for configuring a parser for that
|
|
108
|
+
// extension that pre-processes the file before handing off to the
|
|
109
|
+
// parser.
|
|
110
|
+
// But, this forces us to support the case of using weird language
|
|
111
|
+
// names like pre-mjs-json as valid, unconfigured extensions.
|
|
107
112
|
language = languageForExtension[extension] || extension;
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -169,7 +174,7 @@ const makeExtensionParser = (
|
|
|
169
174
|
syncParser.isSyncParser = true;
|
|
170
175
|
|
|
171
176
|
/**
|
|
172
|
-
* @type {
|
|
177
|
+
* @type {AsyncParseFn}
|
|
173
178
|
*/
|
|
174
179
|
const asyncParser = async (
|
|
175
180
|
bytes,
|
|
@@ -190,7 +195,7 @@ const makeExtensionParser = (
|
|
|
190
195
|
|
|
191
196
|
// Unfortunately, typescript was not smart enough to figure out the return
|
|
192
197
|
// type depending on a boolean in arguments, so it has to be
|
|
193
|
-
//
|
|
198
|
+
// AsyncParseFn|ParseFn
|
|
194
199
|
if (preferSynchronous) {
|
|
195
200
|
transforms = syncModuleTransforms;
|
|
196
201
|
return syncParser;
|
|
@@ -233,7 +238,7 @@ const makeExtensionParser = (
|
|
|
233
238
|
* @param {ModuleTransforms} [moduleTransforms]
|
|
234
239
|
* @param {SyncModuleTransforms} [syncModuleTransforms]
|
|
235
240
|
* @param {false} [preferSynchronous]
|
|
236
|
-
* @returns {
|
|
241
|
+
* @returns {AsyncParseFn}
|
|
237
242
|
*/
|
|
238
243
|
|
|
239
244
|
/**
|
|
@@ -245,7 +250,7 @@ const makeExtensionParser = (
|
|
|
245
250
|
* @param {ModuleTransforms} [moduleTransforms]
|
|
246
251
|
* @param {SyncModuleTransforms} [syncModuleTransforms]
|
|
247
252
|
* @param {boolean} [preferSynchronous] If `true`, will create a `ParseFn`
|
|
248
|
-
* @returns {
|
|
253
|
+
* @returns {AsyncParseFn|ParseFn}
|
|
249
254
|
*/
|
|
250
255
|
function mapParsers(
|
|
251
256
|
languageForExtension,
|
|
@@ -300,7 +305,7 @@ export const makeMapParsers = ({
|
|
|
300
305
|
* Async `mapParsers()` function; returned when a non-synchronous parser is
|
|
301
306
|
* present _or_ when `moduleTransforms` is non-empty.
|
|
302
307
|
*
|
|
303
|
-
* @type {MapParsersFn<
|
|
308
|
+
* @type {MapParsersFn<AsyncParseFn>}
|
|
304
309
|
*/
|
|
305
310
|
const asyncParseFn = (languageForExtension, languageForModuleSpecifier) =>
|
|
306
311
|
mapParsers(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-module-specifier.d.ts","sourceRoot":"","sources":["node-module-specifier.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-module-specifier.d.ts","sourceRoot":"","sources":["node-module-specifier.js"],"names":[],"mappings":"AAwDO,8BAJI,MAAM,YACN,MAAM,GACJ,MAAM,CAiClB;AAeM,2BAJI,MAAM,QACN,MAAM,GACJ,MAAM,CA6BlB;AAaM,iCALI,MAAM,GAEJ,MAAM,CAclB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides functions for interacting with Node.js module specifiers in
|
|
2
3
|
* their canonical form.
|
|
3
4
|
* This is a kind of path math that is platform-agnostic.
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
// @ts-check
|
|
7
|
-
|
|
8
7
|
// q, as in quote, for error messages.
|
|
9
8
|
const q = JSON.stringify;
|
|
10
9
|
|
package/src/node-modules.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string, conditions: Set<string>, packageDescriptor: object, moduleSpecifier: string, options?: CompartmentMapForNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>;
|
|
2
|
-
export function mapNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?:
|
|
3
|
-
tags?: Set<string> | undefined;
|
|
4
|
-
conditions?: Set<string> | undefined;
|
|
5
|
-
dev?: boolean | undefined;
|
|
6
|
-
commonDependencies?: object;
|
|
7
|
-
policy?: object;
|
|
8
|
-
} | undefined): Promise<CompartmentMapDescriptor>;
|
|
2
|
+
export function mapNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: MapNodeModulesOptions | undefined): Promise<CompartmentMapDescriptor>;
|
|
9
3
|
/**
|
|
10
4
|
* The graph is an intermediate object model that the functions of this module
|
|
11
5
|
* build by exploring the `node_modules` tree dropped by tools like npm and
|
|
@@ -37,6 +31,13 @@ export type Node = {
|
|
|
37
31
|
*/
|
|
38
32
|
types: Record<string, Language>;
|
|
39
33
|
};
|
|
34
|
+
export type LanguageOptions = {
|
|
35
|
+
commonjsLanguageForExtension: LanguageForExtension;
|
|
36
|
+
moduleLanguageForExtension: LanguageForExtension;
|
|
37
|
+
workspaceCommonjsLanguageForExtension: LanguageForExtension;
|
|
38
|
+
workspaceModuleLanguageForExtension: LanguageForExtension;
|
|
39
|
+
languages: Set<string>;
|
|
40
|
+
};
|
|
40
41
|
export type CommonDependencyDescriptors = Record<string, {
|
|
41
42
|
spec: string;
|
|
42
43
|
alias: string;
|
|
@@ -47,6 +48,7 @@ import type { ReadPowers } from './types.js';
|
|
|
47
48
|
import type { MaybeReadPowers } from './types.js';
|
|
48
49
|
import type { CompartmentMapForNodeModulesOptions } from './types.js';
|
|
49
50
|
import type { CompartmentMapDescriptor } from './types.js';
|
|
51
|
+
import type { MapNodeModulesOptions } from './types.js';
|
|
50
52
|
import type { LanguageForExtension } from './types.js';
|
|
51
53
|
import type { Language } from './types.js';
|
|
52
54
|
//# 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":"AAy1BO,yDARI,MAAM,GAAG,UAAU,GAAG,eAAe,mBACrC,MAAM,cACN,GAAG,CAAC,MAAM,CAAC,qBACX,MAAM,mBACN,MAAM,8DAEJ,OAAO,CAAC,wBAAwB,CAAC,CAkD7C;AAQM,2CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,gDAEJ,OAAO,CAAC,wBAAwB,CAAC,CA6B7C;;;;;;;oBAr4BY,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC;;WAKnB,MAAM;UACN,MAAM;UACN,KAAK,CAAC,MAAM,CAAC;iBACb,KAAK,CAAC,MAAM,CAAC;qBACb,OAAO;qBACP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;qBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;yBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;aAEtB,oBAAoB;;;;;WAEpB,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC;;;kCAMxB,oBAAoB;gCACpB,oBAAoB;2CACpB,oBAAoB;yCACpB,oBAAoB;eACpB,GAAG,CAAC,MAAM,CAAC;;0CAIZ,MAAM,CAAC,MAAM,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC;iDA+E/C,MAAM,KACJ,OAAO,CAAC,MAAM,CAAC;4BAvHlB,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;yDAAZ,YAAY;8CAAZ,YAAY;2CAAZ,YAAY;0CAAZ,YAAY;8BAAZ,YAAY"}
|