Skip to content

Commit

Permalink
types(ses): Align module descriptor types
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Jul 11, 2024
1 parent 388b96f commit 91c3cd3
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions packages/ses/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ export type RepairIntrinsics = (options?: LockdownOptions) => void;
export type HardenIntrinsics = () => void;
export type Lockdown = (options?: LockdownOptions) => void;

export type ModuleExportsNamespace = Record<string, any>;

export type __LiveExportMap__ = Record<string, [string, boolean]>;
export type __FixedExportMap__ = Record<string, [string]>;

export interface PrecompiledStaticModuleInterface {
export interface PrecompiledModuleSource {
imports: Array<string>;
exports: Array<string>;
reexports: Array<string>;
Expand All @@ -55,7 +57,7 @@ export interface PrecompiledStaticModuleInterface {
__fixedExportMap__: __FixedExportMap__;
}

export interface ThirdPartyStaticModuleInterface {
export interface VirtualModuleSource {
imports: Array<string>;
exports: Array<string>;
/**
Expand All @@ -68,34 +70,51 @@ export interface ThirdPartyStaticModuleInterface {
): void;
}

export type FinalStaticModuleType =
| PrecompiledStaticModuleInterface
| ThirdPartyStaticModuleInterface;
export type ModuleSource = PrecompiledModuleSource | VirtualModuleSource;

export interface RedirectStaticModuleInterface {
export interface RedirectModuleDescriptor {
specifier: string;
record?: FinalStaticModuleType;
record?: ModuleSource;
importMeta?: any;
compartment?: Compartment;
}

export type StaticModuleType =
| RedirectStaticModuleInterface
| FinalStaticModuleType;
export interface ReferenceModuleDescriptor {
specifier: string;
record?: ModuleSource;
importMeta?: any;
compartment?: Compartment;
}

export type ModuleExportsNamespace = Record<string, any>;
export type ModuleDescriptor =
// These descriptor shapes are needed for XS parity:
// | SourceModuleDescriptor
// | NamespaceModuleDescriptor
// To be deprecated:
| RedirectModuleDescriptor
| ReferenceModuleDescriptor
| ModuleExportsNamespace
| VirtualModuleSource
| PrecompiledModuleSource;

// Deprecated type aliases:
export type PrecompiledStaticModuleInterface = PrecompiledModuleSource;
export type ThirdPartyStaticModuleInterface = VirtualModuleSource;
export type RedirectStaticModuleInterface = RedirectModuleDescriptor;
export type FinalStaticModuleType = ModuleSource;
export type StaticModuleType = RedirectStaticModuleInterface | ModuleSource;

export type Transform = (source: string) => string;
export type ResolveHook = (
importSpecifier: string,
referrerSpecifier: string,
) => string;
export type ModuleMap = Record<string, string | ModuleExportsNamespace>;
export type ModuleMap = Record<string, string | ModuleDescriptor>;
export type ModuleMapHook = (
moduleSpecifier: string,
) => string | ModuleExportsNamespace | void;
export type ImportHook = (moduleSpecifier: string) => Promise<StaticModuleType>;
export type ImportNowHook = (moduleSpecifier: string) => StaticModuleType;
) => ModuleDescriptor | undefined;
export type ImportHook = (moduleSpecifier: string) => Promise<ModuleDescriptor>;
export type ImportNowHook = (moduleSpecifier: string) => ModuleDescriptor;

export interface CompartmentOptions {
name?: string;
Expand Down

0 comments on commit 91c3cd3

Please sign in to comment.