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