@endo/compartment-mapper 1.4.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 +292 -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/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/index.d.ts +1 -1
- package/index.js +4 -1
- package/package.json +14 -5
- 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 +2 -4
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +16 -192
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +8 -0
- 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 +399 -127
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +10 -188
- package/src/digest.d.ts +5 -0
- package/src/digest.d.ts.map +1 -0
- package/src/digest.js +235 -0
- 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.map +1 -1
- package/src/import-archive-lite.js +4 -0
- 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 +7 -2
- package/src/import.d.ts.map +1 -1
- package/src/import.js +2 -0
- package/src/link.d.ts.map +1 -1
- package/src/link.js +2 -0
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +4 -1
- package/src/node-modules.d.ts +4 -47
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +157 -131
- 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 +159 -12
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +180 -12
- package/src/types/internal.d.ts +86 -13
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +107 -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/types/external.ts
CHANGED
|
@@ -11,8 +11,8 @@ import type {
|
|
|
11
11
|
Transform,
|
|
12
12
|
} from 'ses';
|
|
13
13
|
import type {
|
|
14
|
-
CompartmentMapDescriptor,
|
|
15
14
|
CompartmentDescriptor,
|
|
15
|
+
CompartmentMapDescriptor,
|
|
16
16
|
Language,
|
|
17
17
|
LanguageForExtension,
|
|
18
18
|
} from './compartment-map-schema.js';
|
|
@@ -29,6 +29,7 @@ export type ExecuteOptions = Partial<{
|
|
|
29
29
|
__shimTransforms__: Array<Transform>;
|
|
30
30
|
attenuations: Record<string, object>;
|
|
31
31
|
Compartment: typeof Compartment;
|
|
32
|
+
__native__: boolean;
|
|
32
33
|
}> &
|
|
33
34
|
ModulesOption &
|
|
34
35
|
ExitModuleImportHookOption;
|
|
@@ -38,6 +39,7 @@ export type ParseArchiveOptions = Partial<{
|
|
|
38
39
|
computeSha512: HashFn;
|
|
39
40
|
computeSourceLocation: ComputeSourceLocationHook;
|
|
40
41
|
computeSourceMapLocation: ComputeSourceMapLocationHook;
|
|
42
|
+
__native__: boolean;
|
|
41
43
|
}> &
|
|
42
44
|
ModulesOption &
|
|
43
45
|
CompartmentOption &
|
|
@@ -46,8 +48,23 @@ export type ParseArchiveOptions = Partial<{
|
|
|
46
48
|
|
|
47
49
|
export type LoadArchiveOptions = ParseArchiveOptions;
|
|
48
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Options having an optional `log` property.
|
|
53
|
+
*/
|
|
54
|
+
export interface LogOptions {
|
|
55
|
+
/**
|
|
56
|
+
* A logger (for logging)
|
|
57
|
+
*/
|
|
58
|
+
log?: LogFn;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Options for `mapNodeModules()`
|
|
63
|
+
*/
|
|
49
64
|
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy &
|
|
50
|
-
PolicyOption
|
|
65
|
+
PolicyOption &
|
|
66
|
+
LogOptions;
|
|
67
|
+
|
|
51
68
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
52
69
|
/** @deprecated renamed `conditions` to be consistent with Node.js */
|
|
53
70
|
tags: Set<string>;
|
|
@@ -67,6 +84,13 @@ type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
|
67
84
|
* of having the `"development"` condition.
|
|
68
85
|
*/
|
|
69
86
|
dev: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Indicates that the node_modules tree should fail to map if it does not
|
|
89
|
+
* strictly reach every expected package.
|
|
90
|
+
* By default, unreachable packages are simply omitted from the map,
|
|
91
|
+
* which defers some errors to when modules load.
|
|
92
|
+
*/
|
|
93
|
+
strict: boolean;
|
|
70
94
|
/** Dependencies to make reachable from any package */
|
|
71
95
|
commonDependencies: Record<string, string>;
|
|
72
96
|
/** Maps extensions to languages for all packages, like `txt` to `text` */
|
|
@@ -106,7 +130,8 @@ export type CompartmentMapForNodeModulesOptions = Omit<
|
|
|
106
130
|
|
|
107
131
|
export type CaptureLiteOptions = ImportingOptions &
|
|
108
132
|
LinkingOptions &
|
|
109
|
-
PolicyOption
|
|
133
|
+
PolicyOption &
|
|
134
|
+
LogOptions;
|
|
110
135
|
|
|
111
136
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
112
137
|
ModuleTransformsOption &
|
|
@@ -122,25 +147,67 @@ export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
|
122
147
|
export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> &
|
|
123
148
|
ArchiveLiteOptions;
|
|
124
149
|
|
|
150
|
+
export type BundleOptions = ArchiveOptions & {
|
|
151
|
+
/**
|
|
152
|
+
* Format of the bundle for purposes of importing modules from the surrounding
|
|
153
|
+
* environment.
|
|
154
|
+
* The default can be CommonJS or ESM but depends on neither `require` nor `import`
|
|
155
|
+
* for external modules, but errors early if the entrained modules need to import
|
|
156
|
+
* a host module.
|
|
157
|
+
* Specifying `cjs` makes `require` available for modules outside the bundle
|
|
158
|
+
* (exits to the import graph).
|
|
159
|
+
*/
|
|
160
|
+
format?: 'cjs';
|
|
161
|
+
/**
|
|
162
|
+
* Evaluates individual module functors in-place so stack traces represent
|
|
163
|
+
* original source locations better.
|
|
164
|
+
* The resulting script cannot be used on a web page with a no-unsafe-eval
|
|
165
|
+
* Content Security Policy.
|
|
166
|
+
*/
|
|
167
|
+
useEvaluate?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* A prefix for the sourceURL comment in each module format that supports
|
|
170
|
+
* sourceURL comments.
|
|
171
|
+
* Requires `useEvaluate` for effect.
|
|
172
|
+
*/
|
|
173
|
+
sourceUrlPrefix?: string;
|
|
174
|
+
};
|
|
175
|
+
|
|
125
176
|
export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> &
|
|
126
177
|
SyncArchiveLiteOptions;
|
|
127
178
|
|
|
128
179
|
/**
|
|
129
180
|
* Options for `loadLocation()`
|
|
130
181
|
*/
|
|
131
|
-
export type LoadLocationOptions = ArchiveOptions &
|
|
182
|
+
export type LoadLocationOptions = ArchiveOptions &
|
|
183
|
+
SyncArchiveOptions &
|
|
184
|
+
LogOptions;
|
|
132
185
|
|
|
133
186
|
/**
|
|
134
187
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
135
188
|
* `ReadNowPowers`) for dynamic require support
|
|
136
189
|
*/
|
|
137
|
-
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
190
|
+
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
191
|
+
ExecuteOptions &
|
|
192
|
+
LogOptions;
|
|
138
193
|
|
|
139
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Options for `importLocation()` without dynamic require support
|
|
196
|
+
*/
|
|
197
|
+
export type ImportLocationOptions = ArchiveOptions &
|
|
198
|
+
ExecuteOptions &
|
|
199
|
+
LogOptions;
|
|
140
200
|
|
|
141
201
|
// ////////////////////////////////////////////////////////////////////////////////
|
|
142
202
|
// Single Options
|
|
143
203
|
|
|
204
|
+
export type ComputeSha512Option = {
|
|
205
|
+
/**
|
|
206
|
+
* For computing integrity hashes for module descriptors based on captured sources.
|
|
207
|
+
*/
|
|
208
|
+
computeSha512?: HashFn;
|
|
209
|
+
};
|
|
210
|
+
|
|
144
211
|
export type SearchSuffixesOption = {
|
|
145
212
|
/**
|
|
146
213
|
* Suffixes to search if the unmodified specifier is not found. Pass `[]` to
|
|
@@ -162,10 +229,18 @@ export type ModulesOption = {
|
|
|
162
229
|
};
|
|
163
230
|
|
|
164
231
|
export type ExitModuleImportHookOption = {
|
|
232
|
+
/**
|
|
233
|
+
* For obtaining module descriptors for modules that must be provided
|
|
234
|
+
* by the eventual runtime execution environment, asynchronously.
|
|
235
|
+
*/
|
|
165
236
|
importHook?: ExitModuleImportHook;
|
|
166
237
|
};
|
|
167
238
|
|
|
168
239
|
export type ExitModuleImportNowHookOption = {
|
|
240
|
+
/**
|
|
241
|
+
* For obtaining module descriptors for modules that must be provided
|
|
242
|
+
* by the eventual runtime execution environment, synchronusly.
|
|
243
|
+
*/
|
|
169
244
|
importNowHook?: ExitModuleImportNowHook;
|
|
170
245
|
};
|
|
171
246
|
|
|
@@ -185,6 +260,34 @@ export type SyncModuleTransformsOption = {
|
|
|
185
260
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
186
261
|
};
|
|
187
262
|
|
|
263
|
+
export type ArchiveOnlyOption = {
|
|
264
|
+
/**
|
|
265
|
+
* Whether to prepare to create an archive or script bundle for execution
|
|
266
|
+
* elsewhere or elsewhen, as opposed to preparing to execute immediately.
|
|
267
|
+
*
|
|
268
|
+
* This has several practical effects.
|
|
269
|
+
*
|
|
270
|
+
* Archives expect to exit to potentially different host modules than the current
|
|
271
|
+
* host, but cannot instantiate those modules.
|
|
272
|
+
* For example, when preparing a bundle for execution in Node.js from within a
|
|
273
|
+
* web page, exiting to `node:fs` is appropriate but cannot be instantiated.
|
|
274
|
+
* So, the import hook will make a note of the exit and provide a stub module
|
|
275
|
+
* that throws an error if it is imported.
|
|
276
|
+
*
|
|
277
|
+
* Also, importing a module graph off a local medium immediately should
|
|
278
|
+
* inject a fully qualified source location into the module source,
|
|
279
|
+
* but sources loaded for an archive must not capture the original source
|
|
280
|
+
* location, but give the runtime an opportunity to inject a sourceURL.
|
|
281
|
+
*
|
|
282
|
+
* Also, the linker does not apply attenuations to the global environment
|
|
283
|
+
* if it is preparing to write an archive or script bundle.
|
|
284
|
+
*
|
|
285
|
+
* This option does not generally surface to users, but is set by the scenario,
|
|
286
|
+
* off for `importLocation`, on for `makeArchive` and `makeScript`.
|
|
287
|
+
*/
|
|
288
|
+
archiveOnly?: boolean;
|
|
289
|
+
};
|
|
290
|
+
|
|
188
291
|
export type PolicyOption = {
|
|
189
292
|
policy?: any;
|
|
190
293
|
};
|
|
@@ -221,12 +324,52 @@ type LinkingOptions = ParserForLanguageOption &
|
|
|
221
324
|
// ////////////////////////////////////////////////////////////////////////////////
|
|
222
325
|
|
|
223
326
|
/**
|
|
224
|
-
*
|
|
327
|
+
* Result of `digestCompartmentMap()`
|
|
225
328
|
*/
|
|
226
|
-
export
|
|
227
|
-
|
|
228
|
-
|
|
329
|
+
export interface DigestResult {
|
|
330
|
+
/**
|
|
331
|
+
* Normalized `CompartmentMapDescriptor`
|
|
332
|
+
*/
|
|
333
|
+
compartmentMap: CompartmentMapDescriptor;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Sources found in the `CompartmentMapDescriptor`
|
|
337
|
+
*/
|
|
338
|
+
sources: Sources;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* A record of renamed {@link CompartmentDescriptor CompartmentDescriptors}
|
|
342
|
+
* from _new_ to _original_ name
|
|
343
|
+
*/
|
|
344
|
+
newToOldCompartmentNames: Record<string, string>;
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* A record of renamed {@link CompartmentDescriptor CompartmentDescriptors}
|
|
348
|
+
* from _original_ to _new_ name
|
|
349
|
+
*/
|
|
350
|
+
oldToNewCompartmentNames: Record<string, string>;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Alias for `newToOldCompartmentNames`
|
|
354
|
+
* @deprecated Use {@link newToOldCompartmentNames} instead.
|
|
355
|
+
*/
|
|
229
356
|
compartmentRenames: Record<string, string>;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* The result of `captureFromMap`.
|
|
361
|
+
*/
|
|
362
|
+
export type CaptureResult = Omit<DigestResult, 'compartmentMap' | 'sources'> & {
|
|
363
|
+
captureCompartmentMap: DigestResult['compartmentMap'];
|
|
364
|
+
captureSources: DigestResult['sources'];
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The result of `makeArchiveCompartmentMap`
|
|
369
|
+
*/
|
|
370
|
+
export type ArchiveResult = Omit<DigestResult, 'compartmentMap' | 'sources'> & {
|
|
371
|
+
archiveCompartmentMap: DigestResult['compartmentMap'];
|
|
372
|
+
archiveSources: DigestResult['sources'];
|
|
230
373
|
};
|
|
231
374
|
|
|
232
375
|
/**
|
|
@@ -240,10 +383,29 @@ export type CompartmentSources = Record<string, ModuleSource>;
|
|
|
240
383
|
export type ModuleSource = Partial<{
|
|
241
384
|
/** module loading error deferred to later stage */
|
|
242
385
|
deferredError: string;
|
|
243
|
-
/**
|
|
386
|
+
/**
|
|
387
|
+
* package-relative location.
|
|
388
|
+
* Not suitable for capture in an archive or bundle since it varies from host
|
|
389
|
+
* to host and would frustrate integrity hash checks.
|
|
390
|
+
*/
|
|
244
391
|
location: string;
|
|
245
392
|
/** fully qualified location */
|
|
246
393
|
sourceLocation: string;
|
|
394
|
+
/**
|
|
395
|
+
* directory name of the original source.
|
|
396
|
+
* This is safe to capture in a compartment map because it is _unlikely_ to
|
|
397
|
+
* vary between hosts.
|
|
398
|
+
* Package managers tend to drop a package in a consistently named location.
|
|
399
|
+
* If entry package is in a workspace, git enforces consistency.
|
|
400
|
+
* If entry package is the root of a repository, we rely on the developer
|
|
401
|
+
* to name the package consistently and suffer an inconsistent integrity hash
|
|
402
|
+
* otherwise.
|
|
403
|
+
* We do not currently capture this property in a compartment map because the
|
|
404
|
+
* schema validator currently (2024) deployed to Agoric blockchains does not
|
|
405
|
+
* tolerate compartment maps with unknown properties.
|
|
406
|
+
* https://github.com/endojs/endo/issues/2671
|
|
407
|
+
*/
|
|
408
|
+
sourceDirname: string;
|
|
247
409
|
bytes: Uint8Array;
|
|
248
410
|
/** in lowercase base-16 (hexadecimal) */
|
|
249
411
|
sha512: string;
|
|
@@ -353,7 +515,8 @@ type ParseArguments = [
|
|
|
353
515
|
sourceMapUrl: string;
|
|
354
516
|
readPowers: ReadFn | ReadPowers;
|
|
355
517
|
compartmentDescriptor: CompartmentDescriptor;
|
|
356
|
-
}
|
|
518
|
+
}> &
|
|
519
|
+
ArchiveOnlyOption,
|
|
357
520
|
];
|
|
358
521
|
|
|
359
522
|
/**
|
|
@@ -377,3 +540,8 @@ export type ParseFn = { isSyncParser?: true } & ((
|
|
|
377
540
|
* ParserImplementations}
|
|
378
541
|
*/
|
|
379
542
|
export type ParserForLanguage = Record<Language | string, ParserImplementation>;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Generic logging function accepted by various functions.
|
|
546
|
+
*/
|
|
547
|
+
export type LogFn = (message: string, ...args: any[]) => void;
|
package/src/types/internal.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ImportHook, ImportNowHook } from 'ses';
|
|
6
6
|
import type { CompartmentDescriptor, Language, LanguageForExtension, LanguageForModuleSpecifier, ModuleDescriptor } from './compartment-map-schema.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { MaybeReadFn, MaybeReadNowFn, ReadFn, ReadPowers } from './powers.js';
|
|
8
8
|
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
9
|
-
import type { AsyncParseFn, CompartmentSources, ExecuteOptions,
|
|
9
|
+
import type { ArchiveOnlyOption, AsyncParseFn, CompartmentSources, ComputeSha512Option, ExecuteOptions, ExitModuleImportHookOption, ExitModuleImportNowHookOption, LogOptions, ModuleTransforms, ParseFn, ParserForLanguage, SearchSuffixesOption, SourceMapHook, SourceMapHookOption, Sources, SyncModuleTransforms } from './external.js';
|
|
10
10
|
export type LinkOptions = {
|
|
11
11
|
resolve?: ResolveHook;
|
|
12
12
|
makeImportHook: ImportHookMaker;
|
|
@@ -14,8 +14,8 @@ export type LinkOptions = {
|
|
|
14
14
|
parserForLanguage?: ParserForLanguage;
|
|
15
15
|
moduleTransforms?: ModuleTransforms;
|
|
16
16
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
17
|
-
|
|
18
|
-
} & ExecuteOptions;
|
|
17
|
+
__native__?: boolean;
|
|
18
|
+
} & ArchiveOnlyOption & ExecuteOptions;
|
|
19
19
|
export type LinkResult = {
|
|
20
20
|
compartment: Compartment;
|
|
21
21
|
compartments: Record<string, Compartment>;
|
|
@@ -24,12 +24,20 @@ export type LinkResult = {
|
|
|
24
24
|
};
|
|
25
25
|
export type ResolveHook = (importSpecifier: string, referrerSpecifier: string) => string;
|
|
26
26
|
export type ShouldDeferError = (language: Language | undefined) => boolean;
|
|
27
|
-
export type
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
export type MakeImportHookMakersOptions = {
|
|
28
|
+
entryCompartmentName: string;
|
|
29
|
+
entryModuleSpecifier: string;
|
|
30
|
+
/**
|
|
31
|
+
* For depositing captured sources.
|
|
32
|
+
*/
|
|
33
|
+
sources?: Sources;
|
|
34
|
+
/**
|
|
35
|
+
* For depositing captured compartment descriptors.
|
|
36
|
+
*/
|
|
37
|
+
compartmentDescriptors?: Record<string, CompartmentDescriptor>;
|
|
38
|
+
} & ComputeSha512Option & SearchSuffixesOption & ArchiveOnlyOption & SourceMapHookOption;
|
|
39
|
+
export type MakeImportHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportHookOption;
|
|
40
|
+
export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportNowHookOption;
|
|
33
41
|
export type ImportHookMaker = (params: {
|
|
34
42
|
packageLocation: string;
|
|
35
43
|
packageName: string;
|
|
@@ -71,16 +79,18 @@ export type ChooseModuleDescriptorParams = {
|
|
|
71
79
|
/** All compartments */
|
|
72
80
|
compartments: Record<string, Compartment>;
|
|
73
81
|
packageSources: CompartmentSources;
|
|
74
|
-
/** Function to compute SHA-512 hash */
|
|
75
|
-
computeSha512?: HashFn;
|
|
76
82
|
readPowers: ReadPowers | ReadFn;
|
|
83
|
+
/**
|
|
84
|
+
* Whether to embed a sourceURL in applicable compiled sources.
|
|
85
|
+
* Should be false for archives and bundles, but true for runtime.
|
|
86
|
+
*/
|
|
77
87
|
sourceMapHook?: SourceMapHook;
|
|
78
88
|
/**
|
|
79
89
|
* Function returning a set of module names (scoped to the compartment) whose
|
|
80
90
|
* parser is not using heuristics to determine imports.
|
|
81
91
|
*/
|
|
82
92
|
strictlyRequiredForCompartment: (compartmentName: string) => Set<string>;
|
|
83
|
-
};
|
|
93
|
+
} & ComputeSha512Option & ArchiveOnlyOption;
|
|
84
94
|
type SyncChooseModuleDescriptorOperators = {
|
|
85
95
|
/**
|
|
86
96
|
* A function that reads a file, returning its binary contents _or_
|
|
@@ -157,5 +167,68 @@ export type MakeMapParsersOptions = {
|
|
|
157
167
|
*/
|
|
158
168
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
159
169
|
};
|
|
170
|
+
/**
|
|
171
|
+
* Options for `search()`
|
|
172
|
+
*/
|
|
173
|
+
export type SearchOptions = LogOptions;
|
|
174
|
+
/**
|
|
175
|
+
* Object fulfilled from `search()`
|
|
176
|
+
*/
|
|
177
|
+
export interface SearchResult {
|
|
178
|
+
packageLocation: string;
|
|
179
|
+
packageDescriptorLocation: string;
|
|
180
|
+
packageDescriptorText: string;
|
|
181
|
+
moduleSpecifier: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Object fulfilled from `searchDescriptor()`
|
|
185
|
+
*
|
|
186
|
+
* @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc.
|
|
187
|
+
*/
|
|
188
|
+
export interface SearchDescriptorResult<T> {
|
|
189
|
+
data: T;
|
|
190
|
+
directory: string;
|
|
191
|
+
location: string;
|
|
192
|
+
packageDescriptorLocation: string;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Options for `searchDescriptor()`
|
|
196
|
+
*/
|
|
197
|
+
export type SearchDescriptorOptions = LogOptions;
|
|
198
|
+
/**
|
|
199
|
+
* A power to read a package descriptor
|
|
200
|
+
* @template T Format of package descriptor
|
|
201
|
+
*/
|
|
202
|
+
export type ReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T>;
|
|
203
|
+
/**
|
|
204
|
+
* A power to _maybe_ read a package descriptor
|
|
205
|
+
* @template T Format of package descriptor
|
|
206
|
+
*/
|
|
207
|
+
export type MaybeReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T | undefined>;
|
|
208
|
+
/**
|
|
209
|
+
* The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk
|
|
210
|
+
*/
|
|
211
|
+
export interface PackageDescriptor {
|
|
212
|
+
/**
|
|
213
|
+
* 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
|
|
214
|
+
*/
|
|
215
|
+
name: string;
|
|
216
|
+
version?: string;
|
|
217
|
+
/**
|
|
218
|
+
* TODO: Update with proper type when this field is handled.
|
|
219
|
+
*/
|
|
220
|
+
exports?: unknown;
|
|
221
|
+
type?: 'module' | 'commonjs';
|
|
222
|
+
dependencies?: Record<string, string>;
|
|
223
|
+
devDependencies?: Record<string, string>;
|
|
224
|
+
peerDependencies?: Record<string, string>;
|
|
225
|
+
optionalDependencies?: Record<string, string>;
|
|
226
|
+
bundleDependencies?: string[];
|
|
227
|
+
peerDependenciesMeta?: Record<string, {
|
|
228
|
+
optional?: boolean;
|
|
229
|
+
[k: string]: unknown;
|
|
230
|
+
}>;
|
|
231
|
+
[k: string]: unknown;
|
|
232
|
+
}
|
|
160
233
|
export {};
|
|
161
234
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACrD,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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E,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAC7C,CAAC;IAEF,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
|
package/src/types/internal.ts
CHANGED
|
@@ -14,7 +14,6 @@ import type {
|
|
|
14
14
|
ModuleDescriptor,
|
|
15
15
|
} from './compartment-map-schema.js';
|
|
16
16
|
import type {
|
|
17
|
-
HashFn,
|
|
18
17
|
MaybeReadFn,
|
|
19
18
|
MaybeReadNowFn,
|
|
20
19
|
ReadFn,
|
|
@@ -22,10 +21,14 @@ import type {
|
|
|
22
21
|
} from './powers.js';
|
|
23
22
|
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
24
23
|
import type {
|
|
24
|
+
ArchiveOnlyOption,
|
|
25
25
|
AsyncParseFn,
|
|
26
26
|
CompartmentSources,
|
|
27
|
+
ComputeSha512Option,
|
|
27
28
|
ExecuteOptions,
|
|
28
|
-
|
|
29
|
+
ExitModuleImportHookOption,
|
|
30
|
+
ExitModuleImportNowHookOption,
|
|
31
|
+
LogOptions,
|
|
29
32
|
ModuleTransforms,
|
|
30
33
|
ParseFn,
|
|
31
34
|
ParserForLanguage,
|
|
@@ -43,8 +46,9 @@ export type LinkOptions = {
|
|
|
43
46
|
parserForLanguage?: ParserForLanguage;
|
|
44
47
|
moduleTransforms?: ModuleTransforms;
|
|
45
48
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
46
|
-
|
|
47
|
-
} &
|
|
49
|
+
__native__?: boolean;
|
|
50
|
+
} & ArchiveOnlyOption &
|
|
51
|
+
ExecuteOptions;
|
|
48
52
|
|
|
49
53
|
export type LinkResult = {
|
|
50
54
|
compartment: Compartment;
|
|
@@ -60,15 +64,27 @@ export type ResolveHook = (
|
|
|
60
64
|
|
|
61
65
|
export type ShouldDeferError = (language: Language | undefined) => boolean;
|
|
62
66
|
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
export type MakeImportHookMakersOptions = {
|
|
68
|
+
entryCompartmentName: string;
|
|
69
|
+
entryModuleSpecifier: string;
|
|
70
|
+
/**
|
|
71
|
+
* For depositing captured sources.
|
|
72
|
+
*/
|
|
73
|
+
sources?: Sources;
|
|
74
|
+
/**
|
|
75
|
+
* For depositing captured compartment descriptors.
|
|
76
|
+
*/
|
|
77
|
+
compartmentDescriptors?: Record<string, CompartmentDescriptor>;
|
|
78
|
+
} & ComputeSha512Option &
|
|
69
79
|
SearchSuffixesOption &
|
|
80
|
+
ArchiveOnlyOption &
|
|
70
81
|
SourceMapHookOption;
|
|
71
82
|
|
|
83
|
+
export type MakeImportHookMakerOptions = MakeImportHookMakersOptions &
|
|
84
|
+
ExitModuleImportHookOption;
|
|
85
|
+
export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions &
|
|
86
|
+
ExitModuleImportNowHookOption;
|
|
87
|
+
|
|
72
88
|
export type ImportHookMaker = (params: {
|
|
73
89
|
packageLocation: string;
|
|
74
90
|
packageName: string;
|
|
@@ -117,16 +133,19 @@ export type ChooseModuleDescriptorParams = {
|
|
|
117
133
|
/** All compartments */
|
|
118
134
|
compartments: Record<string, Compartment>;
|
|
119
135
|
packageSources: CompartmentSources;
|
|
120
|
-
/** Function to compute SHA-512 hash */
|
|
121
|
-
computeSha512?: HashFn;
|
|
122
136
|
readPowers: ReadPowers | ReadFn;
|
|
137
|
+
/**
|
|
138
|
+
* Whether to embed a sourceURL in applicable compiled sources.
|
|
139
|
+
* Should be false for archives and bundles, but true for runtime.
|
|
140
|
+
*/
|
|
123
141
|
sourceMapHook?: SourceMapHook;
|
|
124
142
|
/**
|
|
125
143
|
* Function returning a set of module names (scoped to the compartment) whose
|
|
126
144
|
* parser is not using heuristics to determine imports.
|
|
127
145
|
*/
|
|
128
146
|
strictlyRequiredForCompartment: (compartmentName: string) => Set<string>;
|
|
129
|
-
}
|
|
147
|
+
} & ComputeSha512Option &
|
|
148
|
+
ArchiveOnlyOption;
|
|
130
149
|
|
|
131
150
|
type SyncChooseModuleDescriptorOperators = {
|
|
132
151
|
/**
|
|
@@ -214,3 +233,78 @@ export type MakeMapParsersOptions = {
|
|
|
214
233
|
*/
|
|
215
234
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
216
235
|
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Options for `search()`
|
|
239
|
+
*/
|
|
240
|
+
export type SearchOptions = LogOptions;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Object fulfilled from `search()`
|
|
244
|
+
*/
|
|
245
|
+
export interface SearchResult {
|
|
246
|
+
packageLocation: string;
|
|
247
|
+
packageDescriptorLocation: string;
|
|
248
|
+
packageDescriptorText: string;
|
|
249
|
+
moduleSpecifier: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Object fulfilled from `searchDescriptor()`
|
|
254
|
+
*
|
|
255
|
+
* @template T The datatype; may be a {@link PackageDescriptor}, blob, string, etc.
|
|
256
|
+
*/
|
|
257
|
+
export interface SearchDescriptorResult<T> {
|
|
258
|
+
data: T;
|
|
259
|
+
directory: string;
|
|
260
|
+
location: string;
|
|
261
|
+
packageDescriptorLocation: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Options for `searchDescriptor()`
|
|
266
|
+
*/
|
|
267
|
+
export type SearchDescriptorOptions = LogOptions;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* A power to read a package descriptor
|
|
271
|
+
* @template T Format of package descriptor
|
|
272
|
+
*/
|
|
273
|
+
export type ReadDescriptorFn<T = PackageDescriptor> = (
|
|
274
|
+
location: string,
|
|
275
|
+
) => Promise<T>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* A power to _maybe_ read a package descriptor
|
|
279
|
+
* @template T Format of package descriptor
|
|
280
|
+
*/
|
|
281
|
+
export type MaybeReadDescriptorFn<T = PackageDescriptor> = (
|
|
282
|
+
location: string,
|
|
283
|
+
) => Promise<T | undefined>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk
|
|
287
|
+
*/
|
|
288
|
+
export interface PackageDescriptor {
|
|
289
|
+
/**
|
|
290
|
+
* 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
|
|
291
|
+
*/
|
|
292
|
+
name: string;
|
|
293
|
+
version?: string;
|
|
294
|
+
/**
|
|
295
|
+
* TODO: Update with proper type when this field is handled.
|
|
296
|
+
*/
|
|
297
|
+
exports?: unknown;
|
|
298
|
+
type?: 'module' | 'commonjs';
|
|
299
|
+
dependencies?: Record<string, string>;
|
|
300
|
+
devDependencies?: Record<string, string>;
|
|
301
|
+
peerDependencies?: Record<string, string>;
|
|
302
|
+
optionalDependencies?: Record<string, string>;
|
|
303
|
+
bundleDependencies?: string[];
|
|
304
|
+
peerDependenciesMeta?: Record<
|
|
305
|
+
string,
|
|
306
|
+
{ optional?: boolean; [k: string]: unknown }
|
|
307
|
+
>;
|
|
308
|
+
|
|
309
|
+
[k: string]: unknown;
|
|
310
|
+
}
|