@endo/compartment-mapper 1.3.1 → 1.5.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 +64 -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-all-parsers.d.ts +2 -0
- package/import-archive-all-parsers.d.ts.map +1 -0
- package/import-archive-all-parsers.js +1 -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 +16 -15
- package/src/archive-lite.d.ts +8 -10
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +35 -209
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +140 -28
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +62 -16
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +27 -201
- 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/digest.d.ts +5 -0
- package/src/digest.d.ts.map +1 -0
- package/src/digest.js +235 -0
- package/src/extension.d.ts.map +1 -1
- package/src/extension.js +1 -3
- package/src/import-archive-all-parsers.d.ts +11 -0
- package/src/import-archive-all-parsers.d.ts.map +1 -0
- package/src/import-archive-all-parsers.js +29 -0
- 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 +47 -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 +26 -23
- package/src/import.d.ts.map +1 -1
- package/src/import.js +49 -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 +14 -29
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +25 -17
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +2 -3
- package/src/node-modules.d.ts +10 -8
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +212 -97
- 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 +299 -0
- package/src/types/external.d.ts.map +1 -0
- package/src/types/external.ts +428 -0
- package/src/types/internal.d.ts +162 -0
- package/src/types/internal.d.ts.map +1 -0
- package/src/types/internal.ts +217 -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/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,14 +12,20 @@ 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,
|
|
26
19
|
* SyncModuleTransforms
|
|
27
20
|
* } from './types.js';
|
|
21
|
+
* @import {
|
|
22
|
+
* EReturn
|
|
23
|
+
* } from '@endo/eventual-send';
|
|
28
24
|
*/
|
|
29
25
|
|
|
26
|
+
import { syncTrampoline, asyncTrampoline } from '@endo/trampoline';
|
|
27
|
+
import { parseExtension } from './extension.js';
|
|
28
|
+
|
|
30
29
|
const { entries, fromEntries, keys, hasOwnProperty, values } = Object;
|
|
31
30
|
const { apply } = Reflect;
|
|
32
31
|
// q, as in quote, for strings in error messages.
|
|
@@ -64,7 +63,7 @@ const extensionImpliesLanguage = extension => extension !== 'js';
|
|
|
64
63
|
* @param {ParserForLanguage} parserForLanguage
|
|
65
64
|
* @param {ModuleTransforms} moduleTransforms
|
|
66
65
|
* @param {SyncModuleTransforms} syncModuleTransforms
|
|
67
|
-
* @returns {
|
|
66
|
+
* @returns {AsyncParseFn|ParseFn}
|
|
68
67
|
*/
|
|
69
68
|
const makeExtensionParser = (
|
|
70
69
|
preferSynchronous,
|
|
@@ -78,14 +77,15 @@ const makeExtensionParser = (
|
|
|
78
77
|
let transforms;
|
|
79
78
|
|
|
80
79
|
/**
|
|
81
|
-
* Function returning a generator which executes a parser for a module in
|
|
80
|
+
* Function returning a generator which executes a parser for a module in
|
|
81
|
+
* either sync or async context.
|
|
82
82
|
*
|
|
83
83
|
* @param {Uint8Array} bytes
|
|
84
84
|
* @param {string} specifier
|
|
85
85
|
* @param {string} location
|
|
86
86
|
* @param {string} packageLocation
|
|
87
87
|
* @param {*} options
|
|
88
|
-
* @returns {Generator<ReturnType<ModuleTransform>|ReturnType<SyncModuleTransform>, ParseResult,
|
|
88
|
+
* @returns {Generator<ReturnType<ModuleTransform>|ReturnType<SyncModuleTransform>, ParseResult, EReturn<ModuleTransform|SyncModuleTransform>>}
|
|
89
89
|
*/
|
|
90
90
|
function* getParserGenerator(
|
|
91
91
|
bytes,
|
|
@@ -104,6 +104,14 @@ const makeExtensionParser = (
|
|
|
104
104
|
) {
|
|
105
105
|
language = languageForModuleSpecifier[specifier];
|
|
106
106
|
} else {
|
|
107
|
+
// We should revisit this design decision:
|
|
108
|
+
// Defaulting the language to the extension conflates those namespaces.
|
|
109
|
+
// So, a transform keyed by extension can be used to coerce a language
|
|
110
|
+
// (e.g., .mts to mjs) as a shorthand for configuring a parser for that
|
|
111
|
+
// extension that pre-processes the file before handing off to the
|
|
112
|
+
// parser.
|
|
113
|
+
// But, this forces us to support the case of using weird language
|
|
114
|
+
// names like pre-mjs-json as valid, unconfigured extensions.
|
|
107
115
|
language = languageForExtension[extension] || extension;
|
|
108
116
|
}
|
|
109
117
|
|
|
@@ -169,7 +177,7 @@ const makeExtensionParser = (
|
|
|
169
177
|
syncParser.isSyncParser = true;
|
|
170
178
|
|
|
171
179
|
/**
|
|
172
|
-
* @type {
|
|
180
|
+
* @type {AsyncParseFn}
|
|
173
181
|
*/
|
|
174
182
|
const asyncParser = async (
|
|
175
183
|
bytes,
|
|
@@ -190,7 +198,7 @@ const makeExtensionParser = (
|
|
|
190
198
|
|
|
191
199
|
// Unfortunately, typescript was not smart enough to figure out the return
|
|
192
200
|
// type depending on a boolean in arguments, so it has to be
|
|
193
|
-
//
|
|
201
|
+
// AsyncParseFn|ParseFn
|
|
194
202
|
if (preferSynchronous) {
|
|
195
203
|
transforms = syncModuleTransforms;
|
|
196
204
|
return syncParser;
|
|
@@ -233,7 +241,7 @@ const makeExtensionParser = (
|
|
|
233
241
|
* @param {ModuleTransforms} [moduleTransforms]
|
|
234
242
|
* @param {SyncModuleTransforms} [syncModuleTransforms]
|
|
235
243
|
* @param {false} [preferSynchronous]
|
|
236
|
-
* @returns {
|
|
244
|
+
* @returns {AsyncParseFn}
|
|
237
245
|
*/
|
|
238
246
|
|
|
239
247
|
/**
|
|
@@ -245,7 +253,7 @@ const makeExtensionParser = (
|
|
|
245
253
|
* @param {ModuleTransforms} [moduleTransforms]
|
|
246
254
|
* @param {SyncModuleTransforms} [syncModuleTransforms]
|
|
247
255
|
* @param {boolean} [preferSynchronous] If `true`, will create a `ParseFn`
|
|
248
|
-
* @returns {
|
|
256
|
+
* @returns {AsyncParseFn|ParseFn}
|
|
249
257
|
*/
|
|
250
258
|
function mapParsers(
|
|
251
259
|
languageForExtension,
|
|
@@ -300,7 +308,7 @@ export const makeMapParsers = ({
|
|
|
300
308
|
* Async `mapParsers()` function; returned when a non-synchronous parser is
|
|
301
309
|
* present _or_ when `moduleTransforms` is non-empty.
|
|
302
310
|
*
|
|
303
|
-
* @type {MapParsersFn<
|
|
311
|
+
* @type {MapParsersFn<AsyncParseFn>}
|
|
304
312
|
*/
|
|
305
313
|
const asyncParseFn = (languageForExtension, languageForModuleSpecifier) =>
|
|
306
314
|
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
|
-
export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string,
|
|
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>;
|
|
1
|
+
export function compartmentMapForNodeModules(readPowers: ReadFn | ReadPowers | MaybeReadPowers, packageLocation: string, conditionsOption: Set<string>, packageDescriptor: object, moduleSpecifier: string, options?: CompartmentMapForNodeModulesOptions | 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":"AAs2BO,yDARI,MAAM,GAAG,UAAU,GAAG,eAAe,mBACrC,MAAM,oBACN,GAAG,CAAC,MAAM,CAAC,qBACX,MAAM,mBACN,MAAM,8DAEJ,OAAO,CAAC,wBAAwB,CAAC,CA+D7C;AAQM,2CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,gDAEJ,OAAO,CAAC,wBAAwB,CAAC,CA6B7C;;;;;;;oBA/5BY,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"}
|