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