quickwin 3.0.0 → 3.0.1

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.
Files changed (95) hide show
  1. package/lib/abort.d.ts +21 -0
  2. package/lib/assert.d.ts +2 -0
  3. package/lib/bitmap.d.ts +7 -0
  4. package/lib/cache-utils.d.ts +6 -0
  5. package/lib/certs.d.ts +1 -0
  6. package/lib/dpi.d.ts +9 -0
  7. package/lib/dumpRects.d.ts +2 -0
  8. package/lib/exec-log.d.ts +23 -0
  9. package/lib/fetch.d.ts +4 -0
  10. package/lib/ffi/bind.d.ts +70 -0
  11. package/lib/ffi/ctype.d.ts +117 -0
  12. package/lib/ffi/index.d.ts +2 -0
  13. package/lib/ffi/struct.d.ts +174 -0
  14. package/lib/http-common.d.ts +143 -0
  15. package/lib/http-server.d.ts +59 -0
  16. package/lib/polyfill.d.ts +22 -0
  17. package/lib/react-qw/components/Button.d.ts +9 -0
  18. package/lib/react-qw/components/CheckBox.d.ts +11 -0
  19. package/lib/react-qw/components/ComboBox.d.ts +11 -0
  20. package/lib/react-qw/components/DateTimePicker.d.ts +15 -0
  21. package/lib/react-qw/components/Input.d.ts +15 -0
  22. package/lib/react-qw/components/Link.d.ts +12 -0
  23. package/lib/react-qw/components/ListBox.d.ts +13 -0
  24. package/lib/react-qw/components/ListView.d.ts +37 -0
  25. package/lib/react-qw/components/PathPicker.d.ts +23 -0
  26. package/lib/react-qw/components/ProgressBar.d.ts +9 -0
  27. package/lib/react-qw/components/RadioButton.d.ts +11 -0
  28. package/lib/react-qw/components/ScrollView.d.ts +9 -0
  29. package/lib/react-qw/components/Slider.d.ts +12 -0
  30. package/lib/react-qw/components/Tab.d.ts +14 -0
  31. package/lib/react-qw/components/Tooltip.d.ts +7 -0
  32. package/lib/react-qw/components/TreeView.d.ts +18 -0
  33. package/lib/react-qw/components/index.d.ts +16 -0
  34. package/lib/react-qw/index.d.ts +24 -0
  35. package/lib/react-qw/layout.d.ts +29 -0
  36. package/lib/react-qw/nmhdr.d.ts +1 -0
  37. package/lib/react-qw/props.d.ts +2 -0
  38. package/lib/react-qw/reconciler.d.ts +21 -0
  39. package/lib/stream.d.ts +20 -0
  40. package/lib/text-codec.d.ts +39 -0
  41. package/lib/text-measure.d.ts +14 -0
  42. package/lib/url.d.ts +54 -0
  43. package/lib/websocket.d.ts +73 -0
  44. package/lib/windows/{advapi32.ts → advapi32.d.ts} +6 -21
  45. package/lib/windows/comctl32.d.ts +14 -0
  46. package/lib/windows/comdlg32.d.ts +4 -0
  47. package/lib/windows/{gdi32.ts → gdi32.d.ts} +161 -98
  48. package/lib/windows/{kernel32.ts → kernel32.d.ts} +138 -115
  49. package/lib/windows/{msimg32.ts → msimg32.d.ts} +11 -14
  50. package/lib/windows/ntdll.d.ts +5 -0
  51. package/lib/windows/ole32.d.ts +3 -0
  52. package/lib/windows/{psapi.ts → psapi.d.ts} +9 -18
  53. package/lib/windows/{shell32.ts → shell32.d.ts} +25 -24
  54. package/lib/windows/structs.d.ts +3141 -0
  55. package/lib/windows/{user32.ts → user32.d.ts} +196 -193
  56. package/lib/windows/version.d.ts +27 -0
  57. package/lib/windows/{winspool.ts → winspool.d.ts} +18 -32
  58. package/package.json +15 -6
  59. package/qwin-nowasm-x86.exe +0 -0
  60. package/qwin-nowasm.exe +0 -0
  61. package/qwin-x86.exe +0 -0
  62. package/qwin.exe +0 -0
  63. package/lib/abort.ts +0 -69
  64. package/lib/assert.ts +0 -7
  65. package/lib/bitmap.ts +0 -39
  66. package/lib/cache-utils.ts +0 -40
  67. package/lib/certs.ts +0 -258
  68. package/lib/dpi.ts +0 -31
  69. package/lib/dumpRects.ts +0 -34
  70. package/lib/exec-log.ts +0 -30
  71. package/lib/fetch.ts +0 -589
  72. package/lib/ffi/bind.ts +0 -540
  73. package/lib/ffi/ctype.ts +0 -371
  74. package/lib/ffi/index.ts +0 -6
  75. package/lib/ffi/struct.ts +0 -780
  76. package/lib/http-common.ts +0 -441
  77. package/lib/http-server.ts +0 -604
  78. package/lib/polyfill.ts +0 -171
  79. package/lib/react-qw/components/index.ts +0 -17
  80. package/lib/react-qw/index.ts +0 -96
  81. package/lib/react-qw/layout.ts +0 -111
  82. package/lib/react-qw/nmhdr.ts +0 -7
  83. package/lib/react-qw/props.ts +0 -41
  84. package/lib/react-qw/reconciler.ts +0 -379
  85. package/lib/stream.ts +0 -22
  86. package/lib/text-codec.ts +0 -171
  87. package/lib/text-measure.ts +0 -44
  88. package/lib/url.ts +0 -201
  89. package/lib/websocket.ts +0 -600
  90. package/lib/windows/comctl32.ts +0 -20
  91. package/lib/windows/comdlg32.ts +0 -10
  92. package/lib/windows/ntdll.ts +0 -11
  93. package/lib/windows/ole32.ts +0 -9
  94. package/lib/windows/structs.ts +0 -807
  95. package/lib/windows/version.ts +0 -35
@@ -1,441 +0,0 @@
1
- import './polyfill.js'
2
- import './stream.js'
3
-
4
- // ── Byte helpers ──
5
-
6
- export function _concat(parts: Uint8Array[]): Uint8Array<ArrayBuffer> {
7
- if (parts.length === 0) return new Uint8Array(0)
8
- let totalLen = 0
9
- for (const p of parts) totalLen += p.length
10
- const result = new Uint8Array(totalLen)
11
- let offset = 0
12
- for (const p of parts) { result.set(p, offset); offset += p.length }
13
- return result
14
- }
15
-
16
- export function _toReadableStream(body: BodyInit): ReadableStream<Uint8Array> {
17
- if (body instanceof ReadableStream) return body
18
- const bytes = (typeof body === 'string')
19
- ? new TextEncoder().encode(body)
20
- : (body instanceof ArrayBuffer)
21
- ? new Uint8Array(body)
22
- : new Uint8Array(body.buffer, body.byteOffset, body.byteLength)
23
- return new ReadableStream<Uint8Array>({
24
- start(ctrl) {
25
- ctrl.enqueue(bytes)
26
- ctrl.close()
27
- }
28
- })
29
- }
30
-
31
- export async function _readStream(stream: ReadableStream<Uint8Array>): Promise<Uint8Array<ArrayBuffer>> {
32
- const reader = stream.getReader()
33
- const chunks: Uint8Array[] = []
34
- while (true) {
35
- const { done, value } = await reader.read()
36
- if (done) break
37
- chunks.push(value)
38
- }
39
- return _concat(chunks)
40
- }
41
-
42
- export function _hasChunkedEnd(data: Uint8Array): boolean {
43
- if (data.length < 7) return false
44
- let i = data.length - 7
45
- return data[i] === 0x0D && data[i+1] === 0x0A && data[i+2] === 0x30 && data[i+3] === 0x0D && data[i+4] === 0x0A && data[i+5] === 0x0D && data[i+6] === 0x0A
46
- }
47
-
48
- export function decodeChunked(data: Uint8Array): Uint8Array {
49
- const chunks: Uint8Array[] = []
50
- let pos = 0
51
- while (pos < data.length) {
52
- let crlf = -1
53
- for (let i = pos; i < data.length - 1; i++) {
54
- if (data[i] === 0x0D && data[i + 1] === 0x0A) { crlf = i; break }
55
- }
56
- if (crlf < 0) break
57
-
58
- let size = 0
59
- for (let i = pos; i < crlf; i++) {
60
- const b = data[i]!
61
- if (b >= 0x30 && b <= 0x39) size = size * 16 + (b - 0x30)
62
- else if (b >= 0x41 && b <= 0x46) size = size * 16 + (b - 0x37)
63
- else if (b >= 0x61 && b <= 0x66) size = size * 16 + (b - 0x57)
64
- else break
65
- }
66
-
67
- const dataStart = crlf + 2
68
- if (size === 0) {
69
- for (let i = dataStart; i < data.length - 3; i++) {
70
- if (data[i] === 0x0D && data[i+1] === 0x0A && data[i+2] === 0x0D && data[i+3] === 0x0A) {
71
- pos = i + 4; break
72
- }
73
- }
74
- if (pos === dataStart) break
75
- break
76
- }
77
-
78
- if (dataStart + size > data.length) break
79
- chunks.push(data.subarray(dataStart, dataStart + size))
80
- pos = dataStart + size + 2
81
- }
82
- return _concat(chunks)
83
- }
84
-
85
- // ── Headers ──
86
-
87
- // Flat array storage: [name0, value0, name1, value1, ...]
88
- // Pairs at even/odd indices. Strings are immutable, so [...this._headers] is a correct deep copy.
89
-
90
- export class HeadersImpl {
91
- private _headers: string[] = []
92
-
93
- constructor(init?: HeadersInit) {
94
- if (init) {
95
- if (init instanceof HeadersImpl) {
96
- this._headers = [...init._headers]
97
- } else if (Array.isArray(init)) {
98
- this._headers = init.flatMap(([k, v]) => [k.toLowerCase(), v])
99
- } else if (typeof init === 'object') {
100
- this._headers = Object.entries(init).flatMap(([k, v]) => [k.toLowerCase(), v])
101
- }
102
- }
103
- }
104
-
105
- append(name: string, value: string): void {
106
- this._headers.push(name.toLowerCase(), value)
107
- }
108
-
109
- delete(name: string): void {
110
- const key = name.toLowerCase()
111
- const h = this._headers
112
- let i = h.length - 2
113
- while (i >= 0) {
114
- if (h[i] === key) { h.splice(i, 2); i -= 2 } else i -= 2
115
- }
116
- }
117
-
118
- get(name: string): string | null {
119
- const key = name.toLowerCase()
120
- const matches = [...this.entries()].filter(([k]) => k === key).map(([, v]) => v)
121
- return matches.length ? matches.join(', ') : null
122
- }
123
-
124
- has(name: string): boolean {
125
- return [...this.keys()].includes(name.toLowerCase())
126
- }
127
-
128
- set(name: string, value: string): void {
129
- const key = name.toLowerCase()
130
- const h = this._headers
131
- let found = false
132
- let i = h.length - 2
133
- while (i >= 0) {
134
- if (h[i] === key) {
135
- if (!found) {
136
- h[i + 1] = value
137
- found = true
138
- } else {
139
- h.splice(i, 2)
140
- }
141
- }
142
- i -= 2
143
- }
144
- if (!found) h.push(key, value)
145
- }
146
-
147
- forEach(callback: (value: string, name: string, headers: HeadersImpl) => void): void {
148
- for (const [name, value] of this) {
149
- callback(value, name, this)
150
- }
151
- }
152
-
153
- *entries(): IterableIterator<[string, string]> {
154
- const h = this._headers
155
- for (let i = 0; i < h.length; i += 2) {
156
- yield [h[i]!, h[i + 1]!]
157
- }
158
- }
159
-
160
- *keys(): IterableIterator<string> {
161
- for (const [k] of this) yield k
162
- }
163
-
164
- *values(): IterableIterator<string> {
165
- for (const [, v] of this) yield v
166
- }
167
-
168
- [Symbol.iterator](): IterableIterator<[string, string]> {
169
- return this.entries()
170
- }
171
- }
172
-
173
- // ── Request ──
174
-
175
- export class RequestImpl {
176
- readonly url: string
177
- readonly method: string
178
- readonly headers: HeadersImpl
179
- private _body: ReadableStream<Uint8Array> | null
180
- readonly redirect: RequestRedirect
181
- readonly timeout: number
182
- readonly maxRedirects: number
183
- private _bodyConsumed: boolean = false
184
- readonly integrity: string = ''
185
- readonly keepalive: boolean = false
186
- readonly mode: string = 'cors'
187
- readonly cache: string = 'default'
188
- readonly credentials: string = 'same-origin'
189
- readonly referrer: string = 'about:client'
190
- readonly referrerPolicy: string = ''
191
- readonly signal: AbortSignal | null
192
- readonly rejectUnauthorized: boolean
193
- readonly destination: string = ''
194
-
195
- get body(): ReadableStream<Uint8Array> | null { return this._body }
196
-
197
- get bodyUsed(): boolean {
198
- return this._bodyConsumed || (this._body?.locked ?? false)
199
- }
200
-
201
- constructor(input: string | RequestImpl, init: RequestInit = {}) {
202
- const initBody = init.body
203
- if (input instanceof RequestImpl) {
204
- this.url = input.url
205
- this.method = init.method || input.method
206
- this.headers = new HeadersImpl(init.headers || input.headers)
207
- if (initBody !== undefined && initBody !== null) {
208
- this._body = _toReadableStream(initBody)
209
- } else {
210
- this._body = input._body
211
- }
212
- this.redirect = init.redirect || input.redirect
213
- this.timeout = init.timeout || input.timeout
214
- this.maxRedirects = init.maxRedirects || input.maxRedirects
215
- this.rejectUnauthorized = init.rejectUnauthorized === undefined
216
- ? input.rejectUnauthorized
217
- : init.rejectUnauthorized
218
- } else {
219
- this.url = input
220
- this.method = init.method || 'GET'
221
- this.headers = new HeadersImpl(init.headers)
222
- this._body = initBody !== null && initBody !== undefined ? _toReadableStream(initBody) : null
223
- this.redirect = init.redirect || 'follow'
224
- this.timeout = init.timeout || 30000
225
- this.maxRedirects = init.maxRedirects || 5
226
- this.rejectUnauthorized = init.rejectUnauthorized ?? true
227
- }
228
- this.signal = init.signal !== undefined
229
- ? init.signal
230
- : (input instanceof RequestImpl ? input.signal : null)
231
- }
232
-
233
- async arrayBuffer(): Promise<ArrayBuffer> {
234
- if (!this.body) return new ArrayBuffer(0)
235
- if (this._bodyConsumed) throw new TypeError('Body already used')
236
- this._bodyConsumed = true
237
- const bytes = await _readStream(this.body)
238
- return bytes.buffer
239
- }
240
-
241
- async json<T = unknown>(): Promise<T> {
242
- return JSON.parse(await this.text())
243
- }
244
-
245
- async text(): Promise<string> {
246
- if (!this.body) return ''
247
- if (this._bodyConsumed) throw new TypeError('Body already used')
248
- this._bodyConsumed = true
249
- const bytes = await _readStream(this.body)
250
- return new TextDecoder('utf-8').decode(bytes)
251
- }
252
-
253
- clone(): RequestImpl {
254
- if (this.bodyUsed) throw new TypeError('Body already used')
255
- if (this._body) {
256
- const [branch1, branch2] = this._body.tee()
257
- this._body = branch1
258
- const req = new RequestImpl(this.url, {
259
- method: this.method,
260
- headers: this.headers,
261
- body: branch2,
262
- redirect: this.redirect,
263
- timeout: this.timeout,
264
- maxRedirects: this.maxRedirects,
265
- signal: this.signal,
266
- })
267
- return req
268
- }
269
- return new RequestImpl(this.url, {
270
- method: this.method,
271
- headers: this.headers,
272
- redirect: this.redirect,
273
- timeout: this.timeout,
274
- maxRedirects: this.maxRedirects,
275
- signal: this.signal,
276
- })
277
- }
278
- }
279
-
280
- // ── Response ──
281
-
282
- export class ResponseImpl {
283
- readonly status: number
284
- readonly statusText: string
285
- readonly ok: boolean
286
-
287
- private _headers: HeadersImpl
288
- _redirected: boolean = false
289
- private _type: ResponseType = 'basic'
290
- _url: string = ''
291
- private _body: ReadableStream<Uint8Array>
292
- private _bodyConsumed: boolean = false
293
- private _trailers: Promise<HeadersInit> | undefined
294
-
295
- get body(): ReadableStream<Uint8Array> { return this._body }
296
- get bodyUsed(): boolean { return this._bodyConsumed || this._body.locked }
297
- /** Trailing headers to emit after a chunked body (Promise resolves to
298
- * a HeadersInit), when a `Trailer` declaration header is present. */
299
- get trailers(): Promise<HeadersInit> | undefined { return this._trailers }
300
- get headers(): HeadersImpl { return this._headers }
301
- get redirected(): boolean { return this._redirected }
302
- get type(): ResponseType { return this._type }
303
- get url(): string { return this._url }
304
-
305
- constructor(body?: BodyInit | null, init?: ResponseInit) {
306
- const status = init?.status ?? 200
307
- const statusText = init?.statusText ?? ''
308
- const headers = new HeadersImpl(init?.headers)
309
- this.status = status
310
- this.statusText = statusText
311
- this._headers = headers
312
- this._trailers = init?.trailers
313
- this.ok = status >= 200 && status < 300
314
- if (body instanceof ReadableStream) {
315
- this._body = body
316
- } else {
317
- let bytes: Uint8Array
318
- if (body == null) {
319
- bytes = new Uint8Array(0)
320
- } else if (typeof body === 'string') {
321
- bytes = new TextEncoder().encode(body)
322
- } else if (body instanceof ArrayBuffer) {
323
- bytes = new Uint8Array(body)
324
- } else {
325
- bytes = new Uint8Array(body.buffer, body.byteOffset, body.byteLength)
326
- }
327
- if (!headers.has('content-length')) headers.set('Content-Length', String(bytes.byteLength))
328
- this._body = new ReadableStream<Uint8Array>({
329
- start(ctrl) {
330
- ctrl.enqueue(bytes)
331
- ctrl.close()
332
- }
333
- })
334
- }
335
- }
336
-
337
- async text(): Promise<string> {
338
- if (this.bodyUsed) throw new TypeError('Body already used')
339
- this._bodyConsumed = true
340
- const bytes = await _readStream(this._body)
341
- return new TextDecoder('utf-8').decode(bytes)
342
- }
343
-
344
- async json<T = unknown>(): Promise<T> {
345
- return JSON.parse(await this.text())
346
- }
347
-
348
- async arrayBuffer(): Promise<ArrayBuffer> {
349
- if (this.bodyUsed) throw new TypeError('Body already used')
350
- this._bodyConsumed = true
351
- const bytes = await _readStream(this._body)
352
- return bytes.buffer
353
- }
354
-
355
- async bytes(): Promise<Uint8Array> {
356
- if (this.bodyUsed) throw new TypeError('Body already used')
357
- this._bodyConsumed = true
358
- return await _readStream(this._body)
359
- }
360
-
361
- clone(): Response {
362
- if (this.bodyUsed) throw new TypeError('Body already used')
363
- const [branch1, branch2] = this._body.tee()
364
- this._body = branch1
365
- return new ResponseImpl(branch2, { status: this.status, statusText: this.statusText, headers: this._headers, trailers: this._trailers })
366
- }
367
-
368
- _applyDecompressedBody(stream: ReadableStream<Uint8Array>, _body: ArrayBuffer, newHeaders: HeadersImpl): void {
369
- this._bodyConsumed = false
370
- this._body = stream
371
- this._headers = newHeaders
372
- }
373
- }
374
-
375
- // ── Global declarations ──
376
-
377
- declare global {
378
- type HeadersInit = [string, string][] | Record<string, string> | Headers
379
- type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView
380
- type RequestRedirect = 'error' | 'follow' | 'manual'
381
- type RequestCache = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload'
382
- type RequestCredentials = 'include' | 'omit' | 'same-origin'
383
- type RequestMode = 'cors' | 'navigate' | 'no-cors' | 'same-origin'
384
- type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'
385
-
386
- interface AbortSignal {
387
- readonly aborted: boolean;
388
- readonly reason: unknown;
389
- onabort: ((event: { type: 'abort'; target: unknown }) => void) | null;
390
- addEventListener(type: 'abort', listener: (e: { type: 'abort'; target: unknown }) => void): void;
391
- removeEventListener(type: 'abort', listener: (e: { type: 'abort'; target: unknown }) => void): void;
392
- throwIfAborted(): void;
393
- }
394
-
395
- interface RequestInit {
396
- body?: BodyInit | null;
397
- cache?: RequestCache;
398
- credentials?: RequestCredentials;
399
- headers?: HeadersInit;
400
- integrity?: string;
401
- keepalive?: boolean;
402
- method?: string;
403
- mode?: RequestMode;
404
- redirect?: RequestRedirect;
405
- referrer?: string;
406
- referrerPolicy?: string;
407
- signal?: AbortSignal | null;
408
- window?: null;
409
- timeout?: number;
410
- maxRedirects?: number;
411
- /** Non-standard: when false, TLS certificate verification is skipped
412
- * (mirrors Node's https.request rejectUnauthorized option). */
413
- rejectUnauthorized?: boolean;
414
- }
415
-
416
- interface ResponseInit {
417
- status?: number;
418
- statusText?: string;
419
- headers?: HeadersInit;
420
- /** Non-standard: trailing headers, resolved after the body streams.
421
- * http-server emits them (Node addTrailers semantics) when a `Trailer`
422
- * declaration header is present and the body is chunk-framed. */
423
- trailers?: Promise<HeadersInit>;
424
- }
425
-
426
- interface Headers extends HeadersImpl {}
427
- var Headers: typeof HeadersImpl
428
- interface Response extends Omit<ResponseImpl, '_url' | '_redirected' | '_applyDecompressedBody'> {}
429
- interface ResponseConstructor {
430
- new(body?: BodyInit | null, init?: ResponseInit): Response
431
- }
432
- var Response: ResponseConstructor
433
- interface Request extends RequestImpl {}
434
- var Request: typeof RequestImpl
435
- }
436
-
437
- // ── Register globals ──
438
-
439
- globalThis.Headers = HeadersImpl
440
- globalThis.Request = RequestImpl
441
- globalThis.Response = ResponseImpl