@ccheever/exact-ibex-runtime 0.1.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/package.json +63 -0
- package/src/abort/AbortController.ts +23 -0
- package/src/abort/AbortSignal.ts +152 -0
- package/src/abort/index.ts +2 -0
- package/src/accessibility.ts +12 -0
- package/src/arraybuffer-detach.ts +109 -0
- package/src/base64/base64.ts +168 -0
- package/src/base64/index.ts +1 -0
- package/src/blob/Blob.ts +259 -0
- package/src/blob/File.ts +59 -0
- package/src/blob/FormData.ts +323 -0
- package/src/blob/index.ts +3 -0
- package/src/bootstrap.ts +1946 -0
- package/src/broadcast/BroadcastChannel.ts +280 -0
- package/src/broadcast/index.ts +5 -0
- package/src/cache/Cache.ts +349 -0
- package/src/cache/CacheStorage.ts +89 -0
- package/src/cache/index.ts +27 -0
- package/src/camera/index.ts +6202 -0
- package/src/camera/processor.worker.ts +194 -0
- package/src/camera/scene.ts +195 -0
- package/src/clipboard/Clipboard.ts +129 -0
- package/src/clipboard/ClipboardItem.ts +97 -0
- package/src/clipboard/index.ts +6 -0
- package/src/clone/index.ts +1 -0
- package/src/clone/structuredClone.ts +389 -0
- package/src/clone/transferableSymbols.ts +2 -0
- package/src/compression/CompressionStream.ts +146 -0
- package/src/compression/DecompressionStream.ts +342 -0
- package/src/compression/index.ts +4 -0
- package/src/console/Console.ts +341 -0
- package/src/console/index.ts +2 -0
- package/src/core/accessibility-state.ts +263 -0
- package/src/core/accessibility.ts +184 -0
- package/src/core/agent-state.ts +37 -0
- package/src/core/diagnostics-logs.ts +144 -0
- package/src/core/host-call-bridge.ts +16 -0
- package/src/core/i18n-helpers.ts +189 -0
- package/src/core/locale-state.ts +253 -0
- package/src/core/locale.ts +95 -0
- package/src/crypto/Crypto.ts +2743 -0
- package/src/crypto/index.ts +1 -0
- package/src/diagnostics/logs.ts +7 -0
- package/src/encoding/TextDecoder.ts +1181 -0
- package/src/encoding/TextDecoderStream.ts +58 -0
- package/src/encoding/TextEncoder.ts +180 -0
- package/src/encoding/TextEncoderStream.ts +39 -0
- package/src/encoding/index.ts +8 -0
- package/src/events/CloseEvent.ts +91 -0
- package/src/events/DOMException.ts +409 -0
- package/src/events/ErrorEvent.ts +39 -0
- package/src/events/Event.ts +151 -0
- package/src/events/EventTarget.ts +280 -0
- package/src/events/FocusEvent.ts +27 -0
- package/src/events/KeyboardEvent.ts +46 -0
- package/src/events/MessageEvent.ts +61 -0
- package/src/events/ProgressEvent.ts +33 -0
- package/src/events/PromiseRejectionEvent.ts +31 -0
- package/src/events/index.ts +52 -0
- package/src/eventsource/EventSource.ts +371 -0
- package/src/eventsource/index.ts +2 -0
- package/src/fetch/Headers.ts +642 -0
- package/src/fetch/Request.ts +760 -0
- package/src/fetch/Response.ts +543 -0
- package/src/fetch/body.ts +1256 -0
- package/src/fetch/cookie-jar.ts +566 -0
- package/src/fetch/demo.ts +207 -0
- package/src/fetch/errors.ts +101 -0
- package/src/fetch/fetch.ts +2610 -0
- package/src/fetch/index.ts +101 -0
- package/src/fetch/native-bridge.ts +65 -0
- package/src/fetch/types.ts +258 -0
- package/src/filereader/FileReader.ts +236 -0
- package/src/filereader/index.ts +1 -0
- package/src/fs/Dirent.ts +39 -0
- package/src/fs/ExactFile.ts +450 -0
- package/src/fs/Stats.ts +80 -0
- package/src/fs/index.ts +944 -0
- package/src/fs/promises.ts +386 -0
- package/src/fs/shared.ts +328 -0
- package/src/http-server/index.js +697 -0
- package/src/http-server/index.ts +27 -0
- package/src/identity.generated.ts +14 -0
- package/src/index.ts +283 -0
- package/src/indexeddb/IDBCursor.ts +188 -0
- package/src/indexeddb/IDBDatabase.ts +343 -0
- package/src/indexeddb/IDBFactory.ts +269 -0
- package/src/indexeddb/IDBIndex.ts +194 -0
- package/src/indexeddb/IDBKeyRange.ts +109 -0
- package/src/indexeddb/IDBObjectStore.ts +468 -0
- package/src/indexeddb/IDBRequest.ts +163 -0
- package/src/indexeddb/IDBTransaction.ts +207 -0
- package/src/indexeddb/index.ts +34 -0
- package/src/indexeddb/utils.ts +52 -0
- package/src/inspect/index.ts +1 -0
- package/src/inspect/inspect.ts +465 -0
- package/src/internal/detect.ts +104 -0
- package/src/locale.ts +10 -0
- package/src/location/index.ts +1059 -0
- package/src/locks/LockManager.ts +460 -0
- package/src/locks/index.ts +12 -0
- package/src/media/VideoFrame.ts +58 -0
- package/src/messaging/MessageChannel.ts +31 -0
- package/src/messaging/MessagePort.ts +180 -0
- package/src/messaging/index.ts +2 -0
- package/src/messaging.ts +247 -0
- package/src/native/NativeModules.ts +354 -0
- package/src/native/index.ts +1 -0
- package/src/navigator/Navigator.ts +351 -0
- package/src/navigator/index.ts +1 -0
- package/src/node/Buffer.ts +1786 -0
- package/src/node/index.ts +4 -0
- package/src/node/path.ts +495 -0
- package/src/node/process.ts +2528 -0
- package/src/performance/Performance.ts +532 -0
- package/src/performance/index.ts +21 -0
- package/src/polyfills/array.ts +236 -0
- package/src/polyfills/arraybuffer.ts +172 -0
- package/src/polyfills/groupby.ts +85 -0
- package/src/polyfills/index.ts +85 -0
- package/src/polyfills/intl.ts +1956 -0
- package/src/polyfills/iterator.ts +479 -0
- package/src/polyfills/promise.ts +37 -0
- package/src/polyfills/set.ts +245 -0
- package/src/polyfills/string.ts +85 -0
- package/src/polyfills/typedarray.ts +110 -0
- package/src/promise-rejection-tracking.ts +464 -0
- package/src/react-native/index.ts +388 -0
- package/src/runtime-entry.ts +55 -0
- package/src/scheduling/AnimationFrame.ts +105 -0
- package/src/scheduling/IdleCallback.ts +167 -0
- package/src/scheduling/index.ts +13 -0
- package/src/security/Capabilities.ts +1146 -0
- package/src/security/Permissions.ts +392 -0
- package/src/security/capability-bits.generated.ts +63 -0
- package/src/security/index.ts +16 -0
- package/src/sqlite/Database.ts +456 -0
- package/src/sqlite/Statement.ts +206 -0
- package/src/sqlite/constants.ts +79 -0
- package/src/sqlite/errors.ts +25 -0
- package/src/sqlite/index.ts +34 -0
- package/src/sqlite/module.js +438 -0
- package/src/storage/Storage.ts +291 -0
- package/src/storage/StorageManager.ts +91 -0
- package/src/storage/index.ts +3 -0
- package/src/stream-compat.ts +47 -0
- package/src/streams/ReadableStream.ts +4131 -0
- package/src/streams/TransformStream.ts +375 -0
- package/src/streams/WritableStream.ts +866 -0
- package/src/streams/index.ts +41 -0
- package/src/timers/Timers.ts +296 -0
- package/src/timers/index.ts +11 -0
- package/src/url/URL.ts +656 -0
- package/src/url/URLPattern.ts +850 -0
- package/src/url/URLSearchParams.ts +244 -0
- package/src/url/index.ts +9 -0
- package/src/websocket/WebSocket.ts +770 -0
- package/src/websocket/WebSocketError.ts +52 -0
- package/src/websocket/WebSocketStream.ts +628 -0
- package/src/websocket/index.ts +7 -0
- package/src/window/index.ts +872 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* TextDecoderStream - Web Standard TextDecoderStream Implementation
|
|
4
|
+
*
|
|
5
|
+
* @see https://encoding.spec.whatwg.org/#interface-textdecoderstream
|
|
6
|
+
*
|
|
7
|
+
* Wraps a TransformStream that decodes Uint8Array chunks into string chunks
|
|
8
|
+
* using TextDecoder in streaming mode.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { TransformStream } from '../streams/TransformStream';
|
|
12
|
+
import { TextDecoder } from './TextDecoder';
|
|
13
|
+
import type { TextDecoderOptions } from './TextDecoder';
|
|
14
|
+
|
|
15
|
+
export class TextDecoderStream {
|
|
16
|
+
readonly encoding: string;
|
|
17
|
+
readonly fatal: boolean;
|
|
18
|
+
readonly ignoreBOM: boolean;
|
|
19
|
+
readonly readable: ReadableStream<string>;
|
|
20
|
+
readonly writable: WritableStream<Uint8Array>;
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
private _transform: TransformStream<Uint8Array, string>;
|
|
24
|
+
|
|
25
|
+
constructor(label?: string, options?: TextDecoderOptions) {
|
|
26
|
+
// Create the underlying TextDecoder (validates the label/options)
|
|
27
|
+
const decoder = new TextDecoder(label, options);
|
|
28
|
+
|
|
29
|
+
this.encoding = decoder.encoding;
|
|
30
|
+
this.fatal = decoder.fatal;
|
|
31
|
+
this.ignoreBOM = decoder.ignoreBOM;
|
|
32
|
+
|
|
33
|
+
this._transform = new TransformStream<Uint8Array, string>({
|
|
34
|
+
transform(chunk: Uint8Array, controller) {
|
|
35
|
+
// Decode in streaming mode so incomplete multi-byte sequences
|
|
36
|
+
// are buffered until the next chunk arrives
|
|
37
|
+
const decoded = decoder.decode(chunk, { stream: true });
|
|
38
|
+
if (decoded.length > 0) {
|
|
39
|
+
controller.enqueue(decoded);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
flush(controller) {
|
|
43
|
+
// Final call without stream: true to flush any pending bytes
|
|
44
|
+
const final = decoder.decode(undefined, { stream: false });
|
|
45
|
+
if (final.length > 0) {
|
|
46
|
+
controller.enqueue(final);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.readable = this._transform.readable as unknown as ReadableStream<string>;
|
|
52
|
+
this.writable = this._transform.writable as unknown as WritableStream<Uint8Array>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get [Symbol.toStringTag](): string {
|
|
56
|
+
return 'TextDecoderStream';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextEncoder - Web Standard TextEncoder Implementation
|
|
3
|
+
*
|
|
4
|
+
* @see https://encoding.spec.whatwg.org/#textencoder
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getNativeModule } from '../native/NativeModules';
|
|
8
|
+
|
|
9
|
+
export interface TextEncoderEncodeIntoResult {
|
|
10
|
+
read: number;
|
|
11
|
+
written: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class TextEncoder {
|
|
15
|
+
readonly encoding: "utf-8" = "utf-8";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Encode a string to UTF-8 bytes
|
|
19
|
+
*
|
|
20
|
+
* @param input String to encode
|
|
21
|
+
* @returns Uint8Array of UTF-8 bytes
|
|
22
|
+
*/
|
|
23
|
+
encode(input?: string): Uint8Array {
|
|
24
|
+
if (input === undefined) {
|
|
25
|
+
return new Uint8Array(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const str = String(input);
|
|
29
|
+
|
|
30
|
+
// Try native encoding for better performance
|
|
31
|
+
const nativeEncoding = getNativeModule('encoding');
|
|
32
|
+
if (nativeEncoding) {
|
|
33
|
+
return nativeEncoding.encodeUTF8(str);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Fallback to JS implementation
|
|
37
|
+
const bytes: number[] = [];
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < str.length; i++) {
|
|
40
|
+
let codePoint = str.charCodeAt(i);
|
|
41
|
+
|
|
42
|
+
// Handle surrogate pairs
|
|
43
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff) {
|
|
44
|
+
const high = codePoint;
|
|
45
|
+
const low = str.charCodeAt(++i);
|
|
46
|
+
|
|
47
|
+
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
48
|
+
codePoint = (high - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
|
|
49
|
+
} else {
|
|
50
|
+
// Unpaired high surrogate - use replacement character
|
|
51
|
+
codePoint = 0xfffd;
|
|
52
|
+
i--;
|
|
53
|
+
}
|
|
54
|
+
} else if (codePoint >= 0xdc00 && codePoint <= 0xdfff) {
|
|
55
|
+
// Unpaired low surrogate - use replacement character
|
|
56
|
+
codePoint = 0xfffd;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Encode code point to UTF-8
|
|
60
|
+
if (codePoint <= 0x7f) {
|
|
61
|
+
bytes.push(codePoint);
|
|
62
|
+
} else if (codePoint <= 0x7ff) {
|
|
63
|
+
bytes.push(0xc0 | (codePoint >> 6), 0x80 | (codePoint & 0x3f));
|
|
64
|
+
} else if (codePoint <= 0xffff) {
|
|
65
|
+
bytes.push(
|
|
66
|
+
0xe0 | (codePoint >> 12),
|
|
67
|
+
0x80 | ((codePoint >> 6) & 0x3f),
|
|
68
|
+
0x80 | (codePoint & 0x3f)
|
|
69
|
+
);
|
|
70
|
+
} else {
|
|
71
|
+
bytes.push(
|
|
72
|
+
0xf0 | (codePoint >> 18),
|
|
73
|
+
0x80 | ((codePoint >> 12) & 0x3f),
|
|
74
|
+
0x80 | ((codePoint >> 6) & 0x3f),
|
|
75
|
+
0x80 | (codePoint & 0x3f)
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return new Uint8Array(bytes);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Encode a string into an existing Uint8Array
|
|
85
|
+
*
|
|
86
|
+
* @param source String to encode
|
|
87
|
+
* @param destination Uint8Array to write into
|
|
88
|
+
* @returns Object with read (chars) and written (bytes) counts
|
|
89
|
+
*/
|
|
90
|
+
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult {
|
|
91
|
+
if (!(destination instanceof Uint8Array)) {
|
|
92
|
+
throw new TypeError("encodeInto requires a Uint8Array destination");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Handle detached ArrayBuffer
|
|
96
|
+
if (destination.buffer.byteLength === 0 && destination.byteLength === 0 && destination.length === 0) {
|
|
97
|
+
return { read: 0, written: 0 };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!source) {
|
|
101
|
+
return { read: 0, written: 0 };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let read = 0;
|
|
105
|
+
let written = 0;
|
|
106
|
+
|
|
107
|
+
for (let i = 0; i < source.length; i++) {
|
|
108
|
+
let codePoint = source.charCodeAt(i);
|
|
109
|
+
let bytesNeeded: number;
|
|
110
|
+
let isSurrogatePair = false;
|
|
111
|
+
|
|
112
|
+
// Handle surrogate pairs
|
|
113
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff) {
|
|
114
|
+
const high = codePoint;
|
|
115
|
+
const low = source.charCodeAt(i + 1);
|
|
116
|
+
|
|
117
|
+
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
118
|
+
codePoint = (high - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
|
|
119
|
+
isSurrogatePair = true;
|
|
120
|
+
} else {
|
|
121
|
+
codePoint = 0xfffd;
|
|
122
|
+
}
|
|
123
|
+
} else if (codePoint >= 0xdc00 && codePoint <= 0xdfff) {
|
|
124
|
+
codePoint = 0xfffd;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Calculate bytes needed
|
|
128
|
+
if (codePoint <= 0x7f) {
|
|
129
|
+
bytesNeeded = 1;
|
|
130
|
+
} else if (codePoint <= 0x7ff) {
|
|
131
|
+
bytesNeeded = 2;
|
|
132
|
+
} else if (codePoint <= 0xffff) {
|
|
133
|
+
bytesNeeded = 3;
|
|
134
|
+
} else {
|
|
135
|
+
bytesNeeded = 4;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Check if we have room
|
|
139
|
+
if (written + bytesNeeded > destination.length) {
|
|
140
|
+
// If a surrogate pair doesn't fit as 4 bytes, fall back to treating
|
|
141
|
+
// the high surrogate as unpaired (U+FFFD = 3 bytes)
|
|
142
|
+
if (isSurrogatePair && written + 3 <= destination.length) {
|
|
143
|
+
codePoint = 0xfffd;
|
|
144
|
+
bytesNeeded = 3;
|
|
145
|
+
isSurrogatePair = false;
|
|
146
|
+
} else {
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Write bytes
|
|
152
|
+
if (codePoint <= 0x7f) {
|
|
153
|
+
destination[written++] = codePoint;
|
|
154
|
+
} else if (codePoint <= 0x7ff) {
|
|
155
|
+
destination[written++] = 0xc0 | (codePoint >> 6);
|
|
156
|
+
destination[written++] = 0x80 | (codePoint & 0x3f);
|
|
157
|
+
} else if (codePoint <= 0xffff) {
|
|
158
|
+
destination[written++] = 0xe0 | (codePoint >> 12);
|
|
159
|
+
destination[written++] = 0x80 | ((codePoint >> 6) & 0x3f);
|
|
160
|
+
destination[written++] = 0x80 | (codePoint & 0x3f);
|
|
161
|
+
} else {
|
|
162
|
+
destination[written++] = 0xf0 | (codePoint >> 18);
|
|
163
|
+
destination[written++] = 0x80 | ((codePoint >> 12) & 0x3f);
|
|
164
|
+
destination[written++] = 0x80 | ((codePoint >> 6) & 0x3f);
|
|
165
|
+
destination[written++] = 0x80 | (codePoint & 0x3f);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Count characters read
|
|
169
|
+
if (isSurrogatePair) {
|
|
170
|
+
// Surrogate pair = 2 UTF-16 code units
|
|
171
|
+
read += 2;
|
|
172
|
+
i++; // Skip the low surrogate
|
|
173
|
+
} else {
|
|
174
|
+
read += 1;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return { read, written };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextEncoderStream - Web Standard TextEncoderStream Implementation
|
|
3
|
+
*
|
|
4
|
+
* @see https://encoding.spec.whatwg.org/#interface-textencoderstream
|
|
5
|
+
*
|
|
6
|
+
* Wraps a TransformStream that encodes string chunks into UTF-8 Uint8Array chunks.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { TransformStream } from '../streams/TransformStream';
|
|
10
|
+
import { TextEncoder } from './TextEncoder';
|
|
11
|
+
|
|
12
|
+
export class TextEncoderStream {
|
|
13
|
+
readonly encoding: "utf-8" = "utf-8";
|
|
14
|
+
readonly readable: ReadableStream<Uint8Array>;
|
|
15
|
+
readonly writable: WritableStream<string>;
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
private _transform: TransformStream<string, Uint8Array>;
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
const encoder = new TextEncoder();
|
|
22
|
+
|
|
23
|
+
this._transform = new TransformStream<string, Uint8Array>({
|
|
24
|
+
transform(chunk: string, controller) {
|
|
25
|
+
const encoded = encoder.encode(String(chunk));
|
|
26
|
+
if (encoded.length > 0) {
|
|
27
|
+
controller.enqueue(encoded);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
this.readable = this._transform.readable as unknown as ReadableStream<Uint8Array>;
|
|
33
|
+
this.writable = this._transform.writable as unknown as WritableStream<string>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get [Symbol.toStringTag](): string {
|
|
37
|
+
return 'TextEncoderStream';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { TextEncoder } from "./TextEncoder";
|
|
2
|
+
export type { TextEncoderEncodeIntoResult } from "./TextEncoder";
|
|
3
|
+
|
|
4
|
+
export { TextDecoder } from "./TextDecoder";
|
|
5
|
+
export type { TextDecoderOptions, TextDecodeOptions } from "./TextDecoder";
|
|
6
|
+
|
|
7
|
+
export { TextEncoderStream } from "./TextEncoderStream";
|
|
8
|
+
export { TextDecoderStream } from "./TextDecoderStream";
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloseEvent - Event for WebSocket close events
|
|
3
|
+
*
|
|
4
|
+
* @see https://html.spec.whatwg.org/multipage/web-sockets.html#closeevent
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Event, EventInit } from './Event';
|
|
8
|
+
|
|
9
|
+
export interface CloseEventInit extends EventInit {
|
|
10
|
+
wasClean?: boolean;
|
|
11
|
+
code?: number;
|
|
12
|
+
reason?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function assertCloseEventBrand(value: unknown): CloseEvent {
|
|
16
|
+
if (!(value instanceof CloseEvent)) {
|
|
17
|
+
throw new TypeError('Illegal invocation');
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CloseEvent extends Event {
|
|
23
|
+
_wasClean: boolean;
|
|
24
|
+
_code: number;
|
|
25
|
+
_reason: string;
|
|
26
|
+
|
|
27
|
+
constructor(type: string, eventInitDict?: CloseEventInit) {
|
|
28
|
+
super(type, eventInitDict);
|
|
29
|
+
this._wasClean = eventInitDict?.wasClean ?? false;
|
|
30
|
+
this._code = eventInitDict?.code ?? 0;
|
|
31
|
+
this._reason = eventInitDict?.reason ?? '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get wasClean(): boolean {
|
|
35
|
+
return assertCloseEventBrand(this)._wasClean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get code(): number {
|
|
39
|
+
return assertCloseEventBrand(this)._code;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get reason(): string {
|
|
43
|
+
return assertCloseEventBrand(this)._reason;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get [Symbol.toStringTag](): string {
|
|
47
|
+
return 'CloseEvent';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(CloseEvent, 'length', {
|
|
52
|
+
value: 1,
|
|
53
|
+
configurable: true,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
function nameAccessor(
|
|
57
|
+
descriptor: PropertyDescriptor | undefined,
|
|
58
|
+
propertyName: string
|
|
59
|
+
): PropertyDescriptor | undefined {
|
|
60
|
+
if (!descriptor) {
|
|
61
|
+
return descriptor;
|
|
62
|
+
}
|
|
63
|
+
if (typeof descriptor.get === 'function') {
|
|
64
|
+
Object.defineProperty(descriptor.get, 'name', {
|
|
65
|
+
value: `get ${propertyName}`,
|
|
66
|
+
configurable: true,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (typeof descriptor.set === 'function') {
|
|
70
|
+
Object.defineProperty(descriptor.set, 'name', {
|
|
71
|
+
value: `set ${propertyName}`,
|
|
72
|
+
configurable: true,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return descriptor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const wasCleanDescriptor = nameAccessor(Object.getOwnPropertyDescriptor(CloseEvent.prototype, 'wasClean'), 'wasClean')!;
|
|
79
|
+
const codeDescriptor = nameAccessor(Object.getOwnPropertyDescriptor(CloseEvent.prototype, 'code'), 'code')!;
|
|
80
|
+
const reasonDescriptor = nameAccessor(Object.getOwnPropertyDescriptor(CloseEvent.prototype, 'reason'), 'reason')!;
|
|
81
|
+
|
|
82
|
+
Object.defineProperties(CloseEvent.prototype, {
|
|
83
|
+
wasClean: { get: wasCleanDescriptor.get, enumerable: true, configurable: true },
|
|
84
|
+
code: { get: codeDescriptor.get, enumerable: true, configurable: true },
|
|
85
|
+
reason: { get: reasonDescriptor.get, enumerable: true, configurable: true },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
Object.setPrototypeOf(CloseEvent.prototype, Event.prototype);
|
|
89
|
+
Object.setPrototypeOf(CloseEvent, Event);
|
|
90
|
+
|
|
91
|
+
export default CloseEvent;
|