rsvim-types 0.1.3
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/.gitmodules +3 -0
- package/LICENSE.txt +78 -0
- package/README.md +75 -0
- package/package.json +22 -0
- package/runtime/00__web.ts +669 -0
- package/runtime/01__rsvim.ts +2003 -0
- package/tsconfig.json +40 -0
- package/types/00__web.d.ts +252 -0
- package/types/01__rsvim.d.ts +1335 -0
- package/types/index.d.ts +2 -0
package/tsconfig.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowUnreachableCode": false,
|
|
5
|
+
"allowUnusedLabels": false,
|
|
6
|
+
"checkJs": true,
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationDir": "./types/",
|
|
9
|
+
"isolatedModules": true,
|
|
10
|
+
"keyofStringsOnly": false,
|
|
11
|
+
"lib": ["esnext"],
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"noErrorTruncation": false,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"noImplicitReturns": false,
|
|
18
|
+
"noImplicitThis": true,
|
|
19
|
+
"noStrictGenericChecks": false,
|
|
20
|
+
"noUnusedLocals": false,
|
|
21
|
+
"noUnusedParameters": false,
|
|
22
|
+
"noUncheckedIndexedAccess": false,
|
|
23
|
+
"outDir": "./rsvim_core/src/js/runtime/",
|
|
24
|
+
"removeComments": false,
|
|
25
|
+
"rootDir": "./runtime/",
|
|
26
|
+
"strict": true,
|
|
27
|
+
"strictBindCallApply": true,
|
|
28
|
+
"strictFunctionTypes": true,
|
|
29
|
+
"strictPropertyInitialization": true,
|
|
30
|
+
"strictNullChecks": true,
|
|
31
|
+
"suppressExcessPropertyErrors": false,
|
|
32
|
+
"suppressImplicitAnyIndexErrors": false,
|
|
33
|
+
"target": "esnext",
|
|
34
|
+
"useUnknownInCatchVariables": false,
|
|
35
|
+
"useDefineForClassFields": true,
|
|
36
|
+
"verbatimModuleSyntax": true
|
|
37
|
+
},
|
|
38
|
+
"include": ["./runtime/*.ts"],
|
|
39
|
+
"exclude": ["./target/**/*.js"]
|
|
40
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* ---
|
|
4
|
+
* title: Web API
|
|
5
|
+
* sidebar_position: 3
|
|
6
|
+
* ---
|
|
7
|
+
*
|
|
8
|
+
* The [globalThis](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/globalThis) global object, compatible with [WinterTC](https://min-common-api.proposal.wintertc.org/) web platform APIs.
|
|
9
|
+
*
|
|
10
|
+
* @see [MDN - Web APIs](https://developer.mozilla.org/docs/Web/API).
|
|
11
|
+
*
|
|
12
|
+
* @packageDocumentation
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Encode string text into bytes, it only supports "utf-8" encoding.
|
|
16
|
+
*
|
|
17
|
+
* @see {@link !TextEncoder}
|
|
18
|
+
*/
|
|
19
|
+
export declare class TextEncoder {
|
|
20
|
+
/**
|
|
21
|
+
* @example
|
|
22
|
+
* ```javascript
|
|
23
|
+
* const encoder = new TextEncoder();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Encode string text to {@link !Uint8Array}.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```javascript
|
|
32
|
+
* const encodedBytes = new TextEncoder().encode("Hello, World!");
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param {string} input - Text that need encode.
|
|
36
|
+
* @returns {Uint8Array} Encoded uint8 bytes array.
|
|
37
|
+
* @throws Throws {@link !TypeError} if input is not a string.
|
|
38
|
+
*/
|
|
39
|
+
encode(input: string): Uint8Array;
|
|
40
|
+
/**
|
|
41
|
+
* Encode string text into {@link !Uint8Array}.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} src - Text that need encode.
|
|
44
|
+
* @param {Uint8Array} dest - Destination that receives the encoded uint8 bytes array.
|
|
45
|
+
* @returns {TextEncoder.EncodeIntoResult} Encode result, it contains two numbers: the "read" Unicode code units from src string, and the "written" UTF-8 bytes into the dest buffer.
|
|
46
|
+
* @throws Throws {@link !TypeError} if src is not a string, or dest is not a {@link !Uint8Array}.
|
|
47
|
+
*/
|
|
48
|
+
encodeInto(src: string, dest: Uint8Array): TextEncoder.EncodeIntoResult;
|
|
49
|
+
/**
|
|
50
|
+
* The encoding used by encoder, this always returns "utf-8".
|
|
51
|
+
*/
|
|
52
|
+
get encoding(): string;
|
|
53
|
+
}
|
|
54
|
+
export declare namespace TextEncoder {
|
|
55
|
+
/**
|
|
56
|
+
* @see {@link TextEncoder}
|
|
57
|
+
* @inline
|
|
58
|
+
*/
|
|
59
|
+
type EncodeIntoResult = {
|
|
60
|
+
read: number;
|
|
61
|
+
written: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Decode bytes array into string text.
|
|
66
|
+
*
|
|
67
|
+
* @see {@link !TextDecoder}
|
|
68
|
+
*/
|
|
69
|
+
export declare class TextDecoder {
|
|
70
|
+
#private;
|
|
71
|
+
/**
|
|
72
|
+
* Create a TextDecoder instance with specified encoding.
|
|
73
|
+
*
|
|
74
|
+
* Per the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/), the encodings supported by the TextDecoder API are outlined in the tables below. For each encoding, one or more aliases may be used.
|
|
75
|
+
*
|
|
76
|
+
* | Encoding | Aliases |
|
|
77
|
+
* |----------|---------|
|
|
78
|
+
* |'ibm866' | '866', 'cp866', 'csibm866' |
|
|
79
|
+
* |'iso-8859-2' | 'csisolatin2', 'iso-ir-101', 'iso8859-2', 'iso88592', 'iso_8859-2', 'iso_8859-2:1987', 'l2', 'latin2' |
|
|
80
|
+
* |'iso-8859-3' | 'csisolatin3', 'iso-ir-109', 'iso8859-3', 'iso88593', 'iso_8859-3', 'iso_8859-3:1988', 'l3', 'latin3' |
|
|
81
|
+
* | 'iso-8859-4' | 'csisolatin4', 'iso-ir-110', 'iso8859-4', 'iso88594', 'iso_8859-4', 'iso_8859-4:1988', 'l4', 'latin4' |
|
|
82
|
+
* | 'iso-8859-5' | 'csisolatincyrillic', 'cyrillic', 'iso-ir-144', 'iso8859-5', 'iso88595', 'iso_8859-5', 'iso_8859-5:1988' |
|
|
83
|
+
* | 'iso-8859-6' | 'arabic', 'asmo-708', 'csiso88596e', 'csiso88596i', 'csisolatinarabic', 'ecma-114', 'iso-8859-6-e', 'iso-8859-6-i', 'iso-ir-127', 'iso8859-6', 'iso88596', 'iso_8859-6', 'iso_8859-6:1987' |
|
|
84
|
+
* | 'iso-8859-7' | 'csisolatingreek', 'ecma-118', 'elot_928', 'greek', 'greek8', 'iso-ir-126', 'iso8859-7', 'iso88597', 'iso_8859-7', 'iso_8859-7:1987', 'sun_eu_greek' |
|
|
85
|
+
* | 'iso-8859-8' | 'csiso88598e', 'csisolatinhebrew', 'hebrew', 'iso-8859-8-e', 'iso-ir-138', 'iso8859-8', 'iso88598', 'iso_8859-8', 'iso_8859-8:1988', 'visual' |
|
|
86
|
+
* | 'iso-8859-8-i' | 'csiso88598i', 'logical' |
|
|
87
|
+
* | 'iso-8859-10' | 'csisolatin6', 'iso-ir-157', 'iso8859-10', 'iso885910', 'l6', 'latin6' |
|
|
88
|
+
* | 'iso-8859-13' | 'iso8859-13', 'iso885913' |
|
|
89
|
+
* | 'iso-8859-14' | 'iso8859-14', 'iso885914' |
|
|
90
|
+
* | 'iso-8859-15' | 'csisolatin9', 'iso8859-15', 'iso885915', 'iso_8859-15', 'l9' |
|
|
91
|
+
* | 'koi8-r' | 'cskoi8r', 'koi', 'koi8', 'koi8_r' |
|
|
92
|
+
* | 'koi8-u' | 'koi8-ru' |
|
|
93
|
+
* | 'macintosh' | 'csmacintosh', 'mac', 'x-mac-roman' |
|
|
94
|
+
* | 'windows-874' | 'dos-874', 'iso-8859-11', 'iso8859-11', 'iso885911', 'tis-620' |
|
|
95
|
+
* | 'windows-1250' | 'cp1250', 'x-cp1250' |
|
|
96
|
+
* | 'windows-1251' | 'cp1251', 'x-cp1251' |
|
|
97
|
+
* | 'windows-1252' | 'ansi_x3.4-1968', 'ascii', 'cp1252', 'cp819', 'csisolatin1', 'ibm819', 'iso-8859-1', 'iso-ir-100', 'iso8859-1', 'iso88591', 'iso_8859-1', 'iso_8859-1:1987', 'l1', 'latin1', 'us-ascii', 'x-cp1252' |
|
|
98
|
+
* | 'windows-1253' | 'cp1253', 'x-cp1253' |
|
|
99
|
+
* | 'windows-1254' | 'cp1254', 'csisolatin5', 'iso-8859-9', 'iso-ir-148', 'iso8859-9', 'iso88599', 'iso_8859-9', 'iso_8859-9:1989', 'l5', 'latin5', 'x-cp1254' |
|
|
100
|
+
* | 'windows-1255' | 'cp1255', 'x-cp1255' |
|
|
101
|
+
* | 'windows-1256' | 'cp1256', 'x-cp1256' |
|
|
102
|
+
* | 'windows-1257' | 'cp1257', 'x-cp1257' |
|
|
103
|
+
* | 'windows-1258' | 'cp1258', 'x-cp1258' |
|
|
104
|
+
* | 'x-mac-cyrillic' | 'x-mac-ukrainian' |
|
|
105
|
+
* | 'gbk' | 'chinese', 'csgb2312', 'csiso58gb231280', 'gb2312', 'gb_2312', 'gb_2312-80', 'iso-ir-58', 'x-gbk'
|
|
106
|
+
* | 'gb18030' | |
|
|
107
|
+
* | 'big5' | 'big5-hkscs', 'cn-big5', 'csbig5', 'x-x-big5' |
|
|
108
|
+
* | 'euc-jp' | 'cseucpkdfmtjapanese', 'x-euc-jp' |
|
|
109
|
+
* | 'iso-2022-jp' | 'csiso2022jp' |
|
|
110
|
+
* | 'shift_jis' | 'csshiftjis', 'ms932', 'ms_kanji', 'shift-jis', 'sjis', 'windows-31j', 'x-sjis' |
|
|
111
|
+
* | 'euc-kr' | 'cseuckr', 'csksc56011987', 'iso-ir-149', 'korean', 'ks_c_5601-1987', 'ks_c_5601-1989', 'ksc5601', 'ksc_5601', 'windows-949' |
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```javascript
|
|
115
|
+
* const bytes = new Uint8Array([
|
|
116
|
+
* 0xf0, 0x9d, 0x93, 0xbd,
|
|
117
|
+
* 0xf0, 0x9d, 0x93, 0xae,
|
|
118
|
+
* 0xf0, 0x9d, 0x94, 0x81,
|
|
119
|
+
* 0xf0, 0x9d, 0x93, 0xbd
|
|
120
|
+
* ]);
|
|
121
|
+
* if (new TextDecoder().decode(bytes) !== "𝓽𝓮𝔁𝓽") {
|
|
122
|
+
* Rsvim.cmd.echo("Failed to decode");
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @see [Node.js - WHATWG supported encodings](https://nodejs.org/api/util.html#whatwg-supported-encodings)
|
|
127
|
+
* @see [encoding_rs - Relationship with Windows Code Pages](https://docs.rs/encoding_rs/latest/encoding_rs/#relationship-with-windows-code-pages)
|
|
128
|
+
* @see [encoding_rs - Supported Encodings](https://docs.rs/encoding_rs/latest/encoding_rs/#statics)
|
|
129
|
+
*
|
|
130
|
+
* @param {string} encoding - (Optional) Decoder encoding, by default is "utf-8".
|
|
131
|
+
* @param {TextDecoder.Options} options - (Optional) Decode options, by default is `{fatal: false, ignoreBOM: false}`.
|
|
132
|
+
* @throws Throws {@link !TypeError} if encoding is not a string or options is invalid. Throw {@link !RangeError} if encoding is unknown or not support.
|
|
133
|
+
*/
|
|
134
|
+
constructor(encoding?: string, options?: TextDecoder.Options);
|
|
135
|
+
/**
|
|
136
|
+
* Decode a bytes array to string text. The bytes array can be a {@link !ArrayBuffer}, {@link !TypedArray} or {@link !DataView}.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```javascript
|
|
140
|
+
* // Single pass, non-stream
|
|
141
|
+
* const str1 = new TextDecoder().decode(new Uint8Array([1,2,3,4]));
|
|
142
|
+
*
|
|
143
|
+
* // Stream
|
|
144
|
+
* const decoder = new TextDecoder();
|
|
145
|
+
* let str2 = "";
|
|
146
|
+
* str2 += decoder.decode(new Uint8Array([1]), {stream: true});
|
|
147
|
+
* str2 += decoder.decode(new Uint8Array([2,3]), {stream: true});
|
|
148
|
+
* str2 += decoder.decode(new Uint8Array([4]), {stream: true});
|
|
149
|
+
* str2 += decoder.decode(undefined, {stream: false}); // Flush buffer and finish decoding.
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @see {@link !TextDecoder}
|
|
153
|
+
*
|
|
154
|
+
* @param {(ArrayBuffer | TypedArray | DataView)} input - (Optional) Bytes array, by default is `new Uint8Array()`.
|
|
155
|
+
* @param {TextDecoder.DecodeOptions} options - (Optional) Decode options, by default is `{stream: false}`. When decode a stream data (e.g. read from tcp network) while reading it and cannot determine the end of bytes, should set `stream` option to `true`.
|
|
156
|
+
* @returns {string} Decoded string text.
|
|
157
|
+
* @throws Throws {@link !TypeError} if input is not a Uint8Array, or options is invalid, or the data is malformed and `fatal` option is set.
|
|
158
|
+
*/
|
|
159
|
+
decode(input?: ArrayBuffer | TypedArray | DataView, options?: TextDecoder.DecodeOptions): string;
|
|
160
|
+
/**
|
|
161
|
+
* The encoding used by decoder.
|
|
162
|
+
*/
|
|
163
|
+
get encoding(): string;
|
|
164
|
+
/**
|
|
165
|
+
* Whether throw {@link !TypeError} when decoding error because the data is malformed.
|
|
166
|
+
*/
|
|
167
|
+
get fatal(): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Whether ignore unicode "Byte-Order-Mark" (BOM) when decoding the data.
|
|
170
|
+
*/
|
|
171
|
+
get ignoreBOM(): boolean;
|
|
172
|
+
}
|
|
173
|
+
export declare namespace TextDecoder {
|
|
174
|
+
/**
|
|
175
|
+
* @see {@link TextDecoder}
|
|
176
|
+
* @inline
|
|
177
|
+
*/
|
|
178
|
+
type Options = {
|
|
179
|
+
fatal?: boolean;
|
|
180
|
+
ignoreBOM?: boolean;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* @see {@link TextDecoder}
|
|
184
|
+
* @inline
|
|
185
|
+
*/
|
|
186
|
+
type DecodeOptions = {
|
|
187
|
+
stream?: boolean;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* {@link !TypedArray}
|
|
192
|
+
*/
|
|
193
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
194
|
+
/**
|
|
195
|
+
* Cancel a repeated timer previously established by calling {@link setInterval}.
|
|
196
|
+
*
|
|
197
|
+
* @param {number} id - The ID (integer) which identifies the schedule.
|
|
198
|
+
* @throws Throws {@link !TypeError} if ID is not an integer.
|
|
199
|
+
*/
|
|
200
|
+
export declare function clearInterval(id: number): void;
|
|
201
|
+
/**
|
|
202
|
+
* Set a repeated timer that calls a function, with a fixed time delay between each call.
|
|
203
|
+
*
|
|
204
|
+
* @param {function} callback - A function to be executed every `delay` milliseconds.
|
|
205
|
+
* @param {number} delay - (Optional) The milliseconds that the timer should delay in between execution of the function, by default is `1`.
|
|
206
|
+
* @param {...any} args - (Optional) Additional arguments which are passed through to the function.
|
|
207
|
+
* @returns {number} The ID (integer) which identifies the timer created.
|
|
208
|
+
* @throws Throws {@link !TypeError} if callback is not a function, or delay is neither a number or undefined.
|
|
209
|
+
*/
|
|
210
|
+
export declare function setInterval(callback: (...args: any[]) => void, delay?: number, ...args: any[]): number;
|
|
211
|
+
/**
|
|
212
|
+
* Cancel a timeout previously established by calling {@link setTimeout}.
|
|
213
|
+
*
|
|
214
|
+
* @param {number} id - The ID (integer) which identifies the timer.
|
|
215
|
+
* @throws Throws {@link !TypeError} if ID is not an integer.
|
|
216
|
+
*/
|
|
217
|
+
export declare function clearTimeout(id: number): void;
|
|
218
|
+
/**
|
|
219
|
+
* Set a timer which executes a function or specified piece of code once the timer expires.
|
|
220
|
+
*
|
|
221
|
+
* @param {function} callback - A function to be executed after the timer expires.
|
|
222
|
+
* @param {number} delay - (Optional) The milliseconds that the timer should wait before the function is executed, by default is `1`.
|
|
223
|
+
* @param {...any} args - (Optional) Additional arguments which are passed through to the function.
|
|
224
|
+
* @returns {number} The ID (integer) which identifies the timer created.
|
|
225
|
+
* @throws Throws {@link !TypeError} if callback is not a function, or delay is neither a number or undefined.
|
|
226
|
+
*/
|
|
227
|
+
export declare function setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): number;
|
|
228
|
+
/**
|
|
229
|
+
* A microtask is a short function which is executed after the function or module which created it exits and
|
|
230
|
+
* only if the JavaScript execution stack is empty, but before returning control to the event loop being used
|
|
231
|
+
* to drive the script's execution environment.
|
|
232
|
+
*
|
|
233
|
+
* @param {function} callback - A function to be executed.
|
|
234
|
+
* @throws Throws {@link !TypeError} if callback is not a function.
|
|
235
|
+
*/
|
|
236
|
+
export declare function queueMicrotask(callback: () => void): void;
|
|
237
|
+
/**
|
|
238
|
+
* Dispatch an uncaught exception. Similar to synchronous version of `setTimeout(() => {throw error;}, 0);`.
|
|
239
|
+
*
|
|
240
|
+
* @param {any} error - Anything to be thrown.
|
|
241
|
+
*/
|
|
242
|
+
export declare function reportError(error: any): void;
|
|
243
|
+
declare global {
|
|
244
|
+
var TextEncoder: typeof TextEncoder;
|
|
245
|
+
var TextDecoder: typeof TextDecoder;
|
|
246
|
+
function clearInterval(id: number): void;
|
|
247
|
+
function setInterval(callback: (...args: any[]) => void, delay?: number, ...args: any[]): number;
|
|
248
|
+
function clearTimeout(id: number): void;
|
|
249
|
+
function setTimeout(callback: (...args: any[]) => void, delay: number, ...args: any[]): number;
|
|
250
|
+
function queueMicrotask(callback: () => void): void;
|
|
251
|
+
function reportError(error: any): void;
|
|
252
|
+
}
|