Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dotnet.d.ts « runtime « wasm « mono « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07c1db8ac7c6f8849e272d4a7c2706defb70a865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
//! Licensed to the .NET Foundation under one or more agreements.
//! The .NET Foundation licenses this file to you under the MIT license.
//!
//! This is generated file, see src/mono/wasm/runtime/rollup.config.js

//! This is not considered public API with backward compatibility guarantees. 

declare interface ManagedPointer {
    __brandManagedPointer: "ManagedPointer";
}
declare interface NativePointer {
    __brandNativePointer: "NativePointer";
}
declare interface VoidPtr extends NativePointer {
    __brand: "VoidPtr";
}
declare interface CharPtr extends NativePointer {
    __brand: "CharPtr";
}
declare interface Int32Ptr extends NativePointer {
    __brand: "Int32Ptr";
}
declare interface EmscriptenModule {
    HEAP8: Int8Array;
    HEAP16: Int16Array;
    HEAP32: Int32Array;
    HEAPU8: Uint8Array;
    HEAPU16: Uint16Array;
    HEAPU32: Uint32Array;
    HEAPF32: Float32Array;
    HEAPF64: Float64Array;
    _malloc(size: number): VoidPtr;
    _free(ptr: VoidPtr): void;
    print(message: string): void;
    printErr(message: string): void;
    ccall<T>(ident: string, returnType?: string | null, argTypes?: string[], args?: any[], opts?: any): T;
    cwrap<T extends Function>(ident: string, returnType: string, argTypes?: string[], opts?: any): T;
    cwrap<T extends Function>(ident: string, ...args: any[]): T;
    setValue(ptr: VoidPtr, value: number, type: string, noSafe?: number | boolean): void;
    setValue(ptr: Int32Ptr, value: number, type: string, noSafe?: number | boolean): void;
    getValue(ptr: number, type: string, noSafe?: number | boolean): number;
    UTF8ToString(ptr: CharPtr, maxBytesToRead?: number): string;
    UTF8ArrayToString(u8Array: Uint8Array, idx?: number, maxBytesToRead?: number): string;
    FS_createPath(parent: string, path: string, canRead?: boolean, canWrite?: boolean): string;
    FS_createDataFile(parent: string, name: string, data: TypedArray, canRead: boolean, canWrite: boolean, canOwn?: boolean): string;
    FS_readFile(filename: string, opts: any): any;
    removeRunDependency(id: string): void;
    addRunDependency(id: string): void;
    stackSave(): VoidPtr;
    stackRestore(stack: VoidPtr): void;
    stackAlloc(size: number): VoidPtr;
    ready: Promise<unknown>;
    preInit?: (() => any)[];
    preRun?: (() => any)[];
    postRun?: (() => any)[];
    onAbort?: {
        (error: any): void;
    };
    onRuntimeInitialized?: () => any;
    instantiateWasm: (imports: any, successCallback: Function) => any;
}
declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;

/**
 * Allocates a block of memory that can safely contain pointers into the managed heap.
 * The result object has get(index) and set(index, value) methods that can be used to retrieve and store managed pointers.
 * Once you are done using the root buffer, you must call its release() method.
 * For small numbers of roots, it is preferable to use the mono_wasm_new_root and mono_wasm_new_roots APIs instead.
 */
declare function mono_wasm_new_root_buffer(capacity: number, name?: string): WasmRootBuffer;
/**
 * Allocates a WasmRoot pointing to a root provided and controlled by external code. Typicaly on managed stack.
 * Releasing this root will not de-allocate the root space. You still need to call .release().
 */
declare function mono_wasm_new_external_root<T extends MonoObject>(address: VoidPtr | MonoObjectRef): WasmRoot<T>;
/**
 * Allocates temporary storage for a pointer into the managed heap.
 * Pointers stored here will be visible to the GC, ensuring that the object they point to aren't moved or collected.
 * If you already have a managed pointer you can pass it as an argument to initialize the temporary storage.
 * The result object has get() and set(value) methods, along with a .value property.
 * When you are done using the root you must call its .release() method.
 */
declare function mono_wasm_new_root<T extends MonoObject>(value?: T | undefined): WasmRoot<T>;
/**
 * Releases 1 or more root or root buffer objects.
 * Multiple objects may be passed on the argument list.
 * 'undefined' may be passed as an argument so it is safe to call this method from finally blocks
 *  even if you are not sure all of your roots have been created yet.
 * @param {... WasmRoot} roots
 */
declare function mono_wasm_release_roots(...args: WasmRoot<any>[]): void;
declare class WasmRootBuffer {
    private __count;
    private length;
    private __offset;
    private __offset32;
    private __handle;
    private __ownsAllocation;
    constructor(offset: VoidPtr, capacity: number, ownsAllocation: boolean, name?: string);
    _throw_index_out_of_range(): void;
    _check_in_range(index: number): void;
    get_address(index: number): MonoObjectRef;
    get_address_32(index: number): number;
    get(index: number): ManagedPointer;
    set(index: number, value: ManagedPointer): ManagedPointer;
    copy_value_from_address(index: number, sourceAddress: MonoObjectRef): void;
    _unsafe_get(index: number): number;
    _unsafe_set(index: number, value: ManagedPointer | NativePointer): void;
    clear(): void;
    release(): void;
    toString(): string;
}
interface WasmRoot<T extends MonoObject> {
    get_address(): MonoObjectRef;
    get_address_32(): number;
    get address(): MonoObjectRef;
    get(): T;
    set(value: T): T;
    get value(): T;
    set value(value: T);
    copy_from_address(source: MonoObjectRef): void;
    copy_to_address(destination: MonoObjectRef): void;
    copy_from(source: WasmRoot<T>): void;
    copy_to(destination: WasmRoot<T>): void;
    valueOf(): T;
    clear(): void;
    release(): void;
    toString(): string;
}

interface MonoObject extends ManagedPointer {
    __brandMonoObject: "MonoObject";
}
interface MonoString extends MonoObject {
    __brand: "MonoString";
}
interface MonoArray extends MonoObject {
    __brand: "MonoArray";
}
interface MonoObjectRef extends ManagedPointer {
    __brandMonoObjectRef: "MonoObjectRef";
}
declare type MonoConfig = {
    isError: false;
    assembly_root: string;
    assets: AllAssetEntryTypes[];
    debug_level?: number;
    enable_debugging?: number;
    globalization_mode: GlobalizationMode;
    diagnostic_tracing?: boolean;
    remote_sources?: string[];
    environment_variables?: {
        [i: string]: string;
    };
    runtime_options?: string[];
    aot_profiler_options?: AOTProfilerOptions;
    coverage_profiler_options?: CoverageProfilerOptions;
    ignore_pdb_load_errors?: boolean;
    wait_for_debugger?: number;
};
declare type MonoConfigError = {
    isError: true;
    message: string;
    error: any;
};
declare type AllAssetEntryTypes = AssetEntry | AssemblyEntry | SatelliteAssemblyEntry | VfsEntry | IcuData;
declare type AssetEntry = {
    name: string;
    behavior: AssetBehaviours;
    virtual_path?: string;
    culture?: string;
    load_remote?: boolean;
    is_optional?: boolean;
    buffer?: ArrayBuffer;
};
interface AssemblyEntry extends AssetEntry {
    name: "assembly";
}
interface SatelliteAssemblyEntry extends AssetEntry {
    name: "resource";
    culture: string;
}
interface VfsEntry extends AssetEntry {
    name: "vfs";
    virtual_path: string;
}
interface IcuData extends AssetEntry {
    name: "icu";
    load_remote: boolean;
}
declare const enum AssetBehaviours {
    Resource = "resource",
    Assembly = "assembly",
    Heap = "heap",
    ICU = "icu",
    VFS = "vfs"
}
declare const enum GlobalizationMode {
    ICU = "icu",
    INVARIANT = "invariant",
    AUTO = "auto"
}
declare type AOTProfilerOptions = {
    write_at?: string;
    send_to?: string;
};
declare type CoverageProfilerOptions = {
    write_at?: string;
    send_to?: string;
};
interface EventPipeSessionOptions {
    collectRundownEvents?: boolean;
}
declare type DotnetModuleConfig = {
    disableDotnet6Compatibility?: boolean;
    config?: MonoConfig | MonoConfigError;
    configSrc?: string;
    onConfigLoaded?: (config: MonoConfig) => Promise<void>;
    onDotnetReady?: () => void;
    imports?: DotnetModuleConfigImports;
    exports?: string[];
} & Partial<EmscriptenModule>;
declare type DotnetModuleConfigImports = {
    require?: (name: string) => any;
    fetch?: (url: string) => Promise<Response>;
    fs?: {
        promises?: {
            readFile?: (path: string) => Promise<string | Buffer>;
        };
        readFileSync?: (path: string, options: any | undefined) => string;
    };
    crypto?: {
        randomBytes?: (size: number) => Buffer;
    };
    ws?: WebSocket & {
        Server: any;
    };
    path?: {
        normalize?: (path: string) => string;
        dirname?: (path: string) => string;
    };
    url?: any;
};

declare type EventPipeSessionID = bigint;
interface EventPipeSession {
    get sessionID(): EventPipeSessionID;
    start(): void;
    stop(): void;
    getTraceBlob(): Blob;
}
interface Diagnostics {
    createEventPipeSession(options?: EventPipeSessionOptions): EventPipeSession | null;
}

declare function mono_wasm_runtime_ready(): void;

declare function mono_wasm_setenv(name: string, value: string): void;
declare function mono_load_runtime_and_bcl_args(config: MonoConfig | MonoConfigError | undefined): Promise<void>;
declare function mono_wasm_load_data_archive(data: Uint8Array, prefix: string): boolean;
/**
 * Loads the mono config file (typically called mono-config.json) asynchroniously
 * Note: the run dependencies are so emsdk actually awaits it in order.
 *
 * @param {string} configFilePath - relative path to the config file
 * @throws Will throw an error if the config file loading fails
 */
declare function mono_wasm_load_config(configFilePath: string): Promise<void>;

declare function mono_wasm_load_icu_data(offset: VoidPtr): boolean;

/**
 * @deprecated Not GC or thread safe
 */
declare function conv_string(mono_obj: MonoString): string | null;
declare function conv_string_root(root: WasmRoot<MonoString>): string | null;
declare function js_string_to_mono_string_root(string: string, result: WasmRoot<MonoString>): void;
/**
 * @deprecated Not GC or thread safe
 */
declare function js_string_to_mono_string(string: string): MonoString;

/**
 * @deprecated Not GC or thread safe. For blazor use only
 */
declare function js_to_mono_obj(js_obj: any): MonoObject;
declare function js_to_mono_obj_root(js_obj: any, result: WasmRoot<MonoObject>, should_add_in_flight: boolean): void;
declare function js_typed_array_to_array_root(js_obj: any, result: WasmRoot<MonoArray>): void;
/**
 * @deprecated Not GC or thread safe
 */
declare function js_typed_array_to_array(js_obj: any): MonoArray;

declare function unbox_mono_obj(mono_obj: MonoObject): any;
declare function unbox_mono_obj_root(root: WasmRoot<any>): any;
declare function mono_array_to_js_array(mono_array: MonoArray): any[] | null;
declare function mono_array_root_to_js_array(arrayRoot: WasmRoot<MonoArray>): any[] | null;

declare function mono_bind_static_method(fqn: string, signature?: string): Function;
declare function mono_call_assembly_entry_point(assembly: string, args?: any[], signature?: string): number;

declare function mono_wasm_load_bytes_into_heap(bytes: Uint8Array): VoidPtr;

declare type _MemOffset = number | VoidPtr | NativePointer | ManagedPointer;
declare type _NumberOrPointer = number | VoidPtr | NativePointer | ManagedPointer;
declare function setU8(offset: _MemOffset, value: number): void;
declare function setU16(offset: _MemOffset, value: number): void;
declare function setU32(offset: _MemOffset, value: _NumberOrPointer): void;
declare function setI8(offset: _MemOffset, value: number): void;
declare function setI16(offset: _MemOffset, value: number): void;
declare function setI32(offset: _MemOffset, value: _NumberOrPointer): void;
declare function setI64(offset: _MemOffset, value: number): void;
declare function setF32(offset: _MemOffset, value: number): void;
declare function setF64(offset: _MemOffset, value: number): void;
declare function getU8(offset: _MemOffset): number;
declare function getU16(offset: _MemOffset): number;
declare function getU32(offset: _MemOffset): number;
declare function getI8(offset: _MemOffset): number;
declare function getI16(offset: _MemOffset): number;
declare function getI32(offset: _MemOffset): number;
declare function getI64(offset: _MemOffset): number;
declare function getF32(offset: _MemOffset): number;
declare function getF64(offset: _MemOffset): number;

declare function mono_run_main_and_exit(main_assembly_name: string, args: string[]): Promise<void>;
declare function mono_run_main(main_assembly_name: string, args: string[]): Promise<number>;

declare const MONO: {
    mono_wasm_setenv: typeof mono_wasm_setenv;
    mono_wasm_load_bytes_into_heap: typeof mono_wasm_load_bytes_into_heap;
    mono_wasm_load_icu_data: typeof mono_wasm_load_icu_data;
    mono_wasm_runtime_ready: typeof mono_wasm_runtime_ready;
    mono_wasm_load_data_archive: typeof mono_wasm_load_data_archive;
    mono_wasm_load_config: typeof mono_wasm_load_config;
    mono_load_runtime_and_bcl_args: typeof mono_load_runtime_and_bcl_args;
    mono_wasm_new_root_buffer: typeof mono_wasm_new_root_buffer;
    mono_wasm_new_root: typeof mono_wasm_new_root;
    mono_wasm_new_external_root: typeof mono_wasm_new_external_root;
    mono_wasm_release_roots: typeof mono_wasm_release_roots;
    mono_run_main: typeof mono_run_main;
    mono_run_main_and_exit: typeof mono_run_main_and_exit;
    mono_wasm_add_assembly: (name: string, data: VoidPtr, size: number) => number;
    mono_wasm_load_runtime: (unused: string, debug_level: number) => void;
    config: MonoConfig | MonoConfigError;
    loaded_files: string[];
    setI8: typeof setI8;
    setI16: typeof setI16;
    setI32: typeof setI32;
    setI64: typeof setI64;
    setU8: typeof setU8;
    setU16: typeof setU16;
    setU32: typeof setU32;
    setF32: typeof setF32;
    setF64: typeof setF64;
    getI8: typeof getI8;
    getI16: typeof getI16;
    getI32: typeof getI32;
    getI64: typeof getI64;
    getU8: typeof getU8;
    getU16: typeof getU16;
    getU32: typeof getU32;
    getF32: typeof getF32;
    getF64: typeof getF64;
    diagnostics: Diagnostics;
};
declare type MONOType = typeof MONO;
declare const BINDING: {
    /**
     * @deprecated Not GC or thread safe
     */
    mono_obj_array_new: (size: number) => MonoArray;
    /**
     * @deprecated Not GC or thread safe
     */
    mono_obj_array_set: (array: MonoArray, idx: number, obj: MonoObject) => void;
    /**
     * @deprecated Not GC or thread safe
     */
    js_string_to_mono_string: typeof js_string_to_mono_string;
    /**
     * @deprecated Not GC or thread safe
     */
    js_typed_array_to_array: typeof js_typed_array_to_array;
    /**
     * @deprecated Not GC or thread safe
     */
    mono_array_to_js_array: typeof mono_array_to_js_array;
    /**
     * @deprecated Not GC or thread safe
     */
    js_to_mono_obj: typeof js_to_mono_obj;
    /**
     * @deprecated Not GC or thread safe
     */
    conv_string: typeof conv_string;
    /**
     * @deprecated Not GC or thread safe
     */
    unbox_mono_obj: typeof unbox_mono_obj;
    /**
     * @deprecated Renamed to conv_string_root
     */
    conv_string_rooted: typeof conv_string_root;
    mono_obj_array_new_ref: (size: number, result: MonoObjectRef) => void;
    mono_obj_array_set_ref: (array: MonoObjectRef, idx: number, obj: MonoObjectRef) => void;
    js_string_to_mono_string_root: typeof js_string_to_mono_string_root;
    js_typed_array_to_array_root: typeof js_typed_array_to_array_root;
    js_to_mono_obj_root: typeof js_to_mono_obj_root;
    conv_string_root: typeof conv_string_root;
    unbox_mono_obj_root: typeof unbox_mono_obj_root;
    mono_array_root_to_js_array: typeof mono_array_root_to_js_array;
    bind_static_method: typeof mono_bind_static_method;
    call_assembly_entry_point: typeof mono_call_assembly_entry_point;
};
declare type BINDINGType = typeof BINDING;
interface DotnetPublicAPI {
    MONO: typeof MONO;
    BINDING: typeof BINDING;
    INTERNAL: any;
    Module: EmscriptenModule;
    RuntimeId: number;
    RuntimeBuildInfo: {
        ProductVersion: string;
        Configuration: string;
    };
}

declare function createDotnetRuntime(moduleFactory: DotnetModuleConfig | ((api: DotnetPublicAPI) => DotnetModuleConfig)): Promise<DotnetPublicAPI>;
declare type CreateDotnetRuntimeType = typeof createDotnetRuntime;
declare global {
    function getDotnetRuntime(runtimeId: number): DotnetPublicAPI | undefined;
}

export { BINDINGType, CreateDotnetRuntimeType, DotnetModuleConfig, DotnetPublicAPI, EmscriptenModule, MONOType, MonoArray, MonoObject, MonoString, VoidPtr, createDotnetRuntime as default };