@endo/compartment-mapper 1.3.1 → 1.4.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 +50 -27
- package/archive-lite.d.ts +1 -0
- package/archive-lite.js +3 -0
- package/archive-parsers.d.ts +1 -0
- package/archive-parsers.js +3 -0
- package/archive.d.ts +1 -0
- package/archive.js +3 -0
- package/bundle.d.ts +1 -0
- package/bundle.js +3 -0
- package/capture-lite.d.ts +1 -0
- package/capture-lite.js +3 -0
- package/import-archive-lite.d.ts +1 -0
- package/import-archive-lite.js +3 -0
- package/import-archive-parsers.d.ts +1 -0
- package/import-archive-parsers.js +3 -0
- package/import-archive.d.ts +1 -0
- package/import-archive.js +3 -0
- package/import-lite.d.ts +1 -0
- package/import-lite.js +3 -0
- package/import-parsers.d.ts +1 -0
- package/import-parsers.js +3 -0
- package/import.d.ts +1 -0
- package/import.js +3 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/node-modules.d.ts +1 -0
- package/node-modules.js +3 -0
- package/node-powers.d.ts +1 -0
- package/node-powers.js +3 -0
- package/package.json +10 -14
- package/src/archive-lite.d.ts +6 -6
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +35 -33
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +132 -28
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +54 -14
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +21 -17
- package/src/compartment-map.d.ts +2 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +11 -3
- package/src/extension.d.ts.map +1 -1
- package/src/extension.js +1 -3
- package/src/import-archive-lite.d.ts +3 -19
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +43 -57
- package/src/import-archive-parsers.d.ts.map +1 -1
- package/src/import-archive-parsers.js +1 -0
- package/src/import-archive.d.ts +2 -2
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +15 -12
- package/src/import-hook.d.ts +2 -1
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +87 -76
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +23 -23
- package/src/import.d.ts.map +1 -1
- package/src/import.js +47 -23
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +2 -3
- package/src/json.d.ts.map +1 -1
- package/src/json.js +1 -2
- package/src/link.d.ts.map +1 -1
- package/src/link.js +12 -29
- package/src/map-parser.d.ts.map +1 -1
- package/src/map-parser.js +21 -16
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +2 -3
- package/src/node-modules.d.ts +9 -7
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +176 -87
- package/src/node-powers.d.ts +8 -8
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +29 -24
- package/src/parse-archive-cjs.d.ts +3 -2
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +5 -4
- package/src/parse-archive-mjs.d.ts +3 -2
- package/src/parse-archive-mjs.d.ts.map +1 -1
- package/src/parse-archive-mjs.js +7 -5
- package/src/parse-bytes.d.ts +3 -2
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +7 -5
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +7 -6
- package/src/parse-cjs.d.ts +3 -2
- package/src/parse-cjs.d.ts.map +1 -1
- package/src/parse-cjs.js +14 -5
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-json.js +6 -6
- package/src/parse-mjs.d.ts +3 -2
- package/src/parse-mjs.d.ts.map +1 -1
- package/src/parse-mjs.js +3 -3
- package/src/parse-pre-cjs.d.ts +3 -2
- package/src/parse-pre-cjs.d.ts.map +1 -1
- package/src/parse-pre-cjs.js +14 -4
- package/src/parse-pre-mjs.d.ts +3 -2
- package/src/parse-pre-mjs.d.ts.map +1 -1
- package/src/parse-pre-mjs.js +4 -3
- package/src/parse-text.d.ts +3 -2
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +6 -5
- package/src/policy-format.d.ts +1 -1
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +5 -7
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +15 -10
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +15 -12
- package/src/search.d.ts.map +1 -1
- package/src/search.js +10 -7
- package/src/types/compartment-map-schema.d.ts +98 -0
- package/src/types/compartment-map-schema.d.ts.map +1 -0
- package/src/types/compartment-map-schema.ts +116 -0
- package/src/types/external.d.ts +256 -0
- package/src/types/external.d.ts.map +1 -0
- package/src/types/external.ts +379 -0
- package/src/types/internal.d.ts +161 -0
- package/src/types/internal.d.ts.map +1 -0
- package/src/types/internal.ts +216 -0
- package/src/types/node-powers.d.ts +46 -0
- package/src/types/node-powers.d.ts.map +1 -0
- package/src/types/node-powers.ts +52 -0
- package/src/types/policy-schema.d.ts +81 -0
- package/src/types/policy-schema.d.ts.map +1 -0
- package/src/types/policy-schema.ts +131 -0
- package/src/types/policy.d.ts +20 -0
- package/src/types/policy.d.ts.map +1 -0
- package/src/types/policy.ts +42 -0
- package/src/types/powers.d.ts +83 -0
- package/src/types/powers.d.ts.map +1 -0
- package/src/types/powers.ts +120 -0
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -0
- package/src/types/typescript.ts +41 -0
- package/src/types-external.d.ts +14 -0
- package/src/types-external.js +2 -0
- package/src/types.d.ts +9 -787
- package/src/url.d.ts.map +1 -1
- package/src/url.js +2 -3
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -995
- package/types.d.ts +0 -19
package/README.md
CHANGED
|
@@ -204,6 +204,8 @@ does not exist, to the `index.js` file in the directory with the same name.
|
|
|
204
204
|
> `fetch` global, in conjunction with usable values for `import.meta.url` in
|
|
205
205
|
> ECMAScript modules or `__dirname` and `__filename` in CommonJS modules.
|
|
206
206
|
|
|
207
|
+
## Language Extensions
|
|
208
|
+
|
|
207
209
|
Officially beginning with Node.js 14, Node.js treats `.mjs` files as ECMAScript
|
|
208
210
|
modules and `.cjs` files as CommonJS modules.
|
|
209
211
|
The `.js` extension indicates a CommonJS module by default, to maintain
|
|
@@ -211,30 +213,6 @@ backward compatibility.
|
|
|
211
213
|
However, packages that have a `type` property that explicitly says `module`
|
|
212
214
|
will treat a `.js` file as an ECMAScript module.
|
|
213
215
|
|
|
214
|
-
This unforunately conflicts with packages written to work with the ECMAScript
|
|
215
|
-
module system emulator in the `esm` package on npm, which allows every file
|
|
216
|
-
with the `js` extension to be an ECMAScript module that presents itself to
|
|
217
|
-
Node.js as a CommonJS module.
|
|
218
|
-
To overcome such obstacles, the compartment mapper will accept a non-standard
|
|
219
|
-
`parsers` property in `package.json` that maps file extensions, specifically
|
|
220
|
-
`js` to the corresponding language name, one of `mjs` for ECMAScript modules,
|
|
221
|
-
`cjs` for CommonJS modules, and `json` for JSON modules.
|
|
222
|
-
All other language names are reserved and the defaults for files with the
|
|
223
|
-
extensions `cjs`, `mjs`, `json`, `text`, and `bytes` default to the language of
|
|
224
|
-
the same name unless overridden.
|
|
225
|
-
JSON modules export a default object resulting from the conventional JSON.parse
|
|
226
|
-
of the module's UTF-8 encoded bytes.
|
|
227
|
-
Text modules export a default string from the module's UTF-8 encoded bytes.
|
|
228
|
-
Bytes modules export a default ArrayBuffer capturing the module's bytes.
|
|
229
|
-
If compartment mapper sees `parsers`, it ignores `type`, so these can
|
|
230
|
-
contradict where using the `esm` emulator requires.
|
|
231
|
-
|
|
232
|
-
```json
|
|
233
|
-
{
|
|
234
|
-
"parsers": {"js": "mjs"}
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
216
|
Many Node.js applications using CommonJS modules expect to be able to `require`
|
|
239
217
|
a JSON file like `package.json`.
|
|
240
218
|
The compartment mapper supports loading JSON modules from any type of module.
|
|
@@ -252,9 +230,54 @@ As of Node.js 14, Node does not support loading ECMAScript modules from
|
|
|
252
230
|
CommonJS modules, so using this feature may limit compatibility with the
|
|
253
231
|
Node.js platform.
|
|
254
232
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
233
|
+
The compartment mapper supports language plugins.
|
|
234
|
+
The languages supported by default are:
|
|
235
|
+
|
|
236
|
+
- `mjs` for ECMAScript modules,
|
|
237
|
+
- `cjs` for CommonJS modules,
|
|
238
|
+
- `json` for JSON modules,
|
|
239
|
+
- `text` for UTF-8 encoded text files,
|
|
240
|
+
- `bytes` for any file, exporting a `Uint8Array` as `default`,
|
|
241
|
+
- `pre-mjs-json` for pre-compiled ECMAScript modules captured as JSON in
|
|
242
|
+
archives, and
|
|
243
|
+
- `pre-cjs-json` for pre-compiled CommonJS modules captured as JSON in
|
|
244
|
+
archives.
|
|
245
|
+
|
|
246
|
+
The compartment mapper accepts extensions to this set of languages with
|
|
247
|
+
the `parserForLanguage` option supported by many functions.
|
|
248
|
+
See `src/types/external.ts` for the type and expected behavior for
|
|
249
|
+
parsers.
|
|
250
|
+
|
|
251
|
+
These language identifiers are keys for the `moduleTransforms` and
|
|
252
|
+
`syncModuleTransforms` options, which may map each language to a transform
|
|
253
|
+
function.
|
|
254
|
+
The language identifiers are also the values for a `languageForExtension`,
|
|
255
|
+
`moduleLanguageForExtension`, and `commonjsLanguageForExtension` options to
|
|
256
|
+
configure additional extension-to-language mappings for a module and its
|
|
257
|
+
transitive dependencies.
|
|
258
|
+
|
|
259
|
+
For any package that has `type` set to `"module"` in its `package.json`,
|
|
260
|
+
`moduleLangaugeForExtension` will precede `languageForExtension`.
|
|
261
|
+
Packages with `type` set to `"commonjs"` or simply not set,
|
|
262
|
+
`commonjsLanguageForExtension` will precede `languageForExtension`.
|
|
263
|
+
This provides an hook for mapping TypeScript's `.ts` to either `.cts` or
|
|
264
|
+
`.mts`.
|
|
265
|
+
|
|
266
|
+
The analogous `workspaceLanguageForExtension`,
|
|
267
|
+
`workspaceCommonjsLanguageForExtension`, and
|
|
268
|
+
`workspaceModuleLanguageForExtension` options apply more specifically for
|
|
269
|
+
packages that are not under a `node_modules` directory, indicating that they
|
|
270
|
+
are in the set of linked workspaces and have not been built or published to
|
|
271
|
+
npm.
|
|
272
|
+
|
|
273
|
+
In the scope any given package, the `parsers` property in `package.json` may
|
|
274
|
+
override the extension-to-language mapping.
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"parsers": { "png": "bytes" }
|
|
279
|
+
}
|
|
280
|
+
```
|
|
258
281
|
|
|
259
282
|
> TODO
|
|
260
283
|
>
|
package/archive-lite.d.ts
CHANGED
package/archive-lite.js
CHANGED
package/archive-parsers.d.ts
CHANGED
package/archive-parsers.js
CHANGED
package/archive.d.ts
CHANGED
package/archive.js
CHANGED
package/bundle.d.ts
CHANGED
package/bundle.js
CHANGED
package/capture-lite.d.ts
CHANGED
package/capture-lite.js
CHANGED
package/import-archive-lite.d.ts
CHANGED
package/import-archive-lite.js
CHANGED
package/import-archive.d.ts
CHANGED
package/import-archive.js
CHANGED
package/import-lite.d.ts
CHANGED
package/import-lite.js
CHANGED
package/import-parsers.d.ts
CHANGED
package/import-parsers.js
CHANGED
package/import.d.ts
CHANGED
package/import.js
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/node-modules.d.ts
CHANGED
package/node-modules.js
CHANGED
package/node-powers.d.ts
CHANGED
package/node-powers.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endo/compartment-mapper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "The compartment mapper assembles Node applications in a sandbox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -21,12 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"main": "./index.js",
|
|
24
|
-
"types": "./types.d.ts",
|
|
25
24
|
"exports": {
|
|
26
|
-
".":
|
|
27
|
-
"types": "./types.d.ts",
|
|
28
|
-
"default": "./index.js"
|
|
29
|
-
},
|
|
25
|
+
".": "./index.js",
|
|
30
26
|
"./import.js": "./import.js",
|
|
31
27
|
"./import-lite.js": "./import-lite.js",
|
|
32
28
|
"./import-parsers.js": "./import-parsers.js",
|
|
@@ -55,11 +51,11 @@
|
|
|
55
51
|
"test": "ava"
|
|
56
52
|
},
|
|
57
53
|
"dependencies": {
|
|
58
|
-
"@endo/cjs-module-analyzer": "^1.0.
|
|
59
|
-
"@endo/module-source": "^1.1.
|
|
60
|
-
"@endo/trampoline": "^1.0.
|
|
61
|
-
"@endo/zip": "^1.0.
|
|
62
|
-
"ses": "^1.
|
|
54
|
+
"@endo/cjs-module-analyzer": "^1.0.9",
|
|
55
|
+
"@endo/module-source": "^1.1.2",
|
|
56
|
+
"@endo/trampoline": "^1.0.3",
|
|
57
|
+
"@endo/zip": "^1.0.9",
|
|
58
|
+
"ses": "^1.10.0"
|
|
63
59
|
},
|
|
64
60
|
"devDependencies": {
|
|
65
61
|
"ava": "^6.1.3",
|
|
@@ -70,8 +66,8 @@
|
|
|
70
66
|
"eslint-config-prettier": "^9.1.0",
|
|
71
67
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
72
68
|
"eslint-plugin-import": "^2.29.1",
|
|
73
|
-
"prettier": "^3.
|
|
74
|
-
"typescript": "~5.6.
|
|
69
|
+
"prettier": "^3.3.3",
|
|
70
|
+
"typescript": "~5.6.3"
|
|
75
71
|
},
|
|
76
72
|
"files": [
|
|
77
73
|
"./*.d.ts",
|
|
@@ -113,5 +109,5 @@
|
|
|
113
109
|
"typeCoverage": {
|
|
114
110
|
"atLeast": 86.14
|
|
115
111
|
},
|
|
116
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "5486ed1f238104716b6a8321b977fbc508ef80e1"
|
|
117
113
|
}
|
package/src/archive-lite.d.ts
CHANGED
|
@@ -2,19 +2,19 @@ export function makeArchiveCompartmentMap(compartmentMap: CompartmentMapDescript
|
|
|
2
2
|
archiveCompartmentMap: CompartmentMapDescriptor;
|
|
3
3
|
archiveSources: Sources;
|
|
4
4
|
};
|
|
5
|
-
export function makeAndHashArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?:
|
|
5
|
+
export function makeAndHashArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions | undefined): Promise<{
|
|
6
6
|
bytes: Uint8Array;
|
|
7
7
|
sha512?: string;
|
|
8
8
|
}>;
|
|
9
|
-
export function makeArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?:
|
|
10
|
-
export function mapFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?:
|
|
11
|
-
export function hashFromMap(powers: HashPowers, compartmentMap: CompartmentMapDescriptor, options?:
|
|
12
|
-
export function writeArchiveFromMap(write: WriteFn, readPowers: ReadFn | ReadPowers, archiveLocation: string, compartmentMap: CompartmentMapDescriptor, options?:
|
|
9
|
+
export function makeArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions | undefined): Promise<Uint8Array>;
|
|
10
|
+
export function mapFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions | undefined): Promise<Uint8Array>;
|
|
11
|
+
export function hashFromMap(powers: HashPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions | undefined): Promise<string>;
|
|
12
|
+
export function writeArchiveFromMap(write: WriteFn, readPowers: ReadFn | ReadPowers, archiveLocation: string, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions | undefined): Promise<void>;
|
|
13
13
|
import type { CompartmentMapDescriptor } from './types.js';
|
|
14
14
|
import type { Sources } from './types.js';
|
|
15
15
|
import type { ReadFn } from './types.js';
|
|
16
16
|
import type { ReadPowers } from './types.js';
|
|
17
|
-
import type {
|
|
17
|
+
import type { ArchiveLiteOptions } from './types.js';
|
|
18
18
|
import type { HashPowers } from './types.js';
|
|
19
19
|
import type { WriteFn } from './types.js';
|
|
20
20
|
//# sourceMappingURL=archive-lite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-lite.d.ts","sourceRoot":"","sources":["archive-lite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"archive-lite.d.ts","sourceRoot":"","sources":["archive-lite.js"],"names":[],"mappings":"AAiRO,0DAJI,wBAAwB,WACxB,OAAO,GACL;IAAC,qBAAqB,EAAE,wBAAwB,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAC,CAmCtF;AAyGM,kDALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAmBzD;AAQM,2CALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,UAAU,CAAC,CAS/B;AAQM,mCALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,UAAU,CAAC,CAS/B;AAQM,oCALI,UAAU,kBACV,wBAAwB,6CAEtB,OAAO,CAAC,MAAM,CAAC,CAU3B;AASM,2CANI,OAAO,cACP,MAAM,GAAG,UAAU,mBACnB,MAAM,kBACN,wBAAwB,2DAgBlC;8CAncS,YAAY;6BAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;wCAAZ,YAAY;gCAAZ,YAAY;6BAAZ,YAAY"}
|
package/src/archive-lite.js
CHANGED
|
@@ -28,20 +28,23 @@
|
|
|
28
28
|
* web platform makes further progress on virtual module loaers.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
// @ts-check
|
|
32
31
|
/* eslint no-shadow: 0 */
|
|
33
32
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @import {
|
|
35
|
+
* ArchiveLiteOptions,
|
|
36
|
+
* ArchiveWriter,
|
|
37
|
+
* CaptureSourceLocationHook,
|
|
38
|
+
* CompartmentDescriptor,
|
|
39
|
+
* CompartmentMapDescriptor,
|
|
40
|
+
* HashPowers,
|
|
41
|
+
* ModuleDescriptor,
|
|
42
|
+
* ReadFn,
|
|
43
|
+
* ReadPowers,
|
|
44
|
+
* Sources,
|
|
45
|
+
* WriteFn,
|
|
46
|
+
* } from './types.js'
|
|
47
|
+
*/
|
|
45
48
|
|
|
46
49
|
import { writeZip } from '@endo/zip';
|
|
47
50
|
import { resolve } from './node-module-specifier.js';
|
|
@@ -148,22 +151,25 @@ const translateCompartmentMap = (compartments, sources, compartmentRenames) => {
|
|
|
148
151
|
const result = create(null);
|
|
149
152
|
for (const compartmentName of keys(compartmentRenames)) {
|
|
150
153
|
const compartment = compartments[compartmentName];
|
|
151
|
-
const { name, label, retained, policy } = compartment;
|
|
152
|
-
if (
|
|
154
|
+
const { name, label, retained: compartmentRetained, policy } = compartment;
|
|
155
|
+
if (compartmentRetained) {
|
|
153
156
|
// rename module compartments
|
|
154
157
|
/** @type {Record<string, ModuleDescriptor>} */
|
|
155
158
|
const modules = create(null);
|
|
156
159
|
const compartmentModules = compartment.modules;
|
|
157
160
|
if (compartment.modules) {
|
|
158
161
|
for (const name of keys(compartmentModules).sort()) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
const { retained: moduleRetained, ...retainedModule } =
|
|
163
|
+
compartmentModules[name];
|
|
164
|
+
if (moduleRetained) {
|
|
165
|
+
if (retainedModule.compartment !== undefined) {
|
|
166
|
+
modules[name] = {
|
|
167
|
+
...retainedModule,
|
|
168
|
+
compartment: compartmentRenames[retainedModule.compartment],
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
modules[name] = retainedModule;
|
|
172
|
+
}
|
|
167
173
|
}
|
|
168
174
|
}
|
|
169
175
|
}
|
|
@@ -303,7 +309,7 @@ export const makeArchiveCompartmentMap = (compartmentMap, sources) => {
|
|
|
303
309
|
/**
|
|
304
310
|
* @param {ReadFn | ReadPowers} powers
|
|
305
311
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
306
|
-
* @param {
|
|
312
|
+
* @param {ArchiveLiteOptions} [options]
|
|
307
313
|
* @returns {Promise<{sources: Sources, compartmentMapBytes: Uint8Array, sha512?: string}>}
|
|
308
314
|
*/
|
|
309
315
|
const digestFromMap = async (powers, compartmentMap, options = {}) => {
|
|
@@ -316,15 +322,11 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
316
322
|
policy = undefined,
|
|
317
323
|
sourceMapHook = undefined,
|
|
318
324
|
parserForLanguage: parserForLanguageOption = {},
|
|
319
|
-
languageForExtension: languageForExtensionOption = {},
|
|
320
325
|
} = options;
|
|
321
326
|
|
|
322
327
|
const parserForLanguage = freeze(
|
|
323
328
|
assign(create(null), parserForLanguageOption),
|
|
324
329
|
);
|
|
325
|
-
const languageForExtension = freeze(
|
|
326
|
-
assign(create(null), languageForExtensionOption),
|
|
327
|
-
);
|
|
328
330
|
|
|
329
331
|
const { read, computeSha512 } = unpackReadPowers(powers);
|
|
330
332
|
|
|
@@ -339,6 +341,7 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
339
341
|
const consolidatedExitModuleImportHook = exitModuleImportHookMaker({
|
|
340
342
|
modules: exitModules,
|
|
341
343
|
exitModuleImportHook,
|
|
344
|
+
entryCompartmentName,
|
|
342
345
|
});
|
|
343
346
|
|
|
344
347
|
const makeImportHook = makeImportHookMaker(read, entryCompartmentName, {
|
|
@@ -358,7 +361,6 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
358
361
|
makeImportHook,
|
|
359
362
|
moduleTransforms,
|
|
360
363
|
parserForLanguage,
|
|
361
|
-
languageForExtension,
|
|
362
364
|
archiveOnly: true,
|
|
363
365
|
});
|
|
364
366
|
await compartment.load(entryModuleSpecifier);
|
|
@@ -404,7 +406,7 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
404
406
|
/**
|
|
405
407
|
* @param {ReadFn | ReadPowers} powers
|
|
406
408
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
407
|
-
* @param {
|
|
409
|
+
* @param {ArchiveLiteOptions} [options]
|
|
408
410
|
* @returns {Promise<{bytes: Uint8Array, sha512?: string}>}
|
|
409
411
|
*/
|
|
410
412
|
export const makeAndHashArchiveFromMap = async (
|
|
@@ -429,7 +431,7 @@ export const makeAndHashArchiveFromMap = async (
|
|
|
429
431
|
/**
|
|
430
432
|
* @param {ReadFn | ReadPowers} powers
|
|
431
433
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
432
|
-
* @param {
|
|
434
|
+
* @param {ArchiveLiteOptions} [options]
|
|
433
435
|
* @returns {Promise<Uint8Array>}
|
|
434
436
|
*/
|
|
435
437
|
export const makeArchiveFromMap = async (powers, compartmentMap, options) => {
|
|
@@ -444,7 +446,7 @@ export const makeArchiveFromMap = async (powers, compartmentMap, options) => {
|
|
|
444
446
|
/**
|
|
445
447
|
* @param {ReadFn | ReadPowers} powers
|
|
446
448
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
447
|
-
* @param {
|
|
449
|
+
* @param {ArchiveLiteOptions} [options]
|
|
448
450
|
* @returns {Promise<Uint8Array>}
|
|
449
451
|
*/
|
|
450
452
|
export const mapFromMap = async (powers, compartmentMap, options) => {
|
|
@@ -459,7 +461,7 @@ export const mapFromMap = async (powers, compartmentMap, options) => {
|
|
|
459
461
|
/**
|
|
460
462
|
* @param {HashPowers} powers
|
|
461
463
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
462
|
-
* @param {
|
|
464
|
+
* @param {ArchiveLiteOptions} [options]
|
|
463
465
|
* @returns {Promise<string>}
|
|
464
466
|
*/
|
|
465
467
|
export const hashFromMap = async (powers, compartmentMap, options) => {
|
|
@@ -477,7 +479,7 @@ export const hashFromMap = async (powers, compartmentMap, options) => {
|
|
|
477
479
|
* @param {ReadFn | ReadPowers} readPowers
|
|
478
480
|
* @param {string} archiveLocation
|
|
479
481
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
480
|
-
* @param {
|
|
482
|
+
* @param {ArchiveLiteOptions} [options]
|
|
481
483
|
*/
|
|
482
484
|
export const writeArchiveFromMap = async (
|
|
483
485
|
write,
|
package/src/archive.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["archive.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["archive.js"],"names":[],"mappings":"AA2DO,2CALI,MAAM,GAAG,UAAU,kBACnB,MAAM,yCAEJ,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAiBzD;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,yCAEJ,OAAO,CAAC,UAAU,CAAC,CAsC/B;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,yCAEJ,OAAO,CAAC,UAAU,CAAC,CAuC/B;AAQM,qCALI,UAAU,kBACV,MAAM,yCAEJ,OAAO,CAAC,MAAM,CAAC,CAuC3B;AASM,oCANI,OAAO,cACP,MAAM,GAAG,UAAU,mBACnB,MAAM,kBACN,MAAM,uDA8ChB;4BA5OS,YAAY;gCAAZ,YAAY;oCAAZ,YAAY;gCAAZ,YAAY;6BAAZ,YAAY"}
|