@endo/compartment-mapper 1.4.0 → 1.6.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 (93) hide show
  1. package/README.md +292 -111
  2. package/bundle.d.ts +1 -1
  3. package/bundle.js +4 -1
  4. package/functor-lite.d.ts +3 -0
  5. package/functor-lite.d.ts.map +1 -0
  6. package/functor-lite.js +4 -0
  7. package/functor.d.ts +3 -0
  8. package/functor.d.ts.map +1 -0
  9. package/functor.js +4 -0
  10. package/import-archive-all-parsers.d.ts +2 -0
  11. package/import-archive-all-parsers.d.ts.map +1 -0
  12. package/import-archive-all-parsers.js +1 -0
  13. package/index.d.ts +1 -1
  14. package/index.js +4 -1
  15. package/package.json +14 -5
  16. package/script-lite.d.ts +3 -0
  17. package/script-lite.d.ts.map +1 -0
  18. package/script-lite.js +4 -0
  19. package/script.d.ts +3 -0
  20. package/script.d.ts.map +1 -0
  21. package/script.js +4 -0
  22. package/src/archive-lite.d.ts +2 -4
  23. package/src/archive-lite.d.ts.map +1 -1
  24. package/src/archive-lite.js +16 -192
  25. package/src/archive.d.ts.map +1 -1
  26. package/src/archive.js +8 -0
  27. package/src/bundle-cjs.d.ts +1 -1
  28. package/src/bundle-cjs.d.ts.map +1 -1
  29. package/src/bundle-cjs.js +57 -28
  30. package/src/bundle-json.d.ts.map +1 -1
  31. package/src/bundle-json.js +2 -3
  32. package/src/bundle-lite.d.ts +91 -0
  33. package/src/bundle-lite.d.ts.map +1 -0
  34. package/src/bundle-lite.js +668 -0
  35. package/src/bundle-mjs.d.ts +2 -2
  36. package/src/bundle-mjs.d.ts.map +1 -1
  37. package/src/bundle-mjs.js +36 -19
  38. package/src/bundle.d.ts +48 -10
  39. package/src/bundle.d.ts.map +1 -1
  40. package/src/bundle.js +399 -127
  41. package/src/capture-lite.d.ts.map +1 -1
  42. package/src/capture-lite.js +10 -188
  43. package/src/digest.d.ts +5 -0
  44. package/src/digest.d.ts.map +1 -0
  45. package/src/digest.js +235 -0
  46. package/src/import-archive-all-parsers.d.ts +11 -0
  47. package/src/import-archive-all-parsers.d.ts.map +1 -0
  48. package/src/import-archive-all-parsers.js +29 -0
  49. package/src/import-archive-lite.d.ts.map +1 -1
  50. package/src/import-archive-lite.js +4 -0
  51. package/src/import-hook.d.ts +3 -16
  52. package/src/import-hook.d.ts.map +1 -1
  53. package/src/import-hook.js +11 -18
  54. package/src/import-lite.d.ts.map +1 -1
  55. package/src/import-lite.js +7 -2
  56. package/src/import.d.ts.map +1 -1
  57. package/src/import.js +2 -0
  58. package/src/link.d.ts.map +1 -1
  59. package/src/link.js +2 -0
  60. package/src/map-parser.d.ts.map +1 -1
  61. package/src/map-parser.js +4 -1
  62. package/src/node-modules.d.ts +4 -47
  63. package/src/node-modules.d.ts.map +1 -1
  64. package/src/node-modules.js +157 -131
  65. package/src/parse-archive-cjs.d.ts.map +1 -1
  66. package/src/parse-archive-cjs.js +8 -3
  67. package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
  68. package/src/parse-cjs-shared-export-wrapper.js +2 -10
  69. package/src/parse-cjs.js +1 -1
  70. package/src/parse-mjs.js +2 -2
  71. package/src/policy.d.ts.map +1 -1
  72. package/src/policy.js +4 -7
  73. package/src/search.d.ts +6 -12
  74. package/src/search.d.ts.map +1 -1
  75. package/src/search.js +29 -12
  76. package/src/types/compartment-map-schema.d.ts +5 -0
  77. package/src/types/compartment-map-schema.d.ts.map +1 -1
  78. package/src/types/compartment-map-schema.ts +5 -0
  79. package/src/types/external.d.ts +159 -12
  80. package/src/types/external.d.ts.map +1 -1
  81. package/src/types/external.ts +180 -12
  82. package/src/types/internal.d.ts +86 -13
  83. package/src/types/internal.d.ts.map +1 -1
  84. package/src/types/internal.ts +107 -13
  85. package/src/types/node-modules.d.ts +79 -0
  86. package/src/types/node-modules.d.ts.map +1 -0
  87. package/src/types/node-modules.ts +89 -0
  88. package/src/types/node-powers.d.ts +4 -4
  89. package/src/types/node-powers.d.ts.map +1 -1
  90. package/src/types/node-powers.ts +4 -4
  91. package/src/types/powers.d.ts +2 -2
  92. package/src/types/powers.d.ts.map +1 -1
  93. package/src/types/powers.ts +2 -2
@@ -0,0 +1,91 @@
1
+ export function makeFunctorFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>;
2
+ export function makeScriptFromMap(readPowers: ReadFn | ReadPowers | MaybeReadPowers, compartmentMap: CompartmentMapDescriptor, options?: BundleOptions | undefined): Promise<string>;
3
+ /**
4
+ * The bundler kit defines a language-specific behavior for injecting a module
5
+ * into a bundle.
6
+ * Each module must allocate cells for its imports and exports, link those cells
7
+ * to the cells of dependencies, and provide both the linker and evaluation behavior
8
+ * for the module.
9
+ * The linker behavior gets injected in a lexical scope with the linker runtime
10
+ * and has access to the cells of all modules, whereas the evaluation behavior
11
+ * gets injected in the generated script's top level lexical scope, so has
12
+ * no accidental visibility into the linkage runtime.
13
+ *
14
+ * For example, JSON modules produce a single "default" cell ("getCells"):
15
+ *
16
+ * { default: cell('default') },
17
+ *
18
+ * Then, the JSON gets injected verbatim for the evaluation behavior ("getFunctor").
19
+ * The linker simply sets the cell to the value.
20
+ *
21
+ * functors[0]['default'].set(modules[0]);
22
+ *
23
+ * For an ECMAScript or CommonJS module, the evaluation behavior is a function
24
+ * that the linker runtime can call to inject it with the cells it needs by
25
+ * the names it sees for them.
26
+ */
27
+ export type BundlerKit = {
28
+ /**
29
+ * Produces a JavaScript string consisting of
30
+ * a function expression followed by a comma delimiter that will be evaluated in
31
+ * a lexical scope with no free variables except the globals.
32
+ * In the generated bundle runtime, the function will receive an environment
33
+ * record: a record mapping every name of the corresponding module's internal
34
+ * namespace to a "cell" it can use to get, set, or observe the linked
35
+ * variable.
36
+ */
37
+ getFunctor: () => string;
38
+ /**
39
+ * Produces a JavaScript string consisting of
40
+ * a JavaScript object and a trailing comma.
41
+ * The string is evaluated in the linker runtime's lexical context.
42
+ */
43
+ getCells: () => string;
44
+ /**
45
+ * Produces a JavaScript string,
46
+ * a statement that effects the module's evaluation behavior using the cells
47
+ * it imports and exports and the evaluated "functor".
48
+ */
49
+ getFunctorCall: () => string;
50
+ /**
51
+ * Produces a JavaScript string
52
+ * that may include statements that bind the cells reexported by this module.
53
+ */
54
+ getReexportsWiring: () => string;
55
+ };
56
+ export type BundleModule<SpecificModuleSource extends unknown> = {
57
+ key: string;
58
+ exit: string;
59
+ compartmentName: string;
60
+ moduleSpecifier: string;
61
+ sourceDirname: string;
62
+ parser: string;
63
+ record: StaticModuleType & SpecificModuleSource;
64
+ resolvedImports: Record<string, string>;
65
+ indexedImports: Record<string, number>;
66
+ bytes: Uint8Array;
67
+ index: number;
68
+ bundlerKit: BundlerKit;
69
+ };
70
+ export type BundleExit = {
71
+ exit: string;
72
+ index: number;
73
+ bundlerKit: BundlerKit;
74
+ indexedImports: Record<string, number>;
75
+ resolvedImports: Record<string, string>;
76
+ };
77
+ export type GetBundlerKit<SpecificModuleSource extends unknown> = (module: BundleModule<SpecificModuleSource>, params: {
78
+ useEvaluate?: boolean | undefined;
79
+ sourceUrlPrefix?: string | undefined;
80
+ }) => BundlerKit;
81
+ export type BundlerSupport<SpecificModuleSource extends unknown> = {
82
+ runtime: string;
83
+ getBundlerKit: GetBundlerKit<SpecificModuleSource>;
84
+ };
85
+ import type { ReadFn } from './types.js';
86
+ import type { ReadPowers } from './types.js';
87
+ import type { MaybeReadPowers } from './types.js';
88
+ import type { CompartmentMapDescriptor } from './types.js';
89
+ import type { BundleOptions } from './types.js';
90
+ import type { StaticModuleType } from 'ses';
91
+ //# sourceMappingURL=bundle-lite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-lite.d.ts","sourceRoot":"","sources":["bundle-lite.js"],"names":[],"mappings":"AA4TO,+CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,wBAAwB,wCAEtB,OAAO,CAAC,MAAM,CAAC,CAgV3B;AAQM,8CALI,MAAM,GAAG,UAAU,GAAG,eAAe,kBACrC,wBAAwB,wCAEtB,OAAO,CAAC,MAAM,CAAC,CAW3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA/mBa,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;8CAAZ,YAAY;mCAAZ,YAAY;sCAVZ,KAAK"}