@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/src/archive.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module Provides mechanisms for creating archives (zip files with a
|
|
2
3
|
* `compartmeent-map.json` and a file for every static dependency of an entry
|
|
3
4
|
* module).
|
|
4
5
|
*
|
|
@@ -13,7 +14,16 @@
|
|
|
13
14
|
* for cases like XS native Compartments where pre-compilation is not
|
|
14
15
|
* necessary or where the dependency on Babel can be dererred to runtime.
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @import {
|
|
20
|
+
* ArchiveOptions,
|
|
21
|
+
* ReadFn,
|
|
22
|
+
* ReadPowers,
|
|
23
|
+
* HashPowers,
|
|
24
|
+
* WriteFn,
|
|
25
|
+
* } from './types.js'
|
|
26
|
+
*/
|
|
17
27
|
|
|
18
28
|
import { defaultParserForLanguage } from './archive-parsers.js';
|
|
19
29
|
import { mapNodeModules } from './node-modules.js';
|
|
@@ -27,12 +37,6 @@ import {
|
|
|
27
37
|
|
|
28
38
|
const { assign, create, freeze } = Object;
|
|
29
39
|
|
|
30
|
-
/** @import {ArchiveOptions} from './types.js' */
|
|
31
|
-
/** @import {ReadFn} from './types.js' */
|
|
32
|
-
/** @import {ReadPowers} from './types.js' */
|
|
33
|
-
/** @import {HashPowers} from './types.js' */
|
|
34
|
-
/** @import {WriteFn} from './types.js' */
|
|
35
|
-
|
|
36
40
|
/**
|
|
37
41
|
* Add the default parserForLanguage option.
|
|
38
42
|
* @param {ArchiveOptions} [options]
|
|
@@ -43,7 +47,8 @@ const assignParserForLanguage = (options = {}) => {
|
|
|
43
47
|
const parserForLanguage = freeze(
|
|
44
48
|
assign(create(null), defaultParserForLanguage, parserForLanguageOption),
|
|
45
49
|
);
|
|
46
|
-
|
|
50
|
+
const languages = Object.keys(parserForLanguage);
|
|
51
|
+
return { ...rest, parserForLanguage, languages };
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
/**
|
|
@@ -57,12 +62,16 @@ export const makeAndHashArchive = async (
|
|
|
57
62
|
moduleLocation,
|
|
58
63
|
options = {},
|
|
59
64
|
) => {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
65
|
+
const { parserForLanguage, languages, ...otherOptions } =
|
|
66
|
+
assignParserForLanguage(options);
|
|
67
|
+
const compartmentMap = await mapNodeModules(powers, moduleLocation, {
|
|
68
|
+
languages,
|
|
69
|
+
...otherOptions,
|
|
70
|
+
});
|
|
71
|
+
return makeAndHashArchiveFromMap(powers, compartmentMap, {
|
|
72
|
+
parserForLanguage,
|
|
73
|
+
...otherOptions,
|
|
74
|
+
});
|
|
66
75
|
};
|
|
67
76
|
|
|
68
77
|
/**
|
|
@@ -72,20 +81,41 @@ export const makeAndHashArchive = async (
|
|
|
72
81
|
* @returns {Promise<Uint8Array>}
|
|
73
82
|
*/
|
|
74
83
|
export const makeArchive = async (powers, moduleLocation, options = {}) => {
|
|
75
|
-
const {
|
|
76
|
-
|
|
84
|
+
const {
|
|
85
|
+
dev,
|
|
86
|
+
tags,
|
|
87
|
+
conditions = tags,
|
|
88
|
+
commonDependencies,
|
|
89
|
+
policy,
|
|
90
|
+
languageForExtension,
|
|
91
|
+
commonjsLanguageForExtension,
|
|
92
|
+
moduleLanguageForExtension,
|
|
93
|
+
workspaceLanguageForExtension,
|
|
94
|
+
workspaceCommonjsLanguageForExtension,
|
|
95
|
+
workspaceModuleLanguageForExtension,
|
|
96
|
+
parserForLanguage,
|
|
97
|
+
languages,
|
|
98
|
+
...otherOptions
|
|
99
|
+
} = assignParserForLanguage(options);
|
|
77
100
|
const compartmentMap = await mapNodeModules(powers, moduleLocation, {
|
|
78
101
|
dev,
|
|
79
102
|
conditions,
|
|
80
103
|
commonDependencies,
|
|
81
104
|
policy,
|
|
105
|
+
languageForExtension,
|
|
106
|
+
commonjsLanguageForExtension,
|
|
107
|
+
moduleLanguageForExtension,
|
|
108
|
+
workspaceLanguageForExtension,
|
|
109
|
+
workspaceCommonjsLanguageForExtension,
|
|
110
|
+
workspaceModuleLanguageForExtension,
|
|
111
|
+
languages,
|
|
82
112
|
});
|
|
83
113
|
|
|
84
|
-
return makeArchiveFromMap(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
114
|
+
return makeArchiveFromMap(powers, compartmentMap, {
|
|
115
|
+
parserForLanguage,
|
|
116
|
+
policy,
|
|
117
|
+
...otherOptions,
|
|
118
|
+
});
|
|
89
119
|
};
|
|
90
120
|
|
|
91
121
|
/**
|
|
@@ -95,16 +125,42 @@ export const makeArchive = async (powers, moduleLocation, options = {}) => {
|
|
|
95
125
|
* @returns {Promise<Uint8Array>}
|
|
96
126
|
*/
|
|
97
127
|
export const mapLocation = async (powers, moduleLocation, options = {}) => {
|
|
98
|
-
const {
|
|
128
|
+
const {
|
|
129
|
+
dev,
|
|
130
|
+
tags,
|
|
131
|
+
conditions = tags,
|
|
132
|
+
commonDependencies,
|
|
133
|
+
policy,
|
|
134
|
+
parserForLanguage,
|
|
135
|
+
languages,
|
|
136
|
+
languageForExtension,
|
|
137
|
+
commonjsLanguageForExtension,
|
|
138
|
+
moduleLanguageForExtension,
|
|
139
|
+
workspaceLanguageForExtension,
|
|
140
|
+
workspaceCommonjsLanguageForExtension,
|
|
141
|
+
workspaceModuleLanguageForExtension,
|
|
142
|
+
...otherOptions
|
|
143
|
+
} = assignParserForLanguage(options);
|
|
99
144
|
|
|
100
145
|
const compartmentMap = await mapNodeModules(powers, moduleLocation, {
|
|
101
146
|
dev,
|
|
102
147
|
conditions,
|
|
103
148
|
commonDependencies,
|
|
104
149
|
policy,
|
|
150
|
+
languages,
|
|
151
|
+
languageForExtension,
|
|
152
|
+
commonjsLanguageForExtension,
|
|
153
|
+
moduleLanguageForExtension,
|
|
154
|
+
workspaceLanguageForExtension,
|
|
155
|
+
workspaceCommonjsLanguageForExtension,
|
|
156
|
+
workspaceModuleLanguageForExtension,
|
|
105
157
|
});
|
|
106
158
|
|
|
107
|
-
return mapFromMap(powers, compartmentMap,
|
|
159
|
+
return mapFromMap(powers, compartmentMap, {
|
|
160
|
+
parserForLanguage,
|
|
161
|
+
policy,
|
|
162
|
+
...otherOptions,
|
|
163
|
+
});
|
|
108
164
|
};
|
|
109
165
|
|
|
110
166
|
/**
|
|
@@ -114,16 +170,42 @@ export const mapLocation = async (powers, moduleLocation, options = {}) => {
|
|
|
114
170
|
* @returns {Promise<string>}
|
|
115
171
|
*/
|
|
116
172
|
export const hashLocation = async (powers, moduleLocation, options = {}) => {
|
|
117
|
-
const {
|
|
173
|
+
const {
|
|
174
|
+
dev,
|
|
175
|
+
tags,
|
|
176
|
+
conditions = tags,
|
|
177
|
+
commonDependencies,
|
|
178
|
+
policy,
|
|
179
|
+
parserForLanguage,
|
|
180
|
+
languages,
|
|
181
|
+
languageForExtension,
|
|
182
|
+
commonjsLanguageForExtension,
|
|
183
|
+
moduleLanguageForExtension,
|
|
184
|
+
workspaceLanguageForExtension,
|
|
185
|
+
workspaceCommonjsLanguageForExtension,
|
|
186
|
+
workspaceModuleLanguageForExtension,
|
|
187
|
+
...otherOptions
|
|
188
|
+
} = assignParserForLanguage(options);
|
|
118
189
|
|
|
119
190
|
const compartmentMap = await mapNodeModules(powers, moduleLocation, {
|
|
120
191
|
dev,
|
|
121
192
|
conditions,
|
|
122
193
|
commonDependencies,
|
|
123
194
|
policy,
|
|
195
|
+
languages,
|
|
196
|
+
languageForExtension,
|
|
197
|
+
commonjsLanguageForExtension,
|
|
198
|
+
moduleLanguageForExtension,
|
|
199
|
+
workspaceLanguageForExtension,
|
|
200
|
+
workspaceCommonjsLanguageForExtension,
|
|
201
|
+
workspaceModuleLanguageForExtension,
|
|
124
202
|
});
|
|
125
203
|
|
|
126
|
-
return hashFromMap(powers, compartmentMap,
|
|
204
|
+
return hashFromMap(powers, compartmentMap, {
|
|
205
|
+
parserForLanguage,
|
|
206
|
+
policy,
|
|
207
|
+
...otherOptions,
|
|
208
|
+
});
|
|
127
209
|
};
|
|
128
210
|
|
|
129
211
|
/**
|
|
@@ -140,18 +222,40 @@ export const writeArchive = async (
|
|
|
140
222
|
moduleLocation,
|
|
141
223
|
options = {},
|
|
142
224
|
) => {
|
|
143
|
-
const {
|
|
225
|
+
const {
|
|
226
|
+
dev,
|
|
227
|
+
tags,
|
|
228
|
+
conditions = tags,
|
|
229
|
+
commonDependencies,
|
|
230
|
+
policy,
|
|
231
|
+
parserForLanguage,
|
|
232
|
+
languages,
|
|
233
|
+
languageForExtension,
|
|
234
|
+
commonjsLanguageForExtension,
|
|
235
|
+
moduleLanguageForExtension,
|
|
236
|
+
workspaceLanguageForExtension,
|
|
237
|
+
workspaceCommonjsLanguageForExtension,
|
|
238
|
+
workspaceModuleLanguageForExtension,
|
|
239
|
+
...otherOptions
|
|
240
|
+
} = assignParserForLanguage(options);
|
|
144
241
|
const compartmentMap = await mapNodeModules(readPowers, moduleLocation, {
|
|
145
242
|
dev,
|
|
146
243
|
conditions,
|
|
147
244
|
commonDependencies,
|
|
148
245
|
policy,
|
|
246
|
+
languageForExtension,
|
|
247
|
+
commonjsLanguageForExtension,
|
|
248
|
+
moduleLanguageForExtension,
|
|
249
|
+
workspaceLanguageForExtension,
|
|
250
|
+
workspaceCommonjsLanguageForExtension,
|
|
251
|
+
workspaceModuleLanguageForExtension,
|
|
252
|
+
languages,
|
|
149
253
|
});
|
|
150
254
|
return writeArchiveFromMap(
|
|
151
255
|
write,
|
|
152
256
|
readPowers,
|
|
153
257
|
archiveLocation,
|
|
154
258
|
compartmentMap,
|
|
155
|
-
|
|
259
|
+
{ policy, parserForLanguage, ...otherOptions },
|
|
156
260
|
);
|
|
157
261
|
};
|
package/src/bundle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["bundle.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["bundle.js"],"names":[],"mappings":"AAgOO,uCALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,yCAEJ,OAAO,CAAC,MAAM,CAAC,CAgN3B;AASM,mCANI,OAAO,QACP,MAAM,kBACN,MAAM,kBACN,MAAM,uDAahB;;;;;;;;;;;gBA5aa,MAAM,MAAM;;;;;;;cAOZ,MAAM,MAAM;;;;;;;oBAIZ,MAAM,MAAM;;;;;wBAIZ,MAAM,MAAM;;yBAKH,oBAAoB,SAA9B,OAAS;SAER,MAAM;qBACN,MAAM;qBACN,MAAM;YACN,MAAM;YACN,gBAAgB,GAAG,oBAAoB;qBACvC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;oBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;WACtB,UAAU;WACV,MAAM;gBACN,UAAU;;0BAID,oBAAoB,SAA9B,OAAS,aAEX,YAAY,CAAC,oBAAoB,CAAC,KAChC,UAAU;2BAIA,oBAAoB,SAA9B,OAAS;aAER,MAAM;mBACN,aAAa,CAAC,oBAAoB,CAAC;;4BAlDvC,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;oCAAZ,YAAY;6BAAZ,YAAY;sCAVZ,KAAK"}
|
package/src/bundle.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/* eslint no-shadow: 0 */
|
|
3
2
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @import {
|
|
5
|
+
* StaticModuleType,
|
|
6
|
+
* PrecompiledStaticModuleInterface
|
|
7
|
+
* } from 'ses'
|
|
8
|
+
* @import {
|
|
9
|
+
* ArchiveOptions,
|
|
10
|
+
* CompartmentDescriptor,
|
|
11
|
+
* CompartmentSources,
|
|
12
|
+
* MaybeReadPowers,
|
|
13
|
+
* ReadFn,
|
|
14
|
+
* ReadPowers,
|
|
15
|
+
* Sources,
|
|
16
|
+
* WriteFn,
|
|
17
|
+
* } from './types.js'
|
|
18
|
+
*/
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* @typedef {object} BundlerKit
|
|
@@ -231,6 +235,13 @@ export const makeBundle = async (readPowers, moduleLocation, options) => {
|
|
|
231
235
|
sourceMapHook = undefined,
|
|
232
236
|
parserForLanguage: parserForLanguageOption = {},
|
|
233
237
|
languageForExtension: languageForExtensionOption = {},
|
|
238
|
+
commonjsLanguageForExtension: commonjsLanguageForExtensionOption = {},
|
|
239
|
+
moduleLanguageForExtension: moduleLanguageForExtensionOption = {},
|
|
240
|
+
workspaceLanguageForExtension: workspaceLanguageForExtensionOption = {},
|
|
241
|
+
workspaceCommonjsLanguageForExtension:
|
|
242
|
+
workspaceCommonjsLanguageForExtensionOption = {},
|
|
243
|
+
workspaceModuleLanguageForExtension:
|
|
244
|
+
workspaceModuleLanguageForExtensionOption = {},
|
|
234
245
|
} = options || {};
|
|
235
246
|
const conditions = new Set(conditionsOption);
|
|
236
247
|
|
|
@@ -244,6 +255,27 @@ export const makeBundle = async (readPowers, moduleLocation, options) => {
|
|
|
244
255
|
const languageForExtension = Object.freeze(
|
|
245
256
|
Object.assign(Object.create(null), languageForExtensionOption),
|
|
246
257
|
);
|
|
258
|
+
const commonjsLanguageForExtension = Object.freeze(
|
|
259
|
+
Object.assign(Object.create(null), commonjsLanguageForExtensionOption),
|
|
260
|
+
);
|
|
261
|
+
const moduleLanguageForExtension = Object.freeze(
|
|
262
|
+
Object.assign(Object.create(null), moduleLanguageForExtensionOption),
|
|
263
|
+
);
|
|
264
|
+
const workspaceLanguageForExtension = Object.freeze(
|
|
265
|
+
Object.assign(Object.create(null), workspaceLanguageForExtensionOption),
|
|
266
|
+
);
|
|
267
|
+
const workspaceCommonjsLanguageForExtension = Object.freeze(
|
|
268
|
+
Object.assign(
|
|
269
|
+
Object.create(null),
|
|
270
|
+
workspaceCommonjsLanguageForExtensionOption,
|
|
271
|
+
),
|
|
272
|
+
);
|
|
273
|
+
const workspaceModuleLanguageForExtension = Object.freeze(
|
|
274
|
+
Object.assign(
|
|
275
|
+
Object.create(null),
|
|
276
|
+
workspaceModuleLanguageForExtensionOption,
|
|
277
|
+
),
|
|
278
|
+
);
|
|
247
279
|
|
|
248
280
|
const {
|
|
249
281
|
packageLocation,
|
|
@@ -262,7 +294,16 @@ export const makeBundle = async (readPowers, moduleLocation, options) => {
|
|
|
262
294
|
conditions,
|
|
263
295
|
packageDescriptor,
|
|
264
296
|
moduleSpecifier,
|
|
265
|
-
{
|
|
297
|
+
{
|
|
298
|
+
dev,
|
|
299
|
+
commonDependencies,
|
|
300
|
+
languageForExtension,
|
|
301
|
+
commonjsLanguageForExtension,
|
|
302
|
+
moduleLanguageForExtension,
|
|
303
|
+
workspaceLanguageForExtension,
|
|
304
|
+
workspaceCommonjsLanguageForExtension,
|
|
305
|
+
workspaceModuleLanguageForExtension,
|
|
306
|
+
},
|
|
266
307
|
);
|
|
267
308
|
|
|
268
309
|
const {
|
|
@@ -287,7 +328,6 @@ export const makeBundle = async (readPowers, moduleLocation, options) => {
|
|
|
287
328
|
makeImportHook,
|
|
288
329
|
moduleTransforms,
|
|
289
330
|
parserForLanguage,
|
|
290
|
-
languageForExtension,
|
|
291
331
|
});
|
|
292
332
|
await compartment.load(entryModuleSpecifier);
|
|
293
333
|
|
package/src/capture-lite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function captureFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?:
|
|
1
|
+
export function captureFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: CaptureLiteOptions | undefined): Promise<CaptureResult>;
|
|
2
2
|
import type { ReadFn } from './types.js';
|
|
3
3
|
import type { ReadPowers } from './types.js';
|
|
4
4
|
import type { CompartmentMapDescriptor } from './types.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { CaptureLiteOptions } from './types.js';
|
|
6
6
|
import type { CaptureResult } from './types.js';
|
|
7
7
|
//# sourceMappingURL=capture-lite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-lite.d.ts","sourceRoot":"","sources":["capture-lite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"capture-lite.d.ts","sourceRoot":"","sources":["capture-lite.js"],"names":[],"mappings":"AAsQO,uCALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,6CAEtB,OAAO,CAAC,aAAa,CAAC,CAmElC;4BA9RS,YAAY;gCAAZ,YAAY;8CAAZ,YAAY;wCAAZ,YAAY;mCAAZ,YAAY"}
|
package/src/capture-lite.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module
|
|
2
3
|
* This module provides {@link captureFromMap}, which only "captures" the
|
|
3
4
|
* compartment map descriptors and sources from a partially completed
|
|
4
5
|
* compartment map--_without_ creating an archive. The resulting compartment map
|
|
@@ -24,21 +25,22 @@
|
|
|
24
25
|
* contain original sources, so to import the archive with
|
|
25
26
|
* `src/import-archive-lite.js`, you will need to provide the archive parsers
|
|
26
27
|
* and entrain a runtime dependency on Babel.
|
|
27
|
-
*
|
|
28
|
-
* @module
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
// @ts-check
|
|
32
30
|
/* eslint no-shadow: 0 */
|
|
33
31
|
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @import {
|
|
34
|
+
* CaptureLiteOptions,
|
|
35
|
+
* CaptureResult,
|
|
36
|
+
* CompartmentDescriptor,
|
|
37
|
+
* CompartmentMapDescriptor,
|
|
38
|
+
* ModuleDescriptor,
|
|
39
|
+
* ReadFn,
|
|
40
|
+
* ReadPowers,
|
|
41
|
+
* Sources,
|
|
42
|
+
* } from './types.js'
|
|
43
|
+
*/
|
|
42
44
|
|
|
43
45
|
import {
|
|
44
46
|
assertCompartmentMap,
|
|
@@ -56,6 +58,8 @@ import { unpackReadPowers } from './powers.js';
|
|
|
56
58
|
|
|
57
59
|
const { freeze, assign, create, fromEntries, entries, keys } = Object;
|
|
58
60
|
|
|
61
|
+
const defaultCompartment = Compartment;
|
|
62
|
+
|
|
59
63
|
/**
|
|
60
64
|
* We attempt to produce compartment maps that are consistent regardless of
|
|
61
65
|
* whether the packages were originally laid out on disk for development or
|
|
@@ -253,27 +257,25 @@ const captureCompartmentMap = (compartmentMap, sources) => {
|
|
|
253
257
|
/**
|
|
254
258
|
* @param {ReadFn | ReadPowers} powers
|
|
255
259
|
* @param {CompartmentMapDescriptor} compartmentMap
|
|
256
|
-
* @param {
|
|
260
|
+
* @param {CaptureLiteOptions} [options]
|
|
257
261
|
* @returns {Promise<CaptureResult>}
|
|
258
262
|
*/
|
|
259
263
|
export const captureFromMap = async (powers, compartmentMap, options = {}) => {
|
|
260
264
|
const {
|
|
261
265
|
moduleTransforms,
|
|
266
|
+
syncModuleTransforms,
|
|
262
267
|
modules: exitModules = {},
|
|
263
268
|
searchSuffixes = undefined,
|
|
264
269
|
importHook: exitModuleImportHook = undefined,
|
|
265
270
|
policy = undefined,
|
|
266
271
|
sourceMapHook = undefined,
|
|
267
272
|
parserForLanguage: parserForLanguageOption = {},
|
|
268
|
-
|
|
273
|
+
Compartment = defaultCompartment,
|
|
269
274
|
} = options;
|
|
270
275
|
|
|
271
276
|
const parserForLanguage = freeze(
|
|
272
277
|
assign(create(null), parserForLanguageOption),
|
|
273
278
|
);
|
|
274
|
-
const languageForExtension = freeze(
|
|
275
|
-
assign(create(null), languageForExtensionOption),
|
|
276
|
-
);
|
|
277
279
|
|
|
278
280
|
const { read, computeSha512 } = unpackReadPowers(powers);
|
|
279
281
|
|
|
@@ -288,6 +290,7 @@ export const captureFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
288
290
|
const consolidatedExitModuleImportHook = exitModuleImportHookMaker({
|
|
289
291
|
modules: exitModules,
|
|
290
292
|
exitModuleImportHook,
|
|
293
|
+
entryCompartmentName,
|
|
291
294
|
});
|
|
292
295
|
|
|
293
296
|
const makeImportHook = makeImportHookMaker(read, entryCompartmentName, {
|
|
@@ -306,9 +309,10 @@ export const captureFromMap = async (powers, compartmentMap, options = {}) => {
|
|
|
306
309
|
resolve,
|
|
307
310
|
makeImportHook,
|
|
308
311
|
moduleTransforms,
|
|
312
|
+
syncModuleTransforms,
|
|
309
313
|
parserForLanguage,
|
|
310
|
-
languageForExtension,
|
|
311
314
|
archiveOnly: true,
|
|
315
|
+
Compartment,
|
|
312
316
|
});
|
|
313
317
|
await compartment.load(entryModuleSpecifier);
|
|
314
318
|
if (policy) {
|
package/src/compartment-map.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @type {(a: string, b: string) => number} */
|
|
2
2
|
export const stringCompare: (a: string, b: string) => number;
|
|
3
3
|
export function pathCompare(a: Array<string> | undefined, b: Array<string> | undefined): number;
|
|
4
|
-
export function assertCompartmentMap(allegedCompartmentMap: unknown, url?: string | undefined): asserts allegedCompartmentMap is
|
|
4
|
+
export function assertCompartmentMap(allegedCompartmentMap: unknown, url?: string | undefined): asserts allegedCompartmentMap is CompartmentMapDescriptor;
|
|
5
|
+
import type { CompartmentMapDescriptor } from './types.js';
|
|
5
6
|
//# sourceMappingURL=compartment-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-map.d.ts","sourceRoot":"","sources":["compartment-map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compartment-map.d.ts","sourceRoot":"","sources":["compartment-map.js"],"names":[],"mappings":"AAYA,+CAA+C;AAE/C,4BAFW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAE2B;AAc/D,+BAHI,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,KACzB,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,UAqCnC;AA8ZM,4DALI,OAAO,6BAEL,QAAQ,qBAAqB,IAAI,wBAAwB,CA+BrE;8CArf2C,YAAY"}
|
package/src/compartment-map.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/* Validates a compartment map against its schema. */
|
|
2
2
|
|
|
3
|
-
// @ts-check
|
|
4
3
|
import { assertPackagePolicy } from './policy-format.js';
|
|
5
4
|
|
|
5
|
+
/** @import {CompartmentMapDescriptor} from './types.js' */
|
|
6
|
+
|
|
6
7
|
// TODO convert to the new `||` assert style.
|
|
7
8
|
// Deferred because this file pervasively uses simple template strings rather than
|
|
8
9
|
// template strings tagged with `assert.details` (aka `X`), and uses
|
|
@@ -107,7 +108,7 @@ const assertConditions = (conditions, url) => {
|
|
|
107
108
|
* @param {string} url
|
|
108
109
|
*/
|
|
109
110
|
const assertCompartmentModule = (allegedModule, path, url) => {
|
|
110
|
-
const { compartment, module, ...extra } = allegedModule;
|
|
111
|
+
const { compartment, module, retained, ...extra } = allegedModule;
|
|
111
112
|
assertEmptyObject(
|
|
112
113
|
extra,
|
|
113
114
|
`${path} must not have extra properties, got ${q({
|
|
@@ -125,6 +126,13 @@ const assertCompartmentModule = (allegedModule, path, url) => {
|
|
|
125
126
|
'string',
|
|
126
127
|
`${path}.module must be a string, got ${q(module)} in ${q(url)}`,
|
|
127
128
|
);
|
|
129
|
+
if (retained !== undefined) {
|
|
130
|
+
assert.typeof(
|
|
131
|
+
retained,
|
|
132
|
+
'boolean',
|
|
133
|
+
`${path}.retained must be a boolean, got ${q(retained)} in ${q(url)}`,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
128
136
|
};
|
|
129
137
|
|
|
130
138
|
/**
|
|
@@ -464,7 +472,7 @@ const assertEntry = (allegedEntry, url) => {
|
|
|
464
472
|
/**
|
|
465
473
|
* @param {unknown} allegedCompartmentMap
|
|
466
474
|
* @param {string} [url]
|
|
467
|
-
* @returns {asserts allegedCompartmentMap is
|
|
475
|
+
* @returns {asserts allegedCompartmentMap is CompartmentMapDescriptor}
|
|
468
476
|
*/
|
|
469
477
|
|
|
470
478
|
export const assertCompartmentMap = (
|
package/src/extension.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["extension.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["extension.js"],"names":[],"mappings":"AAUO,yCAHI,MAAM,GACJ,MAAM,CAalB"}
|
package/src/extension.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
export function parseArchive(archiveBytes: Uint8Array, archiveLocation?: string | undefined, options?:
|
|
2
|
-
|
|
3
|
-
computeSha512?: HashFn | undefined;
|
|
4
|
-
modules?: Record<string, unknown> | undefined;
|
|
5
|
-
importHook?: ExitModuleImportHook | undefined;
|
|
6
|
-
Compartment?: typeof Compartment | undefined;
|
|
7
|
-
computeSourceLocation?: ComputeSourceLocationHook | undefined;
|
|
8
|
-
computeSourceMapLocation?: ComputeSourceMapLocationHook | undefined;
|
|
9
|
-
parserForLanguage?: ParserForLanguage | undefined;
|
|
10
|
-
languageForExtension?: LanguageForExtension | undefined;
|
|
11
|
-
} | undefined): Promise<Application>;
|
|
12
|
-
export function loadArchive(readPowers: ReadFn | ReadPowers, archiveLocation: string, options?: LoadArchiveOptions | undefined): Promise<Application>;
|
|
1
|
+
export function parseArchive(archiveBytes: Uint8Array, archiveLocation?: string | undefined, options?: ParseArchiveOptions | undefined): Promise<Application>;
|
|
2
|
+
export function loadArchive(readPowers: ReadFn | ReadPowers, archiveLocation: string, options?: ParseArchiveOptions | undefined): Promise<Application>;
|
|
13
3
|
export function importArchive(readPowers: ReadFn | ReadPowers, archiveLocation: string, options: LoadArchiveOptions): Promise<SomeObject>;
|
|
14
|
-
|
|
15
|
-
import type { HashFn } from './types.js';
|
|
16
|
-
import type { ExitModuleImportHook } from './types.js';
|
|
17
|
-
import type { ComputeSourceLocationHook } from './types.js';
|
|
18
|
-
import type { ComputeSourceMapLocationHook } from './types.js';
|
|
19
|
-
import type { ParserForLanguage } from './types.js';
|
|
20
|
-
import type { LanguageForExtension } from './types.js';
|
|
4
|
+
import type { ParseArchiveOptions } from './types.js';
|
|
21
5
|
import type { Application } from './types.js';
|
|
22
6
|
import type { ReadFn } from './types.js';
|
|
23
7
|
import type { ReadPowers } from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-archive-lite.d.ts","sourceRoot":"","sources":["import-archive-lite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"import-archive-lite.d.ts","sourceRoot":"","sources":["import-archive-lite.js"],"names":[],"mappings":"AAoPO,2CALI,UAAU,oFAGR,OAAO,CAAC,WAAW,CAAC,CA6JhC;AAQM,wCALI,MAAM,GAAG,UAAU,mBACnB,MAAM,8CAEJ,OAAO,CAAC,WAAW,CAAC,CAwBhC;AAQM,0CALI,MAAM,GAAG,UAAU,mBACnB,MAAM,WACN,kBAAkB,GAChB,OAAO,CAAC,UAAU,CAAC,CAK/B;yCApZS,YAAY;iCAAZ,YAAY;4BAAZ,YAAY;gCAAZ,YAAY;wCAAZ,YAAY;gCAAZ,YAAY"}
|