@endo/compartment-mapper 1.6.3 → 2.1.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.
Files changed (95) hide show
  1. package/package.json +24 -14
  2. package/src/archive-lite.d.ts +7 -7
  3. package/src/archive-lite.d.ts.map +1 -1
  4. package/src/archive-lite.js +81 -30
  5. package/src/archive.d.ts.map +1 -1
  6. package/src/archive.js +7 -0
  7. package/src/bundle-lite.d.ts +3 -3
  8. package/src/bundle-lite.d.ts.map +1 -1
  9. package/src/bundle-lite.js +19 -24
  10. package/src/bundle.d.ts +3 -3
  11. package/src/bundle.d.ts.map +1 -1
  12. package/src/bundle.js +19 -24
  13. package/src/capture-lite.d.ts +2 -2
  14. package/src/capture-lite.d.ts.map +1 -1
  15. package/src/capture-lite.js +243 -25
  16. package/src/compartment-map.d.ts +9 -2
  17. package/src/compartment-map.d.ts.map +1 -1
  18. package/src/compartment-map.js +738 -254
  19. package/src/digest.d.ts +22 -2
  20. package/src/digest.d.ts.map +1 -1
  21. package/src/digest.js +180 -57
  22. package/src/generic-graph.d.ts +7 -25
  23. package/src/generic-graph.d.ts.map +1 -1
  24. package/src/generic-graph.js +83 -108
  25. package/src/guards.d.ts +18 -0
  26. package/src/guards.d.ts.map +1 -0
  27. package/src/guards.js +109 -0
  28. package/src/hooks.md +124 -0
  29. package/src/import-archive-lite.d.ts.map +1 -1
  30. package/src/import-archive-lite.js +15 -11
  31. package/src/import-archive.d.ts +5 -19
  32. package/src/import-archive.d.ts.map +1 -1
  33. package/src/import-archive.js +7 -27
  34. package/src/import-hook.d.ts +4 -3
  35. package/src/import-hook.d.ts.map +1 -1
  36. package/src/import-hook.js +140 -70
  37. package/src/import-lite.d.ts +6 -6
  38. package/src/import-lite.d.ts.map +1 -1
  39. package/src/import-lite.js +8 -5
  40. package/src/import.d.ts +3 -3
  41. package/src/import.d.ts.map +1 -1
  42. package/src/import.js +16 -6
  43. package/src/infer-exports.d.ts +4 -2
  44. package/src/infer-exports.d.ts.map +1 -1
  45. package/src/infer-exports.js +172 -23
  46. package/src/link.d.ts +4 -3
  47. package/src/link.d.ts.map +1 -1
  48. package/src/link.js +122 -52
  49. package/src/node-modules.d.ts +4 -3
  50. package/src/node-modules.d.ts.map +1 -1
  51. package/src/node-modules.js +513 -151
  52. package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
  53. package/src/parse-cjs-shared-export-wrapper.js +3 -1
  54. package/src/pattern-replacement.d.ts +6 -0
  55. package/src/pattern-replacement.d.ts.map +1 -0
  56. package/src/pattern-replacement.js +198 -0
  57. package/src/policy-format.d.ts +22 -5
  58. package/src/policy-format.d.ts.map +1 -1
  59. package/src/policy-format.js +342 -108
  60. package/src/policy.d.ts +13 -28
  61. package/src/policy.d.ts.map +1 -1
  62. package/src/policy.js +161 -106
  63. package/src/types/canonical-name.d.ts +97 -0
  64. package/src/types/canonical-name.d.ts.map +1 -0
  65. package/src/types/canonical-name.ts +151 -0
  66. package/src/types/compartment-map-schema.d.ts +121 -35
  67. package/src/types/compartment-map-schema.d.ts.map +1 -1
  68. package/src/types/compartment-map-schema.ts +211 -37
  69. package/src/types/external.d.ts +240 -76
  70. package/src/types/external.d.ts.map +1 -1
  71. package/src/types/external.ts +305 -74
  72. package/src/types/generic-graph.d.ts +8 -2
  73. package/src/types/generic-graph.d.ts.map +1 -1
  74. package/src/types/generic-graph.ts +7 -2
  75. package/src/types/internal.d.ts +31 -50
  76. package/src/types/internal.d.ts.map +1 -1
  77. package/src/types/internal.ts +60 -58
  78. package/src/types/node-modules.d.ts +112 -14
  79. package/src/types/node-modules.d.ts.map +1 -1
  80. package/src/types/node-modules.ts +152 -13
  81. package/src/types/pattern-replacement.d.ts +62 -0
  82. package/src/types/pattern-replacement.d.ts.map +1 -0
  83. package/src/types/pattern-replacement.ts +70 -0
  84. package/src/types/policy-schema.d.ts +26 -11
  85. package/src/types/policy-schema.d.ts.map +1 -1
  86. package/src/types/policy-schema.ts +29 -16
  87. package/src/types/policy.d.ts +6 -2
  88. package/src/types/policy.d.ts.map +1 -1
  89. package/src/types/policy.ts +7 -2
  90. package/src/types/powers.d.ts +11 -9
  91. package/src/types/powers.d.ts.map +1 -1
  92. package/src/types/powers.ts +11 -10
  93. package/src/types/typescript.d.ts +28 -0
  94. package/src/types/typescript.d.ts.map +1 -1
  95. package/src/types/typescript.ts +37 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@endo/compartment-mapper",
3
- "version": "1.6.3",
3
+ "version": "2.1.0",
4
4
  "description": "The compartment mapper assembles Node applications in a sandbox",
5
5
  "keywords": [
6
6
  "node",
@@ -49,35 +49,41 @@
49
49
  },
50
50
  "scripts": {
51
51
  "build": "exit 0",
52
- "prepack": "tsc --build tsconfig.build.json",
53
- "postpack": "git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\"",
54
- "cover": "c8 ava",
52
+ "prepack": "git clean -fX -e node_modules/ && tsc --build tsconfig.build.json",
53
+ "postpack": "git clean -fX -e node_modules/",
54
+ "cover": "c8 ava --config test/_ava-ses.config.js",
55
55
  "lint": "yarn lint:types && yarn lint:eslint",
56
56
  "lint-fix": "eslint --fix .",
57
57
  "lint:eslint": "eslint .",
58
58
  "lint:types": "tsc",
59
59
  "prettier-fixtures": "prettier --write --with-node-modules './test/fixtures-*/**/*.*js'",
60
- "test": "ava"
60
+ "test": "ses-ava"
61
61
  },
62
62
  "dependencies": {
63
63
  "@endo/cjs-module-analyzer": "^1.0.11",
64
- "@endo/module-source": "^1.3.3",
64
+ "@endo/module-source": "^1.4.1",
65
65
  "@endo/path-compare": "^1.1.0",
66
66
  "@endo/trampoline": "^1.0.5",
67
- "@endo/zip": "^1.0.11",
68
- "ses": "^1.14.0"
67
+ "@endo/zip": "^1.1.0",
68
+ "ses": "^2.0.0"
69
69
  },
70
70
  "devDependencies": {
71
- "ava": "^6.1.3",
71
+ "@endo/env-options": "^1.1.11",
72
+ "@endo/evasive-transform": "^2.1.0",
73
+ "@endo/eventual-send": "^1.5.0",
74
+ "@endo/init": "^1.1.13",
75
+ "@endo/ses-ava": "^1.4.1",
76
+ "ava": "catalog:dev",
72
77
  "babel-eslint": "^10.1.0",
73
- "c8": "^7.14.0",
74
- "eslint": "^8.57.1",
78
+ "c8": "catalog:dev",
79
+ "eslint": "catalog:dev",
75
80
  "eslint-config-airbnb-base": "^15.0.0",
76
81
  "eslint-config-prettier": "^9.1.0",
77
82
  "eslint-plugin-eslint-comments": "^3.2.0",
78
83
  "eslint-plugin-import": "^2.31.0",
79
84
  "prettier": "^3.5.3",
80
- "typescript": "~5.8.3"
85
+ "ses": "workspace:^",
86
+ "typescript": "catalog:dev"
81
87
  },
82
88
  "files": [
83
89
  "./*.d.ts",
@@ -112,12 +118,16 @@
112
118
  },
113
119
  "ava": {
114
120
  "files": [
115
- "test/**/*.test.*"
121
+ "test/**/*.test.*",
122
+ "!test/**/*.node-condition.test.*"
116
123
  ],
117
124
  "timeout": "2m"
118
125
  },
126
+ "sesAvaConfigs": {
127
+ "node-condition": "test/_ava-node-condition.config.js"
128
+ },
119
129
  "typeCoverage": {
120
130
  "atLeast": 86.14
121
131
  },
122
- "gitHead": "9815aea9541f241389d2135c6097a7442bdffa17"
132
+ "gitHead": "e74ed050e9d1122d692b00ee14971299c6afbf30"
123
133
  }
@@ -1,13 +1,13 @@
1
- export function makeArchiveCompartmentMap(compartmentMap: CompartmentMapDescriptor, sources: Sources): ArchiveResult;
2
- export function makeAndHashArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<{
1
+ export function makeArchiveCompartmentMap(compartmentMap: PackageCompartmentMapDescriptor, sources: Sources): ArchiveResult;
2
+ export function makeAndHashArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<{
3
3
  bytes: Uint8Array;
4
4
  sha512?: string;
5
5
  }>;
6
- export function makeArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<Uint8Array>;
7
- export function mapFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<Uint8Array>;
8
- export function hashFromMap(powers: HashPowers, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<string>;
9
- export function writeArchiveFromMap(write: WriteFn, readPowers: ReadFn | ReadPowers, archiveLocation: string, compartmentMap: CompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<void>;
10
- import type { CompartmentMapDescriptor } from './types.js';
6
+ export function makeArchiveFromMap(powers: ReadFn | ReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<Uint8Array>;
7
+ export function mapFromMap(powers: ReadFn | ReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<Uint8Array>;
8
+ export function hashFromMap(powers: HashPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<string>;
9
+ export function writeArchiveFromMap(write: WriteFn, readPowers: ReadFn | ReadPowers, archiveLocation: string, compartmentMap: PackageCompartmentMapDescriptor, options?: ArchiveLiteOptions): Promise<void>;
10
+ import type { PackageCompartmentMapDescriptor } from './types.js';
11
11
  import type { Sources } from './types.js';
12
12
  import type { ArchiveResult } from './types.js';
13
13
  import type { ReadFn } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"archive-lite.d.ts","sourceRoot":"","sources":["archive-lite.js"],"names":[],"mappings":"AAmHO,0DAJI,wBAAwB,WACxB,OAAO,GACL,aAAa,CAiBzB;AAyGM,kDALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,YACxB,kBAAkB,GAChB,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAmBzD;AAQM,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;gCAAZ,YAAY;6BAAZ,YAAY"}
@@ -1,4 +1,5 @@
1
- /* Provides functions to create an archive (zip file with a
1
+ /**
2
+ * Provides functions to create an archive (zip file with a
2
3
  * compartment-map.json) from a partially completed compartment map (it must
3
4
  * mention all packages/compartments as well as inter-compartment references
4
5
  * but does not contain an entry for every module reachable from its entry
@@ -26,6 +27,8 @@
26
27
  * In fruition of https://github.com/endojs/endo/issues/400, we will be able to
27
28
  * use original source archives on XS and Node.js, but not on the web until the
28
29
  * web platform makes further progress on virtual module loaers.
30
+ *
31
+ * @module
29
32
  */
30
33
 
31
34
  /* eslint no-shadow: 0 */
@@ -36,8 +39,10 @@
36
39
  * ArchiveResult,
37
40
  * ArchiveWriter,
38
41
  * CaptureSourceLocationHook,
39
- * CompartmentMapDescriptor,
42
+ * CompartmentsRenameFn,
43
+ * FileUrlString,
40
44
  * HashPowers,
45
+ * PackageCompartmentMapDescriptor,
41
46
  * ReadFn,
42
47
  * ReadPowers,
43
48
  * Sources,
@@ -55,19 +60,12 @@ import {
55
60
  import { unpackReadPowers } from './powers.js';
56
61
  import { detectAttenuators } from './policy.js';
57
62
  import { digestCompartmentMap } from './digest.js';
63
+ import { stringCompare } from './compartment-map.js';
64
+ import { ATTENUATORS_COMPARTMENT } from './policy-format.js';
58
65
 
59
66
  const textEncoder = new TextEncoder();
60
67
 
61
- const { assign, create, freeze } = Object;
62
-
63
- /**
64
- * @param {string} rel - a relative URL
65
- * @param {string} abs - a fully qualified URL
66
- * @returns {string}
67
- */
68
- const resolveLocation = (rel, abs) => new URL(rel, abs).toString();
69
-
70
- const { keys } = Object;
68
+ const { assign, create, freeze, keys } = Object;
71
69
 
72
70
  /**
73
71
  * @param {ArchiveWriter} archive
@@ -77,12 +75,10 @@ const addSourcesToArchive = async (archive, sources) => {
77
75
  await null;
78
76
  for (const compartment of keys(sources).sort()) {
79
77
  const modules = sources[compartment];
80
- const compartmentLocation = resolveLocation(`${compartment}/`, 'file:///');
81
78
  for (const specifier of keys(modules).sort()) {
82
- const { bytes, location } = modules[specifier];
83
- if (location !== undefined) {
84
- const moduleLocation = resolveLocation(location, compartmentLocation);
85
- const path = new URL(moduleLocation).pathname.slice(1); // elide initial "/"
79
+ if ('location' in modules[specifier]) {
80
+ const { bytes, location } = modules[specifier];
81
+ const path = `${compartment}/${location}`;
86
82
  if (bytes !== undefined) {
87
83
  // eslint-disable-next-line no-await-in-loop
88
84
  await archive.write(path, bytes);
@@ -100,8 +96,8 @@ const captureSourceLocations = async (sources, captureSourceLocation) => {
100
96
  for (const compartmentName of keys(sources).sort()) {
101
97
  const modules = sources[compartmentName];
102
98
  for (const moduleSpecifier of keys(modules).sort()) {
103
- const { sourceLocation } = modules[moduleSpecifier];
104
- if (sourceLocation !== undefined) {
99
+ if ('sourceLocation' in modules[moduleSpecifier]) {
100
+ const { sourceLocation } = modules[moduleSpecifier];
105
101
  captureSourceLocation(compartmentName, moduleSpecifier, sourceLocation);
106
102
  }
107
103
  }
@@ -109,18 +105,69 @@ const captureSourceLocations = async (sources, captureSourceLocation) => {
109
105
  };
110
106
 
111
107
  /**
112
- * @param {CompartmentMapDescriptor} compartmentMap
108
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
113
109
  * @param {Sources} sources
114
110
  * @returns {ArchiveResult}
115
111
  */
116
112
  export const makeArchiveCompartmentMap = (compartmentMap, sources) => {
113
+ /** @type {CompartmentsRenameFn<FileUrlString, string>} */
114
+ const renameCompartments = compartments => {
115
+ /** @type {Record<FileUrlString, string>} */
116
+ const compartmentRenames = create(null);
117
+
118
+ /**
119
+ * Get the new name of format `packageName-v${version}` compartments (except
120
+ * for the attenuators compartment)
121
+ * @param {string} name
122
+ * @param {string} version
123
+ * @returns {string}
124
+ */
125
+ const getCompartmentName = (name, version) => {
126
+ const compartment = compartments[name];
127
+ return ATTENUATORS_COMPARTMENT === compartment.name
128
+ ? compartment.name
129
+ : `${compartment.name}-v${version}`;
130
+ };
131
+
132
+ // The sort below combines two comparators to avoid depending on sort
133
+ // stability, which became standard as recently as 2019.
134
+ // If that date seems quaint, please accept my regards from the distant past.
135
+ // We are very proud of you.
136
+ const compartmentsByLabel =
137
+ /** @type {Array<{name: FileUrlString, packageName: string, compartmentName: string}>} */ (
138
+ Object.entries(compartments)
139
+ .map(([name, compartment]) => ({
140
+ name,
141
+ packageName: compartments[name].name,
142
+ compartmentName: getCompartmentName(name, compartment.version),
143
+ }))
144
+ .sort((a, b) => stringCompare(a.compartmentName, b.compartmentName))
145
+ );
146
+
147
+ /** @type {string|undefined} */
148
+ let prev;
149
+ let index = 1;
150
+ for (const { name, packageName, compartmentName } of compartmentsByLabel) {
151
+ if (packageName === prev) {
152
+ compartmentRenames[name] = `${compartmentName}-n${index}`; // Added numeric suffix for duplicates
153
+ index += 1;
154
+ } else {
155
+ compartmentRenames[name] = compartmentName;
156
+ prev = packageName;
157
+ index = 1;
158
+ }
159
+ }
160
+ return compartmentRenames;
161
+ };
162
+
117
163
  const {
118
164
  compartmentMap: archiveCompartmentMap,
119
165
  sources: archiveSources,
120
166
  oldToNewCompartmentNames,
121
167
  newToOldCompartmentNames,
122
168
  compartmentRenames,
123
- } = digestCompartmentMap(compartmentMap, sources);
169
+ } = digestCompartmentMap(compartmentMap, sources, { renameCompartments });
170
+
124
171
  return {
125
172
  archiveCompartmentMap,
126
173
  archiveSources,
@@ -130,9 +177,11 @@ export const makeArchiveCompartmentMap = (compartmentMap, sources) => {
130
177
  };
131
178
  };
132
179
 
180
+ const noop = () => {};
181
+
133
182
  /**
134
183
  * @param {ReadFn | ReadPowers} powers
135
- * @param {CompartmentMapDescriptor} compartmentMap
184
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
136
185
  * @param {ArchiveLiteOptions} [options]
137
186
  * @returns {Promise<{sources: Sources, compartmentMapBytes: Uint8Array, sha512?: string}>}
138
187
  */
@@ -146,6 +195,7 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
146
195
  policy = undefined,
147
196
  sourceMapHook = undefined,
148
197
  parserForLanguage: parserForLanguageOption = {},
198
+ log: _log = noop,
149
199
  } = options;
150
200
 
151
201
  const parserForLanguage = freeze(
@@ -179,6 +229,7 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
179
229
  importHook: consolidatedExitModuleImportHook,
180
230
  sourceMapHook,
181
231
  });
232
+
182
233
  // Induce importHook to record all the necessary modules to import the given module specifier.
183
234
  const { compartment, attenuatorsCompartment } = link(compartmentMap, {
184
235
  resolve,
@@ -204,7 +255,7 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
204
255
 
205
256
  const archiveCompartmentMapText = JSON.stringify(
206
257
  archiveCompartmentMap,
207
- null,
258
+ (key, value) => (key.startsWith('_') ? undefined : value),
208
259
  2,
209
260
  );
210
261
  const archiveCompartmentMapBytes = textEncoder.encode(
@@ -223,13 +274,13 @@ const digestFromMap = async (powers, compartmentMap, options = {}) => {
223
274
  return {
224
275
  compartmentMapBytes: archiveCompartmentMapBytes,
225
276
  sources: archiveSources,
226
- sha512: archiveSha512,
277
+ ...(archiveSha512 !== undefined && { sha512: archiveSha512 }),
227
278
  };
228
279
  };
229
280
 
230
281
  /**
231
282
  * @param {ReadFn | ReadPowers} powers
232
- * @param {CompartmentMapDescriptor} compartmentMap
283
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
233
284
  * @param {ArchiveLiteOptions} [options]
234
285
  * @returns {Promise<{bytes: Uint8Array, sha512?: string}>}
235
286
  */
@@ -249,12 +300,12 @@ export const makeAndHashArchiveFromMap = async (
249
300
  await addSourcesToArchive(archive, sources);
250
301
  const bytes = await archive.snapshot();
251
302
 
252
- return { bytes, sha512 };
303
+ return { bytes, ...(sha512 !== undefined && { sha512 }) };
253
304
  };
254
305
 
255
306
  /**
256
307
  * @param {ReadFn | ReadPowers} powers
257
- * @param {CompartmentMapDescriptor} compartmentMap
308
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
258
309
  * @param {ArchiveLiteOptions} [options]
259
310
  * @returns {Promise<Uint8Array>}
260
311
  */
@@ -269,7 +320,7 @@ export const makeArchiveFromMap = async (powers, compartmentMap, options) => {
269
320
 
270
321
  /**
271
322
  * @param {ReadFn | ReadPowers} powers
272
- * @param {CompartmentMapDescriptor} compartmentMap
323
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
273
324
  * @param {ArchiveLiteOptions} [options]
274
325
  * @returns {Promise<Uint8Array>}
275
326
  */
@@ -284,7 +335,7 @@ export const mapFromMap = async (powers, compartmentMap, options) => {
284
335
 
285
336
  /**
286
337
  * @param {HashPowers} powers
287
- * @param {CompartmentMapDescriptor} compartmentMap
338
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
288
339
  * @param {ArchiveLiteOptions} [options]
289
340
  * @returns {Promise<string>}
290
341
  */
@@ -302,7 +353,7 @@ export const hashFromMap = async (powers, compartmentMap, options) => {
302
353
  * @param {WriteFn} write
303
354
  * @param {ReadFn | ReadPowers} readPowers
304
355
  * @param {string} archiveLocation
305
- * @param {CompartmentMapDescriptor} compartmentMap
356
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
306
357
  * @param {ArchiveLiteOptions} [options]
307
358
  */
308
359
  export const writeArchiveFromMap = async (
@@ -1 +1 @@
1
- {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["archive.js"],"names":[],"mappings":"AA6DO,2CALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAiBzD;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,UAAU,CAAC,CAwC/B;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,UAAU,CAAC,CAyC/B;AAQM,qCALI,UAAU,kBACV,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,MAAM,CAAC,CAyC3B;AASM,oCANI,OAAO,cACP,MAAM,GAAG,UAAU,mBACnB,MAAM,kBACN,MAAM,YACN,cAAc,iBA+CxB;4BApPS,YAAY;gCAAZ,YAAY;oCAAZ,YAAY;gCAAZ,YAAY;6BAAZ,YAAY"}
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["archive.js"],"names":[],"mappings":"AA8DO,2CALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAiBzD;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,UAAU,CAAC,CAwC/B;AAQM,oCALI,MAAM,GAAG,UAAU,kBACnB,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,UAAU,CAAC,CAyC/B;AAWM,qCALI,UAAU,kBACV,MAAM,YACN,cAAc,GACZ,OAAO,CAAC,MAAM,CAAC,CA4C3B;AASM,oCANI,OAAO,cACP,MAAM,GAAG,UAAU,mBACnB,MAAM,kBACN,MAAM,YACN,cAAc,iBA+CxB;4BA1PS,YAAY;gCAAZ,YAAY;oCAAZ,YAAY;gCAAZ,YAAY;6BAAZ,YAAY"}
package/src/archive.js CHANGED
@@ -24,6 +24,7 @@
24
24
  * ReadPowers,
25
25
  * HashPowers,
26
26
  * WriteFn,
27
+ * LogFn,
27
28
  * } from './types.js'
28
29
  */
29
30
 
@@ -169,6 +170,9 @@ export const mapLocation = async (powers, moduleLocation, options = {}) => {
169
170
  });
170
171
  };
171
172
 
173
+ /** @type {LogFn} */
174
+ const noop = () => {};
175
+
172
176
  /**
173
177
  * @param {HashPowers} powers
174
178
  * @param {string} moduleLocation
@@ -191,10 +195,12 @@ export const hashLocation = async (powers, moduleLocation, options = {}) => {
191
195
  workspaceLanguageForExtension,
192
196
  workspaceCommonjsLanguageForExtension,
193
197
  workspaceModuleLanguageForExtension,
198
+ log = noop,
194
199
  ...otherOptions
195
200
  } = assignParserForLanguage(options);
196
201
 
197
202
  const compartmentMap = await mapNodeModules(powers, moduleLocation, {
203
+ log,
198
204
  dev,
199
205
  strict,
200
206
  conditions,
@@ -212,6 +218,7 @@ export const hashLocation = async (powers, moduleLocation, options = {}) => {
212
218
  return hashFromMap(powers, compartmentMap, {
213
219
  parserForLanguage,
214
220
  policy,
221
+ log,
215
222
  ...otherOptions,
216
223
  });
217
224
  };
@@ -1,5 +1,5 @@
1
- export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
2
- export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
1
+ export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
2
+ export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
3
3
  /**
4
4
  * The bundler kit defines a language-specific behavior for injecting a module
5
5
  * into a bundle.
@@ -85,7 +85,7 @@ export type BundlerSupport<SpecificModuleSource extends unknown> = {
85
85
  import type { ReadFn } from './types.js';
86
86
  import type { ReadPowers } from './types.js';
87
87
  import type { MaybeReadPowers } from './types.js';
88
- import type { CompartmentMapDescriptor } from './types.js';
88
+ import type { PackageCompartmentMapDescriptor } from './types.js';
89
89
  import type { BundleOptions } from './types.js';
90
90
  import type { StaticModuleType } from 'ses';
91
91
  //# sourceMappingURL=bundle-lite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-lite.d.ts","sourceRoot":"","sources":["bundle-lite.js"],"names":[],"mappings":"AA2TO,+CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,wBAAwB,YACxB,aAAa,GACX,OAAO,CAAC,M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;;;;;;;gBAzmBa,MAAM,MAAM;;;;;;cAOZ,MAAM,MAAM;;;;;;oBAGZ,MAAM,MAAM;;;;;wBAGZ,MAAM,MAAM;;yBAKH,oBAAoB,SAA9B,OAAS;SAER,MAAM;UACN,MAAM;qBACN,MAAM;qBACN,MAAM;mBACN,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;;;UAKV,MAAM;WACN,MAAM;gBACN,UAAU;oBACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;qBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAIb,oBAAoB,SAA9B,OAAS,aAEX,YAAY,CAAC,oBAAoB,CAAC,UAE1C;IAAyB,WAAW;IACZ,eAAe;CACvC,KAAU,UAAU;2BAIA,oBAAoB,SAA9B,OAAS;aAER,MAAM;mBACN,aAAa,CAAC,oBAAoB,CAAC;;4BArFvC,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;qDAAZ,YAAY;mCAAZ,YAAY;sCAVZ,KAAK"}
@@ -7,9 +7,9 @@
7
7
  * } from 'ses'
8
8
  * @import {
9
9
  * BundleOptions,
10
- * CompartmentDescriptor,
11
- * CompartmentMapDescriptor,
12
10
  * CompartmentSources,
11
+ * PackageCompartmentDescriptors,
12
+ * PackageCompartmentMapDescriptor,
13
13
  * MaybeReadPowers,
14
14
  * ReadFn,
15
15
  * ReadPowers,
@@ -110,6 +110,11 @@ import { defaultParserForLanguage } from './archive-parsers.js';
110
110
  import mjsSupport from './bundle-mjs.js';
111
111
  import cjsSupport from './bundle-cjs.js';
112
112
  import jsonSupport from './bundle-json.js';
113
+ import {
114
+ isErrorModuleSource,
115
+ isExitModuleSource,
116
+ isLocalModuleSource,
117
+ } from './guards.js';
113
118
 
114
119
  const { quote: q } = assert;
115
120
 
@@ -144,7 +149,7 @@ null,
144
149
  * The first modules are place-holders for the modules that exit
145
150
  * the compartment map to the host's module system.
146
151
  *
147
- * @param {Record<string, CompartmentDescriptor>} compartmentDescriptors
152
+ * @param {PackageCompartmentDescriptors} compartmentDescriptors
148
153
  * @param {Record<string, CompartmentSources>} compartmentSources
149
154
  * @param {string} entryCompartmentName
150
155
  * @param {string} entryModuleSpecifier
@@ -188,28 +193,18 @@ const sortedModules = (
188
193
 
189
194
  const source = compartmentSources[compartmentName][moduleSpecifier];
190
195
  if (source !== undefined) {
191
- const { record, parser, deferredError, bytes, sourceDirname, exit } =
192
- source;
193
- if (exit !== undefined) {
194
- return exit;
195
- }
196
- assert(
197
- bytes !== undefined,
198
- `No bytes for ${moduleSpecifier} in ${compartmentName}`,
199
- );
200
- assert(
201
- parser !== undefined,
202
- `No parser for ${moduleSpecifier} in ${compartmentName}`,
203
- );
204
- assert(
205
- sourceDirname !== undefined,
206
- `No sourceDirname for ${moduleSpecifier} in ${compartmentName}`,
207
- );
208
- if (deferredError) {
196
+ if (isErrorModuleSource(source)) {
209
197
  throw Error(
210
- `Cannot bundle: encountered deferredError ${deferredError}`,
198
+ `Cannot bundle: encountered deferredError ${source.deferredError}`,
211
199
  );
212
200
  }
201
+ if (isExitModuleSource(source)) {
202
+ return source.exit;
203
+ }
204
+ if (!isLocalModuleSource(source)) {
205
+ throw new TypeError(`Unexpected source type ${JSON.stringify(source)}`);
206
+ }
207
+ const { record, parser, bytes, sourceDirname } = source;
213
208
  if (record) {
214
209
  const { imports = [], reexports = [] } =
215
210
  /** @type {PrecompiledStaticModuleInterface} */ (record);
@@ -309,7 +304,7 @@ const getBundlerKitForModule = (module, params) => {
309
304
 
310
305
  /**
311
306
  * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
312
- * @param {CompartmentMapDescriptor} compartmentMap
307
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
313
308
  * @param {BundleOptions} [options]
314
309
  * @returns {Promise<string>}
315
310
  */
@@ -651,7 +646,7 @@ ${m.bundlerKit.getFunctor()}`,
651
646
 
652
647
  /**
653
648
  * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
654
- * @param {CompartmentMapDescriptor} compartmentMap
649
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
655
650
  * @param {BundleOptions} [options]
656
651
  * @returns {Promise<string>}
657
652
  */
package/src/bundle.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
2
- export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
1
+ export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
2
+ export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: BundleOptions): Promise<string>;
3
3
  export function makeFunctor(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: BundleOptions): Promise<string>;
4
4
  export function makeScript(readPowers: ReadFn | ReadPowers | MaybeReadPowers, moduleLocation: string, options?: BundleOptions): Promise<string>;
5
5
  export function writeScript(write: WriteFn, read: ReadFn, bundleLocation: string, moduleLocation: string, options?: BundleOptions): Promise<void>;
@@ -88,7 +88,7 @@ export type BundlerSupport<SpecificModuleSource extends unknown> = {
88
88
  import type { ReadFn } from './types.js';
89
89
  import type { ReadPowers } from './types.js';
90
90
  import type { MaybeReadPowers } from './types.js';
91
- import type { CompartmentMapDescriptor } from './types.js';
91
+ import type { PackageCompartmentMapDescriptor } from './types.js';
92
92
  import type { BundleOptions } from './types.js';
93
93
  import type { WriteFn } from './types.js';
94
94
  import type { StaticModuleType } from 'ses';
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts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IAAyB,WAAW;IACZ,eAAe;CACvC,KAAU,UAAU;2BAIA,oBAAoB,SAA9B,OAAS;aAER,MAAM;mBACN,aAAa,CAAC,oBAAoB,CAAC;;4BArFvC,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;qDAAZ,YAAY;mCAAZ,YAAY;6BAAZ,YAAY;sCAXZ,KAAK"}
package/src/bundle.js CHANGED
@@ -7,9 +7,9 @@
7
7
  * } from 'ses'
8
8
  * @import {
9
9
  * BundleOptions,
10
- * CompartmentDescriptor,
11
- * CompartmentMapDescriptor,
12
10
  * CompartmentSources,
11
+ * PackageCompartmentDescriptors,
12
+ * PackageCompartmentMapDescriptor,
13
13
  * MaybeReadPowers,
14
14
  * ReadFn,
15
15
  * ReadPowers,
@@ -112,6 +112,11 @@ import { defaultParserForLanguage } from './archive-parsers.js';
112
112
  import mjsSupport from './bundle-mjs.js';
113
113
  import cjsSupport from './bundle-cjs.js';
114
114
  import jsonSupport from './bundle-json.js';
115
+ import {
116
+ isErrorModuleSource,
117
+ isExitModuleSource,
118
+ isLocalModuleSource,
119
+ } from './guards.js';
115
120
 
116
121
  const textEncoder = new TextEncoder();
117
122
 
@@ -148,7 +153,7 @@ null,
148
153
  * The first modules are place-holders for the modules that exit
149
154
  * the compartment map to the host's module system.
150
155
  *
151
- * @param {Record<string, CompartmentDescriptor>} compartmentDescriptors
156
+ * @param {PackageCompartmentDescriptors} compartmentDescriptors
152
157
  * @param {Record<string, CompartmentSources>} compartmentSources
153
158
  * @param {string} entryCompartmentName
154
159
  * @param {string} entryModuleSpecifier
@@ -192,28 +197,18 @@ const sortedModules = (
192
197
 
193
198
  const source = compartmentSources[compartmentName][moduleSpecifier];
194
199
  if (source !== undefined) {
195
- const { record, parser, deferredError, bytes, sourceDirname, exit } =
196
- source;
197
- if (exit !== undefined) {
198
- return exit;
199
- }
200
- assert(
201
- bytes !== undefined,
202
- `No bytes for ${moduleSpecifier} in ${compartmentName}`,
203
- );
204
- assert(
205
- parser !== undefined,
206
- `No parser for ${moduleSpecifier} in ${compartmentName}`,
207
- );
208
- assert(
209
- sourceDirname !== undefined,
210
- `No sourceDirname for ${moduleSpecifier} in ${compartmentName}`,
211
- );
212
- if (deferredError) {
200
+ if (isErrorModuleSource(source)) {
213
201
  throw Error(
214
- `Cannot bundle: encountered deferredError ${deferredError}`,
202
+ `Cannot bundle: encountered deferredError ${source.deferredError}`,
215
203
  );
216
204
  }
205
+ if (isExitModuleSource(source)) {
206
+ return source.exit;
207
+ }
208
+ if (!isLocalModuleSource(source)) {
209
+ throw new TypeError(`Unexpected source type ${JSON.stringify(source)}`);
210
+ }
211
+ const { record, parser, bytes, sourceDirname } = source;
217
212
  if (record) {
218
213
  const { imports = [], reexports = [] } =
219
214
  /** @type {PrecompiledStaticModuleInterface} */ (record);
@@ -314,7 +309,7 @@ const getBundlerKitForModule = (module, params) => {
314
309
 
315
310
  /**
316
311
  * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
317
- * @param {CompartmentMapDescriptor} compartmentMap
312
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
318
313
  * @param {BundleOptions} [options]
319
314
  * @returns {Promise<string>}
320
315
  */
@@ -657,7 +652,7 @@ ${m.bundlerKit.getFunctor()}`,
657
652
 
658
653
  /**
659
654
  * @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
660
- * @param {CompartmentMapDescriptor} compartmentMap
655
+ * @param {PackageCompartmentMapDescriptor} compartmentMap
661
656
  * @param {BundleOptions} [options]
662
657
  * @returns {Promise<string>}
663
658
  */
@@ -1,7 +1,7 @@
1
- export function captureFromMap(powers: ReadFn | ReadPowers, compartmentMap: CompartmentMapDescriptor, options?: CaptureLiteOptions): Promise<CaptureResult>;
1
+ export function captureFromMap(readPowers: ReadFn | ReadPowers, compartmentMap: PackageCompartmentMapDescriptor, options?: CaptureLiteOptions): Promise<CaptureResult>;
2
2
  import type { ReadFn } from './types.js';
3
3
  import type { ReadPowers } from './types.js';
4
- import type { CompartmentMapDescriptor } from './types.js';
4
+ import type { PackageCompartmentMapDescriptor } from './types.js';
5
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":"AAsFO,uCALI,MAAM,GAAG,UAAU,kBACnB,wBAAwB,YACxB,kBAAkB,GAChB,OAAO,CAAC,aAAa,CAAC,CAmElC;4BA9GS,YAAY;gCAAZ,YAAY;8CAAZ,YAAY;wCAAZ,YAAY;mCAAZ,YAAY"}
1
+ {"version":3,"file":"capture-lite.d.ts","sourceRoot":"","sources":["capture-lite.js"],"names":[],"mappings":"AA2RO,2CALI,MAAM,GAAG,UAAU,kBACnB,+BAA+B,YAC/B,kBAAkB,GAChB,OAAO,CAAC,aAAa,CAAC,CAwFlC;4BApUS,YAAY;gCAAZ,YAAY;qDAAZ,YAAY;wCAAZ,YAAY;mCAAZ,YAAY"}