@endo/compartment-mapper
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -6,2 +6,13 @@ # Change Log | ||
### [0.3.2](https://github.com/endojs/endo/compare/@endo/compartment-mapper@0.3.1...@endo/compartment-mapper@0.3.2) (2021-06-14) | ||
### Features | ||
* **compartment-mapper:** Add actionable hint to linker error ([4dbe87b](https://github.com/endojs/endo/commit/4dbe87b40007d5ce9a084b4cf94ac254d9bd9e7a)) | ||
* **compartment-mapper:** Add Node.js power adapter ([fd16355](https://github.com/endojs/endo/commit/fd1635517ce8260d3dc2766c2c39a599f58f9a0c)) | ||
* **compartment-mapper:** Follow symbolic links ([ae553a4](https://github.com/endojs/endo/commit/ae553a469800f548975b0e1ba5bb2c63455a87f4)) | ||
### [0.3.1](https://github.com/endojs/endo/compare/@endo/compartment-mapper@0.3.0...@endo/compartment-mapper@0.3.1) (2021-06-06) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@endo/compartment-mapper", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "The compartment mapper assembles Node applications in a sandbox", | ||
@@ -30,2 +30,3 @@ "keywords": [ | ||
"./bundle.js": "./bundle.js", | ||
"./node-powers.js": "./node-powers.js", | ||
"./package.json": "./package.json" | ||
@@ -42,9 +43,9 @@ }, | ||
"dependencies": { | ||
"@endo/cjs-module-analyzer": "^0.2.1", | ||
"@endo/static-module-record": "^0.5.1", | ||
"@endo/zip": "^0.2.1", | ||
"ses": "^0.13.1" | ||
"@endo/cjs-module-analyzer": "^0.2.2", | ||
"@endo/static-module-record": "^0.5.2", | ||
"@endo/zip": "^0.2.2", | ||
"ses": "^0.13.2" | ||
}, | ||
"devDependencies": { | ||
"@endo/eslint-config": "^0.3.8", | ||
"@endo/eslint-config": "^0.3.9", | ||
"ava": "^3.12.1", | ||
@@ -89,3 +90,3 @@ "babel-eslint": "^10.0.3", | ||
}, | ||
"gitHead": "6ef187e8b1e26bff2bf228a09a9c79214f3cf1e5" | ||
"gitHead": "68cb467c5be67d84ea8f980076c3407365213854" | ||
} |
@@ -14,2 +14,3 @@ // @ts-check | ||
import { parseLocatedJson } from './json.js'; | ||
import { unpackReadPowers } from './powers.js'; | ||
@@ -141,3 +142,3 @@ const textEncoder = new TextEncoder(); | ||
/** | ||
* @param {ReadFn} read | ||
* @param {ReadFn | ReadPowers} powers | ||
* @param {string} moduleLocation | ||
@@ -148,4 +149,5 @@ * @param {Object} [options] | ||
*/ | ||
export const makeArchive = async (read, moduleLocation, options) => { | ||
export const makeArchive = async (powers, moduleLocation, options) => { | ||
const { moduleTransforms } = options || {}; | ||
const { read } = unpackReadPowers(powers); | ||
const { | ||
@@ -166,3 +168,3 @@ packageLocation, | ||
const compartmentMap = await compartmentMapForNodeModules( | ||
read, | ||
powers, | ||
packageLocation, | ||
@@ -231,3 +233,3 @@ tags, | ||
* @param {WriteFn} write | ||
* @param {ReadFn} read | ||
* @param {ReadFn | ReadPowers} readPowers | ||
* @param {string} archiveLocation | ||
@@ -239,3 +241,3 @@ * @param {string} moduleLocation | ||
write, | ||
read, | ||
readPowers, | ||
archiveLocation, | ||
@@ -245,4 +247,4 @@ moduleLocation, | ||
) => { | ||
const archiveBytes = await makeArchive(read, moduleLocation, options); | ||
const archiveBytes = await makeArchive(readPowers, moduleLocation, options); | ||
await write(archiveLocation, archiveBytes); | ||
}; |
@@ -178,3 +178,7 @@ // @ts-check | ||
if (module === undefined) { | ||
throw new Error(`Cannot import missing external module ${q(exit)}`); | ||
throw new Error( | ||
`Cannot import missing external module ${q( | ||
exit, | ||
)}, may be missing from ${compartmentName} package.json`, | ||
); | ||
} | ||
@@ -181,0 +185,0 @@ return module; |
@@ -13,2 +13,3 @@ // @ts-check | ||
import { parseLocatedJson } from './json.js'; | ||
import { unpackReadPowers } from './powers.js'; | ||
@@ -23,3 +24,3 @@ /** @type {Record<string, ParseFn>} */ | ||
/** | ||
* @param {ReadFn} read | ||
* @param {ReadFn | ReadPowers} readPowers | ||
* @param {string} moduleLocation | ||
@@ -29,5 +30,7 @@ * @param {ArchiveOptions} [options] | ||
*/ | ||
export const loadLocation = async (read, moduleLocation, options) => { | ||
export const loadLocation = async (readPowers, moduleLocation, options) => { | ||
const { moduleTransforms = {} } = options || {}; | ||
const { read } = unpackReadPowers(readPowers); | ||
const { | ||
@@ -47,3 +50,3 @@ packageLocation, | ||
const compartmentMap = await compartmentMapForNodeModules( | ||
read, | ||
readPowers, | ||
packageLocation, | ||
@@ -50,0 +53,0 @@ tags, |
@@ -28,2 +28,3 @@ // @ts-check | ||
import { parseLocatedJson } from './json.js'; | ||
import { unpackReadPowers } from './powers.js'; | ||
@@ -106,2 +107,3 @@ const { create, keys, values } = Object; | ||
* @param {ReadDescriptorFn} readDescriptor | ||
* @param {CanonicalFn} canonical | ||
* @param {string} directory | ||
@@ -114,6 +116,10 @@ * @param {string} name | ||
*/ | ||
const findPackage = async (readDescriptor, directory, name) => { | ||
const findPackage = async (readDescriptor, canonical, directory, name) => { | ||
for (;;) { | ||
const packageLocation = resolveLocation(`node_modules/${name}/`, directory); | ||
// eslint-disable-next-line no-await-in-loop | ||
const packageLocation = await canonical( | ||
resolveLocation(`node_modules/${name}/`, directory), | ||
); | ||
// eslint-disable-next-line no-await-in-loop | ||
const packageDescriptor = await readDescriptor(packageLocation); | ||
@@ -197,2 +203,3 @@ if (packageDescriptor !== undefined) { | ||
* @param {ReadDescriptorFn} readDescriptor | ||
* @param {CanonicalFn} canonical | ||
* @param {Graph} graph | ||
@@ -208,2 +215,3 @@ * @param {Object} packageDetails | ||
readDescriptor, | ||
canonical, | ||
graph, | ||
@@ -236,2 +244,3 @@ { packageLocation, packageDescriptor }, | ||
readDescriptor, | ||
canonical, | ||
graph, | ||
@@ -265,2 +274,3 @@ dependencies, | ||
* @param {ReadDescriptorFn} readDescriptor | ||
* @param {CanonicalFn} canonical | ||
* @param {Graph} graph - the partially build graph. | ||
@@ -274,2 +284,3 @@ * @param {Record<string, string>} dependencies | ||
readDescriptor, | ||
canonical, | ||
graph, | ||
@@ -281,3 +292,8 @@ dependencies, | ||
) => { | ||
const dependency = await findPackage(readDescriptor, packageLocation, name); | ||
const dependency = await findPackage( | ||
readDescriptor, | ||
canonical, | ||
packageLocation, | ||
name, | ||
); | ||
if (dependency === undefined) { | ||
@@ -287,3 +303,3 @@ throw new Error(`Cannot find dependency ${name} for ${packageLocation}`); | ||
dependencies[name] = dependency.packageLocation; | ||
await graphPackage(name, readDescriptor, graph, dependency, tags); | ||
await graphPackage(name, readDescriptor, canonical, graph, dependency, tags); | ||
}; | ||
@@ -301,2 +317,3 @@ | ||
* @param {ReadFn} read | ||
* @param {CanonicalFn} canonical | ||
* @param {string} packageLocation - location of the main package. | ||
@@ -309,2 +326,3 @@ * @param {Set<string>} tags | ||
read, | ||
canonical, | ||
packageLocation, | ||
@@ -340,2 +358,3 @@ tags, | ||
readDescriptor, | ||
canonical, | ||
graph, | ||
@@ -423,3 +442,3 @@ { | ||
/** | ||
* @param {ReadFn} read | ||
* @param {ReadFn | ReadPowers} readPowers | ||
* @param {string} packageLocation | ||
@@ -432,3 +451,3 @@ * @param {Set<string>} tags | ||
export const compartmentMapForNodeModules = async ( | ||
read, | ||
readPowers, | ||
packageLocation, | ||
@@ -439,4 +458,6 @@ tags, | ||
) => { | ||
const { read, canonical } = unpackReadPowers(readPowers); | ||
const graph = await graphPackages( | ||
read, | ||
canonical, | ||
packageLocation, | ||
@@ -443,0 +464,0 @@ tags, |
@@ -81,3 +81,3 @@ // @ts-check | ||
* @callback WriteFn | ||
* @param {string} name | ||
* @param {string} location | ||
* @param {Uint8Array} bytes | ||
@@ -94,3 +94,3 @@ * @returns {Promise<void>} | ||
* @callback ReadFn | ||
* @param {string} name | ||
* @param {string} location | ||
* @returns {Promise<Uint8Array>} bytes | ||
@@ -100,2 +100,12 @@ */ | ||
/** | ||
* Returns a canonical URL for a given URL, following redirects or symbolic | ||
* links if any exist along the path. | ||
* Must return the given logical location if the real location does not exist. | ||
* | ||
* @callback CanonicalFn | ||
* @param {string} location | ||
* @returns {Promise<string>} canonical location | ||
*/ | ||
/** | ||
* @typedef {Object} Application | ||
@@ -116,2 +126,13 @@ * @property {ExecuteFn} import | ||
/** | ||
* @typedef {Object} ReadPowers | ||
* @property {ReadFn} read | ||
* @property {CanonicalFn} canonical | ||
*/ | ||
/** | ||
* @typedef {Object} WritePowers | ||
* @property {WriteFn} write | ||
*/ | ||
// ///////////////////////////////////////////////////////////////////////////// | ||
@@ -118,0 +139,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123299
33
2563
Updated@endo/zip@^0.2.2
Updatedses@^0.13.2