feat(compartment-mapper): add tags to ArchiveOptions
MODIFY
packages/compartment-mapper/src/archive.js
packages/compartment-mapper/src/archive.js
@@ -252,6 +252,7 @@ const digestLocation = async (powers, moduleLocation, options) => {
moduleTransforms,
modules: exitModules = {},
dev = false,
+ tags = new Set(),
captureSourceLocation = undefined,
} = options || {};
const { read, computeSha512 } = unpackReadPowers(powers);
@@ -262,8 +263,6 @@ const digestLocation = async (powers, moduleLocation, options) => {
moduleSpecifier,
} = await search(read, moduleLocation);
- /** @type {Set<string>} */
- const tags = new Set();
tags.add('endo');
tags.add('import');
tags.add('default');

MODIFY
packages/compartment-mapper/src/import.js
packages/compartment-mapper/src/import.js
@@ -37,7 +37,8 @@ export const parserForLanguage = {
* @returns {Promise<Application>}
*/
export const loadLocation = async (readPowers, moduleLocation, options) => {
- const { moduleTransforms = {}, dev = false } = options || {};
+ const { moduleTransforms = {}, dev = false, tags = new Set() } =
+ options || {};
const { read } = unpackReadPowers(readPowers);
@@ -52,8 +53,6 @@ export const loadLocation = async (readPowers, moduleLocation, options) => {
packageDescriptorText,
packageDescriptorLocation,
);
- /** @type {Set<string>} */
- const tags = new Set();
const compartmentMap = await compartmentMapForNodeModules(
readPowers,
packageLocation,

MODIFY
packages/compartment-mapper/src/types.js
packages/compartment-mapper/src/types.js
@@ -308,5 +308,6 @@ export {};
* @property {ModuleTransforms} [moduleTransforms]
* @property {Record<string, any>} [modules]
* @property {boolean} [dev]
+ * @property {Set<string>} [tags]
* @property {CaptureSourceLocationHook} [captureSourceLocation]
*/

MODIFY
packages/compartment-mapper/test/scaffold.js
packages/compartment-mapper/test/scaffold.js
@@ -57,6 +57,7 @@ export function scaffold(
onError,
shouldFailBeforeArchiveOperations = false,
knownFailure = false,
+ tags = undefined,
} = {},
) {
// wrapping each time allows for convenient use of test.only
@@ -89,6 +90,7 @@ export function scaffold(
const application = await loadLocation(readPowers, fixture, {
dev: true,
+ tags,
});
const { namespace } = await application.import({
globals,
@@ -107,6 +109,7 @@ export function scaffold(
modules,
Compartment,
dev: true,
+ tags,
});
return namespace;
});
@@ -118,6 +121,7 @@ export function scaffold(
const archive = await makeArchive(readPowers, fixture, {
modules,
dev: true,
+ tags,
});
const application = await parseArchive(archive, '<unknown>', {
modules: Object.fromEntries(
@@ -148,6 +152,7 @@ export function scaffold(
const archive = await makeArchive(readPowers, fixture, {
modules,
dev: true,
+ tags,
});
const prefixArchive = new Uint8Array(archive.length + 10);
prefixArchive.set(archive, 10);
@@ -183,6 +188,7 @@ export function scaffold(
await writeArchive(fakeWrite, readPowers, 'app.agar', fixture, {
modules: { builtin: true },
dev: true,
+ tags,
});
const application = await loadArchive(fakeRead, 'app.agar', {
modules,
@@ -214,6 +220,7 @@ export function scaffold(
await writeArchive(fakeWrite, readPowers, 'app.agar', fixture, {
modules,
dev: true,
+ tags,
});
const { namespace } = await importArchive(fakeRead, 'app.agar', {
globals,
@@ -232,11 +239,13 @@ export function scaffold(
modules,
Compartment,
dev: true,
+ tags,
});
const archiveBytes = await makeArchive(readPowers, fixture, {
modules,
dev: true,
+ tags,
});
const { computeSha512 } = readPowers;
@@ -246,6 +255,7 @@ export function scaffold(
{
modules,
dev: true,
+ tags,
computeSha512,
expectedSha512,
},
@@ -261,11 +271,13 @@ export function scaffold(
const expectedSha512 = await hashLocation(readPowers, fixture, {
modules,
dev: true,
+ tags,
});
const archive = await makeArchive(readPowers, fixture, {
modules,
dev: true,
+ tags,
});
const reader = new ZipReader(archive);

feat(compartment-mapper): add tags to ArchiveOptions