Skip to content

Commit

Permalink
fix: upgrade to SES v0.10.1, and make HandledPromise shim work
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 14, 2020
1 parent 8be98f2 commit 5d0adea
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
14 changes: 13 additions & 1 deletion packages/eventual-send/shim.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
/* global globalThis */

// eslint-disable-next-line import/prefer-default-export
export { HandledPromise } from './src/index';
import { makeHandledPromise } from './src/index';

// 'E' and 'HandledPromise' are exports of the module

// For now:
// import { HandledPromise, E } from '@agoric/eventual-send';
// ...

if (typeof HandledPromise === 'undefined') {
globalThis.HandledPromise = makeHandledPromise(Promise);
}
26 changes: 6 additions & 20 deletions packages/eventual-send/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* global harden HandledPromise */

import makeE from './E';
/* global harden */

const {
defineProperties,
Expand All @@ -13,21 +11,6 @@ const {
const { prototype: promiseProto } = Promise;
const { then: originalThen } = promiseProto;

// 'E' and 'HandledPromise' are exports of the module

// For now:
// import { HandledPromise, E } from '@agoric/eventual-send';
// ...

const hp =
typeof HandledPromise === 'undefined'
? // eslint-disable-next-line no-use-before-define
makeHandledPromise(Promise)
: HandledPromise;

// Provide our exports.
export { hp as HandledPromise };

// the following method (makeHandledPromise) is part
// of the shim, and will not be exported by the module once the feature
// becomes a part of standard javascript
Expand All @@ -44,6 +27,7 @@ export { hp as HandledPromise };
*
* @return {typeof HandledPromise} Handled promise
*/
// eslint-disable-next-line import/prefer-default-export
export function makeHandledPromise(Promise) {
// xs doesn't support WeakMap in pre-loaded closures
// aka "vetted customization code"
Expand Down Expand Up @@ -111,7 +95,7 @@ export function makeHandledPromise(Promise) {
// handled Promises to their corresponding fulfilledHandler.
let forwardingHandler;
let handle;
let promiseResolve;
const promiseResolve = Promise.resolve.bind(Promise);

function HandledPromise(executor, unsettledHandler = undefined) {
if (new.target === undefined) {
Expand Down Expand Up @@ -456,6 +440,8 @@ export function makeHandledPromise(Promise) {
return returnedP;
};

promiseResolve = Promise.resolve.bind(Promise);
// We cannot harden(HandledPromise) because we're a vetted shim which
// runs before lockdown() allows harden to function. In that case,
// though, globalThis.HandledPromise will be hardened after lockdown.
return HandledPromise;
}
5 changes: 4 additions & 1 deletion packages/import-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"tap": "^14.10.5"
},
"peerDependencies": {
"ses": "^0.10.0"
"ses": "^0.10.1"
},
"files": [
"README.md",
Expand Down Expand Up @@ -74,5 +74,8 @@
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"ses": "^0.10.1"
}
}
2 changes: 1 addition & 1 deletion packages/install-ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@agoric/eventual-send": "^0.9.3",
"ses": "^0.10.0"
"ses": "^0.10.1"
},
"files": [
"src/**/*.js"
Expand Down
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8661,6 +8661,15 @@ ses@^0.10.0:
"@agoric/make-hardener" "^0.1.0"
"@agoric/transform-module" "^0.3.0"

ses@^0.10.1:
version "0.10.1"
resolved "https://registry.yarnpkg.com/ses/-/ses-0.10.1.tgz#7506ce0e48e98a518fde20604072b523228b9441"
integrity sha512-OqYfhG7naLai6fuIMa3mbIW7lImdrFC0IqzkokPp+1SvwXfjr4r4U4jYkUjJQTB3NUnq2sLEbJ+1wBO5tdGwAQ==
dependencies:
"@agoric/babel-standalone" "^7.9.5"
"@agoric/make-hardener" "^0.1.0"
"@agoric/transform-module" "^0.3.0"

set-blocking@^2.0.0, set-blocking@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
Expand Down

0 comments on commit 5d0adea

Please sign in to comment.