@endo/compartment-mapper 1.1.5 → 1.2.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 +17 -28
- package/archive-lite.d.ts +2 -0
- package/archive-lite.js +7 -0
- package/archive-parsers.d.ts +2 -0
- package/archive-parsers.js +1 -0
- package/capture-lite.d.ts +2 -0
- package/capture-lite.js +1 -0
- package/import-archive-lite.d.ts +2 -0
- package/import-archive-lite.js +5 -0
- package/import-archive-parsers.d.ts +2 -0
- package/import-archive-parsers.js +1 -0
- package/import-lite.d.ts +2 -0
- package/import-lite.js +1 -0
- package/import-parsers.d.ts +2 -0
- package/import-parsers.js +1 -0
- package/node-modules.d.ts +2 -0
- package/node-modules.js +1 -0
- package/package.json +23 -14
- package/src/archive-lite.d.ts +20 -0
- package/src/archive-lite.d.ts.map +1 -0
- package/src/archive-lite.js +495 -0
- package/src/archive-parsers.d.ts +11 -0
- package/src/archive-parsers.d.ts.map +1 -0
- package/src/archive-parsers.js +26 -0
- package/src/archive.d.ts +0 -6
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +94 -420
- package/src/bundle-cjs.d.ts +6 -17
- package/src/bundle-cjs.d.ts.map +1 -1
- package/src/bundle-cjs.js +11 -3
- package/src/bundle-json.d.ts +15 -0
- package/src/bundle-json.d.ts.map +1 -0
- package/src/bundle-json.js +24 -0
- package/src/bundle-mjs.d.ts +3 -19
- package/src/bundle-mjs.d.ts.map +1 -1
- package/src/bundle-mjs.js +6 -0
- package/src/bundle.d.ts +53 -10
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +118 -56
- package/src/capture-lite.d.ts +7 -0
- package/src/capture-lite.d.ts.map +1 -0
- package/src/capture-lite.js +324 -0
- package/src/compartment-map.d.ts +1 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +18 -37
- package/src/extension.d.ts.map +1 -1
- package/src/extension.js +2 -0
- package/src/import-archive-lite.d.ts +26 -0
- package/src/import-archive-lite.d.ts.map +1 -0
- package/src/import-archive-lite.js +455 -0
- package/src/import-archive-parsers.d.ts +9 -0
- package/src/import-archive-parsers.d.ts.map +1 -0
- package/src/import-archive-parsers.js +24 -0
- package/src/import-archive.d.ts +12 -9
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +74 -406
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +10 -3
- package/src/import-lite.d.ts +9 -0
- package/src/import-lite.d.ts.map +1 -0
- package/src/import-lite.js +121 -0
- package/src/import-parsers.d.ts +9 -0
- package/src/import-parsers.d.ts.map +1 -0
- package/src/import-parsers.js +24 -0
- package/src/import.d.ts +1 -4
- package/src/import.d.ts.map +1 -1
- package/src/import.js +44 -97
- package/src/infer-exports.d.ts +4 -4
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +29 -20
- package/src/json.d.ts.map +1 -1
- package/src/json.js +1 -0
- package/src/link.d.ts +4 -4
- package/src/link.d.ts.map +1 -1
- package/src/link.js +62 -19
- package/src/node-module-specifier.d.ts.map +1 -1
- package/src/node-module-specifier.js +5 -0
- package/src/node-modules.d.ts +13 -2
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +127 -40
- package/src/node-powers.d.ts +4 -4
- package/src/node-powers.d.ts.map +1 -1
- package/src/node-powers.js +10 -0
- package/src/parse-archive-cjs.d.ts +2 -2
- package/src/parse-archive-cjs.d.ts.map +1 -1
- package/src/parse-archive-cjs.js +4 -0
- package/src/parse-archive-mjs.d.ts +2 -2
- package/src/parse-archive-mjs.d.ts.map +1 -1
- package/src/parse-archive-mjs.js +5 -2
- package/src/parse-bytes.d.ts +2 -2
- package/src/parse-bytes.d.ts.map +1 -1
- package/src/parse-bytes.js +4 -0
- package/src/parse-cjs-shared-export-wrapper.d.ts +2 -2
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +16 -1
- package/src/parse-cjs.d.ts +2 -2
- package/src/parse-cjs.d.ts.map +1 -1
- package/src/parse-cjs.js +4 -0
- package/src/parse-json.d.ts +2 -2
- package/src/parse-json.d.ts.map +1 -1
- package/src/parse-json.js +2 -0
- package/src/parse-mjs.d.ts +2 -2
- package/src/parse-mjs.d.ts.map +1 -1
- package/src/parse-mjs.js +4 -2
- package/src/parse-pre-cjs.d.ts +2 -2
- package/src/parse-pre-cjs.d.ts.map +1 -1
- package/src/parse-pre-cjs.js +6 -0
- package/src/parse-pre-mjs.d.ts +2 -2
- package/src/parse-pre-mjs.d.ts.map +1 -1
- package/src/parse-pre-mjs.js +6 -0
- package/src/parse-text.d.ts +2 -2
- package/src/parse-text.d.ts.map +1 -1
- package/src/parse-text.js +5 -0
- package/src/policy-format.d.ts +8 -6
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +12 -3
- package/src/policy.d.ts +9 -9
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +3 -0
- package/src/powers.d.ts +1 -1
- package/src/powers.d.ts.map +1 -1
- package/src/powers.js +7 -0
- package/src/search.d.ts +4 -2
- package/src/search.d.ts.map +1 -1
- package/src/search.js +22 -16
- package/src/types.d.ts +121 -15
- package/src/types.d.ts.map +1 -1
- package/src/types.js +161 -19
- package/src/url.d.ts.map +1 -1
- package/src/url.js +5 -0
package/README.md
CHANGED
|
@@ -164,27 +164,15 @@ in a parent directory, under `node_modules`.
|
|
|
164
164
|
The `main`, `browser`, and `exports` properties determine the modules each
|
|
165
165
|
package exports to other compartments.
|
|
166
166
|
|
|
167
|
-
The `exports` property describes [package entry points] and can be influenced
|
|
168
|
-
by build
|
|
169
|
-
Currently, the only
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
> application for use in a web client.
|
|
177
|
-
> For this case, the compartment mapper would prepare a JSON manifest like an
|
|
178
|
-
> `importmap` (if not precisely an `importmap`).
|
|
179
|
-
> The "compartment map" would be consistent except when the dependency graph
|
|
180
|
-
> changes so updates could be automated with a `postinstall` script.
|
|
181
|
-
> Preparing a web application for production would follow a process similar to
|
|
182
|
-
> creating an archive, but with the `browser` build tag.
|
|
183
|
-
|
|
184
|
-
The `browser` and `require` tags are well-known but not yet supported.
|
|
185
|
-
The `browser` tag will apply for compartment maps generated for use on the web.
|
|
186
|
-
The `require` tag is a fallback for environments that do not support ESM and
|
|
187
|
-
will never apply.
|
|
167
|
+
The `exports` property describes [package entry points][] and can be influenced
|
|
168
|
+
by build _conditions_.
|
|
169
|
+
Currently, the only conditions supported by the compartment mapper are
|
|
170
|
+
`import`, `browser`, and `endo`.
|
|
171
|
+
The `imports` condition indicates that the module map should use ESM modules
|
|
172
|
+
over CommonJS modules or other variants, and `endo`.
|
|
173
|
+
The `browser` condition also draws in the `browser` property from
|
|
174
|
+
`package.json` instead of `main`.
|
|
175
|
+
The `endo` condition only indicates that this tool is in use.
|
|
188
176
|
|
|
189
177
|
If no `exports` apply to the root of the compartment namespace (`"."`),
|
|
190
178
|
the `main` property serves as a default.
|
|
@@ -284,7 +272,7 @@ Node.js platform.
|
|
|
284
272
|
> For browser applications, the compartment mapper would use the translator
|
|
285
273
|
> modules in two modes.
|
|
286
274
|
> During development, the compartment mapper would be able to load the
|
|
287
|
-
> translator in the client, with the `browser`
|
|
275
|
+
> translator in the client, with the `browser` condition.
|
|
288
276
|
> The compartment mapper would also be able to run the translator in a separate
|
|
289
277
|
> non-browser compartment during bundling, so the translator can be excluded
|
|
290
278
|
> from the production application and archived applications.
|
|
@@ -392,18 +380,19 @@ The compartment map shape:
|
|
|
392
380
|
// CompartmentMap describes how to prepare compartments
|
|
393
381
|
// to run an application.
|
|
394
382
|
type CompartmentMap = {
|
|
395
|
-
tags:
|
|
383
|
+
tags: Conditions,
|
|
396
384
|
entry: Entry,
|
|
397
385
|
compartments: Record<CompartmentName, Compartment>,
|
|
398
386
|
realms: Record<RealmName, Realm>, // TODO
|
|
399
387
|
};
|
|
400
388
|
|
|
401
|
-
//
|
|
389
|
+
// Conditions influence which modules are selected
|
|
390
|
+
// to represent the implementation of various modules.
|
|
402
391
|
// These may include terms like "browser", meaning
|
|
403
392
|
// each compartment uses the implementation of each
|
|
404
393
|
// module suitable for use in a browser environment.
|
|
405
|
-
type
|
|
406
|
-
type
|
|
394
|
+
type Conditions = Array<Condition>;
|
|
395
|
+
type Condition = string;
|
|
407
396
|
|
|
408
397
|
// Entry is a reference to the module that is the module to initially import.
|
|
409
398
|
type Entry = CompartmentModule;
|
|
@@ -485,7 +474,7 @@ type InternalModuleSpecifier = string;
|
|
|
485
474
|
// in the namespace of the foreign compartment.
|
|
486
475
|
type ExternalModuleSpecifier = string;
|
|
487
476
|
|
|
488
|
-
// ParserMap indicates which parser to use to construct
|
|
477
|
+
// ParserMap indicates which parser to use to construct module sources
|
|
489
478
|
// from sources, for each supported file extension.
|
|
490
479
|
// For parity with Node.js, a package with `"type": "module"` in its
|
|
491
480
|
// `package.json` would have a parser map of `{"js": "mjs", "cjs": "cjs",
|
|
@@ -500,7 +489,7 @@ type ParserMap = Record<Extension, Parser>;
|
|
|
500
489
|
// Extension is a file extension such as "js" for "main.js" or "" for "README".
|
|
501
490
|
type Extension = string;
|
|
502
491
|
|
|
503
|
-
// Parser is a union of built-in parsers for
|
|
492
|
+
// Parser is a union of built-in parsers for module sources.
|
|
504
493
|
// "mjs" corresponds to ECMAScript modules.
|
|
505
494
|
// "cjs" corresponds to CommonJS modules.
|
|
506
495
|
// "json" corresponds to JSON.
|
package/archive-lite.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultParserForLanguage } from './src/archive-parsers.js';
|
package/capture-lite.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { captureFromMap } from './src/capture-lite.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultParserForLanguage } from './src/import-archive-parsers.js';
|
package/import-lite.d.ts
ADDED
package/import-lite.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadFromMap, importFromMap } from './src/import-lite.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultParserForLanguage } from './src/import-parsers.js';
|
package/node-modules.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mapNodeModules } from './src/node-modules.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endo/compartment-mapper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The compartment mapper assembles Node applications in a sandbox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -28,16 +28,24 @@
|
|
|
28
28
|
"default": "./index.js"
|
|
29
29
|
},
|
|
30
30
|
"./import.js": "./import.js",
|
|
31
|
+
"./import-lite.js": "./import-lite.js",
|
|
32
|
+
"./import-parsers.js": "./import-parsers.js",
|
|
31
33
|
"./archive.js": "./archive.js",
|
|
34
|
+
"./archive-lite.js": "./archive-lite.js",
|
|
35
|
+
"./archive-parsers.js": "./archive-parsers.js",
|
|
36
|
+
"./capture-lite.js": "./capture-lite.js",
|
|
32
37
|
"./import-archive.js": "./import-archive.js",
|
|
38
|
+
"./import-archive-lite.js": "./import-archive-lite.js",
|
|
39
|
+
"./import-archive-parsers.js": "./import-archive-parsers.js",
|
|
33
40
|
"./bundle.js": "./bundle.js",
|
|
34
41
|
"./node-powers.js": "./node-powers.js",
|
|
42
|
+
"./node-modules.js": "./node-modules.js",
|
|
35
43
|
"./package.json": "./package.json"
|
|
36
44
|
},
|
|
37
45
|
"scripts": {
|
|
38
46
|
"build": "exit 0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
47
|
+
"prepack": "tsc --build tsconfig.build.json",
|
|
48
|
+
"postpack": "git clean -f '*.d.ts*'",
|
|
41
49
|
"cover": "c8 ava",
|
|
42
50
|
"lint": "yarn lint:types && yarn lint:eslint",
|
|
43
51
|
"lint-fix": "eslint --fix .",
|
|
@@ -47,22 +55,22 @@
|
|
|
47
55
|
"test": "ava"
|
|
48
56
|
},
|
|
49
57
|
"dependencies": {
|
|
50
|
-
"@endo/cjs-module-analyzer": "^1.0.
|
|
51
|
-
"@endo/
|
|
52
|
-
"@endo/zip": "^1.0.
|
|
53
|
-
"ses": "^1.
|
|
58
|
+
"@endo/cjs-module-analyzer": "^1.0.6",
|
|
59
|
+
"@endo/module-source": "^1.0.0",
|
|
60
|
+
"@endo/zip": "^1.0.6",
|
|
61
|
+
"ses": "^1.6.0"
|
|
54
62
|
},
|
|
55
63
|
"devDependencies": {
|
|
56
|
-
"ava": "^6.1.
|
|
57
|
-
"babel-eslint": "^10.0
|
|
64
|
+
"ava": "^6.1.3",
|
|
65
|
+
"babel-eslint": "^10.1.0",
|
|
58
66
|
"c8": "^7.14.0",
|
|
59
67
|
"eslint": "^8.57.0",
|
|
60
68
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
61
69
|
"eslint-config-prettier": "^9.1.0",
|
|
62
|
-
"eslint-plugin-eslint-comments": "^3.
|
|
63
|
-
"eslint-plugin-import": "^2.29.
|
|
70
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
71
|
+
"eslint-plugin-import": "^2.29.1",
|
|
64
72
|
"prettier": "^3.2.5",
|
|
65
|
-
"typescript": "
|
|
73
|
+
"typescript": "5.5.2"
|
|
66
74
|
},
|
|
67
75
|
"files": [
|
|
68
76
|
"LICENSE*",
|
|
@@ -93,12 +101,13 @@
|
|
|
93
101
|
},
|
|
94
102
|
"ava": {
|
|
95
103
|
"files": [
|
|
96
|
-
"test/**/test
|
|
104
|
+
"test/**/test-*.*",
|
|
105
|
+
"test/**/*.test.*"
|
|
97
106
|
],
|
|
98
107
|
"timeout": "2m"
|
|
99
108
|
},
|
|
100
109
|
"typeCoverage": {
|
|
101
110
|
"atLeast": 86.14
|
|
102
111
|
},
|
|
103
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "681b813ccb1fa177905dabf2ed3f5f248cb33ce7"
|
|
104
113
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function makeArchiveCompartmentMap(compartmentMap: CompartmentMapDescriptor, sources: Sources): {
|
|
2
|
+
archiveCompartmentMap: CompartmentMapDescriptor;
|
|
3
|
+
archiveSources: Sources;
|
|
4
|
+
};
|
|
5
|
+
export function makeAndHashArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveOptions | undefined): Promise<{
|
|
6
|
+
bytes: Uint8Array;
|
|
7
|
+
sha512?: string;
|
|
8
|
+
}>;
|
|
9
|
+
export function makeArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveOptions | undefined): Promise<Uint8Array>;
|
|
10
|
+
export function mapFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveOptions | undefined): Promise<Uint8Array>;
|
|
11
|
+
export function hashFromMap(powers: HashPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveOptions | undefined): Promise<string>;
|
|
12
|
+
export function writeArchiveFromMap(write: WriteFn, readPowers: ReadFn | ReadPowers, archiveLocation: string, compartmentMap: CompartmentMapDescriptor, options?: ArchiveOptions | undefined): Promise<void>;
|
|
13
|
+
import type { CompartmentMapDescriptor } from './types.js';
|
|
14
|
+
import type { Sources } from './types.js';
|
|
15
|
+
import type { ReadFn } from './types.js';
|
|
16
|
+
import type { ReadPowers } from './types.js';
|
|
17
|
+
import type { ArchiveOptions } from './types.js';
|
|
18
|
+
import type { HashPowers } from './types.js';
|
|
19
|
+
import type { WriteFn } from './types.js';
|
|
20
|
+
//# sourceMappingURL=archive-lite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archive-lite.d.ts","sourceRoot":"","sources":["archive-lite.js"],"names":[],"mappings":"AA2QO,0DAJI,wBAAwB,WACxB,OAAO,GACL;IAAC,qBAAqB,EAAE,wBAAwB,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAC,CAmCtF;AA6GM,kDALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,yCAEtB,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAmBzD;AAQM,2CALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,yCAEtB,OAAO,CAAC,UAAU,CAAC,CAS/B;AAQM,mCALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,yCAEtB,OAAO,CAAC,UAAU,CAAC,CAS/B;AAQM,oCALI,UAAU,kBACV,wBAAwB,yCAEtB,OAAO,CAAC,MAAM,CAAC,CAU3B;AASM,2CANI,OAAO,cACP,MAAM,GAAG,UAAU,mBACnB,MAAM,kBACN,wBAAwB,uDAgBlC;8CA1c2C,YAAY;6BAM7B,YAAY;4BAJb,YAAY;gCAER,YAAY;oCAPR,YAAY;gCAQhB,YAAY;6BAEf,YAAY"}
|