@endo/compartment-mapper 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +278 -111
- package/bundle.d.ts +1 -1
- package/bundle.js +4 -1
- package/functor-lite.d.ts +3 -0
- package/functor-lite.d.ts.map +1 -0
- package/functor-lite.js +4 -0
- package/functor.d.ts +3 -0
- package/functor.d.ts.map +1 -0
- package/functor.js +4 -0
- package/index.d.ts +1 -1
- package/index.js +4 -1
- package/package.json +8 -4
- package/script-lite.d.ts +3 -0
- package/script-lite.d.ts.map +1 -0
- package/script-lite.js +4 -0
- package/script.d.ts +3 -0
- package/script.d.ts.map +1 -0
- package/script.js +4 -0
- package/src/archive-lite.js +1 -1
- package/src/bundle-cjs.d.ts +1 -1
- package/src/bundle-cjs.d.ts.map +1 -1
- package/src/bundle-cjs.js +57 -28
- package/src/bundle-json.d.ts.map +1 -1
- package/src/bundle-json.js +2 -3
- package/src/bundle-lite.d.ts +91 -0
- package/src/bundle-lite.d.ts.map +1 -0
- package/src/bundle-lite.js +668 -0
- package/src/bundle-mjs.d.ts +2 -2
- package/src/bundle-mjs.d.ts.map +1 -1
- package/src/bundle-mjs.js +36 -19
- package/src/bundle.d.ts +48 -10
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +391 -125
- package/src/capture-lite.js +1 -1
- package/src/import-hook.d.ts +3 -16
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +11 -18
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +4 -2
- package/src/node-modules.d.ts +4 -47
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +121 -121
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +8 -3
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +2 -10
- package/src/parse-cjs.js +1 -1
- package/src/parse-mjs.js +2 -2
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +4 -7
- package/src/search.d.ts +6 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +29 -12
- package/src/types/compartment-map-schema.d.ts +5 -0
- package/src/types/compartment-map-schema.d.ts.map +1 -1
- package/src/types/compartment-map-schema.ts +5 -0
- package/src/types/external.d.ts +112 -8
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +127 -8
- package/src/types/internal.d.ts +85 -13
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +106 -13
- package/src/types/node-modules.d.ts +79 -0
- package/src/types/node-modules.d.ts.map +1 -0
- package/src/types/node-modules.ts +89 -0
- package/src/types/node-powers.d.ts +4 -4
- package/src/types/node-powers.d.ts.map +1 -1
- package/src/types/node-powers.ts +4 -4
- package/src/types/powers.d.ts +2 -2
- package/src/types/powers.d.ts.map +1 -1
- package/src/types/powers.ts +2 -2
package/src/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"AAmDO,iCANM,CAAC,YACH,MAAM,uBACN,sBAAsB,CAAC,CAAC,kBACxB,uBAAuB,GACrB,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,CA8B9C;AAgCM,mCALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,0DAEJ,OAAO,CAAC,YAAY,CAAC,CA0BjC;2CAxHS,YAAY;6CAAZ,YAAY;4CAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;kCAAZ,YAAY"}
|
package/src/search.js
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
* ReadFn,
|
|
9
9
|
* ReadPowers,
|
|
10
10
|
* MaybeReadPowers,
|
|
11
|
+
* SearchOptions,
|
|
12
|
+
* SearchResult,
|
|
13
|
+
* SearchDescriptorResult,
|
|
14
|
+
* MaybeReadDescriptorFn,
|
|
15
|
+
* SearchDescriptorOptions,
|
|
11
16
|
* } from './types.js'
|
|
12
17
|
*/
|
|
13
18
|
|
|
@@ -18,6 +23,11 @@ import { unpackReadPowers } from './powers.js';
|
|
|
18
23
|
// q, as in quote, for enquoting strings in error messages.
|
|
19
24
|
const q = JSON.stringify;
|
|
20
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Default logger that does nothing
|
|
28
|
+
*/
|
|
29
|
+
const noop = () => {};
|
|
30
|
+
|
|
21
31
|
const decoder = new TextDecoder();
|
|
22
32
|
|
|
23
33
|
/**
|
|
@@ -35,10 +45,15 @@ const resolveLocation = (rel, abs) => new URL(rel, abs).toString();
|
|
|
35
45
|
*
|
|
36
46
|
* @template T
|
|
37
47
|
* @param {string} location
|
|
38
|
-
* @param {
|
|
39
|
-
* @
|
|
48
|
+
* @param {MaybeReadDescriptorFn<T>} maybeReadDescriptor
|
|
49
|
+
* @param {SearchDescriptorOptions} options
|
|
50
|
+
* @returns {Promise<SearchDescriptorResult<T>>}
|
|
40
51
|
*/
|
|
41
|
-
export const searchDescriptor = async (
|
|
52
|
+
export const searchDescriptor = async (
|
|
53
|
+
location,
|
|
54
|
+
maybeReadDescriptor,
|
|
55
|
+
{ log: _log = noop } = {},
|
|
56
|
+
) => {
|
|
42
57
|
await null;
|
|
43
58
|
let directory = resolveLocation('./', location);
|
|
44
59
|
for (;;) {
|
|
@@ -91,17 +106,19 @@ const maybeReadDescriptorDefault = async (
|
|
|
91
106
|
*
|
|
92
107
|
* @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
|
|
93
108
|
* @param {string} moduleLocation
|
|
94
|
-
* @
|
|
95
|
-
*
|
|
96
|
-
* packageDescriptorLocation: string,
|
|
97
|
-
* packageDescriptorText: string,
|
|
98
|
-
* moduleSpecifier: string,
|
|
99
|
-
* }>}
|
|
109
|
+
* @param {SearchOptions} [options]
|
|
110
|
+
* @returns {Promise<SearchResult>}
|
|
100
111
|
*/
|
|
101
|
-
export const search = async (
|
|
112
|
+
export const search = async (
|
|
113
|
+
readPowers,
|
|
114
|
+
moduleLocation,
|
|
115
|
+
{ log = noop } = {},
|
|
116
|
+
) => {
|
|
102
117
|
const { data, directory, location, packageDescriptorLocation } =
|
|
103
|
-
await searchDescriptor(
|
|
104
|
-
|
|
118
|
+
await searchDescriptor(
|
|
119
|
+
moduleLocation,
|
|
120
|
+
loc => maybeReadDescriptorDefault(readPowers, loc),
|
|
121
|
+
{ log },
|
|
105
122
|
);
|
|
106
123
|
|
|
107
124
|
if (!data) {
|
|
@@ -29,6 +29,11 @@ export type EntryDescriptor = {
|
|
|
29
29
|
*/
|
|
30
30
|
export type CompartmentDescriptor = {
|
|
31
31
|
label: string;
|
|
32
|
+
/**
|
|
33
|
+
* name of the parent directory of the package from which the compartment is derived,
|
|
34
|
+
* for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace.
|
|
35
|
+
*/
|
|
36
|
+
sourceDirname?: string;
|
|
32
37
|
/** shortest path of dependency names to this compartment */
|
|
33
38
|
path?: Array<string>;
|
|
34
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-map-schema.d.ts","sourceRoot":"","sources":["compartment-map-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,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37
37
|
label: string;
|
|
38
|
+
/**
|
|
39
|
+
* name of the parent directory of the package from which the compartment is derived,
|
|
40
|
+
* for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace.
|
|
41
|
+
*/
|
|
42
|
+
sourceDirname?: string;
|
|
38
43
|
/** shortest path of dependency names to this compartment */
|
|
39
44
|
path?: Array<string>;
|
|
40
45
|
/**
|
package/src/types/external.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module External types of the compartment mapper.
|
|
3
3
|
*/
|
|
4
4
|
import type { FinalStaticModuleType, StaticModuleType, ThirdPartyStaticModuleInterface, Transform } from 'ses';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CompartmentDescriptor, CompartmentMapDescriptor, Language, LanguageForExtension } from './compartment-map-schema.js';
|
|
6
6
|
import type { HashFn, ReadFn, ReadPowers } from './powers.js';
|
|
7
7
|
/**
|
|
8
8
|
* Set of options available in the context of code execution.
|
|
@@ -25,7 +25,19 @@ export type ParseArchiveOptions = Partial<{
|
|
|
25
25
|
__native__: boolean;
|
|
26
26
|
}> & ModulesOption & CompartmentOption & ParserForLanguageOption & ExitModuleImportHookOption;
|
|
27
27
|
export type LoadArchiveOptions = ParseArchiveOptions;
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Options having an optional `log` property.
|
|
30
|
+
*/
|
|
31
|
+
export interface LogOptions {
|
|
32
|
+
/**
|
|
33
|
+
* A logger (for logging)
|
|
34
|
+
*/
|
|
35
|
+
log?: LogFn;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for `mapNodeModules()`
|
|
39
|
+
*/
|
|
40
|
+
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy & PolicyOption & LogOptions;
|
|
29
41
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
30
42
|
/** @deprecated renamed `conditions` to be consistent with Node.js */
|
|
31
43
|
tags: Set<string>;
|
|
@@ -84,21 +96,55 @@ type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
|
84
96
|
* @deprecated Use `mapNodeModules()`.
|
|
85
97
|
*/
|
|
86
98
|
export type CompartmentMapForNodeModulesOptions = Omit<MapNodeModulesOptions, 'conditions' | 'tags'>;
|
|
87
|
-
export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption;
|
|
99
|
+
export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption & LogOptions;
|
|
88
100
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions & ModuleTransformsOption & ImportingOptions & ExitModuleImportHookOption & LinkingOptions;
|
|
89
101
|
export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions & SyncModuleTransformsOption & SyncImportingOptions & ExitModuleImportNowHookOption;
|
|
90
102
|
export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> & ArchiveLiteOptions;
|
|
103
|
+
export type BundleOptions = ArchiveOptions & {
|
|
104
|
+
/**
|
|
105
|
+
* Format of the bundle for purposes of importing modules from the surrounding
|
|
106
|
+
* environment.
|
|
107
|
+
* The default can be CommonJS or ESM but depends on neither `require` nor `import`
|
|
108
|
+
* for external modules, but errors early if the entrained modules need to import
|
|
109
|
+
* a host module.
|
|
110
|
+
* Specifying `cjs` makes `require` available for modules outside the bundle
|
|
111
|
+
* (exits to the import graph).
|
|
112
|
+
*/
|
|
113
|
+
format?: 'cjs';
|
|
114
|
+
/**
|
|
115
|
+
* Evaluates individual module functors in-place so stack traces represent
|
|
116
|
+
* original source locations better.
|
|
117
|
+
* The resulting script cannot be used on a web page with a no-unsafe-eval
|
|
118
|
+
* Content Security Policy.
|
|
119
|
+
*/
|
|
120
|
+
useEvaluate?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* A prefix for the sourceURL comment in each module format that supports
|
|
123
|
+
* sourceURL comments.
|
|
124
|
+
* Requires `useEvaluate` for effect.
|
|
125
|
+
*/
|
|
126
|
+
sourceUrlPrefix?: string;
|
|
127
|
+
};
|
|
91
128
|
export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> & SyncArchiveLiteOptions;
|
|
92
129
|
/**
|
|
93
130
|
* Options for `loadLocation()`
|
|
94
131
|
*/
|
|
95
|
-
export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions;
|
|
132
|
+
export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions & LogOptions;
|
|
96
133
|
/**
|
|
97
134
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
98
135
|
* `ReadNowPowers`) for dynamic require support
|
|
99
136
|
*/
|
|
100
|
-
export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions;
|
|
101
|
-
|
|
137
|
+
export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions & LogOptions;
|
|
138
|
+
/**
|
|
139
|
+
* Options for `importLocation()` without dynamic require support
|
|
140
|
+
*/
|
|
141
|
+
export type ImportLocationOptions = ArchiveOptions & ExecuteOptions & LogOptions;
|
|
142
|
+
export type ComputeSha512Option = {
|
|
143
|
+
/**
|
|
144
|
+
* For computing integrity hashes for module descriptors based on captured sources.
|
|
145
|
+
*/
|
|
146
|
+
computeSha512?: HashFn;
|
|
147
|
+
};
|
|
102
148
|
export type SearchSuffixesOption = {
|
|
103
149
|
/**
|
|
104
150
|
* Suffixes to search if the unmodified specifier is not found. Pass `[]` to
|
|
@@ -117,9 +163,17 @@ export type ModulesOption = {
|
|
|
117
163
|
modules?: Record<string, any>;
|
|
118
164
|
};
|
|
119
165
|
export type ExitModuleImportHookOption = {
|
|
166
|
+
/**
|
|
167
|
+
* For obtaining module descriptors for modules that must be provided
|
|
168
|
+
* by the eventual runtime execution environment, asynchronously.
|
|
169
|
+
*/
|
|
120
170
|
importHook?: ExitModuleImportHook;
|
|
121
171
|
};
|
|
122
172
|
export type ExitModuleImportNowHookOption = {
|
|
173
|
+
/**
|
|
174
|
+
* For obtaining module descriptors for modules that must be provided
|
|
175
|
+
* by the eventual runtime execution environment, synchronusly.
|
|
176
|
+
*/
|
|
123
177
|
importNowHook?: ExitModuleImportNowHook;
|
|
124
178
|
};
|
|
125
179
|
export type ParserForLanguageOption = {
|
|
@@ -134,6 +188,33 @@ export type ModuleTransformsOption = {
|
|
|
134
188
|
export type SyncModuleTransformsOption = {
|
|
135
189
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
136
190
|
};
|
|
191
|
+
export type ArchiveOnlyOption = {
|
|
192
|
+
/**
|
|
193
|
+
* Whether to prepare to create an archive or script bundle for execution
|
|
194
|
+
* elsewhere or elsewhen, as opposed to preparing to execute immediately.
|
|
195
|
+
*
|
|
196
|
+
* This has several practical effects.
|
|
197
|
+
*
|
|
198
|
+
* Archives expect to exit to potentially different host modules than the current
|
|
199
|
+
* host, but cannot instantiate those modules.
|
|
200
|
+
* For example, when preparing a bundle for execution in Node.js from within a
|
|
201
|
+
* web page, exiting to `node:fs` is appropriate but cannot be instantiated.
|
|
202
|
+
* So, the import hook will make a note of the exit and provide a stub module
|
|
203
|
+
* that throws an error if it is imported.
|
|
204
|
+
*
|
|
205
|
+
* Also, importing a module graph off a local medium immediately should
|
|
206
|
+
* inject a fully qualified source location into the module source,
|
|
207
|
+
* but sources loaded for an archive must not capture the original source
|
|
208
|
+
* location, but give the runtime an opportunity to inject a sourceURL.
|
|
209
|
+
*
|
|
210
|
+
* Also, the linker does not apply attenuations to the global environment
|
|
211
|
+
* if it is preparing to write an archive or script bundle.
|
|
212
|
+
*
|
|
213
|
+
* This option does not generally surface to users, but is set by the scenario,
|
|
214
|
+
* off for `importLocation`, on for `makeArchive` and `makeScript`.
|
|
215
|
+
*/
|
|
216
|
+
archiveOnly?: boolean;
|
|
217
|
+
};
|
|
137
218
|
export type PolicyOption = {
|
|
138
219
|
policy?: any;
|
|
139
220
|
};
|
|
@@ -198,10 +279,29 @@ export type CompartmentSources = Record<string, ModuleSource>;
|
|
|
198
279
|
export type ModuleSource = Partial<{
|
|
199
280
|
/** module loading error deferred to later stage */
|
|
200
281
|
deferredError: string;
|
|
201
|
-
/**
|
|
282
|
+
/**
|
|
283
|
+
* package-relative location.
|
|
284
|
+
* Not suitable for capture in an archive or bundle since it varies from host
|
|
285
|
+
* to host and would frustrate integrity hash checks.
|
|
286
|
+
*/
|
|
202
287
|
location: string;
|
|
203
288
|
/** fully qualified location */
|
|
204
289
|
sourceLocation: string;
|
|
290
|
+
/**
|
|
291
|
+
* directory name of the original source.
|
|
292
|
+
* This is safe to capture in a compartment map because it is _unlikely_ to
|
|
293
|
+
* vary between hosts.
|
|
294
|
+
* Package managers tend to drop a package in a consistently named location.
|
|
295
|
+
* If entry package is in a workspace, git enforces consistency.
|
|
296
|
+
* If entry package is the root of a repository, we rely on the developer
|
|
297
|
+
* to name the package consistently and suffer an inconsistent integrity hash
|
|
298
|
+
* otherwise.
|
|
299
|
+
* We do not currently capture this property in a compartment map because the
|
|
300
|
+
* schema validator currently (2024) deployed to Agoric blockchains does not
|
|
301
|
+
* tolerate compartment maps with unknown properties.
|
|
302
|
+
* https://github.com/endojs/endo/issues/2671
|
|
303
|
+
*/
|
|
304
|
+
sourceDirname: string;
|
|
205
305
|
bytes: Uint8Array;
|
|
206
306
|
/** in lowercase base-16 (hexadecimal) */
|
|
207
307
|
sha512: string;
|
|
@@ -275,7 +375,7 @@ type ParseArguments = [
|
|
|
275
375
|
sourceMapUrl: string;
|
|
276
376
|
readPowers: ReadFn | ReadPowers;
|
|
277
377
|
compartmentDescriptor: CompartmentDescriptor;
|
|
278
|
-
}>
|
|
378
|
+
}> & ArchiveOnlyOption
|
|
279
379
|
];
|
|
280
380
|
/**
|
|
281
381
|
* Result of a {@link ParseFn} or {@link AsyncParseFn}
|
|
@@ -295,5 +395,9 @@ export type ParseFn = {
|
|
|
295
395
|
* ParserImplementations}
|
|
296
396
|
*/
|
|
297
397
|
export type ParserForLanguage = Record<Language | string, ParserImplementation>;
|
|
398
|
+
/**
|
|
399
|
+
* Generic logging function accepted by various functions.
|
|
400
|
+
*/
|
|
401
|
+
export type LogFn = (message: string, ...args: any[]) => void;
|
|
298
402
|
export {};
|
|
299
403
|
//# sourceMappingURL=external.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["external.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,+BAA+B,EAC/B,SAAS,EACV,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EACV,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["external.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,+BAA+B,EAC/B,SAAS,EACV,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,QAAQ,EACR,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,WAAW,EAAE,OAAO,WAAW,CAAC;IAChC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC,GACA,aAAa,GACb,0BAA0B,CAAC;AAE7B,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,yBAAyB,CAAC;IACjD,wBAAwB,EAAE,4BAA4B,CAAC;IACvD,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC,GACA,a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SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,cAAc,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAE7E,MAAM,MAAM,OAAO,GAAG;IAAE,YAAY,CAAC,EAAE,IAAI,CAAA;CAAE,GAAG,CAAC,CAC/C,GAAG,IAAI,EAAE,cAAc,KACpB,WAAW,CAAC,CAAC;AAElB;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,EAAE,oBAAoB,CAAC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
|
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';
|
|
@@ -48,8 +48,23 @@ export type ParseArchiveOptions = Partial<{
|
|
|
48
48
|
|
|
49
49
|
export type LoadArchiveOptions = ParseArchiveOptions;
|
|
50
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
|
+
*/
|
|
51
64
|
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy &
|
|
52
|
-
PolicyOption
|
|
65
|
+
PolicyOption &
|
|
66
|
+
LogOptions;
|
|
67
|
+
|
|
53
68
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
54
69
|
/** @deprecated renamed `conditions` to be consistent with Node.js */
|
|
55
70
|
tags: Set<string>;
|
|
@@ -115,7 +130,8 @@ export type CompartmentMapForNodeModulesOptions = Omit<
|
|
|
115
130
|
|
|
116
131
|
export type CaptureLiteOptions = ImportingOptions &
|
|
117
132
|
LinkingOptions &
|
|
118
|
-
PolicyOption
|
|
133
|
+
PolicyOption &
|
|
134
|
+
LogOptions;
|
|
119
135
|
|
|
120
136
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
121
137
|
ModuleTransformsOption &
|
|
@@ -131,25 +147,67 @@ export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
|
131
147
|
export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> &
|
|
132
148
|
ArchiveLiteOptions;
|
|
133
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
|
+
|
|
134
176
|
export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> &
|
|
135
177
|
SyncArchiveLiteOptions;
|
|
136
178
|
|
|
137
179
|
/**
|
|
138
180
|
* Options for `loadLocation()`
|
|
139
181
|
*/
|
|
140
|
-
export type LoadLocationOptions = ArchiveOptions &
|
|
182
|
+
export type LoadLocationOptions = ArchiveOptions &
|
|
183
|
+
SyncArchiveOptions &
|
|
184
|
+
LogOptions;
|
|
141
185
|
|
|
142
186
|
/**
|
|
143
187
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
144
188
|
* `ReadNowPowers`) for dynamic require support
|
|
145
189
|
*/
|
|
146
|
-
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
190
|
+
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
191
|
+
ExecuteOptions &
|
|
192
|
+
LogOptions;
|
|
147
193
|
|
|
148
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Options for `importLocation()` without dynamic require support
|
|
196
|
+
*/
|
|
197
|
+
export type ImportLocationOptions = ArchiveOptions &
|
|
198
|
+
ExecuteOptions &
|
|
199
|
+
LogOptions;
|
|
149
200
|
|
|
150
201
|
// ////////////////////////////////////////////////////////////////////////////////
|
|
151
202
|
// Single Options
|
|
152
203
|
|
|
204
|
+
export type ComputeSha512Option = {
|
|
205
|
+
/**
|
|
206
|
+
* For computing integrity hashes for module descriptors based on captured sources.
|
|
207
|
+
*/
|
|
208
|
+
computeSha512?: HashFn;
|
|
209
|
+
};
|
|
210
|
+
|
|
153
211
|
export type SearchSuffixesOption = {
|
|
154
212
|
/**
|
|
155
213
|
* Suffixes to search if the unmodified specifier is not found. Pass `[]` to
|
|
@@ -171,10 +229,18 @@ export type ModulesOption = {
|
|
|
171
229
|
};
|
|
172
230
|
|
|
173
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
|
+
*/
|
|
174
236
|
importHook?: ExitModuleImportHook;
|
|
175
237
|
};
|
|
176
238
|
|
|
177
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
|
+
*/
|
|
178
244
|
importNowHook?: ExitModuleImportNowHook;
|
|
179
245
|
};
|
|
180
246
|
|
|
@@ -194,6 +260,34 @@ export type SyncModuleTransformsOption = {
|
|
|
194
260
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
195
261
|
};
|
|
196
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
|
+
|
|
197
291
|
export type PolicyOption = {
|
|
198
292
|
policy?: any;
|
|
199
293
|
};
|
|
@@ -289,10 +383,29 @@ export type CompartmentSources = Record<string, ModuleSource>;
|
|
|
289
383
|
export type ModuleSource = Partial<{
|
|
290
384
|
/** module loading error deferred to later stage */
|
|
291
385
|
deferredError: string;
|
|
292
|
-
/**
|
|
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
|
+
*/
|
|
293
391
|
location: string;
|
|
294
392
|
/** fully qualified location */
|
|
295
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;
|
|
296
409
|
bytes: Uint8Array;
|
|
297
410
|
/** in lowercase base-16 (hexadecimal) */
|
|
298
411
|
sha512: string;
|
|
@@ -402,7 +515,8 @@ type ParseArguments = [
|
|
|
402
515
|
sourceMapUrl: string;
|
|
403
516
|
readPowers: ReadFn | ReadPowers;
|
|
404
517
|
compartmentDescriptor: CompartmentDescriptor;
|
|
405
|
-
}
|
|
518
|
+
}> &
|
|
519
|
+
ArchiveOnlyOption,
|
|
406
520
|
];
|
|
407
521
|
|
|
408
522
|
/**
|
|
@@ -426,3 +540,8 @@ export type ParseFn = { isSyncParser?: true } & ((
|
|
|
426
540
|
* ParserImplementations}
|
|
427
541
|
*/
|
|
428
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;
|