quickwin 1.2.1 → 2.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.
Files changed (137) hide show
  1. package/README.en.md +3 -3
  2. package/README.md +21 -24
  3. package/examples/PdfCanvas.js +8 -37
  4. package/examples/PdfCanvas.tsx +11 -41
  5. package/examples/exec_server.js +20054 -1423
  6. package/examples/exec_server.tsx +489 -0
  7. package/examples/exec_server_worker.js +383 -33
  8. package/examples/exec_server_worker.ts +408 -30
  9. package/examples/pdf_preview2.js +31 -73
  10. package/examples/pdf_preview2.ts +33 -76
  11. package/examples/pdf_viewer.js +1496 -616
  12. package/examples/pdf_viewer.tsx +23 -64
  13. package/examples/setres.js +22 -47
  14. package/examples/setres.ts +23 -57
  15. package/examples/test_gallery.js +1491 -525
  16. package/examples/test_react_lazy.js +1455 -500
  17. package/examples/test_react_listbox.js +1454 -499
  18. package/examples/test_root_window.js +1450 -495
  19. package/examples/test_tab.js +1455 -500
  20. package/lib/abort.js +70 -0
  21. package/lib/abort.ts +69 -0
  22. package/lib/certs.js +214 -0
  23. package/lib/certs.ts +224 -0
  24. package/lib/exec-log.js +15 -0
  25. package/lib/exec-log.ts +30 -0
  26. package/lib/fetch.js +37 -4
  27. package/lib/fetch.ts +35 -4
  28. package/lib/ffi/bind.js +352 -0
  29. package/lib/ffi/bind.ts +442 -0
  30. package/lib/ffi/ctype.js +168 -0
  31. package/lib/ffi/ctype.ts +331 -0
  32. package/lib/ffi/index.js +6 -0
  33. package/lib/ffi/index.ts +6 -0
  34. package/lib/ffi/struct.js +412 -0
  35. package/lib/ffi/struct.ts +664 -0
  36. package/lib/http-common.js +43 -5
  37. package/lib/http-common.ts +48 -6
  38. package/lib/http-server.js +187 -29
  39. package/lib/http-server.ts +177 -26
  40. package/lib/react-qw/components/DateTimePicker.js +20 -33
  41. package/lib/react-qw/components/Input.js +3 -10
  42. package/lib/react-qw/components/Link.js +7 -22
  43. package/lib/react-qw/components/ListView.js +80 -141
  44. package/lib/react-qw/components/PathPicker.js +36 -80
  45. package/lib/react-qw/components/ScrollView.js +15 -8
  46. package/lib/react-qw/components/Slider.js +2 -1
  47. package/lib/react-qw/components/Tab.js +15 -20
  48. package/lib/react-qw/components/Tooltip.js +21 -20
  49. package/lib/react-qw/components/TreeView.js +14 -47
  50. package/lib/react-qw/index.js +4 -2
  51. package/lib/react-qw/index.ts +4 -2
  52. package/lib/react-qw/nmhdr.js +5 -0
  53. package/lib/react-qw/nmhdr.ts +7 -0
  54. package/lib/react-qw/props.js +7 -2
  55. package/lib/react-qw/props.ts +7 -3
  56. package/lib/react-qw/reconciler.js +23 -13
  57. package/lib/react-qw/reconciler.ts +22 -13
  58. package/lib/text-measure.js +18 -35
  59. package/lib/text-measure.ts +20 -37
  60. package/lib/websocket.js +12 -2
  61. package/lib/websocket.ts +15 -2
  62. package/lib/windows/comctl32.js +18 -0
  63. package/lib/windows/comctl32.ts +20 -0
  64. package/lib/windows/comdlg32.js +7 -0
  65. package/lib/windows/comdlg32.ts +9 -0
  66. package/lib/windows/gdi32.js +90 -0
  67. package/lib/windows/gdi32.ts +97 -0
  68. package/lib/windows/kernel32.js +66 -0
  69. package/lib/windows/kernel32.ts +76 -0
  70. package/lib/windows/ntdll.js +8 -0
  71. package/lib/windows/ntdll.ts +10 -0
  72. package/lib/windows/ole32.js +7 -0
  73. package/lib/windows/ole32.ts +9 -0
  74. package/lib/windows/shell32.js +11 -0
  75. package/lib/windows/shell32.ts +14 -0
  76. package/lib/windows/structs.js +384 -0
  77. package/lib/windows/structs.ts +422 -0
  78. package/lib/windows/user32.js +469 -0
  79. package/lib/windows/user32.ts +502 -0
  80. package/package.json +1 -1
  81. package/quickwin.d.ts +22 -33
  82. package/quickwin_const.d.ts +1 -0
  83. package/qwin-nowasm-x86.exe +0 -0
  84. package/qwin-nowasm.exe +0 -0
  85. package/qwin-x86.exe +0 -0
  86. package/qwin.exe +0 -0
  87. package/test/bench_ffi_callraw.js +236 -0
  88. package/test/bench_ffi_callraw.ts +236 -0
  89. package/test/bench_ffi_overhead.js +139 -0
  90. package/test/bench_ffi_overhead.ts +141 -0
  91. package/test/bench_sendmessage.js +104 -0
  92. package/test/bench_sendmessage.ts +100 -0
  93. package/test/bench_sendmessage_nonnull.js +187 -0
  94. package/test/bench_sendmessage_nonnull.ts +188 -0
  95. package/test/run.js +14 -4
  96. package/test/run.ts +15 -5
  97. package/test/test_basic_fetch.js +8 -0
  98. package/test/test_basic_fetch.ts +9 -0
  99. package/test/test_ffi.js +33 -47
  100. package/test/test_ffi.ts +41 -60
  101. package/test/test_ffi_abi.js +235 -0
  102. package/test/test_ffi_abi.ts +218 -0
  103. package/test/test_ffi_bind.js +572 -0
  104. package/test/test_ffi_bind.ts +597 -0
  105. package/test/test_ffi_struct.js +745 -0
  106. package/test/test_ffi_struct.ts +798 -0
  107. package/test/test_ffi_struct_layout.js +495 -0
  108. package/test/test_ffi_struct_layout.ts +543 -0
  109. package/test/test_ffi_user32.js +103 -0
  110. package/test/test_ffi_user32.ts +113 -0
  111. package/test/test_ffi_windows.js +101 -0
  112. package/test/test_ffi_windows.ts +113 -0
  113. package/test/test_helper.js +8 -1
  114. package/test/test_helper.ts +9 -1
  115. package/test/test_http_import.js +18 -0
  116. package/test/test_http_import.ts +19 -0
  117. package/test/test_http_server.js +73 -1
  118. package/test/test_http_server.ts +75 -1
  119. package/test/test_ipv6.js +2 -2
  120. package/test/test_ipv6.ts +2 -2
  121. package/test/test_net_fetch.js +70 -8
  122. package/test/test_net_fetch.ts +69 -7
  123. package/test/test_net_websocket.js +1 -1
  124. package/test/test_net_websocket.ts +1 -1
  125. package/test/test_react_complex.js +1465 -510
  126. package/test/test_react_counter.js +1455 -500
  127. package/test/test_react_flex.js +1475 -513
  128. package/test/test_react_hidden.js +1458 -503
  129. package/test/test_react_listview_link.js +1455 -500
  130. package/test/test_react_notify.js +18534 -0
  131. package/test/test_react_render.js +1455 -500
  132. package/test/test_wolfssl_read.js +3 -2
  133. package/test/test_wolfssl_read.ts +3 -1
  134. package/test/test_worker_net.js +35 -17
  135. package/test/test_worker_net.ts +27 -15
  136. package/tsconfig.json +1 -1
  137. package/examples/exec_server.ts +0 -80
@@ -1367,9 +1367,9 @@ var require_scheduler_development = __commonJS({
1367
1367
  }
1368
1368
  return first;
1369
1369
  }
1370
- function compare(a, b) {
1371
- var diff = a.sortIndex - b.sortIndex;
1372
- return 0 !== diff ? diff : a.id - b.id;
1370
+ function compare(a, b6) {
1371
+ var diff = a.sortIndex - b6.sortIndex;
1372
+ return 0 !== diff ? diff : a.id - b6.id;
1373
1373
  }
1374
1374
  function advanceTimers(currentTime) {
1375
1375
  for (var timer = peek(timerQueue); null !== timer; ) {
@@ -1667,14 +1667,14 @@ var require_react_reconciler_development = __commonJS({
1667
1667
  throw Error("Unable to find node on an unmounted component.");
1668
1668
  return alternate !== fiber ? null : fiber;
1669
1669
  }
1670
- for (var a = fiber, b = alternate; ; ) {
1670
+ for (var a = fiber, b6 = alternate; ; ) {
1671
1671
  var parentA = a.return;
1672
1672
  if (null === parentA) break;
1673
1673
  var parentB = parentA.alternate;
1674
1674
  if (null === parentB) {
1675
- b = parentA.return;
1676
- if (null !== b) {
1677
- a = b;
1675
+ b6 = parentA.return;
1676
+ if (null !== b6) {
1677
+ a = b6;
1678
1678
  continue;
1679
1679
  }
1680
1680
  break;
@@ -1682,23 +1682,23 @@ var require_react_reconciler_development = __commonJS({
1682
1682
  if (parentA.child === parentB.child) {
1683
1683
  for (parentB = parentA.child; parentB; ) {
1684
1684
  if (parentB === a) return assertIsMounted(parentA), fiber;
1685
- if (parentB === b) return assertIsMounted(parentA), alternate;
1685
+ if (parentB === b6) return assertIsMounted(parentA), alternate;
1686
1686
  parentB = parentB.sibling;
1687
1687
  }
1688
1688
  throw Error("Unable to find node on an unmounted component.");
1689
1689
  }
1690
- if (a.return !== b.return) a = parentA, b = parentB;
1690
+ if (a.return !== b6.return) a = parentA, b6 = parentB;
1691
1691
  else {
1692
1692
  for (var didFindChild = false, _child = parentA.child; _child; ) {
1693
1693
  if (_child === a) {
1694
1694
  didFindChild = true;
1695
1695
  a = parentA;
1696
- b = parentB;
1696
+ b6 = parentB;
1697
1697
  break;
1698
1698
  }
1699
- if (_child === b) {
1699
+ if (_child === b6) {
1700
1700
  didFindChild = true;
1701
- b = parentA;
1701
+ b6 = parentA;
1702
1702
  a = parentB;
1703
1703
  break;
1704
1704
  }
@@ -1709,12 +1709,12 @@ var require_react_reconciler_development = __commonJS({
1709
1709
  if (_child === a) {
1710
1710
  didFindChild = true;
1711
1711
  a = parentB;
1712
- b = parentA;
1712
+ b6 = parentA;
1713
1713
  break;
1714
1714
  }
1715
- if (_child === b) {
1715
+ if (_child === b6) {
1716
1716
  didFindChild = true;
1717
- b = parentB;
1717
+ b6 = parentB;
1718
1718
  a = parentA;
1719
1719
  break;
1720
1720
  }
@@ -1726,7 +1726,7 @@ var require_react_reconciler_development = __commonJS({
1726
1726
  );
1727
1727
  }
1728
1728
  }
1729
- if (a.alternate !== b)
1729
+ if (a.alternate !== b6)
1730
1730
  throw Error(
1731
1731
  "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
1732
1732
  );
@@ -15071,10 +15071,10 @@ var require_react_reconciler_development = __commonJS({
15071
15071
  setCurrentUpdatePriority(previousPriority), ReactSharedInternals.T = prevTransition;
15072
15072
  }
15073
15073
  };
15074
- exports2.discreteUpdates = function(fn, a, b, c, d) {
15074
+ exports2.discreteUpdates = function(fn, a, b6, c, d) {
15075
15075
  var prevTransition = ReactSharedInternals.T, previousPriority = getCurrentUpdatePriority();
15076
15076
  try {
15077
- return setCurrentUpdatePriority(2), ReactSharedInternals.T = null, fn(a, b, c, d);
15077
+ return setCurrentUpdatePriority(2), ReactSharedInternals.T = null, fn(a, b6, c, d);
15078
15078
  } finally {
15079
15079
  setCurrentUpdatePriority(previousPriority), ReactSharedInternals.T = prevTransition, executionContext === NoContext && (workInProgressRootRenderTargetTime = now$1() + RENDER_TIMEOUT_MS);
15080
15080
  }
@@ -15357,24 +15357,1166 @@ var require_constants = __commonJS({
15357
15357
  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
- import * as gui19 from "gui";
15361
- import * as os3 from "os";
15360
+ import * as gui18 from "gui";
15361
+ import * as os5 from "os";
15362
15362
 
15363
15363
  // _build/lib/react-qw/index.js
15364
- import * as gui18 from "gui";
15364
+ import * as gui17 from "gui";
15365
+
15366
+ // _build/lib/windows/user32.js
15367
+ import * as os3 from "os";
15368
+
15369
+ // _build/lib/ffi/bind.js
15370
+ import * as ffi from "ffi";
15371
+ import * as os2 from "os";
15372
+ import * as std from "std";
15373
+ import * as win from "win";
15374
+
15375
+ // _build/lib/text-codec.js
15376
+ var _labelMap = {
15377
+ "utf-8": "utf-8",
15378
+ "utf8": "utf-8",
15379
+ "unicode-1-1-utf-8": "utf-8",
15380
+ "utf-16": "utf-16le",
15381
+ "utf-16le": "utf-16le",
15382
+ "utf-16be": "utf-16be"
15383
+ };
15384
+ function _normalizeLabel(label) {
15385
+ if (!label)
15386
+ return "utf-8";
15387
+ const result = _labelMap[label.trim().toLowerCase()];
15388
+ if (result)
15389
+ return result;
15390
+ throw new RangeError(`The encoding label "${label}" is not supported`);
15391
+ }
15392
+ function _decodeUTF8(buf, fatal) {
15393
+ let out = "";
15394
+ for (let i = 0; i < buf.length; ) {
15395
+ const b6 = buf[i++];
15396
+ if (b6 < 128) {
15397
+ out += String.fromCharCode(b6);
15398
+ continue;
15399
+ }
15400
+ if (b6 < 192) {
15401
+ out += fatal ? (() => {
15402
+ throw new TypeError("unexpected continuation byte");
15403
+ })() : "\uFFFD";
15404
+ continue;
15405
+ }
15406
+ let c, min;
15407
+ if (b6 < 224) {
15408
+ if (i >= buf.length) {
15409
+ out += fatal ? (() => {
15410
+ throw new TypeError("incomplete utf-8");
15411
+ })() : "\uFFFD";
15412
+ break;
15413
+ }
15414
+ const b22 = buf[i++];
15415
+ if ((b22 & 192) !== 128) {
15416
+ out += "\uFFFD";
15417
+ continue;
15418
+ }
15419
+ c = (b6 & 31) << 6 | b22 & 63;
15420
+ min = 128;
15421
+ } else if (b6 < 240) {
15422
+ if (i + 1 >= buf.length) {
15423
+ out += fatal ? (() => {
15424
+ throw new TypeError("incomplete utf-8");
15425
+ })() : "\uFFFD";
15426
+ break;
15427
+ }
15428
+ const b22 = buf[i++];
15429
+ const b32 = buf[i++];
15430
+ if ((b22 & 192) !== 128 || (b32 & 192) !== 128) {
15431
+ out += "\uFFFD";
15432
+ continue;
15433
+ }
15434
+ c = (b6 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
15435
+ min = 2048;
15436
+ } else if (b6 < 248) {
15437
+ if (i + 2 >= buf.length) {
15438
+ out += fatal ? (() => {
15439
+ throw new TypeError("incomplete utf-8");
15440
+ })() : "\uFFFD";
15441
+ break;
15442
+ }
15443
+ const b22 = buf[i++];
15444
+ const b32 = buf[i++];
15445
+ const b42 = buf[i++];
15446
+ if ((b22 & 192) !== 128 || (b32 & 192) !== 128 || (b42 & 192) !== 128) {
15447
+ out += "\uFFFD";
15448
+ continue;
15449
+ }
15450
+ c = (b6 & 7) << 18 | (b22 & 63) << 12 | (b32 & 63) << 6 | b42 & 63;
15451
+ min = 65536;
15452
+ } else {
15453
+ out += fatal ? (() => {
15454
+ throw new TypeError("invalid utf-8 start");
15455
+ })() : "\uFFFD";
15456
+ continue;
15457
+ }
15458
+ if (c < min || c >= 55296 && c <= 57343 || c > 1114111) {
15459
+ out += fatal ? (() => {
15460
+ throw new TypeError("invalid utf-8 codepoint");
15461
+ })() : "\uFFFD";
15462
+ continue;
15463
+ }
15464
+ if (c <= 65535)
15465
+ out += String.fromCharCode(c);
15466
+ else {
15467
+ c -= 65536;
15468
+ out += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
15469
+ }
15470
+ }
15471
+ return out;
15472
+ }
15473
+ function _decodeUTF16(buf, le, fatal) {
15474
+ const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
15475
+ let out = "";
15476
+ for (let i = 0; i + 1 < buf.length; i += 2) {
15477
+ let c = dv.getUint16(i, le);
15478
+ if (c >= 55296 && c <= 56319) {
15479
+ i += 2;
15480
+ if (i + 1 >= buf.length) {
15481
+ out += fatal ? (() => {
15482
+ throw new TypeError("truncated surrogate pair");
15483
+ })() : "\uFFFD";
15484
+ break;
15485
+ }
15486
+ const c2 = dv.getUint16(i, le);
15487
+ if (c2 >= 56320 && c2 <= 57343) {
15488
+ out += String.fromCharCode(c, c2);
15489
+ } else {
15490
+ out += fatal ? (() => {
15491
+ throw new TypeError("invalid surrogate pair");
15492
+ })() : "\uFFFD";
15493
+ i -= 2;
15494
+ }
15495
+ } else if (c >= 56320 && c <= 57343) {
15496
+ out += fatal ? (() => {
15497
+ throw new TypeError("unexpected trailing surrogate");
15498
+ })() : "\uFFFD";
15499
+ } else {
15500
+ out += String.fromCharCode(c);
15501
+ }
15502
+ }
15503
+ return out;
15504
+ }
15505
+ var TextDecoderImpl = class {
15506
+ _encoding;
15507
+ _fatal;
15508
+ _ignoreBOM;
15509
+ constructor(label, options) {
15510
+ this._encoding = _normalizeLabel(label);
15511
+ this._fatal = options?.fatal ?? false;
15512
+ this._ignoreBOM = options?.ignoreBOM ?? false;
15513
+ }
15514
+ get encoding() {
15515
+ return this._encoding;
15516
+ }
15517
+ get fatal() {
15518
+ return this._fatal;
15519
+ }
15520
+ get ignoreBOM() {
15521
+ return this._ignoreBOM;
15522
+ }
15523
+ decode(buffer) {
15524
+ if (!buffer)
15525
+ return "";
15526
+ const arr = buffer instanceof Uint8Array ? buffer : buffer instanceof ArrayBuffer ? new Uint8Array(buffer) : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
15527
+ if (this._encoding === "utf-8") {
15528
+ return _decodeUTF8(arr, this._fatal);
15529
+ }
15530
+ const le = this._encoding === "utf-16le";
15531
+ let offset = 0;
15532
+ if (arr.length >= 2 && !this._ignoreBOM) {
15533
+ const bomLo = le ? arr[0] : arr[1];
15534
+ const bomHi = le ? arr[1] : arr[0];
15535
+ const bom = bomHi << 8 | bomLo;
15536
+ if (bom === 65279 || bom === 65534) {
15537
+ offset = 2;
15538
+ }
15539
+ }
15540
+ return _decodeUTF16(arr.slice(offset), le, this._fatal);
15541
+ }
15542
+ };
15543
+ var TextEncoderImpl = class {
15544
+ _encoding;
15545
+ constructor(label) {
15546
+ this._encoding = _normalizeLabel(label);
15547
+ }
15548
+ get encoding() {
15549
+ return this._encoding;
15550
+ }
15551
+ encode(input) {
15552
+ if (!input)
15553
+ return new Uint8Array(0);
15554
+ if (this._encoding === "utf-8") {
15555
+ const bytes = [];
15556
+ for (let i = 0; i < input.length; i++) {
15557
+ let c = input.charCodeAt(i);
15558
+ if (c < 128) {
15559
+ bytes.push(c);
15560
+ } else if (c < 2048) {
15561
+ bytes.push(192 | c >> 6, 128 | c & 63);
15562
+ } else if (c < 55296 || c >= 57344) {
15563
+ bytes.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
15564
+ } else {
15565
+ i++;
15566
+ const c2 = input.charCodeAt(i);
15567
+ c = 65536 + ((c & 1023) << 10) | c2 & 1023;
15568
+ bytes.push(240 | c >> 18, 128 | c >> 12 & 63, 128 | c >> 6 & 63, 128 | c & 63);
15569
+ }
15570
+ }
15571
+ return new Uint8Array(bytes);
15572
+ }
15573
+ const le = this._encoding === "utf-16le";
15574
+ const buf = new ArrayBuffer(input.length * 2);
15575
+ const dv = new DataView(buf);
15576
+ for (let i = 0; i < input.length; i++)
15577
+ dv.setUint16(i * 2, input.charCodeAt(i), le);
15578
+ return new Uint8Array(buf);
15579
+ }
15580
+ };
15581
+ if (typeof globalThis.TextDecoder === "undefined") {
15582
+ globalThis.TextDecoder = TextDecoderImpl;
15583
+ }
15584
+ if (typeof globalThis.TextEncoder === "undefined") {
15585
+ globalThis.TextEncoder = TextEncoderImpl;
15586
+ }
15587
+
15588
+ // _build/lib/ffi/ctype.js
15589
+ import { bufferPtr } from "ffi";
15590
+ import * as os from "os";
15591
+ var C_BASIC_TYPE = [
15592
+ "void",
15593
+ "u8",
15594
+ "i8",
15595
+ "u16",
15596
+ "i16",
15597
+ "u32",
15598
+ "i32",
15599
+ "u64",
15600
+ "i64",
15601
+ "f32",
15602
+ "f64",
15603
+ "ptr"
15604
+ ];
15605
+ var PTR_TOKEN_RE = /^<([^<>\s]*)>ptr(!|@[A-Za-z_]\w*)?$/;
15606
+ function isCPtrToken(t) {
15607
+ return PTR_TOKEN_RE.test(t);
15608
+ }
15609
+ function ptrName(t) {
15610
+ const m = PTR_TOKEN_RE.exec(t);
15611
+ return m?.[1] || "";
15612
+ }
15613
+ var cTokenToType = (t) => {
15614
+ if (isCPtrToken(t))
15615
+ return "ptr";
15616
+ else
15617
+ return t;
15618
+ };
15619
+ var PTR_SIZE = os.arch === "x64" ? 8 : 4;
15620
+ var SizeAlign = {
15621
+ u8: 1,
15622
+ i8: 1,
15623
+ u16: 2,
15624
+ i16: 2,
15625
+ u32: 4,
15626
+ i32: 4,
15627
+ u64: 8,
15628
+ i64: 8,
15629
+ f32: 4,
15630
+ f64: 8
15631
+ };
15632
+ var NULL = 0;
15633
+ function normToken(t) {
15634
+ if (isCPtrToken(t)) {
15635
+ const m = PTR_TOKEN_RE.exec(t);
15636
+ return m?.[2]?.startsWith("@") ? `<${m[1]}>ptr` : t;
15637
+ }
15638
+ const at = t.indexOf("@");
15639
+ const base = at >= 0 ? t.slice(0, at) : t;
15640
+ const suffixOk = at < 0 || /^[A-Za-z_]\w*$/.test(t.slice(at + 1));
15641
+ if (suffixOk && base !== "ptr" && C_BASIC_TYPE.includes(base))
15642
+ return base;
15643
+ throw new Error("Unknown token: " + t);
15644
+ }
15645
+ function readScalar(dv, off, k) {
15646
+ switch (k) {
15647
+ case "u8":
15648
+ return dv.getUint8(off);
15649
+ case "i8":
15650
+ return dv.getInt8(off);
15651
+ case "u16":
15652
+ return dv.getUint16(off, true);
15653
+ case "i16":
15654
+ return dv.getInt16(off, true);
15655
+ case "u32":
15656
+ return dv.getUint32(off, true);
15657
+ case "i32":
15658
+ return dv.getInt32(off, true);
15659
+ case "u64":
15660
+ return dv.getBigUint64(off, true);
15661
+ case "i64":
15662
+ return dv.getBigInt64(off, true);
15663
+ case "f32":
15664
+ return dv.getFloat32(off, true);
15665
+ case "f64":
15666
+ return dv.getFloat64(off, true);
15667
+ case "ptr": {
15668
+ return PTR_SIZE === 8 ? Number(dv.getBigInt64(off, true)) : dv.getInt32(off, true);
15669
+ }
15670
+ }
15671
+ }
15672
+ function writeScalar(dv, off, { k, v }) {
15673
+ switch (k) {
15674
+ case "u8":
15675
+ dv.setUint8(off, Number(v));
15676
+ break;
15677
+ case "i8":
15678
+ dv.setInt8(off, Number(v));
15679
+ break;
15680
+ case "u16":
15681
+ dv.setUint16(off, Number(v), true);
15682
+ break;
15683
+ case "i16":
15684
+ dv.setInt16(off, Number(v), true);
15685
+ break;
15686
+ case "u32":
15687
+ dv.setUint32(off, v >>> 0, true);
15688
+ break;
15689
+ case "i32":
15690
+ dv.setUint32(off, v >>> 0, true);
15691
+ break;
15692
+ case "u64":
15693
+ dv.setBigUint64(off, v, true);
15694
+ break;
15695
+ case "i64":
15696
+ dv.setBigInt64(off, v, true);
15697
+ break;
15698
+ case "f32":
15699
+ dv.setFloat32(off, v, true);
15700
+ break;
15701
+ case "f64":
15702
+ dv.setFloat64(off, v, true);
15703
+ break;
15704
+ case "ptr": {
15705
+ if (v == null) {
15706
+ throw new Error("ffi: got null/undefined for a ptr slot; pass the imported NULL constant for empty");
15707
+ }
15708
+ if (PTR_SIZE === 8)
15709
+ dv.setBigUint64(off, BigInt.asUintN(64, BigInt(v)), true);
15710
+ else
15711
+ dv.setUint32(off, v >>> 0, true);
15712
+ break;
15713
+ }
15714
+ }
15715
+ }
15716
+ function writeSlot(dv, off, e) {
15717
+ const { k, v } = e;
15718
+ if (k === "u8" || k === "i8" || k === "u16" || k === "i16") {
15719
+ dv.setUint32(off, Number(v) >>> 0, true);
15720
+ return;
15721
+ }
15722
+ writeScalar(dv, off, e);
15723
+ }
15724
+ var PtrArrayBuffer = class extends ArrayBuffer {
15725
+ ptr;
15726
+ constructor(byteLength) {
15727
+ super(byteLength);
15728
+ this.ptr = bufferPtr(this);
15729
+ }
15730
+ };
15731
+
15732
+ // _build/lib/ffi/bind.js
15733
+ var _dllCache = /* @__PURE__ */ new Map();
15734
+ function loadDll(dll) {
15735
+ const cached = _dllCache.get(dll);
15736
+ if (cached !== void 0)
15737
+ return cached;
15738
+ const loaded = win.LoadLibrary(dll);
15739
+ if (!loaded)
15740
+ throw new Error(`ffi-bind: LoadLibrary("${dll}") failed`);
15741
+ _dllCache.set(dll, loaded);
15742
+ return loaded;
15743
+ }
15744
+ function parseSig(sig) {
15745
+ const parts = sig.split(" -> ");
15746
+ if (parts.length !== 2) {
15747
+ throw new Error(`ffi-bind: invalid signature "${sig}" (expected "arg1 arg2 -> ret")`);
15748
+ }
15749
+ const rawArgs = parts[0].split(" ").filter((t) => t !== "");
15750
+ const argTokens = [];
15751
+ for (const raw of rawArgs) {
15752
+ const tok = normToken(raw);
15753
+ if (tok === "void") {
15754
+ throw new Error("Void can not in args");
15755
+ }
15756
+ argTokens.push(tok);
15757
+ }
15758
+ return {
15759
+ argTokens,
15760
+ retToken: normToken(parts[1]),
15761
+ sig
15762
+ };
15763
+ }
15764
+ function makeFn(proc, sig, encoders, decoders) {
15765
+ const ps = parseSig(sig);
15766
+ return (...a) => callPacked(proc, ps, a, encoders, decoders);
15767
+ }
15768
+ var IA32_ARG_SIZE = {
15769
+ u8: 4,
15770
+ i8: 4,
15771
+ u16: 4,
15772
+ i16: 4,
15773
+ u32: 4,
15774
+ i32: 4,
15775
+ u64: 8,
15776
+ i64: 8,
15777
+ f32: 4,
15778
+ f64: 8,
15779
+ ptr: PTR_SIZE
15780
+ };
15781
+ var X64_MIN_SLOTS = 4;
15782
+ function callPacked(proc, { argTokens, retToken, sig }, args, encoders, decoders) {
15783
+ const is64 = os2.arch === "x64";
15784
+ const getWidth = (t, is642) => {
15785
+ if (is642)
15786
+ return 8;
15787
+ if (isCPtrToken(t))
15788
+ return PTR_SIZE;
15789
+ return IA32_ARG_SIZE[t];
15790
+ };
15791
+ let total = 0;
15792
+ for (const t of argTokens)
15793
+ total += getWidth(t, is64);
15794
+ if (is64 && argTokens.length < X64_MIN_SLOTS)
15795
+ total = X64_MIN_SLOTS * 8;
15796
+ const argFrame = new ArrayBuffer(total);
15797
+ const dv = new DataView(argFrame);
15798
+ const held = [];
15799
+ let off = 0;
15800
+ for (let i = 0; i < argTokens.length; i++) {
15801
+ const argToken = argTokens[i];
15802
+ const nonnull = argToken.endsWith("!");
15803
+ const arg = args[i];
15804
+ if (isCPtrToken(argToken)) {
15805
+ const name = ptrName(argToken);
15806
+ if (typeof arg === "number") {
15807
+ if (nonnull && arg === 0)
15808
+ throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! got 0 (null pointer forbidden here; the token marks this position non-null)`);
15809
+ writeSlot(dv, off, { k: "ptr", v: arg });
15810
+ } else {
15811
+ if (arg === null || arg === void 0) {
15812
+ throw new Error(`ffi-bind: <${name}>ptr got ${String(arg)}; pass the imported NULL constant for an empty pointer`);
15813
+ }
15814
+ const codec = encoders[name];
15815
+ if (!codec) {
15816
+ throw new Error(name === "" ? `ffi-bind: <>ptr expects number (NULL | Ptr), got ${typeof arg}; use <BYTE>ptr with a PtrArrayBuffer (new PtrArrayBuffer(n)), or ffi.bufferPtr(buf) for an address` : `ffi-bind: unknown layout "<${name}>ptr" (available: ${Object.keys(encoders).join(", ") || "none"})`);
15817
+ }
15818
+ if (!codec.encode) {
15819
+ throw new Error(`ffi-bind: <${name}>ptr has no encoder (out-only codec)`);
15820
+ }
15821
+ const buf = codec.encode(arg);
15822
+ held.push(buf);
15823
+ const p = buf.ptr;
15824
+ if (typeof p !== "number")
15825
+ throw new Error("ffi-bind: codec.encode must return a PtrArrayBuffer, got plain ArrayBuffer");
15826
+ if (nonnull && p === 0)
15827
+ throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! encode produced 0 (null pointer forbidden here)`);
15828
+ writeSlot(dv, off, { k: "ptr", v: p });
15829
+ }
15830
+ } else {
15831
+ writeSlot(dv, off, { k: argToken, v: arg });
15832
+ }
15833
+ off += getWidth(argToken, is64);
15834
+ }
15835
+ const retBuf = new ArrayBuffer(8);
15836
+ const retIsFp = retToken === "f32" || retToken === "f64";
15837
+ ffi.ffiCall(proc, argFrame, retBuf, retIsFp ? 1 : 0);
15838
+ const raw = readRet(cTokenToType(retToken), retBuf);
15839
+ if (retToken.endsWith("!") && raw === 0)
15840
+ throw new Error(`ffi-bind: ${sig}: return ${retToken} got 0 (the token promises C never returns null here)`);
15841
+ if (isCPtrToken(retToken) && raw !== 0) {
15842
+ const name = ptrName(retToken);
15843
+ if (name !== "") {
15844
+ const codec = decoders[name];
15845
+ if (codec?.decode)
15846
+ return codec.decode(raw);
15847
+ }
15848
+ }
15849
+ return raw;
15850
+ }
15851
+ function readRet(ret, retBuf) {
15852
+ if (ret === "void")
15853
+ return void 0;
15854
+ return readScalar(new DataView(retBuf), 0, ret);
15855
+ }
15856
+ var WCHAR = {
15857
+ encode: (v) => {
15858
+ const u8 = new TextEncoder("utf-16le").encode(v + "\0");
15859
+ const out = new PtrArrayBuffer(u8.byteLength);
15860
+ new Uint8Array(out).set(u8);
15861
+ return out;
15862
+ },
15863
+ decode: (p) => {
15864
+ if (typeof p === "number") {
15865
+ let s2 = "";
15866
+ let addr = p;
15867
+ const start = addr;
15868
+ for (; ; ) {
15869
+ const lo = ffi.readByte(addr);
15870
+ const hi = ffi.readByte(addr + 1);
15871
+ if (lo === 0 && hi === 0)
15872
+ return s2;
15873
+ s2 += String.fromCharCode(lo | hi << 8);
15874
+ addr += 2;
15875
+ if (addr - start > 1 << 21) {
15876
+ throw new Error("ffi-bind: WCHAR decode exceeded 4MiB without NUL");
15877
+ }
15878
+ }
15879
+ }
15880
+ const u8 = new Uint8Array(p);
15881
+ const limit = u8.length & ~1;
15882
+ let s = "";
15883
+ for (let i = 0; i < limit; i += 2) {
15884
+ const c = u8[i] | u8[i + 1] << 8;
15885
+ if (c === 0)
15886
+ return s;
15887
+ s += String.fromCharCode(c);
15888
+ }
15889
+ return s;
15890
+ },
15891
+ alloc: (size = 256) => new PtrArrayBuffer(size * 2)
15892
+ };
15893
+ var BYTE = {
15894
+ encode: (v) => {
15895
+ if (!(v instanceof PtrArrayBuffer))
15896
+ throw new Error("ffi-bind: <BYTE>ptr wants a PtrArrayBuffer (new PtrArrayBuffer(n) / BYTE.alloc / struct.encode), not a plain ArrayBuffer");
15897
+ return v;
15898
+ },
15899
+ alloc: (byteLen) => new PtrArrayBuffer(byteLen)
15900
+ };
15901
+ var builtinCodecs = { WCHAR, BYTE };
15902
+ function bind(dll, name, sig, encoders, decoders) {
15903
+ const proc = win.GetProcAddress(loadDll(dll), name);
15904
+ if (!proc)
15905
+ throw new Error(`ffi-bind: proc "${name}" not found in ${dll}`);
15906
+ const effDec = decoders ?? encoders;
15907
+ return makeFn(proc, sig, { ...builtinCodecs, ...encoders }, { ...builtinCodecs, ...effDec ?? {} });
15908
+ }
15909
+ var leakRegistry = new FinalizationRegistry((held) => {
15910
+ std.printf('[ffi] closure leaked (GCed without dispose): sig="%s" ptr=0x%x\n', held.sig, held.ptr);
15911
+ });
15912
+
15913
+ // _build/lib/ffi/struct.js
15914
+ import * as ffi2 from "ffi";
15915
+ function alignUp(v, a) {
15916
+ return v + a - 1 & ~(a - 1);
15917
+ }
15918
+ var isCNumberToken = (t) => SizeAlign[t] !== void 0;
15919
+ function lower(v) {
15920
+ if (typeof v === "string") {
15921
+ const st = /^(u8|u16)\[(\d+)\]@(utf-8|utf-16le)$/.exec(v);
15922
+ if (st) {
15923
+ const length = Number(st[2]);
15924
+ if (!Number.isInteger(length) || length < 1)
15925
+ throw new Error(`ffi-struct: string length must be an integer >= 1, got ${length}`);
15926
+ const s2 = st[1] === "u8" ? 1 : 2;
15927
+ return { size: s2 * length, align: s2, type: { tag: "string", encoding: st[3] } };
15928
+ }
15929
+ const a = /^([^\[\]]+)\[(\d+)\]$/.exec(v);
15930
+ if (a) {
15931
+ const length = Number(a[2]);
15932
+ if (!Number.isInteger(length) || length < 1)
15933
+ throw new Error(`ffi-struct: array length must be an integer >= 1, got ${length}`);
15934
+ const el = lower(a[1]);
15935
+ if (el.type.tag === "bitfield")
15936
+ throw new Error("ffi-struct: bitfields cannot be array elements");
15937
+ return {
15938
+ size: el.size * length,
15939
+ align: el.align,
15940
+ type: { tag: "array", elementType: el.type, elementSize: el.size }
15941
+ };
15942
+ }
15943
+ const b6 = /^([A-Za-z_]\w*):(\d+)$/.exec(v);
15944
+ if (b6) {
15945
+ const rawUnit = b6[1];
15946
+ const unit = normToken(rawUnit);
15947
+ if (!isCNumberToken(unit) || unit === "f32" || unit === "f64")
15948
+ throw new Error(`ffi-struct: bitfield unit must be an integer type, got "${rawUnit}"`);
15949
+ const width = Number(b6[2]);
15950
+ const s2 = SizeAlign[unit];
15951
+ const cap = s2 * 8;
15952
+ if (!Number.isInteger(width) || width < 1)
15953
+ throw new Error(`ffi-struct: bitfield width must be an integer >= 1, got ${width}`);
15954
+ if (width > cap)
15955
+ throw new Error(`ffi-struct: bitfield width ${width} exceeds unit width ${cap}`);
15956
+ return { size: s2, align: s2, type: { tag: "bitfield", unit, bit: 0, width } };
15957
+ }
15958
+ const k = normToken(v);
15959
+ if (isCPtrToken(k))
15960
+ return { size: PTR_SIZE, align: PTR_SIZE, type: { tag: "basic", kind: "ptr" } };
15961
+ if (!isCNumberToken(k))
15962
+ throw new Error(`ffi-struct: unknown kind "${v}"`);
15963
+ const s = SizeAlign[k];
15964
+ return { size: s, align: s, type: { tag: "basic", kind: k } };
15965
+ }
15966
+ if (v && typeof v === "object") {
15967
+ const o = v;
15968
+ const tag = o["#"];
15969
+ if (tag === void 0)
15970
+ throw new Error(`ffi-struct: nested object value requires a '#' key ('struct' | 'union' | 'array')`);
15971
+ if (tag === "array" && "#pack" in o)
15972
+ throw new Error(`ffi-struct: '#pack' is only allowed on struct/union, got '${tag}'`);
15973
+ if (tag === "array") {
15974
+ const length = o["length"];
15975
+ if (!Number.isInteger(length) || length < 1)
15976
+ throw new Error(`ffi-struct: array length must be an integer >= 1, got ${String(length)}`);
15977
+ const el = lower(o["element"]);
15978
+ if (el.type.tag === "bitfield")
15979
+ throw new Error("ffi-struct: bitfields cannot be array elements");
15980
+ return {
15981
+ size: el.size * length,
15982
+ align: el.align,
15983
+ type: { tag: "array", elementType: el.type, elementSize: el.size }
15984
+ };
15985
+ }
15986
+ if (tag === "struct" || tag === "union") {
15987
+ const l = computeStructLayout(v);
15988
+ return { size: l.size, align: l.maxEffectiveAlign, type: { tag, fields: l.fields } };
15989
+ }
15990
+ throw new Error(`ffi-struct: unknown '#' declaration ${JSON.stringify(String(tag))}`);
15991
+ }
15992
+ throw new Error(`ffi-struct: invalid member value: ${String(v)}`);
15993
+ }
15994
+ function computeStructLayout(t) {
15995
+ const isStruct = t["#"] === "struct";
15996
+ const pack = t["#pack"] ?? 8;
15997
+ let maxEffectiveAlign = 1;
15998
+ let maxMemberSize = 0;
15999
+ const fields = [];
16000
+ let cursor = 0;
16001
+ let unitBase = -1;
16002
+ let unitBits = 0;
16003
+ let unitSize = 0;
16004
+ const flushUnit = () => {
16005
+ if (unitBase < 0)
16006
+ return;
16007
+ cursor = alignUp(unitBase + Math.ceil(unitBits / 8), unitSize);
16008
+ unitBase = -1;
16009
+ };
16010
+ for (const [rawName, v] of Object.entries(t)) {
16011
+ if (rawName.startsWith("#"))
16012
+ continue;
16013
+ const m = /^([^@]+)@(\d+)$/.exec(rawName);
16014
+ const name = m ? m[1] : rawName;
16015
+ const alignas = m ? Number(m[2]) : 0;
16016
+ const { size, align: natural, type } = lower(v);
16017
+ const nonnull = typeof v === "string" && v.endsWith("!");
16018
+ let align = natural;
16019
+ if (pack > 0)
16020
+ align = Math.min(pack, align);
16021
+ if (alignas)
16022
+ align = Math.max(align, alignas);
16023
+ if (type.tag === "bitfield") {
16024
+ if (name.startsWith("$"))
16025
+ throw new Error("ffi-struct: bitfield members must be named");
16026
+ if (!isStruct) {
16027
+ fields.push({ name, offset: 0, size, type: { ...type, bit: 0 } });
16028
+ maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
16029
+ maxMemberSize = Math.max(maxMemberSize, size);
16030
+ continue;
16031
+ }
16032
+ const width = type.width;
16033
+ if (unitBase < 0 || size !== unitSize || unitBits + width > unitSize * 8) {
16034
+ if (unitBase >= 0)
16035
+ flushUnit();
16036
+ const offset2 = alignUp(cursor, align);
16037
+ unitBase = offset2;
16038
+ unitBits = 0;
16039
+ unitSize = size;
16040
+ }
16041
+ fields.push({
16042
+ name,
16043
+ offset: unitBase,
16044
+ // 单元基址(不是位域自己的地址)
16045
+ size,
16046
+ type: { ...type, bit: unitBits }
16047
+ });
16048
+ unitBits += width;
16049
+ maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
16050
+ maxMemberSize = Math.max(maxMemberSize, size);
16051
+ continue;
16052
+ }
16053
+ flushUnit();
16054
+ const offset = alignUp(cursor, align);
16055
+ if (!name.startsWith("$")) {
16056
+ fields.push({ name, offset, size, type, ...nonnull ? { nonnull: true } : {} });
16057
+ } else {
16058
+ if (type.tag !== "struct" && type.tag !== "union")
16059
+ throw new Error(`ffi-struct: anonymous member "${name}" must be a struct/union`);
16060
+ for (const cf of type.fields)
16061
+ fields.push({ ...cf, offset: cf.offset + offset });
16062
+ }
16063
+ if (isStruct)
16064
+ cursor = offset + size;
16065
+ maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
16066
+ maxMemberSize = Math.max(maxMemberSize, size);
16067
+ }
16068
+ flushUnit();
16069
+ return {
16070
+ size: isStruct ? alignUp(cursor, maxEffectiveAlign) : alignUp(maxMemberSize, maxEffectiveAlign),
16071
+ maxEffectiveAlign,
16072
+ fields
16073
+ };
16074
+ }
16075
+ function readUnitRaw(dv, off, unit) {
16076
+ const s = SizeAlign[unit];
16077
+ if (s === 1)
16078
+ return BigInt(dv.getUint8(off));
16079
+ if (s === 2)
16080
+ return BigInt(dv.getUint16(off, true));
16081
+ if (s === 4)
16082
+ return BigInt(dv.getUint32(off, true));
16083
+ return dv.getBigUint64(off, true);
16084
+ }
16085
+ function writeUnitRaw(dv, off, unit, v) {
16086
+ const s = SizeAlign[unit];
16087
+ if (s === 1) {
16088
+ dv.setUint8(off, Number(v & 0xffn));
16089
+ return;
16090
+ }
16091
+ if (s === 2) {
16092
+ dv.setUint16(off, Number(v & 0xffffn), true);
16093
+ return;
16094
+ }
16095
+ if (s === 4) {
16096
+ dv.setUint32(off, Number(v & 0xffffffffn), true);
16097
+ return;
16098
+ }
16099
+ dv.setBigUint64(off, v & 0xffffffffffffffffn, true);
16100
+ }
16101
+ function readBitfield(dv, off, t) {
16102
+ const w = BigInt(t.width);
16103
+ let v = readUnitRaw(dv, off, t.unit) >> BigInt(t.bit) & (1n << w) - 1n;
16104
+ if (t.unit[0] === "i" && v & 1n << w - 1n)
16105
+ v -= 1n << w;
16106
+ if (t.width > 53)
16107
+ return v;
16108
+ return Number(v);
16109
+ }
16110
+ function writeBitfield(dv, off, t, val) {
16111
+ const w = BigInt(t.width);
16112
+ const bit = BigInt(t.bit);
16113
+ const widthMask = (1n << w) - 1n;
16114
+ const posMask = widthMask << bit;
16115
+ const raw = readUnitRaw(dv, off, t.unit);
16116
+ const bits = (typeof val === "bigint" ? val : BigInt(Math.trunc(val))) & widthMask;
16117
+ writeUnitRaw(dv, off, t.unit, raw & ~posMask | bits << bit);
16118
+ }
16119
+ var stringEncoders = {
16120
+ "utf-8": new TextEncoder("utf-8"),
16121
+ "utf-16le": new TextEncoder("utf-16le")
16122
+ };
16123
+ var stringDecoders = {
16124
+ "utf-8": new TextDecoder("utf-8", { ignoreBOM: true }),
16125
+ "utf-16le": new TextDecoder("utf-16le", { ignoreBOM: true })
16126
+ };
16127
+ function readString(dv, off, size, enc) {
16128
+ const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
16129
+ const unit = enc === "utf-16le" ? 2 : 1;
16130
+ let end = size;
16131
+ for (let i = 0; i + unit <= size; i += unit) {
16132
+ if (bytes[i] === 0 && (unit === 1 || bytes[i + 1] === 0)) {
16133
+ end = i;
16134
+ break;
16135
+ }
16136
+ }
16137
+ return stringDecoders[enc].decode(bytes.subarray(0, end));
16138
+ }
16139
+ function writeString(dv, off, size, enc, v) {
16140
+ const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
16141
+ bytes.fill(0);
16142
+ const unit = enc === "utf-16le" ? 2 : 1;
16143
+ const cap = size - unit;
16144
+ if (cap <= 0)
16145
+ return;
16146
+ const src = stringEncoders[enc].encode(String(v ?? ""));
16147
+ bytes.set(src.subarray(0, Math.min(src.length, cap)));
16148
+ }
16149
+ function readArray(dv, off, size, t) {
16150
+ const count = t.elementSize > 0 ? size / t.elementSize : 0;
16151
+ const out = [];
16152
+ for (let i = 0; i < count; i++)
16153
+ out.push(readElement(dv, off + i * t.elementSize, t.elementType, t.elementSize));
16154
+ return out;
16155
+ }
16156
+ function writeArray(dv, off, size, t, v) {
16157
+ const count = t.elementSize > 0 ? size / t.elementSize : 0;
16158
+ const list = v ?? [];
16159
+ for (let i = 0; i < count; i++)
16160
+ writeElement(dv, off + i * t.elementSize, t.elementType, t.elementSize, list[i]);
16161
+ }
16162
+ function readElement(dv, off, t, size) {
16163
+ switch (t.tag) {
16164
+ case "basic":
16165
+ return readScalar(dv, off, t.kind);
16166
+ case "bitfield":
16167
+ return readBitfield(dv, off, t);
16168
+ case "string":
16169
+ return readString(dv, off, size, t.encoding);
16170
+ case "struct":
16171
+ case "union":
16172
+ return doDecode(dv, off, t.fields);
16173
+ case "array":
16174
+ return readArray(dv, off, size, t);
16175
+ }
16176
+ }
16177
+ function writeElement(dv, off, t, size, val) {
16178
+ switch (t.tag) {
16179
+ // TODO: remove this any
16180
+ case "basic":
16181
+ writeScalar(dv, off, { k: t.kind, v: val });
16182
+ break;
16183
+ // 直传(不 Number()):writeBitfield 的 val 是 number | bigint,
16184
+ // 64 位单元走 bigint,先 Number() 会把 >2^53 的位域值截断。
16185
+ case "bitfield":
16186
+ writeBitfield(dv, off, t, val ?? 0);
16187
+ break;
16188
+ case "string":
16189
+ writeString(dv, off, size, t.encoding, val);
16190
+ break;
16191
+ case "struct":
16192
+ case "union":
16193
+ doEncode(dv, off, t.fields, val ?? {});
16194
+ break;
16195
+ case "array":
16196
+ writeArray(dv, off, size, t, val);
16197
+ break;
16198
+ }
16199
+ }
16200
+ function doDecode(dv, base, fields) {
16201
+ const out = {};
16202
+ for (const f of fields) {
16203
+ const v = readElement(dv, base + f.offset, f.type, f.size);
16204
+ if (f.nonnull && v === 0)
16205
+ throw new Error(`ffi-struct: decode: '!' field "${f.name}" got 0 (C did not fill it, or decode was called on an unfilled slot)`);
16206
+ out[f.name] = v;
16207
+ }
16208
+ return out;
16209
+ }
16210
+ function doEncode(dv, base, fields, v) {
16211
+ for (const f of fields) {
16212
+ if (v[f.name] === void 0)
16213
+ continue;
16214
+ writeElement(dv, base + f.offset, f.type, f.size, v[f.name]);
16215
+ }
16216
+ }
16217
+ function createStruct(t) {
16218
+ const { fields, size, maxEffectiveAlign } = computeStructLayout(t);
16219
+ return {
16220
+ __struct: t,
16221
+ size,
16222
+ structAlign: maxEffectiveAlign,
16223
+ decode: (p) => {
16224
+ if (typeof p === "number") {
16225
+ const buf = new ArrayBuffer(size);
16226
+ const u8 = new Uint8Array(buf);
16227
+ for (let i = 0; i < size; i++)
16228
+ u8[i] = ffi2.readByte(p + i);
16229
+ return doDecode(new DataView(buf), 0, fields);
16230
+ }
16231
+ return doDecode(new DataView(p), 0, fields);
16232
+ },
16233
+ alloc: (() => new PtrArrayBuffer(size)),
16234
+ encode: ((v, buf) => {
16235
+ if (v === void 0 || v === null)
16236
+ throw new Error(`ffi-struct: encode(v) requires an argument; use alloc() for a zeroed out-param slot`);
16237
+ const out = buf ?? new PtrArrayBuffer(size);
16238
+ doEncode(new DataView(out), 0, fields, v);
16239
+ return out;
16240
+ }),
16241
+ offsetOf: (name) => {
16242
+ for (const f of fields)
16243
+ if (f.name === name)
16244
+ return f.offset;
16245
+ throw new Error(`ffi-struct: no field "${name}"`);
16246
+ }
16247
+ };
16248
+ }
16249
+ function buildDecl(kind, member, pack) {
16250
+ const decl = { "#": kind };
16251
+ if (pack !== void 0)
16252
+ decl["#pack"] = pack;
16253
+ for (const [k, v] of Object.entries(member))
16254
+ if (!k.startsWith("#"))
16255
+ decl[k] = v;
16256
+ return decl;
16257
+ }
16258
+ function struct(a, b6, c) {
16259
+ const isNamed = typeof a === "string";
16260
+ const raw = isNamed ? b6 : a;
16261
+ const opts = isNamed ? c : b6;
16262
+ return createStruct(buildDecl("struct", raw, opts?.pack));
16263
+ }
16264
+
16265
+ // _build/lib/windows/structs.js
16266
+ var RECT = /* @__PURE__ */ struct("RECT", {
16267
+ left: "i32",
16268
+ top: "i32",
16269
+ right: "i32",
16270
+ bottom: "i32"
16271
+ });
16272
+ var POINT = /* @__PURE__ */ struct("POINT", {
16273
+ x: "i32",
16274
+ y: "i32"
16275
+ });
16276
+ var SIZE = /* @__PURE__ */ struct("SIZE", {
16277
+ cx: "i32",
16278
+ cy: "i32"
16279
+ });
16280
+ var LOGFONTW = /* @__PURE__ */ struct("LOGFONTW", {
16281
+ lfHeight: "i32",
16282
+ lfWidth: "i32",
16283
+ lfEscapement: "i32",
16284
+ lfOrientation: "i32",
16285
+ lfWeight: "i32",
16286
+ lfItalic: "u8",
16287
+ lfUnderline: "u8",
16288
+ lfStrikeOut: "u8",
16289
+ lfCharSet: "u8",
16290
+ lfOutPrecision: "u8",
16291
+ lfClipPrecision: "u8",
16292
+ lfQuality: "u8",
16293
+ lfPitchAndFamily: "u8",
16294
+ lfFaceName: "u16[32]@utf-16le"
16295
+ });
16296
+ var OPENFILENAMEW = /* @__PURE__ */ struct("OPENFILENAMEW", {
16297
+ lStructSize: "u32",
16298
+ hwndOwner: "<HWND>ptr",
16299
+ hInstance: "<HMODULE>ptr",
16300
+ lpstrFilter: "<>ptr",
16301
+ lpstrCustomFilter: "<>ptr",
16302
+ nMaxCustFilter: "u32",
16303
+ nFilterIndex: "u32",
16304
+ lpstrFile: "<>ptr",
16305
+ nMaxFile: "u32",
16306
+ lpstrFileTitle: "<>ptr",
16307
+ nMaxFileTitle: "u32",
16308
+ lpstrInitialDir: "<>ptr",
16309
+ lpstrTitle: "<>ptr",
16310
+ Flags: "u32",
16311
+ nFileOffset: "u16",
16312
+ nFileExtension: "u16",
16313
+ lpstrDefExt: "<>ptr",
16314
+ lCustData: "<>ptr",
16315
+ lpfnHook: "<>ptr",
16316
+ lpTemplateName: "<>ptr",
16317
+ pvReserved: "<>ptr",
16318
+ dwReserved: "u32",
16319
+ FlagsEx: "u32"
16320
+ });
16321
+ var BROWSEINFOW = /* @__PURE__ */ struct("BROWSEINFOW", {
16322
+ hwndOwner: "<HWND>ptr",
16323
+ pidlRoot: "<>ptr",
16324
+ pszDisplayName: "<>ptr",
16325
+ lpszTitle: "<>ptr",
16326
+ ulFlags: "u32",
16327
+ lpfn: "<>ptr",
16328
+ lParam: "<>ptr",
16329
+ iImage: "i32"
16330
+ });
16331
+ var NMHDR = /* @__PURE__ */ struct("NMHDR", {
16332
+ hwndFrom: "<HWND>ptr",
16333
+ idFrom: "<>ptr",
16334
+ code: "i32"
16335
+ });
16336
+ var SYSTEMTIME = /* @__PURE__ */ struct("SYSTEMTIME", {
16337
+ wYear: "u16",
16338
+ wMonth: "u16",
16339
+ wDayOfWeek: "u16",
16340
+ wDay: "u16",
16341
+ wHour: "u16",
16342
+ wMinute: "u16",
16343
+ wSecond: "u16",
16344
+ wMilliseconds: "u16"
16345
+ });
16346
+ var NMDATETIMECHANGE = /* @__PURE__ */ struct("NMDATETIMECHANGE", {
16347
+ hdr: NMHDR.__struct,
16348
+ dwFlags: "u32",
16349
+ st: SYSTEMTIME.__struct
16350
+ });
16351
+ var LITEM = /* @__PURE__ */ struct("LITEM", {
16352
+ mask: "u32",
16353
+ iLink: "i32",
16354
+ state: "u32",
16355
+ stateMask: "u32",
16356
+ szID: "u16[48]@utf-16le",
16357
+ szUrl: "u16[2084]@utf-16le"
16358
+ });
16359
+ var NMLINK = /* @__PURE__ */ struct("NMLINK", {
16360
+ hdr: NMHDR.__struct,
16361
+ item: LITEM.__struct
16362
+ });
16363
+ var NMCUSTOMDRAW = /* @__PURE__ */ struct("NMCUSTOMDRAW", {
16364
+ hdr: NMHDR.__struct,
16365
+ dwDrawStage: "u32",
16366
+ hdc: "<HDC>ptr",
16367
+ rc: "i32[4]",
16368
+ dwItemSpec: "<>ptr",
16369
+ uItemState: "u32",
16370
+ lItemlParam: "<>ptr"
16371
+ });
16372
+ var NMLVCUSTOMDRAW = /* @__PURE__ */ struct("NMLVCUSTOMDRAW", {
16373
+ hdr: NMHDR.__struct,
16374
+ dwDrawStage: "u32",
16375
+ hdc: "<HDC>ptr",
16376
+ rc: "i32[4]",
16377
+ dwItemSpec: "<>ptr",
16378
+ uItemState: "u32",
16379
+ lItemlParam: "<>ptr",
16380
+ clrText: "u32",
16381
+ clrTextBk: "u32",
16382
+ iSubItem: "i32",
16383
+ dwItemType: "u32"
16384
+ });
16385
+ var NMLISTVIEW = /* @__PURE__ */ struct("NMLISTVIEW", {
16386
+ hdr: NMHDR.__struct,
16387
+ iItem: "i32",
16388
+ iSubItem: "i32",
16389
+ uNewState: "u32",
16390
+ uOldState: "u32",
16391
+ uChanged: "u32",
16392
+ ptAction: "i32[2]",
16393
+ lParam: "<>ptr"
16394
+ });
16395
+ var TCITEMW = /* @__PURE__ */ struct("TCITEMW", {
16396
+ mask: "u32",
16397
+ dwState: "u32",
16398
+ dwStateMask: "u32",
16399
+ pszText: "<>ptr",
16400
+ cchTextMax: "i32",
16401
+ iImage: "i32",
16402
+ lParam: "<>ptr"
16403
+ });
16404
+ var TVITEM = /* @__PURE__ */ struct("TVITEM", {
16405
+ mask: "u32",
16406
+ hItem: "<>ptr",
16407
+ state: "u32",
16408
+ stateMask: "u32",
16409
+ pszText: "<>ptr",
16410
+ cchTextMax: "i32",
16411
+ iImage: "i32",
16412
+ iSelectedImage: "i32",
16413
+ cChildren: "i32",
16414
+ lParam: "<>ptr"
16415
+ });
16416
+ var TVINSERTSTRUCT = /* @__PURE__ */ struct("TVINSERTSTRUCT", {
16417
+ hParent: "<>ptr",
16418
+ hInsertAfter: "<>ptr",
16419
+ item: TVITEM.__struct
16420
+ });
16421
+ var LVHITTESTINFO = /* @__PURE__ */ struct("LVHITTESTINFO", {
16422
+ pt: "i32[2]",
16423
+ flags: "u32",
16424
+ iItem: "i32",
16425
+ iSubItem: "i32",
16426
+ iGroup: "i32"
16427
+ });
16428
+ var LVITEMW = /* @__PURE__ */ struct("LVITEMW", {
16429
+ mask: "u32",
16430
+ iItem: "i32",
16431
+ iSubItem: "i32",
16432
+ state: "u32",
16433
+ stateMask: "u32",
16434
+ pszText: "<>ptr",
16435
+ cchTextMax: "i32",
16436
+ iImage: "i32",
16437
+ lParam: "<>ptr",
16438
+ iIndent: "i32",
16439
+ iGroupId: "i32",
16440
+ cColumns: "u32",
16441
+ puColumns: "<>ptr",
16442
+ piColFmt: "<>ptr",
16443
+ iGroup: "i32"
16444
+ });
16445
+ var LVCOLUMNW = /* @__PURE__ */ struct("LVCOLUMNW", {
16446
+ mask: "u32",
16447
+ fmt: "i32",
16448
+ cx: "i32",
16449
+ pszText: "<>ptr",
16450
+ cchTextMax: "i32",
16451
+ iSubItem: "i32",
16452
+ iImage: "i32",
16453
+ iOrder: "i32",
16454
+ cxMin: "i32",
16455
+ cxDefault: "i32",
16456
+ cxIdeal: "i32"
16457
+ });
16458
+ var MSG = /* @__PURE__ */ struct("MSG", {
16459
+ hwnd: "<HWND>ptr",
16460
+ message: "u32",
16461
+ wParam: "<>ptr",
16462
+ lParam: "<>ptr",
16463
+ time: "u32",
16464
+ pt: POINT.__struct
16465
+ });
16466
+ var PAINTSTRUCT = /* @__PURE__ */ struct("PAINTSTRUCT", {
16467
+ hdc: "<HDC>ptr",
16468
+ fErase: "i32",
16469
+ rcPaint: RECT.__struct,
16470
+ fRestore: "i32",
16471
+ fIncUpdate: "i32",
16472
+ rgbReserved: "u8[32]"
16473
+ });
16474
+
16475
+ // _build/lib/windows/user32.js
16476
+ var b = (name, sig, encoders) => bind("user32.dll", name, sig, encoders);
16477
+ var _bProbe = b("GetDesktopWindow", " -> <HWND>ptr");
16478
+ var LONG_PTR_SYM = os3.arch === "x64" ? "PtrW" : "W";
16479
+ var SetWindowPos = /* @__PURE__ */ b("SetWindowPos", "<HWND>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32");
16480
+ var SetWindowText = /* @__PURE__ */ b("SetWindowTextW", "<HWND>ptr <WCHAR>ptr -> i32");
16481
+ var GetWindowLongPtr = /* @__PURE__ */ b("GetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp -> <>ptr");
16482
+ var SetWindowLongPtr = /* @__PURE__ */ b("SetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp <>ptr -> <>ptr");
16483
+ var EnableWindow = /* @__PURE__ */ b("EnableWindow", "<HWND>ptr i32 -> i32");
16484
+ var SetParent = /* @__PURE__ */ b("SetParent", "<HWND>ptr <HWND>ptr -> <HWND>ptr");
16485
+ var DefWindowProc = /* @__PURE__ */ b("DefWindowProcW", "<HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
16486
+ var CallWindowProc = /* @__PURE__ */ b("CallWindowProcW", "<>ptr <HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
16487
+ var GetDC = /* @__PURE__ */ b("GetDC", "<HWND>ptr -> <HDC>ptr");
16488
+ var ReleaseDC = /* @__PURE__ */ b("ReleaseDC", "<HWND>ptr <HDC>ptr! -> i32");
16489
+ var DrawText = /* @__PURE__ */ b("DrawTextW", "<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32");
16490
+ var InvalidateRect = /* @__PURE__ */ b("InvalidateRect", "<HWND>ptr <RECT>ptr i32 -> i32", { RECT });
16491
+ var SetCursor = /* @__PURE__ */ b("SetCursor", "<HCURSOR>ptr -> <HCURSOR>ptr");
16492
+ var LoadCursor = /* @__PURE__ */ b("LoadCursorW", "<HMODULE>ptr <>ptr -> <HCURSOR>ptr");
16493
+ var GetCursorPos = /* @__PURE__ */ b("GetCursorPos", "<POINT>ptr -> i32");
16494
+ var ScreenToClient = /* @__PURE__ */ b("ScreenToClient", "<HWND>ptr <POINT>ptr -> i32");
16495
+ var ShowScrollBar = /* @__PURE__ */ b("ShowScrollBar", "<HWND>ptr u32 i32 -> i32");
16496
+ var GetSystemMetrics = /* @__PURE__ */ b("GetSystemMetrics", "i32 -> i32");
15365
16497
 
15366
16498
  // _build/lib/react-qw/reconciler.js
15367
16499
  var import_react_reconciler = __toESM(require_react_reconciler(), 1);
15368
16500
  var import_react = __toESM(require_react(), 1);
15369
16501
  var import_constants = __toESM(require_constants(), 1);
15370
16502
  import * as gui3 from "gui";
15371
- import * as os2 from "os";
16503
+ import * as os4 from "os";
16504
+
16505
+ // _build/lib/windows/gdi32.js
16506
+ var b2 = (name, sig, encoders) => bind("gdi32.dll", name, sig, encoders);
16507
+ var DeleteObject = /* @__PURE__ */ b2("DeleteObject", "<>ptr -> i32");
16508
+ var GetDeviceCaps = /* @__PURE__ */ b2("GetDeviceCaps", "<HDC>ptr! i32@DeviceCap -> i32");
16509
+ var CreateFontIndirect = /* @__PURE__ */ b2("CreateFontIndirectW", "<LOGFONTW>ptr -> <>ptr", { LOGFONTW });
16510
+ var SelectObject = /* @__PURE__ */ b2("SelectObject", "<HDC>ptr! <>ptr -> <>ptr");
16511
+ var GetObject = /* @__PURE__ */ b2("GetObjectW", "<>ptr i32 <BYTE>ptr -> i32");
15372
16512
 
15373
16513
  // _build/lib/react-qw/props.js
15374
16514
  import * as gui from "gui";
15375
16515
  function applyProps(instance, newProps, _oldProps) {
15376
16516
  const hwnd2 = instance.hwnd;
15377
16517
  instance.props = newProps;
16518
+ if (hwnd2 === null)
16519
+ return;
15378
16520
  const textVal = "text" in newProps ? newProps.text : typeof newProps.children === "string" ? newProps.children : typeof newProps.children === "number" ? String(newProps.children) : void 0;
15379
16521
  if (textVal !== void 0) {
15380
16522
  let cursor = -1;
@@ -15382,13 +16524,13 @@ function applyProps(instance, newProps, _oldProps) {
15382
16524
  const sel = gui.SendMessage(hwnd2, 176, 0, 0);
15383
16525
  cursor = sel >>> 16;
15384
16526
  }
15385
- gui.SetWindowText(hwnd2, textVal);
16527
+ SetWindowText(hwnd2, textVal);
15386
16528
  if (instance.type === "EDIT" && cursor >= 0) {
15387
16529
  gui.SendMessage(hwnd2, 177, cursor, cursor);
15388
16530
  }
15389
16531
  }
15390
16532
  if ("disabled" in newProps) {
15391
- gui.EnableWindow(hwnd2, !newProps.disabled);
16533
+ EnableWindow(hwnd2, !newProps.disabled ? 1 : 0);
15392
16534
  }
15393
16535
  if ("hidden" in newProps) {
15394
16536
  gui.ShowWindow(
@@ -15488,58 +16630,36 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
15488
16630
  }
15489
16631
 
15490
16632
  // _build/lib/text-measure.js
15491
- import * as ffi from "ffi";
15492
- import * as os from "os";
15493
- import * as win from "win";
15494
16633
  import * as gui2 from "gui";
15495
- function loadProc(lib, name) {
15496
- const ptr = win.GetProcAddress(lib, name);
15497
- if (!ptr)
15498
- throw new Error(`Cannot load ${name}`);
15499
- return ptr;
15500
- }
15501
- var user32 = win.LoadLibrary("user32.dll");
15502
- var gdi32 = win.LoadLibrary("gdi32.dll");
15503
- if (!user32 || !gdi32)
15504
- throw new Error("Failed to load system DLLs");
15505
- var DrawTextW = loadProc(user32, "DrawTextW");
15506
- var GetDC = loadProc(user32, "GetDC");
15507
- var ReleaseDC = loadProc(user32, "ReleaseDC");
15508
- var SelectObject = loadProc(gdi32, "SelectObject");
15509
- var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
15510
- var FFI_S32 = ffi.FFI_TYPE_SINT32;
15511
- var FFI_PTR = ffi.FFI_TYPE_POINTER;
15512
16634
  function measureText(hdc, text, maxWidth) {
15513
- const textBuf = new TextEncoder("utf-16le").encode(text + "\0").buffer;
15514
- const rect = new ArrayBuffer(16);
15515
- const dv = new DataView(rect);
15516
- dv.setInt32(8, maxWidth, true);
15517
- ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
16635
+ const r = RECT.encode({ right: maxWidth });
16636
+ DrawText(
15518
16637
  hdc,
15519
- textBuf,
16638
+ text,
15520
16639
  -1,
15521
- rect,
16640
+ r.ptr,
15522
16641
  1024
15523
16642
  /* gui.DrawTextFlag.CALCRECT */
15524
- ], FFI_S32);
15525
- return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
16643
+ );
16644
+ const { right, bottom } = RECT.decode(r);
16645
+ return { width: right, height: bottom };
15526
16646
  }
15527
16647
  function getButtonIdealSize(hwnd2) {
15528
- const size = new ArrayBuffer(8);
15529
- gui2.SendMessage(hwnd2, 5633, 0, ffi.bufferPtr(size));
15530
- const dv = new DataView(size);
15531
- return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
16648
+ const size = SIZE.alloc();
16649
+ gui2.SendMessage(hwnd2, 5633, 0, size.ptr);
16650
+ const { cx, cy } = SIZE.decode(size);
16651
+ return { width: cx, height: cy };
15532
16652
  }
15533
16653
  function measureTextForHwnd(hwnd2, text) {
15534
- const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
16654
+ const hdc = GetDC(hwnd2);
15535
16655
  if (!hdc)
15536
16656
  return { width: 0, height: 0 };
15537
16657
  const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
15538
- const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
16658
+ const oldFont = hFont ? SelectObject(hdc, hFont) : 0;
15539
16659
  const result = measureText(hdc, text, 0);
15540
16660
  if (hFont)
15541
- ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
15542
- ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
16661
+ SelectObject(hdc, oldFont);
16662
+ ReleaseDC(hwnd2, hdc);
15543
16663
  const wr = gui2.GetWindowRect(hwnd2);
15544
16664
  const cr = gui2.GetClientRect(hwnd2);
15545
16665
  if (wr && cr) {
@@ -15551,14 +16671,20 @@ function measureTextForHwnd(hwnd2, text) {
15551
16671
 
15552
16672
  // _build/lib/react-qw/reconciler.js
15553
16673
  var dpiFont = gui3.CreateSystemDpiFont();
15554
- var scaleFactor = gui3.GetScaleFactor();
16674
+ var scaleFactor = (() => {
16675
+ const hdc = GetDC(NULL);
16676
+ const dpi = hdc ? GetDeviceCaps(hdc, 88) : 96;
16677
+ if (hdc)
16678
+ ReleaseDC(NULL, hdc);
16679
+ return dpi / 96;
16680
+ })();
15555
16681
  var DELAYED_CONTROLS = /* @__PURE__ */ new Set(["SysListView32", "SysTreeView32", "LISTBOX", "COMBOBOX", "msctls_trackbar32", "SysDateTimePick32", "SysLink"]);
15556
16682
  function isDelayedControl(winClass) {
15557
16683
  return DELAYED_CONTROLS.has(winClass);
15558
16684
  }
15559
16685
  function setupWindowProc(instance, hwnd2) {
15560
16686
  instance.hwnd = hwnd2;
15561
- const oldProc = gui3.GetWindowLongPtr(
16687
+ const oldProc = GetWindowLongPtr(
15562
16688
  hwnd2,
15563
16689
  -4
15564
16690
  /* gui.Gwlp.WNDPROC */
@@ -15567,11 +16693,11 @@ function setupWindowProc(instance, hwnd2) {
15567
16693
  gui3.SetWindowProc(hwnd2, (hwnd3, msg, wParam, lParam) => {
15568
16694
  const ev = instance.props.onEvent;
15569
16695
  if (!ev)
15570
- return gui3.CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
16696
+ return CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
15571
16697
  if (typeof ev === "object") {
15572
- return ev.fn({ hwnd: hwnd3, msg, wParam, lParam, callOldWndProc: () => gui3.CallWindowProc(oldProc, hwnd3, msg, wParam, lParam) });
16698
+ return ev.fn({ hwnd: hwnd3, msg, wParam, lParam, callOldWndProc: () => CallWindowProc(oldProc, hwnd3, msg, wParam, lParam) });
15573
16699
  }
15574
- const result = gui3.CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
16700
+ const result = CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
15575
16701
  const override = ev({ hwnd: hwnd3, msg, wParam, lParam });
15576
16702
  return typeof override === "number" && Number.isInteger(override) ? override : result;
15577
16703
  });
@@ -15641,7 +16767,7 @@ function runFlexLayout(inst) {
15641
16767
  if (lr && lr.x === r.x && lr.y === r.y && lr.w === r.width && lr.h === r.height)
15642
16768
  continue;
15643
16769
  console.log("flex: set", child.type, child.hwnd, "to", r.x, r.y, r.width, r.height);
15644
- gui3.SetWindowPos(
16770
+ SetWindowPos(
15645
16771
  child.hwnd,
15646
16772
  0,
15647
16773
  (r.x + pl) * scaleFactor,
@@ -15651,7 +16777,7 @@ function runFlexLayout(inst) {
15651
16777
  64
15652
16778
  /* gui.SetWindowPosFlag.SWP_SHOWWINDOW */
15653
16779
  );
15654
- gui3.InvalidateRect(child.hwnd, null, true);
16780
+ InvalidateRect(child.hwnd, NULL, 1);
15655
16781
  child.lastRect = { x: r.x, y: r.y, w: r.width, h: r.height };
15656
16782
  }
15657
16783
  for (const c of children)
@@ -15697,7 +16823,7 @@ var hostConfig = {
15697
16823
  if (child.hwnd === null) {
15698
16824
  ensureChildWindow(child, parent.hwnd);
15699
16825
  } else {
15700
- gui3.SetParent(child.hwnd, parent.hwnd);
16826
+ SetParent(child.hwnd, parent.hwnd ?? NULL);
15701
16827
  }
15702
16828
  if (false)
15703
16829
  console.log("[reconciler] appendInitialChild parent:", parent.hwnd, "child:", child.hwnd);
@@ -15707,7 +16833,7 @@ var hostConfig = {
15707
16833
  if (child.hwnd === null) {
15708
16834
  ensureChildWindow(child, parent.hwnd);
15709
16835
  } else {
15710
- gui3.SetParent(child.hwnd, parent.hwnd);
16836
+ SetParent(child.hwnd, parent.hwnd ?? NULL);
15711
16837
  }
15712
16838
  if (false)
15713
16839
  console.log("[reconciler] appendChild parent:", parent.hwnd, "child:", child.hwnd);
@@ -15717,7 +16843,7 @@ var hostConfig = {
15717
16843
  if (child.hwnd === null) {
15718
16844
  ensureChildWindow(child, container);
15719
16845
  } else {
15720
- gui3.SetParent(child.hwnd, container);
16846
+ SetParent(child.hwnd, container);
15721
16847
  }
15722
16848
  const rootInst = instancesByHwnd.get(container);
15723
16849
  if (rootInst)
@@ -15729,7 +16855,7 @@ var hostConfig = {
15729
16855
  if (child.hwnd === null) {
15730
16856
  ensureChildWindow(child, parent.hwnd);
15731
16857
  } else {
15732
- gui3.SetParent(child.hwnd, parent.hwnd);
16858
+ SetParent(child.hwnd, parent.hwnd ?? NULL);
15733
16859
  }
15734
16860
  if (false)
15735
16861
  console.log("[reconciler] insertBefore parent:", parent.hwnd, "child:", child.hwnd, "before:", beforeChild.hwnd);
@@ -15741,7 +16867,7 @@ var hostConfig = {
15741
16867
  if (child.hwnd === null) {
15742
16868
  ensureChildWindow(child, container);
15743
16869
  } else {
15744
- gui3.SetParent(child.hwnd, container);
16870
+ SetParent(child.hwnd, container);
15745
16871
  }
15746
16872
  const rootInst = instancesByHwnd.get(container);
15747
16873
  if (!rootInst)
@@ -15798,7 +16924,7 @@ var hostConfig = {
15798
16924
  resetTextContent(_instance) {
15799
16925
  },
15800
16926
  commitTextUpdate(instance, _oldText, newText) {
15801
- gui3.SetWindowText(instance.hwnd, newText);
16927
+ SetWindowText(instance.hwnd, newText);
15802
16928
  },
15803
16929
  hideInstance(instance) {
15804
16930
  if (instance.hwnd !== null)
@@ -15852,10 +16978,10 @@ var hostConfig = {
15852
16978
  clearContainer(_container) {
15853
16979
  },
15854
16980
  scheduleTimeout(fn, delay) {
15855
- return os2.setTimeout(fn, delay);
16981
+ return os4.setTimeout(fn, delay);
15856
16982
  },
15857
16983
  cancelTimeout(id) {
15858
- os2.clearTimeout?.(id);
16984
+ os4.clearTimeout?.(id);
15859
16985
  },
15860
16986
  noTimeout: -1,
15861
16987
  supportsMutation: true,
@@ -16022,28 +17148,23 @@ var ComboBox = (0, import_react4.forwardRef)(({ items, selectedIndex: controlled
16022
17148
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
16023
17149
  var import_react5 = __toESM(require_react(), 1);
16024
17150
  import * as gui6 from "gui";
16025
- import * as ffi2 from "ffi";
16026
- function readI16(ptr, offset) {
16027
- return ffi2.readByte(ptr + offset) | ffi2.readByte(ptr + offset + 1) << 8;
16028
- }
16029
- function readI32(ptr, offset) {
16030
- return ffi2.readByte(ptr + offset) | ffi2.readByte(ptr + offset + 1) << 8 | ffi2.readByte(ptr + offset + 2) << 16 | ffi2.readByte(ptr + offset + 3) << 24;
16031
- }
16032
- function bufPtr(buf) {
16033
- return ffi2.bufferPtr(buf);
17151
+
17152
+ // _build/lib/react-qw/nmhdr.js
17153
+ function nmCode(lParam) {
17154
+ return NMHDR.decode(lParam).code;
16034
17155
  }
17156
+
17157
+ // _build/lib/react-qw/components/DateTimePicker.js
16035
17158
  function dateToSysTimeBuf(d) {
16036
- const buf = new ArrayBuffer(16);
16037
- const dv = new DataView(buf);
16038
- dv.setUint16(0, d.getFullYear(), true);
16039
- dv.setUint16(2, d.getMonth() + 1, true);
16040
- dv.setUint16(4, 0, true);
16041
- dv.setUint16(6, d.getDate(), true);
16042
- dv.setUint16(8, d.getHours(), true);
16043
- dv.setUint16(10, d.getMinutes(), true);
16044
- dv.setUint16(12, d.getSeconds(), true);
16045
- dv.setUint16(14, d.getMilliseconds(), true);
16046
- return buf;
17159
+ return SYSTEMTIME.encode({
17160
+ wYear: d.getFullYear(),
17161
+ wMonth: d.getMonth() + 1,
17162
+ wDay: d.getDate(),
17163
+ wHour: d.getHours(),
17164
+ wMinute: d.getMinutes(),
17165
+ wSecond: d.getSeconds(),
17166
+ wMilliseconds: d.getMilliseconds()
17167
+ });
16047
17168
  }
16048
17169
  var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ value, onChange, defaultValue, format = "short", allowNone, updown, style }, ref) {
16049
17170
  const [internalDate, setInternalDate] = (0, import_react5.useState)(defaultValue ?? null);
@@ -16068,7 +17189,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
16068
17189
  const d = effectiveDate;
16069
17190
  if (d) {
16070
17191
  const buf = dateToSysTimeBuf(d);
16071
- gui6.SendMessage(h, 4098, 0, bufPtr(buf));
17192
+ gui6.SendMessage(h, 4098, 0, buf.ptr);
16072
17193
  } else {
16073
17194
  gui6.SendMessage(h, 4098, 1, 0);
16074
17195
  }
@@ -16077,7 +17198,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
16077
17198
  const h = dpRef.current;
16078
17199
  if (!h)
16079
17200
  return;
16080
- gui6.InvalidateRect(h, null, true);
17201
+ InvalidateRect(h, NULL, 1);
16081
17202
  const cr = gui6.GetClientRect(h);
16082
17203
  if (cr) {
16083
17204
  const w = cr.right - cr.left;
@@ -16087,21 +17208,15 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
16087
17208
  }, []);
16088
17209
  return (0, import_jsx_runtime4.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
16089
17210
  if (e.msg === 78) {
16090
- const code = readI32(e.lParam, 16);
17211
+ const code = nmCode(e.lParam);
16091
17212
  if (code === -759) {
16092
- const dwFlags = readI32(e.lParam, 24);
17213
+ const { dwFlags, st } = NMDATETIMECHANGE.decode(e.lParam);
16093
17214
  if (dwFlags === 1) {
16094
17215
  if (!isControlled)
16095
17216
  setInternalDate(null);
16096
17217
  onChangeRef.current?.(null);
16097
17218
  } else {
16098
- const year = readI16(e.lParam, 28);
16099
- const month = readI16(e.lParam, 30);
16100
- const day = readI16(e.lParam, 34);
16101
- const hour = readI16(e.lParam, 36);
16102
- const min = readI16(e.lParam, 38);
16103
- const sec = readI16(e.lParam, 40);
16104
- const d = new Date(year, month - 1, day, hour, min, sec);
17219
+ const d = new Date(st.wYear, st.wMonth - 1, st.wDay, st.wHour, st.wMinute, st.wSecond);
16105
17220
  if (!isControlled)
16106
17221
  setInternalDate(d);
16107
17222
  onChangeRef.current?.(d);
@@ -16117,14 +17232,6 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
16117
17232
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
16118
17233
  var import_react6 = __toESM(require_react(), 1);
16119
17234
  import * as gui7 from "gui";
16120
- import * as ffi3 from "ffi";
16121
- function textToUtf16(s) {
16122
- const buf = new ArrayBuffer((s.length + 1) * 2);
16123
- const dv = new DataView(buf);
16124
- for (let i = 0; i < s.length; i++)
16125
- dv.setUint16(i * 2, s.charCodeAt(i), true);
16126
- return buf;
16127
- }
16128
17235
  var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValue = "", onChange, placeholder, password, multiline, readonly, number, disabled, style }, ref) => {
16129
17236
  const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue);
16130
17237
  const isControlled = controlledValue !== void 0;
@@ -16143,8 +17250,8 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
16143
17250
  const h = inputRef.current;
16144
17251
  if (!h || !placeholder)
16145
17252
  return;
16146
- const buf = textToUtf16(placeholder);
16147
- gui7.SendMessage(h, 5377, 1, ffi3.bufferPtr(buf));
17253
+ const buf = WCHAR.encode(placeholder);
17254
+ gui7.SendMessage(h, 5377, 1, buf.ptr);
16148
17255
  }, [placeholder]);
16149
17256
  return (0, import_jsx_runtime5.jsx)("w", { type: "EDIT", text: displayValue, ws, style, disabled, ref: (h) => {
16150
17257
  inputRef.current = h;
@@ -16168,23 +17275,6 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
16168
17275
  // _build/lib/react-qw/components/Link.js
16169
17276
  var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
16170
17277
  var import_react7 = __toESM(require_react(), 1);
16171
- import * as gui8 from "gui";
16172
- import * as ffi4 from "ffi";
16173
- function readI322(ptr, offset) {
16174
- return ffi4.readByte(ptr + offset) | ffi4.readByte(ptr + offset + 1) << 8 | ffi4.readByte(ptr + offset + 2) << 16 | ffi4.readByte(ptr + offset + 3) << 24;
16175
- }
16176
- function readUtf16(ptr, offset, maxWords) {
16177
- const chars = [];
16178
- for (let i = 0; i < maxWords; i++) {
16179
- const lo = ffi4.readByte(ptr + offset + i * 2);
16180
- const hi = ffi4.readByte(ptr + offset + i * 2 + 1);
16181
- const code = hi << 8 | lo;
16182
- if (code === 0)
16183
- break;
16184
- chars.push(String.fromCharCode(code));
16185
- }
16186
- return chars.join("");
16187
- }
16188
17278
  var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClick, style }, ref) {
16189
17279
  const displayText = children != null ? String(children) : href ?? "";
16190
17280
  const linkText = href ? `<A HREF="${href}">${displayText}</A>` : displayText;
@@ -16195,14 +17285,13 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
16195
17285
  const h = linkRef.current;
16196
17286
  if (!h)
16197
17287
  return;
16198
- gui8.InvalidateRect(h, null, true);
17288
+ InvalidateRect(h, NULL, 1);
16199
17289
  }, [linkText]);
16200
17290
  return (0, import_jsx_runtime6.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
16201
17291
  if (e.msg === 78) {
16202
- const code = readI322(e.lParam, 16);
17292
+ const code = nmCode(e.lParam);
16203
17293
  if (code === -2 || code === -4) {
16204
- const url = readUtf16(e.lParam, 136, 2048);
16205
- onClickRef.current?.(url);
17294
+ onClickRef.current?.(NMLINK.decode(e.lParam).item.szUrl);
16206
17295
  }
16207
17296
  }
16208
17297
  }, children: (0, import_jsx_runtime6.jsx)("w", { type: "SysLink", ws: 268435456 | 65536, text: linkText, style: { flexGrow: 1 }, ref: (h) => {
@@ -16213,7 +17302,7 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
16213
17302
  // _build/lib/react-qw/components/ListBox.js
16214
17303
  var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
16215
17304
  var import_react8 = __toESM(require_react(), 1);
16216
- import * as gui9 from "gui";
17305
+ import * as gui8 from "gui";
16217
17306
  var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledIndex, defaultSelectedIndex = -1, onChange, style, sort, scrollToBottom }, ref) => {
16218
17307
  const [internalIndex, setInternalIndex] = (0, import_react8.useState)(defaultSelectedIndex);
16219
17308
  const isControlled = controlledIndex !== void 0;
@@ -16225,18 +17314,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
16225
17314
  const h = lbRef.current;
16226
17315
  if (!h)
16227
17316
  return;
16228
- gui9.SendMessage(h, 388, 0, 0);
17317
+ gui8.SendMessage(h, 388, 0, 0);
16229
17318
  for (const item of items)
16230
- gui9.SendMessage(h, 384, 0, item);
17319
+ gui8.SendMessage(h, 384, 0, item);
16231
17320
  if (sel >= 0 && sel < items.length)
16232
- gui9.SendMessage(h, 390, sel, 0);
17321
+ gui8.SendMessage(h, 390, sel, 0);
16233
17322
  if (scrollToBottom && items.length > 0)
16234
- gui9.SendMessage(h, 407, items.length - 1, 0);
17323
+ gui8.SendMessage(h, 407, items.length - 1, 0);
16235
17324
  }, [items]);
16236
17325
  (0, import_react8.useEffect)(() => {
16237
17326
  const h = lbRef.current;
16238
17327
  if (h)
16239
- gui9.SendMessage(h, 390, sel, 0);
17328
+ gui8.SendMessage(h, 390, sel, 0);
16240
17329
  }, [sel]);
16241
17330
  return (0, import_jsx_runtime7.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, onEvent: (e) => {
16242
17331
  if (e.msg !== 273)
@@ -16246,7 +17335,7 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
16246
17335
  const h = lbRef.current;
16247
17336
  if (!h)
16248
17337
  return;
16249
- const newSel = gui9.SendMessage(h, 392, 0, 0);
17338
+ const newSel = gui8.SendMessage(h, 392, 0, 0);
16250
17339
  if (newSel !== sel && newSel >= 0) {
16251
17340
  if (!isControlled)
16252
17341
  setInternalIndex(newSel);
@@ -16261,75 +17350,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
16261
17350
  // _build/lib/react-qw/components/ListView.js
16262
17351
  var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
16263
17352
  var import_react9 = __toESM(require_react(), 1);
16264
- import * as gui10 from "gui";
16265
- import * as ffi5 from "ffi";
16266
- import * as win2 from "win";
16267
- function textToUtf162(s) {
16268
- const buf = new ArrayBuffer((s.length + 1) * 2);
16269
- const dv = new DataView(buf);
16270
- for (let i = 0; i < s.length; i++)
16271
- dv.setUint16(i * 2, s.charCodeAt(i), true);
16272
- return buf;
16273
- }
16274
- function readI323(ptr, offset) {
16275
- return ffi5.readByte(ptr + offset) | ffi5.readByte(ptr + offset + 1) << 8 | ffi5.readByte(ptr + offset + 2) << 16 | ffi5.readByte(ptr + offset + 3) << 24;
16276
- }
16277
- function readU32(ptr, offset) {
16278
- return ffi5.readByte(ptr + offset) | ffi5.readByte(ptr + offset + 1) << 8 | ffi5.readByte(ptr + offset + 2) << 16 | ffi5.readByte(ptr + offset + 3) << 24 >>> 0;
16279
- }
16280
- function readU64(ptr, offset) {
16281
- const lo = readU32(ptr, offset);
16282
- const hi = readU32(ptr, offset + 4);
16283
- return lo + hi * 4294967296;
16284
- }
17353
+ import * as gui9 from "gui";
17354
+ import * as ffi3 from "ffi";
16285
17355
  function writeU32(ptr, offset, v) {
16286
- ffi5.writeByte(ptr + offset, v & 255);
16287
- ffi5.writeByte(ptr + offset + 1, v >> 8 & 255);
16288
- ffi5.writeByte(ptr + offset + 2, v >> 16 & 255);
16289
- ffi5.writeByte(ptr + offset + 3, v >> 24 & 255);
16290
- }
16291
- function bufPtr2(buf) {
16292
- return ffi5.bufferPtr(buf);
17356
+ ffi3.writeByte(ptr + offset, v & 255);
17357
+ ffi3.writeByte(ptr + offset + 1, v >> 8 & 255);
17358
+ ffi3.writeByte(ptr + offset + 2, v >> 16 & 255);
17359
+ ffi3.writeByte(ptr + offset + 3, v >> 24 & 255);
16293
17360
  }
16294
17361
  var LV_WS = 268435456 | 8388608 | 2097152 | 1048576 | 1 | 4;
16295
- var CD_STAGE = 24;
16296
- var CD_HDC = 32;
16297
- var CD_ITEM = 56;
16298
- var CD_CLRTEXT = 80;
16299
- var CD_CLRTEXTBK = 84;
16300
- var CD_SUBITEM = 88;
16301
- var NMIA_ITEM = 24;
16302
- var NMIA_SUBITEM = 28;
16303
- var NM_CODE = 16;
17362
+ var CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf("clrText");
17363
+ var CD_CLRTEXTBK = NMLVCUSTOMDRAW.offsetOf("clrTextBk");
16304
17364
  var fontCache = /* @__PURE__ */ new Map();
16305
- var gdi322 = null;
16306
- var createFontIndirectW = null;
16307
- var selectObjectFn = null;
16308
- var getObjectW = null;
16309
- function ensureGdi() {
16310
- if (gdi322 !== null)
16311
- return;
16312
- gdi322 = win2.LoadLibrary("gdi32.dll");
16313
- if (!gdi322)
16314
- return;
16315
- createFontIndirectW = win2.GetProcAddress(gdi322, "CreateFontIndirectW");
16316
- selectObjectFn = win2.GetProcAddress(gdi322, "SelectObject");
16317
- getObjectW = win2.GetProcAddress(gdi322, "GetObjectW");
16318
- }
16319
- var user322 = null;
16320
- var loadCursorW = null;
16321
- var setCursorFn = null;
16322
- var screenToClient = null;
16323
- function ensureUser32() {
16324
- if (user322 !== null)
16325
- return;
16326
- user322 = win2.LoadLibrary("user32.dll");
16327
- if (!user322)
16328
- return;
16329
- loadCursorW = win2.GetProcAddress(user322, "LoadCursorW");
16330
- setCursorFn = win2.GetProcAddress(user322, "SetCursor");
16331
- screenToClient = win2.GetProcAddress(user322, "ScreenToClient");
16332
- }
16333
17365
  function getCellFont(hwnd2, style) {
16334
17366
  const key = (style.bold ? "b" : "") + (style.italic ? "i" : "") + (style.underline ? "u" : "");
16335
17367
  if (key === "")
@@ -16337,39 +17369,37 @@ function getCellFont(hwnd2, style) {
16337
17369
  const cached = fontCache.get(key);
16338
17370
  if (cached !== void 0)
16339
17371
  return cached === 0 ? null : cached;
16340
- ensureGdi();
16341
- if (!createFontIndirectW || !getObjectW || !hwnd2)
17372
+ if (!hwnd2)
16342
17373
  return null;
16343
- const lf = new ArrayBuffer(92);
16344
- const dv = new DataView(lf);
16345
- const cur = gui10.SendMessage(hwnd2, 49, 0, 0);
17374
+ let base = { lfHeight: -13 };
17375
+ const cur = gui9.SendMessage(hwnd2, 49, 0, 0);
16346
17376
  if (cur) {
16347
- const got = ffi5.ffiCall(getObjectW, [ffi5.FFI_TYPE_UINT64, ffi5.FFI_TYPE_SINT32, ffi5.FFI_TYPE_POINTER], [cur, 92, lf], ffi5.FFI_TYPE_SINT32);
16348
- if (!got)
17377
+ const lf = LOGFONTW.alloc();
17378
+ if (!GetObject(cur, LOGFONTW.size, lf))
16349
17379
  return null;
16350
- } else {
16351
- dv.setInt32(0, -13, true);
17380
+ base = LOGFONTW.decode(lf);
16352
17381
  }
16353
- if (style.bold)
16354
- dv.setInt32(16, 700, true);
16355
- if (style.italic)
16356
- dv.setUint8(20, 1);
16357
- if (style.underline)
16358
- dv.setUint8(21, 1);
16359
- const h = ffi5.ffiCall(createFontIndirectW, [ffi5.FFI_TYPE_POINTER], [lf], ffi5.FFI_TYPE_UINT64);
16360
- fontCache.set(key, h === 0 ? 0 : h);
16361
- return h === 0 ? null : h;
17382
+ const h = CreateFontIndirect({
17383
+ ...base,
17384
+ ...style.bold ? {
17385
+ lfWeight: 700
17386
+ /* gui.FontWeight.BOLD */
17387
+ } : {},
17388
+ ...style.italic ? { lfItalic: 1 } : {},
17389
+ ...style.underline ? { lfUnderline: 1 } : {}
17390
+ });
17391
+ fontCache.set(key, h ? h : 0);
17392
+ return h ? h : null;
16362
17393
  }
16363
17394
  function handleCustomDraw(lParam, columns, data, hwnd2) {
16364
- const stage = readU32(lParam, CD_STAGE);
17395
+ const { dwDrawStage: stage } = NMCUSTOMDRAW.decode(lParam);
16365
17396
  if (stage === 1)
16366
17397
  return 32;
16367
17398
  if (stage === 65537)
16368
17399
  return 32;
16369
17400
  if (stage === 196609) {
16370
- const colIndex = readI323(lParam, CD_SUBITEM);
16371
- const row = readI323(lParam, CD_ITEM);
16372
- const style = resolveCellStyle(columns, data, row, colIndex);
17401
+ const cd = NMLVCUSTOMDRAW.decode(lParam);
17402
+ const style = resolveCellStyle(columns, data, cd.dwItemSpec, cd.iSubItem);
16373
17403
  if (!style)
16374
17404
  return 0;
16375
17405
  if (style.color !== void 0)
@@ -16377,12 +17407,9 @@ function handleCustomDraw(lParam, columns, data, hwnd2) {
16377
17407
  if (style.background !== void 0)
16378
17408
  writeU32(lParam, CD_CLRTEXTBK, style.background);
16379
17409
  const hfont = getCellFont(hwnd2, style);
16380
- if (hfont && selectObjectFn) {
16381
- const hdc = readU64(lParam, CD_HDC);
16382
- if (hdc) {
16383
- ffi5.ffiCall(selectObjectFn, [ffi5.FFI_TYPE_UINT64, ffi5.FFI_TYPE_UINT64], [hdc, hfont], ffi5.FFI_TYPE_UINT64);
16384
- return 2;
16385
- }
17410
+ if (hfont && cd.hdc) {
17411
+ SelectObject(cd.hdc, hfont);
17412
+ return 2;
16386
17413
  }
16387
17414
  }
16388
17415
  return 0;
@@ -16413,20 +17440,26 @@ function resolveCellStyle(columns, data, row, colIndex) {
16413
17440
  return style || void 0;
16414
17441
  }
16415
17442
  function makeLVItem(i, sub, text, image) {
16416
- const b = new ArrayBuffer(84);
16417
- const dv = new DataView(b);
16418
- dv.setInt32(4, i, true);
16419
- dv.setInt32(8, sub, true);
16420
- let mask = 1;
16421
- if (image !== void 0) {
16422
- mask |= 2;
16423
- dv.setInt32(36, image, true);
16424
- }
16425
- dv.setUint32(0, mask, true);
16426
- const textBuf = textToUtf162(text);
16427
- dv.setBigUint64(24, BigInt(bufPtr2(textBuf)), true);
16428
- b.__textBuf = textBuf;
16429
- return b;
17443
+ const textBuf = WCHAR.encode(text);
17444
+ const b6 = LVITEMW.encode({
17445
+ mask: 1 | (image !== void 0 ? 2 : 0),
17446
+ iItem: i,
17447
+ iSubItem: sub,
17448
+ state: 0,
17449
+ stateMask: 0,
17450
+ pszText: textBuf.ptr,
17451
+ cchTextMax: 0,
17452
+ iImage: image ?? 0,
17453
+ lParam: 0,
17454
+ iIndent: 0,
17455
+ iGroupId: 0,
17456
+ cColumns: 0,
17457
+ puColumns: 0,
17458
+ piColFmt: 0,
17459
+ iGroup: 0
17460
+ });
17461
+ b6.__textBuf = textBuf;
17462
+ return b6;
16430
17463
  }
16431
17464
  var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, data, style, icons, iconSize, getIcon }, ref) {
16432
17465
  const lvRef = (0, import_react9.useRef)(null);
@@ -16438,36 +17471,36 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
16438
17471
  const il = iconListRef.current;
16439
17472
  iconListRef.current = 0;
16440
17473
  if (il) {
16441
- gui10.SendMessage(h, 4099, 1, 0);
16442
- gui10.ImageListDestroy(il);
17474
+ gui9.SendMessage(h, 4099, 1, 0);
17475
+ gui9.ImageListDestroy(il);
16443
17476
  }
16444
17477
  if (!icons || icons.length === 0)
16445
17478
  return;
16446
17479
  const size = iconSize ?? 32;
16447
- const img = gui10.ImageListCreate(size, size, 32, icons.length, 1);
17480
+ const img = gui9.ImageListCreate(size, size, 32, icons.length, 1);
16448
17481
  if (!img)
16449
17482
  return;
16450
17483
  for (const p of icons) {
16451
- const hbm = gui10.CreateBitmapFromPixels(size, size, p);
17484
+ const hbm = gui9.CreateBitmapFromPixels(size, size, p);
16452
17485
  if (hbm) {
16453
- gui10.ImageListAdd(img, hbm);
16454
- gui10.DeleteObject(hbm);
17486
+ gui9.ImageListAdd(img, hbm);
17487
+ DeleteObject(hbm);
16455
17488
  }
16456
17489
  }
16457
- gui10.SendMessage(h, 4099, 1, img);
17490
+ gui9.SendMessage(h, 4099, 1, img);
16458
17491
  iconListRef.current = img;
16459
17492
  }, [icons, iconSize]);
16460
17493
  (0, import_react9.useEffect)(() => {
16461
17494
  const h = lvRef.current;
16462
17495
  if (!h)
16463
17496
  return;
16464
- const hdr = gui10.SendMessage(h, 4127, 0, 0);
17497
+ const hdr = gui9.SendMessage(h, 4127, 0, 0);
16465
17498
  if (hdr) {
16466
- let n2 = gui10.SendMessage(hdr, 4608, 0, 0);
17499
+ let n2 = gui9.SendMessage(hdr, 4608, 0, 0);
16467
17500
  for (let k = n2 - 1; k >= 0; k--)
16468
- gui10.SendMessage(h, 4124, k, 0);
17501
+ gui9.SendMessage(h, 4124, k, 0);
16469
17502
  }
16470
- gui10.SendMessage(
17503
+ gui9.SendMessage(
16471
17504
  h,
16472
17505
  4150,
16473
17506
  0,
@@ -16476,37 +17509,43 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
16476
17509
  );
16477
17510
  const n = columns.length;
16478
17511
  for (let j = 0; j < n; j++) {
16479
- const titleBuf = textToUtf162(columns[j].name);
16480
- const lvc = new ArrayBuffer(52);
16481
- const dv = new DataView(lvc);
16482
- dv.setUint32(0, 4 | 2 | 1, true);
16483
- dv.setInt32(4, alignToFmt(columns[j].align), true);
16484
- dv.setInt32(8, columns[j].width ?? 100, true);
16485
- dv.setBigUint64(16, BigInt(bufPtr2(titleBuf)), true);
16486
- dv.setInt32(28, j, true);
17512
+ const titleBuf = WCHAR.encode(columns[j].name);
17513
+ const lvc = LVCOLUMNW.encode({
17514
+ mask: 4 | 2 | 1,
17515
+ fmt: alignToFmt(columns[j].align),
17516
+ cx: columns[j].width ?? 100,
17517
+ pszText: titleBuf.ptr,
17518
+ cchTextMax: 0,
17519
+ iSubItem: j,
17520
+ iImage: 0,
17521
+ iOrder: 0,
17522
+ cxMin: 0,
17523
+ cxDefault: 0,
17524
+ cxIdeal: 0
17525
+ });
16487
17526
  lvc.__titleBuf = titleBuf;
16488
- gui10.SendMessage(h, 4193, j, bufPtr2(lvc));
17527
+ gui9.SendMessage(h, 4193, j, lvc.ptr);
16489
17528
  }
16490
17529
  }, [columns]);
16491
17530
  (0, import_react9.useEffect)(() => {
16492
17531
  const h = lvRef.current;
16493
17532
  if (!h)
16494
17533
  return;
16495
- gui10.SendMessage(h, 4105, 0, 0);
17534
+ gui9.SendMessage(h, 4105, 0, 0);
16496
17535
  const nCols = columns.length;
16497
17536
  for (let i = 0; i < data.length; i++) {
16498
17537
  const record = data[i];
16499
17538
  const img = getIcon ? getIcon(record, i) : void 0;
16500
17539
  const itemBuf = makeLVItem(i, 0, cellText(record, columns[0], i), img);
16501
- gui10.SendMessage(h, 4173, 0, bufPtr2(itemBuf));
17540
+ gui9.SendMessage(h, 4173, 0, itemBuf.ptr);
16502
17541
  for (let j = 1; j < nCols; j++) {
16503
17542
  const subBuf = makeLVItem(i, j, cellText(record, columns[j], i));
16504
- gui10.SendMessage(h, 4172, 0, bufPtr2(subBuf));
17543
+ gui9.SendMessage(h, 4172, 0, subBuf.ptr);
16505
17544
  }
16506
17545
  }
16507
17546
  for (let j = 0; j < columns.length; j++) {
16508
17547
  if (columns[j].width == null) {
16509
- gui10.SendMessage(
17548
+ gui9.SendMessage(
16510
17549
  h,
16511
17550
  4126,
16512
17551
  j,
@@ -16518,19 +17557,17 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
16518
17557
  }, [data, columns, getIcon]);
16519
17558
  return (0, import_jsx_runtime8.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
16520
17559
  if (e.msg === 78) {
16521
- const code = readI323(e.lParam, NM_CODE);
17560
+ const code = nmCode(e.lParam);
16522
17561
  if (code === -12) {
16523
17562
  return handleCustomDraw(e.lParam, columns, data, lvRef.current);
16524
17563
  }
16525
17564
  if (code === -100) {
16526
- const uNewState = readU32(e.lParam, 32);
16527
- const uOldState = readU32(e.lParam, 36);
17565
+ const { uNewState, uOldState } = NMLISTVIEW.decode(e.lParam);
16528
17566
  if ((uNewState & 2) !== (uOldState & 2))
16529
17567
  return 1;
16530
17568
  }
16531
17569
  if (code === -2) {
16532
- const iItem = readI323(e.lParam, NMIA_ITEM);
16533
- const iSubItem = readI323(e.lParam, NMIA_SUBITEM);
17570
+ const { iItem, iSubItem } = NMLISTVIEW.decode(e.lParam);
16534
17571
  const col = columns[iSubItem];
16535
17572
  const record = data[iItem];
16536
17573
  if (col?.onCellClick && record !== void 0)
@@ -16548,33 +17585,20 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
16548
17585
  const h = lvRef.current;
16549
17586
  if (!h)
16550
17587
  return;
16551
- ensureUser32();
16552
- if (!loadCursorW || !setCursorFn || !screenToClient)
16553
- return;
16554
- const sp = gui10.GetCursorPos();
16555
- if (!sp)
17588
+ const pt = POINT.alloc();
17589
+ if (!GetCursorPos(pt.ptr))
16556
17590
  return;
16557
- const sbuf = new ArrayBuffer(8);
16558
- const sdv = new DataView(sbuf);
16559
- sdv.setInt32(0, sp[0], true);
16560
- sdv.setInt32(4, sp[1], true);
16561
- ffi5.ffiCall(screenToClient, [ffi5.FFI_TYPE_UINT64, ffi5.FFI_TYPE_POINTER], [h, sbuf], ffi5.FFI_TYPE_SINT32);
16562
- const lvhi = new ArrayBuffer(24);
16563
- const lvd = new DataView(lvhi);
16564
- lvd.setInt32(0, sdv.getInt32(0, true), true);
16565
- lvd.setInt32(4, sdv.getInt32(4, true), true);
16566
- lvd.setInt32(12, -1, true);
16567
- lvd.setInt32(16, -1, true);
16568
- const lvhiPtr = bufPtr2(lvhi);
16569
- gui10.SendMessage(h, 4153, 0, lvhiPtr);
16570
- const iItem = readI323(lvhiPtr, 12);
16571
- const iSubItem = readI323(lvhiPtr, 16);
17591
+ ScreenToClient(h, pt.ptr);
17592
+ const { x: sx, y: sy } = POINT.decode(pt);
17593
+ const hit = LVHITTESTINFO.encode({ pt: [sx, sy], iItem: -1, iSubItem: -1 });
17594
+ gui9.SendMessage(h, 4153, 0, hit.ptr);
17595
+ const { iItem, iSubItem } = LVHITTESTINFO.decode(hit);
16572
17596
  const style2 = resolveCellStyle(columns, data, iItem, iSubItem);
16573
17597
  if (!style2 || style2.cursor === void 0)
16574
17598
  return;
16575
- const hc = ffi5.ffiCall(loadCursorW, [ffi5.FFI_TYPE_UINT64, ffi5.FFI_TYPE_UINT64], [0, style2.cursor], ffi5.FFI_TYPE_UINT64);
17599
+ const hc = LoadCursor(NULL, style2.cursor);
16576
17600
  if (hc) {
16577
- ffi5.ffiCall(setCursorFn, [ffi5.FFI_TYPE_UINT64], [hc], ffi5.FFI_TYPE_UINT64);
17601
+ SetCursor(hc);
16578
17602
  return 1;
16579
17603
  }
16580
17604
  return;
@@ -16584,7 +17608,7 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
16584
17608
  // _build/lib/react-qw/components/ProgressBar.js
16585
17609
  var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
16586
17610
  var import_react10 = __toESM(require_react(), 1);
16587
- import * as gui11 from "gui";
17611
+ import * as gui10 from "gui";
16588
17612
  var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style, smooth }, ref) => {
16589
17613
  const pbRef = (0, import_react10.useRef)(null);
16590
17614
  const ws = 268435456 | 8388608 | (smooth ? 1 : 0);
@@ -16592,8 +17616,8 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
16592
17616
  const h = pbRef.current;
16593
17617
  if (!h)
16594
17618
  return;
16595
- gui11.SendMessage(h, 1030, 0, max);
16596
- gui11.SendMessage(h, 1026, Math.min(value, max), 0);
17619
+ gui10.SendMessage(h, 1030, 0, max);
17620
+ gui10.SendMessage(h, 1026, Math.min(value, max), 0);
16597
17621
  }, [value, max]);
16598
17622
  return (0, import_jsx_runtime9.jsx)("w", { type: "msctls_progress32", ws, style, ref: (h) => {
16599
17623
  pbRef.current = h;
@@ -16607,7 +17631,7 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
16607
17631
  // _build/lib/react-qw/components/RadioButton.js
16608
17632
  var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
16609
17633
  var import_react11 = __toESM(require_react(), 1);
16610
- import * as gui12 from "gui";
17634
+ import * as gui11 from "gui";
16611
17635
  var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked, defaultChecked = false, onChange, label, style, disabled }, ref) => {
16612
17636
  const [internalChecked, setInternalChecked] = (0, import_react11.useState)(defaultChecked);
16613
17637
  const isControlled = controlledChecked !== void 0;
@@ -16617,7 +17641,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
16617
17641
  const h = rbRef.current;
16618
17642
  if (!h)
16619
17643
  return;
16620
- gui12.SendMessage(h, 241, displayChecked ? 1 : 0, 0);
17644
+ gui11.SendMessage(h, 241, displayChecked ? 1 : 0, 0);
16621
17645
  }, [displayChecked]);
16622
17646
  return (0, import_jsx_runtime10.jsx)("w", { type: "BUTTON", text: label ?? "", ws: 268435456 | 9, style, disabled, ref: (h) => {
16623
17647
  rbRef.current = h;
@@ -16627,7 +17651,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
16627
17651
  ref.current = h;
16628
17652
  }, onEvent: (e) => {
16629
17653
  if (e.msg === 514) {
16630
- const newChecked = gui12.SendMessage(e.hwnd, 240, 0, 0) !== 0;
17654
+ const newChecked = gui11.SendMessage(e.hwnd, 240, 0, 0) !== 0;
16631
17655
  if (newChecked !== displayChecked) {
16632
17656
  if (!isControlled)
16633
17657
  setInternalChecked(newChecked);
@@ -16640,24 +17664,27 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
16640
17664
  // _build/lib/react-qw/components/ScrollView.js
16641
17665
  var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
16642
17666
  var import_react12 = __toESM(require_react(), 1);
16643
- import * as gui13 from "gui";
17667
+ import * as gui12 from "gui";
16644
17668
  var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth, contentHeight }, ref) => {
16645
17669
  const svRef = (0, import_react12.useRef)(null);
16646
17670
  const contentRef = (0, import_react12.useRef)(null);
16647
17671
  const scrollXRef = (0, import_react12.useRef)(0);
16648
17672
  const scrollYRef = (0, import_react12.useRef)(0);
16649
17673
  function updateScroll(sv, content) {
16650
- const svRect = gui13.GetClientRect(sv);
17674
+ const svRect = gui12.GetClientRect(sv);
16651
17675
  if (!svRect)
16652
17676
  return;
16653
17677
  const svW = svRect.right - svRect.left;
16654
17678
  const svH = svRect.bottom - svRect.top;
16655
- const scale = gui13.GetScaleFactor();
17679
+ const hdc = GetDC(NULL);
17680
+ const scale = hdc ? GetDeviceCaps(hdc, 88) / 96 : 1;
17681
+ if (hdc)
17682
+ ReleaseDC(NULL, hdc);
16656
17683
  const natW = Math.round((contentWidth ?? svW / scale) * scale);
16657
17684
  const natH = Math.round((contentHeight ?? svH / scale) * scale);
16658
17685
  scrollXRef.current = Math.max(0, Math.min(scrollXRef.current, natW - svW));
16659
17686
  scrollYRef.current = Math.max(0, Math.min(scrollYRef.current, natH - svH));
16660
- gui13.SetWindowPos(
17687
+ SetWindowPos(
16661
17688
  content,
16662
17689
  0,
16663
17690
  -scrollXRef.current,
@@ -16669,18 +17696,18 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16669
17696
  );
16670
17697
  forceFlexLayout(content);
16671
17698
  if (natW > svW) {
16672
- gui13.SetScrollInfo(sv, 0, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
16673
- gui13.ShowScrollBar(sv, 0, true);
17699
+ gui12.SetScrollInfo(sv, 0, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
17700
+ ShowScrollBar(sv, 0, 1);
16674
17701
  } else {
16675
17702
  scrollXRef.current = 0;
16676
- gui13.ShowScrollBar(sv, 0, false);
17703
+ ShowScrollBar(sv, 0, 0);
16677
17704
  }
16678
17705
  if (natH > svH) {
16679
- gui13.SetScrollInfo(sv, 1, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
16680
- gui13.ShowScrollBar(sv, 1, true);
17706
+ gui12.SetScrollInfo(sv, 1, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
17707
+ ShowScrollBar(sv, 1, 1);
16681
17708
  } else {
16682
17709
  scrollYRef.current = 0;
16683
- gui13.ShowScrollBar(sv, 1, false);
17710
+ ShowScrollBar(sv, 1, 0);
16684
17711
  }
16685
17712
  }
16686
17713
  (0, import_react12.useLayoutEffect)(() => {
@@ -16696,7 +17723,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16696
17723
  } else {
16697
17724
  scrollXRef.current = newPos;
16698
17725
  }
16699
- gui13.SetWindowPos(
17726
+ SetWindowPos(
16700
17727
  content,
16701
17728
  0,
16702
17729
  -scrollXRef.current,
@@ -16706,14 +17733,14 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16706
17733
  1 | 4
16707
17734
  /* gui.SetWindowPosFlag.SWP_NOZORDER */
16708
17735
  );
16709
- gui13.SetScrollInfo(sv, bar, { pos: newPos }, true);
17736
+ gui12.SetScrollInfo(sv, bar, { pos: newPos }, true);
16710
17737
  }
16711
17738
  function handleScroll(e, bar) {
16712
17739
  const sv = svRef.current;
16713
17740
  const content = contentRef.current;
16714
17741
  if (!sv || !content)
16715
17742
  return;
16716
- const info = gui13.GetScrollInfo(sv, bar);
17743
+ const info = gui12.GetScrollInfo(sv, bar);
16717
17744
  const maxPos = info.max - info.page + 1;
16718
17745
  const code = e.wParam & 65535;
16719
17746
  const ref_ = bar === 1 ? scrollYRef : scrollXRef;
@@ -16747,7 +17774,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16747
17774
  if (!isHorz && contentHeight === void 0)
16748
17775
  return;
16749
17776
  const bar = isHorz ? 0 : 1;
16750
- const info = gui13.GetScrollInfo(sv, bar);
17777
+ const info = gui12.GetScrollInfo(sv, bar);
16751
17778
  const maxPos = info.max - info.page + 1;
16752
17779
  const ref_ = isHorz ? scrollXRef : scrollYRef;
16753
17780
  let newPos = ref_.current + dy;
@@ -16764,7 +17791,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16764
17791
  }, onEvent: {
16765
17792
  fn: (e) => {
16766
17793
  if (e.msg === 132 || e.msg === 161) {
16767
- return gui13.DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
17794
+ return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
16768
17795
  }
16769
17796
  if (e.msg === 277) {
16770
17797
  handleScroll(
@@ -16796,7 +17823,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
16796
17823
  // _build/lib/react-qw/components/Slider.js
16797
17824
  var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
16798
17825
  var import_react13 = __toESM(require_react(), 1);
16799
- import * as gui14 from "gui";
17826
+ import * as gui13 from "gui";
16800
17827
  var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 100, vertical = false, disabled, style }, ref) => {
16801
17828
  const wrapperRef = (0, import_react13.useRef)(null);
16802
17829
  const sliderRef = (0, import_react13.useRef)(null);
@@ -16805,14 +17832,14 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
16805
17832
  if (!h)
16806
17833
  return;
16807
17834
  const lParam = min & 65535 | (max & 65535) << 16;
16808
- gui14.SendMessage(h, 1030, 0, lParam);
16809
- gui14.SendMessage(h, 1029, 1, value);
17835
+ gui13.SendMessage(h, 1030, 0, lParam);
17836
+ gui13.SendMessage(h, 1029, 1, value);
16810
17837
  }, [min, max]);
16811
17838
  (0, import_react13.useEffect)(() => {
16812
17839
  const h = sliderRef.current;
16813
17840
  if (!h)
16814
17841
  return;
16815
- gui14.SendMessage(h, 1029, 1, value);
17842
+ gui13.SendMessage(h, 1029, 1, value);
16816
17843
  }, [value]);
16817
17844
  const tbStyle = 268435456 | 65536 | 1 | (vertical ? 2 : 0);
16818
17845
  return (0, import_jsx_runtime12.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style, ref: (h) => {
@@ -16823,13 +17850,13 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
16823
17850
  ref.current = h;
16824
17851
  }, onEvent: (e) => {
16825
17852
  if (e.msg === 132 || e.msg === 161) {
16826
- return gui14.DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
17853
+ return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
16827
17854
  }
16828
17855
  if (e.msg === 276 || e.msg === 277) {
16829
17856
  const h = sliderRef.current;
16830
17857
  if (!h)
16831
17858
  return 0;
16832
- const pos = gui14.SendMessage(h, 1024, 0, 0);
17859
+ const pos = gui13.SendMessage(h, 1024, 0, 0);
16833
17860
  onChange?.(pos);
16834
17861
  return 0;
16835
17862
  }
@@ -16842,18 +17869,7 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
16842
17869
  // _build/lib/react-qw/components/Tab.js
16843
17870
  var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
16844
17871
  var import_react14 = __toESM(require_react(), 1);
16845
- import * as gui15 from "gui";
16846
- import * as ffi6 from "ffi";
16847
- function textToUtf163(s) {
16848
- const buf = new ArrayBuffer((s.length + 1) * 2);
16849
- const dv = new DataView(buf);
16850
- for (let i = 0; i < s.length; i++)
16851
- dv.setUint16(i * 2, s.charCodeAt(i), true);
16852
- return buf;
16853
- }
16854
- function readI324(ptr, offset) {
16855
- return ffi6.readByte(ptr + offset) | ffi6.readByte(ptr + offset + 1) << 8 | ffi6.readByte(ptr + offset + 2) << 16 | ffi6.readByte(ptr + offset + 3) << 24;
16856
- }
17872
+ import * as gui14 from "gui";
16857
17873
  var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex, defaultSelectedIndex = 0, onChange, style }, ref) => {
16858
17874
  const [internalIndex, setInternalIndex] = (0, import_react14.useState)(defaultSelectedIndex);
16859
17875
  const isControlled = controlledIndex !== void 0;
@@ -16863,32 +17879,36 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
16863
17879
  const h = tabHwnd.current;
16864
17880
  if (!h)
16865
17881
  return;
16866
- gui15.SendMessage(h, 4873, 0, 0);
17882
+ gui14.SendMessage(h, 4873, 0, 0);
16867
17883
  for (let i = 0; i < tabs.length; i++) {
16868
- const titleBuf = textToUtf163(tabs[i].title);
16869
- const tci = new ArrayBuffer(40);
16870
- const dv = new DataView(tci);
16871
- dv.setUint32(0, 1, true);
16872
- dv.setBigUint64(16, BigInt(ffi6.bufferPtr(titleBuf)), true);
16873
- dv.setInt32(24, tabs[i].title.length + 1, true);
16874
- const tciPtr = ffi6.bufferPtr(tci);
16875
- gui15.SendMessage(h, 4926, i, tciPtr);
17884
+ const titleBuf = WCHAR.encode(tabs[i].title);
17885
+ const tci = TCITEMW.encode({
17886
+ mask: 1,
17887
+ dwState: 0,
17888
+ dwStateMask: 0,
17889
+ pszText: titleBuf.ptr,
17890
+ cchTextMax: tabs[i].title.length + 1,
17891
+ iImage: 0,
17892
+ lParam: 0
17893
+ });
17894
+ const tciPtr = tci.ptr;
17895
+ gui14.SendMessage(h, 4926, i, tciPtr);
16876
17896
  }
16877
- gui15.SendMessage(h, 4876, sel, 0);
17897
+ gui14.SendMessage(h, 4876, sel, 0);
16878
17898
  }, [tabs]);
16879
17899
  (0, import_react14.useEffect)(() => {
16880
17900
  const h = tabHwnd.current;
16881
17901
  if (h)
16882
- gui15.SendMessage(h, 4876, sel, 0);
17902
+ gui14.SendMessage(h, 4876, sel, 0);
16883
17903
  }, [sel]);
16884
17904
  return (0, import_jsx_runtime13.jsxs)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
16885
17905
  if (e.msg === 78) {
16886
17906
  const h = tabHwnd.current;
16887
17907
  if (!h)
16888
17908
  return;
16889
- const code = readI324(e.lParam, 16);
17909
+ const code = nmCode(e.lParam);
16890
17910
  if (code === -552 || code === -2) {
16891
- const newSel = gui15.SendMessage(h, 4875, 0, 0);
17911
+ const newSel = gui14.SendMessage(h, 4875, 0, 0);
16892
17912
  if (newSel !== sel) {
16893
17913
  if (!isControlled)
16894
17914
  setInternalIndex(newSel);
@@ -16901,79 +17921,50 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
16901
17921
 
16902
17922
  // _build/lib/react-qw/components/Tooltip.js
16903
17923
  var import_react15 = __toESM(require_react(), 1);
16904
- import * as gui16 from "gui";
16905
- import * as ffi7 from "ffi";
17924
+ import * as gui15 from "gui";
16906
17925
 
16907
17926
  // _build/lib/react-qw/components/TreeView.js
16908
17927
  var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
16909
17928
  var import_react16 = __toESM(require_react(), 1);
16910
- import * as gui17 from "gui";
16911
- import * as ffi8 from "ffi";
16912
- function textToUtf164(s) {
16913
- const buf = new ArrayBuffer((s.length + 1) * 2);
16914
- const dv = new DataView(buf);
16915
- for (let i = 0; i < s.length; i++)
16916
- dv.setUint16(i * 2, s.charCodeAt(i), true);
16917
- return buf;
16918
- }
16919
- function readI325(ptr, offset) {
16920
- return ffi8.readByte(ptr + offset) | ffi8.readByte(ptr + offset + 1) << 8 | ffi8.readByte(ptr + offset + 2) << 16 | ffi8.readByte(ptr + offset + 3) << 24;
16921
- }
16922
- function bufPtr3(buf) {
16923
- return ffi8.bufferPtr(buf);
16924
- }
16925
- function setPtr(dv, offset, ptr) {
16926
- dv.setUint32(offset, ptr & 4294967295, true);
16927
- dv.setUint32(offset + 4, Math.floor(ptr / 4294967296), true);
16928
- }
17929
+ import * as gui16 from "gui";
16929
17930
  function buildTvItem(textPtr, cChildren) {
16930
17931
  let mask = 1;
16931
17932
  if (cChildren > 0)
16932
17933
  mask |= 64;
16933
- const buf = new ArrayBuffer(56);
16934
- const dv = new DataView(buf);
16935
- dv.setUint32(0, mask, true);
16936
- setPtr(dv, 8, 0);
16937
- dv.setUint32(16, 0, true);
16938
- dv.setUint32(20, 0, true);
16939
- setPtr(dv, 24, textPtr);
16940
- dv.setInt32(32, 260, true);
16941
- dv.setInt32(36, 0, true);
16942
- dv.setInt32(40, 0, true);
16943
- dv.setInt32(44, cChildren, true);
16944
- setPtr(dv, 48, 0);
16945
- return buf;
16946
- }
16947
- function buildTvInsertStruct(hParent, hInsertAfter, itemBuf) {
16948
- const buf = new ArrayBuffer(72);
16949
- const dv = new DataView(buf);
16950
- setPtr(dv, 0, hParent);
16951
- setPtr(dv, 8, hInsertAfter);
16952
- const src = new DataView(itemBuf);
16953
- for (let i = 0; i < 56; i += 4)
16954
- dv.setUint32(16 + i, src.getUint32(i, true), true);
16955
- return buf;
17934
+ return TVITEM.encode({
17935
+ mask,
17936
+ hItem: 0,
17937
+ state: 0,
17938
+ stateMask: 0,
17939
+ pszText: textPtr,
17940
+ cchTextMax: 260,
17941
+ iImage: 0,
17942
+ iSelectedImage: 0,
17943
+ cChildren,
17944
+ lParam: 0
17945
+ });
16956
17946
  }
16957
17947
  function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
16958
17948
  for (const node of nodes) {
16959
17949
  const cChildren = node.children && node.children.length > 0 ? 1 : 0;
16960
- const textBuf = textToUtf164(node.label);
16961
- const itemBuf = buildTvItem(bufPtr3(textBuf), cChildren);
16962
- const tvins = buildTvInsertStruct(parentHandle, -65536, itemBuf);
16963
- const hItem = gui17.SendMessage(hTree, 4402, 0, bufPtr3(tvins));
17950
+ const textBuf = WCHAR.encode(node.label);
17951
+ const itemBuf = buildTvItem(textBuf.ptr, cChildren);
17952
+ const item = TVITEM.decode(itemBuf);
17953
+ const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536, item });
17954
+ const hItem = gui16.SendMessage(hTree, 4402, 0, tvins.ptr);
16964
17955
  hItemMap.set(hItem, node);
16965
17956
  if (node.key)
16966
17957
  keyMap.set(node.key, hItem);
16967
17958
  if (node.children && node.children.length > 0) {
16968
17959
  insertItems(hTree, node.children, hItem, hItemMap, keyMap);
16969
- gui17.SendMessage(hTree, 4354, 2, hItem);
17960
+ gui16.SendMessage(hTree, 4354, 2, hItem);
16970
17961
  }
16971
17962
  }
16972
17963
  }
16973
17964
  function deleteAllItems(hTree) {
16974
- const n = gui17.SendMessage(hTree, 4357, 0, 0);
17965
+ const n = gui16.SendMessage(hTree, 4357, 0, 0);
16975
17966
  if (n > 0)
16976
- gui17.SendMessage(
17967
+ gui16.SendMessage(
16977
17968
  hTree,
16978
17969
  4353,
16979
17970
  1,
@@ -17005,7 +17996,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
17005
17996
  const h = tvRef.current;
17006
17997
  if (!h)
17007
17998
  return;
17008
- gui17.SendMessage(
17999
+ gui16.SendMessage(
17009
18000
  h,
17010
18001
  4396,
17011
18002
  0,
@@ -17021,16 +18012,16 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
17021
18012
  return;
17022
18013
  const hItem = keyMapRef.current.get(selKey);
17023
18014
  if (hItem !== void 0)
17024
- gui17.SendMessage(h, 4363, 9, hItem);
18015
+ gui16.SendMessage(h, 4363, 9, hItem);
17025
18016
  }, [selKey]);
17026
18017
  return (0, import_jsx_runtime14.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
17027
18018
  if (e.msg === 78) {
17028
- const code = readI325(e.lParam, 16);
18019
+ const code = nmCode(e.lParam);
17029
18020
  if (code === -451) {
17030
18021
  const h = tvRef.current;
17031
18022
  if (!h)
17032
18023
  return;
17033
- const hCaret = gui17.SendMessage(h, 4362, 9, 0);
18024
+ const hCaret = gui16.SendMessage(h, 4362, 9, 0);
17034
18025
  const node = hItemMapRef.current.get(hCaret) ?? null;
17035
18026
  const key = node?.key ?? null;
17036
18027
  if (!isControlled)
@@ -17046,99 +18037,63 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
17046
18037
  // _build/lib/react-qw/components/PathPicker.js
17047
18038
  var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
17048
18039
  var import_react17 = __toESM(require_react(), 1);
17049
- import * as ffi9 from "ffi";
17050
- import * as win3 from "win";
17051
- var FFI_PTR2 = ffi9.FFI_TYPE_POINTER;
17052
- var FFI_U32 = ffi9.FFI_TYPE_UINT32;
17053
- var _GetOpenFileNameW = 0;
17054
- var _SHBrowseForFolderW = 0;
17055
- var _SHGetPathFromIDListW = 0;
17056
- var _CoTaskMemFree = 0;
17057
- function ensureDlls() {
17058
- if (_GetOpenFileNameW)
17059
- return true;
17060
- const comdlg32 = win3.LoadLibrary("comdlg32.dll");
17061
- const shell32 = win3.LoadLibrary("shell32.dll");
17062
- const ole32 = win3.LoadLibrary("ole32.dll");
17063
- if (!comdlg32 || !shell32 || !ole32)
17064
- return false;
17065
- const load = (lib, name) => win3.GetProcAddress(lib, name) || 0;
17066
- _GetOpenFileNameW = load(comdlg32, "GetOpenFileNameW");
17067
- _SHBrowseForFolderW = load(shell32, "SHBrowseForFolderW");
17068
- _SHGetPathFromIDListW = load(shell32, "SHGetPathFromIDListW");
17069
- _CoTaskMemFree = load(ole32, "CoTaskMemFree");
17070
- return !!_GetOpenFileNameW && !!_SHBrowseForFolderW && !!_SHGetPathFromIDListW && !!_CoTaskMemFree;
17071
- }
17072
- function strToWide(s) {
17073
- return new TextEncoder("utf-16le").encode(s + "\0").buffer;
17074
- }
17075
- var _decoder = new TextDecoder("utf-16le");
17076
- function wideToStr(buf, offset = 0) {
17077
- const str = _decoder.decode(new Uint8Array(buf, offset));
17078
- const nullIdx = str.indexOf("\0");
17079
- return nullIdx >= 0 ? str.substring(0, nullIdx) : str;
17080
- }
17081
- function setPtr2(dv, off, ptr) {
17082
- dv.setUint32(off, ptr & 4294967295, true);
17083
- dv.setUint32(off + 4, Math.floor(ptr / 4294967296), true);
17084
- }
18040
+
18041
+ // _build/lib/windows/comdlg32.js
18042
+ var b3 = (name, sig) => bind("comdlg32.dll", name, sig);
18043
+ var GetOpenFileName = /* @__PURE__ */ b3("GetOpenFileNameW", "<BYTE>ptr -> u32");
18044
+
18045
+ // _build/lib/windows/shell32.js
18046
+ var b4 = (name, sig) => bind("shell32.dll", name, sig);
18047
+ var SHBrowseForFolder = /* @__PURE__ */ b4("SHBrowseForFolderW", "<BYTE>ptr -> <>ptr");
18048
+ var SHGetPathFromIDList = /* @__PURE__ */ b4("SHGetPathFromIDListW", "<>ptr <BYTE>ptr -> u32");
18049
+
18050
+ // _build/lib/windows/ole32.js
18051
+ var b5 = (name, sig) => bind("ole32.dll", name, sig);
18052
+ var CoTaskMemFree = /* @__PURE__ */ b5("CoTaskMemFree", "<>ptr -> void");
18053
+
18054
+ // _build/lib/react-qw/components/PathPicker.js
17085
18055
  function openFileDialog(owner, filter, title, multiple) {
17086
- if (!ensureDlls())
17087
- return null;
17088
- const structBuf = new ArrayBuffer(152);
17089
- const sv = new DataView(structBuf);
17090
- const fileBuf = new ArrayBuffer(260 * 2);
17091
- const filterWide = strToWide(filter);
17092
- const titleWide = title ? strToWide(title) : null;
17093
- sv.setUint32(0, 152, true);
17094
- setPtr2(sv, 8, owner);
17095
- setPtr2(sv, 24, ffi9.bufferPtr(filterWide));
17096
- setPtr2(sv, 48, ffi9.bufferPtr(fileBuf));
17097
- sv.setUint32(56, 260, true);
18056
+ const fileBuf = WCHAR.alloc(260);
18057
+ const filterWide = WCHAR.encode(filter);
18058
+ const titleWide = title ? WCHAR.encode(title) : null;
17098
18059
  let flags = 4096 | 2048 | 8;
17099
18060
  if (multiple)
17100
18061
  flags |= 512;
17101
18062
  flags |= 524288;
17102
- sv.setUint32(96, flags, true);
17103
- if (titleWide)
17104
- setPtr2(sv, 88, ffi9.bufferPtr(titleWide));
17105
- const ret = ffi9.ffiCall(_GetOpenFileNameW, [FFI_PTR2], [structBuf], FFI_U32);
18063
+ const ofn = OPENFILENAMEW.encode({
18064
+ lStructSize: OPENFILENAMEW.size,
18065
+ hwndOwner: owner,
18066
+ lpstrFilter: filterWide.ptr,
18067
+ lpstrFile: fileBuf.ptr,
18068
+ nMaxFile: 260,
18069
+ lpstrTitle: titleWide?.ptr ?? 0,
18070
+ Flags: flags
18071
+ });
18072
+ const ret = GetOpenFileName(ofn);
17106
18073
  if (!ret)
17107
18074
  return null;
17108
18075
  if (!multiple) {
17109
- return wideToStr(fileBuf);
17110
- }
17111
- const dir = wideToStr(fileBuf);
17112
- let pos = (dir.length + 1) * 2;
17113
- const files = [];
17114
- while (pos < fileBuf.byteLength) {
17115
- const f = wideToStr(fileBuf, pos);
17116
- if (f.length === 0)
17117
- break;
17118
- files.push(dir + "\\" + f);
17119
- pos += (f.length + 1) * 2;
18076
+ return WCHAR.decode(fileBuf);
17120
18077
  }
17121
- if (files.length === 0)
17122
- return [dir];
17123
- return files;
18078
+ const strs = new TextDecoder("utf-16le").decode(new Uint8Array(fileBuf)).split("\0");
18079
+ const dir = strs[0] ?? "";
18080
+ const files = strs.slice(1).filter((f) => f.length > 0).map((f) => dir + "\\" + f);
18081
+ return files.length > 0 ? files : [dir];
17124
18082
  }
17125
18083
  function openFolderDialog(owner, title) {
17126
- if (!ensureDlls())
17127
- return null;
17128
- const structBuf = new ArrayBuffer(64);
17129
- const sv = new DataView(structBuf);
17130
- const titleWide = title ? strToWide(title) : null;
17131
- setPtr2(sv, 0, owner);
17132
- if (titleWide)
17133
- setPtr2(sv, 24, ffi9.bufferPtr(titleWide));
17134
- sv.setUint32(32, 65, true);
17135
- const pidl = ffi9.ffiCall(_SHBrowseForFolderW, [FFI_PTR2], [structBuf], FFI_PTR2);
18084
+ const titleWide = title ? WCHAR.encode(title) : null;
18085
+ const bi = BROWSEINFOW.encode({
18086
+ hwndOwner: owner,
18087
+ lpszTitle: titleWide?.ptr ?? 0,
18088
+ ulFlags: 65
18089
+ });
18090
+ const pidl = SHBrowseForFolder(bi);
17136
18091
  if (!pidl)
17137
18092
  return null;
17138
- const pathBuf = new ArrayBuffer(260 * 2);
17139
- const ok = ffi9.ffiCall(_SHGetPathFromIDListW, [ffi9.FFI_TYPE_UINT64, FFI_PTR2], [pidl, pathBuf], FFI_U32);
17140
- ffi9.ffiCall(_CoTaskMemFree, [ffi9.FFI_TYPE_UINT64], [pidl], ffi9.FFI_TYPE_VOID);
17141
- return ok ? wideToStr(pathBuf) : null;
18093
+ const pathBuf = WCHAR.alloc(260);
18094
+ const ok = SHGetPathFromIDList(pidl, pathBuf);
18095
+ CoTaskMemFree(pidl);
18096
+ return ok ? WCHAR.decode(pathBuf) : null;
17142
18097
  }
17143
18098
  var PathPicker = (0, import_react17.forwardRef)((props, ref) => {
17144
18099
  const { type = "file", filter = "All Files\0*.*\0\0", title, disabled, style } = props;
@@ -17189,7 +18144,7 @@ var rootMap = /* @__PURE__ */ new Map();
17189
18144
  function ensureDefaultClass() {
17190
18145
  if (defaultClassRegistered)
17191
18146
  return DEFAULT_CLASS;
17192
- gui18.RegisterClass(DEFAULT_CLASS, (hwnd2, msg, wParam, lParam) => {
18147
+ gui17.RegisterClass(DEFAULT_CLASS, (hwnd2, msg, wParam, lParam) => {
17193
18148
  const entry = rootMap.get(hwnd2);
17194
18149
  if (msg === 2 && entry) {
17195
18150
  rootMap.delete(hwnd2);
@@ -17202,7 +18157,7 @@ function ensureDefaultClass() {
17202
18157
  return result;
17203
18158
  if (msg === 5)
17204
18159
  forceFlexLayout(hwnd2);
17205
- return gui18.DefWindowProc(hwnd2, msg, wParam, lParam);
18160
+ return DefWindowProc(hwnd2, msg, wParam, lParam);
17206
18161
  });
17207
18162
  defaultClassRegistered = true;
17208
18163
  return DEFAULT_CLASS;
@@ -17215,15 +18170,15 @@ function createRoot(container) {
17215
18170
  const ws = (cfg.ws ?? 0) | 13565952;
17216
18171
  const w = (cfg.width ?? 800) * scaleFactor;
17217
18172
  const h = (cfg.height ?? 600) * scaleFactor;
17218
- const [sw, sh] = gui18.GetScreenSize();
18173
+ const [sw, sh] = [GetSystemMetrics(0), GetSystemMetrics(1)];
17219
18174
  const x = cfg.x === void 0 ? (sw - w) / 2 | 0 : cfg.x === -2147483648 ? -2147483648 : cfg.x * scaleFactor;
17220
18175
  const y = cfg.y === void 0 ? (sh - h) / 2 | 0 : cfg.y === -2147483648 ? -2147483648 : cfg.y * scaleFactor;
17221
- const hwin = gui18.CreateWindow(className, cfg.text || "", ws, x, y, w, h, null, null);
18176
+ const hwin = gui17.CreateWindow(className, cfg.text || "", ws, x, y, w, h, null, null);
17222
18177
  if (!hwin)
17223
18178
  throw new Error("CreateWindow failed");
17224
18179
  hwnd2 = hwin;
17225
18180
  if (!cfg.noShowWindow)
17226
- gui18.ShowWindow(hwnd2);
18181
+ gui17.ShowWindow(hwnd2);
17227
18182
  } else {
17228
18183
  hwnd2 = container;
17229
18184
  }
@@ -17253,29 +18208,29 @@ function render(element, containerOrConfig, _callback) {
17253
18208
  // _build/test/test_react_hidden.js
17254
18209
  var WS_CHILD = 1073741824;
17255
18210
  var WS_VISIBLE = 268435456;
17256
- gui19.RegisterClass("ReactHidden", (hwnd2, msg, wParam, lParam) => {
18211
+ gui18.RegisterClass("ReactHidden", (hwnd2, msg, wParam, lParam) => {
17257
18212
  if (!hwnd2)
17258
- return gui19.DefWindowProc(hwnd2, msg, wParam, lParam);
18213
+ return gui18.DefWindowProc(hwnd2, msg, wParam, lParam);
17259
18214
  if (msg === 2) {
17260
- gui19.PostQuitMessage(0);
18215
+ gui18.PostQuitMessage(0);
17261
18216
  return 0;
17262
18217
  }
17263
18218
  if (msg === 513) {
17264
- gui19.PostQuitMessage(0);
18219
+ gui18.PostQuitMessage(0);
17265
18220
  return 0;
17266
18221
  }
17267
- return gui19.DefWindowProc(hwnd2, msg, wParam, lParam);
18222
+ return gui18.DefWindowProc(hwnd2, msg, wParam, lParam);
17268
18223
  });
17269
18224
  function App() {
17270
18225
  const [hidden, setHidden] = (0, import_react18.useState)(true);
17271
18226
  (0, import_react18.useEffect)(() => {
17272
- os3.setTimeout(() => setHidden(false), 2e3);
18227
+ os5.setTimeout(() => setHidden(false), 2e3);
17273
18228
  }, []);
17274
18229
  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 } })] });
17275
18230
  }
17276
- var hwnd = gui19.CreateWindow("ReactHidden", "Hidden Prop Test", 13565952, 200, 200, 500, 400, null, null);
18231
+ var hwnd = gui18.CreateWindow("ReactHidden", "Hidden Prop Test", 13565952, 200, 200, 500, 400, null, null);
17277
18232
  if (hwnd) {
17278
- gui19.ShowWindow(hwnd);
18233
+ gui18.ShowWindow(hwnd);
17279
18234
  render((0, import_jsx_runtime16.jsx)(App, {}), hwnd);
17280
18235
  }
17281
18236
  /*! Bundled license information: