fix(ses, transform-module)!: Fix StaticModuleRecord name
MODIFY
packages/make-importer/README.md
packages/make-importer/README.md
@@ -30,8 +30,8 @@ const importer = makeImporter({
resolve, // (specifier: string, referrer: AbsoluteSpecifier) => AbsoluteSpecifier // cached
locate, // (absSpecifer: AbsoluteSpecifier) => Promise<ModuleLocation> // cached
retrieve, // (loc: ModuleLocation) => Promise<ResourceStream> // (not cached)
- analyze, // (rs: ResourceStream) => Promise<ModuleStaticRecord> // cached by ModuleLocation
- // interface ModuleLinkageRecord extends ModuleStaticRecord {
+ analyze, // (rs: ResourceStream) => Promise<StaticModuleRecord> // cached by ModuleLocation
+ // interface ModuleLinkageRecord extends StaticModuleRecord {
// moduleLocation: ModuleLocation,
// moduleLocations: Map<string, ModuleLocation>,
// }
@@ -47,7 +47,7 @@ const importer = makeImporter({
## What per what?
-One ModuleLocation per ModuleStaticRecord.
+One ModuleLocation per StaticModuleRecord.
One ModuleLinkageRecord per ModuleLocation (in a given Linker's instanceCache).

MODIFY
packages/make-importer/src/importer.js
packages/make-importer/src/importer.js
@@ -35,7 +35,7 @@ export const makeImporter = (importHooks, moduleCache = new Map()) => {
const absoluteSpecifier = resolve(specifier, referrer);
moduleLocation = await locate(absoluteSpecifier);
} else {
- // The static record is already prepared, so bypass the rewriter.
+ // The static module record is already prepared, so bypass the rewriter.
// This fresh object ensures we don't clash in the cache.
moduleLocation = {
toString() {
@@ -53,7 +53,7 @@ export const makeImporter = (importHooks, moduleCache = new Map()) => {
.then(analyze)
.then(sr => ({ staticRecord: sr }));
} else {
- // We are injecting a pre-created static record.
+ // We are injecting a pre-created static module record.
getStaticRecordP = Promise.resolve({ staticRecord });
}

MODIFY
packages/ses/NEWS.md
packages/ses/NEWS.md
@@ -4,7 +4,7 @@ User-visible changes in SES:
* Adds support for modules to Compartments.
* SES no longer exports anything.
- `Compartment`, `ModuleStaticRecord`, `lockdown`, and `harden` are all
+ `Compartment`, `StaticModuleRecord`, `lockdown`, and `harden` are all
introduced as properties of `globalThis`.
* The `Compartment` `global` getter is now named `globalThis`, consistent with
the specification proposal.

MODIFY
packages/ses/README.md
packages/ses/README.md
@@ -143,7 +143,7 @@ a `resolveHook` and an `importHook`.
The `resolveHook` determines how the compartment will infer the full module
specifier for another module from a referrer module and the import specifier.
The `importHook` accepts a full specifier and asynchronously returns a
-`ModuleStaticRecord` for that module.
+`StaticModuleRecord` for that module.
```js
import 'ses';
@@ -155,7 +155,7 @@ const c1 = new Compartment({}, {}, {
importHook: async moduleSpecifier => {
const moduleLocation = locate(moduleSpecifier);
const moduleText = await retrieve(moduleLocation);
- return new ModuleStaticRecord(moduleText, moduleLocation);
+ return new StaticModuleRecord(moduleText, moduleLocation);
},
});
```

MODIFY
packages/ses/src/compartment-shim.js
packages/ses/src/compartment-shim.js
-// This module exports both Compartment and ModuleStaticRecord because they
+// This module exports both Compartment and StaticModuleRecord because they
// communicate through the moduleAnalyses private side-table.
/* eslint max-classes-per-file: ["error", 2] */
@@ -27,17 +27,17 @@ const { entries } = Object;
const analyzeModule = makeModuleAnalyzer(babel.default);
-// moduleAnalyses are the private data of a ModuleStaticRecord.
+// moduleAnalyses are the private data of a StaticModuleRecord.
// We use moduleAnalyses in the loader/linker to look up
-// the analysis corresponding to any ModuleStaticRecord constructed by an
+// the analysis corresponding to any StaticModuleRecord constructed by an
// importHook.
const moduleAnalyses = new WeakMap();
/**
- * ModuleStaticRecord captures the effort of parsing and analyzing module text
- * so a cache of ModuleStaticRecords may be shared by multiple Compartments.
+ * StaticModuleRecord captures the effort of parsing and analyzing module text
+ * so a cache of StaticModuleRecords may be shared by multiple Compartments.
*/
-export class ModuleStaticRecord {
+export class StaticModuleRecord {
constructor(string, url) {
const analysis = analyzeModule({ string, url });
@@ -51,11 +51,11 @@ export class ModuleStaticRecord {
// eslint-disable-next-line class-methods-use-this
toString() {
- return '[object ModuleStaticRecord]';
+ return '[object StaticModuleRecord]';
}
static toString() {
- return 'function ModuleStaticRecord() { [shim code] }';
+ return 'function StaticModuleRecord() { [shim code] }';
}
}

MODIFY
packages/ses/src/intrinsic-names.js
packages/ses/src/intrinsic-names.js
@@ -146,7 +146,7 @@ export const intrinsicNames = [
'FunctionPrototypeConstructor',
'Compartment',
'CompartmentPrototype',
- 'ModuleStaticRecord',
- 'ModuleStaticRecordPrototype',
+ 'StaticModuleRecord',
+ 'StaticModuleRecordPrototype',
'harden',
];

MODIFY
packages/ses/src/intrinsics-global.js
packages/ses/src/intrinsics-global.js
@@ -95,8 +95,8 @@ const globalIntrinsicNames = [
'globalThis',
'Compartment',
'CompartmentPrototype',
- 'ModuleStaticRecord',
- 'ModuleStaticRecordPrototype',
+ 'StaticModuleRecord',
+ 'StaticModuleRecordPrototype',
'harden',
];

MODIFY
packages/ses/src/main.js
packages/ses/src/main.js
// limitations under the License.
import { lockdown, harden } from './lockdown-shim.js';
-import { Compartment, ModuleStaticRecord } from './compartment-shim.js';
+import { Compartment, StaticModuleRecord } from './compartment-shim.js';
Object.assign(globalThis, {
lockdown,
harden,
Compartment,
- ModuleStaticRecord,
+ StaticModuleRecord,
});

MODIFY
packages/ses/src/module-link.js
packages/ses/src/module-link.js
// For brevity, in this file, as in module-load.js, the term "moduleRecord"
// without qualification means "module compartment record".
-// This is a super-set of the "module static record", that is reusable between
+// This is a super-set of the "static module record", that is reusable between
// compartments with different hooks.
// The "module compartment record" captures the compartment and overlays the
// module's "imports" with the more specific "resolvedImports" as inferred from

MODIFY
packages/ses/src/module-load.js
packages/ses/src/module-load.js
// For brevity, in this file, as in module-link.js, the term "moduleRecord"
// without qualification means "module compartment record".
-// This is a super-set of the "module static record", that is reusable between
+// This is a super-set of the "static module record", that is reusable between
// compartments with different hooks.
// The "module compartment record" captures the compartment and overlays the
// module's "imports" with the more specific "resolvedImports" as inferred from
@@ -31,7 +31,7 @@ const resolveAll = (imports, resolveHook, fullReferrerSpecifier) => {
return freeze(resolvedImports);
};
-// `load` asynchronously loads `ModuleStaticRecords` and creates a complete
+// `load` asynchronously loads `StaticModuleRecords` and creates a complete
// graph of `ModuleCompartmentRecords`.
// The module records refer to each other by a reference to the dependency's
// compartment and the specifier of the module within its own compartment.
@@ -72,7 +72,7 @@ export const load = async (
// Guard against invalid importHook behavior.
if (!moduleAnalyses.has(moduleStaticRecord)) {
throw new TypeError(
- `importHook must return a ModuleStaticRecord constructed within the same Compartment and Realm`,
+ `importHook must return a StaticModuleRecord constructed within the same Compartment and Realm`,
);
}

MODIFY
packages/ses/src/whitelist.js
packages/ses/src/whitelist.js
@@ -1550,13 +1550,13 @@ export default {
module: fn,
},
- ModuleStaticRecord: {
+ StaticModuleRecord: {
'**proto**': 'FunctionPrototype',
- prototype: 'ModuleStaticRecordPrototype',
+ prototype: 'StaticModuleRecordPrototype',
},
- ModuleStaticRecordPrototype: {
- constructor: 'ModuleStaticRecord',
+ StaticModuleRecordPrototype: {
+ constructor: 'StaticModuleRecord',
},
harden: fn,

MODIFY
packages/ses/test/import-commons.js
packages/ses/test/import-commons.js
-import { ModuleStaticRecord } from '../src/compartment-shim.js';
+import { StaticModuleRecord } from '../src/compartment-shim.js';
// q, to quote strings in error messages.
const q = JSON.stringify;
@@ -23,5 +23,5 @@ export const makeStaticRetriever = sources => {
export const makeImporter = (locate, retrieve) => async moduleSpecifier => {
const moduleLocation = locate(moduleSpecifier);
const string = await retrieve(moduleLocation);
- return new ModuleStaticRecord(string, moduleLocation);
+ return new StaticModuleRecord(string, moduleLocation);
};

MODIFY
packages/ses/test/module-static-record.test.js
packages/ses/test/module-static-record.test.js
import tap from 'tap';
-import { ModuleStaticRecord } from '../src/compartment-shim.js';
+import { StaticModuleRecord } from '../src/compartment-shim.js';
const { test } = tap;
-test('module static record constructor', t => {
- const msr = new ModuleStaticRecord(`
+test('static module record constructor', t => {
+ const msr = new StaticModuleRecord(`
import foo from 'import-default-export-from-me.js';
import oof from 'import-default-export-from-me.js';
import * as bar from 'import-all-from-me.js';
@@ -23,13 +23,13 @@ test('module static record constructor', t => {
`);
t.equal(
- '[object ModuleStaticRecord]',
+ '[object StaticModuleRecord]',
msr.toString(),
'instance string representation should be fixed',
);
t.equal(
- 'function ModuleStaticRecord() { [shim code] }',
- ModuleStaticRecord.toString(),
+ 'function StaticModuleRecord() { [shim code] }',
+ StaticModuleRecord.toString(),
'constructor string representation should be fixed',
);
@@ -46,10 +46,10 @@ test('module static record constructor', t => {
'should capture sorted unique imports',
);
- t.ok(Object.isFrozen(msr), 'ModuleStaticRecords should be frozen');
+ t.ok(Object.isFrozen(msr), 'StaticModuleRecords should be frozen');
t.ok(
Object.isFrozen(msr.imports),
- 'ModuleStaticRecord imports should be frozen',
+ 'StaticModuleRecord imports should be frozen',
);
t.end();

MODIFY
packages/transform-module/README.md
packages/transform-module/README.md
Transform-module is a transformation from a JS module source to a corresponding
JS program that, when evaluated, produces a function that can execute a module
and orchestrate its imports and exports.
-The module static record includes the static analysis of the module: what it
+The static module record includes the static analysis of the module: what it
imports and exports and how it refers to imported modules.
The workflow for executing a module, as conducted by a Compartment,
@@ -42,7 +42,7 @@ export const quux = 'Hello, World!';
quuux = 'Hello, World!';
```
-From this, the analyzer produces a module static record that shows what modules
+From this, the analyzer produces a static module record that shows what modules
the module needs to be linked to and how to link their imports and exports.
```js
@@ -124,11 +124,11 @@ to all modules that import the value.
```ts
// This is the signature of the analyze function, after composing it
// with Babel core.
-type Analyzer = ({string: ModuleSource}) => ModuleStaticRecord
+type Analyzer = ({string: ModuleSource}) => StaticModuleRecord
type ModuleSource = string
-type ModuleStaticRecord = {
+type StaticModuleRecord = {
exportAlls: ExportAlls,
imports: Imports,
liveExportMap: LiveExportMap,
@@ -138,7 +138,7 @@ type ModuleStaticRecord = {
// ExportAlls are the relative module specifiers found in directives like:
// export * from 'import-and-reexport-all-from-me.js';
-// These are both on the module static record and passed to the import function
+// These are both on the static module record and passed to the import function
// injected into a module functor.
// TODO Consider removing the import argument.
// It does not appear to be used by module instances.

fix(ses, transform-module)!: Fix StaticModuleRecord name (#323)