quickwin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +197 -0
- package/README.md +196 -0
- package/examples/PdfCanvas.js +67 -0
- package/examples/PdfCanvas.tsx +83 -0
- package/examples/pdf_preview2.js +431 -0
- package/examples/pdf_preview2.ts +375 -0
- package/examples/pdf_viewer.js +17623 -0
- package/examples/pdf_viewer.tsx +279 -0
- package/examples/test_gallery.js +17452 -0
- package/examples/test_gallery.tsx +285 -0
- package/examples/test_react_lazy.js +17336 -0
- package/examples/test_react_lazy.tsx +63 -0
- package/examples/test_react_listbox.js +17339 -0
- package/examples/test_react_listbox.tsx +71 -0
- package/examples/test_root_window.js +17313 -0
- package/examples/test_root_window.tsx +41 -0
- package/examples/test_tab.js +17339 -0
- package/examples/test_tab.tsx +75 -0
- package/examples/tray_demo.js +79 -0
- package/examples/tray_demo.tsx +81 -0
- package/lib/assert.js +8 -0
- package/lib/assert.ts +7 -0
- package/lib/cache-utils.js +43 -0
- package/lib/cache-utils.ts +40 -0
- package/lib/dumpRects.js +25 -0
- package/lib/dumpRects.ts +25 -0
- package/lib/fetch.js +490 -0
- package/lib/fetch.ts +502 -0
- package/lib/http-common.js +342 -0
- package/lib/http-common.ts +399 -0
- package/lib/http-server.js +416 -0
- package/lib/http-server.ts +424 -0
- package/lib/polyfill.js +156 -0
- package/lib/polyfill.ts +171 -0
- package/lib/react-qw/components/Button.js +8 -0
- package/lib/react-qw/components/CheckBox.js +31 -0
- package/lib/react-qw/components/ComboBox.js +42 -0
- package/lib/react-qw/components/DateTimePicker.js +96 -0
- package/lib/react-qw/components/Input.js +50 -0
- package/lib/react-qw/components/Link.js +43 -0
- package/lib/react-qw/components/ListBox.js +48 -0
- package/lib/react-qw/components/ListView.js +328 -0
- package/lib/react-qw/components/PathPicker.js +136 -0
- package/lib/react-qw/components/ProgressBar.js +22 -0
- package/lib/react-qw/components/RadioButton.js +31 -0
- package/lib/react-qw/components/ScrollView.js +139 -0
- package/lib/react-qw/components/Slider.js +45 -0
- package/lib/react-qw/components/Tab.js +61 -0
- package/lib/react-qw/components/Tooltip.js +55 -0
- package/lib/react-qw/components/TreeView.js +130 -0
- package/lib/react-qw/components/index.js +16 -0
- package/lib/react-qw/components/index.ts +17 -0
- package/lib/react-qw/index.js +73 -0
- package/lib/react-qw/index.ts +90 -0
- package/lib/react-qw/jsx.d.ts +34 -0
- package/lib/react-qw/layout.js +82 -0
- package/lib/react-qw/layout.ts +111 -0
- package/lib/react-qw/props.js +27 -0
- package/lib/react-qw/props.ts +36 -0
- package/lib/react-qw/reconciler.js +333 -0
- package/lib/react-qw/reconciler.ts +373 -0
- package/lib/stream.js +2 -0
- package/lib/stream.ts +22 -0
- package/lib/text-codec.js +197 -0
- package/lib/text-codec.ts +171 -0
- package/lib/text-measure.js +52 -0
- package/lib/text-measure.ts +54 -0
- package/lib/url.js +278 -0
- package/lib/url.ts +201 -0
- package/lib/vendor/web-streams/ponyfill.d.mts +829 -0
- package/lib/vendor/web-streams/ponyfill.mjs +8 -0
- package/lib/websocket.js +541 -0
- package/lib/websocket.ts +555 -0
- package/package.json +44 -0
- package/quickwin.d.ts +594 -0
- package/quickwin_const.d.ts +900 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin.exe +0 -0
- package/test/add.wasm +0 -0
- package/test/complex.wasm +0 -0
- package/test/complex_imports.wasm +0 -0
- package/test/debug/http_server_e2e.js +31 -0
- package/test/debug/minwasm.js +52 -0
- package/test/debug/mupdf_debug.js +104 -0
- package/test/debug/wasm.js +122 -0
- package/test/debug/wasm_export_debug.js +64 -0
- package/test/debug/wasm_names.js +46 -0
- package/test/global_imports.wasm +0 -0
- package/test/import_func.wasm +0 -0
- package/test/imports.wasm +0 -0
- package/test/run.js +91 -0
- package/test/run.ts +96 -0
- package/test/sjlj.wasm +0 -0
- package/test/test_basic.js +7 -0
- package/test/test_basic.ts +9 -0
- package/test/test_basic_fetch.js +34 -0
- package/test/test_basic_fetch.ts +33 -0
- package/test/test_brotli.js +48 -0
- package/test/test_brotli.ts +52 -0
- package/test/test_fetch_cache.js +169 -0
- package/test/test_fetch_cache.ts +187 -0
- package/test/test_ffi.js +157 -0
- package/test/test_ffi.ts +174 -0
- package/test/test_frame_encoding.js +128 -0
- package/test/test_frame_encoding.ts +132 -0
- package/test/test_helper.js +84 -0
- package/test/test_helper.ts +80 -0
- package/test/test_http_import.js +78 -0
- package/test/test_http_import.ts +74 -0
- package/test/test_http_server.js +142 -0
- package/test/test_http_server.ts +136 -0
- package/test/test_import_dir.js +4 -0
- package/test/test_import_dir.ts +5 -0
- package/test/test_ipv6.js +134 -0
- package/test/test_ipv6.ts +129 -0
- package/test/test_jsx.js +1314 -0
- package/test/test_meta_url.js +3 -0
- package/test/test_meta_url.ts +4 -0
- package/test/test_mupdf_render.js +69 -0
- package/test/test_mupdf_render.ts +74 -0
- package/test/test_mupdf_twice.js +77 -0
- package/test/test_mupdf_twice.ts +81 -0
- package/test/test_mupdf_wasm.js +33 -0
- package/test/test_mupdf_wasm.ts +30 -0
- package/test/test_net_event.js +57 -0
- package/test/test_net_event.ts +55 -0
- package/test/test_net_fetch.js +259 -0
- package/test/test_net_fetch.ts +238 -0
- package/test/test_net_websocket.js +180 -0
- package/test/test_net_websocket.ts +164 -0
- package/test/test_polyfill.js +144 -0
- package/test/test_polyfill.ts +159 -0
- package/test/test_react_complex.js +17440 -0
- package/test/test_react_counter.js +17331 -0
- package/test/test_react_flex.js +17643 -0
- package/test/test_react_hidden.js +17336 -0
- package/test/test_react_listview_link.js +17371 -0
- package/test/test_react_render.js +17326 -0
- package/test/test_url.js +173 -0
- package/test/test_url.ts +183 -0
- package/test/test_wasm_basic.js +85 -0
- package/test/test_wasm_basic.ts +73 -0
- package/test/test_wasm_import_global.js +41 -0
- package/test/test_wasm_import_global.ts +45 -0
- package/test/test_wasm_sjlj.js +145 -0
- package/test/test_wasm_sjlj.ts +125 -0
- package/test/test_wasm_types.js +97 -0
- package/test/test_wasm_types.ts +124 -0
- package/test/test_worker.js +21 -0
- package/test/test_worker.ts +24 -0
- package/test/test_worker_fetch.js +26 -0
- package/test/test_worker_fetch.ts +27 -0
- package/test/test_worker_net.js +51 -0
- package/test/test_worker_net.ts +54 -0
- package/test/test_worker_wasm_concurrent.js +44 -0
- package/test/test_worker_wasm_concurrent.ts +45 -0
- package/test/types.wasm +0 -0
- package/test/worker_fetch.js +13 -0
- package/test/worker_fetch.ts +13 -0
- package/test/worker_helper.js +1 -0
- package/test/worker_helper.ts +1 -0
- package/test/worker_http.js +18 -0
- package/test/worker_http.ts +20 -0
- package/test/worker_import_lib.js +12 -0
- package/test/worker_import_lib.ts +13 -0
- package/test/worker_module.js +16 -0
- package/test/worker_module.ts +17 -0
- package/test/worker_wasm_concurrent.js +22 -0
- package/test/worker_wasm_concurrent.ts +22 -0
- package/tsconfig.json +27 -0
- package/vendor/mupdf-wasm/mupdf-wasm.d.ts +571 -0
- package/vendor/mupdf-wasm/mupdf-wasm.js +2749 -0
- package/vendor/mupdf-wasm/mupdf-wasm.wasm +0 -0
- package/vendor/mupdf-wasm/mupdf.d.ts +939 -0
- package/vendor/mupdf-wasm/mupdf.js +3317 -0
package/quickwin.d.ts
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
/// <reference path="quickwin_const.d.ts" />
|
|
2
|
+
interface ImportMeta {
|
|
3
|
+
url: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Provides the command line arguments. The first argument is the script name. */
|
|
7
|
+
declare var scriptArgs: string[];
|
|
8
|
+
/** Print the arguments separated by spaces and a trailing newline. */
|
|
9
|
+
declare function print(...args: unknown[]): void;
|
|
10
|
+
/** Same as print(). */
|
|
11
|
+
declare const console: Console
|
|
12
|
+
|
|
13
|
+
declare const navigator: {
|
|
14
|
+
appVersion: string
|
|
15
|
+
userAgent: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Console {
|
|
19
|
+
/** Same as print(). */
|
|
20
|
+
log: (...args: unknown[]) => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
type UnknownRecord = Record<string, unknown>
|
|
25
|
+
|
|
26
|
+
declare namespace WebAssembly {
|
|
27
|
+
interface Module { }
|
|
28
|
+
interface Instance<E extends UnknownRecord = UnknownRecord> {
|
|
29
|
+
exports: E
|
|
30
|
+
}
|
|
31
|
+
interface Global {
|
|
32
|
+
value: unknown
|
|
33
|
+
valueOf(): unknown
|
|
34
|
+
}
|
|
35
|
+
interface GlobalDescriptor {
|
|
36
|
+
value: 'i32' | 'i64' | 'f32' | 'f64'
|
|
37
|
+
mutable?: boolean
|
|
38
|
+
}
|
|
39
|
+
interface Memory {
|
|
40
|
+
readonly buffer: ArrayBuffer
|
|
41
|
+
grow(delta: number): number
|
|
42
|
+
}
|
|
43
|
+
interface MemoryDescriptor {
|
|
44
|
+
initial: number
|
|
45
|
+
maximum?: number
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const WebAssembly: {
|
|
50
|
+
validate(buffer: ArrayBuffer): boolean
|
|
51
|
+
compile(buffer: ArrayBuffer): Promise<WebAssembly.Module>
|
|
52
|
+
instantiate<E extends UnknownRecord = UnknownRecord>(buffer: ArrayBuffer, importObject?: unknown): Promise<{ module: WebAssembly.Module; instance: WebAssembly.Instance<E> }>
|
|
53
|
+
instantiate<E extends UnknownRecord = UnknownRecord>(module: WebAssembly.Module, importObject?: unknown): Promise<WebAssembly.Instance<E>>
|
|
54
|
+
Module: {
|
|
55
|
+
new(buffer: ArrayBuffer): WebAssembly.Module
|
|
56
|
+
exports(module: WebAssembly.Module): { name: string; kind: string }[]
|
|
57
|
+
imports(module: WebAssembly.Module): { module: string; name: string; kind: string }[]
|
|
58
|
+
}
|
|
59
|
+
Instance: {
|
|
60
|
+
/**
|
|
61
|
+
* WAMR 限制:
|
|
62
|
+
* - 导入的 Global 在实例化时会 snapshot 值,之后无法与宿主或其他实例共享
|
|
63
|
+
* - 不支持 mutable imported global 的实时同步
|
|
64
|
+
*/
|
|
65
|
+
new<E extends UnknownRecord = UnknownRecord>(module: WebAssembly.Module, importObject?: unknown): WebAssembly.Instance<E>
|
|
66
|
+
}
|
|
67
|
+
Global: {
|
|
68
|
+
new(descriptor: WebAssembly.GlobalDescriptor, value?: unknown): WebAssembly.Global
|
|
69
|
+
}
|
|
70
|
+
Memory: {
|
|
71
|
+
new(descriptor: WebAssembly.MemoryDescriptor): WebAssembly.Memory
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
interface Event {
|
|
76
|
+
readonly type: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface MessageEvent {
|
|
80
|
+
readonly type: string;
|
|
81
|
+
readonly data: unknown;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface CloseEvent {
|
|
85
|
+
readonly type: string;
|
|
86
|
+
readonly code: number;
|
|
87
|
+
readonly reason: string;
|
|
88
|
+
readonly wasClean: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
declare module "std" {
|
|
92
|
+
interface FILE {
|
|
93
|
+
/** Close the file. Return 0 if OK or `-errno` in case of I/O error. */
|
|
94
|
+
close(): number;
|
|
95
|
+
/** Outputs the string with the UTF-8 encoding. */
|
|
96
|
+
puts(str: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Formatted printf.
|
|
99
|
+
* The same formats as the standard C library `printf` are supported.
|
|
100
|
+
* Integer format types (e.g. `%d`) truncate the Numbers or BigInts to 32 bits.
|
|
101
|
+
* Use the `l` modifier (e.g. `%ld`) to truncate to 64 bits.
|
|
102
|
+
*/
|
|
103
|
+
printf(fmt: string, ...args: unknown[]): void;
|
|
104
|
+
/** Flush the buffered file. */
|
|
105
|
+
flush(): void;
|
|
106
|
+
/** Seek to a give file position (whence is `std.SEEK_*`). `offset` can be a number or a bigint. Return 0 if OK or `-errno` in case of I/O error. */
|
|
107
|
+
seek(offset: number | bigint, whence: number): number;
|
|
108
|
+
/** Return the current file position. */
|
|
109
|
+
tell(): number;
|
|
110
|
+
/** Return the current file position as a bigint. */
|
|
111
|
+
tello(): bigint;
|
|
112
|
+
/** Return true if end of file. */
|
|
113
|
+
eof(): boolean;
|
|
114
|
+
/** Return the associated OS handle. */
|
|
115
|
+
fileno(): import("os").Fd;
|
|
116
|
+
/** Return true if there was an error. */
|
|
117
|
+
error(): boolean;
|
|
118
|
+
/** Clear the error indication. */
|
|
119
|
+
clearerr(): void;
|
|
120
|
+
/** Read `length` bytes from the file to the ArrayBuffer `buffer` at byte position `position` (wrapper to the libc `fread`). */
|
|
121
|
+
read(buffer: ArrayBuffer, position: number, length: number): number;
|
|
122
|
+
/** Write `length` bytes to the file from the ArrayBuffer `buffer` at byte position `position` (wrapper to the libc `fwrite`). */
|
|
123
|
+
write(buffer: ArrayBuffer, position: number, length: number): number;
|
|
124
|
+
/** Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed. */
|
|
125
|
+
getline(): string | null;
|
|
126
|
+
/** Read `max_size` bytes from the file and return them as a string assuming UTF-8 encoding. If `max_size` is not present, the file is read up its end. */
|
|
127
|
+
readAsString(max_size?: number): string | null;
|
|
128
|
+
/** Return the next byte from the file. Return -1 if the end of file is reached. */
|
|
129
|
+
getByte(): number;
|
|
130
|
+
/** Write one byte to the file. */
|
|
131
|
+
putByte(c: number): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface UrlGetOptions {
|
|
135
|
+
/** Boolean (default = false). If true, the response is an ArrayBuffer instead of a string. */
|
|
136
|
+
binary?: boolean;
|
|
137
|
+
/** Boolean (default = false). If true, return the an object contains the properties `response`, `responseHeaders`, `status`. */
|
|
138
|
+
full?: boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface UrlGetFullResult {
|
|
142
|
+
response: string | ArrayBuffer | null;
|
|
143
|
+
responseHeaders: string;
|
|
144
|
+
status: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
interface EvalScriptOptions {
|
|
148
|
+
/** Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript. */
|
|
149
|
+
backtrace_barrier?: boolean;
|
|
150
|
+
/** Boolean (default = false). If true, `await` is accepted in the script and a promise is returned. */
|
|
151
|
+
async?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Exit the process. */
|
|
155
|
+
function exit(n: number): never;
|
|
156
|
+
/** Evaluate the string `str` as a script (global eval). */
|
|
157
|
+
function evalScript(str: string, options?: EvalScriptOptions): unknown;
|
|
158
|
+
/** Evaluate the file `filename` as a script (global eval). */
|
|
159
|
+
function loadScript(filename: string): unknown;
|
|
160
|
+
/** Load the file `filename` and return it as a string assuming UTF-8 encoding. Return `null` in case of I/O error. */
|
|
161
|
+
function loadFile(filename: string): string | null;
|
|
162
|
+
/** Open a file (wrapper to the libc `fopen()`). Return the FILE object or `null` in case of I/O error. If `errorObj` is not undefined, set its `errno` property to the error code or to 0 if no error occured. */
|
|
163
|
+
function open(filename: string, flags: string, errorObj?: { errno: number }): FILE | null;
|
|
164
|
+
/** Open a process by creating a pipe (wrapper to the libc `popen()`). Return the FILE object or `null` in case of I/O error. If `errorObj` is not undefined, set its `errno` property to the error code or to 0 if no error occured. */
|
|
165
|
+
function popen(command: string, flags: string, errorObj?: { errno: number }): FILE | null;
|
|
166
|
+
/** Open a file from a file handle (wrapper to the libc `fdopen()`). Return the FILE object or `null` in case of I/O error. If `errorObj` is not undefined, set its `errno` property to the error code or to 0 if no error occured. */
|
|
167
|
+
function fdopen(fd: number, flags: string, errorObj?: { errno: number }): FILE | null;
|
|
168
|
+
/** Open a temporary file. Return the FILE object or `null` in case of I/O error. If `errorObj` is not undefined, set its `errno` property to the error code or to 0 if no error occured. */
|
|
169
|
+
function tmpfile(errorObj?: { errno: number }): FILE | null;
|
|
170
|
+
/** Equivalent to `std.out.puts(str)`. */
|
|
171
|
+
function puts(str: string): void;
|
|
172
|
+
/** Equivalent to `std.out.printf(fmt, ...args)`. */
|
|
173
|
+
function printf(fmt: string, ...args: unknown[]): void;
|
|
174
|
+
/** Equivalent to the libc sprintf(). */
|
|
175
|
+
function sprintf(fmt: string, ...args: unknown[]): string;
|
|
176
|
+
|
|
177
|
+
/** Wrappers to the libc file `stdout`. */
|
|
178
|
+
const out: FILE;
|
|
179
|
+
/** Wrappers to the libc file `stderr`. */
|
|
180
|
+
const err: FILE;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Enumeration object containing the integer value of common errors
|
|
184
|
+
* (additional error codes may be defined):
|
|
185
|
+
*/
|
|
186
|
+
namespace Error {
|
|
187
|
+
const EINVAL: number;
|
|
188
|
+
const EIO: number;
|
|
189
|
+
const EACCES: number;
|
|
190
|
+
const EEXIST: number;
|
|
191
|
+
const ENOSPC: number;
|
|
192
|
+
const ENOSYS: number;
|
|
193
|
+
const EBUSY: number;
|
|
194
|
+
const ENOENT: number;
|
|
195
|
+
const EPERM: number;
|
|
196
|
+
const EPIPE: number;
|
|
197
|
+
const EBADF: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Parse `str` using a superset of `JSON.parse`. The superset is very close to the JSON5 specification.
|
|
202
|
+
* Extensions: comments, unquoted properties, trailing comma, single quoted strings, hex/octal/binary integers, NaN, Infinity, etc.
|
|
203
|
+
*/
|
|
204
|
+
function parseExtJSON(str: string): unknown;
|
|
205
|
+
function __printObject(val: unknown): void;
|
|
206
|
+
/** Return a string that describes the error `errno`. */
|
|
207
|
+
function strerror(errno: number): string;
|
|
208
|
+
/** Manually invoke the cycle removal algorithm. The cycle removal algorithm is automatically started when needed, so this function is useful in case of specific memory constraints or for testing. */
|
|
209
|
+
function gc(): void;
|
|
210
|
+
/** Return the value of the environment variable `name` or `undefined` if it is not defined. */
|
|
211
|
+
function getenv(name: string): string | undefined;
|
|
212
|
+
/** Set the value of the environment variable `name` to the string `value`. */
|
|
213
|
+
function setenv(name: string, value: string): void;
|
|
214
|
+
/** Delete the environment variable `name`. */
|
|
215
|
+
function unsetenv(name: string): void;
|
|
216
|
+
/** Return an object containing the environment variables as key-value pairs. */
|
|
217
|
+
function getenviron(): Record<string, string>;
|
|
218
|
+
/** Download `url` using the curl command line utility. */
|
|
219
|
+
function urlGet(url: string, options?: UrlGetOptions): string | ArrayBuffer | UrlGetFullResult | null;
|
|
220
|
+
|
|
221
|
+
/** Constants for seek(). */
|
|
222
|
+
const SEEK_SET: number;
|
|
223
|
+
const SEEK_CUR: number;
|
|
224
|
+
const SEEK_END: number;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Wrappers to the libc file `stdin`. */
|
|
228
|
+
declare module "std" {
|
|
229
|
+
const _in: FILE;
|
|
230
|
+
export { _in as in };
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare module "os" {
|
|
234
|
+
type Fd = number & { readonly __brand: unique symbol };
|
|
235
|
+
|
|
236
|
+
interface StatResult {
|
|
237
|
+
dev: number;
|
|
238
|
+
ino: number;
|
|
239
|
+
mode: number;
|
|
240
|
+
nlink: number;
|
|
241
|
+
uid: number;
|
|
242
|
+
gid: number;
|
|
243
|
+
rdev: number;
|
|
244
|
+
size: number;
|
|
245
|
+
blocks: number;
|
|
246
|
+
atime: number;
|
|
247
|
+
mtime: number;
|
|
248
|
+
ctime: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Open a file. Return a handle or < 0 if error. */
|
|
252
|
+
function open(filename: string, flags: number, mode?: number): Fd | null;
|
|
253
|
+
/** Close the file handle `fd`. */
|
|
254
|
+
function close(fd: Fd): number;
|
|
255
|
+
/** Seek in the file. Use `std.SEEK_*` for `whence`. `offset` is either a number or a bigint. If `offset` is a bigint, a bigint is returned too. */
|
|
256
|
+
function seek(fd: Fd, offset: number | bigint, whence: number): number | bigint;
|
|
257
|
+
/** Read `length` bytes from the file handle `fd` to the ArrayBuffer `buffer` at byte position `offset`. Return the number of read bytes or < 0 if error. */
|
|
258
|
+
function read(fd: Fd, buffer: ArrayBuffer, offset: number, length: number): number;
|
|
259
|
+
/** Write `length` bytes to the file handle `fd` from the ArrayBuffer `buffer` at byte position `offset`. Return the number of written bytes or < 0 if error. */
|
|
260
|
+
function write(fd: Fd, buffer: ArrayBuffer, offset: number, length: number): number;
|
|
261
|
+
/** Return `true` if `fd` is a TTY (terminal) handle. */
|
|
262
|
+
function isatty(fd: Fd): boolean;
|
|
263
|
+
/** Return the TTY size as `[width, height]` or `null` if not available. */
|
|
264
|
+
function ttyGetWinSize(fd: Fd): [number, number] | null;
|
|
265
|
+
/** Set the TTY in raw mode. */
|
|
266
|
+
function ttySetRaw(fd: Fd): void;
|
|
267
|
+
/** Remove a file. Return 0 if OK or `-errno`. */
|
|
268
|
+
function remove(filename: string): number;
|
|
269
|
+
/** Rename a file. Return 0 if OK or `-errno`. */
|
|
270
|
+
function rename(oldname: string, newname: string): number;
|
|
271
|
+
/** Return `[str, err]` where `str` is the canonicalized absolute pathname of `path` and `err` the error code. */
|
|
272
|
+
function realpath(path: string): [string, number];
|
|
273
|
+
/** Return `[str, err]` where `str` is the current working directory and `err` the error code. */
|
|
274
|
+
function getcwd(): [string, number];
|
|
275
|
+
/** Change the current directory. Return 0 if OK or `-errno`. */
|
|
276
|
+
function chdir(path: string): number;
|
|
277
|
+
/** Create a directory at `path`. Return 0 if OK or `-errno`. */
|
|
278
|
+
function mkdir(path: string, mode?: number): number;
|
|
279
|
+
/** Return `[obj, err]` where `obj` is an object containing the file status of `path`. `err` is the error code. */
|
|
280
|
+
function stat(path: string): [StatResult, number];
|
|
281
|
+
/** Change the access and modification times of the file `path`. The times are specified in milliseconds since 1970. Return 0 if OK or `-errno`. */
|
|
282
|
+
function utimes(path: string, atime: number, mtime: number): number;
|
|
283
|
+
/** Return `[array, err]` where `array` is an array of strings containing the filenames of the directory `path`. `err` is the error code. */
|
|
284
|
+
function readdir(path: string): [string[], number];
|
|
285
|
+
/** Add a read handler to the file handle `fd`. `func` is called each time there is data pending for `fd`. A single read handler per file handle is supported. Use `func = null` to remove the handler. */
|
|
286
|
+
function setReadHandler(fd: Fd, func: (() => void) | null): void;
|
|
287
|
+
/** Add a write handler to the file handle `fd`. `func` is called each time data can be written to `fd`. A single write handler per file handle is supported. Use `func = null` to remove the handler. */
|
|
288
|
+
function setWriteHandler(fd: Fd, func: (() => void) | null): void;
|
|
289
|
+
/** Call the function `func` when the signal `signal` happens. Only a single handler per signal number is supported. Use `null` to set the default handler or `undefined` to ignore the signal. Signal handlers can only be defined in the main thread. */
|
|
290
|
+
function signal(signal: number, func: (() => void) | null | undefined): void;
|
|
291
|
+
/** Sleep during `delay_ms` milliseconds. */
|
|
292
|
+
function sleep(delay_ms: number): void;
|
|
293
|
+
/** Asynchronouse sleep during `delay_ms` milliseconds. Returns a promise. */
|
|
294
|
+
function sleepAsync(delay_ms: number): Promise<void>;
|
|
295
|
+
/** Return a timestamp in milliseconds with more precision than `Date.now()`. */
|
|
296
|
+
function now(): number;
|
|
297
|
+
type TimerId = number & { readonly __brand: unique symbol };
|
|
298
|
+
/** Call the function `func` after `delay` ms. Return a handle to the timer. */
|
|
299
|
+
function setTimeout(func: () => void, delay: number): TimerId;
|
|
300
|
+
/** Cancel a timer. */
|
|
301
|
+
function clearTimeout(id: TimerId): void;
|
|
302
|
+
|
|
303
|
+
/** POSIX open flags. */
|
|
304
|
+
const O_RDONLY: number;
|
|
305
|
+
const O_WRONLY: number;
|
|
306
|
+
const O_RDWR: number;
|
|
307
|
+
const O_APPEND: number;
|
|
308
|
+
const O_CREAT: number;
|
|
309
|
+
const O_EXCL: number;
|
|
310
|
+
const O_TRUNC: number;
|
|
311
|
+
/** (Windows specific). Open the file in text mode. The default is binary mode. */
|
|
312
|
+
const O_BINARY: number;
|
|
313
|
+
/** (Windows specific). Open the file in text mode. The default is binary mode. */
|
|
314
|
+
const O_TEXT: number;
|
|
315
|
+
|
|
316
|
+
/** POSIX signal numbers. */
|
|
317
|
+
const SIGINT: number;
|
|
318
|
+
const SIGABRT: number;
|
|
319
|
+
const SIGFPE: number;
|
|
320
|
+
const SIGILL: number;
|
|
321
|
+
const SIGSEGV: number;
|
|
322
|
+
const SIGTERM: number;
|
|
323
|
+
|
|
324
|
+
/** Constants to interpret the `mode` property returned by `stat()`. They have the same value as in the C system header `sys/stat.h`. */
|
|
325
|
+
const S_IFMT: number;
|
|
326
|
+
const S_IFIFO: number;
|
|
327
|
+
const S_IFCHR: number;
|
|
328
|
+
const S_IFDIR: number;
|
|
329
|
+
const S_IFBLK: number;
|
|
330
|
+
const S_IFREG: number;
|
|
331
|
+
|
|
332
|
+
class Worker {
|
|
333
|
+
/** Constructor to create a new thread (worker) with an API close to the `WebWorkers`. `module_filename` is a string specifying the module filename which is executed in the newly created thread. */
|
|
334
|
+
constructor(module_filename: string);
|
|
335
|
+
/** Send a message to the corresponding worker. `msg` is cloned in the destination worker using an algorithm similar to the `HTML` structured clone algorithm. */
|
|
336
|
+
postMessage(msg: unknown): void;
|
|
337
|
+
/** Getter and setter. Set a function which is called each time a message is received. The function is called with a single argument. It is an object with a `data` property containing the received message. */
|
|
338
|
+
onmessage: ((event: { data: unknown }) => void) | null;
|
|
339
|
+
/** In the created worker, `Worker.parent` represents the parent worker and is used to send or receive messages. */
|
|
340
|
+
static parent: Worker;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Return a string representing the platform: `"linux"`, `"darwin"`, `"win32"` or `"js"`. */
|
|
344
|
+
const platform: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
declare module "sock" {
|
|
348
|
+
type SockHandle = number & { readonly __brand: unique symbol };
|
|
349
|
+
type SockFd = number & { readonly __brand: unique symbol };
|
|
350
|
+
|
|
351
|
+
function socket(domain?: AddrFamily, type?: SockType, protocol?: Protocol): SockHandle;
|
|
352
|
+
function connect(sock: SockHandle, addr: string, port: number): number;
|
|
353
|
+
/** bind(sock, addr, port) — addr 可为 "0.0.0.0"/"127.0.0.1"/"::"/"::1" 或 null(任意地址);失败返回 -1 */
|
|
354
|
+
function bind(sock: SockHandle, addr: string | null, port: number): number;
|
|
355
|
+
/** listen(sock, backlog?) — 成功后该 socket 转为监听模式,on_event 会收到 FD_ACCEPT */
|
|
356
|
+
function listen(sock: SockHandle, backlog?: number): number;
|
|
357
|
+
/** accept(sock) — 接受一个连接,返回 { handle, addr, port },无可接受连接时返回 null */
|
|
358
|
+
function accept(sock: SockHandle): { handle: SockHandle; addr: string; port: number } | null;
|
|
359
|
+
/** getsockname(sock) — 返回本地绑定地址 { addr, port }(port=0 自动分配后可用它查询实际端口) */
|
|
360
|
+
function getsockname(sock: SockHandle): { addr: string; port: number } | null;
|
|
361
|
+
function send(sock: SockHandle, buf: ArrayBuffer, flags?: number): number;
|
|
362
|
+
function recv(sock: SockHandle, size?: number, flags?: number): ArrayBuffer | null;
|
|
363
|
+
function closesocket(sock: SockHandle): void;
|
|
364
|
+
function shutdown(sock: SockHandle, how: Shutdown): number;
|
|
365
|
+
function set_on_event(sock: SockHandle, callback: (events: { lNetworkEvents: number; iErrorCode: number[] }) => void): void;
|
|
366
|
+
function get_fd(sock: SockHandle): SockFd;
|
|
367
|
+
function resolve(hostname: string): string | null;
|
|
368
|
+
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
declare module "wolfssl" {
|
|
372
|
+
type WOLFSSL = number & { readonly __brand: unique symbol };
|
|
373
|
+
type WOLFSSL_CTX = number & { readonly __brand: unique symbol };
|
|
374
|
+
type WOLFSSL_METHOD = number & { readonly __brand: unique symbol };
|
|
375
|
+
|
|
376
|
+
function wolfSSL_library_init(): number;
|
|
377
|
+
function wolfSSL_CTX_new(method: WOLFSSL_METHOD): WOLFSSL_CTX | null;
|
|
378
|
+
function wolfSSL_CTX_free(ctx: WOLFSSL_CTX): void;
|
|
379
|
+
function wolfSSL_CTX_set_verify(ctx: WOLFSSL_CTX, mode: VerifyMode): number;
|
|
380
|
+
function wolfSSL_CTX_use_certificate_file(ctx: WOLFSSL_CTX, file: string, format?: FileType): number;
|
|
381
|
+
function wolfSSL_CTX_use_PrivateKey_file(ctx: WOLFSSL_CTX, file: string, format?: FileType): number;
|
|
382
|
+
|
|
383
|
+
function wolfSSL_new(ctx: WOLFSSL_CTX): WOLFSSL | null;
|
|
384
|
+
function wolfSSL_free(ssl: WOLFSSL): void;
|
|
385
|
+
function wolfSSL_set_fd(ssl: WOLFSSL, fd: import("sock").SockFd): number;
|
|
386
|
+
function wolfSSL_connect(ssl: WOLFSSL): number;
|
|
387
|
+
function wolfSSL_shutdown(ssl: WOLFSSL): number;
|
|
388
|
+
function wolfSSL_write(ssl: WOLFSSL, buf: ArrayBuffer): number;
|
|
389
|
+
function wolfSSL_read(ssl: WOLFSSL, sz: number): ArrayBuffer | null;
|
|
390
|
+
function wolfSSL_get_error(ssl: WOLFSSL, ret: number): number;
|
|
391
|
+
function wolfSSL_UseSNI(ssl: WOLFSSL, type: SniType, name: string, len?: number): number;
|
|
392
|
+
|
|
393
|
+
function wolfSSLv23_client_method(): WOLFSSL_METHOD;
|
|
394
|
+
function wolfTLSv1_2_client_method(): WOLFSSL_METHOD;
|
|
395
|
+
function wolfTLSv1_3_client_method(): WOLFSSL_METHOD;
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
declare module "win" {
|
|
400
|
+
type HMODULE = number & { readonly __label: unique symbol };
|
|
401
|
+
|
|
402
|
+
function LoadLibrary(libName: string): HMODULE | null;
|
|
403
|
+
function GetProcAddress(hModule: HMODULE, procName: string): number | null;
|
|
404
|
+
function FreeLibrary(hModule: HMODULE): boolean;
|
|
405
|
+
/** GetModuleFileName(hModule?) — 传 HMODULE 或不传(当前进程),返回模块完整路径;失败返回 undefined */
|
|
406
|
+
function GetModuleFileName(hModule?: HMODULE): string | undefined;
|
|
407
|
+
/** GetModuleHandle(moduleName?) — 不传返回当前 exe 的模块句柄;失败返回 null */
|
|
408
|
+
function GetModuleHandle(moduleName?: string): HMODULE | null;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare module "gui" {
|
|
412
|
+
type HWND = number & { readonly __label: unique symbol };
|
|
413
|
+
type HMENU = number & { readonly __label: unique symbol };
|
|
414
|
+
type HFONT = number & { readonly __label: unique symbol };
|
|
415
|
+
type HICON = number & { readonly __label: unique symbol };
|
|
416
|
+
type WNDPROC = number & { readonly __label: unique symbol };
|
|
417
|
+
|
|
418
|
+
function RegisterClass(className: string, wndProc?: (hwnd: HWND, msg: number, wParam: number, lParam: number) => number): number;
|
|
419
|
+
function CreateWindow(className: string, title: string, style: number, x: number, y: number, width: number, height: number, parent: HWND | null, menu: HMENU | null): HWND | null;
|
|
420
|
+
// 销毁窗口及其所有子窗口,自动清理 WNDPROC 和 JS 引用
|
|
421
|
+
function DestroyWindow(hwnd: HWND): boolean;
|
|
422
|
+
function GetWindow(hwnd: HWND, cmd: GetWindowCmd): HWND;
|
|
423
|
+
|
|
424
|
+
function ShowWindow(hwnd: HWND, nCmdShow?: ShowWindowCmd): void;
|
|
425
|
+
function SetWindowProc(hwnd: HWND, wndProc: (hwnd: HWND, msg: number, wParam: number, lParam: number) => number): void;
|
|
426
|
+
function DefWindowProc(hwnd: HWND, msg: number, wParam: number, lParam: number): number;
|
|
427
|
+
function PostQuitMessage(exitCode: number): void;
|
|
428
|
+
function SendMessage(hwnd: HWND, msg: number, wParam: number, lParam: number | string): number;
|
|
429
|
+
function MessageBox(message: string): void;
|
|
430
|
+
function SetWindowText(hwnd: HWND, text: string): void;
|
|
431
|
+
function GetWindowText(hwnd: HWND): string;
|
|
432
|
+
function GetScaleFactor(): number;
|
|
433
|
+
function CreateSystemDpiFont(): HFONT | null;
|
|
434
|
+
type GwlpReturnType<T extends Gwlp> = T extends Gwlp.WNDPROC ? WNDPROC : number;
|
|
435
|
+
function GetWindowLongPtr<T extends Gwlp>(hwnd: HWND, nIndex: T): GwlpReturnType<T>;
|
|
436
|
+
function SetWindowLongPtr(hwnd: HWND, nIndex: Gwlp, newLong: number): number;
|
|
437
|
+
function UnsetWindowProc(hwnd: HWND): boolean;
|
|
438
|
+
function CallWindowProc(wndProc: WNDPROC, hwnd: HWND, msg: number, wParam: number, lParam: number): number;
|
|
439
|
+
function SetParent(hwnd: HWND, parent: HWND | null): void;
|
|
440
|
+
function EnableWindow(hwnd: HWND, enable: boolean): void;
|
|
441
|
+
function SetWindowPos(hwnd: HWND, insertAfter: SetWindowPosHwnd, x: number, y: number, width: number, height: number, flags: number): void;
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
interface NotifyIconData {
|
|
446
|
+
hwnd: HWND
|
|
447
|
+
uID?: number
|
|
448
|
+
flags?: number
|
|
449
|
+
callbackMessage?: number
|
|
450
|
+
hIcon?: HICON
|
|
451
|
+
tip?: string
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function ShellNotifyIcon(cmd: NotifyIconCmd, nid: NotifyIconData): boolean;
|
|
455
|
+
/**
|
|
456
|
+
* Thin wrapper around LoadImageW. Parameter order matches Win32 LoadImageW: (hinst, name, uType?, cx?, cy?, fuLoad?).
|
|
457
|
+
* hinst: null for system resources/file path, number for module handle;
|
|
458
|
+
* name: when hinst=null, a system icon IDI or .ico file path; when hinst=module handle, a resource ID (number) or resource name (string);
|
|
459
|
+
* uType: gui.ImageType constant, default IMAGE_ICON (returns HICON), pass BITMAP/CURSOR for number return;
|
|
460
|
+
* cx/cy: target size (0 for default, use gui.LoadImageFlag.DEFAULTSIZE for system default size);
|
|
461
|
+
* fuLoad: gui.LoadImageFlag constants. Note: loading system icons (IDI_*, hinst=null) requires gui.LoadImageFlag.SHARED.
|
|
462
|
+
* Example: gui.LoadImage(null, "app.ico", gui.ImageType.ICON, 32, 32, gui.LoadImageFlag.LOADFROMFILE)
|
|
463
|
+
* gui.LoadImage(null, gui.IDI.APPLICATION, gui.ImageType.ICON, 0, 0, gui.LoadImageFlag.SHARED)
|
|
464
|
+
*/
|
|
465
|
+
function LoadImage<H extends (import("win").HMODULE) | null, T extends ImageType = ImageType.ICON>(
|
|
466
|
+
hinst: H,
|
|
467
|
+
name: H extends null ? string | IDI : string | number,
|
|
468
|
+
uType?: T,
|
|
469
|
+
cx?: number,
|
|
470
|
+
cy?: number,
|
|
471
|
+
fuLoad?: number
|
|
472
|
+
): T extends ImageType.ICON ? HICON | null : number | null;
|
|
473
|
+
/**
|
|
474
|
+
* Loads the first icon group (RT_GROUP_ICON) from this exe, i.e. the custom icon
|
|
475
|
+
* embedded by rcedit. Works with any resource ID including 0. Returns null if the
|
|
476
|
+
* exe has no icon resource.
|
|
477
|
+
* cx/cy: target size in pixels (0 for the natural size).
|
|
478
|
+
* Example: gui.LoadAppIcon() → HICON of the exe's icon.
|
|
479
|
+
*/
|
|
480
|
+
function LoadAppIcon(cx?: number, cy?: number): HICON | null;
|
|
481
|
+
/** 从 BGRA 像素数据创建 32bpp top-down DIB,data 为 length >= width*height*4 的 ArrayBuffer,返回 HBITMAP */
|
|
482
|
+
function CreateBitmapFromPixels(width: number, height: number, data: ArrayBuffer): number | null;
|
|
483
|
+
function DeleteObject(hObject: number): boolean;
|
|
484
|
+
function ImageListCreate(cx: number, cy: number, flags?: number, initial?: number, grow?: number): number | null;
|
|
485
|
+
function ImageListAdd(himl: number, hBitmap: number): number;
|
|
486
|
+
function ImageListDestroy(himl: number): boolean;
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
function CreatePopupMenu(): HMENU | null;
|
|
490
|
+
function AppendMenu(menu: HMENU, flags: number, id: number, text: string): boolean;
|
|
491
|
+
function TrackPopupMenu(menu: HMENU, x: number, y: number, flags?: number, hwnd?: HWND): number;
|
|
492
|
+
function DestroyMenu(menu: HMENU): boolean;
|
|
493
|
+
function SetForegroundWindow(hwnd: HWND): boolean;
|
|
494
|
+
/** Returns [x, y] or null */
|
|
495
|
+
function GetCursorPos(): [number, number] | null;
|
|
496
|
+
/** Returns [width, height] of the primary monitor */
|
|
497
|
+
function GetScreenSize(): [number, number];
|
|
498
|
+
/** Client-area/mouse rect: { left, top, right, bottom } */
|
|
499
|
+
type RECT = { left: number; top: number; right: number; bottom: number };
|
|
500
|
+
/** Returns { left, top, right, bottom } of client area, or null if invalid */
|
|
501
|
+
function GetClientRect(hwnd: HWND): RECT | null;
|
|
502
|
+
|
|
503
|
+
function GetWindowRect(hwnd: HWND): RECT | null;
|
|
504
|
+
/** Invalidates client area (rect can be null/undefined for full window) */
|
|
505
|
+
function InvalidateRect(hwnd: HWND, rect?: RECT | null, erase?: boolean): void;
|
|
506
|
+
/** Forces immediate repaint of invalidated area */
|
|
507
|
+
function UpdateWindow(hwnd: HWND): void;
|
|
508
|
+
/** Checks if the window handle is valid */
|
|
509
|
+
function IsWindow(hwnd: HWND): boolean;
|
|
510
|
+
/** Sets scroll info; returns current scroll box position. Signature matches Win32 SetScrollInfo. */
|
|
511
|
+
function SetScrollInfo(hwnd: HWND, bar: ScrollBar, info: { pos?: number; page?: number; min?: number; max?: number }, redraw?: boolean): number;
|
|
512
|
+
|
|
513
|
+
/** Gets scroll info. Signature matches Win32 GetScrollInfo. */
|
|
514
|
+
function GetScrollInfo(hwnd: HWND, bar: ScrollBar): { pos: number; page: number; min: number; max: number; trackPos: number };
|
|
515
|
+
|
|
516
|
+
/** Shows or hides a scroll bar. Signature matches Win32 ShowScrollBar. */
|
|
517
|
+
function ShowScrollBar(hwnd: HWND, bar: ScrollBar, show: boolean): boolean;
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
declare module "ffi" {
|
|
547
|
+
type TYPE_OF_FFI_TYPE_VOID = number & { readonly __label: unique symbol }
|
|
548
|
+
type TYPE_OF_FFI_TYPE_UINT8 = number & { readonly __label: unique symbol }
|
|
549
|
+
type TYPE_OF_FFI_TYPE_SINT8 = number & { readonly __label: unique symbol }
|
|
550
|
+
type TYPE_OF_FFI_TYPE_UINT16 = number & { readonly __label: unique symbol }
|
|
551
|
+
type TYPE_OF_FFI_TYPE_SINT16 = number & { readonly __label: unique symbol }
|
|
552
|
+
type TYPE_OF_FFI_TYPE_UINT32 = number & { readonly __label: unique symbol }
|
|
553
|
+
type TYPE_OF_FFI_TYPE_SINT32 = number & { readonly __label: unique symbol }
|
|
554
|
+
type TYPE_OF_FFI_TYPE_UINT64 = number & { readonly __label: unique symbol }
|
|
555
|
+
type TYPE_OF_FFI_TYPE_SINT64 = number & { readonly __label: unique symbol }
|
|
556
|
+
type TYPE_OF_FFI_TYPE_POINTER = number & { readonly __label: unique symbol }
|
|
557
|
+
|
|
558
|
+
const FFI_TYPE_VOID: TYPE_OF_FFI_TYPE_VOID;
|
|
559
|
+
const FFI_TYPE_UINT8: TYPE_OF_FFI_TYPE_UINT8;
|
|
560
|
+
const FFI_TYPE_SINT8: TYPE_OF_FFI_TYPE_SINT8;
|
|
561
|
+
const FFI_TYPE_UINT16: TYPE_OF_FFI_TYPE_UINT16;
|
|
562
|
+
const FFI_TYPE_SINT16: TYPE_OF_FFI_TYPE_SINT16;
|
|
563
|
+
const FFI_TYPE_UINT32: TYPE_OF_FFI_TYPE_UINT32;
|
|
564
|
+
const FFI_TYPE_SINT32: TYPE_OF_FFI_TYPE_SINT32;
|
|
565
|
+
const FFI_TYPE_UINT64: TYPE_OF_FFI_TYPE_UINT64;
|
|
566
|
+
const FFI_TYPE_SINT64: TYPE_OF_FFI_TYPE_SINT64;
|
|
567
|
+
const FFI_TYPE_POINTER: TYPE_OF_FFI_TYPE_POINTER;
|
|
568
|
+
|
|
569
|
+
type FfiType = TYPE_OF_FFI_TYPE_VOID | TYPE_OF_FFI_TYPE_UINT8 | TYPE_OF_FFI_TYPE_SINT8 | TYPE_OF_FFI_TYPE_UINT16 | TYPE_OF_FFI_TYPE_SINT16 | TYPE_OF_FFI_TYPE_UINT32 | TYPE_OF_FFI_TYPE_SINT32 | TYPE_OF_FFI_TYPE_UINT64 | TYPE_OF_FFI_TYPE_SINT64 | TYPE_OF_FFI_TYPE_POINTER;
|
|
570
|
+
type TypeArg<T extends FfiType> = T extends Exclude<FfiType, TYPE_OF_FFI_TYPE_VOID | TYPE_OF_FFI_TYPE_POINTER> ? number : T extends TYPE_OF_FFI_TYPE_POINTER ? (ArrayBuffer | null) : never;
|
|
571
|
+
type TypeArgs<T extends FfiType[], Args extends(number | null | ArrayBuffer)[] = []> = T extends [infer T1 extends FfiType, ...infer RES extends FfiType[]] ? TypeArgs<RES, [...Args, TypeArg<T1>]> : Args;
|
|
572
|
+
|
|
573
|
+
function ffiCall<const T extends Exclude<FfiType, TYPE_OF_FFI_TYPE_VOID>[], const R extends FfiType>(func: number, argTypes: T, args: TypeArgs<T>, retType: R): R extends TYPE_OF_FFI_TYPE_VOID ? undefined : R extends TYPE_OF_FFI_TYPE_POINTER ? number | null : TypeArg<R>;
|
|
574
|
+
function bufferPtr(buf: ArrayBuffer): number;
|
|
575
|
+
function readByte(ptr: number): number;
|
|
576
|
+
function writeByte(ptr: number, value: number): void;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
interface HttpCache {
|
|
582
|
+
readMeta(url: string): string | null;
|
|
583
|
+
readBody(url: string): ArrayBuffer | null;
|
|
584
|
+
writeBodyOnly(url: string, body: string | ArrayBuffer): void;
|
|
585
|
+
writeMeta(url: string, ini: string): void;
|
|
586
|
+
cacheKey(url: string): string;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
declare var __httpCache__: HttpCache;
|
|
590
|
+
|
|
591
|
+
declare module "brotli" {
|
|
592
|
+
function decompress(data: ArrayBufferLike): ArrayBuffer;
|
|
593
|
+
}
|
|
594
|
+
|