quickwin 1.2.0 → 1.2.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.
package/main.js ADDED
@@ -0,0 +1,46 @@
1
+ import { CallWindowProc, CreateSystemDpiFont, CreateWindow as CreateWindowWithoutScale, DefWindowProc, GetScaleFactor, GetWindowLongPtr, GetWindowText, RegisterClass, SendMessage, SetWindowProc, ShowWindow, } from "gui";
2
+ const scaleFactor = GetScaleFactor();
3
+ const dpiFont = CreateSystemDpiFont();
4
+ if (!dpiFont)
5
+ throw new Error('Failed to create DPI font');
6
+ const CreateWindow = (className, title, style, x, y, cx, cy, parent, id) => {
7
+ let hwnd = CreateWindowWithoutScale(className, title, style, x * scaleFactor, y * scaleFactor, cx * scaleFactor, cy * scaleFactor, parent, id);
8
+ if (hwnd)
9
+ SendMessage(hwnd, 48 /* WmMsg.SETFONT */, dpiFont, 1);
10
+ return hwnd;
11
+ };
12
+ let btn = null;
13
+ let edit = null;
14
+ let list = null;
15
+ function wndProc(hwnd, msg, wParam, lParam) {
16
+ if (msg === 1 /* WmMsg.CREATE */) {
17
+ btn = CreateWindow("BUTTON", "添加", 1073741824 /* WindowStyle.CHILD */ | 268435456 /* WindowStyle.VISIBLE */ | 0 /* ButtonStyle.PUSHBUTTON */, 120, 10, 80, 30, hwnd, null);
18
+ edit = CreateWindow("EDIT", "", 1073741824 /* WindowStyle.CHILD */ | 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */, 10, 10, 100, 20, hwnd, null);
19
+ list = CreateWindow("LISTBOX", "", 1073741824 /* WindowStyle.CHILD */ | 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */, 10, 40, 200, 100, hwnd, null);
20
+ if (!btn)
21
+ return 0;
22
+ const oldProc = GetWindowLongPtr(btn, -4 /* Gwlp.WNDPROC */);
23
+ SetWindowProc(btn, (hwnd, msg, wParam, lParam) => {
24
+ if (msg == 513 /* WmMsg.LBUTTONDOWN */) {
25
+ if (!edit)
26
+ return 0;
27
+ if (!list)
28
+ return 0;
29
+ const text = GetWindowText(edit);
30
+ if (text.trim())
31
+ SendMessage(list, 384 /* LbMsg.ADDSTRING */, 0, text);
32
+ return 0;
33
+ }
34
+ return CallWindowProc(oldProc, hwnd, msg, wParam, lParam);
35
+ });
36
+ return 0;
37
+ }
38
+ else if (msg === 273 /* WmMsg.COMMAND */) {
39
+ return 0;
40
+ }
41
+ return DefWindowProc(hwnd, msg, wParam, lParam);
42
+ }
43
+ RegisterClass("MainWindow", wndProc);
44
+ var hwnd = CreateWindow("MainWindow", "Todo List", 13565952 /* WindowStyle.OVERLAPPEDWINDOW */, 0, 0, 600, 400, null, null);
45
+ if (hwnd)
46
+ ShowWindow(hwnd);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "quickwin",
4
- "version": "1.2.0",
4
+ "version": "1.2.1",
5
5
  "description": "QuickJS Win32 runtime — GUI, networking, WASM, FFI, and more",
6
6
  "bin": {
7
7
  "quickwin": "qwin.exe",
@@ -18,6 +18,7 @@
18
18
  "qwin-nowasm.exe",
19
19
  "qwin-x86.exe",
20
20
  "qwin-nowasm-x86.exe",
21
+ "main.js",
21
22
  "lib/",
22
23
  "test/",
23
24
  "examples/",
package/quickwin.d.ts CHANGED
@@ -386,6 +386,7 @@ declare module "wolfssl" {
386
386
  function wolfSSL_connect(ssl: WOLFSSL): number;
387
387
  function wolfSSL_shutdown(ssl: WOLFSSL): number;
388
388
  function wolfSSL_write(ssl: WOLFSSL, buf: ArrayBuffer): number;
389
+ /** 成功返回 ArrayBuffer;EOF/暂无数据/错误返回 null(区分用 wolfSSL_get_error:6=ZERO_RETURN 关闭,2=WANT_READ) */
389
390
  function wolfSSL_read(ssl: WOLFSSL, sz: number): ArrayBuffer | null;
390
391
  function wolfSSL_get_error(ssl: WOLFSSL, ret: number): number;
391
392
  function wolfSSL_UseSNI(ssl: WOLFSSL, type: SniType, name: string, len?: number): number;
Binary file
package/qwin-nowasm.exe CHANGED
Binary file
package/qwin-x86.exe CHANGED
Binary file
package/qwin.exe CHANGED
Binary file
package/test/run.js CHANGED
@@ -24,6 +24,7 @@ const suiteDefs = [
24
24
  { name: 'mupdf-render', file: './test_mupdf_render.js', tags: ['wasm', 'mupdf'] },
25
25
  { name: 'ffi', file: './test_ffi.js', tags: [] },
26
26
  { name: 'net-fetch', file: './test_net_fetch.js', tags: ['net'] },
27
+ { name: 'net-wolfssl-read', file: './test_wolfssl_read.js', tags: ['net'] },
27
28
  { name: 'net-websocket', file: './test_net_websocket.js', tags: ['net'] },
28
29
  { name: 'net-event', file: './test_net_event.js', tags: ['net'] },
29
30
  { name: 'http-server', file: './test_http_server.js', tags: ['net'] },
package/test/run.ts CHANGED
@@ -28,6 +28,7 @@ const suiteDefs = [
28
28
  { name: 'mupdf-render', file: './test_mupdf_render.js', tags: ['wasm', 'mupdf'] },
29
29
  { name: 'ffi', file: './test_ffi.js', tags: [] },
30
30
  { name: 'net-fetch', file: './test_net_fetch.js', tags: ['net'] },
31
+ { name: 'net-wolfssl-read', file: './test_wolfssl_read.js', tags: ['net'] },
31
32
  { name: 'net-websocket', file: './test_net_websocket.js', tags: ['net'] },
32
33
  { name: 'net-event', file: './test_net_event.js', tags: ['net'] },
33
34
  { name: 'http-server', file: './test_http_server.js', tags: ['net'] },
@@ -1,5 +1,6 @@
1
1
  import '../lib/fetch.js';
2
2
  import * as std from 'std';
3
+ import * as os from 'os';
3
4
  export const suite = {
4
5
  name: 'net-fetch',
5
6
  run: async (t) => {
@@ -255,5 +256,66 @@ export const suite = {
255
256
  else {
256
257
  assert('https endpoint reachable', false);
257
258
  }
259
+ // ── large HTTPS body (wolfSSL_read null regression) ──
260
+ // Pre-fix: wolfSSL_read returned number -1 on WANT_READ →
261
+ // receivedBytes became NaN → stream never closed → hang.
262
+ t.section('large HTTPS body');
263
+ {
264
+ const LARGE = 200000;
265
+ try {
266
+ const r = await Promise.race([
267
+ fetch(`https://localhost:18924/large/${LARGE}`, { timeout: 15000 }),
268
+ new Promise((_, rej) => os.setTimeout(() => rej(new Error('Body hang watchdog 15s')), 15000))
269
+ ]);
270
+ assert('large HTTPS status 200', r.status === 200);
271
+ const buf = await Promise.race([
272
+ r.arrayBuffer(),
273
+ new Promise((_, rej) => os.setTimeout(() => rej(new Error('arrayBuffer hang watchdog 15s')), 15000))
274
+ ]);
275
+ assert('large HTTPS byteLength exact', buf.byteLength === LARGE);
276
+ }
277
+ catch (e) {
278
+ assert('large HTTPS completed without hang (' + String(e.message) + ')', false);
279
+ }
280
+ }
281
+ // ── large HTTP body (sock.recv path same null contract) ──
282
+ t.section('large HTTP body');
283
+ {
284
+ const LARGE = 200000;
285
+ try {
286
+ const r = await Promise.race([
287
+ fetch(`http://localhost:18923/large/${LARGE}`, { timeout: 15000 }),
288
+ new Promise((_, rej) => os.setTimeout(() => rej(new Error('Body hang watchdog 15s')), 15000))
289
+ ]);
290
+ assert('large HTTP status 200', r.status === 200);
291
+ const buf = await Promise.race([
292
+ r.arrayBuffer(),
293
+ new Promise((_, rej) => os.setTimeout(() => rej(new Error('arrayBuffer hang watchdog 15s')), 15000))
294
+ ]);
295
+ assert('large HTTP byteLength exact', buf.byteLength === LARGE);
296
+ }
297
+ catch (e) {
298
+ assert('large HTTP completed (' + String(e.message) + ')', false);
299
+ }
300
+ }
301
+ // ── body timeout after headers (armTimeout after doResolve) ──
302
+ t.section('HTTPS body timeout');
303
+ {
304
+ let rejected = false;
305
+ let msg = '';
306
+ try {
307
+ const r = await fetch('https://localhost:18924/stall', { timeout: 2000 });
308
+ await Promise.race([
309
+ r.arrayBuffer(),
310
+ new Promise((_, rej) => os.setTimeout(() => rej(new Error('Body timeout')), 8000))
311
+ ]);
312
+ }
313
+ catch (e) {
314
+ rejected = true;
315
+ msg = String(e.message);
316
+ }
317
+ assert('stall body rejects (timeout)', rejected);
318
+ assert('stall error mentions timeout', /timeout/i.test(msg));
319
+ }
258
320
  }
259
321
  };
@@ -1,5 +1,6 @@
1
1
  import '../lib/fetch.js'
2
2
  import * as std from 'std'
3
+ import * as os from 'os'
3
4
  import { Tester } from './test_helper.js'
4
5
 
5
6
  export const suite = {
@@ -234,5 +235,76 @@ export const suite = {
234
235
  } else {
235
236
  assert('https endpoint reachable', false)
236
237
  }
238
+
239
+ // ── large HTTPS body (wolfSSL_read null regression) ──
240
+ // Pre-fix: wolfSSL_read returned number -1 on WANT_READ →
241
+ // receivedBytes became NaN → stream never closed → hang.
242
+ t.section('large HTTPS body')
243
+ {
244
+ const LARGE = 200000
245
+ try {
246
+ const r = await Promise.race([
247
+ fetch(`https://localhost:18924/large/${LARGE}`, { timeout: 15000 }),
248
+ new Promise<never>((_, rej) =>
249
+ os.setTimeout(() => rej(new Error('Body hang watchdog 15s')), 15000)
250
+ )
251
+ ])
252
+ assert('large HTTPS status 200', r.status === 200)
253
+ const buf = await Promise.race([
254
+ r.arrayBuffer(),
255
+ new Promise<never>((_, rej) =>
256
+ os.setTimeout(() => rej(new Error('arrayBuffer hang watchdog 15s')), 15000)
257
+ )
258
+ ])
259
+ assert('large HTTPS byteLength exact', buf.byteLength === LARGE)
260
+ } catch (e: unknown) {
261
+ assert('large HTTPS completed without hang (' + String((e as Error).message) + ')', false)
262
+ }
263
+ }
264
+
265
+ // ── large HTTP body (sock.recv path same null contract) ──
266
+ t.section('large HTTP body')
267
+ {
268
+ const LARGE = 200000
269
+ try {
270
+ const r = await Promise.race([
271
+ fetch(`http://localhost:18923/large/${LARGE}`, { timeout: 15000 }),
272
+ new Promise<never>((_, rej) =>
273
+ os.setTimeout(() => rej(new Error('Body hang watchdog 15s')), 15000)
274
+ )
275
+ ])
276
+ assert('large HTTP status 200', r.status === 200)
277
+ const buf = await Promise.race([
278
+ r.arrayBuffer(),
279
+ new Promise<never>((_, rej) =>
280
+ os.setTimeout(() => rej(new Error('arrayBuffer hang watchdog 15s')), 15000)
281
+ )
282
+ ])
283
+ assert('large HTTP byteLength exact', buf.byteLength === LARGE)
284
+ } catch (e: unknown) {
285
+ assert('large HTTP completed (' + String((e as Error).message) + ')', false)
286
+ }
287
+ }
288
+
289
+ // ── body timeout after headers (armTimeout after doResolve) ──
290
+ t.section('HTTPS body timeout')
291
+ {
292
+ let rejected = false
293
+ let msg = ''
294
+ try {
295
+ const r = await fetch('https://localhost:18924/stall', { timeout: 2000 })
296
+ await Promise.race([
297
+ r.arrayBuffer(),
298
+ new Promise<never>((_, rej) =>
299
+ os.setTimeout(() => rej(new Error('Body timeout')), 8000)
300
+ )
301
+ ])
302
+ } catch (e: unknown) {
303
+ rejected = true
304
+ msg = String((e as Error).message)
305
+ }
306
+ assert('stall body rejects (timeout)', rejected)
307
+ assert('stall error mentions timeout', /timeout/i.test(msg))
308
+ }
237
309
  }
238
310
  }
@@ -15358,7 +15358,7 @@ var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
15358
15358
  var import_react18 = __toESM(require_react(), 1);
15359
15359
  import "../lib/polyfill.js";
15360
15360
  import * as gui19 from "gui";
15361
- import * as os2 from "os";
15361
+ import * as os3 from "os";
15362
15362
 
15363
15363
  // _build/lib/react-qw/index.js
15364
15364
  import * as gui18 from "gui";
@@ -15368,7 +15368,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
15368
15368
  var import_react = __toESM(require_react(), 1);
15369
15369
  var import_constants = __toESM(require_constants(), 1);
15370
15370
  import * as gui3 from "gui";
15371
- import * as os from "os";
15371
+ import * as os2 from "os";
15372
15372
 
15373
15373
  // _build/lib/react-qw/props.js
15374
15374
  import * as gui from "gui";
@@ -15489,6 +15489,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
15489
15489
 
15490
15490
  // _build/lib/text-measure.js
15491
15491
  import * as ffi from "ffi";
15492
+ import * as os from "os";
15492
15493
  import * as win from "win";
15493
15494
  import * as gui2 from "gui";
15494
15495
  function loadProc(lib, name) {
@@ -15505,7 +15506,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
15505
15506
  var GetDC = loadProc(user32, "GetDC");
15506
15507
  var ReleaseDC = loadProc(user32, "ReleaseDC");
15507
15508
  var SelectObject = loadProc(gdi32, "SelectObject");
15508
- var FFI_TYPE_UINT642 = ffi.FFI_TYPE_UINT64;
15509
+ var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
15509
15510
  var FFI_S32 = ffi.FFI_TYPE_SINT32;
15510
15511
  var FFI_PTR = ffi.FFI_TYPE_POINTER;
15511
15512
  function measureText(hdc, text, maxWidth) {
@@ -15513,14 +15514,14 @@ function measureText(hdc, text, maxWidth) {
15513
15514
  const rect = new ArrayBuffer(16);
15514
15515
  const dv = new DataView(rect);
15515
15516
  dv.setInt32(8, maxWidth, true);
15516
- ffi.ffiCall(DrawTextW, [FFI_TYPE_UINT642, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15517
+ ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15517
15518
  hdc,
15518
15519
  textBuf,
15519
15520
  -1,
15520
15521
  rect,
15521
15522
  1024
15522
15523
  /* gui.DrawTextFlag.CALCRECT */
15523
- ], FFI_TYPE_UINT642);
15524
+ ], FFI_S32);
15524
15525
  return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
15525
15526
  }
15526
15527
  function getButtonIdealSize(hwnd2) {
@@ -15530,15 +15531,15 @@ function getButtonIdealSize(hwnd2) {
15530
15531
  return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
15531
15532
  }
15532
15533
  function measureTextForHwnd(hwnd2, text) {
15533
- const hdc = ffi.ffiCall(GetDC, [FFI_TYPE_UINT642], [hwnd2], FFI_TYPE_UINT642);
15534
+ const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
15534
15535
  if (!hdc)
15535
15536
  return { width: 0, height: 0 };
15536
15537
  const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
15537
- const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, hFont], FFI_TYPE_UINT642) : 0;
15538
+ const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
15538
15539
  const result = measureText(hdc, text, 0);
15539
15540
  if (hFont)
15540
- ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, oldFont], FFI_TYPE_UINT642);
15541
- ffi.ffiCall(ReleaseDC, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hwnd2, hdc], FFI_S32);
15541
+ ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
15542
+ ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
15542
15543
  const wr = gui2.GetWindowRect(hwnd2);
15543
15544
  const cr = gui2.GetClientRect(hwnd2);
15544
15545
  if (wr && cr) {
@@ -15851,10 +15852,10 @@ var hostConfig = {
15851
15852
  clearContainer(_container) {
15852
15853
  },
15853
15854
  scheduleTimeout(fn, delay) {
15854
- return os.setTimeout(fn, delay);
15855
+ return os2.setTimeout(fn, delay);
15855
15856
  },
15856
15857
  cancelTimeout(id) {
15857
- os.clearTimeout?.(id);
15858
+ os2.clearTimeout?.(id);
15858
15859
  },
15859
15860
  noTimeout: -1,
15860
15861
  supportsMutation: true,
@@ -17279,9 +17280,9 @@ function printWindowTree(hwnd2, indent = 0) {
17279
17280
  function mockSetInterval(func, delay) {
17280
17281
  function loop() {
17281
17282
  func();
17282
- os2.setTimeout(loop, delay);
17283
+ os3.setTimeout(loop, delay);
17283
17284
  }
17284
- os2.setTimeout(loop, delay);
17285
+ os3.setTimeout(loop, delay);
17285
17286
  }
17286
17287
  gui19.RegisterClass("ComplexTest", (hwnd2, msg, wParam, lParam) => {
17287
17288
  if (!hwnd2)
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
15367
15367
  var import_react = __toESM(require_react(), 1);
15368
15368
  var import_constants = __toESM(require_constants(), 1);
15369
15369
  import * as gui3 from "gui";
15370
- import * as os from "os";
15370
+ import * as os2 from "os";
15371
15371
 
15372
15372
  // _build/lib/react-qw/props.js
15373
15373
  import * as gui from "gui";
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
15488
15488
 
15489
15489
  // _build/lib/text-measure.js
15490
15490
  import * as ffi from "ffi";
15491
+ import * as os from "os";
15491
15492
  import * as win from "win";
15492
15493
  import * as gui2 from "gui";
15493
15494
  function loadProc(lib, name) {
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
15504
15505
  var GetDC = loadProc(user32, "GetDC");
15505
15506
  var ReleaseDC = loadProc(user32, "ReleaseDC");
15506
15507
  var SelectObject = loadProc(gdi32, "SelectObject");
15507
- var FFI_TYPE_UINT642 = ffi.FFI_TYPE_UINT64;
15508
+ var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
15508
15509
  var FFI_S32 = ffi.FFI_TYPE_SINT32;
15509
15510
  var FFI_PTR = ffi.FFI_TYPE_POINTER;
15510
15511
  function measureText(hdc, text, maxWidth) {
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
15512
15513
  const rect = new ArrayBuffer(16);
15513
15514
  const dv = new DataView(rect);
15514
15515
  dv.setInt32(8, maxWidth, true);
15515
- ffi.ffiCall(DrawTextW, [FFI_TYPE_UINT642, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15516
+ ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15516
15517
  hdc,
15517
15518
  textBuf,
15518
15519
  -1,
15519
15520
  rect,
15520
15521
  1024
15521
15522
  /* gui.DrawTextFlag.CALCRECT */
15522
- ], FFI_TYPE_UINT642);
15523
+ ], FFI_S32);
15523
15524
  return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
15524
15525
  }
15525
15526
  function getButtonIdealSize(hwnd2) {
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd2) {
15529
15530
  return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
15530
15531
  }
15531
15532
  function measureTextForHwnd(hwnd2, text) {
15532
- const hdc = ffi.ffiCall(GetDC, [FFI_TYPE_UINT642], [hwnd2], FFI_TYPE_UINT642);
15533
+ const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
15533
15534
  if (!hdc)
15534
15535
  return { width: 0, height: 0 };
15535
15536
  const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
15536
- const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, hFont], FFI_TYPE_UINT642) : 0;
15537
+ const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
15537
15538
  const result = measureText(hdc, text, 0);
15538
15539
  if (hFont)
15539
- ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, oldFont], FFI_TYPE_UINT642);
15540
- ffi.ffiCall(ReleaseDC, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hwnd2, hdc], FFI_S32);
15540
+ ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
15541
+ ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
15541
15542
  const wr = gui2.GetWindowRect(hwnd2);
15542
15543
  const cr = gui2.GetClientRect(hwnd2);
15543
15544
  if (wr && cr) {
@@ -15850,10 +15851,10 @@ var hostConfig = {
15850
15851
  clearContainer(_container) {
15851
15852
  },
15852
15853
  scheduleTimeout(fn, delay) {
15853
- return os.setTimeout(fn, delay);
15854
+ return os2.setTimeout(fn, delay);
15854
15855
  },
15855
15856
  cancelTimeout(id) {
15856
- os.clearTimeout?.(id);
15857
+ os2.clearTimeout?.(id);
15857
15858
  },
15858
15859
  noTimeout: -1,
15859
15860
  supportsMutation: true,
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
15367
15367
  var import_react = __toESM(require_react(), 1);
15368
15368
  var import_constants = __toESM(require_constants(), 1);
15369
15369
  import * as gui3 from "gui";
15370
- import * as os from "os";
15370
+ import * as os2 from "os";
15371
15371
 
15372
15372
  // _build/lib/react-qw/props.js
15373
15373
  import * as gui from "gui";
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
15488
15488
 
15489
15489
  // _build/lib/text-measure.js
15490
15490
  import * as ffi from "ffi";
15491
+ import * as os from "os";
15491
15492
  import * as win from "win";
15492
15493
  import * as gui2 from "gui";
15493
15494
  function loadProc(lib, name) {
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
15504
15505
  var GetDC = loadProc(user32, "GetDC");
15505
15506
  var ReleaseDC = loadProc(user32, "ReleaseDC");
15506
15507
  var SelectObject = loadProc(gdi32, "SelectObject");
15507
- var FFI_TYPE_UINT642 = ffi.FFI_TYPE_UINT64;
15508
+ var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
15508
15509
  var FFI_S32 = ffi.FFI_TYPE_SINT32;
15509
15510
  var FFI_PTR = ffi.FFI_TYPE_POINTER;
15510
15511
  function measureText(hdc, text, maxWidth) {
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
15512
15513
  const rect = new ArrayBuffer(16);
15513
15514
  const dv = new DataView(rect);
15514
15515
  dv.setInt32(8, maxWidth, true);
15515
- ffi.ffiCall(DrawTextW, [FFI_TYPE_UINT642, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15516
+ ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15516
15517
  hdc,
15517
15518
  textBuf,
15518
15519
  -1,
15519
15520
  rect,
15520
15521
  1024
15521
15522
  /* gui.DrawTextFlag.CALCRECT */
15522
- ], FFI_TYPE_UINT642);
15523
+ ], FFI_S32);
15523
15524
  return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
15524
15525
  }
15525
15526
  function getButtonIdealSize(hwnd) {
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd) {
15529
15530
  return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
15530
15531
  }
15531
15532
  function measureTextForHwnd(hwnd, text) {
15532
- const hdc = ffi.ffiCall(GetDC, [FFI_TYPE_UINT642], [hwnd], FFI_TYPE_UINT642);
15533
+ const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd], FFI_HND);
15533
15534
  if (!hdc)
15534
15535
  return { width: 0, height: 0 };
15535
15536
  const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
15536
- const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, hFont], FFI_TYPE_UINT642) : 0;
15537
+ const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
15537
15538
  const result = measureText(hdc, text, 0);
15538
15539
  if (hFont)
15539
- ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, oldFont], FFI_TYPE_UINT642);
15540
- ffi.ffiCall(ReleaseDC, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hwnd, hdc], FFI_S32);
15540
+ ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
15541
+ ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd, hdc], FFI_S32);
15541
15542
  const wr = gui2.GetWindowRect(hwnd);
15542
15543
  const cr = gui2.GetClientRect(hwnd);
15543
15544
  if (wr && cr) {
@@ -15850,10 +15851,10 @@ var hostConfig = {
15850
15851
  clearContainer(_container) {
15851
15852
  },
15852
15853
  scheduleTimeout(fn, delay) {
15853
- return os.setTimeout(fn, delay);
15854
+ return os2.setTimeout(fn, delay);
15854
15855
  },
15855
15856
  cancelTimeout(id) {
15856
- os.clearTimeout?.(id);
15857
+ os2.clearTimeout?.(id);
15857
15858
  },
15858
15859
  noTimeout: -1,
15859
15860
  supportsMutation: true,
@@ -15358,7 +15358,7 @@ var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
15358
15358
  var import_react18 = __toESM(require_react(), 1);
15359
15359
  import "../lib/polyfill.js";
15360
15360
  import * as gui19 from "gui";
15361
- import * as os2 from "os";
15361
+ import * as os3 from "os";
15362
15362
 
15363
15363
  // _build/lib/react-qw/index.js
15364
15364
  import * as gui18 from "gui";
@@ -15368,7 +15368,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
15368
15368
  var import_react = __toESM(require_react(), 1);
15369
15369
  var import_constants = __toESM(require_constants(), 1);
15370
15370
  import * as gui3 from "gui";
15371
- import * as os from "os";
15371
+ import * as os2 from "os";
15372
15372
 
15373
15373
  // _build/lib/react-qw/props.js
15374
15374
  import * as gui from "gui";
@@ -15489,6 +15489,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
15489
15489
 
15490
15490
  // _build/lib/text-measure.js
15491
15491
  import * as ffi from "ffi";
15492
+ import * as os from "os";
15492
15493
  import * as win from "win";
15493
15494
  import * as gui2 from "gui";
15494
15495
  function loadProc(lib, name) {
@@ -15505,7 +15506,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
15505
15506
  var GetDC = loadProc(user32, "GetDC");
15506
15507
  var ReleaseDC = loadProc(user32, "ReleaseDC");
15507
15508
  var SelectObject = loadProc(gdi32, "SelectObject");
15508
- var FFI_TYPE_UINT642 = ffi.FFI_TYPE_UINT64;
15509
+ var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
15509
15510
  var FFI_S32 = ffi.FFI_TYPE_SINT32;
15510
15511
  var FFI_PTR = ffi.FFI_TYPE_POINTER;
15511
15512
  function measureText(hdc, text, maxWidth) {
@@ -15513,14 +15514,14 @@ function measureText(hdc, text, maxWidth) {
15513
15514
  const rect = new ArrayBuffer(16);
15514
15515
  const dv = new DataView(rect);
15515
15516
  dv.setInt32(8, maxWidth, true);
15516
- ffi.ffiCall(DrawTextW, [FFI_TYPE_UINT642, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15517
+ ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
15517
15518
  hdc,
15518
15519
  textBuf,
15519
15520
  -1,
15520
15521
  rect,
15521
15522
  1024
15522
15523
  /* gui.DrawTextFlag.CALCRECT */
15523
- ], FFI_TYPE_UINT642);
15524
+ ], FFI_S32);
15524
15525
  return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
15525
15526
  }
15526
15527
  function getButtonIdealSize(hwnd2) {
@@ -15530,15 +15531,15 @@ function getButtonIdealSize(hwnd2) {
15530
15531
  return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
15531
15532
  }
15532
15533
  function measureTextForHwnd(hwnd2, text) {
15533
- const hdc = ffi.ffiCall(GetDC, [FFI_TYPE_UINT642], [hwnd2], FFI_TYPE_UINT642);
15534
+ const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
15534
15535
  if (!hdc)
15535
15536
  return { width: 0, height: 0 };
15536
15537
  const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
15537
- const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, hFont], FFI_TYPE_UINT642) : 0;
15538
+ const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
15538
15539
  const result = measureText(hdc, text, 0);
15539
15540
  if (hFont)
15540
- ffi.ffiCall(SelectObject, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hdc, oldFont], FFI_TYPE_UINT642);
15541
- ffi.ffiCall(ReleaseDC, [FFI_TYPE_UINT642, FFI_TYPE_UINT642], [hwnd2, hdc], FFI_S32);
15541
+ ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
15542
+ ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
15542
15543
  const wr = gui2.GetWindowRect(hwnd2);
15543
15544
  const cr = gui2.GetClientRect(hwnd2);
15544
15545
  if (wr && cr) {
@@ -15851,10 +15852,10 @@ var hostConfig = {
15851
15852
  clearContainer(_container) {
15852
15853
  },
15853
15854
  scheduleTimeout(fn, delay) {
15854
- return os.setTimeout(fn, delay);
15855
+ return os2.setTimeout(fn, delay);
15855
15856
  },
15856
15857
  cancelTimeout(id) {
15857
- os.clearTimeout?.(id);
15858
+ os2.clearTimeout?.(id);
15858
15859
  },
15859
15860
  noTimeout: -1,
15860
15861
  supportsMutation: true,
@@ -17268,7 +17269,7 @@ gui19.RegisterClass("ReactHidden", (hwnd2, msg, wParam, lParam) => {
17268
17269
  function App() {
17269
17270
  const [hidden, setHidden] = (0, import_react18.useState)(true);
17270
17271
  (0, import_react18.useEffect)(() => {
17271
- os2.setTimeout(() => setHidden(false), 2e3);
17272
+ os3.setTimeout(() => setHidden(false), 2e3);
17272
17273
  }, []);
17273
17274
  return (0, import_jsx_runtime16.jsxs)("w", { type: "STATIC", ws: WS_CHILD | WS_VISIBLE, style: { width: 480, height: 360, flexDirection: "column", padding: 10, gap: 10 }, children: [(0, import_jsx_runtime16.jsx)("w", { type: "STATIC", text: "Click to close", ws: WS_CHILD | WS_VISIBLE, style: { width: 200, height: 30 } }), (0, import_jsx_runtime16.jsx)("w", { type: "STATIC", text: hidden ? "HIDDEN" : "VISIBLE", ws: WS_CHILD | WS_VISIBLE, hidden, style: { width: 200, height: 100 } })] });
17274
17275
  }