@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.
Files changed (145) hide show
  1. package/README.md +50 -27
  2. package/archive-lite.d.ts +1 -0
  3. package/archive-lite.js +3 -0
  4. package/archive-parsers.d.ts +1 -0
  5. package/archive-parsers.js +3 -0
  6. package/archive.d.ts +1 -0
  7. package/archive.js +3 -0
  8. package/bundle.d.ts +1 -0
  9. package/bundle.js +3 -0
  10. package/capture-lite.d.ts +1 -0
  11. package/capture-lite.js +3 -0
  12. package/import-archive-lite.d.ts +1 -0
  13. package/import-archive-lite.js +3 -0
  14. package/import-archive-parsers.d.ts +1 -0
  15. package/import-archive-parsers.js +3 -0
  16. package/import-archive.d.ts +1 -0
  17. package/import-archive.js +3 -0
  18. package/import-lite.d.ts +1 -0
  19. package/import-lite.js +3 -0
  20. package/import-parsers.d.ts +1 -0
  21. package/import-parsers.js +3 -0
  22. package/import.d.ts +1 -0
  23. package/import.js +3 -0
  24. package/index.d.ts +1 -0
  25. package/index.js +3 -1
  26. package/node-modules.d.ts +1 -0
  27. package/node-modules.js +3 -0
  28. package/node-powers.d.ts +1 -0
  29. package/node-powers.js +3 -0
  30. package/package.json +10 -14
  31. package/src/archive-lite.d.ts +6 -6
  32. package/src/archive-lite.d.ts.map +1 -1
  33. package/src/archive-lite.js +35 -33
  34. package/src/archive.d.ts.map +1 -1
  35. package/src/archive.js +132 -28
  36. package/src/bundle.d.ts.map +1 -1
  37. package/src/bundle.js +54 -14
  38. package/src/capture-lite.d.ts +2 -2
  39. package/src/capture-lite.d.ts.map +1 -1
  40. package/src/capture-lite.js +21 -17
  41. package/src/compartment-map.d.ts +2 -1
  42. package/src/compartment-map.d.ts.map +1 -1
  43. package/src/compartment-map.js +11 -3
  44. package/src/extension.d.ts.map +1 -1
  45. package/src/extension.js +1 -3
  46. package/src/import-archive-lite.d.ts +3 -19
  47. package/src/import-archive-lite.d.ts.map +1 -1
  48. package/src/import-archive-lite.js +43 -57
  49. package/src/import-archive-parsers.d.ts.map +1 -1
  50. package/src/import-archive-parsers.js +1 -0
  51. package/src/import-archive.d.ts +2 -2
  52. package/src/import-archive.d.ts.map +1 -1
  53. package/src/import-archive.js +15 -12
  54. package/src/import-hook.d.ts +2 -1
  55. package/src/import-hook.d.ts.map +1 -1
  56. package/src/import-hook.js +87 -76
  57. package/src/import-lite.d.ts.map +1 -1
  58. package/src/import-lite.js +23 -23
  59. package/src/import.d.ts.map +1 -1
  60. package/src/import.js +47 -23
  61. package/src/infer-exports.d.ts.map +1 -1
  62. package/src/infer-exports.js +2 -3
  63. package/src/json.d.ts.map +1 -1
  64. package/src/json.js +1 -2
  65. package/src/link.d.ts.map +1 -1
  66. package/src/link.js +12 -29
  67. package/src/map-parser.d.ts.map +1 -1
  68. package/src/map-parser.js +21 -16
  69. package/src/node-module-specifier.d.ts.map +1 -1
  70. package/src/node-module-specifier.js +2 -3
  71. package/src/node-modules.d.ts +9 -7
  72. package/src/node-modules.d.ts.map +1 -1
  73. package/src/node-modules.js +176 -87
  74. package/src/node-powers.d.ts +8 -8
  75. package/src/node-powers.d.ts.map +1 -1
  76. package/src/node-powers.js +29 -24
  77. package/src/parse-archive-cjs.d.ts +3 -2
  78. package/src/parse-archive-cjs.d.ts.map +1 -1
  79. package/src/parse-archive-cjs.js +5 -4
  80. package/src/parse-archive-mjs.d.ts +3 -2
  81. package/src/parse-archive-mjs.d.ts.map +1 -1
  82. package/src/parse-archive-mjs.js +7 -5
  83. package/src/parse-bytes.d.ts +3 -2
  84. package/src/parse-bytes.d.ts.map +1 -1
  85. package/src/parse-bytes.js +7 -5
  86. package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
  87. package/src/parse-cjs-shared-export-wrapper.js +7 -6
  88. package/src/parse-cjs.d.ts +3 -2
  89. package/src/parse-cjs.d.ts.map +1 -1
  90. package/src/parse-cjs.js +14 -5
  91. package/src/parse-json.d.ts.map +1 -1
  92. package/src/parse-json.js +6 -6
  93. package/src/parse-mjs.d.ts +3 -2
  94. package/src/parse-mjs.d.ts.map +1 -1
  95. package/src/parse-mjs.js +3 -3
  96. package/src/parse-pre-cjs.d.ts +3 -2
  97. package/src/parse-pre-cjs.d.ts.map +1 -1
  98. package/src/parse-pre-cjs.js +14 -4
  99. package/src/parse-pre-mjs.d.ts +3 -2
  100. package/src/parse-pre-mjs.d.ts.map +1 -1
  101. package/src/parse-pre-mjs.js +4 -3
  102. package/src/parse-text.d.ts +3 -2
  103. package/src/parse-text.d.ts.map +1 -1
  104. package/src/parse-text.js +6 -5
  105. package/src/policy-format.d.ts +1 -1
  106. package/src/policy-format.d.ts.map +1 -1
  107. package/src/policy-format.js +5 -7
  108. package/src/policy.d.ts.map +1 -1
  109. package/src/policy.js +15 -10
  110. package/src/powers.d.ts.map +1 -1
  111. package/src/powers.js +15 -12
  112. package/src/search.d.ts.map +1 -1
  113. package/src/search.js +10 -7
  114. package/src/types/compartment-map-schema.d.ts +98 -0
  115. package/src/types/compartment-map-schema.d.ts.map +1 -0
  116. package/src/types/compartment-map-schema.ts +116 -0
  117. package/src/types/external.d.ts +256 -0
  118. package/src/types/external.d.ts.map +1 -0
  119. package/src/types/external.ts +379 -0
  120. package/src/types/internal.d.ts +161 -0
  121. package/src/types/internal.d.ts.map +1 -0
  122. package/src/types/internal.ts +216 -0
  123. package/src/types/node-powers.d.ts +46 -0
  124. package/src/types/node-powers.d.ts.map +1 -0
  125. package/src/types/node-powers.ts +52 -0
  126. package/src/types/policy-schema.d.ts +81 -0
  127. package/src/types/policy-schema.d.ts.map +1 -0
  128. package/src/types/policy-schema.ts +131 -0
  129. package/src/types/policy.d.ts +20 -0
  130. package/src/types/policy.d.ts.map +1 -0
  131. package/src/types/policy.ts +42 -0
  132. package/src/types/powers.d.ts +83 -0
  133. package/src/types/powers.d.ts.map +1 -0
  134. package/src/types/powers.ts +120 -0
  135. package/src/types/typescript.d.ts +28 -0
  136. package/src/types/typescript.d.ts.map +1 -0
  137. package/src/types/typescript.ts +41 -0
  138. package/src/types-external.d.ts +14 -0
  139. package/src/types-external.js +2 -0
  140. package/src/types.d.ts +9 -787
  141. package/src/url.d.ts.map +1 -1
  142. package/src/url.js +2 -3
  143. package/src/types.d.ts.map +0 -1
  144. package/src/types.js +0 -995
  145. package/types.d.ts +0 -19
@@ -1,14 +1,12 @@
1
- /* Provides shared functionality for {@link parse-cjs.js} and {@link
1
+ /**
2
+ * @module Provides shared functionality for {@link parse-cjs.js} and {@link
2
3
  * parse-archive-cjs.js} toward importing or archiving CommonJS as a virtual
3
4
  * module source.
4
5
  */
5
6
 
6
- import { findInvalidReadNowPowersProps, isReadNowPowers } from './powers.js';
7
-
8
- // @ts-check
7
+ /** @import {ReadFn, ReadPowers} from './types.js' */
9
8
 
10
- /** @import {ReadFn} from './types.js' */
11
- /** @import {ReadPowers} from './types.js' */
9
+ import { findInvalidReadNowPowersProps, isReadNowPowers } from './powers.js';
12
10
 
13
11
  const { apply } = Reflect;
14
12
  const { freeze, keys, create, hasOwnProperty, defineProperty } = Object;
@@ -20,6 +18,9 @@ const { freeze, keys, create, hasOwnProperty, defineProperty } = Object;
20
18
  */
21
19
  const has = (object, key) => apply(hasOwnProperty, object, [key]);
22
20
 
21
+ /**
22
+ * @param {string} path
23
+ */
23
24
  const noTrailingSlash = path => {
24
25
  const l = path.length - 1;
25
26
  return path[l] === '\\' || path[l] === '/' ? path.slice(0, -1) : path;
@@ -1,5 +1,6 @@
1
- /** @type {import('./types.js').ParseFn} */
2
- export const parseCjs: import("./types.js").ParseFn;
1
+ /** @type {ParseFn} */
2
+ export const parseCjs: ParseFn;
3
3
  declare const _default: import("./types.js").ParserImplementation;
4
4
  export default _default;
5
+ import type { ParseFn } from './types.js';
5
6
  //# sourceMappingURL=parse-cjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-cjs.d.ts","sourceRoot":"","sources":["parse-cjs.js"],"names":[],"mappings":"AAaA,2CAA2C;AAC3C,uBADW,OAAO,YAAY,EAAE,OAAO,CAkDrC;wBAES,OAAO,YAAY,EAAE,oBAAoB"}
1
+ {"version":3,"file":"parse-cjs.d.ts","sourceRoot":"","sources":["parse-cjs.js"],"names":[],"mappings":"AAcA,sBAAsB;AACtB,uBADW,OAAO,CA0DhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BArEzB,YAAY"}
package/src/parse-cjs.js CHANGED
@@ -1,8 +1,9 @@
1
- /* Provides language behavior (parser) for importing CommonJS as a virtual
2
- * module source.
1
+ /**
2
+ * @module Provides language behavior (parser) for importing CommonJS as a
3
+ * virtual module source.
3
4
  */
4
5
 
5
- // @ts-check
6
+ /** @import {ParseFn} from './types.js' */
6
7
 
7
8
  import { analyzeCommonJS } from '@endo/cjs-module-analyzer';
8
9
  import { wrap, getModulePaths } from './parse-cjs-shared-export-wrapper.js';
@@ -11,7 +12,7 @@ const textDecoder = new TextDecoder();
11
12
 
12
13
  const { freeze } = Object;
13
14
 
14
- /** @type {import('./types.js').ParseFn} */
15
+ /** @type {ParseFn} */
15
16
  export const parseCjs = (
16
17
  bytes,
17
18
  _specifier,
@@ -51,7 +52,15 @@ export const parseCjs = (
51
52
  readPowers,
52
53
  });
53
54
 
54
- functor(require, moduleExports, module, filename, dirname);
55
+ // In CommonJS, the top-level `this` is the `module.exports` object.
56
+ functor.call(
57
+ moduleExports,
58
+ require,
59
+ moduleExports,
60
+ module,
61
+ filename,
62
+ dirname,
63
+ );
55
64
 
56
65
  afterExecute();
57
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["parse-json.js"],"names":[],"mappings":"AAoBA,sBAAsB;AACtB,wBADW,OAAO,CAoBhB;wBAES,oBAAoB;;6BArCJ,YAAY;0CACC,YAAY"}
1
+ {"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["parse-json.js"],"names":[],"mappings":"AAmBA,sBAAsB;AACtB,wBADW,OAAO,CAqBhB;wBAES,oBAAoB;;6BAtCiB,YAAY;0CAAZ,YAAY"}
package/src/parse-json.js CHANGED
@@ -1,10 +1,9 @@
1
- /* Provides language support for importing JSON modules. */
1
+ /** @module Provides language support for importing JSON modules. */
2
2
 
3
- // @ts-check
4
-
5
- /** @import {Harden} from 'ses' */
6
- /** @import {ParseFn} from './types.js' */
7
- /** @import {ParserImplementation} from './types.js' */
3
+ /**
4
+ * @import {Harden} from 'ses'
5
+ * @import {ParseFn, ParserImplementation} from './types.js'
6
+ */
8
7
 
9
8
  import { parseLocatedJson } from './json.js';
10
9
 
@@ -21,6 +20,7 @@ const textDecoder = new TextDecoder();
21
20
  /** @type {ParseFn} */
22
21
  export const parseJson = (bytes, _specifier, location, _packageLocation) => {
23
22
  const source = textDecoder.decode(bytes);
23
+ /** @type {Array<string>} */
24
24
  const imports = freeze([]);
25
25
 
26
26
  /**
@@ -1,5 +1,6 @@
1
- /** @type {import('./types.js').ParseFn} */
2
- export const parseMjs: import("./types.js").ParseFn;
1
+ /** @type {ParseFn} */
2
+ export const parseMjs: ParseFn;
3
3
  declare const _default: import("./types.js").ParserImplementation;
4
4
  export default _default;
5
+ import type { ParseFn } from './types.js';
5
6
  //# sourceMappingURL=parse-mjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-mjs.d.ts","sourceRoot":"","sources":["parse-mjs.js"],"names":[],"mappings":"AAQA,2CAA2C;AAC3C,uBADW,OAAO,YAAY,EAAE,OAAO,CAqBrC;wBAES,OAAO,YAAY,EAAE,oBAAoB"}
1
+ {"version":3,"file":"parse-mjs.d.ts","sourceRoot":"","sources":["parse-mjs.js"],"names":[],"mappings":"AAQA,sBAAsB;AACtB,uBADW,OAAO,CAqBhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BA7BzB,YAAY"}
package/src/parse-mjs.js CHANGED
@@ -1,12 +1,12 @@
1
- /* Provides language behavior (a parser) for importing ESM. */
1
+ /** @module Provides language behavior (a parser) for importing ESM. */
2
2
 
3
- // @ts-check
3
+ /** @import {ParseFn} from './types.js' */
4
4
 
5
5
  import { ModuleSource } from '@endo/module-source';
6
6
 
7
7
  const textDecoder = new TextDecoder();
8
8
 
9
- /** @type {import('./types.js').ParseFn} */
9
+ /** @type {ParseFn} */
10
10
  export const parseMjs = (
11
11
  bytes,
12
12
  _specifier,
@@ -1,5 +1,6 @@
1
- /** @type {import('./types.js').ParseFn} */
2
- export const parsePreCjs: import("./types.js").ParseFn;
1
+ /** @type {ParseFn} */
2
+ export const parsePreCjs: ParseFn;
3
3
  declare const _default: import("./types.js").ParserImplementation;
4
4
  export default _default;
5
+ import type { ParseFn } from './types.js';
5
6
  //# sourceMappingURL=parse-pre-cjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-pre-cjs.d.ts","sourceRoot":"","sources":["parse-pre-cjs.js"],"names":[],"mappings":"AAaA,2CAA2C;AAC3C,0BADW,OAAO,YAAY,EAAE,OAAO,CA+CrC;wBAES,OAAO,YAAY,EAAE,oBAAoB"}
1
+ {"version":3,"file":"parse-pre-cjs.d.ts","sourceRoot":"","sources":["parse-pre-cjs.js"],"names":[],"mappings":"AAeA,sBAAsB;AACtB,0BADW,OAAO,CAuDhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BAhEzB,YAAY"}
@@ -1,17 +1,19 @@
1
- /* Provides language-specific behavior for importing pre-compiled CommonJS.
1
+ /**
2
+ * @module Provides language-specific behavior for importing pre-compiled
3
+ * CommonJS.
2
4
  * Pre-compiled CommonJS is a module in JSON format that describes its imports,
3
5
  * exports, and source to execute in the presence of `require`, `module`, and
4
6
  * `exports`.
5
7
  */
6
8
 
7
- // @ts-check
9
+ /** @import {ParseFn} from './types.js' */
8
10
 
9
11
  import { parseLocatedJson } from './json.js';
10
12
  import { wrap, getModulePaths } from './parse-cjs-shared-export-wrapper.js';
11
13
 
12
14
  const textDecoder = new TextDecoder();
13
15
 
14
- /** @type {import('./types.js').ParseFn} */
16
+ /** @type {ParseFn} */
15
17
  export const parsePreCjs = (
16
18
  bytes,
17
19
  _specifier,
@@ -43,7 +45,15 @@ export const parsePreCjs = (
43
45
  readPowers,
44
46
  });
45
47
 
46
- functor(require, moduleExports, module, filename, dirname);
48
+ // In CommonJS, the top-level `this` is the `module.exports` object.
49
+ functor.call(
50
+ moduleExports,
51
+ require,
52
+ moduleExports,
53
+ module,
54
+ filename,
55
+ dirname,
56
+ );
47
57
 
48
58
  afterExecute();
49
59
  };
@@ -1,5 +1,6 @@
1
- /** @type {import('./types.js').ParseFn} */
2
- export const parsePreMjs: import("./types.js").ParseFn;
1
+ /** @type {ParseFn} */
2
+ export const parsePreMjs: ParseFn;
3
3
  declare const _default: import("./types.js").ParserImplementation;
4
4
  export default _default;
5
+ import type { ParseFn } from './types.js';
5
6
  //# sourceMappingURL=parse-pre-mjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-pre-mjs.d.ts","sourceRoot":"","sources":["parse-pre-mjs.js"],"names":[],"mappings":"AAYA,2CAA2C;AAC3C,0BADW,OAAO,YAAY,EAAE,OAAO,CAsBrC;wBAES,OAAO,YAAY,EAAE,oBAAoB"}
1
+ {"version":3,"file":"parse-pre-mjs.d.ts","sourceRoot":"","sources":["parse-pre-mjs.js"],"names":[],"mappings":"AAaA,sBAAsB;AACtB,0BADW,OAAO,CAsBhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BA9BzB,YAAY"}
@@ -1,16 +1,17 @@
1
- /* Provides language-specific behaviors for importing pre-compiled ESM.
1
+ /**
2
+ * @module Provides language-specific behaviors for importing pre-compiled ESM.
2
3
  * Pre-compiling or translating ESM from a module to a script with a
3
4
  * calling-convention is necessary to prepare an archive so that it can be
4
5
  * imported by the SES shim without entraining a dependency on Babel.
5
6
  */
6
7
 
7
- // @ts-check
8
+ /** @import {ParseFn} from './types.js' */
8
9
 
9
10
  import { parseLocatedJson } from './json.js';
10
11
 
11
12
  const textDecoder = new TextDecoder();
12
13
 
13
- /** @type {import('./types.js').ParseFn} */
14
+ /** @type {ParseFn} */
14
15
  export const parsePreMjs = (
15
16
  bytes,
16
17
  _specifier,
@@ -1,5 +1,6 @@
1
- /** @type {import('./types.js').ParseFn} */
2
- export const parseText: import("./types.js").ParseFn;
1
+ /** @type {ParseFn} */
2
+ export const parseText: ParseFn;
3
3
  declare const _default: import("./types.js").ParserImplementation;
4
4
  export default _default;
5
+ import type { ParseFn } from './types.js';
5
6
  //# sourceMappingURL=parse-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-text.d.ts","sourceRoot":"","sources":["parse-text.js"],"names":[],"mappings":"AAiBA,2CAA2C;AAC3C,wBADW,OAAO,YAAY,EAAE,OAAO,CAuBrC;wBAES,OAAO,YAAY,EAAE,oBAAoB"}
1
+ {"version":3,"file":"parse-text.d.ts","sourceRoot":"","sources":["parse-text.js"],"names":[],"mappings":"AAkBA,sBAAsB;AACtB,wBADW,OAAO,CAuBhB;wBAES,OAAO,YAAY,EAAE,oBAAoB;;6BArCzB,YAAY"}
package/src/parse-text.js CHANGED
@@ -1,9 +1,10 @@
1
- /* Provides language-behaviors for importing a module as a document that
2
- * exports itself as a string based on a UTF-8 interpretation of the module's
3
- * text.
1
+ /**
2
+ * @module Provides language-behaviors for importing a module as a document
3
+ * that exports itself as a string based on a UTF-8 interpretation of the
4
+ * module's text.
4
5
  */
5
6
 
6
- // @ts-check
7
+ /** @import {ParseFn} from './types.js' */
7
8
 
8
9
  /**
9
10
  * TypeScript cannot be relied upon to deal with the nuances of Readonly, so we
@@ -15,7 +16,7 @@ const freeze = Object.freeze;
15
16
 
16
17
  const textDecoder = new TextDecoder();
17
18
 
18
- /** @type {import('./types.js').ParseFn} */
19
+ /** @type {ParseFn} */
19
20
  export const parseText = (bytes, _specifier, _location, _packageLocation) => {
20
21
  const text = textDecoder.decode(bytes);
21
22
 
@@ -3,7 +3,7 @@ export function isAllowingEverything(policyValue: unknown): policyValue is impor
3
3
  export function isAttenuationDefinition(allegedDefinition: unknown): allegedDefinition is import("./types.js").AttenuationDefinition;
4
4
  export function getAttenuatorFromDefinition(attenuationDefinition: import("./types.js").AttenuationDefinition): import("./types.js").UnifiedAttenuationDefinition;
5
5
  export function assertPackagePolicy(allegedPackagePolicy: unknown, path: string, url?: string | undefined): asserts allegedPackagePolicy is SomePackagePolicy | undefined;
6
- export function assertPolicy(allegedPolicy: unknown): asserts allegedPolicy is SomePolicy | undefined;
6
+ export function assertPolicy(allegedPolicy: unknown): asserts allegedPolicy is (SomePolicy | undefined);
7
7
  import type { SomePackagePolicy } from './types.js';
8
8
  import type { SomePolicy } from './types.js';
9
9
  //# sourceMappingURL=policy-format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"policy-format.d.ts","sourceRoot":"","sources":["policy-format.js"],"names":[],"mappings":"AA6BO,kDALI,OAAO,YAAY,EAAE,aAAa,SAClC,UAAU,GAAC,SAAS,GAAC,UAAU,YAC/B,MAAM,GACJ,OAAO,GAAG,OAAO,YAAY,EAAE,qBAAqB,CAyBhE;AAQM,kDAHI,OAAO,GACL,WAAW,IAAI,OAAO,YAAY,EAAE,cAAc,CAGxB;AAOhC,2DAHI,OAAO,GACL,iBAAiB,IAAI,OAAO,YAAY,EAAE,qBAAqB,CAS3E;AAOM,mEAHI,OAAO,YAAY,EAAE,qBAAqB,GACxC,OAAO,YAAY,EAAE,4BAA4B,CAuB7D;AA0CM,0DALI,OAAO,QACP,MAAM,6BAEJ,QAAQ,oBAAoB,IAAI,iBAAiB,GAAC,SAAS,CA4DvE;AAUM,4CAHI,OAAO,GACL,QAAQ,aAAa,IAAI,UAAU,GAAC,SAAS,CAgCzD;uCA7OoC,YAAY;gCACnB,YAAY"}
1
+ {"version":3,"file":"policy-format.d.ts","sourceRoot":"","sources":["policy-format.js"],"names":[],"mappings":"AA2BO,kDALI,OAAO,YAAY,EAAE,aAAa,SAClC,UAAU,GAAC,SAAS,GAAC,UAAU,YAC/B,MAAM,GACJ,OAAO,GAAG,OAAO,YAAY,EAAE,qBAAqB,CAyBhE;AAQM,kDAHI,OAAO,GACL,WAAW,IAAI,OAAO,YAAY,EAAE,cAAc,CAGxB;AAOhC,2DAHI,OAAO,GACL,iBAAiB,IAAI,OAAO,YAAY,EAAE,qBAAqB,CAS3E;AAOM,mEAHI,OAAO,YAAY,EAAE,qBAAqB,GACxC,OAAO,YAAY,EAAE,4BAA4B,CAuB7D;AA0CM,0DALI,OAAO,QACP,MAAM,6BAEJ,QAAQ,oBAAoB,IAAI,iBAAiB,GAAC,SAAS,CA4DvE;AAUM,4CAHI,OAAO,GACL,QAAQ,aAAa,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,CAgC7D;uCA5OgD,YAAY;gCAAZ,YAAY"}
@@ -1,11 +1,9 @@
1
- /* Provides functions for enforcing compartment-map linkage and global variable
2
- * policies for each compartment.
1
+ /**
2
+ * @module Provides functions for enforcing compartment-map linkage and global
3
+ * variable policies for each compartment.
3
4
  */
4
5
 
5
- // @ts-check
6
-
7
- /** @import {SomePackagePolicy} from './types.js' */
8
- /** @import {SomePolicy} from './types.js' */
6
+ /** @import {SomePackagePolicy, SomePolicy} from './types.js' */
9
7
 
10
8
  const { entries, keys } = Object;
11
9
  const { isArray } = Array;
@@ -209,7 +207,7 @@ export const assertPackagePolicy = (allegedPackagePolicy, path, url) => {
209
207
  * It also moonlights as a type guard.
210
208
  *
211
209
  * @param {unknown} allegedPolicy - Alleged `Policy` to test
212
- * @returns {asserts allegedPolicy is SomePolicy|undefined}
210
+ * @returns {asserts allegedPolicy is (SomePolicy | undefined)}
213
211
  */
214
212
  export const assertPolicy = allegedPolicy => {
215
213
  if (allegedPolicy === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["policy.js"],"names":[],"mappings":"AA2BA;;GAEG;AACH,sDAAuD;AAyDhD,gEAFM,KAAK,CAAC,MAAM,CAAC,CAezB;AA0BM,qDAJI,gBAAgB,iBAChB,aAAa,GACX,OAAO,CASnB;;;;;;;;;AAKE,+CACQ,gBAAg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OAAO,KAAK,EAAE,+BAA+B,UAC7C,aAAa,eACb,2BAA2B,GACzB,OAAO,CAAC,OAAO,KAAK,EAAE,+BAA+B,CAAC,CAyBlE;;;;;;;;;;;;;;4BAveS,YAAY;sCAAZ,YAAY;mCAAZ,YAAY;gCAAZ,YAAY;uCAAZ,YAAY;2CAAZ,YAAY;iDAAZ,YAAY"}
package/src/policy.js CHANGED
@@ -1,17 +1,22 @@
1
- /* Provides mechanisms for interacting with Compartment Map runtime policies.
1
+ /**
2
+ * @module Provides mechanisms for interacting with Compartment Map runtime policies.
2
3
  */
3
4
 
4
5
  // @ts-check
5
6
 
6
- /** @import {Policy} from './types.js' */
7
- /** @import {PackagePolicy} from './types.js' */
8
- /** @import {AttenuationDefinition} from './types.js' */
9
- /** @import {PackageNamingKit} from './types.js' */
10
- /** @import {DeferredAttenuatorsProvider} from './types.js' */
11
- /** @import {CompartmentDescriptor} from './types.js' */
12
- /** @import {Attenuator} from './types.js' */
13
- /** @import {SomePolicy} from './types.js' */
14
- /** @import {SomePackagePolicy} from './types.js' */
7
+ /**
8
+ * @import {
9
+ * Policy,
10
+ * PackagePolicy,
11
+ * AttenuationDefinition,
12
+ * PackageNamingKit,
13
+ * DeferredAttenuatorsProvider,
14
+ * CompartmentDescriptor,
15
+ * Attenuator,
16
+ * SomePolicy,
17
+ * SomePackagePolicy,
18
+ * } from './types.js'
19
+ */
15
20
 
16
21
  import {
17
22
  getAttenuatorFromDefinition,
@@ -1 +1 @@
1
- {"version":3,"file":"powers.d.ts","sourceRoot":"","sources":["powers.js"],"names":[],"mappings":"AA0BO,yCAHI,MAAM,GAAG,UAAU,GAAG,eAAe,GACnC,eAAe,CAgC3B;AAiBM,uCAHI,UAAU,GAAC,MAAM,GAAC,SAAS,GACzB,KAAK,IAAI,aAAa,CAShC;AAWI,wFAFM,iBAAiB,EAAE,CAS/B;4BAtFyB,YAAY;gCACR,YAAY;qCACP,YAAY;mCAJd,YAAY;uCACR,YAAY"}
1
+ {"version":3,"file":"powers.d.ts","sourceRoot":"","sources":["powers.js"],"names":[],"mappings":"AA6BO,yCAHI,MAAM,GAAG,UAAU,GAAG,eAAe,GACnC,eAAe,CAgC3B;AAiBM,uCAHI,UAAU,GAAC,MAAM,GAAC,SAAS,GACzB,KAAK,IAAI,aAAa,CAShC;AAWI,wFAFM,iBAAiB,EAAE,CAS/B;4BApFS,YAAY;gCAAZ,YAAY;qCAAZ,YAAY;mCAAZ,YAAY;uCAAZ,YAAY"}
package/src/powers.js CHANGED
@@ -1,19 +1,22 @@
1
- /* As the interface of the Compartment Mapper evolved, it became necessary to
2
- * expand some function signatures that accepted a single power to one that
3
- * accepted a powers object.
1
+ /**
2
+ * @module As the interface of the Compartment Mapper evolved, it became
3
+ * necessary to expand some function signatures that accepted a single power to
4
+ * one that accepted a powers object.
4
5
  * This module provides functions for safely unpacking I/O capabilities and
5
6
  * maintaining backward-compatibility with older accepted usage patterns.
6
7
  */
7
8
 
8
- // @ts-check
9
-
10
- /** @import {CanonicalFn} from './types.js' */
11
- /** @import {ReadNowPowers} from './types.js' */
12
- /** @import {ReadNowPowersProp} from './types.js' */
13
- /** @import {ReadFn} from './types.js' */
14
- /** @import {ReadPowers} from './types.js' */
15
- /** @import {MaybeReadPowers} from './types.js' */
16
- /** @import {MaybeReadFn} from './types.js' */
9
+ /**
10
+ * @import {
11
+ * CanonicalFn,
12
+ * ReadNowPowers,
13
+ * ReadNowPowersProp,
14
+ * ReadFn,
15
+ * ReadPowers,
16
+ * MaybeReadPowers,
17
+ * MaybeReadFn,
18
+ * } from './types.js'
19
+ */
17
20
 
18
21
  const { freeze } = Object;
19
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"AAqCO,iCALM,CAAC,YACH,MAAM,uBACN,CAAC,QAAQ,EAAC,MAAM,KAAG,OAAO,CAAC,CAAC,GAAC,SAAS,CAAC,GACrC,OAAO,CAAC;IAAC,IAAI,EAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,yBAAyB,EAAE,MAAM,CAAA;CAAC,CAAC,CA0BpG;AAoCM,mCATI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,GACJ,OAAO,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAoBJ;4BA7GyB,YAAY;gCACR,YAAY;qCACP,YAAY"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["search.js"],"names":[],"mappings":"AAwCO,iCALM,CAAC,YACH,MAAM,uBACN,CAAC,QAAQ,EAAC,MAAM,KAAG,OAAO,CAAC,CAAC,GAAC,SAAS,CAAC,GACrC,OAAO,CAAC;IAAC,IAAI,EAAC,CAAC,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAC,MAAM,CAAC;IAAC,yBAAyB,EAAE,MAAM,CAAA;CAAC,CAAC,CA0BpG;AAoCM,mCATI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,MAAM,GACJ,OAAO,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAoBJ;4BA5GS,YAAY;gCAAZ,YAAY;qCAAZ,YAAY"}
package/src/search.js CHANGED
@@ -1,12 +1,15 @@
1
- /* Provides the behavior for `node-modules.js` to find modules and packages
2
- * according to the Node.js `node_modules` convention.
1
+ /**
2
+ * @module Provides the behavior for `node-modules.js` to find modules and
3
+ * packages according to the Node.js `node_modules` convention.
3
4
  */
4
5
 
5
- // @ts-check
6
-
7
- /** @import {ReadFn} from './types.js' */
8
- /** @import {ReadPowers} from './types.js' */
9
- /** @import {MaybeReadPowers} from './types.js' */
6
+ /**
7
+ * @import {
8
+ * ReadFn,
9
+ * ReadPowers,
10
+ * MaybeReadPowers,
11
+ * } from './types.js'
12
+ */
10
13
 
11
14
  import { relativize } from './node-module-specifier.js';
12
15
  import { relative } from './url.js';
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @module These types describe the schema of a `compartment-map.json`, which
3
+ * in turn describes how to load and link an application from storage, like a
4
+ * file system, web host, or zip archive.
5
+ */
6
+ import type { SomePackagePolicy } from './policy-schema.js';
7
+ import type { LiteralUnion } from './typescript.js';
8
+ /**
9
+ * A compartment map describes how to construct an application as a graph of
10
+ * Compartments, each corresponding to Node.js style packaged modules.
11
+ */
12
+ export type CompartmentMapDescriptor = {
13
+ tags: Array<string>;
14
+ entry: EntryDescriptor;
15
+ compartments: Record<string, CompartmentDescriptor>;
16
+ };
17
+ /**
18
+ * The entry descriptor of a compartment map denotes the root module of an
19
+ * application and the compartment that contains it.
20
+ */
21
+ export type EntryDescriptor = {
22
+ compartment: string;
23
+ module: string;
24
+ };
25
+ /**
26
+ * A compartment descriptor corresponds to a single Compartment
27
+ * of an assembled Application and describes how to construct
28
+ * one for a given library or application `package.json`.
29
+ */
30
+ export type CompartmentDescriptor = {
31
+ label: string;
32
+ /** shortest path of dependency names to this compartment */
33
+ path?: Array<string>;
34
+ /**
35
+ * the name of the originating package suitable for constructing a sourceURL
36
+ * prefix that will match it to files in a developer workspace.
37
+ */
38
+ name: string;
39
+ location: string;
40
+ /**
41
+ * whether this compartment was retained by any module in the solution. This
42
+ * property should never appear in an archived compartment map.
43
+ */
44
+ retained?: boolean;
45
+ modules: Record<string, ModuleDescriptor>;
46
+ scopes: Record<string, ScopeDescriptor>;
47
+ /** language for extension */
48
+ parsers: LanguageForExtension;
49
+ /** language for module specifier */
50
+ types: LanguageForModuleSpecifier;
51
+ /** policy specific to compartment */
52
+ policy: SomePackagePolicy;
53
+ /** List of compartment names this Compartment depends upon */
54
+ compartments: Set<string>;
55
+ };
56
+ /**
57
+ * For every module explicitly mentioned in an `exports` field of a
58
+ * `package.json`, there is a corresponding module descriptor.
59
+ */
60
+ export type ModuleDescriptor = {
61
+ compartment?: string;
62
+ module?: string;
63
+ location?: string;
64
+ parser?: Language;
65
+ /** in base 16, hex */
66
+ sha512?: string;
67
+ exit?: string;
68
+ deferredError?: string;
69
+ retained?: boolean;
70
+ };
71
+ /**
72
+ * Scope descriptors link all names under a prefix to modules in another
73
+ * compartment, like a wildcard.
74
+ * These are employed to link any module not explicitly mentioned
75
+ * in a `package.json` file, when that `package.json` file does not have
76
+ * an explicit `exports` map.
77
+ */
78
+ export type ScopeDescriptor = {
79
+ compartment: string;
80
+ module?: string;
81
+ };
82
+ /**
83
+ * Natively-recognized and custom languages
84
+ */
85
+ export type Language = LiteralUnion<BuiltinLanguage, string>;
86
+ /**
87
+ * Languages natively recognized by `compartment-mapper`
88
+ */
89
+ export type BuiltinLanguage = 'mjs' | 'cjs' | 'json' | 'bytes' | 'text' | 'pre-mjs-json' | 'pre-cjs-json';
90
+ /**
91
+ * Mapping of file extension to {@link Language Languages}.
92
+ */
93
+ export type LanguageForExtension = Record<string, Language>;
94
+ /**
95
+ * Mapping of module specifier to {@link Language Languages}.
96
+ */
97
+ export type LanguageForModuleSpecifier = Record<string, Language>;
98
+ //# sourceMappingURL=compartment-map-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compartment-map-schema.d.ts","sourceRoot":"","sources":["compartment-map-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,KAAK,EAAE,eAAe,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,E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