@endo/compartment-mapper 1.6.3 → 2.0.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.
- package/package.json +12 -16
- package/src/archive-lite.d.ts +7 -7
- package/src/archive-lite.d.ts.map +1 -1
- package/src/archive-lite.js +78 -27
- package/src/archive.d.ts.map +1 -1
- package/src/archive.js +7 -0
- package/src/bundle-lite.d.ts +3 -3
- package/src/bundle-lite.d.ts.map +1 -1
- package/src/bundle-lite.js +19 -24
- package/src/bundle.d.ts +3 -3
- package/src/bundle.d.ts.map +1 -1
- package/src/bundle.js +19 -24
- package/src/capture-lite.d.ts +2 -2
- package/src/capture-lite.d.ts.map +1 -1
- package/src/capture-lite.js +217 -25
- package/src/compartment-map.d.ts +9 -2
- package/src/compartment-map.d.ts.map +1 -1
- package/src/compartment-map.js +737 -254
- package/src/digest.d.ts +22 -2
- package/src/digest.d.ts.map +1 -1
- package/src/digest.js +179 -56
- package/src/generic-graph.d.ts.map +1 -1
- package/src/generic-graph.js +8 -3
- package/src/guards.d.ts +18 -0
- package/src/guards.d.ts.map +1 -0
- package/src/guards.js +109 -0
- package/src/hooks.md +124 -0
- package/src/import-archive-lite.d.ts.map +1 -1
- package/src/import-archive-lite.js +15 -11
- package/src/import-archive.d.ts +5 -19
- package/src/import-archive.d.ts.map +1 -1
- package/src/import-archive.js +7 -27
- package/src/import-hook.d.ts +4 -3
- package/src/import-hook.d.ts.map +1 -1
- package/src/import-hook.js +138 -69
- package/src/import-lite.d.ts +6 -6
- package/src/import-lite.d.ts.map +1 -1
- package/src/import-lite.js +8 -5
- package/src/import.d.ts +3 -3
- package/src/import.d.ts.map +1 -1
- package/src/import.js +16 -6
- package/src/infer-exports.d.ts.map +1 -1
- package/src/infer-exports.js +16 -6
- package/src/link.d.ts +4 -3
- package/src/link.d.ts.map +1 -1
- package/src/link.js +70 -58
- package/src/node-modules.d.ts +4 -3
- package/src/node-modules.d.ts.map +1 -1
- package/src/node-modules.js +482 -114
- package/src/parse-cjs-shared-export-wrapper.d.ts.map +1 -1
- package/src/parse-cjs-shared-export-wrapper.js +3 -1
- package/src/policy-format.d.ts +22 -5
- package/src/policy-format.d.ts.map +1 -1
- package/src/policy-format.js +342 -108
- package/src/policy.d.ts +13 -28
- package/src/policy.d.ts.map +1 -1
- package/src/policy.js +161 -106
- package/src/types/canonical-name.d.ts +97 -0
- package/src/types/canonical-name.d.ts.map +1 -0
- package/src/types/canonical-name.ts +151 -0
- package/src/types/compartment-map-schema.d.ts +114 -35
- package/src/types/compartment-map-schema.d.ts.map +1 -1
- package/src/types/compartment-map-schema.ts +202 -37
- package/src/types/external.d.ts +168 -28
- package/src/types/external.d.ts.map +1 -1
- package/src/types/external.ts +215 -26
- package/src/types/internal.d.ts +23 -42
- package/src/types/internal.d.ts.map +1 -1
- package/src/types/internal.ts +51 -50
- package/src/types/node-modules.d.ts +71 -10
- package/src/types/node-modules.d.ts.map +1 -1
- package/src/types/node-modules.ts +107 -9
- package/src/types/policy-schema.d.ts +26 -11
- package/src/types/policy-schema.d.ts.map +1 -1
- package/src/types/policy-schema.ts +29 -16
- package/src/types/policy.d.ts +6 -2
- package/src/types/policy.d.ts.map +1 -1
- package/src/types/policy.ts +7 -2
- package/src/types/typescript.d.ts +28 -0
- package/src/types/typescript.d.ts.map +1 -1
- package/src/types/typescript.ts +37 -1
package/src/types/external.ts
CHANGED
|
@@ -15,10 +15,105 @@ import type {
|
|
|
15
15
|
import type {
|
|
16
16
|
CompartmentDescriptor,
|
|
17
17
|
CompartmentMapDescriptor,
|
|
18
|
+
DigestedCompartmentMapDescriptor,
|
|
18
19
|
Language,
|
|
19
20
|
LanguageForExtension,
|
|
21
|
+
PackageCompartmentDescriptorName,
|
|
22
|
+
PackageCompartmentDescriptors,
|
|
20
23
|
} from './compartment-map-schema.js';
|
|
24
|
+
import type { SomePolicy } from './policy-schema.js';
|
|
21
25
|
import type { HashFn, ReadFn, ReadPowers } from './powers.js';
|
|
26
|
+
import type { CanonicalName } from './canonical-name.js';
|
|
27
|
+
import type { PackageDescriptor } from './node-modules.js';
|
|
28
|
+
|
|
29
|
+
export type { CanonicalName };
|
|
30
|
+
export type { PackageDescriptor };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Hook executed for each canonical name mentioned in policy but not found in the
|
|
34
|
+
* compartment map
|
|
35
|
+
*/
|
|
36
|
+
export type UnknownCanonicalNameHook = (params: {
|
|
37
|
+
canonicalName: CanonicalName;
|
|
38
|
+
path: string[];
|
|
39
|
+
message: string;
|
|
40
|
+
suggestion?: CanonicalName | undefined;
|
|
41
|
+
log: LogFn;
|
|
42
|
+
}) => void;
|
|
43
|
+
|
|
44
|
+
export type { PackageCompartmentDescriptorName };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Data about a package provided by a {@link PackageDataHook}
|
|
48
|
+
*/
|
|
49
|
+
export type PackageData = {
|
|
50
|
+
name: string;
|
|
51
|
+
packageDescriptor: PackageDescriptor;
|
|
52
|
+
location: FileUrlString;
|
|
53
|
+
canonicalName: PackageCompartmentDescriptorName;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Hook executed with data about all packages found while crawling `node_modules`.
|
|
58
|
+
*
|
|
59
|
+
* Called once before `translateGraph`.
|
|
60
|
+
*/
|
|
61
|
+
export type PackageDataHook = (params: {
|
|
62
|
+
packageData: Readonly<Map<PackageCompartmentDescriptorName, PackageData>>;
|
|
63
|
+
log: LogFn;
|
|
64
|
+
}) => void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Hook executed for each canonical name (corresponding to a package) in the
|
|
68
|
+
* `CompartmentMapDescriptor` with a list of canonical names of its
|
|
69
|
+
* dependencies.
|
|
70
|
+
*
|
|
71
|
+
* Can return partial updates to modify the dependencies set.
|
|
72
|
+
*
|
|
73
|
+
* Suggested use cases:
|
|
74
|
+
* - Adding dependencies based on policy
|
|
75
|
+
* - Removing dependencies based on policy
|
|
76
|
+
* - Filtering dependencies based on multiple criteria
|
|
77
|
+
*/
|
|
78
|
+
export type PackageDependenciesHook = (params: {
|
|
79
|
+
canonicalName: CanonicalName;
|
|
80
|
+
dependencies: Readonly<Set<CanonicalName>>;
|
|
81
|
+
log: LogFn;
|
|
82
|
+
}) => Partial<{ dependencies: Set<CanonicalName> }> | void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The `moduleSource` property value for {@link ModuleSourceHook}
|
|
86
|
+
*/
|
|
87
|
+
export type ModuleSourceHookModuleSource =
|
|
88
|
+
| {
|
|
89
|
+
location: FileUrlString;
|
|
90
|
+
language: Language;
|
|
91
|
+
bytes: Uint8Array;
|
|
92
|
+
imports?: string[] | undefined;
|
|
93
|
+
exports?: string[] | undefined;
|
|
94
|
+
reexports?: string[] | undefined;
|
|
95
|
+
sha512?: string | undefined;
|
|
96
|
+
}
|
|
97
|
+
| { error: string }
|
|
98
|
+
| { exit: string };
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Hook executed when processing a module source.
|
|
102
|
+
*/
|
|
103
|
+
export type ModuleSourceHook = (params: {
|
|
104
|
+
moduleSource: ModuleSourceHookModuleSource;
|
|
105
|
+
canonicalName: CanonicalName;
|
|
106
|
+
log: LogFn;
|
|
107
|
+
}) => void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Hook executed for each canonical name with its connections (linked compartments).
|
|
111
|
+
*/
|
|
112
|
+
export type PackageConnectionsHook = (params: {
|
|
113
|
+
canonicalName: CanonicalName;
|
|
114
|
+
connections: Set<CanonicalName>;
|
|
115
|
+
log: LogFn;
|
|
116
|
+
}) => void;
|
|
22
117
|
|
|
23
118
|
/**
|
|
24
119
|
* Set of options available in the context of code execution.
|
|
@@ -65,6 +160,7 @@ export interface LogOptions {
|
|
|
65
160
|
*/
|
|
66
161
|
export type MapNodeModulesOptions = MapNodeModulesOptionsOmitPolicy &
|
|
67
162
|
PolicyOption &
|
|
163
|
+
MapNodeModulesHookOptions &
|
|
68
164
|
LogOptions;
|
|
69
165
|
|
|
70
166
|
type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
@@ -127,23 +223,57 @@ type MapNodeModulesOptionsOmitPolicy = Partial<{
|
|
|
127
223
|
}>;
|
|
128
224
|
|
|
129
225
|
/**
|
|
130
|
-
*
|
|
226
|
+
* Hook options for `mapNodeModules()`
|
|
131
227
|
*/
|
|
228
|
+
export type MapNodeModulesHookOptions = {
|
|
229
|
+
unknownCanonicalNameHook?: UnknownCanonicalNameHook | undefined;
|
|
230
|
+
packageDependenciesHook?: PackageDependenciesHook | undefined;
|
|
231
|
+
packageDataHook?: PackageDataHook | undefined;
|
|
232
|
+
};
|
|
233
|
+
|
|
132
234
|
export type CompartmentMapForNodeModulesOptions = Omit<
|
|
133
235
|
MapNodeModulesOptions,
|
|
134
236
|
'conditions' | 'tags'
|
|
135
237
|
>;
|
|
136
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Options for `captureFromMap()`
|
|
241
|
+
*/
|
|
137
242
|
export type CaptureLiteOptions = ImportingOptions &
|
|
138
243
|
LinkingOptions &
|
|
139
244
|
PolicyOption &
|
|
140
|
-
LogOptions
|
|
245
|
+
LogOptions &
|
|
246
|
+
PreloadOption &
|
|
247
|
+
CaptureFromMapHookOptions;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Hook options for `captureFromMap()`
|
|
251
|
+
*/
|
|
252
|
+
export type CaptureFromMapHookOptions = {
|
|
253
|
+
packageConnectionsHook?: PackageConnectionsHook | undefined;
|
|
254
|
+
moduleSourceHook?: ModuleSourceHook | undefined;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Options bag containing a `preload` array.
|
|
259
|
+
*/
|
|
260
|
+
export interface PreloadOption {
|
|
261
|
+
/**
|
|
262
|
+
* List of compartment names (the keys of
|
|
263
|
+
* {@link CompartmentMapDescriptor.compartments}) and entries (`ModuleConfiguration` names) to force-load _after_ the
|
|
264
|
+
* entry compartment and any attenuators.
|
|
265
|
+
*
|
|
266
|
+
* If an array of strings is provided, the entry is assumed to be `.`.
|
|
267
|
+
*/
|
|
268
|
+
_preload?: Array<string> | Array<{ compartment: string; entry: string }>;
|
|
269
|
+
}
|
|
141
270
|
|
|
142
271
|
export type ArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
143
272
|
ModuleTransformsOption &
|
|
144
273
|
ImportingOptions &
|
|
145
274
|
ExitModuleImportHookOption &
|
|
146
|
-
LinkingOptions
|
|
275
|
+
LinkingOptions &
|
|
276
|
+
LogOptions;
|
|
147
277
|
|
|
148
278
|
export type SyncArchiveLiteOptions = SyncOrAsyncArchiveOptions &
|
|
149
279
|
SyncModuleTransformsOption &
|
|
@@ -179,15 +309,35 @@ export type BundleOptions = ArchiveOptions & {
|
|
|
179
309
|
sourceUrlPrefix?: string;
|
|
180
310
|
};
|
|
181
311
|
|
|
182
|
-
export type SyncArchiveOptions = Omit<
|
|
312
|
+
export type SyncArchiveOptions = Omit<
|
|
313
|
+
MapNodeModulesOptions,
|
|
314
|
+
| 'languages'
|
|
315
|
+
| 'unknownCanonicalNameHook'
|
|
316
|
+
| 'packageDependenciesHook'
|
|
317
|
+
| 'packageDataHook'
|
|
318
|
+
> &
|
|
183
319
|
SyncArchiveLiteOptions;
|
|
184
320
|
|
|
321
|
+
export type SyncLoadLocationOptions = SyncArchiveOptions &
|
|
322
|
+
LogOptions &
|
|
323
|
+
PreloadOption &
|
|
324
|
+
LoadLocationHookOptions;
|
|
325
|
+
|
|
185
326
|
/**
|
|
186
327
|
* Options for `loadLocation()`
|
|
187
328
|
*/
|
|
188
329
|
export type LoadLocationOptions = ArchiveOptions &
|
|
189
330
|
SyncArchiveOptions &
|
|
190
|
-
LogOptions
|
|
331
|
+
LogOptions &
|
|
332
|
+
PreloadOption &
|
|
333
|
+
LoadLocationHookOptions;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Hook options for `loadLocation()`
|
|
337
|
+
*/
|
|
338
|
+
export type LoadLocationHookOptions = MapNodeModulesHookOptions & {
|
|
339
|
+
moduleSourceHook?: ModuleSourceHook | undefined;
|
|
340
|
+
};
|
|
191
341
|
|
|
192
342
|
/**
|
|
193
343
|
* Options for `importLocation()` necessary (but not sufficient--see
|
|
@@ -195,14 +345,17 @@ export type LoadLocationOptions = ArchiveOptions &
|
|
|
195
345
|
*/
|
|
196
346
|
export type SyncImportLocationOptions = SyncArchiveOptions &
|
|
197
347
|
ExecuteOptions &
|
|
198
|
-
LogOptions
|
|
348
|
+
LogOptions &
|
|
349
|
+
PreloadOption;
|
|
199
350
|
|
|
200
351
|
/**
|
|
201
352
|
* Options for `importLocation()` without dynamic require support
|
|
202
353
|
*/
|
|
203
354
|
export type ImportLocationOptions = ArchiveOptions &
|
|
204
355
|
ExecuteOptions &
|
|
205
|
-
|
|
356
|
+
LoadLocationHookOptions &
|
|
357
|
+
LogOptions &
|
|
358
|
+
PreloadOption;
|
|
206
359
|
|
|
207
360
|
// ////////////////////////////////////////////////////////////////////////////////
|
|
208
361
|
// Single Options
|
|
@@ -295,7 +448,7 @@ export type ArchiveOnlyOption = {
|
|
|
295
448
|
};
|
|
296
449
|
|
|
297
450
|
export type PolicyOption = {
|
|
298
|
-
policy?:
|
|
451
|
+
policy?: SomePolicy;
|
|
299
452
|
};
|
|
300
453
|
|
|
301
454
|
export type LanguageForExtensionOption = {
|
|
@@ -332,11 +485,14 @@ type LinkingOptions = ParserForLanguageOption &
|
|
|
332
485
|
/**
|
|
333
486
|
* Result of `digestCompartmentMap()`
|
|
334
487
|
*/
|
|
335
|
-
export interface DigestResult
|
|
488
|
+
export interface DigestResult<
|
|
489
|
+
OldCompartmentName extends string = FileUrlString,
|
|
490
|
+
NewCompartmentName extends string = PackageCompartmentDescriptorName,
|
|
491
|
+
> {
|
|
336
492
|
/**
|
|
337
493
|
* Normalized `CompartmentMapDescriptor`
|
|
338
494
|
*/
|
|
339
|
-
compartmentMap:
|
|
495
|
+
compartmentMap: DigestedCompartmentMapDescriptor;
|
|
340
496
|
|
|
341
497
|
/**
|
|
342
498
|
* Sources found in the `CompartmentMapDescriptor`
|
|
@@ -347,34 +503,37 @@ export interface DigestResult {
|
|
|
347
503
|
* A record of renamed {@link CompartmentDescriptor CompartmentDescriptors}
|
|
348
504
|
* from _new_ to _original_ name
|
|
349
505
|
*/
|
|
350
|
-
newToOldCompartmentNames: Record<
|
|
506
|
+
newToOldCompartmentNames: Record<NewCompartmentName, OldCompartmentName>;
|
|
351
507
|
|
|
352
508
|
/**
|
|
353
509
|
* A record of renamed {@link CompartmentDescriptor CompartmentDescriptors}
|
|
354
510
|
* from _original_ to _new_ name
|
|
355
511
|
*/
|
|
356
|
-
oldToNewCompartmentNames: Record<
|
|
512
|
+
oldToNewCompartmentNames: Record<OldCompartmentName, NewCompartmentName>;
|
|
357
513
|
|
|
358
514
|
/**
|
|
359
515
|
* Alias for `newToOldCompartmentNames`
|
|
360
516
|
* @deprecated Use {@link newToOldCompartmentNames} instead.
|
|
361
517
|
*/
|
|
362
|
-
compartmentRenames: Record<
|
|
518
|
+
compartmentRenames: Record<NewCompartmentName, OldCompartmentName>;
|
|
363
519
|
}
|
|
364
520
|
|
|
365
521
|
/**
|
|
366
522
|
* The result of `captureFromMap`.
|
|
367
523
|
*/
|
|
368
524
|
export type CaptureResult = Omit<DigestResult, 'compartmentMap' | 'sources'> & {
|
|
369
|
-
captureCompartmentMap:
|
|
525
|
+
captureCompartmentMap: DigestedCompartmentMapDescriptor;
|
|
370
526
|
captureSources: DigestResult['sources'];
|
|
371
527
|
};
|
|
372
528
|
|
|
373
529
|
/**
|
|
374
530
|
* The result of `makeArchiveCompartmentMap`
|
|
375
531
|
*/
|
|
376
|
-
export type ArchiveResult = Omit<
|
|
377
|
-
|
|
532
|
+
export type ArchiveResult = Omit<
|
|
533
|
+
DigestResult<FileUrlString, string>,
|
|
534
|
+
'compartmentMap' | 'sources'
|
|
535
|
+
> & {
|
|
536
|
+
archiveCompartmentMap: DigestedCompartmentMapDescriptor;
|
|
378
537
|
archiveSources: DigestResult['sources'];
|
|
379
538
|
};
|
|
380
539
|
|
|
@@ -385,18 +544,31 @@ export type ArchiveResult = Omit<DigestResult, 'compartmentMap' | 'sources'> & {
|
|
|
385
544
|
export type Sources = Record<string, CompartmentSources>;
|
|
386
545
|
export type CompartmentSources = Record<string, ModuleSource>;
|
|
387
546
|
|
|
388
|
-
|
|
389
|
-
|
|
547
|
+
export type ModuleSource =
|
|
548
|
+
| LocalModuleSource
|
|
549
|
+
| ExitModuleSource
|
|
550
|
+
| ErrorModuleSource;
|
|
551
|
+
|
|
552
|
+
export interface BaseModuleSource {
|
|
390
553
|
/** module loading error deferred to later stage */
|
|
554
|
+
|
|
555
|
+
deferredError?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface ErrorModuleSource extends BaseModuleSource {
|
|
391
559
|
deferredError: string;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export interface LocalModuleSource extends BaseModuleSource {
|
|
392
563
|
/**
|
|
393
564
|
* package-relative location.
|
|
394
565
|
* Not suitable for capture in an archive or bundle since it varies from host
|
|
395
566
|
* to host and would frustrate integrity hash checks.
|
|
396
567
|
*/
|
|
397
568
|
location: string;
|
|
398
|
-
|
|
399
|
-
|
|
569
|
+
parser: Language;
|
|
570
|
+
/** in lowercase base-16 (hexadecimal) */
|
|
571
|
+
sha512?: string;
|
|
400
572
|
/**
|
|
401
573
|
* directory name of the original source.
|
|
402
574
|
* This is safe to capture in a compartment map because it is _unlikely_ to
|
|
@@ -412,15 +584,19 @@ export type ModuleSource = Partial<{
|
|
|
412
584
|
* https://github.com/endojs/endo/issues/2671
|
|
413
585
|
*/
|
|
414
586
|
sourceDirname: string;
|
|
587
|
+
/** fully qualified location */
|
|
588
|
+
|
|
589
|
+
sourceLocation: FileUrlString;
|
|
415
590
|
bytes: Uint8Array;
|
|
416
|
-
/** in lowercase base-16 (hexadecimal) */
|
|
417
|
-
sha512: string;
|
|
418
|
-
parser: Language;
|
|
419
|
-
/** indicates that this is a reference that exits the mapped compartments */
|
|
420
|
-
exit: string;
|
|
421
591
|
/** module for the module */
|
|
422
592
|
record: StaticModuleType;
|
|
423
|
-
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
export interface ExitModuleSource extends BaseModuleSource {
|
|
596
|
+
/** indicates that this is a reference that exits the mapped compartments */
|
|
597
|
+
|
|
598
|
+
exit: string;
|
|
599
|
+
}
|
|
424
600
|
|
|
425
601
|
export type SourceMapHook = (
|
|
426
602
|
sourceMap: string,
|
|
@@ -556,3 +732,16 @@ export type LogFn = (...args: any[]) => void;
|
|
|
556
732
|
* A string that represents a file URL.
|
|
557
733
|
*/
|
|
558
734
|
export type FileUrlString = `file://${string}`;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* A function that renames compartments; used by `digestCompartmentMap()`.
|
|
738
|
+
*
|
|
739
|
+
* The default implementation uses {@link PackageCompartmentDescriptorName} as the key type.
|
|
740
|
+
*
|
|
741
|
+
* @returns Mapping from old compartment names to new compartment names
|
|
742
|
+
* @template NewName Key type
|
|
743
|
+
*/
|
|
744
|
+
export type CompartmentsRenameFn<
|
|
745
|
+
OldName extends string = FileUrlString,
|
|
746
|
+
NewName extends string = PackageCompartmentDescriptorName,
|
|
747
|
+
> = (compartments: PackageCompartmentDescriptors) => Record<OldName, NewName>;
|
package/src/types/internal.d.ts
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import type { ImportHook, ImportNowHook, StaticModuleType } from 'ses';
|
|
8
|
-
import type { CompartmentDescriptor, Language, LanguageForExtension, LanguageForModuleSpecifier,
|
|
9
|
-
import type {
|
|
8
|
+
import type { CompartmentDescriptor, Language, LanguageForExtension, LanguageForModuleSpecifier, PackageCompartmentDescriptor, PackageCompartmentDescriptors, CompartmentModuleConfiguration, PackageCompartmentDescriptorName } from './compartment-map-schema.js';
|
|
9
|
+
import type { ArchiveOnlyOption, AsyncParseFn, CompartmentSources, ComputeSha512Option, ExecuteOptions, ExitModuleImportHookOption, ExitModuleImportNowHookOption, FileUrlString, ModuleSourceHook, PackageConnectionsHook, PreloadOption, LogOptions, ModuleTransforms, ParseFn, ParserForLanguage, PolicyOption, SearchSuffixesOption, SourceMapHook, SourceMapHookOption, Sources, SyncModuleTransforms, CompartmentsRenameFn } from './external.js';
|
|
10
|
+
import type { PackageDescriptor } from './node-modules.js';
|
|
10
11
|
import type { DeferredAttenuatorsProvider } from './policy.js';
|
|
11
|
-
import type {
|
|
12
|
+
import type { MaybeReadFn, MaybeReadNowFn, ReadFn, ReadPowers } from './powers.js';
|
|
12
13
|
export type LinkOptions = {
|
|
13
14
|
resolve?: ResolveHook;
|
|
14
15
|
makeImportHook: ImportHookMaker;
|
|
@@ -17,7 +18,7 @@ export type LinkOptions = {
|
|
|
17
18
|
moduleTransforms?: ModuleTransforms;
|
|
18
19
|
syncModuleTransforms?: SyncModuleTransforms;
|
|
19
20
|
__native__?: boolean;
|
|
20
|
-
} & ArchiveOnlyOption & ExecuteOptions;
|
|
21
|
+
} & ArchiveOnlyOption & ExecuteOptions & LogOptions;
|
|
21
22
|
export type LinkResult = {
|
|
22
23
|
compartment: Compartment;
|
|
23
24
|
compartments: Record<string, Compartment>;
|
|
@@ -36,12 +37,13 @@ export type MakeImportHookMakersOptions = {
|
|
|
36
37
|
/**
|
|
37
38
|
* For depositing captured compartment descriptors.
|
|
38
39
|
*/
|
|
39
|
-
compartmentDescriptors?:
|
|
40
|
-
|
|
40
|
+
compartmentDescriptors?: PackageCompartmentDescriptors;
|
|
41
|
+
moduleSourceHook?: ModuleSourceHook | undefined;
|
|
42
|
+
} & ComputeSha512Option & SearchSuffixesOption & ArchiveOnlyOption & SourceMapHookOption & LogOptions;
|
|
41
43
|
export type MakeImportHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportHookOption;
|
|
42
44
|
export type MakeImportNowHookMakerOptions = MakeImportHookMakersOptions & ExitModuleImportNowHookOption;
|
|
43
45
|
export type ImportHookMaker = (params: {
|
|
44
|
-
packageLocation:
|
|
46
|
+
packageLocation: PackageCompartmentDescriptorName;
|
|
45
47
|
packageName: string;
|
|
46
48
|
attenuators: DeferredAttenuatorsProvider;
|
|
47
49
|
parse: ParseFn | AsyncParseFn;
|
|
@@ -49,7 +51,7 @@ export type ImportHookMaker = (params: {
|
|
|
49
51
|
compartments: Record<string, Compartment>;
|
|
50
52
|
}) => ImportHook;
|
|
51
53
|
export type ImportNowHookMaker = (params: {
|
|
52
|
-
packageLocation:
|
|
54
|
+
packageLocation: PackageCompartmentDescriptorName;
|
|
53
55
|
packageName: string;
|
|
54
56
|
parse: ParseFn | AsyncParseFn;
|
|
55
57
|
compartments: Record<string, Compartment>;
|
|
@@ -71,13 +73,13 @@ export type ChooseModuleDescriptorParams = {
|
|
|
71
73
|
/** Module specifiers with each search suffix appended */
|
|
72
74
|
candidates: string[];
|
|
73
75
|
moduleSpecifier: string;
|
|
74
|
-
packageLocation:
|
|
76
|
+
packageLocation: FileUrlString;
|
|
75
77
|
/** Compartment descriptor from the compartment map */
|
|
76
|
-
compartmentDescriptor:
|
|
78
|
+
compartmentDescriptor: PackageCompartmentDescriptor;
|
|
77
79
|
/** All compartment descriptors from the compartment map */
|
|
78
|
-
compartmentDescriptors:
|
|
80
|
+
compartmentDescriptors: PackageCompartmentDescriptors;
|
|
79
81
|
/** All module descriptors in same compartment */
|
|
80
|
-
moduleDescriptors: Record<string,
|
|
82
|
+
moduleDescriptors: Record<string, CompartmentModuleConfiguration>;
|
|
81
83
|
/** All compartments */
|
|
82
84
|
compartments: Record<string, Compartment>;
|
|
83
85
|
packageSources: CompartmentSources;
|
|
@@ -86,9 +88,10 @@ export type ChooseModuleDescriptorParams = {
|
|
|
86
88
|
* Whether to embed a sourceURL in applicable compiled sources.
|
|
87
89
|
* Should be false for archives and bundles, but true for runtime.
|
|
88
90
|
*/
|
|
89
|
-
sourceMapHook?: SourceMapHook;
|
|
91
|
+
sourceMapHook?: SourceMapHook | undefined;
|
|
92
|
+
moduleSourceHook?: ModuleSourceHook | undefined;
|
|
90
93
|
strictlyRequiredForCompartment: StrictlyRequiredFn;
|
|
91
|
-
} & ComputeSha512Option & ArchiveOnlyOption;
|
|
94
|
+
} & ComputeSha512Option & ArchiveOnlyOption & LogOptions;
|
|
92
95
|
type ShouldDeferErrorOption = {
|
|
93
96
|
shouldDeferError: ShouldDeferError;
|
|
94
97
|
};
|
|
@@ -198,34 +201,6 @@ export type ReadDescriptorFn<T = PackageDescriptor> = (location: string) => Prom
|
|
|
198
201
|
* @template T Format of package descriptor
|
|
199
202
|
*/
|
|
200
203
|
export type MaybeReadDescriptorFn<T = PackageDescriptor> = (location: string) => Promise<T | undefined>;
|
|
201
|
-
/**
|
|
202
|
-
* The type of a `package.json` file containing relevant fields; used by `graphPackages` and its ilk
|
|
203
|
-
*/
|
|
204
|
-
export interface PackageDescriptor {
|
|
205
|
-
/**
|
|
206
|
-
* TODO: In reality, this is optional, but `graphPackage` does not consider it to be. This will need to be fixed once support for "anonymous" packages lands; see https://github.com/endojs/endo/pull/2664
|
|
207
|
-
*/
|
|
208
|
-
name: string;
|
|
209
|
-
version?: string;
|
|
210
|
-
/**
|
|
211
|
-
* TODO: Update with proper type when this field is handled.
|
|
212
|
-
*/
|
|
213
|
-
exports?: unknown;
|
|
214
|
-
type?: 'module' | 'commonjs';
|
|
215
|
-
dependencies?: Record<string, string>;
|
|
216
|
-
devDependencies?: Record<string, string>;
|
|
217
|
-
peerDependencies?: Record<string, string>;
|
|
218
|
-
optionalDependencies?: Record<string, string>;
|
|
219
|
-
bundleDependencies?: string[];
|
|
220
|
-
peerDependenciesMeta?: Record<string, {
|
|
221
|
-
optional?: boolean;
|
|
222
|
-
[k: string]: unknown;
|
|
223
|
-
}>;
|
|
224
|
-
module?: string;
|
|
225
|
-
browser?: Record<string, string> | string;
|
|
226
|
-
main?: string;
|
|
227
|
-
[k: string]: unknown;
|
|
228
|
-
}
|
|
229
204
|
/**
|
|
230
205
|
* Function returning a set of module names (scoped to the compartment) whose
|
|
231
206
|
* parser is not using heuristics to determine imports.
|
|
@@ -246,5 +221,11 @@ specifier: string,
|
|
|
246
221
|
* The error that was thrown
|
|
247
222
|
*/
|
|
248
223
|
error: Error) => StaticModuleType;
|
|
224
|
+
export type MakeLoadCompartmentsOptions = LogOptions & PolicyOption & PreloadOption;
|
|
225
|
+
export type DigestCompartmentMapOptions<OldCompartmentName extends string = FileUrlString, NewCompartmentName extends string = PackageCompartmentDescriptorName> = LogOptions & {
|
|
226
|
+
packageConnectionsHook?: PackageConnectionsHook | undefined;
|
|
227
|
+
renameCompartments?: CompartmentsRenameFn<OldCompartmentName, NewCompartmentName>;
|
|
228
|
+
};
|
|
229
|
+
export type CaptureCompartmentMapOptions = DigestCompartmentMapOptions;
|
|
249
230
|
export {};
|
|
250
231
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AACvE,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AACvE,OAAO,KAAK,EACV,qBAAqB,EACrB,QAAQ,EACR,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,gCAAgC,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,k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