@endo/compartment-mapper 1.5.0 → 1.6.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.
- package/LICENSE +1 -1
- package/README.md +278 -111
- package/SECURITY.md +2 -2
- 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 +15 -11
- 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.d.ts +5 -5
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +1 -1
- package/src/archive.d.ts +5 -5
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +3 -1
- package/src/bundle-cjs.d.ts +12 -2
- 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 +667 -0
- package/src/bundle-mjs.d.ts +13 -3
- 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 +392 -126
- package/src/capture-lite.d.ts +1 -1
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +4 -2
- package/src/compartment-map.d.ts +1 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/import-archive-lite.d.ts +2 -2
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +3 -1
- package/src/import-archive.d.ts +3 -3
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +3 -1
- package/src/import-hook.d.ts +3 -16
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +214 -116
- package/src/import-lite.d.ts +1 -1
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +7 -3
- package/src/import.d.ts.map +1 -1
- package/src/import.js +3 -1
- package/src/infer-exports.d.ts +5 -7
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +23 -8
- package/src/link.d.ts.map +1 -1
- package/src/link.js +4 -1
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +51 -5
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +3 -1
- package/src/node-modules.d.ts +4 -47
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +267 -148
- package/src/node-powers.d.ts +1 -1
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +3 -1
- package/src/parse-archive-cjs.d.ts +5 -1
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +11 -4
- package/src/parse-archive-mjs.d.ts +5 -1
- package/src/parse-archive-mjs.d.ts.map +1 -1
- package/src/parse-archive-mjs.js +3 -1
- package/src/parse-bytes.d.ts +5 -1
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +3 -1
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +5 -11
- package/src/parse-cjs.d.ts +5 -1
- package/src/parse-cjs.d.ts.map +1 -1
- package/src/parse-cjs.js +4 -2
- package/src/parse-json.d.ts +5 -2
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-mjs.d.ts +5 -1
- package/src/parse-mjs.d.ts.map +1 -1
- package/src/parse-mjs.js +2 -2
- package/src/parse-pre-cjs.d.ts +5 -1
- package/src/parse-pre-cjs.d.ts.map +1 -1
- package/src/parse-pre-cjs.js +3 -1
- package/src/parse-pre-mjs.d.ts +5 -1
- package/src/parse-pre-mjs.d.ts.map +1 -1
- package/src/parse-pre-mjs.js +3 -1
- package/src/parse-text.d.ts +5 -1
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +3 -1
- package/src/policy-format.d.ts +2 -1
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +5 -2
- package/src/policy.d.ts +2 -2
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +10 -11
- package/src/powers.d.ts +1 -1
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +3 -1
- package/src/search.d.ts +7 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +32 -13
- package/src/types/compartment-map-schema.d.ts +8 -1
- package/src/types/compartment-map-schema.d.ts.map +1 -1
- package/src/types/compartment-map-schema.ts +8 -1
- package/src/types/external.d.ts +127 -17
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +142 -17
- package/src/types/internal.d.ts +116 -29
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +144 -31
- 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 +7 -5
- package/src/types/node-powers.d.ts.map +1 -1
- package/src/types/node-powers.ts +7 -5
- package/src/types/policy-schema.d.ts +3 -1
- package/src/types/policy-schema.d.ts.map +1 -1
- package/src/types/policy-schema.ts +3 -1
- package/src/types/policy.d.ts +3 -1
- package/src/types/policy.d.ts.map +1 -1
- package/src/types/policy.ts +3 -1
- package/src/types/powers.d.ts +5 -3
- package/src/types/powers.d.ts.map +1 -1
- package/src/types/powers.ts +5 -3
- package/src/types/typescript.d.ts +3 -1
- package/src/types/typescript.d.ts.map +1 -1
- package/src/types/typescript.ts +3 -1
- package/src/url.d.ts.map +1 -1
- package/src/url.js +3 -1
package/src/types/internal.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Internal types of the compartment mapper that need not be visible to
|
|
3
3
|
* consumers.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
4
6
|
*/
|
|
5
|
-
import type { ImportHook, ImportNowHook } from 'ses';
|
|
7
|
+
import type { ImportHook, ImportNowHook, StaticModuleType } from 'ses';
|
|
6
8
|
import type { CompartmentDescriptor, Language, LanguageForExtension, LanguageForModuleSpecifier, ModuleDescriptor } from './compartment-map-schema.js';
|
|
7
|
-
import type {
|
|
9
|
+
import type { MaybeReadFn, MaybeReadNowFn, ReadFn, ReadPowers } from './powers.js';
|
|
8
10
|
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
9
|
-
import type { AsyncParseFn, CompartmentSources, ExecuteOptions,
|
|
11
|
+
import type { ArchiveOnlyOption, AsyncParseFn, CompartmentSources, ComputeSha512Option, ExecuteOptions, ExitModuleImportHookOption, ExitModuleImportNowHookOption, LogOptions, ModuleTransforms, ParseFn, ParserForLanguage, SearchSuffixesOption, SourceMapHook, SourceMapHookOption, Sources, SyncModuleTransforms } from './external.js';
|
|
10
12
|
export type LinkOptions = {
|
|
11
13
|
resolve?: ResolveHook;
|
|
12
14
|
makeImportHook: ImportHookMaker;
|
|
@@ -14,9 +16,8 @@ export type LinkOptions = {
|
|
|
14
16
|
parserForLanguage?: ParserForLanguage;
|
|
15
17
|
moduleTransforms?: ModuleTransforms;
|
|
16
18
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
17
|
-
archiveOnly?: boolean;
|
|
18
19
|
__native__?: boolean;
|
|
19
|
-
} & ExecuteOptions;
|
|
20
|
+
} & ArchiveOnlyOption & ExecuteOptions;
|
|
20
21
|
export type LinkResult = {
|
|
21
22
|
compartment: Compartment;
|
|
22
23
|
compartments: Record<string, Compartment>;
|
|
@@ -25,12 +26,20 @@ export type LinkResult = {
|
|
|
25
26
|
};
|
|
26
27
|
export type ResolveHook = (importSpecifier: string, referrerSpecifier: string) => string;
|
|
27
28
|
export type ShouldDeferError = (language: Language | undefined) => boolean;
|
|
28
|
-
export type
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
export type MakeImportHookMakersOptions = {
|
|
30
|
+
entryCompartmentName: string;
|
|
31
|
+
entryModuleSpecifier: string;
|
|
32
|
+
/**
|
|
33
|
+
* For depositing captured sources.
|
|
34
|
+
*/
|
|
35
|
+
sources?: Sources;
|
|
36
|
+
/**
|
|
37
|
+
* For depositing captured compartment descriptors.
|
|
38
|
+
*/
|
|
39
|
+
compartmentDescriptors?: Record<string, CompartmentDescriptor>;
|
|
40
|
+
} & ComputeSha512Option & SearchSuffixesOption & ArchiveOnlyOption & SourceMapHookOption;
|
|
41
|
+
export type MakeImportHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportHookOption;
|
|
42
|
+
export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportNowHookOption;
|
|
34
43
|
export type ImportHookMaker = (params: {
|
|
35
44
|
packageLocation: string;
|
|
36
45
|
packageName: string;
|
|
@@ -44,8 +53,8 @@ export type ImportNowHookMaker = (params: {
|
|
|
44
53
|
packageName: string;
|
|
45
54
|
parse: ParseFn | AsyncParseFn;
|
|
46
55
|
compartments: Record<string, Compartment>;
|
|
56
|
+
shouldDeferError: ShouldDeferError;
|
|
47
57
|
attenuators?: never;
|
|
48
|
-
shouldDeferError?: never;
|
|
49
58
|
}) => ImportNowHook;
|
|
50
59
|
/**
|
|
51
60
|
* The value returned by `makeMapParsers()`
|
|
@@ -72,15 +81,16 @@ export type ChooseModuleDescriptorParams = {
|
|
|
72
81
|
/** All compartments */
|
|
73
82
|
compartments: Record<string, Compartment>;
|
|
74
83
|
packageSources: CompartmentSources;
|
|
75
|
-
/** Function to compute SHA-512 hash */
|
|
76
|
-
computeSha512?: HashFn;
|
|
77
84
|
readPowers: ReadPowers | ReadFn;
|
|
78
|
-
sourceMapHook?: SourceMapHook;
|
|
79
85
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
86
|
+
* Whether to embed a sourceURL in applicable compiled sources.
|
|
87
|
+
* Should be false for archives and bundles, but true for runtime.
|
|
82
88
|
*/
|
|
83
|
-
|
|
89
|
+
sourceMapHook?: SourceMapHook;
|
|
90
|
+
strictlyRequiredForCompartment: StrictlyRequiredFn;
|
|
91
|
+
} & ComputeSha512Option & ArchiveOnlyOption;
|
|
92
|
+
type ShouldDeferErrorOption = {
|
|
93
|
+
shouldDeferError: ShouldDeferError;
|
|
84
94
|
};
|
|
85
95
|
type SyncChooseModuleDescriptorOperators = {
|
|
86
96
|
/**
|
|
@@ -93,8 +103,6 @@ type SyncChooseModuleDescriptorOperators = {
|
|
|
93
103
|
* a `ParseResult`
|
|
94
104
|
*/
|
|
95
105
|
parse: ParseFn;
|
|
96
|
-
/** Should be omitted */
|
|
97
|
-
shouldDeferError?: never;
|
|
98
106
|
};
|
|
99
107
|
/**
|
|
100
108
|
* Operators for `chooseModuleDescriptor` representing asynchronous operation.
|
|
@@ -110,16 +118,11 @@ export type AsyncChooseModuleDescriptorOperators = {
|
|
|
110
118
|
* a `ParseResult`
|
|
111
119
|
*/
|
|
112
120
|
parse: AsyncParseFn | ParseFn;
|
|
113
|
-
/**
|
|
114
|
-
* A function that returns `true` if the language returned by `parse` should
|
|
115
|
-
* defer errors.
|
|
116
|
-
*/
|
|
117
|
-
shouldDeferError: (language: Language) => boolean;
|
|
118
121
|
};
|
|
119
122
|
/**
|
|
120
123
|
* Either synchronous or asynchronous operators for `chooseModuleDescriptor`.
|
|
121
124
|
*/
|
|
122
|
-
export type ChooseModuleDescriptorOperators = AsyncChooseModuleDescriptorOperators | SyncChooseModuleDescriptorOperators;
|
|
125
|
+
export type ChooseModuleDescriptorOperators = ShouldDeferErrorOption & (AsyncChooseModuleDescriptorOperators | SyncChooseModuleDescriptorOperators);
|
|
123
126
|
/**
|
|
124
127
|
* The agglomeration of things that the `chooseModuleDescriptor` generator can
|
|
125
128
|
* yield.
|
|
@@ -137,8 +140,6 @@ export type FindRedirectParams = {
|
|
|
137
140
|
compartmentDescriptors: Record<string, CompartmentDescriptor>;
|
|
138
141
|
compartments: Record<string, Compartment>;
|
|
139
142
|
absoluteModuleSpecifier: string;
|
|
140
|
-
/** Location of the compartment descriptor's package. */
|
|
141
|
-
packageLocation: string;
|
|
142
143
|
};
|
|
143
144
|
/**
|
|
144
145
|
* Options for `makeMapParsers()`
|
|
@@ -158,5 +159,91 @@ export type MakeMapParsersOptions = {
|
|
|
158
159
|
*/
|
|
159
160
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
160
161
|
};
|
|
162
|
+
/**
|
|
163
|
+
* Options for `search()`
|
|
164
|
+
*/
|
|
165
|
+
export type SearchOptions = LogOptions;
|
|
166
|
+
/**
|
|
167
|
+
* Object fulfilled from `search()`
|
|
168
|
+
*/
|
|
169
|
+
export interface SearchResult {
|
|
170
|
+
packageLocation: string;
|
|
171
|
+
packageDescriptorLocation: string;
|
|
172
|
+
packageDescriptorText: string;
|
|
173
|
+
moduleSpecifier: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Object fulfilled from `searchDescriptor()`
|
|
177
|
+
*
|
|
178
|
+
* @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc.
|
|
179
|
+
*/
|
|
180
|
+
export interface SearchDescriptorResult<T> {
|
|
181
|
+
data: T;
|
|
182
|
+
directory: string;
|
|
183
|
+
location: string;
|
|
184
|
+
packageDescriptorLocation: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Options for `searchDescriptor()`
|
|
188
|
+
*/
|
|
189
|
+
export type SearchDescriptorOptions = LogOptions;
|
|
190
|
+
/**
|
|
191
|
+
* A power to read a package descriptor
|
|
192
|
+
* @template T Format of package descriptor
|
|
193
|
+
*/
|
|
194
|
+
export type ReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T>;
|
|
195
|
+
/**
|
|
196
|
+
* A power to _maybe_ read a package descriptor
|
|
197
|
+
* @template T Format of package descriptor
|
|
198
|
+
*/
|
|
199
|
+
export type MaybeReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T | undefined>;
|
|
200
|
+
/**
|
|
201
|
+
* The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk
|
|
202
|
+
*/
|
|
203
|
+
export interface PackageDescriptor {
|
|
204
|
+
/**
|
|
205
|
+
* TODO: In reality, this is optional, but `graphPackage` does not consider it to be. This will need to be fixed once support for "anonymous" packages lands; see https://github.com/endojs/endo/pull/2664
|
|
206
|
+
*/
|
|
207
|
+
name: string;
|
|
208
|
+
version?: string;
|
|
209
|
+
/**
|
|
210
|
+
* TODO: Update with proper type when this field is handled.
|
|
211
|
+
*/
|
|
212
|
+
exports?: unknown;
|
|
213
|
+
type?: 'module' | 'commonjs';
|
|
214
|
+
dependencies?: Record<string, string>;
|
|
215
|
+
devDependencies?: Record<string, string>;
|
|
216
|
+
peerDependencies?: Record<string, string>;
|
|
217
|
+
optionalDependencies?: Record<string, string>;
|
|
218
|
+
bundleDependencies?: string[];
|
|
219
|
+
peerDependenciesMeta?: Record<string, {
|
|
220
|
+
optional?: boolean;
|
|
221
|
+
[k: string]: unknown;
|
|
222
|
+
}>;
|
|
223
|
+
module?: string;
|
|
224
|
+
browser?: Record<string, string> | string;
|
|
225
|
+
main?: string;
|
|
226
|
+
[k: string]: unknown;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Function returning a set of module names (scoped to the compartment) whose
|
|
230
|
+
* parser is not using heuristics to determine imports.
|
|
231
|
+
*/
|
|
232
|
+
export type StrictlyRequiredFn = (compartmentName: string) => Set<string>;
|
|
233
|
+
/**
|
|
234
|
+
* Function which decides whether to throw an error immediately upon failing to
|
|
235
|
+
* load a module or defer to execution time.
|
|
236
|
+
*
|
|
237
|
+
* @returns A phony `StaticModuleType` which throws when executed
|
|
238
|
+
*/
|
|
239
|
+
export type DeferErrorFn = (
|
|
240
|
+
/**
|
|
241
|
+
* The module specifier that failed to load
|
|
242
|
+
*/
|
|
243
|
+
specifier: string,
|
|
244
|
+
/**
|
|
245
|
+
* The error that was thrown
|
|
246
|
+
*/
|
|
247
|
+
error: Error) => StaticModuleType;
|
|
161
248
|
export {};
|
|
162
249
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AACvE,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,MAAM,EACN,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,6BAA6B,EAC7B,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,OAAO,EACP,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,cAAc,EAAE,eAAe,CAAC;IAChC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,iB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C;IAE1C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,eAAe,EAAE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG;AACzB;;GAEG;AACH,SAAS,EAAE,MAAM;AACjB;;GAEG;AACH,KAAK,EAAE,KAAK,KACT,gBAAgB,CAAC"}
|
package/src/types/internal.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Internal types of the compartment mapper that need not be visible to
|
|
3
3
|
* consumers.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
/* eslint-disable no-use-before-define */
|
|
7
9
|
|
|
8
|
-
import type { ImportHook, ImportNowHook } from 'ses';
|
|
10
|
+
import type { ImportHook, ImportNowHook, StaticModuleType } from 'ses';
|
|
9
11
|
import type {
|
|
10
12
|
CompartmentDescriptor,
|
|
11
13
|
Language,
|
|
@@ -14,7 +16,6 @@ import type {
|
|
|
14
16
|
ModuleDescriptor,
|
|
15
17
|
} from './compartment-map-schema.js';
|
|
16
18
|
import type {
|
|
17
|
-
HashFn,
|
|
18
19
|
MaybeReadFn,
|
|
19
20
|
MaybeReadNowFn,
|
|
20
21
|
ReadFn,
|
|
@@ -22,10 +23,14 @@ import type {
|
|
|
22
23
|
} from './powers.js';
|
|
23
24
|
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
24
25
|
import type {
|
|
26
|
+
ArchiveOnlyOption,
|
|
25
27
|
AsyncParseFn,
|
|
26
28
|
CompartmentSources,
|
|
29
|
+
ComputeSha512Option,
|
|
27
30
|
ExecuteOptions,
|
|
28
|
-
|
|
31
|
+
ExitModuleImportHookOption,
|
|
32
|
+
ExitModuleImportNowHookOption,
|
|
33
|
+
LogOptions,
|
|
29
34
|
ModuleTransforms,
|
|
30
35
|
ParseFn,
|
|
31
36
|
ParserForLanguage,
|
|
@@ -43,9 +48,9 @@ export type LinkOptions = {
|
|
|
43
48
|
parserForLanguage?: ParserForLanguage;
|
|
44
49
|
moduleTransforms?: ModuleTransforms;
|
|
45
50
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
46
|
-
archiveOnly?: boolean;
|
|
47
51
|
__native__?: boolean;
|
|
48
|
-
} &
|
|
52
|
+
} & ArchiveOnlyOption &
|
|
53
|
+
ExecuteOptions;
|
|
49
54
|
|
|
50
55
|
export type LinkResult = {
|
|
51
56
|
compartment: Compartment;
|
|
@@ -61,15 +66,27 @@ export type ResolveHook = (
|
|
|
61
66
|
|
|
62
67
|
export type ShouldDeferError = (language: Language | undefined) => boolean;
|
|
63
68
|
|
|
64
|
-
export type
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
export type MakeImportHookMakersOptions = {
|
|
70
|
+
entryCompartmentName: string;
|
|
71
|
+
entryModuleSpecifier: string;
|
|
72
|
+
/**
|
|
73
|
+
* For depositing captured sources.
|
|
74
|
+
*/
|
|
75
|
+
sources?: Sources;
|
|
76
|
+
/**
|
|
77
|
+
* For depositing captured compartment descriptors.
|
|
78
|
+
*/
|
|
79
|
+
compartmentDescriptors?: Record<string, CompartmentDescriptor>;
|
|
80
|
+
} & ComputeSha512Option &
|
|
70
81
|
SearchSuffixesOption &
|
|
82
|
+
ArchiveOnlyOption &
|
|
71
83
|
SourceMapHookOption;
|
|
72
84
|
|
|
85
|
+
export type MakeImportHookMakerOptions = MakeImportHookMakersOptions &
|
|
86
|
+
ExitModuleImportHookOption;
|
|
87
|
+
export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions &
|
|
88
|
+
ExitModuleImportNowHookOption;
|
|
89
|
+
|
|
73
90
|
export type ImportHookMaker = (params: {
|
|
74
91
|
packageLocation: string;
|
|
75
92
|
packageName: string;
|
|
@@ -84,11 +101,11 @@ export type ImportNowHookMaker = (params: {
|
|
|
84
101
|
packageName: string;
|
|
85
102
|
parse: ParseFn | AsyncParseFn;
|
|
86
103
|
compartments: Record<string, Compartment>;
|
|
104
|
+
shouldDeferError: ShouldDeferError;
|
|
87
105
|
// Unlike analogous prameters of ImportHookMaker, the Compartment Mapper
|
|
88
106
|
// ignores these two parameters, so they are expressly disallowed to avoid
|
|
89
107
|
// confusion about whether they would be respected.
|
|
90
108
|
attenuators?: never;
|
|
91
|
-
shouldDeferError?: never;
|
|
92
109
|
}) => ImportNowHook;
|
|
93
110
|
|
|
94
111
|
/**
|
|
@@ -118,15 +135,19 @@ export type ChooseModuleDescriptorParams = {
|
|
|
118
135
|
/** All compartments */
|
|
119
136
|
compartments: Record<string, Compartment>;
|
|
120
137
|
packageSources: CompartmentSources;
|
|
121
|
-
/** Function to compute SHA-512 hash */
|
|
122
|
-
computeSha512?: HashFn;
|
|
123
138
|
readPowers: ReadPowers | ReadFn;
|
|
124
|
-
sourceMapHook?: SourceMapHook;
|
|
125
139
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
140
|
+
* Whether to embed a sourceURL in applicable compiled sources.
|
|
141
|
+
* Should be false for archives and bundles, but true for runtime.
|
|
128
142
|
*/
|
|
129
|
-
|
|
143
|
+
sourceMapHook?: SourceMapHook;
|
|
144
|
+
|
|
145
|
+
strictlyRequiredForCompartment: StrictlyRequiredFn;
|
|
146
|
+
} & ComputeSha512Option &
|
|
147
|
+
ArchiveOnlyOption;
|
|
148
|
+
|
|
149
|
+
type ShouldDeferErrorOption = {
|
|
150
|
+
shouldDeferError: ShouldDeferError;
|
|
130
151
|
};
|
|
131
152
|
|
|
132
153
|
type SyncChooseModuleDescriptorOperators = {
|
|
@@ -140,8 +161,6 @@ type SyncChooseModuleDescriptorOperators = {
|
|
|
140
161
|
* a `ParseResult`
|
|
141
162
|
*/
|
|
142
163
|
parse: ParseFn;
|
|
143
|
-
/** Should be omitted */
|
|
144
|
-
shouldDeferError?: never;
|
|
145
164
|
};
|
|
146
165
|
|
|
147
166
|
/**
|
|
@@ -158,19 +177,13 @@ export type AsyncChooseModuleDescriptorOperators = {
|
|
|
158
177
|
* a `ParseResult`
|
|
159
178
|
*/
|
|
160
179
|
parse: AsyncParseFn | ParseFn;
|
|
161
|
-
/**
|
|
162
|
-
* A function that returns `true` if the language returned by `parse` should
|
|
163
|
-
* defer errors.
|
|
164
|
-
*/
|
|
165
|
-
shouldDeferError: (language: Language) => boolean;
|
|
166
180
|
};
|
|
167
181
|
|
|
168
182
|
/**
|
|
169
183
|
* Either synchronous or asynchronous operators for `chooseModuleDescriptor`.
|
|
170
184
|
*/
|
|
171
|
-
export type ChooseModuleDescriptorOperators =
|
|
172
|
-
|
|
|
173
|
-
| SyncChooseModuleDescriptorOperators;
|
|
185
|
+
export type ChooseModuleDescriptorOperators = ShouldDeferErrorOption &
|
|
186
|
+
(AsyncChooseModuleDescriptorOperators | SyncChooseModuleDescriptorOperators);
|
|
174
187
|
|
|
175
188
|
/**
|
|
176
189
|
* The agglomeration of things that the `chooseModuleDescriptor` generator can
|
|
@@ -193,8 +206,6 @@ export type FindRedirectParams = {
|
|
|
193
206
|
compartments: Record<string, Compartment>;
|
|
194
207
|
/* A module specifier which is an absolute path. NOT a `file://` URL. */
|
|
195
208
|
absoluteModuleSpecifier: string;
|
|
196
|
-
/** Location of the compartment descriptor's package. */
|
|
197
|
-
packageLocation: string;
|
|
198
209
|
};
|
|
199
210
|
|
|
200
211
|
/**
|
|
@@ -215,3 +226,105 @@ export type MakeMapParsersOptions = {
|
|
|
215
226
|
*/
|
|
216
227
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
217
228
|
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Options for `search()`
|
|
232
|
+
*/
|
|
233
|
+
export type SearchOptions = LogOptions;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Object fulfilled from `search()`
|
|
237
|
+
*/
|
|
238
|
+
export interface SearchResult {
|
|
239
|
+
packageLocation: string;
|
|
240
|
+
packageDescriptorLocation: string;
|
|
241
|
+
packageDescriptorText: string;
|
|
242
|
+
moduleSpecifier: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Object fulfilled from `searchDescriptor()`
|
|
247
|
+
*
|
|
248
|
+
* @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc.
|
|
249
|
+
*/
|
|
250
|
+
export interface SearchDescriptorResult<T> {
|
|
251
|
+
data: T;
|
|
252
|
+
directory: string;
|
|
253
|
+
location: string;
|
|
254
|
+
packageDescriptorLocation: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Options for `searchDescriptor()`
|
|
259
|
+
*/
|
|
260
|
+
export type SearchDescriptorOptions = LogOptions;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A power to read a package descriptor
|
|
264
|
+
* @template T Format of package descriptor
|
|
265
|
+
*/
|
|
266
|
+
export type ReadDescriptorFn<T = PackageDescriptor> = (
|
|
267
|
+
location: string,
|
|
268
|
+
) => Promise<T>;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A power to _maybe_ read a package descriptor
|
|
272
|
+
* @template T Format of package descriptor
|
|
273
|
+
*/
|
|
274
|
+
export type MaybeReadDescriptorFn<T = PackageDescriptor> = (
|
|
275
|
+
location: string,
|
|
276
|
+
) => Promise<T | undefined>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk
|
|
280
|
+
*/
|
|
281
|
+
export interface PackageDescriptor {
|
|
282
|
+
/**
|
|
283
|
+
* TODO: In reality, this is optional, but `graphPackage` does not consider it to be. This will need to be fixed once support for "anonymous" packages lands; see https://github.com/endojs/endo/pull/2664
|
|
284
|
+
*/
|
|
285
|
+
name: string;
|
|
286
|
+
version?: string;
|
|
287
|
+
/**
|
|
288
|
+
* TODO: Update with proper type when this field is handled.
|
|
289
|
+
*/
|
|
290
|
+
exports?: unknown;
|
|
291
|
+
type?: 'module' | 'commonjs';
|
|
292
|
+
dependencies?: Record<string, string>;
|
|
293
|
+
devDependencies?: Record<string, string>;
|
|
294
|
+
peerDependencies?: Record<string, string>;
|
|
295
|
+
optionalDependencies?: Record<string, string>;
|
|
296
|
+
bundleDependencies?: string[];
|
|
297
|
+
peerDependenciesMeta?: Record<
|
|
298
|
+
string,
|
|
299
|
+
{ optional?: boolean; [k: string]: unknown }
|
|
300
|
+
>;
|
|
301
|
+
module?: string;
|
|
302
|
+
browser?: Record<string, string> | string;
|
|
303
|
+
|
|
304
|
+
main?: string;
|
|
305
|
+
|
|
306
|
+
[k: string]: unknown;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Function returning a set of module names (scoped to the compartment) whose
|
|
311
|
+
* parser is not using heuristics to determine imports.
|
|
312
|
+
*/
|
|
313
|
+
export type StrictlyRequiredFn = (compartmentName: string) => Set<string>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Function which decides whether to throw an error immediately upon failing to
|
|
317
|
+
* load a module or defer to execution time.
|
|
318
|
+
*
|
|
319
|
+
* @returns A phony `StaticModuleType` which throws when executed
|
|
320
|
+
*/
|
|
321
|
+
export type DeferErrorFn = (
|
|
322
|
+
/**
|
|
323
|
+
* The module specifier that failed to load
|
|
324
|
+
*/
|
|
325
|
+
specifier: string,
|
|
326
|
+
/**
|
|
327
|
+
* The error that was thrown
|
|
328
|
+
*/
|
|
329
|
+
error: Error,
|
|
330
|
+
) => StaticModuleType;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Language, LanguageForExtension } from './compartment-map-schema.js';
|
|
2
|
+
import type { LogOptions } from './external.js';
|
|
3
|
+
import type { PackageDescriptor } from './internal.js';
|
|
4
|
+
export type CommonDependencyDescriptors = Record<string, {
|
|
5
|
+
spec: string;
|
|
6
|
+
alias: string;
|
|
7
|
+
}>;
|
|
8
|
+
export type GraphPackageOptions = {
|
|
9
|
+
preferredPackageLogicalPathMap?: Map<string, string[]>;
|
|
10
|
+
logicalPath?: string[];
|
|
11
|
+
commonDependencyDescriptors?: CommonDependencyDescriptors;
|
|
12
|
+
} & LogOptions;
|
|
13
|
+
export type GraphPackagesOptions = LogOptions;
|
|
14
|
+
export type GatherDependencyOptions = {
|
|
15
|
+
childLogicalPath?: string[];
|
|
16
|
+
/**
|
|
17
|
+
* If `true` the dependency is optional
|
|
18
|
+
*/
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Dependencies added to _all_ packages
|
|
22
|
+
*/
|
|
23
|
+
commonDependencyDescriptors?: CommonDependencyDescriptors;
|
|
24
|
+
} & LogOptions;
|
|
25
|
+
export interface Node {
|
|
26
|
+
/**
|
|
27
|
+
* Informative compartment label based on the package name and version (if available)
|
|
28
|
+
*/
|
|
29
|
+
label: string;
|
|
30
|
+
/**
|
|
31
|
+
* Package name
|
|
32
|
+
*/
|
|
33
|
+
name: string;
|
|
34
|
+
path: Array<string>;
|
|
35
|
+
logicalPath: Array<string>;
|
|
36
|
+
/**
|
|
37
|
+
* `true` if the package's {@link PackageDescriptor} has an `exports` field
|
|
38
|
+
*/
|
|
39
|
+
explicitExports: boolean;
|
|
40
|
+
internalAliases: Record<string, string>;
|
|
41
|
+
externalAliases: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* The name of the original package's parent directory, for reconstructing
|
|
44
|
+
* a sourceURL that is likely to converge with the original location in an IDE.
|
|
45
|
+
*/
|
|
46
|
+
sourceDirname: string;
|
|
47
|
+
/**
|
|
48
|
+
* An object whose keys are the thing being imported, and the values are the
|
|
49
|
+
* names of the matching module (relative to the containing package's root;
|
|
50
|
+
* i.e. the URL that was used as the key of graph).
|
|
51
|
+
*
|
|
52
|
+
* The values are the keys of other {@link Node Nodes} in the {@link Graph}.
|
|
53
|
+
*/
|
|
54
|
+
dependencyLocations: Record<string, string>;
|
|
55
|
+
parsers: LanguageForExtension;
|
|
56
|
+
types: Record<string, Language>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The graph is an intermediate object model that the functions of this module
|
|
60
|
+
* build by exploring the `node_modules` tree dropped by tools like npm and
|
|
61
|
+
* consumed by tools like Node.js.
|
|
62
|
+
* This gets translated finally into a compartment map.
|
|
63
|
+
*/
|
|
64
|
+
export type Graph = Record<string, Node>;
|
|
65
|
+
export interface LanguageOptions {
|
|
66
|
+
commonjsLanguageForExtension: LanguageForExtension;
|
|
67
|
+
moduleLanguageForExtension: LanguageForExtension;
|
|
68
|
+
workspaceCommonjsLanguageForExtension: LanguageForExtension;
|
|
69
|
+
workspaceModuleLanguageForExtension: LanguageForExtension;
|
|
70
|
+
languages: Set<string>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Object result of `findPackage()`
|
|
74
|
+
*/
|
|
75
|
+
export interface PackageDetails {
|
|
76
|
+
packageLocation: string;
|
|
77
|
+
packageDescriptor: PackageDescriptor;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=node-modules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-modules.d.ts","sourceRoot":"","sources":["node-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAChC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,8BAA8B,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EA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,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,iBAAiB,CAAC;CACtC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Language,
|
|
3
|
+
LanguageForExtension,
|
|
4
|
+
} from './compartment-map-schema.js';
|
|
5
|
+
import type { LogOptions } from './external.js';
|
|
6
|
+
import type { PackageDescriptor } from './internal.js';
|
|
7
|
+
|
|
8
|
+
export type CommonDependencyDescriptors = Record<
|
|
9
|
+
string,
|
|
10
|
+
{ spec: string; alias: string }
|
|
11
|
+
>;
|
|
12
|
+
|
|
13
|
+
export type GraphPackageOptions = {
|
|
14
|
+
preferredPackageLogicalPathMap?: Map<string, string[]>;
|
|
15
|
+
logicalPath?: string[];
|
|
16
|
+
commonDependencyDescriptors?: CommonDependencyDescriptors;
|
|
17
|
+
} & LogOptions;
|
|
18
|
+
|
|
19
|
+
export type GraphPackagesOptions = LogOptions;
|
|
20
|
+
|
|
21
|
+
export type GatherDependencyOptions = {
|
|
22
|
+
childLogicalPath?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* If `true` the dependency is optional
|
|
25
|
+
*/
|
|
26
|
+
optional?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Dependencies added to _all_ packages
|
|
29
|
+
*/
|
|
30
|
+
commonDependencyDescriptors?: CommonDependencyDescriptors;
|
|
31
|
+
} & LogOptions;
|
|
32
|
+
|
|
33
|
+
export interface Node {
|
|
34
|
+
/**
|
|
35
|
+
* Informative compartment label based on the package name and version (if available)
|
|
36
|
+
*/
|
|
37
|
+
label: string;
|
|
38
|
+
/**
|
|
39
|
+
* Package name
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
42
|
+
path: Array<string>;
|
|
43
|
+
logicalPath: Array<string>;
|
|
44
|
+
/**
|
|
45
|
+
* `true` if the package's {@link PackageDescriptor} has an `exports` field
|
|
46
|
+
*/
|
|
47
|
+
explicitExports: boolean;
|
|
48
|
+
internalAliases: Record<string, string>;
|
|
49
|
+
externalAliases: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* The name of the original package's parent directory, for reconstructing
|
|
52
|
+
* a sourceURL that is likely to converge with the original location in an IDE.
|
|
53
|
+
*/
|
|
54
|
+
sourceDirname: string;
|
|
55
|
+
/**
|
|
56
|
+
* An object whose keys are the thing being imported, and the values are the
|
|
57
|
+
* names of the matching module (relative to the containing package's root;
|
|
58
|
+
* i.e. the URL that was used as the key of graph).
|
|
59
|
+
*
|
|
60
|
+
* The values are the keys of other {@link Node Nodes} in the {@link Graph}.
|
|
61
|
+
*/
|
|
62
|
+
dependencyLocations: Record<string, string>;
|
|
63
|
+
parsers: LanguageForExtension;
|
|
64
|
+
types: Record<string, Language>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The graph is an intermediate object model that the functions of this module
|
|
69
|
+
* build by exploring the `node_modules` tree dropped by tools like npm and
|
|
70
|
+
* consumed by tools like Node.js.
|
|
71
|
+
* This gets translated finally into a compartment map.
|
|
72
|
+
*/
|
|
73
|
+
export type Graph = Record<string, Node>;
|
|
74
|
+
|
|
75
|
+
export interface LanguageOptions {
|
|
76
|
+
commonjsLanguageForExtension: LanguageForExtension;
|
|
77
|
+
moduleLanguageForExtension: LanguageForExtension;
|
|
78
|
+
workspaceCommonjsLanguageForExtension: LanguageForExtension;
|
|
79
|
+
workspaceModuleLanguageForExtension: LanguageForExtension;
|
|
80
|
+
languages: Set<string>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Object result of `findPackage()`
|
|
85
|
+
*/
|
|
86
|
+
export interface PackageDetails {
|
|
87
|
+
packageLocation: string;
|
|
88
|
+
packageDescriptor: PackageDescriptor;
|
|
89
|
+
}
|