Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19043,7 +19043,7 @@ declare namespace WebAssembly {
};

interface Instance {
readonly exports: any;
readonly exports: Exports;
}

var Instance: {
Expand Down Expand Up @@ -19134,10 +19134,16 @@ declare namespace WebAssembly {

type ImportExportKind = "function" | "table" | "memory" | "global";
type TableKind = "anyfunc";
type ValueType = "i32" | "i64" | "f32" | "f64";
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
function compile(bytes: BufferSource): Promise<Module>;
function compileStreaming(source: Response | Promise<Response>): Promise<Module>;
function instantiate(bytes: BufferSource, importObject?: any): Promise<WebAssemblyInstantiatedSource>;
function instantiate(moduleObject: Module, importObject?: any): Promise<Instance>;
function instantiate(bytes: BufferSource, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>;
function instantiate(moduleObject: Module, importObject?: Imports): Promise<Instance>;
function instantiateStreaming(source: Response | Promise<Response>, importObject?: any): Promise<WebAssemblyInstantiatedSource>;
function validate(bytes: BufferSource): boolean;
}
Expand Down Expand Up @@ -20097,7 +20103,6 @@ type TouchType = "direct" | "stylus";
type Transport = "usb" | "nfc" | "ble";
type UserVerificationRequirement = "required" | "preferred" | "discouraged";
type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted";
type ValueType = "i32" | "i64" | "f32" | "f64";
type VideoFacingModeEnum = "user" | "environment" | "left" | "right";
type VisibilityState = "hidden" | "visible" | "prerender";
type WebGLPowerPreference = "default" | "low-power" | "high-performance";
Expand Down
13 changes: 9 additions & 4 deletions baselines/webworker.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5604,7 +5604,7 @@ declare namespace WebAssembly {
};

interface Instance {
readonly exports: any;
readonly exports: Exports;
}

var Instance: {
Expand Down Expand Up @@ -5679,10 +5679,16 @@ declare namespace WebAssembly {

type ImportExportKind = "function" | "table" | "memory" | "global";
type TableKind = "anyfunc";
type ValueType = "i32" | "i64" | "f32" | "f64";
type ExportValue = Function | Global | Memory | Table;
type Exports = Record<string, ExportValue>;
type ImportValue = ExportValue | number;
type ModuleImports = Record<string, ImportValue>;
type Imports = Record<string, ModuleImports>;
function compile(bytes: BufferSource): Promise<Module>;
function compileStreaming(source: Response | Promise<Response>): Promise<Module>;
function instantiate(bytes: BufferSource, importObject?: any): Promise<WebAssemblyInstantiatedSource>;
function instantiate(moduleObject: Module, importObject?: any): Promise<Instance>;
function instantiate(bytes: BufferSource, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>;
function instantiate(moduleObject: Module, importObject?: Imports): Promise<Instance>;
function instantiateStreaming(source: Response | Promise<Response>, importObject?: any): Promise<WebAssemblyInstantiatedSource>;
function validate(bytes: BufferSource): boolean;
}
Expand Down Expand Up @@ -5857,7 +5863,6 @@ type RequestRedirect = "follow" | "error" | "manual";
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant";
type ServiceWorkerUpdateViaCache = "imports" | "all" | "none";
type ValueType = "i32" | "i64" | "f32" | "f64";
type VisibilityState = "hidden" | "visible" | "prerender";
type WebGLPowerPreference = "default" | "low-power" | "high-performance";
type WorkerType = "classic" | "module";
Expand Down
49 changes: 49 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2264,6 +2264,55 @@
{
"new-type": "WindowProxy",
"type": "Window"
},
{
"new-type": "ExportValue",
"legacy-namespace": "WebAssembly",
"override-type": "Function | Global | Memory | Table"
},
{
"new-type": "Exports",
"legacy-namespace": "WebAssembly",
"type": "record",
"subtype": [
{
"type": "DOMString"
},
{
"type": "ExportValue"
}
]
},
{
"new-type": "ImportValue",
"legacy-namespace": "WebAssembly",
"override-type": "ExportValue | number"
},
{
"new-type": "ModuleImports",
"legacy-namespace": "WebAssembly",
"type": "record",
"subtype": [
{
"type": "DOMString"
},
{
"type": "ImportValue"
}
]
},
{
"new-type": "Imports",
"legacy-namespace": "WebAssembly",
"type": "record",
"subtype": [
{
"type": "DOMString"
},
{
"type": "ModuleImports"
}
]
}
]
}
Expand Down
34 changes: 33 additions & 1 deletion inputfiles/overridingTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@
},
"TableKind": {
"legacy-namespace": "WebAssembly"
},
"ValueType": {
"legacy-namespace": "WebAssembly"
}
}
},
Expand Down Expand Up @@ -2802,6 +2805,15 @@
}
}
}
},
"Instance": {
"properties": {
"property": {
"exports": {
"type": "Exports"
}
}
}
}
}
},
Expand Down Expand Up @@ -3190,5 +3202,25 @@
"new-type": "BodyInit"
}
]
}
},
"namespaces": [
{
"name": "WebAssembly",
"methods": {
"method": {
"instantiate": {
"override-signatures": [
"instantiate(bytes: BufferSource, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>",
"instantiate(moduleObject: Module, importObject?: Imports): Promise<Instance>"
],
"force-references": [
{
"type": "Imports"
}
]
}
}
}
}
]
}
8 changes: 6 additions & 2 deletions src/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,8 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
namespace.nested.enums
.sort(compareName)
.forEach(emitEnum);
namespace.nested.typedefs
.forEach(emitTypeDef);
}

emitProperties("var ", EmitScope.InstanceOnly, namespace);
Expand Down Expand Up @@ -1097,7 +1099,9 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {

function emitTypeDefs() {
if (webidl.typedefs) {
webidl.typedefs.typedef.forEach(emitTypeDef);
webidl.typedefs.typedef
.filter(i => !i["legacy-namespace"])
.forEach(emitTypeDef);
}
}

Expand Down Expand Up @@ -1272,7 +1276,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor) {
mapToArray(i.methods ? i.methods.method : {})
.filter(m => m.signature && !m["override-signatures"])
.map(m => ({
...m,
...m,
signature: replaceTypedefsInSignatures(m.signature.filter(hasSequenceArgument))
}))
.filter(m => m.signature.length)
Expand Down
8 changes: 7 additions & 1 deletion src/legacy-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export function collectLegacyNamespaceTypes(webidl: Browser.WebIdl): Browser.Int
getNamespace(i["legacy-namespace"]).nested!.enums.push(i);
}
}
for (const i of webidl.typedefs!.typedef) {
if (i["legacy-namespace"]) {
getNamespace(i["legacy-namespace"]).nested!.typedefs.push(i);
}
}

return mapToArray(namespaceMap);

Expand All @@ -44,7 +49,8 @@ function addEmptyNested(namespace: Browser.Interface): Browser.Interface {
nested: {
interfaces: [],
enums: [],
dictionaries: []
dictionaries: [],
typedefs: [],
}
};
}
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export interface Interface {
interfaces: Interface[];
enums: Enum[];
dictionaries: Dictionary[];
typedefs: TypeDef[];
}
}

Expand All @@ -222,6 +223,7 @@ export interface Enum {
export interface TypeDef extends Typed {
"new-type": string;
deprecated?: 1;
"legacy-namespace"?: string;
}

export interface Dictionary {
Expand Down