@endo/compartment-mapper 1.6.1 → 1.6.2
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/package.json +9 -8
- package/src/compartment-map.d.ts +0 -1
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +0 -49
- package/src/digest.d.ts.map +1 -1
- package/src/digest.js +2 -5
- package/src/node-modules.js +1 -1
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endo/compartment-mapper",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "The compartment mapper assembles Node applications in a sandbox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "exit 0",
|
|
52
52
|
"prepack": "tsc --build tsconfig.build.json",
|
|
53
|
-
"postpack": "git clean -
|
|
53
|
+
"postpack": "git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\"",
|
|
54
54
|
"cover": "c8 ava",
|
|
55
55
|
"lint": "yarn lint:types && yarn lint:eslint",
|
|
56
56
|
"lint-fix": "eslint --fix .",
|
|
@@ -60,11 +60,12 @@
|
|
|
60
60
|
"test": "ava"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@endo/cjs-module-analyzer": "^1.0.
|
|
64
|
-
"@endo/module-source": "^1.3.
|
|
65
|
-
"@endo/
|
|
66
|
-
"@endo/
|
|
67
|
-
"
|
|
63
|
+
"@endo/cjs-module-analyzer": "^1.0.11",
|
|
64
|
+
"@endo/module-source": "^1.3.2",
|
|
65
|
+
"@endo/path-compare": "^1.1.0",
|
|
66
|
+
"@endo/trampoline": "^1.0.5",
|
|
67
|
+
"@endo/zip": "^1.0.11",
|
|
68
|
+
"ses": "^1.13.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"ava": "^6.1.3",
|
|
@@ -118,5 +119,5 @@
|
|
|
118
119
|
"typeCoverage": {
|
|
119
120
|
"atLeast": 86.14
|
|
120
121
|
},
|
|
121
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "03b92fc383da5d8bb4ea993b90149a0db5799d0b"
|
|
122
123
|
}
|
package/src/compartment-map.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @type {(a: string, b: string) => number} */
|
|
2
2
|
export const stringCompare: (a: string, b: string) => number;
|
|
3
|
-
export function pathCompare(a: Array<string> | undefined, b: Array<string> | undefined): number;
|
|
4
3
|
export function assertCompartmentMap(allegedCompartmentMap: unknown, url?: string): asserts allegedCompartmentMap is CompartmentMapDescriptor;
|
|
5
4
|
import type { CompartmentMapDescriptor } from './types.js';
|
|
6
5
|
//# sourceMappingURL=compartment-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AA8Z/D,4DALI,OAAO,QACP,MAAM,GACJ,QAAQ,qBAAqB,IAAI,wBAAwB,CA+BrE;8CApc2C,YAAY"}
|
package/src/compartment-map.js
CHANGED
|
@@ -14,55 +14,6 @@ const q = JSON.stringify;
|
|
|
14
14
|
// eslint-disable-next-line no-nested-ternary
|
|
15
15
|
export const stringCompare = (a, b) => (a === b ? 0 : a < b ? -1 : 1);
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* @param {number} length
|
|
19
|
-
* @param {string} term
|
|
20
|
-
*/
|
|
21
|
-
const cumulativeLength = (length, term) => {
|
|
22
|
-
return length + term.length;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {Array<string> | undefined} a
|
|
27
|
-
* @param {Array<string> | undefined} b
|
|
28
|
-
*/
|
|
29
|
-
export const pathCompare = (a, b) => {
|
|
30
|
-
// Undefined is not preferred
|
|
31
|
-
if (a === undefined && b === undefined) {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
if (a === undefined) {
|
|
35
|
-
return 1;
|
|
36
|
-
}
|
|
37
|
-
if (b === undefined) {
|
|
38
|
-
return -1;
|
|
39
|
-
}
|
|
40
|
-
// Prefer the shortest dependency path.
|
|
41
|
-
if (a.length !== b.length) {
|
|
42
|
-
return a.length - b.length;
|
|
43
|
-
}
|
|
44
|
-
// Otherwise, favor the shortest cumulative length.
|
|
45
|
-
const aSum = a.reduce(cumulativeLength, 0);
|
|
46
|
-
const bSum = b.reduce(cumulativeLength, 0);
|
|
47
|
-
if (aSum !== bSum) {
|
|
48
|
-
return aSum - bSum;
|
|
49
|
-
}
|
|
50
|
-
// Otherwise, compare terms lexically.
|
|
51
|
-
assert(a.length === b.length); // Reminder
|
|
52
|
-
// This loop guarantees that if any pair of terms is different, including the
|
|
53
|
-
// case where one is a prefix of the other, we will return a non-zero value.
|
|
54
|
-
for (let i = 0; i < a.length; i += 1) {
|
|
55
|
-
const comparison = stringCompare(a[i], b[i]);
|
|
56
|
-
if (comparison !== 0) {
|
|
57
|
-
return comparison;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// If all pairs of terms are the same respective lengths, we are guaranteed
|
|
61
|
-
// that they are exactly the same or one of them is lexically distinct and would
|
|
62
|
-
// have already been caught.
|
|
63
|
-
return 0;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
17
|
/**
|
|
67
18
|
* @template T
|
|
68
19
|
* @param {Iterable<T>} iterable
|
package/src/digest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["digest.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["digest.js"],"names":[],"mappings":"AAqLO,qDAJI,wBAAwB,WACxB,OAAO,GACL,YAAY,CAoDxB;8CAxNS,YAAY;6BAAZ,YAAY;kCAAZ,YAAY"}
|
package/src/digest.js
CHANGED
|
@@ -16,11 +16,8 @@
|
|
|
16
16
|
* } from './types.js'
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
pathCompare,
|
|
22
|
-
stringCompare,
|
|
23
|
-
} from './compartment-map.js';
|
|
19
|
+
import { pathCompare } from '@endo/path-compare';
|
|
20
|
+
import { assertCompartmentMap, stringCompare } from './compartment-map.js';
|
|
24
21
|
|
|
25
22
|
const { create, fromEntries, entries, keys } = Object;
|
|
26
23
|
|
package/src/node-modules.js
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* } from './types/node-modules.js'
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
import { pathCompare } from '
|
|
45
|
+
import { pathCompare } from '@endo/path-compare';
|
|
46
46
|
import { inferExportsAndAliases } from './infer-exports.js';
|
|
47
47
|
import { parseLocatedJson } from './json.js';
|
|
48
48
|
import { join } from './node-module-specifier.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AA0CO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,
|
|
1
|
+
{"version":3,"file":"parse-cjs-shared-export-wrapper.d.ts","sourceRoot":"","sources":["parse-cjs-shared-export-wrapper.js"],"names":[],"mappings":"AA0CO,2CAPI,UAAU,GAAG,MAAM,GAAG,SAAS,YAC/B,MAAM,GACJ;IACR,QAAQ,EAAC,MAAM,GAAC,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,GAAC,IAAI,CAAA;CACrB,CAgCH;AAmBM,uGAZJ;IAAmB,uBAAuB,EAAlC,MAAM;IACU,WAAW,EAA3B,WAAW;IACgB,eAAe,EAA1C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACX,QAAQ,EAAnB,MAAM;IAC8B,UAAU,EAA9C,MAAM,GAAG,UAAU,GAAG,SAAS;CACvC,GAAU;IACR,MAAM,EAAE;QAAE,OAAO,EAAE,GAAG,CAAA;KAAE,CAAC;IACzB,aAAa,EAAE,GAAG,CAAC;IACnB,YAAY,WAAW;IACvB,OAAO,WAAW;CACnB,CA+IH;gCAhOqC,YAAY;4BAAZ,YAAY"}
|
|
@@ -182,6 +182,26 @@ export const wrap = ({
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
// stub implementation of require.extensions
|
|
186
|
+
const requireExtensions = create(null);
|
|
187
|
+
const fail = freeze(
|
|
188
|
+
/**
|
|
189
|
+
* @param {NodeJS.Module} _module
|
|
190
|
+
* @param {string} _filename
|
|
191
|
+
* @returns {any}
|
|
192
|
+
*/
|
|
193
|
+
(_module, _filename) => {
|
|
194
|
+
throw Error('Not implemented');
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
requireExtensions['.js'] = fail;
|
|
198
|
+
requireExtensions['.json'] = fail;
|
|
199
|
+
requireExtensions['.node'] = fail;
|
|
200
|
+
freeze(requireExtensions);
|
|
201
|
+
require.extensions = /** @type {NodeJS.Require['extensions']} */ (
|
|
202
|
+
requireExtensions
|
|
203
|
+
);
|
|
204
|
+
|
|
185
205
|
freeze(require);
|
|
186
206
|
|
|
187
207
|
const afterExecute = () => {
|