feat(ses): Add TypeScript definitions for Compartment aux types
MODIFY
packages/ses/NEWS.md
packages/ses/NEWS.md
@@ -2,7 +2,9 @@ User-visible changes in SES:
## Next release
-- No changes yet
+- Expand TypeScript definitions to include Compartment, StaticModuleRecord,
+ StaticModuleType, RedirectStaticModuleInterface, FinalStaticModuleType,
+ ThirdPartyStaticModuleInterface, Transform, ImportHook, and ModuleMapHook.
## Release 0.12.3 (1-Mar-2021)

MODIFY
packages/ses/index.d.ts
packages/ses/index.d.ts
import type { Hardener } from '@agoric/make-hardener';
import type { CompartmentConstructor } from './src/compartment-shim';
import type { Lockdown } from './src/lockdown-shim';
+import type { StaticModuleRecord } from './module-shim';
// For scripts.
declare var harden: Hardener;
declare var lockdown: Lockdown;
-declare var Compartment: CompartmentConstructor;
+declare var Compartment : ReturnType<CompartmentConstructor>;
+declare var StaticModuleRecord : StaticModuleRecord;
+
+declare type StaticModuleType = RedirectStaticModuleInterface | FinalStaticModuleType;
+declare interface RedirectStaticModuleInterface {
+ readonly record: FinalStaticModuleType,
+ specifier: string
+};
+declare type FinalStaticModuleType = StaticModuleRecord | ThirdPartyModuleInterface;
+declare interface ThirdPartyStaticModuleInterface {
+ readonly imports: Array<string>,
+ readonly execute: (exports: Object) => void,
+};
+
+declare type Transform = (source: string) => string;
+declare type ImportHook = (moduleSpecifier: string) => Promise<Object>;
+declare type ModuleMapHook = (moduleSpecifier: string) => string | Object | void;
declare global {
// For modules.
var harden: Hardener;
var lockdown : Lockdown;
- var Compartment : CompartmentConstructor;
+ var Compartment : ReturnType<CompartmentConstructor>;
+ var StaticModuleRecord : StaticModuleRecord;
+
+ type StaticModuleType = RedirectStaticModuleInterface | FinalStaticModuleType;
+ interface RedirectStaticModuleInterface {
+ readonly record: FinalStaticModuleType,
+ specifier: string
+ };
+ type FinalStaticModuleType = StaticModuleRecord | ThirdPartyModuleInterface;
+ interface ThirdPartyStaticModuleInterface {
+ readonly imports: Array<string>,
+ readonly execute: (exports: Object) => void,
+ };
+
+ type Transform = (source: string) => string;
+ type ImportHook = (moduleSpecifier: string) => Promise<Object>;
+ type ModuleMapHook = (moduleSpecifier: string) => string | Object | void;
}

feat(ses): Add TypeScript definitions for Compartment aux types