@endo/compartment-mapper 1.6.3 → 2.1.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 (95) hide show
  1. package/package.json +24 -14
  2. package/src/archive-lite.d.ts +7 -7
  3. package/src/archive-lite.d.ts.map +1 -1
  4. package/src/archive-lite.js +81 -30
  5. package/src/archive.d.ts.map +1 -1
  6. package/src/archive.js +7 -0
  7. package/src/bundle-lite.d.ts +3 -3
  8. package/src/bundle-lite.d.ts.map +1 -1
  9. package/src/bundle-lite.js +19 -24
  10. package/src/bundle.d.ts +3 -3
  11. package/src/bundle.d.ts.map +1 -1
  12. package/src/bundle.js +19 -24
  13. package/src/capture-lite.d.ts +2 -2
  14. package/src/capture-lite.d.ts.map +1 -1
  15. package/src/capture-lite.js +243 -25
  16. package/src/compartment-map.d.ts +9 -2
  17. package/src/compartment-map.d.ts.map +1 -1
  18. package/src/compartment-map.js +738 -254
  19. package/src/digest.d.ts +22 -2
  20. package/src/digest.d.ts.map +1 -1
  21. package/src/digest.js +180 -57
  22. package/src/generic-graph.d.ts +7 -25
  23. package/src/generic-graph.d.ts.map +1 -1
  24. package/src/generic-graph.js +83 -108
  25. package/src/guards.d.ts +18 -0
  26. package/src/guards.d.ts.map +1 -0
  27. package/src/guards.js +109 -0
  28. package/src/hooks.md +124 -0
  29. package/src/import-archive-lite.d.ts.map +1 -1
  30. package/src/import-archive-lite.js +15 -11
  31. package/src/import-archive.d.ts +5 -19
  32. package/src/import-archive.d.ts.map +1 -1
  33. package/src/import-archive.js +7 -27
  34. package/src/import-hook.d.ts +4 -3
  35. package/src/import-hook.d.ts.map +1 -1
  36. package/src/import-hook.js +140 -70
  37. package/src/import-lite.d.ts +6 -6
  38. package/src/import-lite.d.ts.map +1 -1
  39. package/src/import-lite.js +8 -5
  40. package/src/import.d.ts +3 -3
  41. package/src/import.d.ts.map +1 -1
  42. package/src/import.js +16 -6
  43. package/src/infer-exports.d.ts +4 -2
  44. package/src/infer-exports.d.ts.map +1 -1
  45. package/src/infer-exports.js +172 -23
  46. package/src/link.d.ts +4 -3
  47. package/src/link.d.ts.map +1 -1
  48. package/src/link.js +122 -52
  49. package/src/node-modules.d.ts +4 -3
  50. package/src/node-modules.d.ts.map +1 -1
  51. package/src/node-modules.js +513 -151
  52. package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
  53. package/src/parse-cjs-shared-export-wrapper.js +3 -1
  54. package/src/pattern-replacement.d.ts +6 -0
  55. package/src/pattern-replacement.d.ts.map +1 -0
  56. package/src/pattern-replacement.js +198 -0
  57. package/src/policy-format.d.ts +22 -5
  58. package/src/policy-format.d.ts.map +1 -1
  59. package/src/policy-format.js +342 -108
  60. package/src/policy.d.ts +13 -28
  61. package/src/policy.d.ts.map +1 -1
  62. package/src/policy.js +161 -106
  63. package/src/types/canonical-name.d.ts +97 -0
  64. package/src/types/canonical-name.d.ts.map +1 -0
  65. package/src/types/canonical-name.ts +151 -0
  66. package/src/types/compartment-map-schema.d.ts +121 -35
  67. package/src/types/compartment-map-schema.d.ts.map +1 -1
  68. package/src/types/compartment-map-schema.ts +211 -37
  69. package/src/types/external.d.ts +240 -76
  70. package/src/types/external.d.ts.map +1 -1
  71. package/src/types/external.ts +305 -74
  72. package/src/types/generic-graph.d.ts +8 -2
  73. package/src/types/generic-graph.d.ts.map +1 -1
  74. package/src/types/generic-graph.ts +7 -2
  75. package/src/types/internal.d.ts +31 -50
  76. package/src/types/internal.d.ts.map +1 -1
  77. package/src/types/internal.ts +60 -58
  78. package/src/types/node-modules.d.ts +112 -14
  79. package/src/types/node-modules.d.ts.map +1 -1
  80. package/src/types/node-modules.ts +152 -13
  81. package/src/types/pattern-replacement.d.ts +62 -0
  82. package/src/types/pattern-replacement.d.ts.map +1 -0
  83. package/src/types/pattern-replacement.ts +70 -0
  84. package/src/types/policy-schema.d.ts +26 -11
  85. package/src/types/policy-schema.d.ts.map +1 -1
  86. package/src/types/policy-schema.ts +29 -16
  87. package/src/types/policy.d.ts +6 -2
  88. package/src/types/policy.d.ts.map +1 -1
  89. package/src/types/policy.ts +7 -2
  90. package/src/types/powers.d.ts +11 -9
  91. package/src/types/powers.d.ts.map +1 -1
  92. package/src/types/powers.ts +11 -10
  93. package/src/types/typescript.d.ts +28 -0
  94. package/src/types/typescript.d.ts.map +1 -1
  95. package/src/types/typescript.ts +37 -1
@@ -21,14 +21,14 @@ import type { SomeObject } from './typescript.js';
21
21
  export type ReadPowers<T extends string = any> = {
22
22
  canonical: CanonicalFn<T>;
23
23
  read: ReadFn;
24
- maybeRead?: MaybeReadFn;
25
- readNow?: ReadNowFn;
26
- maybeReadNow?: MaybeReadNowFn;
27
- computeSha512?: HashFn;
28
- fileURLToPath?: FileURLToPathFn;
29
- pathToFileURL?: PathToFileURLFn;
30
- requireResolve?: RequireResolveFn;
31
- isAbsolute?: IsAbsoluteFn;
24
+ maybeRead?: MaybeReadFn | undefined;
25
+ readNow?: ReadNowFn | undefined;
26
+ maybeReadNow?: MaybeReadNowFn | undefined;
27
+ computeSha512?: HashFn | undefined;
28
+ fileURLToPath?: FileURLToPathFn | undefined;
29
+ pathToFileURL?: PathToFileURLFn | undefined;
30
+ requireResolve?: RequireResolveFn | undefined;
31
+ isAbsolute?: IsAbsoluteFn | undefined;
32
32
  };
33
33
 
34
34
  /**
@@ -53,8 +53,9 @@ export type MaybeReadPowers<T extends string = any> = ReadPowers<T> & {
53
53
  export type ReadNowPowers<T extends string = any> = Omit<
54
54
  ReadPowers<T>,
55
55
  ReadNowPowersProp
56
- > &
57
- Required<Pick<ReadPowers<T>, ReadNowPowersProp>>;
56
+ > & {
57
+ [P in ReadNowPowersProp]-?: NonNullable<ReadPowers<T>[P]>;
58
+ };
58
59
 
59
60
  /**
60
61
  * These properties are necessary for dynamic require support
@@ -25,6 +25,34 @@ export type Primitive = null | undefined | string | number | boolean | symbol |
25
25
  * https://github.com/Microsoft/TypeScript/issues/29729
26
26
  * Microsoft/TypeScript#29729}. It will be removed as soon as it's not needed
27
27
  * anymore.
28
+ * @see {@link https://www.npmjs.com/package/type-fest}
28
29
  */
29
30
  export type LiteralUnion<LiteralType, PrimitiveType extends Primitive> = LiteralType | (PrimitiveType & Record<never, never>);
31
+ /**
32
+ * Generic type guard function that checks if a value of type `T` is also of type `U`.
33
+ * @template T The type of the value to check.
34
+ * @template U The type that the value should be checked against.
35
+ */
36
+ export type TypeGuard<T, U extends T> = (value: T) => value is U;
37
+ /**
38
+ * Helper type for a generic type guard used in an "extends" clause
39
+ */
40
+ export type SomeTypeGuard = TypeGuard<any, any>;
41
+ /**
42
+ * Infers the type that a type guard function checks for.
43
+ *
44
+ * @template T The type guard function type itself
45
+ * @returns The type that the guard checks for
46
+ */
47
+ export type GuardedType<T> = T extends (value: any) => value is infer U ? U : never;
48
+ /**
49
+ * Converts a union type to an intersection type
50
+ */
51
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
52
+ /**
53
+ * Makes a nicer tooltip for `T` in IDEs (most of the time).
54
+ */
55
+ export type Simplify<T> = {
56
+ [K in keyof T]: T[K];
57
+ } & {};
30
58
  //# sourceMappingURL=typescript.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,CAAC,WAAW,EAAE,aAAa,SAAS,SAAS,IACjE,WAAW,GACX,CAAC,aAAa,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"typescript.d.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/issues/29729
36
36
  * Microsoft/TypeScript#29729}. It will be removed as soon as it's not needed
37
37
  * anymore.
38
+ * @see {@link https://www.npmjs.com/package/type-fest}
38
39
  */
39
40
  export type LiteralUnion<LiteralType, PrimitiveType extends Primitive> =
40
41
  | LiteralType
41
42
  | (PrimitiveType & Record<never, never>);
42
43
 
43
- // LiteralUnion is from https://www.npmjs.com/package/type-fest
44
+ /**
45
+ * Generic type guard function that checks if a value of type `T` is also of type `U`.
46
+ * @template T The type of the value to check.
47
+ * @template U The type that the value should be checked against.
48
+ */
49
+
50
+ export type TypeGuard<T, U extends T> = (value: T) => value is U;
51
+
52
+ /**
53
+ * Helper type for a generic type guard used in an "extends" clause
54
+ */
55
+ export type SomeTypeGuard = TypeGuard<any, any>;
56
+
57
+ /**
58
+ * Infers the type that a type guard function checks for.
59
+ *
60
+ * @template T The type guard function type itself
61
+ * @returns The type that the guard checks for
62
+ */
63
+ export type GuardedType<T> = T extends (value: any) => value is infer U
64
+ ? U
65
+ : never;
66
+
67
+ /**
68
+ * Converts a union type to an intersection type
69
+ */
70
+ export type UnionToIntersection<U> = (
71
+ U extends any ? (k: U) => void : never
72
+ ) extends (k: infer I) => void
73
+ ? I
74
+ : never;
75
+
76
+ /**
77
+ * Makes a nicer tooltip for `T` in IDEs (most of the time).
78
+ */
79
+ export type Simplify<T> = { [K in keyof T]: T[K] } & {};