@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/search.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Provides the behavior for `node-modules.js` to find modules and
|
|
3
3
|
* packages according to the Node.js `node_modules` convention.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
4
6
|
*/
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -8,6 +10,11 @@
|
|
|
8
10
|
* ReadFn,
|
|
9
11
|
* ReadPowers,
|
|
10
12
|
* MaybeReadPowers,
|
|
13
|
+
* SearchOptions,
|
|
14
|
+
* SearchResult,
|
|
15
|
+
* SearchDescriptorResult,
|
|
16
|
+
* MaybeReadDescriptorFn,
|
|
17
|
+
* SearchDescriptorOptions,
|
|
11
18
|
* } from './types.js'
|
|
12
19
|
*/
|
|
13
20
|
|
|
@@ -18,6 +25,11 @@ import { unpackReadPowers } from './powers.js';
|
|
|
18
25
|
// q, as in quote, for enquoting strings in error messages.
|
|
19
26
|
const q = JSON.stringify;
|
|
20
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Default logger that does nothing
|
|
30
|
+
*/
|
|
31
|
+
const noop = () => {};
|
|
32
|
+
|
|
21
33
|
const decoder = new TextDecoder();
|
|
22
34
|
|
|
23
35
|
/**
|
|
@@ -35,10 +47,15 @@ const resolveLocation = (rel, abs) => new URL(rel, abs).toString();
|
|
|
35
47
|
*
|
|
36
48
|
* @template T
|
|
37
49
|
* @param {string} location
|
|
38
|
-
* @param {
|
|
39
|
-
* @
|
|
50
|
+
* @param {MaybeReadDescriptorFn<T>} maybeReadDescriptor
|
|
51
|
+
* @param {SearchDescriptorOptions} options
|
|
52
|
+
* @returns {Promise<SearchDescriptorResult<T>>}
|
|
40
53
|
*/
|
|
41
|
-
export const searchDescriptor = async (
|
|
54
|
+
export const searchDescriptor = async (
|
|
55
|
+
location,
|
|
56
|
+
maybeReadDescriptor,
|
|
57
|
+
{ log: _log = noop } = {},
|
|
58
|
+
) => {
|
|
42
59
|
await null;
|
|
43
60
|
let directory = resolveLocation('./', location);
|
|
44
61
|
for (;;) {
|
|
@@ -91,17 +108,19 @@ const maybeReadDescriptorDefault = async (
|
|
|
91
108
|
*
|
|
92
109
|
* @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
|
|
93
110
|
* @param {string} moduleLocation
|
|
94
|
-
* @
|
|
95
|
-
*
|
|
96
|
-
* packageDescriptorLocation: string,
|
|
97
|
-
* packageDescriptorText: string,
|
|
98
|
-
* moduleSpecifier: string,
|
|
99
|
-
* }>}
|
|
111
|
+
* @param {SearchOptions} [options]
|
|
112
|
+
* @returns {Promise<SearchResult>}
|
|
100
113
|
*/
|
|
101
|
-
export const search = async (
|
|
114
|
+
export const search = async (
|
|
115
|
+
readPowers,
|
|
116
|
+
moduleLocation,
|
|
117
|
+
{ log = noop } = {},
|
|
118
|
+
) => {
|
|
102
119
|
const { data, directory, location, packageDescriptorLocation } =
|
|
103
|
-
await searchDescriptor(
|
|
104
|
-
|
|
120
|
+
await searchDescriptor(
|
|
121
|
+
moduleLocation,
|
|
122
|
+
loc => maybeReadDescriptorDefault(readPowers, loc),
|
|
123
|
+
{ log },
|
|
105
124
|
);
|
|
106
125
|
|
|
107
126
|
if (!data) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* These types describe the schema of a `compartment-map.json`, which
|
|
3
3
|
* in turn describes how to load and link an application from storage, like a
|
|
4
4
|
* file system, web host, or zip archive.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
5
7
|
*/
|
|
6
8
|
import type { SomePackagePolicy } from './policy-schema.js';
|
|
7
9
|
import type { LiteralUnion } from './typescript.js';
|
|
@@ -29,6 +31,11 @@ export type EntryDescriptor = {
|
|
|
29
31
|
*/
|
|
30
32
|
export type CompartmentDescriptor = {
|
|
31
33
|
label: string;
|
|
34
|
+
/**
|
|
35
|
+
* name of the parent directory of the package from which the compartment is derived,
|
|
36
|
+
* for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace.
|
|
37
|
+
*/
|
|
38
|
+
sourceDirname?: string;
|
|
32
39
|
/** shortest path of dependency names to this compartment */
|
|
33
40
|
path?: Array<string>;
|
|
34
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-map-schema.d.ts","sourceRoot":"","sources":["compartment-map-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"compartment-map-schema.d.ts","sourceRoot":"","sources":["compartment-map-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACxC,6BAA6B;IAC7B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,oCAAoC;IACpC,KAAK,EAAE,0BAA0B,CAAC;IAClC,qCAAqC;IACrC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,KAAK,GACL,MAAM,GACN,OAAO,GACP,MAAM,GACN,cAAc,GACd,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* These types describe the schema of a `compartment-map.json`, which
|
|
3
3
|
* in turn describes how to load and link an application from storage, like a
|
|
4
4
|
* file system, web host, or zip archive.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
5
7
|
*/
|
|
6
8
|
|
|
7
9
|
/* eslint-disable no-use-before-define */
|
|
@@ -35,6 +37,11 @@ export type EntryDescriptor = {
|
|
|
35
37
|
*/
|
|
36
38
|
export type CompartmentDescriptor = {
|
|
37
39
|
label: string;
|
|
40
|
+
/**
|
|
41
|
+
* name of the parent directory of the package from which the compartment is derived,
|
|
42
|
+
* for purposes of generating sourceURL comments that are most likely to unite with the original sources in an IDE workspace.
|
|
43
|
+
*/
|
|
44
|
+
sourceDirname?: string;
|
|
38
45
|
/** shortest path of dependency names to this compartment */
|
|
39
46
|
path?: Array<string>;
|
|
40
47
|
/**
|
package/src/types/external.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* External types of the compartment mapper.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
3
5
|
*/
|
|
4
6
|
import type { FinalStaticModuleType, StaticModuleType, ThirdPartyStaticModuleInterface, Transform } from 'ses';
|
|
5
|
-
import type {
|
|
7
|
+
import type { CompartmentDescriptor, CompartmentMapDescriptor, Language, LanguageForExtension } from './compartment-map-schema.js';
|
|
6
8
|
import type { HashFn, ReadFn, ReadPowers } from './powers.js';
|
|
7
9
|
/**
|
|
8
10
|
* Set of options available in the context of code execution.
|
|
@@ -25,24 +27,40 @@ export type ParseArchiveOptions = Partial<{
|
|
|
25
27
|
__native__: boolean;
|
|
26
28
|
}> & ModulesOption & CompartmentOption & ParserForLanguageOption & ExitModuleImportHookOption;
|
|
27
29
|
export type LoadArchiveOptions = ParseArchiveOptions;
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Options having an optional `log` property.
|
|
32
|
+
*/
|
|
33
|
+
export interface LogOptions {
|
|
34
|
+
/**
|
|
35
|
+
* A logger (for logging)
|
|
36
|
+
*/
|
|
37
|
+
log?: LogFn;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Options for `mapNodeModules()`
|
|
41
|
+
*/
|
|
42
|
+
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy & PolicyOption & LogOptions;
|
|
29
43
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
30
44
|
/** @deprecated renamed `conditions` to be consistent with Node.js */
|
|
31
45
|
tags: Set<string>;
|
|
32
46
|
/**
|
|
33
47
|
* Conditions for package `"imports"` and `"exports"`.
|
|
34
|
-
*
|
|
35
|
-
* entry package should be reachable.
|
|
48
|
+
*
|
|
36
49
|
* Common conditions include `"node"`, `"browser"`, `"require"`, `"import"`,
|
|
37
|
-
* and `"default"`.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
50
|
+
* and `"default"`. The conditions `"import"`, `"default"`, and `"endo"` need
|
|
51
|
+
* not be specified.
|
|
52
|
+
*
|
|
53
|
+
* _If using the `"development"` condition_ and you just need to map
|
|
54
|
+
* `devDependencies`, use the {@link MapNodeModulesOptions.dev dev} flag
|
|
55
|
+
* instead.
|
|
40
56
|
*/
|
|
41
57
|
conditions: Set<string>;
|
|
42
58
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
59
|
+
* If `true`, include packages from `devDependencies` in the resulting {@link CompartmentMapDescriptor}.
|
|
60
|
+
*
|
|
61
|
+
* Historically this is synonymous with the `"development"`
|
|
62
|
+
* {@link MapNodeModulesOptions.conditions condition}, but this behavior may
|
|
63
|
+
* be deprecated in a future version.
|
|
46
64
|
*/
|
|
47
65
|
dev: boolean;
|
|
48
66
|
/**
|
|
@@ -84,21 +102,55 @@ type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
|
84
102
|
* @deprecated Use `mapNodeModules()`.
|
|
85
103
|
*/
|
|
86
104
|
export type CompartmentMapForNodeModulesOptions = Omit<MapNodeModulesOptions, 'conditions' | 'tags'>;
|
|
87
|
-
export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption;
|
|
105
|
+
export type CaptureLiteOptions = ImportingOptions & LinkingOptions & PolicyOption & LogOptions;
|
|
88
106
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions & ModuleTransformsOption & ImportingOptions & ExitModuleImportHookOption & LinkingOptions;
|
|
89
107
|
export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions & SyncModuleTransformsOption & SyncImportingOptions & ExitModuleImportNowHookOption;
|
|
90
108
|
export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> & ArchiveLiteOptions;
|
|
109
|
+
export type BundleOptions = ArchiveOptions & {
|
|
110
|
+
/**
|
|
111
|
+
* Format of the bundle for purposes of importing modules from the surrounding
|
|
112
|
+
* environment.
|
|
113
|
+
* The default can be CommonJS or ESM but depends on neither `require` nor `import`
|
|
114
|
+
* for external modules, but errors early if the entrained modules need to import
|
|
115
|
+
* a host module.
|
|
116
|
+
* Specifying `cjs` makes `require` available for modules outside the bundle
|
|
117
|
+
* (exits to the import graph).
|
|
118
|
+
*/
|
|
119
|
+
format?: 'cjs';
|
|
120
|
+
/**
|
|
121
|
+
* Evaluates individual module functors in-place so stack traces represent
|
|
122
|
+
* original source locations better.
|
|
123
|
+
* The resulting script cannot be used on a web page with a no-unsafe-eval
|
|
124
|
+
* Content Security Policy.
|
|
125
|
+
*/
|
|
126
|
+
useEvaluate?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* A prefix for the sourceURL comment in each module format that supports
|
|
129
|
+
* sourceURL comments.
|
|
130
|
+
* Requires `useEvaluate` for effect.
|
|
131
|
+
*/
|
|
132
|
+
sourceUrlPrefix?: string;
|
|
133
|
+
};
|
|
91
134
|
export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> & SyncArchiveLiteOptions;
|
|
92
135
|
/**
|
|
93
136
|
* Options for `loadLocation()`
|
|
94
137
|
*/
|
|
95
|
-
export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions;
|
|
138
|
+
export type LoadLocationOptions = ArchiveOptions & SyncArchiveOptions & LogOptions;
|
|
96
139
|
/**
|
|
97
140
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
98
141
|
* `ReadNowPowers`) for dynamic require support
|
|
99
142
|
*/
|
|
100
|
-
export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions;
|
|
101
|
-
|
|
143
|
+
export type SyncImportLocationOptions = SyncArchiveOptions & ExecuteOptions & LogOptions;
|
|
144
|
+
/**
|
|
145
|
+
* Options for `importLocation()` without dynamic require support
|
|
146
|
+
*/
|
|
147
|
+
export type ImportLocationOptions = ArchiveOptions & ExecuteOptions & LogOptions;
|
|
148
|
+
export type ComputeSha512Option = {
|
|
149
|
+
/**
|
|
150
|
+
* For computing integrity hashes for module descriptors based on captured sources.
|
|
151
|
+
*/
|
|
152
|
+
computeSha512?: HashFn;
|
|
153
|
+
};
|
|
102
154
|
export type SearchSuffixesOption = {
|
|
103
155
|
/**
|
|
104
156
|
* Suffixes to search if the unmodified specifier is not found. Pass `[]` to
|
|
@@ -117,9 +169,17 @@ export type ModulesOption = {
|
|
|
117
169
|
modules?: Record<string, any>;
|
|
118
170
|
};
|
|
119
171
|
export type ExitModuleImportHookOption = {
|
|
172
|
+
/**
|
|
173
|
+
* For obtaining module descriptors for modules that must be provided
|
|
174
|
+
* by the eventual runtime execution environment, asynchronously.
|
|
175
|
+
*/
|
|
120
176
|
importHook?: ExitModuleImportHook;
|
|
121
177
|
};
|
|
122
178
|
export type ExitModuleImportNowHookOption = {
|
|
179
|
+
/**
|
|
180
|
+
* For obtaining module descriptors for modules that must be provided
|
|
181
|
+
* by the eventual runtime execution environment, synchronusly.
|
|
182
|
+
*/
|
|
123
183
|
importNowHook?: ExitModuleImportNowHook;
|
|
124
184
|
};
|
|
125
185
|
export type ParserForLanguageOption = {
|
|
@@ -134,6 +194,33 @@ export type ModuleTransformsOption = {
|
|
|
134
194
|
export type SyncModuleTransformsOption = {
|
|
135
195
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
136
196
|
};
|
|
197
|
+
export type ArchiveOnlyOption = {
|
|
198
|
+
/**
|
|
199
|
+
* Whether to prepare to create an archive or script bundle for execution
|
|
200
|
+
* elsewhere or elsewhen, as opposed to preparing to execute immediately.
|
|
201
|
+
*
|
|
202
|
+
* This has several practical effects.
|
|
203
|
+
*
|
|
204
|
+
* Archives expect to exit to potentially different host modules than the current
|
|
205
|
+
* host, but cannot instantiate those modules.
|
|
206
|
+
* For example, when preparing a bundle for execution in Node.js from within a
|
|
207
|
+
* web page, exiting to `node:fs` is appropriate but cannot be instantiated.
|
|
208
|
+
* So, the import hook will make a note of the exit and provide a stub module
|
|
209
|
+
* that throws an error if it is imported.
|
|
210
|
+
*
|
|
211
|
+
* Also, importing a module graph off a local medium immediately should
|
|
212
|
+
* inject a fully qualified source location into the module source,
|
|
213
|
+
* but sources loaded for an archive must not capture the original source
|
|
214
|
+
* location, but give the runtime an opportunity to inject a sourceURL.
|
|
215
|
+
*
|
|
216
|
+
* Also, the linker does not apply attenuations to the global environment
|
|
217
|
+
* if it is preparing to write an archive or script bundle.
|
|
218
|
+
*
|
|
219
|
+
* This option does not generally surface to users, but is set by the scenario,
|
|
220
|
+
* off for `importLocation`, on for `makeArchive` and `makeScript`.
|
|
221
|
+
*/
|
|
222
|
+
archiveOnly?: boolean;
|
|
223
|
+
};
|
|
137
224
|
export type PolicyOption = {
|
|
138
225
|
policy?: any;
|
|
139
226
|
};
|
|
@@ -198,10 +285,29 @@ export type CompartmentSources = Record<string, ModuleSource>;
|
|
|
198
285
|
export type ModuleSource = Partial<{
|
|
199
286
|
/** module loading error deferred to later stage */
|
|
200
287
|
deferredError: string;
|
|
201
|
-
/**
|
|
288
|
+
/**
|
|
289
|
+
* package-relative location.
|
|
290
|
+
* Not suitable for capture in an archive or bundle since it varies from host
|
|
291
|
+
* to host and would frustrate integrity hash checks.
|
|
292
|
+
*/
|
|
202
293
|
location: string;
|
|
203
294
|
/** fully qualified location */
|
|
204
295
|
sourceLocation: string;
|
|
296
|
+
/**
|
|
297
|
+
* directory name of the original source.
|
|
298
|
+
* This is safe to capture in a compartment map because it is _unlikely_ to
|
|
299
|
+
* vary between hosts.
|
|
300
|
+
* Package managers tend to drop a package in a consistently named location.
|
|
301
|
+
* If entry package is in a workspace, git enforces consistency.
|
|
302
|
+
* If entry package is the root of a repository, we rely on the developer
|
|
303
|
+
* to name the package consistently and suffer an inconsistent integrity hash
|
|
304
|
+
* otherwise.
|
|
305
|
+
* We do not currently capture this property in a compartment map because the
|
|
306
|
+
* schema validator currently (2024) deployed to Agoric blockchains does not
|
|
307
|
+
* tolerate compartment maps with unknown properties.
|
|
308
|
+
* https://github.com/endojs/endo/issues/2671
|
|
309
|
+
*/
|
|
310
|
+
sourceDirname: string;
|
|
205
311
|
bytes: Uint8Array;
|
|
206
312
|
/** in lowercase base-16 (hexadecimal) */
|
|
207
313
|
sha512: string;
|
|
@@ -275,7 +381,7 @@ type ParseArguments = [
|
|
|
275
381
|
sourceMapUrl: string;
|
|
276
382
|
readPowers: ReadFn | ReadPowers;
|
|
277
383
|
compartmentDescriptor: CompartmentDescriptor;
|
|
278
|
-
}>
|
|
384
|
+
}> & ArchiveOnlyOption
|
|
279
385
|
];
|
|
280
386
|
/**
|
|
281
387
|
* Result of a {@link ParseFn} or {@link AsyncParseFn}
|
|
@@ -295,5 +401,9 @@ export type ParseFn = {
|
|
|
295
401
|
* ParserImplementations}
|
|
296
402
|
*/
|
|
297
403
|
export type ParserForLanguage = Record<Language | string, ParserImplementation>;
|
|
404
|
+
/**
|
|
405
|
+
* Generic logging function accepted by various functions.
|
|
406
|
+
*/
|
|
407
|
+
export type LogFn = (message: string, ...args: any[]) => void;
|
|
298
408
|
export {};
|
|
299
409
|
//# sourceMappingURL=external.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["external.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["external.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,+BAA+B,EAC/B,SAAS,EACV,MAAM,KAAK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AI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
|
package/src/types/external.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* External types of the compartment mapper.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
/* eslint-disable no-use-before-define */
|
|
@@ -11,8 +13,8 @@ import type {
|
|
|
11
13
|
Transform,
|
|
12
14
|
} from 'ses';
|
|
13
15
|
import type {
|
|
14
|
-
CompartmentMapDescriptor,
|
|
15
16
|
CompartmentDescriptor,
|
|
17
|
+
CompartmentMapDescriptor,
|
|
16
18
|
Language,
|
|
17
19
|
LanguageForExtension,
|
|
18
20
|
} from './compartment-map-schema.js';
|
|
@@ -48,25 +50,44 @@ export type ParseArchiveOptions = Partial<{
|
|
|
48
50
|
|
|
49
51
|
export type LoadArchiveOptions = ParseArchiveOptions;
|
|
50
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Options having an optional `log` property.
|
|
55
|
+
*/
|
|
56
|
+
export interface LogOptions {
|
|
57
|
+
/**
|
|
58
|
+
* A logger (for logging)
|
|
59
|
+
*/
|
|
60
|
+
log?: LogFn;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Options for `mapNodeModules()`
|
|
65
|
+
*/
|
|
51
66
|
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy &
|
|
52
|
-
PolicyOption
|
|
67
|
+
PolicyOption &
|
|
68
|
+
LogOptions;
|
|
69
|
+
|
|
53
70
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
54
71
|
/** @deprecated renamed `conditions` to be consistent with Node.js */
|
|
55
72
|
tags: Set<string>;
|
|
56
73
|
/**
|
|
57
74
|
* Conditions for package `"imports"` and `"exports"`.
|
|
58
|
-
*
|
|
59
|
-
* entry package should be reachable.
|
|
75
|
+
*
|
|
60
76
|
* Common conditions include `"node"`, `"browser"`, `"require"`, `"import"`,
|
|
61
|
-
* and `"default"`.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
77
|
+
* and `"default"`. The conditions `"import"`, `"default"`, and `"endo"` need
|
|
78
|
+
* not be specified.
|
|
79
|
+
*
|
|
80
|
+
* _If using the `"development"` condition_ and you just need to map
|
|
81
|
+
* `devDependencies`, use the {@link MapNodeModulesOptions.dev dev} flag
|
|
82
|
+
* instead.
|
|
64
83
|
*/
|
|
65
84
|
conditions: Set<string>;
|
|
66
85
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
86
|
+
* If `true`, include packages from `devDependencies` in the resulting {@link CompartmentMapDescriptor}.
|
|
87
|
+
*
|
|
88
|
+
* Historically this is synonymous with the `"development"`
|
|
89
|
+
* {@link MapNodeModulesOptions.conditions condition}, but this behavior may
|
|
90
|
+
* be deprecated in a future version.
|
|
70
91
|
*/
|
|
71
92
|
dev: boolean;
|
|
72
93
|
/**
|
|
@@ -115,7 +136,8 @@ export type CompartmentMapForNodeModulesOptions = Omit<
|
|
|
115
136
|
|
|
116
137
|
export type CaptureLiteOptions = ImportingOptions &
|
|
117
138
|
LinkingOptions &
|
|
118
|
-
PolicyOption
|
|
139
|
+
PolicyOption &
|
|
140
|
+
LogOptions;
|
|
119
141
|
|
|
120
142
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
121
143
|
ModuleTransformsOption &
|
|
@@ -131,25 +153,67 @@ export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
|
131
153
|
export type ArchiveOptions = Omit<MapNodeModulesOptions, 'language'> &
|
|
132
154
|
ArchiveLiteOptions;
|
|
133
155
|
|
|
156
|
+
export type BundleOptions = ArchiveOptions & {
|
|
157
|
+
/**
|
|
158
|
+
* Format of the bundle for purposes of importing modules from the surrounding
|
|
159
|
+
* environment.
|
|
160
|
+
* The default can be CommonJS or ESM but depends on neither `require` nor `import`
|
|
161
|
+
* for external modules, but errors early if the entrained modules need to import
|
|
162
|
+
* a host module.
|
|
163
|
+
* Specifying `cjs` makes `require` available for modules outside the bundle
|
|
164
|
+
* (exits to the import graph).
|
|
165
|
+
*/
|
|
166
|
+
format?: 'cjs';
|
|
167
|
+
/**
|
|
168
|
+
* Evaluates individual module functors in-place so stack traces represent
|
|
169
|
+
* original source locations better.
|
|
170
|
+
* The resulting script cannot be used on a web page with a no-unsafe-eval
|
|
171
|
+
* Content Security Policy.
|
|
172
|
+
*/
|
|
173
|
+
useEvaluate?: boolean;
|
|
174
|
+
/**
|
|
175
|
+
* A prefix for the sourceURL comment in each module format that supports
|
|
176
|
+
* sourceURL comments.
|
|
177
|
+
* Requires `useEvaluate` for effect.
|
|
178
|
+
*/
|
|
179
|
+
sourceUrlPrefix?: string;
|
|
180
|
+
};
|
|
181
|
+
|
|
134
182
|
export type SyncArchiveOptions = Omit<MapNodeModulesOptions, 'languages'> &
|
|
135
183
|
SyncArchiveLiteOptions;
|
|
136
184
|
|
|
137
185
|
/**
|
|
138
186
|
* Options for `loadLocation()`
|
|
139
187
|
*/
|
|
140
|
-
export type LoadLocationOptions = ArchiveOptions &
|
|
188
|
+
export type LoadLocationOptions = ArchiveOptions &
|
|
189
|
+
SyncArchiveOptions &
|
|
190
|
+
LogOptions;
|
|
141
191
|
|
|
142
192
|
/**
|
|
143
193
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
144
194
|
* `ReadNowPowers`) for dynamic require support
|
|
145
195
|
*/
|
|
146
|
-
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
196
|
+
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
197
|
+
ExecuteOptions &
|
|
198
|
+
LogOptions;
|
|
147
199
|
|
|
148
|
-
|
|
200
|
+
/**
|
|
201
|
+
* Options for `importLocation()` without dynamic require support
|
|
202
|
+
*/
|
|
203
|
+
export type ImportLocationOptions = ArchiveOptions &
|
|
204
|
+
ExecuteOptions &
|
|
205
|
+
LogOptions;
|
|
149
206
|
|
|
150
207
|
// ////////////////////////////////////////////////////////////////////////////////
|
|
151
208
|
// Single Options
|
|
152
209
|
|
|
210
|
+
export type ComputeSha512Option = {
|
|
211
|
+
/**
|
|
212
|
+
* For computing integrity hashes for module descriptors based on captured sources.
|
|
213
|
+
*/
|
|
214
|
+
computeSha512?: HashFn;
|
|
215
|
+
};
|
|
216
|
+
|
|
153
217
|
export type SearchSuffixesOption = {
|
|
154
218
|
/**
|
|
155
219
|
* Suffixes to search if the unmodified specifier is not found. Pass `[]` to
|
|
@@ -171,10 +235,18 @@ export type ModulesOption = {
|
|
|
171
235
|
};
|
|
172
236
|
|
|
173
237
|
export type ExitModuleImportHookOption = {
|
|
238
|
+
/**
|
|
239
|
+
* For obtaining module descriptors for modules that must be provided
|
|
240
|
+
* by the eventual runtime execution environment, asynchronously.
|
|
241
|
+
*/
|
|
174
242
|
importHook?: ExitModuleImportHook;
|
|
175
243
|
};
|
|
176
244
|
|
|
177
245
|
export type ExitModuleImportNowHookOption = {
|
|
246
|
+
/**
|
|
247
|
+
* For obtaining module descriptors for modules that must be provided
|
|
248
|
+
* by the eventual runtime execution environment, synchronusly.
|
|
249
|
+
*/
|
|
178
250
|
importNowHook?: ExitModuleImportNowHook;
|
|
179
251
|
};
|
|
180
252
|
|
|
@@ -194,6 +266,34 @@ export type SyncModuleTransformsOption = {
|
|
|
194
266
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
195
267
|
};
|
|
196
268
|
|
|
269
|
+
export type ArchiveOnlyOption = {
|
|
270
|
+
/**
|
|
271
|
+
* Whether to prepare to create an archive or script bundle for execution
|
|
272
|
+
* elsewhere or elsewhen, as opposed to preparing to execute immediately.
|
|
273
|
+
*
|
|
274
|
+
* This has several practical effects.
|
|
275
|
+
*
|
|
276
|
+
* Archives expect to exit to potentially different host modules than the current
|
|
277
|
+
* host, but cannot instantiate those modules.
|
|
278
|
+
* For example, when preparing a bundle for execution in Node.js from within a
|
|
279
|
+
* web page, exiting to `node:fs` is appropriate but cannot be instantiated.
|
|
280
|
+
* So, the import hook will make a note of the exit and provide a stub module
|
|
281
|
+
* that throws an error if it is imported.
|
|
282
|
+
*
|
|
283
|
+
* Also, importing a module graph off a local medium immediately should
|
|
284
|
+
* inject a fully qualified source location into the module source,
|
|
285
|
+
* but sources loaded for an archive must not capture the original source
|
|
286
|
+
* location, but give the runtime an opportunity to inject a sourceURL.
|
|
287
|
+
*
|
|
288
|
+
* Also, the linker does not apply attenuations to the global environment
|
|
289
|
+
* if it is preparing to write an archive or script bundle.
|
|
290
|
+
*
|
|
291
|
+
* This option does not generally surface to users, but is set by the scenario,
|
|
292
|
+
* off for `importLocation`, on for `makeArchive` and `makeScript`.
|
|
293
|
+
*/
|
|
294
|
+
archiveOnly?: boolean;
|
|
295
|
+
};
|
|
296
|
+
|
|
197
297
|
export type PolicyOption = {
|
|
198
298
|
policy?: any;
|
|
199
299
|
};
|
|
@@ -289,10 +389,29 @@ export type CompartmentSources = Record<string, ModuleSource>;
|
|
|
289
389
|
export type ModuleSource = Partial<{
|
|
290
390
|
/** module loading error deferred to later stage */
|
|
291
391
|
deferredError: string;
|
|
292
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* package-relative location.
|
|
394
|
+
* Not suitable for capture in an archive or bundle since it varies from host
|
|
395
|
+
* to host and would frustrate integrity hash checks.
|
|
396
|
+
*/
|
|
293
397
|
location: string;
|
|
294
398
|
/** fully qualified location */
|
|
295
399
|
sourceLocation: string;
|
|
400
|
+
/**
|
|
401
|
+
* directory name of the original source.
|
|
402
|
+
* This is safe to capture in a compartment map because it is _unlikely_ to
|
|
403
|
+
* vary between hosts.
|
|
404
|
+
* Package managers tend to drop a package in a consistently named location.
|
|
405
|
+
* If entry package is in a workspace, git enforces consistency.
|
|
406
|
+
* If entry package is the root of a repository, we rely on the developer
|
|
407
|
+
* to name the package consistently and suffer an inconsistent integrity hash
|
|
408
|
+
* otherwise.
|
|
409
|
+
* We do not currently capture this property in a compartment map because the
|
|
410
|
+
* schema validator currently (2024) deployed to Agoric blockchains does not
|
|
411
|
+
* tolerate compartment maps with unknown properties.
|
|
412
|
+
* https://github.com/endojs/endo/issues/2671
|
|
413
|
+
*/
|
|
414
|
+
sourceDirname: string;
|
|
296
415
|
bytes: Uint8Array;
|
|
297
416
|
/** in lowercase base-16 (hexadecimal) */
|
|
298
417
|
sha512: string;
|
|
@@ -402,7 +521,8 @@ type ParseArguments = [
|
|
|
402
521
|
sourceMapUrl: string;
|
|
403
522
|
readPowers: ReadFn | ReadPowers;
|
|
404
523
|
compartmentDescriptor: CompartmentDescriptor;
|
|
405
|
-
}
|
|
524
|
+
}> &
|
|
525
|
+
ArchiveOnlyOption,
|
|
406
526
|
];
|
|
407
527
|
|
|
408
528
|
/**
|
|
@@ -426,3 +546,8 @@ export type ParseFn = { isSyncParser?: true } & ((
|
|
|
426
546
|
* ParserImplementations}
|
|
427
547
|
*/
|
|
428
548
|
export type ParserForLanguage = Record<Language | string, ParserImplementation>;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Generic logging function accepted by various functions.
|
|
552
|
+
*/
|
|
553
|
+
export type LogFn = (message: string, ...args: any[]) => void;
|