ses 1.4.1 → 1.5.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/NEWS.md +5 -0
- package/README.md +35 -0
- package/dist/lockdown.cjs +442 -508
- package/dist/lockdown.mjs +442 -508
- package/dist/lockdown.umd.js +442 -508
- package/dist/lockdown.umd.min.js +1 -1
- package/dist/ses.cjs +442 -508
- package/dist/ses.mjs +442 -508
- package/dist/ses.umd.js +442 -508
- package/dist/ses.umd.min.js +1 -1
- package/dist/types.d.cts +533 -0
- package/package.json +24 -15
- package/src/commons.js +66 -0
- package/src/compartment.js +4 -2
- package/src/error/assert.js +93 -25
- package/src/error/fatal-assert.js +2 -0
- package/src/error/stringify-utils.js +2 -0
- package/src/error/tame-console.js +8 -8
- package/src/error/types.js +1 -365
- package/src/make-hardener.js +49 -21
- package/src/module-load.js +185 -71
- package/src/permits.js +2 -0
- package/src/tame-symbol-constructor.js +4 -5
- package/types.d.ts +269 -14
package/NEWS.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
User-visible changes in SES:
|
|
2
2
|
|
|
3
|
+
# v1.5.0 (2024-05-06)
|
|
4
|
+
|
|
5
|
+
- Adds `importNowHook` to the `Compartment` options. The compartment will invoke the hook whenever it encounters a missing dependency while running `compartmentInstance.importNow(specifier)`, which cannot use an asynchronous `importHook`.
|
|
6
|
+
- To support TypeScript v5.5, a CommonJS-specific type declaration file is now explicitly exported.
|
|
7
|
+
|
|
3
8
|
# v1.3.0 (2024-02-22)
|
|
4
9
|
|
|
5
10
|
- Now supports `Promise.any`, `AggegateError`, `error.errors`,
|
package/README.md
CHANGED
|
@@ -384,6 +384,41 @@ const odd = new Compartment({}, {}, {
|
|
|
384
384
|
});
|
|
385
385
|
```
|
|
386
386
|
|
|
387
|
+
### importNowHook
|
|
388
|
+
|
|
389
|
+
Additionally, an `importNowHook` may be provided that the compartment will use as means to synchronously load modules not seen before in situations where calling out to asynchronous `importHook` is not possible.
|
|
390
|
+
Specifically, when `compartmentInstance.importNow('specifier')` is called, the compartment will first look up module records it's already aware of and call `moduleMapHook` and if none of that is successful in finding a module record matching the specifier, it will call `importNowHook` expecting to synchronously receive the same record type as from `importHook` or throw if it cannot.
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
import 'ses';
|
|
394
|
+
import { StaticModuleRecord } from '@endo/static-module-record';
|
|
395
|
+
|
|
396
|
+
const c1 = new Compartment({}, {
|
|
397
|
+
'c2': c2.module('./main.js'),
|
|
398
|
+
}, {
|
|
399
|
+
name: "first compartment",
|
|
400
|
+
resolveHook: (moduleSpecifier, moduleReferrer) => {
|
|
401
|
+
return resolve(moduleSpecifier, moduleReferrer);
|
|
402
|
+
},
|
|
403
|
+
importHook: async moduleSpecifier => {
|
|
404
|
+
const moduleLocation = locate(moduleSpecifier);
|
|
405
|
+
const moduleText = await retrieve(moduleLocation);
|
|
406
|
+
return new StaticModuleRecord(moduleText, moduleLocation);
|
|
407
|
+
},
|
|
408
|
+
importNowHook: moduleSpecifier => {
|
|
409
|
+
const moduleLocation = locate(moduleSpecifier);
|
|
410
|
+
// Platform specific synchronous read API can be used
|
|
411
|
+
const moduleText = fs.readFileSync(moduleLocation);
|
|
412
|
+
return new StaticModuleRecord(moduleText, moduleLocation);
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
//... | importHook | importNowHook
|
|
416
|
+
await c1.import('a'); //| called | not called
|
|
417
|
+
c1.importNow('b'); //| not called | called
|
|
418
|
+
c1.importNow('a'); //| not called | not called
|
|
419
|
+
c1.importNow('c2'); //| not called | not called
|
|
420
|
+
```
|
|
421
|
+
|
|
387
422
|
### Third-party modules
|
|
388
423
|
|
|
389
424
|
To incorporate modules not implemented as JavaScript modules, third-parties may
|