Remove level of indirection by removing SES.js and moving functionality to index.js instead
DELETE
src/SES.js
-// Copyright (C) 2018 Agoric
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import { createSESWithRealmConstructor } from './bundle/index';
-import { creatorStrings } from './stringifiedBundle';
-import Realm from '../proposal-realms/shim/src/realm';
-
-const SES = createSESWithRealmConstructor(creatorStrings, Realm);
-export default SES;

MODIFY
src/index.js
src/index.js
// See the License for the specific language governing permissions and
// limitations under the License.
-import SES from './SES';
+import { createSESWithRealmConstructor } from './bundle/index';
+import { creatorStrings } from './stringifiedBundle';
+import Realm from '../proposal-realms/shim/src/realm';
-const { makeSESRootRealm } = SES;
+const SES = createSESWithRealmConstructor(creatorStrings, Realm);
export default SES;
-export { SES, makeSESRootRealm };
-
-// this should be usable like:
-// import SES from 'SES'; let r = SES.makeSESRootRealm();
-// const SES = require("SES"); let r = SES.makeSESRootRealm();
-// import {SES, def, Nat} from 'SES';
-
-// f = compileExpr(source); then f(imports) can only affect 'imports'
-// exports.compileExpr = function(exprSrc, opt_mitigateOpts) { };
-
-/*
-exports.makeRootSESRealm = function() {
- const r = new Realm({
- // wishlist: if set, dateNowTrap is used for 'Date.now()' and 'new
- // Date()' inside the Realm it should return a number just like
- // Date.now(). The behavior of dateNowTrap and randTrap must be inherited
- // by all child Realms, whether constructed with {intrinsics: 'inherit'}
- // or not. The new Realm will have new identities for the Date
- // constructor and Math.random even though their behavior delegates.
-
- //dateNowTrap() {throw TypeError("nondeterministic");},
-
- // wishlist: if set, randTrap is used for 'Math.random()', and should
- // either 1: always return a float or 2: always throw
-
- //randTrap() {throw TypeError("nondeterministic");}
- });
- r.evaluate(prepareSESRealm_js)(r.global); //populate r
- r.spawn = r.global.ses.spawn;
- r.confine = r.global.ses.confine;
-
- tamperProofDataProperties(r.intrinsics);
- deepFreeze(r.global);
- return r;
-}
-*/

MODIFY
test/test-console.js
test/test-console.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('console disabled by default', t => {
const s = SES.makeSESRootRealm({ errorStackMode: 'allow' });

MODIFY
test/test-date.js
test/test-date.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('Date.now neutered by default', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test-error.js
test/test-error.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('Error.captureStackTrace neutered by default', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test-freeze.js
test/test-freeze.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('SESRealm global is frozen', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test-intl.js
test/test-intl.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
// Intl is removed entirely and unconditionally, for now. We might bring this
// back in the future.

MODIFY
test/test-math.js
test/test-math.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('Math.random neutered by default', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test-nesting.js
test/test-nesting.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('nested realms should work at all', t => {
const s1 = SES.makeSESRootRealm();

MODIFY
test/test-regexp.js
test/test-regexp.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('RegExp.compile neutered by default', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test-removal.js
test/test-removal.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
// The Node.js root environment (the repl you get when running /usr/bin/node)
// has extra (non-JS) properties like 'console', 'vm', 'crypto', and

MODIFY
test/test-require.js
test/test-require.js
import test from 'tape';
import OrigNat from '@agoric/nat';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('SES environment lacks require by default', t => {
const s = SES.makeSESRootRealm();

MODIFY
test/test.js
test/test.js
import test from 'tape';
-import { SES } from '../src/index';
+import SES from '../src/index';
test('create', t => {
const s = SES.makeSESRootRealm();

Remove level of indirection by removing SES.js and moving functionality to index.js instead (#89)