-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Emit WebAssembly types separately from DOM types
- Loading branch information
Showing
5 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
///////////////////////////// | ||
/// WebAssembly APIs | ||
///////////////////////////// | ||
|
||
declare namespace WebAssembly { | ||
interface CompileError extends Error { | ||
} | ||
|
||
var CompileError: { | ||
prototype: CompileError; | ||
new(message?: string): CompileError; | ||
(message?: string): CompileError; | ||
}; | ||
|
||
interface Global { | ||
value: any; | ||
valueOf(): any; | ||
} | ||
|
||
var Global: { | ||
prototype: Global; | ||
new(descriptor: GlobalDescriptor, v?: any): Global; | ||
}; | ||
|
||
interface Instance { | ||
readonly exports: Exports; | ||
} | ||
|
||
var Instance: { | ||
prototype: Instance; | ||
new(module: Module, importObject?: Imports): Instance; | ||
}; | ||
|
||
interface LinkError extends Error { | ||
} | ||
|
||
var LinkError: { | ||
prototype: LinkError; | ||
new(message?: string): LinkError; | ||
(message?: string): LinkError; | ||
}; | ||
|
||
interface Memory { | ||
readonly buffer: ArrayBuffer; | ||
grow(delta: number): number; | ||
} | ||
|
||
var Memory: { | ||
prototype: Memory; | ||
new(descriptor: MemoryDescriptor): Memory; | ||
}; | ||
|
||
interface Module { | ||
} | ||
|
||
var Module: { | ||
prototype: Module; | ||
new(bytes: BufferSource): Module; | ||
customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; | ||
exports(moduleObject: Module): ModuleExportDescriptor[]; | ||
imports(moduleObject: Module): ModuleImportDescriptor[]; | ||
}; | ||
|
||
interface RuntimeError extends Error { | ||
} | ||
|
||
var RuntimeError: { | ||
prototype: RuntimeError; | ||
new(message?: string): RuntimeError; | ||
(message?: string): RuntimeError; | ||
}; | ||
|
||
interface Table { | ||
readonly length: number; | ||
get(index: number): any; | ||
grow(delta: number, value?: any): number; | ||
set(index: number, value?: any): void; | ||
} | ||
|
||
var Table: { | ||
prototype: Table; | ||
new(descriptor: TableDescriptor, value?: any): Table; | ||
}; | ||
|
||
interface GlobalDescriptor { | ||
mutable?: boolean; | ||
value: ValueType; | ||
} | ||
|
||
interface MemoryDescriptor { | ||
initial: number; | ||
maximum?: number; | ||
shared?: boolean; | ||
} | ||
|
||
interface ModuleExportDescriptor { | ||
kind: ImportExportKind; | ||
name: string; | ||
} | ||
|
||
interface ModuleImportDescriptor { | ||
kind: ImportExportKind; | ||
module: string; | ||
name: string; | ||
} | ||
|
||
interface TableDescriptor { | ||
element: TableKind; | ||
initial: number; | ||
maximum?: number; | ||
} | ||
|
||
interface WebAssemblyInstantiatedSource { | ||
instance: Instance; | ||
module: Module; | ||
} | ||
|
||
type ImportExportKind = "function" | "global" | "memory" | "table"; | ||
type TableKind = "anyfunc" | "externref"; | ||
type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64"; | ||
type ExportValue = Function | Global | Memory | Table; | ||
type Exports = Record<string, ExportValue>; | ||
type ImportValue = ExportValue | number; | ||
type Imports = Record<string, ModuleImports>; | ||
type ModuleImports = Record<string, ImportValue>; | ||
function compile(bytes: BufferSource): Promise<Module>; | ||
function instantiate(bytes: BufferSource, importObject?: Imports): Promise<WebAssemblyInstantiatedSource>; | ||
function instantiate(moduleObject: Module, importObject?: Imports): Promise<Instance>; | ||
function validate(bytes: BufferSource): boolean; | ||
} | ||
|
||
type BufferSource = ArrayBufferView | ArrayBuffer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"WebAssembly": [ | ||
], | ||
"Window": [ | ||
"AesCbcParams", | ||
"AesCtrParams", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters