quickwin 1.3.0 → 2.1.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 +18 -24
- package/README.md +17 -23
- package/examples/PdfCanvas.js +8 -37
- package/examples/PdfCanvas.tsx +11 -41
- package/examples/exec_server.js +20155 -1420
- 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 +25 -82
- package/examples/pdf_preview2.ts +27 -84
- package/examples/pdf_viewer.js +1424 -1180
- package/examples/pdf_viewer.tsx +16 -67
- package/examples/setres.js +22 -47
- package/examples/setres.ts +23 -57
- package/examples/test_gallery.js +1418 -1075
- package/examples/test_react_lazy.js +1391 -1059
- package/examples/test_react_listbox.js +1390 -1058
- package/examples/test_root_window.js +1384 -1052
- package/examples/test_tab.js +1391 -1059
- package/lib/abort.js +70 -0
- package/lib/abort.ts +69 -0
- package/lib/certs.js +219 -0
- package/lib/certs.ts +229 -0
- package/lib/exec-log.js +15 -0
- package/lib/exec-log.ts +30 -0
- package/lib/fetch.js +88 -7
- package/lib/fetch.ts +73 -7
- package/lib/ffi/bind.js +441 -0
- package/lib/ffi/bind.ts +539 -0
- package/lib/ffi/ctype.js +194 -0
- package/lib/ffi/ctype.ts +369 -0
- package/lib/ffi/index.js +6 -0
- package/lib/ffi/index.ts +6 -0
- package/lib/ffi/struct.js +490 -0
- package/lib/ffi/struct.ts +753 -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 +18 -37
- package/lib/react-qw/components/Input.js +3 -10
- package/lib/react-qw/components/Link.js +6 -19
- package/lib/react-qw/components/ListView.js +50 -154
- package/lib/react-qw/components/PathPicker.js +28 -88
- 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 +6 -22
- package/lib/react-qw/components/Tooltip.js +10 -21
- package/lib/react-qw/components/TreeView.js +8 -31
- package/lib/react-qw/index.js +5 -3
- package/lib/react-qw/index.ts +8 -3
- package/lib/react-qw/nmhdr.js +3 -24
- package/lib/react-qw/nmhdr.ts +5 -30
- 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 +20 -23
- package/lib/text-measure.ts +22 -26
- package/lib/websocket.js +44 -4
- package/lib/websocket.ts +40 -4
- package/lib/windows/advapi32.js +53 -0
- package/lib/windows/advapi32.ts +64 -0
- package/lib/windows/comctl32.js +18 -0
- package/lib/windows/comctl32.ts +19 -0
- package/lib/windows/comdlg32.js +8 -0
- package/lib/windows/comdlg32.ts +10 -0
- package/lib/windows/gdi32.js +392 -0
- package/lib/windows/gdi32.ts +420 -0
- package/lib/windows/kernel32.js +262 -0
- package/lib/windows/kernel32.ts +291 -0
- package/lib/windows/msimg32.js +38 -0
- package/lib/windows/msimg32.ts +45 -0
- package/lib/windows/ntdll.js +9 -0
- package/lib/windows/ntdll.ts +11 -0
- package/lib/windows/ole32.js +7 -0
- package/lib/windows/ole32.ts +9 -0
- package/lib/windows/psapi.js +32 -0
- package/lib/windows/psapi.ts +37 -0
- package/lib/windows/shell32.js +13 -0
- package/lib/windows/shell32.ts +16 -0
- package/lib/windows/structs.js +519 -0
- package/lib/windows/structs.ts +566 -0
- package/lib/windows/user32.js +572 -0
- package/lib/windows/user32.ts +607 -0
- package/lib/windows/version.js +29 -0
- package/lib/windows/version.ts +35 -0
- package/lib/windows/winspool.js +71 -0
- package/lib/windows/winspool.ts +80 -0
- package/package.json +1 -1
- package/quickwin.d.ts +31 -40
- package/quickwin_const.d.ts +137 -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 +19 -4
- package/test/run.ts +20 -5
- package/test/test_basic_fetch.js +29 -0
- package/test/test_basic_fetch.ts +26 -0
- package/test/test_ffi.js +27 -45
- package/test/test_ffi.ts +35 -54
- package/test/test_ffi_abi.js +290 -0
- package/test/test_ffi_abi.ts +274 -0
- package/test/test_ffi_array.js +116 -0
- package/test/test_ffi_array.ts +141 -0
- package/test/test_ffi_bind.js +620 -8
- package/test/test_ffi_bind.ts +630 -8
- package/test/test_ffi_struct.js +632 -88
- package/test/test_ffi_struct.ts +666 -91
- 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_files.js +102 -0
- package/test/test_files.ts +121 -0
- package/test/test_gdi_draw.js +681 -0
- package/test/test_gdi_draw.ts +725 -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 +74 -11
- package/test/test_net_fetch.ts +73 -10
- package/test/test_net_websocket.js +1 -1
- package/test/test_net_websocket.ts +1 -1
- package/test/test_printer.js +137 -0
- package/test/test_printer.ts +148 -0
- package/test/test_proc.js +141 -0
- package/test/test_proc.ts +163 -0
- package/test/test_react_complex.js +1401 -1069
- package/test/test_react_counter.js +1391 -1059
- package/test/test_react_flex.js +1411 -1072
- package/test/test_react_hidden.js +1394 -1062
- package/test/test_react_listview_link.js +1391 -1059
- package/test/test_react_notify.js +18638 -0
- package/test/test_react_render.js +1391 -1059
- package/test/test_registry.js +74 -0
- package/test/test_registry.ts +95 -0
- package/test/test_sysinfo.js +122 -0
- package/test/test_sysinfo.ts +141 -0
- package/test/test_wolfssl_read.js +45 -43
- package/test/test_wolfssl_read.ts +42 -40
- 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/lib/ffi-bind.js +0 -85
- package/lib/ffi-bind.ts +0 -170
- package/lib/ffi-struct.js +0 -224
- package/lib/ffi-struct.ts +0 -239
- package/lib/win-common-structs.js +0 -39
- package/lib/win-common-structs.ts +0 -41
package/examples/pdf_viewer.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
|
}
|
|
@@ -15355,146 +15355,180 @@ var require_constants = __commonJS({
|
|
|
15355
15355
|
|
|
15356
15356
|
// _build/examples/pdf_viewer.js
|
|
15357
15357
|
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
|
|
15358
|
-
var import_react19 = __toESM(require_react(), 1);
|
|
15359
|
-
import "../lib/polyfill.js";
|
|
15360
|
-
import * as std from "std";
|
|
15361
|
-
import * as gui19 from "gui";
|
|
15362
|
-
import * as win5 from "win";
|
|
15363
|
-
import * as ffi13 from "ffi";
|
|
15364
|
-
|
|
15365
|
-
// _build/lib/react-qw/index.js
|
|
15366
|
-
import * as gui18 from "gui";
|
|
15367
15358
|
|
|
15368
|
-
// _build/lib/
|
|
15369
|
-
|
|
15370
|
-
var import_react = __toESM(require_react(), 1);
|
|
15371
|
-
var import_constants = __toESM(require_constants(), 1);
|
|
15372
|
-
import * as gui3 from "gui";
|
|
15359
|
+
// _build/lib/ffi/ctype.js
|
|
15360
|
+
import { bufferPtr } from "ffi";
|
|
15373
15361
|
import * as os from "os";
|
|
15374
|
-
|
|
15375
|
-
|
|
15376
|
-
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15385
|
-
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
|
|
15392
|
-
|
|
15393
|
-
|
|
15394
|
-
|
|
15395
|
-
|
|
15396
|
-
|
|
15397
|
-
|
|
15398
|
-
|
|
15399
|
-
|
|
15400
|
-
|
|
15362
|
+
var C_BASIC_TYPE = [
|
|
15363
|
+
"void",
|
|
15364
|
+
"u8",
|
|
15365
|
+
"i8",
|
|
15366
|
+
"u16",
|
|
15367
|
+
"i16",
|
|
15368
|
+
"u32",
|
|
15369
|
+
"i32",
|
|
15370
|
+
"u64",
|
|
15371
|
+
"i64",
|
|
15372
|
+
"f32",
|
|
15373
|
+
"f64",
|
|
15374
|
+
"ptr"
|
|
15375
|
+
];
|
|
15376
|
+
var PTR_TOKEN_RE = /^<([A-Za-z_]\w*|)>ptr(!|@[A-Za-z_]\w*)?$/;
|
|
15377
|
+
function isCPtrToken(t) {
|
|
15378
|
+
return PTR_TOKEN_RE.test(t);
|
|
15379
|
+
}
|
|
15380
|
+
var VAL_TOKEN_RE = /^<([A-Za-z_]\w*)>$/;
|
|
15381
|
+
function isCValToken(t) {
|
|
15382
|
+
return VAL_TOKEN_RE.test(t);
|
|
15383
|
+
}
|
|
15384
|
+
function valName(t) {
|
|
15385
|
+
const m = VAL_TOKEN_RE.exec(t);
|
|
15386
|
+
return m?.[1] || "";
|
|
15387
|
+
}
|
|
15388
|
+
function ptrName(t) {
|
|
15389
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15390
|
+
return m?.[1] || "";
|
|
15391
|
+
}
|
|
15392
|
+
var cTokenToType = (t) => {
|
|
15393
|
+
if (isCPtrToken(t))
|
|
15394
|
+
return "ptr";
|
|
15395
|
+
if (isCValToken(t))
|
|
15396
|
+
throw new Error(`ffi: cTokenToType: by-value token "${t}" has no scalar slot type`);
|
|
15397
|
+
return t;
|
|
15398
|
+
};
|
|
15399
|
+
var PTR_SIZE = os.arch === "x64" ? 8 : 4;
|
|
15400
|
+
var SizeAlign = {
|
|
15401
|
+
u8: 1,
|
|
15402
|
+
i8: 1,
|
|
15403
|
+
u16: 2,
|
|
15404
|
+
i16: 2,
|
|
15405
|
+
u32: 4,
|
|
15406
|
+
i32: 4,
|
|
15407
|
+
u64: 8,
|
|
15408
|
+
i64: 8,
|
|
15409
|
+
f32: 4,
|
|
15410
|
+
f64: 8
|
|
15411
|
+
};
|
|
15412
|
+
var NULL = 0;
|
|
15413
|
+
function normToken(t) {
|
|
15414
|
+
if (isCPtrToken(t)) {
|
|
15415
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15416
|
+
const name = m?.[1] || "";
|
|
15417
|
+
const mod = m?.[2];
|
|
15418
|
+
return mod?.startsWith("@") ? `<${name}>ptr` : t;
|
|
15401
15419
|
}
|
|
15402
|
-
if (
|
|
15403
|
-
|
|
15404
|
-
|
|
15405
|
-
|
|
15406
|
-
|
|
15407
|
-
|
|
15420
|
+
if (isCValToken(t))
|
|
15421
|
+
return t;
|
|
15422
|
+
const at = t.indexOf("@");
|
|
15423
|
+
const base = at >= 0 ? t.slice(0, at) : t;
|
|
15424
|
+
const suffixOk = at < 0 || /^[A-Za-z_]\w*$/.test(t.slice(at + 1));
|
|
15425
|
+
if (suffixOk && base !== "ptr" && C_BASIC_TYPE.includes(base))
|
|
15426
|
+
return base;
|
|
15427
|
+
throw new Error("Unknown token: " + t);
|
|
15428
|
+
}
|
|
15429
|
+
function readScalar(dv, off, k) {
|
|
15430
|
+
switch (k) {
|
|
15431
|
+
case "u8":
|
|
15432
|
+
return dv.getUint8(off);
|
|
15433
|
+
case "i8":
|
|
15434
|
+
return dv.getInt8(off);
|
|
15435
|
+
case "u16":
|
|
15436
|
+
return dv.getUint16(off, true);
|
|
15437
|
+
case "i16":
|
|
15438
|
+
return dv.getInt16(off, true);
|
|
15439
|
+
case "u32":
|
|
15440
|
+
return dv.getUint32(off, true);
|
|
15441
|
+
case "i32":
|
|
15442
|
+
return dv.getInt32(off, true);
|
|
15443
|
+
case "u64":
|
|
15444
|
+
return dv.getBigUint64(off, true);
|
|
15445
|
+
case "i64":
|
|
15446
|
+
return dv.getBigInt64(off, true);
|
|
15447
|
+
case "f32":
|
|
15448
|
+
return dv.getFloat32(off, true);
|
|
15449
|
+
case "f64":
|
|
15450
|
+
return dv.getFloat64(off, true);
|
|
15451
|
+
case "ptr": {
|
|
15452
|
+
return PTR_SIZE === 8 ? Number(dv.getBigInt64(off, true)) : dv.getInt32(off, true);
|
|
15453
|
+
}
|
|
15408
15454
|
}
|
|
15409
15455
|
}
|
|
15410
|
-
|
|
15411
|
-
|
|
15412
|
-
|
|
15413
|
-
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
|
|
15431
|
-
|
|
15432
|
-
|
|
15433
|
-
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
|
|
15437
|
-
|
|
15438
|
-
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15456
|
+
function writeScalar(dv, off, { k, v }) {
|
|
15457
|
+
switch (k) {
|
|
15458
|
+
case "u8":
|
|
15459
|
+
dv.setUint8(off, Number(v));
|
|
15460
|
+
break;
|
|
15461
|
+
case "i8":
|
|
15462
|
+
dv.setInt8(off, Number(v));
|
|
15463
|
+
break;
|
|
15464
|
+
case "u16":
|
|
15465
|
+
dv.setUint16(off, Number(v), true);
|
|
15466
|
+
break;
|
|
15467
|
+
case "i16":
|
|
15468
|
+
dv.setInt16(off, Number(v), true);
|
|
15469
|
+
break;
|
|
15470
|
+
case "u32":
|
|
15471
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15472
|
+
break;
|
|
15473
|
+
case "i32":
|
|
15474
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15475
|
+
break;
|
|
15476
|
+
case "u64":
|
|
15477
|
+
dv.setBigUint64(off, v, true);
|
|
15478
|
+
break;
|
|
15479
|
+
case "i64":
|
|
15480
|
+
dv.setBigInt64(off, v, true);
|
|
15481
|
+
break;
|
|
15482
|
+
case "f32":
|
|
15483
|
+
dv.setFloat32(off, v, true);
|
|
15484
|
+
break;
|
|
15485
|
+
case "f64":
|
|
15486
|
+
dv.setFloat64(off, v, true);
|
|
15487
|
+
break;
|
|
15488
|
+
case "ptr": {
|
|
15489
|
+
if (v == null) {
|
|
15490
|
+
throw new Error("ffi: got null/undefined for a ptr slot; pass the imported NULL constant for empty");
|
|
15491
|
+
}
|
|
15492
|
+
if (PTR_SIZE === 8)
|
|
15493
|
+
dv.setBigUint64(off, BigInt.asUintN(64, BigInt(v)), true);
|
|
15494
|
+
else
|
|
15495
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15496
|
+
break;
|
|
15446
15497
|
}
|
|
15447
15498
|
}
|
|
15448
|
-
|
|
15449
|
-
|
|
15450
|
-
|
|
15451
|
-
if (
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
offset = Math.max(0, free / 2);
|
|
15455
|
-
else if (justify === "space-between" && n > 1)
|
|
15456
|
-
extraGap = free / (n - 1);
|
|
15457
|
-
else if (justify === "space-around") {
|
|
15458
|
-
extraGap = free / n;
|
|
15459
|
-
offset = extraGap / 2;
|
|
15460
|
-
} else if (justify === "space-evenly") {
|
|
15461
|
-
extraGap = free / (n + 1);
|
|
15462
|
-
offset = extraGap;
|
|
15499
|
+
}
|
|
15500
|
+
function writeSlot(dv, off, e) {
|
|
15501
|
+
const { k, v } = e;
|
|
15502
|
+
if (k === "u8" || k === "i8" || k === "u16" || k === "i16") {
|
|
15503
|
+
dv.setUint32(off, Number(v) >>> 0, true);
|
|
15504
|
+
return;
|
|
15463
15505
|
}
|
|
15464
|
-
|
|
15465
|
-
return sizes.map((sz, i) => {
|
|
15466
|
-
const childCrossBase = sz[crossSize];
|
|
15467
|
-
const childAlign = children[i].style.alignSelf ?? "auto";
|
|
15468
|
-
const effectiveAlign = childAlign === "auto" ? align : childAlign;
|
|
15469
|
-
let childMain = sz[mainSize];
|
|
15470
|
-
let childCross = childCrossBase;
|
|
15471
|
-
const res = { x: 0, y: 0, width: 0, height: 0 };
|
|
15472
|
-
res[mainPos] = cursor;
|
|
15473
|
-
res[crossPos] = 0;
|
|
15474
|
-
res[mainDim] = childMain;
|
|
15475
|
-
res[crossDim] = childCross;
|
|
15476
|
-
if (effectiveAlign === "stretch") {
|
|
15477
|
-
const hasExplicitCross = typeof children[i].style[crossDim] === "number";
|
|
15478
|
-
if (!hasExplicitCross) {
|
|
15479
|
-
res[crossDim] = parentCross;
|
|
15480
|
-
res[crossPos] = 0;
|
|
15481
|
-
}
|
|
15482
|
-
} else if (effectiveAlign === "flex-end") {
|
|
15483
|
-
res[crossPos] = parentCross - childCross;
|
|
15484
|
-
} else if (effectiveAlign === "center") {
|
|
15485
|
-
res[crossPos] = Math.max(0, (parentCross - childCross) / 2);
|
|
15486
|
-
}
|
|
15487
|
-
cursor += childMain + gap + extraGap;
|
|
15488
|
-
return res;
|
|
15489
|
-
});
|
|
15506
|
+
writeScalar(dv, off, e);
|
|
15490
15507
|
}
|
|
15508
|
+
var PtrArrayBuffer = class extends ArrayBuffer {
|
|
15509
|
+
ptr;
|
|
15510
|
+
constructor(byteLength) {
|
|
15511
|
+
super(byteLength);
|
|
15512
|
+
this.ptr = bufferPtr(this);
|
|
15513
|
+
}
|
|
15514
|
+
};
|
|
15491
15515
|
|
|
15492
|
-
// _build/
|
|
15493
|
-
|
|
15494
|
-
import
|
|
15516
|
+
// _build/examples/pdf_viewer.js
|
|
15517
|
+
var import_react19 = __toESM(require_react(), 1);
|
|
15518
|
+
import "../lib/polyfill.js";
|
|
15519
|
+
import * as std2 from "std";
|
|
15520
|
+
import * as gui18 from "gui";
|
|
15521
|
+
|
|
15522
|
+
// _build/lib/react-qw/index.js
|
|
15523
|
+
import * as gui17 from "gui";
|
|
15524
|
+
|
|
15525
|
+
// _build/lib/windows/user32.js
|
|
15526
|
+
import * as os3 from "os";
|
|
15495
15527
|
|
|
15496
|
-
// _build/lib/ffi
|
|
15528
|
+
// _build/lib/ffi/bind.js
|
|
15497
15529
|
import * as ffi from "ffi";
|
|
15530
|
+
import * as os2 from "os";
|
|
15531
|
+
import * as std from "std";
|
|
15498
15532
|
import * as win from "win";
|
|
15499
15533
|
|
|
15500
15534
|
// _build/lib/text-codec.js
|
|
@@ -15517,62 +15551,62 @@ function _normalizeLabel(label) {
|
|
|
15517
15551
|
function _decodeUTF8(buf, fatal) {
|
|
15518
15552
|
let out = "";
|
|
15519
15553
|
for (let i = 0; i < buf.length; ) {
|
|
15520
|
-
const
|
|
15521
|
-
if (
|
|
15522
|
-
out += String.fromCharCode(
|
|
15554
|
+
const b6 = buf[i++];
|
|
15555
|
+
if (b6 < 128) {
|
|
15556
|
+
out += String.fromCharCode(b6);
|
|
15523
15557
|
continue;
|
|
15524
15558
|
}
|
|
15525
|
-
if (
|
|
15559
|
+
if (b6 < 192) {
|
|
15526
15560
|
out += fatal ? (() => {
|
|
15527
15561
|
throw new TypeError("unexpected continuation byte");
|
|
15528
15562
|
})() : "\uFFFD";
|
|
15529
15563
|
continue;
|
|
15530
15564
|
}
|
|
15531
15565
|
let c, min;
|
|
15532
|
-
if (
|
|
15566
|
+
if (b6 < 224) {
|
|
15533
15567
|
if (i >= buf.length) {
|
|
15534
15568
|
out += fatal ? (() => {
|
|
15535
15569
|
throw new TypeError("incomplete utf-8");
|
|
15536
15570
|
})() : "\uFFFD";
|
|
15537
15571
|
break;
|
|
15538
15572
|
}
|
|
15539
|
-
const
|
|
15540
|
-
if ((
|
|
15573
|
+
const b22 = buf[i++];
|
|
15574
|
+
if ((b22 & 192) !== 128) {
|
|
15541
15575
|
out += "\uFFFD";
|
|
15542
15576
|
continue;
|
|
15543
15577
|
}
|
|
15544
|
-
c = (
|
|
15578
|
+
c = (b6 & 31) << 6 | b22 & 63;
|
|
15545
15579
|
min = 128;
|
|
15546
|
-
} else if (
|
|
15580
|
+
} else if (b6 < 240) {
|
|
15547
15581
|
if (i + 1 >= buf.length) {
|
|
15548
15582
|
out += fatal ? (() => {
|
|
15549
15583
|
throw new TypeError("incomplete utf-8");
|
|
15550
15584
|
})() : "\uFFFD";
|
|
15551
15585
|
break;
|
|
15552
15586
|
}
|
|
15553
|
-
const
|
|
15554
|
-
const
|
|
15555
|
-
if ((
|
|
15587
|
+
const b22 = buf[i++];
|
|
15588
|
+
const b32 = buf[i++];
|
|
15589
|
+
if ((b22 & 192) !== 128 || (b32 & 192) !== 128) {
|
|
15556
15590
|
out += "\uFFFD";
|
|
15557
15591
|
continue;
|
|
15558
15592
|
}
|
|
15559
|
-
c = (
|
|
15593
|
+
c = (b6 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
15560
15594
|
min = 2048;
|
|
15561
|
-
} else if (
|
|
15595
|
+
} else if (b6 < 248) {
|
|
15562
15596
|
if (i + 2 >= buf.length) {
|
|
15563
15597
|
out += fatal ? (() => {
|
|
15564
15598
|
throw new TypeError("incomplete utf-8");
|
|
15565
15599
|
})() : "\uFFFD";
|
|
15566
15600
|
break;
|
|
15567
15601
|
}
|
|
15568
|
-
const
|
|
15569
|
-
const
|
|
15570
|
-
const
|
|
15571
|
-
if ((
|
|
15602
|
+
const b22 = buf[i++];
|
|
15603
|
+
const b32 = buf[i++];
|
|
15604
|
+
const b42 = buf[i++];
|
|
15605
|
+
if ((b22 & 192) !== 128 || (b32 & 192) !== 128 || (b42 & 192) !== 128) {
|
|
15572
15606
|
out += "\uFFFD";
|
|
15573
15607
|
continue;
|
|
15574
15608
|
}
|
|
15575
|
-
c = (
|
|
15609
|
+
c = (b6 & 7) << 18 | (b22 & 63) << 12 | (b32 & 63) << 6 | b42 & 63;
|
|
15576
15610
|
min = 65536;
|
|
15577
15611
|
} else {
|
|
15578
15612
|
out += fatal ? (() => {
|
|
@@ -15710,65 +15744,9 @@ if (typeof globalThis.TextEncoder === "undefined") {
|
|
|
15710
15744
|
globalThis.TextEncoder = TextEncoderImpl;
|
|
15711
15745
|
}
|
|
15712
15746
|
|
|
15713
|
-
// _build/lib/ffi
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
u8: ffi.FFI_TYPE_UINT8,
|
|
15717
|
-
i8: ffi.FFI_TYPE_SINT8,
|
|
15718
|
-
u16: ffi.FFI_TYPE_UINT16,
|
|
15719
|
-
i16: ffi.FFI_TYPE_SINT16,
|
|
15720
|
-
u32: ffi.FFI_TYPE_UINT32,
|
|
15721
|
-
i32: ffi.FFI_TYPE_SINT32,
|
|
15722
|
-
u64: ffi.FFI_TYPE_UINT64,
|
|
15723
|
-
i64: ffi.FFI_TYPE_SINT64,
|
|
15724
|
-
f32: ffi.FFI_TYPE_FLOAT,
|
|
15725
|
-
f64: ffi.FFI_TYPE_DOUBLE,
|
|
15726
|
-
ptr: ffi.FFI_TYPE_POINTER,
|
|
15727
|
-
wstr: ffi.FFI_TYPE_POINTER
|
|
15728
|
-
};
|
|
15729
|
-
var C_ALIAS = {
|
|
15730
|
-
int: "i32",
|
|
15731
|
-
long: "i32",
|
|
15732
|
-
short: "i16",
|
|
15733
|
-
char: "i8",
|
|
15734
|
-
float: "f32",
|
|
15735
|
-
double: "f64",
|
|
15736
|
-
DWORD: "u32",
|
|
15737
|
-
UINT: "u32",
|
|
15738
|
-
ULONG: "u32",
|
|
15739
|
-
LONG: "i32",
|
|
15740
|
-
BOOL: "i32",
|
|
15741
|
-
HRESULT: "i32",
|
|
15742
|
-
SHORT: "i16",
|
|
15743
|
-
USHORT: "u16",
|
|
15744
|
-
BYTE: "u8",
|
|
15745
|
-
LONG_PTR: "ptr",
|
|
15746
|
-
ULONG_PTR: "ptr",
|
|
15747
|
-
INT_PTR: "ptr",
|
|
15748
|
-
UINT_PTR: "ptr",
|
|
15749
|
-
DWORD_PTR: "ptr",
|
|
15750
|
-
SIZE_T: "ptr",
|
|
15751
|
-
WPARAM: "ptr",
|
|
15752
|
-
LPARAM: "ptr",
|
|
15753
|
-
HANDLE: "ptr",
|
|
15754
|
-
HWND: "ptr",
|
|
15755
|
-
HDC: "ptr",
|
|
15756
|
-
HMODULE: "ptr",
|
|
15757
|
-
HFONT: "ptr",
|
|
15758
|
-
HBRUSH: "ptr",
|
|
15759
|
-
HICON: "ptr",
|
|
15760
|
-
HBITMAP: "ptr",
|
|
15761
|
-
LPVOID: "ptr",
|
|
15762
|
-
LPCVOID: "ptr",
|
|
15763
|
-
LPCWSTR: "ptr",
|
|
15764
|
-
PCWSTR: "ptr",
|
|
15765
|
-
LPWSTR: "ptr"
|
|
15766
|
-
};
|
|
15767
|
-
function normKind(t) {
|
|
15768
|
-
const k = C_ALIAS[t] ?? t;
|
|
15769
|
-
if (!(k in KIND_TO_FFI))
|
|
15770
|
-
throw new Error(`ffi-bind: invalid kind "${t}"`);
|
|
15771
|
-
return k;
|
|
15747
|
+
// _build/lib/ffi/bind.js
|
|
15748
|
+
function valCodec(name, encoders) {
|
|
15749
|
+
return encoders[name];
|
|
15772
15750
|
}
|
|
15773
15751
|
var _dllCache = /* @__PURE__ */ new Map();
|
|
15774
15752
|
function loadDll(dll) {
|
|
@@ -15783,77 +15761,1025 @@ function loadDll(dll) {
|
|
|
15783
15761
|
}
|
|
15784
15762
|
function parseSig(sig) {
|
|
15785
15763
|
const parts = sig.split(" -> ");
|
|
15786
|
-
|
|
15787
|
-
if (ret === void 0 || parts.length > 2) {
|
|
15764
|
+
if (parts.length !== 2) {
|
|
15788
15765
|
throw new Error(`ffi-bind: invalid signature "${sig}" (expected "arg1 arg2 -> ret")`);
|
|
15789
15766
|
}
|
|
15790
|
-
const
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15767
|
+
const rawArgs = parts[0].split(" ").filter((t) => t !== "");
|
|
15768
|
+
const argTokens = [];
|
|
15769
|
+
for (const raw of rawArgs) {
|
|
15770
|
+
const tok = normToken(raw);
|
|
15771
|
+
if (tok === "void") {
|
|
15772
|
+
throw new Error("Void can not in args");
|
|
15773
|
+
}
|
|
15774
|
+
argTokens.push(tok);
|
|
15775
|
+
}
|
|
15776
|
+
const retToken = normToken(parts[1]);
|
|
15777
|
+
if (isCValToken(retToken))
|
|
15778
|
+
throw new Error(`ffi-bind: "${sig}": by-value struct at the return position (<${valName(retToken)}>) is not supported \u2014 argument positions only; pass a struct out through an out-param slot instead (<N>ptr + caller buffer)`);
|
|
15779
|
+
return {
|
|
15780
|
+
argTokens,
|
|
15781
|
+
retToken,
|
|
15782
|
+
sig
|
|
15783
|
+
};
|
|
15784
|
+
}
|
|
15785
|
+
function makeFn(proc, sig, encoders, decoders) {
|
|
15786
|
+
const ps = parseSig(sig);
|
|
15787
|
+
for (const t of ps.argTokens) {
|
|
15788
|
+
if (!isCValToken(t))
|
|
15789
|
+
continue;
|
|
15790
|
+
const name = valName(t);
|
|
15791
|
+
const codec = valCodec(name, encoders);
|
|
15792
|
+
if (!codec || typeof codec.encode !== "function")
|
|
15793
|
+
throw new Error(`ffi-bind: ${sig}: by-value position <${name}> has no registered layout (available: ${Object.keys(encoders).join(", ") || "none"})`);
|
|
15794
|
+
if (typeof codec.size !== "number" || codec.size < 1)
|
|
15795
|
+
throw new Error(`ffi-bind: ${sig}: by-value position <${name}> requires a struct layout with size >= 1 (got ${codec.size}; non-struct codecs expose no size)`);
|
|
15796
|
+
}
|
|
15797
|
+
return (...a) => callPacked(proc, ps, a, encoders, decoders);
|
|
15796
15798
|
}
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15802
|
-
|
|
15803
|
-
|
|
15799
|
+
var IA32_ARG_SIZE = {
|
|
15800
|
+
u8: 4,
|
|
15801
|
+
i8: 4,
|
|
15802
|
+
u16: 4,
|
|
15803
|
+
i16: 4,
|
|
15804
|
+
u32: 4,
|
|
15805
|
+
i32: 4,
|
|
15806
|
+
u64: 8,
|
|
15807
|
+
i64: 8,
|
|
15808
|
+
f32: 4,
|
|
15809
|
+
f64: 8,
|
|
15810
|
+
ptr: PTR_SIZE
|
|
15811
|
+
};
|
|
15812
|
+
var X64_MIN_SLOTS = 4;
|
|
15813
|
+
function callPacked(proc, { argTokens, retToken, sig }, args, encoders, decoders) {
|
|
15814
|
+
const is64 = os2.arch === "x64";
|
|
15815
|
+
const getWidth = (t, is642) => {
|
|
15816
|
+
if (isCValToken(t))
|
|
15817
|
+
throw new Error(`ffi-bind: getWidth: by-value token "${t}" (dispatched by widthOf)`);
|
|
15818
|
+
if (is642)
|
|
15819
|
+
return 8;
|
|
15820
|
+
if (isCPtrToken(t))
|
|
15821
|
+
return PTR_SIZE;
|
|
15822
|
+
return IA32_ARG_SIZE[t];
|
|
15823
|
+
};
|
|
15824
|
+
const widthOf = (t) => {
|
|
15825
|
+
if (isCValToken(t)) {
|
|
15826
|
+
if (is64)
|
|
15827
|
+
return 8;
|
|
15828
|
+
const layout = valCodec(valName(t), encoders);
|
|
15829
|
+
if (!layout)
|
|
15830
|
+
throw new Error(`ffi-bind: <${valName(t)}> by-value position has no registered layout`);
|
|
15831
|
+
const size = layout.size;
|
|
15832
|
+
return size % 4 === 0 ? size : size + 4 - size % 4;
|
|
15833
|
+
}
|
|
15834
|
+
return getWidth(t, is64);
|
|
15804
15835
|
};
|
|
15836
|
+
let total = 0;
|
|
15837
|
+
for (const t of argTokens)
|
|
15838
|
+
total += widthOf(t);
|
|
15839
|
+
if (is64 && argTokens.length < X64_MIN_SLOTS)
|
|
15840
|
+
total = X64_MIN_SLOTS * 8;
|
|
15841
|
+
const argFrame = new ArrayBuffer(total);
|
|
15842
|
+
const dv = new DataView(argFrame);
|
|
15843
|
+
const held = [];
|
|
15844
|
+
let off = 0;
|
|
15845
|
+
for (let i = 0; i < argTokens.length; i++) {
|
|
15846
|
+
const argToken = argTokens[i];
|
|
15847
|
+
const nonnull = argToken.endsWith("!");
|
|
15848
|
+
const arg = args[i];
|
|
15849
|
+
if (isCPtrToken(argToken)) {
|
|
15850
|
+
const name = ptrName(argToken);
|
|
15851
|
+
if (typeof arg === "number") {
|
|
15852
|
+
if (nonnull && arg === 0)
|
|
15853
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! got 0 (null pointer forbidden here; the token marks this position non-null)`);
|
|
15854
|
+
writeSlot(dv, off, { k: "ptr", v: arg });
|
|
15855
|
+
} else {
|
|
15856
|
+
if (arg === null || arg === void 0) {
|
|
15857
|
+
throw new Error(`ffi-bind: <${name}>ptr got ${String(arg)}; pass the imported NULL constant for an empty pointer`);
|
|
15858
|
+
}
|
|
15859
|
+
const codec = encoders[name];
|
|
15860
|
+
if (!codec) {
|
|
15861
|
+
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"})`);
|
|
15862
|
+
}
|
|
15863
|
+
if (!codec.encode) {
|
|
15864
|
+
throw new Error(`ffi-bind: <${name}>ptr has no encoder (out-only codec)`);
|
|
15865
|
+
}
|
|
15866
|
+
const buf = codec.encode(arg);
|
|
15867
|
+
held.push(buf);
|
|
15868
|
+
const p = buf.ptr;
|
|
15869
|
+
if (typeof p !== "number")
|
|
15870
|
+
throw new Error("ffi-bind: codec.encode must return a PtrArrayBuffer, got plain ArrayBuffer");
|
|
15871
|
+
if (nonnull && p === 0)
|
|
15872
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! encode produced 0 (null pointer forbidden here)`);
|
|
15873
|
+
writeSlot(dv, off, { k: "ptr", v: p });
|
|
15874
|
+
}
|
|
15875
|
+
} else if (isCValToken(argToken)) {
|
|
15876
|
+
const name = valName(argToken);
|
|
15877
|
+
const codec = valCodec(name, encoders);
|
|
15878
|
+
if (!codec)
|
|
15879
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}> by-value position has no registered layout`);
|
|
15880
|
+
if (arg === null || arg === void 0)
|
|
15881
|
+
throw new Error(`ffi-bind: <${name}> value position got ${String(arg)}; pass a struct object (use <${name}>ptr to pass a pointer)`);
|
|
15882
|
+
const size = codec.size;
|
|
15883
|
+
if (!is64 || size <= 8 && (size & size - 1) === 0) {
|
|
15884
|
+
codec.encode(arg, argFrame, off);
|
|
15885
|
+
} else {
|
|
15886
|
+
const buf = new ArrayBuffer(size + 15);
|
|
15887
|
+
const base = ffi.bufferPtr(buf);
|
|
15888
|
+
const pad = (16 - base % 16) % 16;
|
|
15889
|
+
codec.encode(arg, buf, pad);
|
|
15890
|
+
held.push(buf);
|
|
15891
|
+
writeSlot(dv, off, { k: "ptr", v: base + pad });
|
|
15892
|
+
}
|
|
15893
|
+
} else {
|
|
15894
|
+
writeSlot(dv, off, { k: argToken, v: arg });
|
|
15895
|
+
}
|
|
15896
|
+
off += widthOf(argToken);
|
|
15897
|
+
}
|
|
15898
|
+
const retBuf = new ArrayBuffer(8);
|
|
15899
|
+
const retIsFp = retToken === "f32" || retToken === "f64";
|
|
15900
|
+
ffi.ffiCall(proc, argFrame, retBuf, retIsFp ? 1 : 0);
|
|
15901
|
+
const raw = readRet(cTokenToType(retToken), retBuf);
|
|
15902
|
+
if (retToken.endsWith("!") && raw === 0)
|
|
15903
|
+
throw new Error(`ffi-bind: ${sig}: return ${retToken} got 0 (the token promises C never returns null here)`);
|
|
15904
|
+
if (isCPtrToken(retToken) && raw !== 0) {
|
|
15905
|
+
const name = ptrName(retToken);
|
|
15906
|
+
if (name !== "") {
|
|
15907
|
+
const codec = decoders[name];
|
|
15908
|
+
if (codec?.decode)
|
|
15909
|
+
return codec.decode(raw);
|
|
15910
|
+
}
|
|
15911
|
+
}
|
|
15912
|
+
return raw;
|
|
15805
15913
|
}
|
|
15806
|
-
function
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
|
|
15914
|
+
function readRet(ret, retBuf) {
|
|
15915
|
+
if (ret === "void")
|
|
15916
|
+
return void 0;
|
|
15917
|
+
return readScalar(new DataView(retBuf), 0, ret);
|
|
15918
|
+
}
|
|
15919
|
+
var WCHAR = {
|
|
15920
|
+
encode: (v) => {
|
|
15921
|
+
const u8 = new TextEncoder("utf-16le").encode(v + "\0");
|
|
15922
|
+
const out = new PtrArrayBuffer(u8.byteLength);
|
|
15923
|
+
new Uint8Array(out).set(u8);
|
|
15924
|
+
return out;
|
|
15925
|
+
},
|
|
15926
|
+
decode: (p) => {
|
|
15927
|
+
if (typeof p === "number") {
|
|
15928
|
+
let s2 = "";
|
|
15929
|
+
let addr = p;
|
|
15930
|
+
const start = addr;
|
|
15931
|
+
for (; ; ) {
|
|
15932
|
+
const lo = ffi.readByte(addr);
|
|
15933
|
+
const hi = ffi.readByte(addr + 1);
|
|
15934
|
+
if (lo === 0 && hi === 0)
|
|
15935
|
+
return s2;
|
|
15936
|
+
s2 += String.fromCharCode(lo | hi << 8);
|
|
15937
|
+
addr += 2;
|
|
15938
|
+
if (addr - start > 1 << 21) {
|
|
15939
|
+
throw new Error("ffi-bind: WCHAR decode exceeded 4MiB without NUL");
|
|
15940
|
+
}
|
|
15941
|
+
}
|
|
15942
|
+
}
|
|
15943
|
+
const u8 = new Uint8Array(p);
|
|
15944
|
+
const limit = u8.length & ~1;
|
|
15945
|
+
let s = "";
|
|
15946
|
+
for (let i = 0; i < limit; i += 2) {
|
|
15947
|
+
const c = u8[i] | u8[i + 1] << 8;
|
|
15948
|
+
if (c === 0)
|
|
15949
|
+
return s;
|
|
15950
|
+
s += String.fromCharCode(c);
|
|
15951
|
+
}
|
|
15952
|
+
return s;
|
|
15953
|
+
},
|
|
15954
|
+
alloc: (size = 256) => new PtrArrayBuffer(size * 2)
|
|
15955
|
+
};
|
|
15956
|
+
var BYTE = {
|
|
15957
|
+
encode: (v) => {
|
|
15958
|
+
if (!(v instanceof PtrArrayBuffer))
|
|
15959
|
+
throw new Error("ffi-bind: <BYTE>ptr wants a PtrArrayBuffer (new PtrArrayBuffer(n) / BYTE.alloc / struct.encode), not a plain ArrayBuffer");
|
|
15960
|
+
return v;
|
|
15961
|
+
},
|
|
15962
|
+
alloc: (byteLen) => new PtrArrayBuffer(byteLen)
|
|
15963
|
+
};
|
|
15964
|
+
var builtinCodecs = { WCHAR, BYTE };
|
|
15965
|
+
function bind(dll, name, sig, encoders, decoders) {
|
|
15966
|
+
const proc = win.GetProcAddress(loadDll(dll), name);
|
|
15967
|
+
if (!proc)
|
|
15968
|
+
throw new Error(`ffi-bind: proc "${name}" not found in ${dll}`);
|
|
15969
|
+
const effDec = decoders ?? encoders;
|
|
15970
|
+
return makeFn(proc, sig, { ...builtinCodecs, ...encoders }, { ...builtinCodecs, ...effDec ?? {} });
|
|
15971
|
+
}
|
|
15972
|
+
var leakRegistry = new FinalizationRegistry((held) => {
|
|
15973
|
+
std.printf('[ffi] closure leaked (GCed without dispose): sig="%s" ptr=0x%x\n', held.sig, held.ptr);
|
|
15974
|
+
});
|
|
15975
|
+
|
|
15976
|
+
// _build/lib/ffi/struct.js
|
|
15977
|
+
import * as ffi2 from "ffi";
|
|
15978
|
+
function alignUp(v, a) {
|
|
15979
|
+
return v + a - 1 & ~(a - 1);
|
|
15980
|
+
}
|
|
15981
|
+
var isCNumberToken = (t) => SizeAlign[t] !== void 0;
|
|
15982
|
+
function lower(v) {
|
|
15983
|
+
if (typeof v === "string") {
|
|
15984
|
+
const st = /^(u8|u16)\[(\d+)\]@(utf-8|utf-16le)$/.exec(v);
|
|
15985
|
+
if (st) {
|
|
15986
|
+
const length = Number(st[2]);
|
|
15987
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15988
|
+
throw new Error(`ffi-struct: string length must be an integer >= 1, got ${length}`);
|
|
15989
|
+
const s2 = st[1] === "u8" ? 1 : 2;
|
|
15990
|
+
return { size: s2 * length, align: s2, type: { tag: "string", encoding: st[3] } };
|
|
15991
|
+
}
|
|
15992
|
+
const a = /^([^\[\]]+)\[(\d+)\]$/.exec(v);
|
|
15993
|
+
if (a) {
|
|
15994
|
+
const length = Number(a[2]);
|
|
15995
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15996
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${length}`);
|
|
15997
|
+
const el = lower(a[1]);
|
|
15998
|
+
if (el.type.tag === "bitfield")
|
|
15999
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
16000
|
+
return {
|
|
16001
|
+
size: el.size * length,
|
|
16002
|
+
align: el.align,
|
|
16003
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
16004
|
+
};
|
|
16005
|
+
}
|
|
16006
|
+
const b6 = /^([A-Za-z_]\w*):(\d+)$/.exec(v);
|
|
16007
|
+
if (b6) {
|
|
16008
|
+
const rawUnit = b6[1];
|
|
16009
|
+
const unit = normToken(rawUnit);
|
|
16010
|
+
if (!isCNumberToken(unit) || unit === "f32" || unit === "f64")
|
|
16011
|
+
throw new Error(`ffi-struct: bitfield unit must be an integer type, got "${rawUnit}"`);
|
|
16012
|
+
const width = Number(b6[2]);
|
|
16013
|
+
const s2 = SizeAlign[unit];
|
|
16014
|
+
const cap = s2 * 8;
|
|
16015
|
+
if (!Number.isInteger(width) || width < 1)
|
|
16016
|
+
throw new Error(`ffi-struct: bitfield width must be an integer >= 1, got ${width}`);
|
|
16017
|
+
if (width > cap)
|
|
16018
|
+
throw new Error(`ffi-struct: bitfield width ${width} exceeds unit width ${cap}`);
|
|
16019
|
+
return { size: s2, align: s2, type: { tag: "bitfield", unit, bit: 0, width } };
|
|
16020
|
+
}
|
|
16021
|
+
const k = normToken(v);
|
|
16022
|
+
if (isCPtrToken(k))
|
|
16023
|
+
return { size: PTR_SIZE, align: PTR_SIZE, type: { tag: "basic", kind: "ptr" } };
|
|
16024
|
+
if (!isCNumberToken(k))
|
|
16025
|
+
throw new Error(`ffi-struct: unknown kind "${v}"`);
|
|
16026
|
+
const s = SizeAlign[k];
|
|
16027
|
+
return { size: s, align: s, type: { tag: "basic", kind: k } };
|
|
15814
16028
|
}
|
|
15815
|
-
|
|
16029
|
+
if (v && typeof v === "object") {
|
|
16030
|
+
const o = v;
|
|
16031
|
+
const tag = o["#"];
|
|
16032
|
+
if (tag === void 0)
|
|
16033
|
+
throw new Error(`ffi-struct: nested object value requires a '#' key ('struct' | 'union' | 'array')`);
|
|
16034
|
+
if (tag === "array" && "#pack" in o)
|
|
16035
|
+
throw new Error(`ffi-struct: '#pack' is only allowed on struct/union, got '${tag}'`);
|
|
16036
|
+
if (tag === "array") {
|
|
16037
|
+
const length = o["length"];
|
|
16038
|
+
if (!Number.isInteger(length) || length < 1)
|
|
16039
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${String(length)}`);
|
|
16040
|
+
const el = lower(o["element"]);
|
|
16041
|
+
if (el.type.tag === "bitfield")
|
|
16042
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
16043
|
+
return {
|
|
16044
|
+
size: el.size * length,
|
|
16045
|
+
align: el.align,
|
|
16046
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
16047
|
+
};
|
|
16048
|
+
}
|
|
16049
|
+
if (tag === "struct" || tag === "union") {
|
|
16050
|
+
const l = computeStructLayout(v);
|
|
16051
|
+
return { size: l.size, align: l.maxEffectiveAlign, type: { tag, fields: l.fields } };
|
|
16052
|
+
}
|
|
16053
|
+
throw new Error(`ffi-struct: unknown '#' declaration ${JSON.stringify(String(tag))}`);
|
|
16054
|
+
}
|
|
16055
|
+
throw new Error(`ffi-struct: invalid member value: ${String(v)}`);
|
|
16056
|
+
}
|
|
16057
|
+
function computeStructLayout(t) {
|
|
16058
|
+
const isStruct = t["#"] === "struct";
|
|
16059
|
+
const pack = t["#pack"] ?? 8;
|
|
16060
|
+
let maxEffectiveAlign = 1;
|
|
16061
|
+
let maxMemberSize = 0;
|
|
16062
|
+
const fields = [];
|
|
16063
|
+
let cursor = 0;
|
|
16064
|
+
let unitBase = -1;
|
|
16065
|
+
let unitBits = 0;
|
|
16066
|
+
let unitSize = 0;
|
|
16067
|
+
const flushUnit = () => {
|
|
16068
|
+
if (unitBase < 0)
|
|
16069
|
+
return;
|
|
16070
|
+
cursor = alignUp(unitBase + Math.ceil(unitBits / 8), unitSize);
|
|
16071
|
+
unitBase = -1;
|
|
16072
|
+
};
|
|
16073
|
+
for (const [rawName, v] of Object.entries(t)) {
|
|
16074
|
+
if (rawName.startsWith("#"))
|
|
16075
|
+
continue;
|
|
16076
|
+
const m = /^([^@]+)@(\d+)$/.exec(rawName);
|
|
16077
|
+
const name = m ? m[1] : rawName;
|
|
16078
|
+
const alignas = m ? Number(m[2]) : 0;
|
|
16079
|
+
const { size, align: natural, type } = lower(v);
|
|
16080
|
+
const nonnull = typeof v === "string" && v.endsWith("!");
|
|
16081
|
+
let align = natural;
|
|
16082
|
+
if (pack > 0)
|
|
16083
|
+
align = Math.min(pack, align);
|
|
16084
|
+
if (alignas)
|
|
16085
|
+
align = Math.max(align, alignas);
|
|
16086
|
+
if (type.tag === "bitfield") {
|
|
16087
|
+
if (name.startsWith("$"))
|
|
16088
|
+
throw new Error("ffi-struct: bitfield members must be named");
|
|
16089
|
+
if (!isStruct) {
|
|
16090
|
+
fields.push({ name, offset: 0, size, type: { ...type, bit: 0 } });
|
|
16091
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16092
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16093
|
+
continue;
|
|
16094
|
+
}
|
|
16095
|
+
const width = type.width;
|
|
16096
|
+
if (unitBase < 0 || size !== unitSize || unitBits + width > unitSize * 8) {
|
|
16097
|
+
if (unitBase >= 0)
|
|
16098
|
+
flushUnit();
|
|
16099
|
+
const offset2 = alignUp(cursor, align);
|
|
16100
|
+
unitBase = offset2;
|
|
16101
|
+
unitBits = 0;
|
|
16102
|
+
unitSize = size;
|
|
16103
|
+
}
|
|
16104
|
+
fields.push({
|
|
16105
|
+
name,
|
|
16106
|
+
offset: unitBase,
|
|
16107
|
+
// 单元基址(不是位域自己的地址)
|
|
16108
|
+
size,
|
|
16109
|
+
type: { ...type, bit: unitBits }
|
|
16110
|
+
});
|
|
16111
|
+
unitBits += width;
|
|
16112
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16113
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16114
|
+
continue;
|
|
16115
|
+
}
|
|
16116
|
+
flushUnit();
|
|
16117
|
+
const offset = alignUp(cursor, align);
|
|
16118
|
+
if (!name.startsWith("$")) {
|
|
16119
|
+
fields.push({ name, offset, size, type, ...nonnull ? { nonnull: true } : {} });
|
|
16120
|
+
} else {
|
|
16121
|
+
if (type.tag !== "struct" && type.tag !== "union")
|
|
16122
|
+
throw new Error(`ffi-struct: anonymous member "${name}" must be a struct/union`);
|
|
16123
|
+
for (const cf of type.fields)
|
|
16124
|
+
fields.push({ ...cf, offset: cf.offset + offset });
|
|
16125
|
+
}
|
|
16126
|
+
if (isStruct)
|
|
16127
|
+
cursor = offset + size;
|
|
16128
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16129
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16130
|
+
}
|
|
16131
|
+
flushUnit();
|
|
16132
|
+
return {
|
|
16133
|
+
size: isStruct ? alignUp(cursor, maxEffectiveAlign) : alignUp(maxMemberSize, maxEffectiveAlign),
|
|
16134
|
+
maxEffectiveAlign,
|
|
16135
|
+
fields
|
|
16136
|
+
};
|
|
16137
|
+
}
|
|
16138
|
+
function readUnitRaw(dv, off, unit) {
|
|
16139
|
+
const s = SizeAlign[unit];
|
|
16140
|
+
if (s === 1)
|
|
16141
|
+
return BigInt(dv.getUint8(off));
|
|
16142
|
+
if (s === 2)
|
|
16143
|
+
return BigInt(dv.getUint16(off, true));
|
|
16144
|
+
if (s === 4)
|
|
16145
|
+
return BigInt(dv.getUint32(off, true));
|
|
16146
|
+
return dv.getBigUint64(off, true);
|
|
16147
|
+
}
|
|
16148
|
+
function writeUnitRaw(dv, off, unit, v) {
|
|
16149
|
+
const s = SizeAlign[unit];
|
|
16150
|
+
if (s === 1) {
|
|
16151
|
+
dv.setUint8(off, Number(v & 0xffn));
|
|
16152
|
+
return;
|
|
16153
|
+
}
|
|
16154
|
+
if (s === 2) {
|
|
16155
|
+
dv.setUint16(off, Number(v & 0xffffn), true);
|
|
16156
|
+
return;
|
|
16157
|
+
}
|
|
16158
|
+
if (s === 4) {
|
|
16159
|
+
dv.setUint32(off, Number(v & 0xffffffffn), true);
|
|
16160
|
+
return;
|
|
16161
|
+
}
|
|
16162
|
+
dv.setBigUint64(off, v & 0xffffffffffffffffn, true);
|
|
16163
|
+
}
|
|
16164
|
+
function readBitfield(dv, off, t) {
|
|
16165
|
+
const w = BigInt(t.width);
|
|
16166
|
+
let v = readUnitRaw(dv, off, t.unit) >> BigInt(t.bit) & (1n << w) - 1n;
|
|
16167
|
+
if (t.unit[0] === "i" && v & 1n << w - 1n)
|
|
16168
|
+
v -= 1n << w;
|
|
16169
|
+
if (t.width > 53)
|
|
16170
|
+
return v;
|
|
16171
|
+
return Number(v);
|
|
16172
|
+
}
|
|
16173
|
+
function writeBitfield(dv, off, t, val) {
|
|
16174
|
+
const w = BigInt(t.width);
|
|
16175
|
+
const bit = BigInt(t.bit);
|
|
16176
|
+
const widthMask = (1n << w) - 1n;
|
|
16177
|
+
const posMask = widthMask << bit;
|
|
16178
|
+
const raw = readUnitRaw(dv, off, t.unit);
|
|
16179
|
+
const bits = (typeof val === "bigint" ? val : BigInt(Math.trunc(val))) & widthMask;
|
|
16180
|
+
writeUnitRaw(dv, off, t.unit, raw & ~posMask | bits << bit);
|
|
16181
|
+
}
|
|
16182
|
+
var stringEncoders = {
|
|
16183
|
+
"utf-8": new TextEncoder("utf-8"),
|
|
16184
|
+
"utf-16le": new TextEncoder("utf-16le")
|
|
16185
|
+
};
|
|
16186
|
+
var stringDecoders = {
|
|
16187
|
+
"utf-8": new TextDecoder("utf-8", { ignoreBOM: true }),
|
|
16188
|
+
"utf-16le": new TextDecoder("utf-16le", { ignoreBOM: true })
|
|
16189
|
+
};
|
|
16190
|
+
function readString(dv, off, size, enc) {
|
|
16191
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16192
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16193
|
+
let end = size;
|
|
16194
|
+
for (let i = 0; i + unit <= size; i += unit) {
|
|
16195
|
+
if (bytes[i] === 0 && (unit === 1 || bytes[i + 1] === 0)) {
|
|
16196
|
+
end = i;
|
|
16197
|
+
break;
|
|
16198
|
+
}
|
|
16199
|
+
}
|
|
16200
|
+
return stringDecoders[enc].decode(bytes.subarray(0, end));
|
|
16201
|
+
}
|
|
16202
|
+
function writeString(dv, off, size, enc, v) {
|
|
16203
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16204
|
+
bytes.fill(0);
|
|
16205
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16206
|
+
const cap = size - unit;
|
|
16207
|
+
if (cap <= 0)
|
|
16208
|
+
return;
|
|
16209
|
+
const src = stringEncoders[enc].encode(String(v ?? ""));
|
|
16210
|
+
bytes.set(src.subarray(0, Math.min(src.length, cap)));
|
|
16211
|
+
}
|
|
16212
|
+
function readArray(dv, off, size, t) {
|
|
16213
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16214
|
+
const out = [];
|
|
16215
|
+
for (let i = 0; i < count; i++)
|
|
16216
|
+
out.push(readElement(dv, off + i * t.elementSize, t.elementType, t.elementSize));
|
|
16217
|
+
return out;
|
|
16218
|
+
}
|
|
16219
|
+
function writeArray(dv, off, size, t, v) {
|
|
16220
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16221
|
+
const list = v ?? [];
|
|
16222
|
+
for (let i = 0; i < count; i++)
|
|
16223
|
+
writeElement(dv, off + i * t.elementSize, t.elementType, t.elementSize, list[i]);
|
|
16224
|
+
}
|
|
16225
|
+
function readElement(dv, off, t, size) {
|
|
16226
|
+
switch (t.tag) {
|
|
16227
|
+
case "basic":
|
|
16228
|
+
return readScalar(dv, off, t.kind);
|
|
16229
|
+
case "bitfield":
|
|
16230
|
+
return readBitfield(dv, off, t);
|
|
16231
|
+
case "string":
|
|
16232
|
+
return readString(dv, off, size, t.encoding);
|
|
16233
|
+
case "struct":
|
|
16234
|
+
case "union":
|
|
16235
|
+
return doDecode(dv, off, t.fields);
|
|
16236
|
+
case "array":
|
|
16237
|
+
return readArray(dv, off, size, t);
|
|
16238
|
+
}
|
|
16239
|
+
}
|
|
16240
|
+
function writeElement(dv, off, t, size, val) {
|
|
16241
|
+
switch (t.tag) {
|
|
16242
|
+
// TODO: remove this any
|
|
16243
|
+
case "basic":
|
|
16244
|
+
writeScalar(dv, off, { k: t.kind, v: val });
|
|
16245
|
+
break;
|
|
16246
|
+
// 直传(不 Number()):writeBitfield 的 val 是 number | bigint,
|
|
16247
|
+
// 64 位单元走 bigint,先 Number() 会把 >2^53 的位域值截断。
|
|
16248
|
+
case "bitfield":
|
|
16249
|
+
writeBitfield(dv, off, t, val ?? 0);
|
|
16250
|
+
break;
|
|
16251
|
+
case "string":
|
|
16252
|
+
writeString(dv, off, size, t.encoding, val);
|
|
16253
|
+
break;
|
|
16254
|
+
case "struct":
|
|
16255
|
+
case "union":
|
|
16256
|
+
doEncode(dv, off, t.fields, val ?? {});
|
|
16257
|
+
break;
|
|
16258
|
+
case "array":
|
|
16259
|
+
writeArray(dv, off, size, t, val);
|
|
16260
|
+
break;
|
|
16261
|
+
}
|
|
16262
|
+
}
|
|
16263
|
+
function doDecode(dv, base, fields) {
|
|
16264
|
+
const out = {};
|
|
16265
|
+
for (const f of fields) {
|
|
16266
|
+
const v = readElement(dv, base + f.offset, f.type, f.size);
|
|
16267
|
+
if (f.nonnull && v === 0)
|
|
16268
|
+
throw new Error(`ffi-struct: decode: '!' field "${f.name}" got 0 (C did not fill it, or decode was called on an unfilled slot)`);
|
|
16269
|
+
out[f.name] = v;
|
|
16270
|
+
}
|
|
16271
|
+
return out;
|
|
16272
|
+
}
|
|
16273
|
+
function doEncode(dv, base, fields, v) {
|
|
16274
|
+
for (const f of fields) {
|
|
16275
|
+
if (v[f.name] === void 0)
|
|
16276
|
+
continue;
|
|
16277
|
+
writeElement(dv, base + f.offset, f.type, f.size, v[f.name]);
|
|
16278
|
+
}
|
|
16279
|
+
}
|
|
16280
|
+
function createStruct(t) {
|
|
16281
|
+
const { fields, size, maxEffectiveAlign } = computeStructLayout(t);
|
|
16282
|
+
return {
|
|
16283
|
+
__struct: t,
|
|
16284
|
+
size,
|
|
16285
|
+
structAlign: maxEffectiveAlign,
|
|
16286
|
+
decode: (p) => {
|
|
16287
|
+
if (typeof p === "number")
|
|
16288
|
+
return doDecode(new DataView(ffi2.readBytes(p, size)), 0, fields);
|
|
16289
|
+
return doDecode(new DataView(p), 0, fields);
|
|
16290
|
+
},
|
|
16291
|
+
alloc: ((n) => {
|
|
16292
|
+
if (n !== void 0 && (!Number.isInteger(n) || n < 1))
|
|
16293
|
+
throw new Error(`ffi-struct: alloc(n) requires an integer n >= 1 (PAB(0) never escapes \u2014 pass NULL for an empty pointer position)`);
|
|
16294
|
+
return new PtrArrayBuffer(size * (n ?? 1));
|
|
16295
|
+
}),
|
|
16296
|
+
encode: ((v, buf, offset) => {
|
|
16297
|
+
if (v === void 0 || v === null)
|
|
16298
|
+
throw new Error(`ffi-struct: encode(v) requires an argument; use alloc() for a zeroed out-param slot`);
|
|
16299
|
+
const out = buf ?? new PtrArrayBuffer(size);
|
|
16300
|
+
doEncode(new DataView(out), offset ?? 0, fields, v);
|
|
16301
|
+
return out;
|
|
16302
|
+
}),
|
|
16303
|
+
offsetOf: (name) => {
|
|
16304
|
+
for (const f of fields)
|
|
16305
|
+
if (f.name === name)
|
|
16306
|
+
return f.offset;
|
|
16307
|
+
throw new Error(`ffi-struct: no field "${name}"`);
|
|
16308
|
+
}
|
|
16309
|
+
};
|
|
16310
|
+
}
|
|
16311
|
+
function buildDecl(kind, member, pack) {
|
|
16312
|
+
const decl = { "#": kind };
|
|
16313
|
+
if (pack !== void 0)
|
|
16314
|
+
decl["#pack"] = pack;
|
|
16315
|
+
for (const [k, v] of Object.entries(member))
|
|
16316
|
+
if (!k.startsWith("#"))
|
|
16317
|
+
decl[k] = v;
|
|
16318
|
+
return decl;
|
|
16319
|
+
}
|
|
16320
|
+
function structArray(def) {
|
|
16321
|
+
const { fields, size } = computeStructLayout(def.__struct);
|
|
16322
|
+
const readN = (dv, n) => {
|
|
16323
|
+
const out = [];
|
|
16324
|
+
for (let i = 0; i < n; i++)
|
|
16325
|
+
out.push(doDecode(dv, i * size, fields));
|
|
16326
|
+
return out;
|
|
16327
|
+
};
|
|
16328
|
+
return {
|
|
16329
|
+
encode: (els) => {
|
|
16330
|
+
if (!Array.isArray(els) || els.length === 0)
|
|
16331
|
+
throw new Error(`ffi-struct: structArray(def).encode(els) requires a non-empty element array (pass NULL for an empty pointer position)`);
|
|
16332
|
+
const out = def.alloc(els.length);
|
|
16333
|
+
for (let i = 0; i < els.length; i++)
|
|
16334
|
+
def.encode(els[i], out, i * def.size);
|
|
16335
|
+
return out;
|
|
16336
|
+
},
|
|
16337
|
+
decode: ((p, count) => {
|
|
16338
|
+
if (count !== void 0 && (!Number.isInteger(count) || count < 0))
|
|
16339
|
+
throw new Error(`ffi-struct: structArray.decode(p, count) requires a non-negative integer count, got ${count}`);
|
|
16340
|
+
if (typeof p === "number") {
|
|
16341
|
+
if (count === void 0)
|
|
16342
|
+
throw new Error(`ffi-struct: structArray.decode(address, count) requires an explicit count (a bare address carries no length)`);
|
|
16343
|
+
if (count === 0)
|
|
16344
|
+
return [];
|
|
16345
|
+
return readN(new DataView(ffi2.readBytes(p, count * size)), count);
|
|
16346
|
+
}
|
|
16347
|
+
let n;
|
|
16348
|
+
if (count !== void 0) {
|
|
16349
|
+
n = count;
|
|
16350
|
+
if (n * size > p.byteLength)
|
|
16351
|
+
throw new Error(`ffi-struct: structArray.decode: count ${n} \xD7 size ${size} = ${n * size} exceeds buffer byteLength ${p.byteLength}`);
|
|
16352
|
+
} else {
|
|
16353
|
+
if (p.byteLength % size !== 0)
|
|
16354
|
+
throw new Error(`ffi-struct: structArray.decode: byteLength ${p.byteLength} is not a multiple of size ${size} (mixed buffer? pass count explicitly)`);
|
|
16355
|
+
n = p.byteLength / size;
|
|
16356
|
+
}
|
|
16357
|
+
if (n === 0)
|
|
16358
|
+
return [];
|
|
16359
|
+
return readN(new DataView(p), n);
|
|
16360
|
+
})
|
|
16361
|
+
};
|
|
16362
|
+
}
|
|
16363
|
+
function struct(a, b6, c) {
|
|
16364
|
+
const isNamed = typeof a === "string";
|
|
16365
|
+
const raw = isNamed ? b6 : a;
|
|
16366
|
+
const opts = isNamed ? c : b6;
|
|
16367
|
+
return createStruct(buildDecl("struct", raw, opts?.pack));
|
|
16368
|
+
}
|
|
16369
|
+
|
|
16370
|
+
// _build/lib/windows/structs.js
|
|
16371
|
+
var RECT = /* @__PURE__ */ struct("RECT", {
|
|
16372
|
+
left: "i32",
|
|
16373
|
+
top: "i32",
|
|
16374
|
+
right: "i32",
|
|
16375
|
+
bottom: "i32"
|
|
16376
|
+
});
|
|
16377
|
+
var POINT = /* @__PURE__ */ struct("POINT", {
|
|
16378
|
+
x: "i32",
|
|
16379
|
+
y: "i32"
|
|
16380
|
+
});
|
|
16381
|
+
var SIZE = /* @__PURE__ */ struct("SIZE", {
|
|
16382
|
+
cx: "i32",
|
|
16383
|
+
cy: "i32"
|
|
16384
|
+
});
|
|
16385
|
+
var LOGFONTW = /* @__PURE__ */ struct("LOGFONTW", {
|
|
16386
|
+
lfHeight: "i32",
|
|
16387
|
+
lfWidth: "i32",
|
|
16388
|
+
lfEscapement: "i32",
|
|
16389
|
+
lfOrientation: "i32",
|
|
16390
|
+
lfWeight: "i32",
|
|
16391
|
+
lfItalic: "u8",
|
|
16392
|
+
lfUnderline: "u8",
|
|
16393
|
+
lfStrikeOut: "u8",
|
|
16394
|
+
lfCharSet: "u8",
|
|
16395
|
+
lfOutPrecision: "u8",
|
|
16396
|
+
lfClipPrecision: "u8",
|
|
16397
|
+
lfQuality: "u8",
|
|
16398
|
+
lfPitchAndFamily: "u8",
|
|
16399
|
+
lfFaceName: "u16[32]@utf-16le"
|
|
16400
|
+
});
|
|
16401
|
+
var BITMAPINFOHEADER = /* @__PURE__ */ struct("BITMAPINFOHEADER", {
|
|
16402
|
+
biSize: "u32",
|
|
16403
|
+
biWidth: "i32",
|
|
16404
|
+
biHeight: "i32",
|
|
16405
|
+
biPlanes: "u16",
|
|
16406
|
+
biBitCount: "u16",
|
|
16407
|
+
biCompression: "u32",
|
|
16408
|
+
biSizeImage: "u32",
|
|
16409
|
+
biXPelsPerMeter: "i32",
|
|
16410
|
+
biYPelsPerMeter: "i32",
|
|
16411
|
+
biClrUsed: "u32",
|
|
16412
|
+
biClrImportant: "u32"
|
|
16413
|
+
});
|
|
16414
|
+
var OPENFILENAMEW = /* @__PURE__ */ struct("OPENFILENAMEW", {
|
|
16415
|
+
lStructSize: "u32",
|
|
16416
|
+
hwndOwner: "<HWND>ptr",
|
|
16417
|
+
hInstance: "<HMODULE>ptr",
|
|
16418
|
+
lpstrFilter: "<>ptr",
|
|
16419
|
+
lpstrCustomFilter: "<>ptr",
|
|
16420
|
+
nMaxCustFilter: "u32",
|
|
16421
|
+
nFilterIndex: "u32",
|
|
16422
|
+
lpstrFile: "<>ptr",
|
|
16423
|
+
nMaxFile: "u32",
|
|
16424
|
+
lpstrFileTitle: "<>ptr",
|
|
16425
|
+
nMaxFileTitle: "u32",
|
|
16426
|
+
lpstrInitialDir: "<>ptr",
|
|
16427
|
+
lpstrTitle: "<>ptr",
|
|
16428
|
+
Flags: "u32",
|
|
16429
|
+
nFileOffset: "u16",
|
|
16430
|
+
nFileExtension: "u16",
|
|
16431
|
+
lpstrDefExt: "<>ptr",
|
|
16432
|
+
lCustData: "<>ptr",
|
|
16433
|
+
lpfnHook: "<>ptr",
|
|
16434
|
+
lpTemplateName: "<>ptr",
|
|
16435
|
+
pvReserved: "<>ptr",
|
|
16436
|
+
dwReserved: "u32",
|
|
16437
|
+
FlagsEx: "u32"
|
|
16438
|
+
});
|
|
16439
|
+
var BROWSEINFOW = /* @__PURE__ */ struct("BROWSEINFOW", {
|
|
16440
|
+
hwndOwner: "<HWND>ptr",
|
|
16441
|
+
pidlRoot: "<>ptr",
|
|
16442
|
+
pszDisplayName: "<>ptr",
|
|
16443
|
+
lpszTitle: "<>ptr",
|
|
16444
|
+
ulFlags: "u32",
|
|
16445
|
+
lpfn: "<>ptr",
|
|
16446
|
+
lParam: "<>ptr",
|
|
16447
|
+
iImage: "i32"
|
|
16448
|
+
});
|
|
16449
|
+
var NMHDR = /* @__PURE__ */ struct("NMHDR", {
|
|
16450
|
+
hwndFrom: "<HWND>ptr",
|
|
16451
|
+
idFrom: "<>ptr",
|
|
16452
|
+
code: "i32"
|
|
16453
|
+
});
|
|
16454
|
+
var SYSTEMTIME = /* @__PURE__ */ struct("SYSTEMTIME", {
|
|
16455
|
+
wYear: "u16",
|
|
16456
|
+
wMonth: "u16",
|
|
16457
|
+
wDayOfWeek: "u16",
|
|
16458
|
+
wDay: "u16",
|
|
16459
|
+
wHour: "u16",
|
|
16460
|
+
wMinute: "u16",
|
|
16461
|
+
wSecond: "u16",
|
|
16462
|
+
wMilliseconds: "u16"
|
|
16463
|
+
});
|
|
16464
|
+
var NMDATETIMECHANGE = /* @__PURE__ */ struct("NMDATETIMECHANGE", {
|
|
16465
|
+
hdr: NMHDR.__struct,
|
|
16466
|
+
dwFlags: "u32",
|
|
16467
|
+
st: SYSTEMTIME.__struct
|
|
16468
|
+
});
|
|
16469
|
+
var LITEM = /* @__PURE__ */ struct("LITEM", {
|
|
16470
|
+
mask: "u32",
|
|
16471
|
+
iLink: "i32",
|
|
16472
|
+
state: "u32",
|
|
16473
|
+
stateMask: "u32",
|
|
16474
|
+
szID: "u16[48]@utf-16le",
|
|
16475
|
+
szUrl: "u16[2084]@utf-16le"
|
|
16476
|
+
});
|
|
16477
|
+
var NMLINK = /* @__PURE__ */ struct("NMLINK", {
|
|
16478
|
+
hdr: NMHDR.__struct,
|
|
16479
|
+
item: LITEM.__struct
|
|
16480
|
+
});
|
|
16481
|
+
var NMCUSTOMDRAW = /* @__PURE__ */ struct("NMCUSTOMDRAW", {
|
|
16482
|
+
hdr: NMHDR.__struct,
|
|
16483
|
+
dwDrawStage: "u32",
|
|
16484
|
+
hdc: "<HDC>ptr",
|
|
16485
|
+
rc: "i32[4]",
|
|
16486
|
+
dwItemSpec: "<>ptr",
|
|
16487
|
+
uItemState: "u32",
|
|
16488
|
+
lItemlParam: "<>ptr"
|
|
16489
|
+
});
|
|
16490
|
+
var NMLVCUSTOMDRAW = /* @__PURE__ */ struct("NMLVCUSTOMDRAW", {
|
|
16491
|
+
hdr: NMHDR.__struct,
|
|
16492
|
+
dwDrawStage: "u32",
|
|
16493
|
+
hdc: "<HDC>ptr",
|
|
16494
|
+
rc: "i32[4]",
|
|
16495
|
+
dwItemSpec: "<>ptr",
|
|
16496
|
+
uItemState: "u32",
|
|
16497
|
+
lItemlParam: "<>ptr",
|
|
16498
|
+
clrText: "u32",
|
|
16499
|
+
clrTextBk: "u32",
|
|
16500
|
+
iSubItem: "i32",
|
|
16501
|
+
dwItemType: "u32"
|
|
16502
|
+
});
|
|
16503
|
+
var NMLISTVIEW = /* @__PURE__ */ struct("NMLISTVIEW", {
|
|
16504
|
+
hdr: NMHDR.__struct,
|
|
16505
|
+
iItem: "i32",
|
|
16506
|
+
iSubItem: "i32",
|
|
16507
|
+
uNewState: "u32",
|
|
16508
|
+
uOldState: "u32",
|
|
16509
|
+
uChanged: "u32",
|
|
16510
|
+
ptAction: "i32[2]",
|
|
16511
|
+
lParam: "<>ptr"
|
|
16512
|
+
});
|
|
16513
|
+
var TCITEMW = /* @__PURE__ */ struct("TCITEMW", {
|
|
16514
|
+
mask: "u32",
|
|
16515
|
+
dwState: "u32",
|
|
16516
|
+
dwStateMask: "u32",
|
|
16517
|
+
pszText: "<>ptr",
|
|
16518
|
+
cchTextMax: "i32",
|
|
16519
|
+
iImage: "i32",
|
|
16520
|
+
lParam: "<>ptr"
|
|
16521
|
+
});
|
|
16522
|
+
var TVITEM = /* @__PURE__ */ struct("TVITEM", {
|
|
16523
|
+
mask: "u32",
|
|
16524
|
+
hItem: "<>ptr",
|
|
16525
|
+
state: "u32",
|
|
16526
|
+
stateMask: "u32",
|
|
16527
|
+
pszText: "<>ptr",
|
|
16528
|
+
cchTextMax: "i32",
|
|
16529
|
+
iImage: "i32",
|
|
16530
|
+
iSelectedImage: "i32",
|
|
16531
|
+
cChildren: "i32",
|
|
16532
|
+
lParam: "<>ptr"
|
|
16533
|
+
});
|
|
16534
|
+
var TVINSERTSTRUCT = /* @__PURE__ */ struct("TVINSERTSTRUCT", {
|
|
16535
|
+
hParent: "<>ptr",
|
|
16536
|
+
hInsertAfter: "<>ptr",
|
|
16537
|
+
item: TVITEM.__struct
|
|
16538
|
+
});
|
|
16539
|
+
var LVHITTESTINFO = /* @__PURE__ */ struct("LVHITTESTINFO", {
|
|
16540
|
+
pt: "i32[2]",
|
|
16541
|
+
flags: "u32",
|
|
16542
|
+
iItem: "i32",
|
|
16543
|
+
iSubItem: "i32",
|
|
16544
|
+
iGroup: "i32"
|
|
16545
|
+
});
|
|
16546
|
+
var LVITEMW = /* @__PURE__ */ struct("LVITEMW", {
|
|
16547
|
+
mask: "u32",
|
|
16548
|
+
iItem: "i32",
|
|
16549
|
+
iSubItem: "i32",
|
|
16550
|
+
state: "u32",
|
|
16551
|
+
stateMask: "u32",
|
|
16552
|
+
pszText: "<>ptr",
|
|
16553
|
+
cchTextMax: "i32",
|
|
16554
|
+
iImage: "i32",
|
|
16555
|
+
lParam: "<>ptr",
|
|
16556
|
+
iIndent: "i32",
|
|
16557
|
+
iGroupId: "i32",
|
|
16558
|
+
cColumns: "u32",
|
|
16559
|
+
puColumns: "<>ptr",
|
|
16560
|
+
piColFmt: "<>ptr",
|
|
16561
|
+
iGroup: "i32"
|
|
16562
|
+
});
|
|
16563
|
+
var LVCOLUMNW = /* @__PURE__ */ struct("LVCOLUMNW", {
|
|
16564
|
+
mask: "u32",
|
|
16565
|
+
fmt: "i32",
|
|
16566
|
+
cx: "i32",
|
|
16567
|
+
pszText: "<>ptr",
|
|
16568
|
+
cchTextMax: "i32",
|
|
16569
|
+
iSubItem: "i32",
|
|
16570
|
+
iImage: "i32",
|
|
16571
|
+
iOrder: "i32",
|
|
16572
|
+
cxMin: "i32",
|
|
16573
|
+
cxDefault: "i32",
|
|
16574
|
+
cxIdeal: "i32"
|
|
16575
|
+
});
|
|
16576
|
+
var MSG = /* @__PURE__ */ struct("MSG", {
|
|
16577
|
+
hwnd: "<HWND>ptr",
|
|
16578
|
+
message: "u32",
|
|
16579
|
+
wParam: "<>ptr",
|
|
16580
|
+
lParam: "<>ptr",
|
|
16581
|
+
time: "u32",
|
|
16582
|
+
pt: POINT.__struct
|
|
16583
|
+
});
|
|
16584
|
+
var PAINTSTRUCT = /* @__PURE__ */ struct("PAINTSTRUCT", {
|
|
16585
|
+
hdc: "<HDC>ptr",
|
|
16586
|
+
fErase: "i32",
|
|
16587
|
+
rcPaint: RECT.__struct,
|
|
16588
|
+
fRestore: "i32",
|
|
16589
|
+
fIncUpdate: "i32",
|
|
16590
|
+
rgbReserved: "u8[32]"
|
|
16591
|
+
});
|
|
16592
|
+
|
|
16593
|
+
// _build/lib/windows/user32.js
|
|
16594
|
+
var b = (name, sig, encoders) => bind("user32.dll", name, sig, encoders);
|
|
16595
|
+
var _bProbe = b("GetDesktopWindow", " -> <HWND>ptr");
|
|
16596
|
+
var LONG_PTR_SYM = os3.arch === "x64" ? "PtrW" : "W";
|
|
16597
|
+
var SetWindowPos = /* @__PURE__ */ b("SetWindowPos", "<HWND>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32");
|
|
16598
|
+
var SetWindowText = /* @__PURE__ */ b("SetWindowTextW", "<HWND>ptr <WCHAR>ptr -> i32");
|
|
16599
|
+
var GetWindowLongPtr = /* @__PURE__ */ b("GetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp -> <>ptr");
|
|
16600
|
+
var SetWindowLongPtr = /* @__PURE__ */ b("SetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp <>ptr -> <>ptr");
|
|
16601
|
+
var EnableWindow = /* @__PURE__ */ b("EnableWindow", "<HWND>ptr i32 -> i32");
|
|
16602
|
+
var SetParent = /* @__PURE__ */ b("SetParent", "<HWND>ptr <HWND>ptr -> <HWND>ptr");
|
|
16603
|
+
var DefWindowProc = /* @__PURE__ */ b("DefWindowProcW", "<HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16604
|
+
var CallWindowProc = /* @__PURE__ */ b("CallWindowProcW", "<>ptr <HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16605
|
+
var GetDC = /* @__PURE__ */ b("GetDC", "<HWND>ptr -> <HDC>ptr");
|
|
16606
|
+
var ReleaseDC = /* @__PURE__ */ b("ReleaseDC", "<HWND>ptr <HDC>ptr! -> i32");
|
|
16607
|
+
var DrawText = /* @__PURE__ */ b("DrawTextW", "<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32");
|
|
16608
|
+
var InvalidateRect = /* @__PURE__ */ b("InvalidateRect", "<HWND>ptr <RECT>ptr i32 -> i32", { RECT });
|
|
16609
|
+
var SetCursor = /* @__PURE__ */ b("SetCursor", "<HCURSOR>ptr -> <HCURSOR>ptr");
|
|
16610
|
+
var LoadCursor = /* @__PURE__ */ b("LoadCursorW", "<HMODULE>ptr <>ptr -> <HCURSOR>ptr");
|
|
16611
|
+
var GetCursorPos = /* @__PURE__ */ b("GetCursorPos", "<POINT>ptr -> i32");
|
|
16612
|
+
var ScreenToClient = /* @__PURE__ */ b("ScreenToClient", "<HWND>ptr <POINT>ptr -> i32");
|
|
16613
|
+
var ShowScrollBar = /* @__PURE__ */ b("ShowScrollBar", "<HWND>ptr u32 i32 -> i32");
|
|
16614
|
+
var GetSystemMetrics = /* @__PURE__ */ b("GetSystemMetrics", "i32 -> i32");
|
|
16615
|
+
|
|
16616
|
+
// _build/lib/react-qw/reconciler.js
|
|
16617
|
+
var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
16618
|
+
var import_react = __toESM(require_react(), 1);
|
|
16619
|
+
var import_constants = __toESM(require_constants(), 1);
|
|
16620
|
+
import * as gui3 from "gui";
|
|
16621
|
+
import * as os4 from "os";
|
|
16622
|
+
|
|
16623
|
+
// _build/lib/windows/gdi32.js
|
|
16624
|
+
var b2 = (name, sig, encoders) => bind("gdi32.dll", name, sig, encoders);
|
|
16625
|
+
var POINTArr = structArray(POINT);
|
|
16626
|
+
var DeleteObject = /* @__PURE__ */ b2("DeleteObject", "<HGDIOBJ>ptr -> i32");
|
|
16627
|
+
var GetDeviceCaps = /* @__PURE__ */ b2("GetDeviceCaps", "<HDC>ptr! i32@DeviceCap -> i32");
|
|
16628
|
+
var CreateFontIndirect = /* @__PURE__ */ b2("CreateFontIndirectW", "<LOGFONTW>ptr -> <HGDIOBJ>ptr", { LOGFONTW });
|
|
16629
|
+
var SelectObject = /* @__PURE__ */ b2("SelectObject", "<HDC>ptr! <HGDIOBJ>ptr -> <HGDIOBJ>ptr");
|
|
16630
|
+
var GetObject = /* @__PURE__ */ b2("GetObjectW", "<HGDIOBJ>ptr i32 <BYTE>ptr -> i32");
|
|
16631
|
+
var SetDIBitsToDevice = /* @__PURE__ */ b2("SetDIBitsToDevice", "<HDC>ptr! i32 i32 u32 u32 i32 i32 u32 u32 <BYTE>ptr <BYTE>ptr u32 -> i32");
|
|
16632
|
+
|
|
16633
|
+
// _build/lib/react-qw/props.js
|
|
16634
|
+
import * as gui from "gui";
|
|
16635
|
+
function applyProps(instance, newProps, _oldProps) {
|
|
16636
|
+
const hwnd = instance.hwnd;
|
|
16637
|
+
instance.props = newProps;
|
|
16638
|
+
if (hwnd === null)
|
|
16639
|
+
return;
|
|
16640
|
+
const textVal = "text" in newProps ? newProps.text : typeof newProps.children === "string" ? newProps.children : typeof newProps.children === "number" ? String(newProps.children) : void 0;
|
|
16641
|
+
if (textVal !== void 0) {
|
|
16642
|
+
let cursor = -1;
|
|
16643
|
+
if (instance.type === "EDIT") {
|
|
16644
|
+
const sel = gui.SendMessage(hwnd, 176, 0, 0);
|
|
16645
|
+
cursor = sel >>> 16;
|
|
16646
|
+
}
|
|
16647
|
+
SetWindowText(hwnd, textVal);
|
|
16648
|
+
if (instance.type === "EDIT" && cursor >= 0) {
|
|
16649
|
+
gui.SendMessage(hwnd, 177, cursor, cursor);
|
|
16650
|
+
}
|
|
16651
|
+
}
|
|
16652
|
+
if ("disabled" in newProps) {
|
|
16653
|
+
EnableWindow(hwnd, !newProps.disabled ? 1 : 0);
|
|
16654
|
+
}
|
|
16655
|
+
if ("hidden" in newProps) {
|
|
16656
|
+
gui.ShowWindow(
|
|
16657
|
+
hwnd,
|
|
16658
|
+
newProps.hidden ? 0 : 5
|
|
16659
|
+
/* gui.ShowWindowCmd.SHOW */
|
|
16660
|
+
);
|
|
16661
|
+
}
|
|
16662
|
+
if ("visible" in newProps) {
|
|
16663
|
+
gui.ShowWindow(
|
|
16664
|
+
hwnd,
|
|
16665
|
+
newProps.visible ? 5 : 0
|
|
16666
|
+
/* gui.ShowWindowCmd.HIDE */
|
|
16667
|
+
);
|
|
16668
|
+
}
|
|
16669
|
+
}
|
|
16670
|
+
|
|
16671
|
+
// _build/lib/react-qw/layout.js
|
|
16672
|
+
var DEFAULT_W = 100;
|
|
16673
|
+
var DEFAULT_H = 30;
|
|
16674
|
+
function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
16675
|
+
const dir = flex.flexDirection || "column";
|
|
16676
|
+
const gap = flex.gap ?? 0;
|
|
16677
|
+
const justify = flex.justifyContent || "flex-start";
|
|
16678
|
+
const align = flex.alignItems || "stretch";
|
|
16679
|
+
const isRow = dir === "row";
|
|
16680
|
+
const n = children.length;
|
|
16681
|
+
const mainSize = isRow ? "w" : "h";
|
|
16682
|
+
const crossSize = isRow ? "h" : "w";
|
|
16683
|
+
const mainPos = isRow ? "x" : "y";
|
|
16684
|
+
const crossPos = isRow ? "y" : "x";
|
|
16685
|
+
const mainDim = isRow ? "width" : "height";
|
|
16686
|
+
const crossDim = isRow ? "height" : "width";
|
|
16687
|
+
const pt = flex.paddingTop ?? flex.padding ?? 0;
|
|
16688
|
+
const pr = flex.paddingRight ?? flex.padding ?? 0;
|
|
16689
|
+
const pb = flex.paddingBottom ?? flex.padding ?? 0;
|
|
16690
|
+
const pl = flex.paddingLeft ?? flex.padding ?? 0;
|
|
16691
|
+
const mainPadding = isRow ? pl + pr : pt + pb;
|
|
16692
|
+
const crossPadding = isRow ? pt + pb : pl + pr;
|
|
16693
|
+
const parentMain = (isRow ? parentW : parentH) - mainPadding;
|
|
16694
|
+
const parentCross = (isRow ? parentH : parentW) - crossPadding;
|
|
16695
|
+
const sizes = children.map((c) => ({
|
|
16696
|
+
w: typeof c.style.width === "number" ? c.style.width : DEFAULT_W,
|
|
16697
|
+
h: typeof c.style.height === "number" ? c.style.height : DEFAULT_H
|
|
16698
|
+
}));
|
|
16699
|
+
const flexGrows = children.map((c) => c.style.flexGrow ?? 0);
|
|
16700
|
+
const totalGrow = flexGrows.reduce((s, g) => s + g, 0);
|
|
16701
|
+
const baseMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16702
|
+
let freeGrow = parentMain - baseMain - Math.max(0, n - 1) * gap;
|
|
16703
|
+
if (totalGrow > 0 && freeGrow > 0) {
|
|
16704
|
+
for (let i = 0; i < n; i++) {
|
|
16705
|
+
sizes[i][mainSize] += freeGrow * flexGrows[i] / totalGrow;
|
|
16706
|
+
}
|
|
16707
|
+
}
|
|
16708
|
+
const totalMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16709
|
+
const free = parentMain - totalMain - Math.max(0, n - 1) * gap;
|
|
16710
|
+
let offset = 0, extraGap = 0;
|
|
16711
|
+
if (justify === "flex-end")
|
|
16712
|
+
offset = free;
|
|
16713
|
+
else if (justify === "center")
|
|
16714
|
+
offset = Math.max(0, free / 2);
|
|
16715
|
+
else if (justify === "space-between" && n > 1)
|
|
16716
|
+
extraGap = free / (n - 1);
|
|
16717
|
+
else if (justify === "space-around") {
|
|
16718
|
+
extraGap = free / n;
|
|
16719
|
+
offset = extraGap / 2;
|
|
16720
|
+
} else if (justify === "space-evenly") {
|
|
16721
|
+
extraGap = free / (n + 1);
|
|
16722
|
+
offset = extraGap;
|
|
16723
|
+
}
|
|
16724
|
+
let cursor = offset;
|
|
16725
|
+
return sizes.map((sz, i) => {
|
|
16726
|
+
const childCrossBase = sz[crossSize];
|
|
16727
|
+
const childAlign = children[i].style.alignSelf ?? "auto";
|
|
16728
|
+
const effectiveAlign = childAlign === "auto" ? align : childAlign;
|
|
16729
|
+
let childMain = sz[mainSize];
|
|
16730
|
+
let childCross = childCrossBase;
|
|
16731
|
+
const res = { x: 0, y: 0, width: 0, height: 0 };
|
|
16732
|
+
res[mainPos] = cursor;
|
|
16733
|
+
res[crossPos] = 0;
|
|
16734
|
+
res[mainDim] = childMain;
|
|
16735
|
+
res[crossDim] = childCross;
|
|
16736
|
+
if (effectiveAlign === "stretch") {
|
|
16737
|
+
const hasExplicitCross = typeof children[i].style[crossDim] === "number";
|
|
16738
|
+
if (!hasExplicitCross) {
|
|
16739
|
+
res[crossDim] = parentCross;
|
|
16740
|
+
res[crossPos] = 0;
|
|
16741
|
+
}
|
|
16742
|
+
} else if (effectiveAlign === "flex-end") {
|
|
16743
|
+
res[crossPos] = parentCross - childCross;
|
|
16744
|
+
} else if (effectiveAlign === "center") {
|
|
16745
|
+
res[crossPos] = Math.max(0, (parentCross - childCross) / 2);
|
|
16746
|
+
}
|
|
16747
|
+
cursor += childMain + gap + extraGap;
|
|
16748
|
+
return res;
|
|
16749
|
+
});
|
|
15816
16750
|
}
|
|
15817
16751
|
|
|
15818
16752
|
// _build/lib/text-measure.js
|
|
15819
|
-
|
|
15820
|
-
DrawTextW: "ptr wstr i32 ptr i32 -> i32",
|
|
15821
|
-
GetDC: "ptr -> ptr",
|
|
15822
|
-
ReleaseDC: "ptr ptr -> i32"
|
|
15823
|
-
});
|
|
15824
|
-
var gdi32 = bindLib("gdi32.dll", {
|
|
15825
|
-
SelectObject: "ptr ptr -> ptr"
|
|
15826
|
-
});
|
|
16753
|
+
import * as gui2 from "gui";
|
|
15827
16754
|
function measureText(hdc, text, maxWidth) {
|
|
15828
|
-
const
|
|
15829
|
-
|
|
15830
|
-
dv.setInt32(8, maxWidth, true);
|
|
15831
|
-
user32.DrawTextW(
|
|
16755
|
+
const r = RECT.encode({ right: maxWidth });
|
|
16756
|
+
DrawText(
|
|
15832
16757
|
hdc,
|
|
15833
16758
|
text,
|
|
15834
16759
|
-1,
|
|
15835
|
-
|
|
16760
|
+
r.ptr,
|
|
15836
16761
|
1024
|
|
15837
16762
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15838
16763
|
);
|
|
15839
|
-
|
|
16764
|
+
const { right, bottom } = RECT.decode(r);
|
|
16765
|
+
return { width: right, height: bottom };
|
|
15840
16766
|
}
|
|
15841
16767
|
function getButtonIdealSize(hwnd) {
|
|
15842
|
-
const size =
|
|
15843
|
-
gui2.SendMessage(hwnd, 5633, 0,
|
|
15844
|
-
const
|
|
15845
|
-
return { width:
|
|
16768
|
+
const size = SIZE.alloc();
|
|
16769
|
+
gui2.SendMessage(hwnd, 5633, 0, size.ptr);
|
|
16770
|
+
const { cx, cy } = SIZE.decode(size);
|
|
16771
|
+
return { width: cx, height: cy };
|
|
15846
16772
|
}
|
|
15847
16773
|
function measureTextForHwnd(hwnd, text) {
|
|
15848
|
-
const hdc =
|
|
16774
|
+
const hdc = GetDC(hwnd);
|
|
15849
16775
|
if (!hdc)
|
|
15850
16776
|
return { width: 0, height: 0 };
|
|
15851
16777
|
const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
|
|
15852
|
-
const oldFont = hFont ?
|
|
16778
|
+
const oldFont = hFont ? SelectObject(hdc, hFont) : NULL;
|
|
15853
16779
|
const result = measureText(hdc, text, 0);
|
|
15854
16780
|
if (hFont)
|
|
15855
|
-
|
|
15856
|
-
|
|
16781
|
+
SelectObject(hdc, oldFont);
|
|
16782
|
+
ReleaseDC(hwnd, hdc);
|
|
15857
16783
|
const wr = gui2.GetWindowRect(hwnd);
|
|
15858
16784
|
const cr = gui2.GetClientRect(hwnd);
|
|
15859
16785
|
if (wr && cr) {
|
|
@@ -15865,14 +16791,20 @@ function measureTextForHwnd(hwnd, text) {
|
|
|
15865
16791
|
|
|
15866
16792
|
// _build/lib/react-qw/reconciler.js
|
|
15867
16793
|
var dpiFont = gui3.CreateSystemDpiFont();
|
|
15868
|
-
var scaleFactor =
|
|
16794
|
+
var scaleFactor = (() => {
|
|
16795
|
+
const hdc = GetDC(NULL);
|
|
16796
|
+
const dpi = hdc ? GetDeviceCaps(hdc, 88) : 96;
|
|
16797
|
+
if (hdc)
|
|
16798
|
+
ReleaseDC(NULL, hdc);
|
|
16799
|
+
return dpi / 96;
|
|
16800
|
+
})();
|
|
15869
16801
|
var DELAYED_CONTROLS = /* @__PURE__ */ new Set(["SysListView32", "SysTreeView32", "LISTBOX", "COMBOBOX", "msctls_trackbar32", "SysDateTimePick32", "SysLink"]);
|
|
15870
16802
|
function isDelayedControl(winClass) {
|
|
15871
16803
|
return DELAYED_CONTROLS.has(winClass);
|
|
15872
16804
|
}
|
|
15873
16805
|
function setupWindowProc(instance, hwnd) {
|
|
15874
16806
|
instance.hwnd = hwnd;
|
|
15875
|
-
const oldProc =
|
|
16807
|
+
const oldProc = GetWindowLongPtr(
|
|
15876
16808
|
hwnd,
|
|
15877
16809
|
-4
|
|
15878
16810
|
/* gui.Gwlp.WNDPROC */
|
|
@@ -15881,11 +16813,11 @@ function setupWindowProc(instance, hwnd) {
|
|
|
15881
16813
|
gui3.SetWindowProc(hwnd, (hwnd2, msg, wParam, lParam) => {
|
|
15882
16814
|
const ev = instance.props.onEvent;
|
|
15883
16815
|
if (!ev)
|
|
15884
|
-
return
|
|
16816
|
+
return CallWindowProc(oldProc, hwnd2, msg, wParam, lParam);
|
|
15885
16817
|
if (typeof ev === "object") {
|
|
15886
|
-
return ev.fn({ hwnd: hwnd2, msg, wParam, lParam, callOldWndProc: () =>
|
|
16818
|
+
return ev.fn({ hwnd: hwnd2, msg, wParam, lParam, callOldWndProc: () => CallWindowProc(oldProc, hwnd2, msg, wParam, lParam) });
|
|
15887
16819
|
}
|
|
15888
|
-
const result =
|
|
16820
|
+
const result = CallWindowProc(oldProc, hwnd2, msg, wParam, lParam);
|
|
15889
16821
|
const override = ev({ hwnd: hwnd2, msg, wParam, lParam });
|
|
15890
16822
|
return typeof override === "number" && Number.isInteger(override) ? override : result;
|
|
15891
16823
|
});
|
|
@@ -15955,7 +16887,7 @@ function runFlexLayout(inst) {
|
|
|
15955
16887
|
if (lr && lr.x === r.x && lr.y === r.y && lr.w === r.width && lr.h === r.height)
|
|
15956
16888
|
continue;
|
|
15957
16889
|
console.log("flex: set", child.type, child.hwnd, "to", r.x, r.y, r.width, r.height);
|
|
15958
|
-
|
|
16890
|
+
SetWindowPos(
|
|
15959
16891
|
child.hwnd,
|
|
15960
16892
|
0,
|
|
15961
16893
|
(r.x + pl) * scaleFactor,
|
|
@@ -15965,7 +16897,7 @@ function runFlexLayout(inst) {
|
|
|
15965
16897
|
64
|
|
15966
16898
|
/* gui.SetWindowPosFlag.SWP_SHOWWINDOW */
|
|
15967
16899
|
);
|
|
15968
|
-
|
|
16900
|
+
InvalidateRect(child.hwnd, NULL, 1);
|
|
15969
16901
|
child.lastRect = { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
15970
16902
|
}
|
|
15971
16903
|
for (const c of children)
|
|
@@ -16011,7 +16943,7 @@ var hostConfig = {
|
|
|
16011
16943
|
if (child.hwnd === null) {
|
|
16012
16944
|
ensureChildWindow(child, parent.hwnd);
|
|
16013
16945
|
} else {
|
|
16014
|
-
|
|
16946
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16015
16947
|
}
|
|
16016
16948
|
if (false)
|
|
16017
16949
|
console.log("[reconciler] appendInitialChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16021,7 +16953,7 @@ var hostConfig = {
|
|
|
16021
16953
|
if (child.hwnd === null) {
|
|
16022
16954
|
ensureChildWindow(child, parent.hwnd);
|
|
16023
16955
|
} else {
|
|
16024
|
-
|
|
16956
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16025
16957
|
}
|
|
16026
16958
|
if (false)
|
|
16027
16959
|
console.log("[reconciler] appendChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16031,7 +16963,7 @@ var hostConfig = {
|
|
|
16031
16963
|
if (child.hwnd === null) {
|
|
16032
16964
|
ensureChildWindow(child, container);
|
|
16033
16965
|
} else {
|
|
16034
|
-
|
|
16966
|
+
SetParent(child.hwnd, container);
|
|
16035
16967
|
}
|
|
16036
16968
|
const rootInst = instancesByHwnd.get(container);
|
|
16037
16969
|
if (rootInst)
|
|
@@ -16043,7 +16975,7 @@ var hostConfig = {
|
|
|
16043
16975
|
if (child.hwnd === null) {
|
|
16044
16976
|
ensureChildWindow(child, parent.hwnd);
|
|
16045
16977
|
} else {
|
|
16046
|
-
|
|
16978
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16047
16979
|
}
|
|
16048
16980
|
if (false)
|
|
16049
16981
|
console.log("[reconciler] insertBefore parent:", parent.hwnd, "child:", child.hwnd, "before:", beforeChild.hwnd);
|
|
@@ -16055,7 +16987,7 @@ var hostConfig = {
|
|
|
16055
16987
|
if (child.hwnd === null) {
|
|
16056
16988
|
ensureChildWindow(child, container);
|
|
16057
16989
|
} else {
|
|
16058
|
-
|
|
16990
|
+
SetParent(child.hwnd, container);
|
|
16059
16991
|
}
|
|
16060
16992
|
const rootInst = instancesByHwnd.get(container);
|
|
16061
16993
|
if (!rootInst)
|
|
@@ -16112,7 +17044,7 @@ var hostConfig = {
|
|
|
16112
17044
|
resetTextContent(_instance) {
|
|
16113
17045
|
},
|
|
16114
17046
|
commitTextUpdate(instance, _oldText, newText) {
|
|
16115
|
-
|
|
17047
|
+
SetWindowText(instance.hwnd, newText);
|
|
16116
17048
|
},
|
|
16117
17049
|
hideInstance(instance) {
|
|
16118
17050
|
if (instance.hwnd !== null)
|
|
@@ -16166,10 +17098,10 @@ var hostConfig = {
|
|
|
16166
17098
|
clearContainer(_container) {
|
|
16167
17099
|
},
|
|
16168
17100
|
scheduleTimeout(fn, delay) {
|
|
16169
|
-
return
|
|
17101
|
+
return os4.setTimeout(fn, delay);
|
|
16170
17102
|
},
|
|
16171
17103
|
cancelTimeout(id) {
|
|
16172
|
-
|
|
17104
|
+
os4.clearTimeout?.(id);
|
|
16173
17105
|
},
|
|
16174
17106
|
noTimeout: -1,
|
|
16175
17107
|
supportsMutation: true,
|
|
@@ -16336,298 +17268,23 @@ var ComboBox = (0, import_react4.forwardRef)(({ items, selectedIndex: controlled
|
|
|
16336
17268
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
16337
17269
|
var import_react5 = __toESM(require_react(), 1);
|
|
16338
17270
|
import * as gui6 from "gui";
|
|
16339
|
-
import * as ffi4 from "ffi";
|
|
16340
|
-
|
|
16341
|
-
// _build/lib/ffi-struct.js
|
|
16342
|
-
import * as os2 from "os";
|
|
16343
|
-
var PTR = os2.arch === "x64" ? 8 : 4;
|
|
16344
|
-
var AS = {
|
|
16345
|
-
u8: [1, 1],
|
|
16346
|
-
i8: [1, 1],
|
|
16347
|
-
u16: [2, 2],
|
|
16348
|
-
i16: [2, 2],
|
|
16349
|
-
u32: [4, 4],
|
|
16350
|
-
i32: [4, 4],
|
|
16351
|
-
u64: [8, 8],
|
|
16352
|
-
i64: [8, 8],
|
|
16353
|
-
f32: [4, 4],
|
|
16354
|
-
f64: [8, 8],
|
|
16355
|
-
ptr: [PTR, PTR],
|
|
16356
|
-
wstr: [2, 2]
|
|
16357
|
-
// 仅定长数组元素用(wchar)
|
|
16358
|
-
};
|
|
16359
|
-
function alignUp(v, a) {
|
|
16360
|
-
return v + a - 1 & ~(a - 1);
|
|
16361
|
-
}
|
|
16362
|
-
function parseField(f) {
|
|
16363
|
-
const arr = /^(.+)\[(\d+)\]$/.exec(f);
|
|
16364
|
-
if (arr) {
|
|
16365
|
-
const b2 = normKind(arr[1]);
|
|
16366
|
-
if (b2 === "void")
|
|
16367
|
-
throw new Error(`ffi-struct: "void" cannot be an array base`);
|
|
16368
|
-
return { base: b2, count: Number(arr[2]) };
|
|
16369
|
-
}
|
|
16370
|
-
const b = normKind(f);
|
|
16371
|
-
if (b === "void" || b === "wstr")
|
|
16372
|
-
throw new Error(`ffi-struct: invalid scalar field type "${f}"`);
|
|
16373
|
-
return { base: b, count: 1 };
|
|
16374
|
-
}
|
|
16375
|
-
function layout(def) {
|
|
16376
|
-
const fields = [];
|
|
16377
|
-
let cursor = 0;
|
|
16378
|
-
let maxAlign = 1;
|
|
16379
|
-
for (const key of Object.keys(def)) {
|
|
16380
|
-
const v = def[key];
|
|
16381
|
-
let a;
|
|
16382
|
-
let w;
|
|
16383
|
-
if (typeof v === "string") {
|
|
16384
|
-
const { base, count } = parseField(v);
|
|
16385
|
-
const [align, elem] = AS[base];
|
|
16386
|
-
a = align;
|
|
16387
|
-
w = count >= 1 ? elem * count : elem;
|
|
16388
|
-
fields.push({ name: key, base, count, offset: 0 });
|
|
16389
|
-
} else {
|
|
16390
|
-
const child = v;
|
|
16391
|
-
a = child.structAlign;
|
|
16392
|
-
w = child.size;
|
|
16393
|
-
fields.push({ name: key, base: "u8", count: 0, offset: 0, child });
|
|
16394
|
-
}
|
|
16395
|
-
const off = alignUp(cursor, a);
|
|
16396
|
-
const f = fields[fields.length - 1];
|
|
16397
|
-
f.offset = off;
|
|
16398
|
-
cursor = off + w;
|
|
16399
|
-
if (a > maxAlign)
|
|
16400
|
-
maxAlign = a;
|
|
16401
|
-
}
|
|
16402
|
-
return { fields, size: alignUp(cursor, maxAlign), structAlign: maxAlign };
|
|
16403
|
-
}
|
|
16404
|
-
var _layoutCache = /* @__PURE__ */ new WeakMap();
|
|
16405
|
-
function buildLayout(def) {
|
|
16406
|
-
let hit = _layoutCache.get(def);
|
|
16407
|
-
if (hit)
|
|
16408
|
-
return hit;
|
|
16409
|
-
hit = layout(def);
|
|
16410
|
-
_layoutCache.set(def, hit);
|
|
16411
|
-
return hit;
|
|
16412
|
-
}
|
|
16413
|
-
function readScalar(dv, off, k) {
|
|
16414
|
-
switch (k) {
|
|
16415
|
-
case "u8":
|
|
16416
|
-
return dv.getUint8(off);
|
|
16417
|
-
case "i8":
|
|
16418
|
-
return dv.getInt8(off);
|
|
16419
|
-
case "u16":
|
|
16420
|
-
return dv.getUint16(off, true);
|
|
16421
|
-
case "i16":
|
|
16422
|
-
return dv.getInt16(off, true);
|
|
16423
|
-
case "u32":
|
|
16424
|
-
return dv.getUint32(off, true);
|
|
16425
|
-
case "i32":
|
|
16426
|
-
return dv.getInt32(off, true);
|
|
16427
|
-
case "u64":
|
|
16428
|
-
return Number(dv.getBigUint64(off, true));
|
|
16429
|
-
case "i64":
|
|
16430
|
-
return Number(dv.getBigInt64(off, true));
|
|
16431
|
-
case "f32":
|
|
16432
|
-
return dv.getFloat32(off, true);
|
|
16433
|
-
case "f64":
|
|
16434
|
-
return dv.getFloat64(off, true);
|
|
16435
|
-
case "ptr":
|
|
16436
|
-
return readPtr(dv, off);
|
|
16437
|
-
case "wstr":
|
|
16438
|
-
return dv.getUint16(off, true);
|
|
16439
|
-
}
|
|
16440
|
-
}
|
|
16441
|
-
function readPtr(dv, off) {
|
|
16442
|
-
if (PTR === 8)
|
|
16443
|
-
return Number(dv.getBigUint64(off, true));
|
|
16444
|
-
return dv.getUint32(off, true);
|
|
16445
|
-
}
|
|
16446
|
-
function writeScalar(dv, off, k, val) {
|
|
16447
|
-
switch (k) {
|
|
16448
|
-
case "u8":
|
|
16449
|
-
dv.setUint8(off, val);
|
|
16450
|
-
break;
|
|
16451
|
-
case "i8":
|
|
16452
|
-
dv.setInt8(off, val);
|
|
16453
|
-
break;
|
|
16454
|
-
case "u16":
|
|
16455
|
-
dv.setUint16(off, val, true);
|
|
16456
|
-
break;
|
|
16457
|
-
case "i16":
|
|
16458
|
-
dv.setInt16(off, val, true);
|
|
16459
|
-
break;
|
|
16460
|
-
case "u32":
|
|
16461
|
-
dv.setUint32(off, val >>> 0, true);
|
|
16462
|
-
break;
|
|
16463
|
-
case "i32":
|
|
16464
|
-
dv.setInt32(off, val | 0, true);
|
|
16465
|
-
break;
|
|
16466
|
-
case "u64":
|
|
16467
|
-
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16468
|
-
break;
|
|
16469
|
-
case "i64":
|
|
16470
|
-
dv.setBigInt64(off, BigInt(Math.trunc(val)), true);
|
|
16471
|
-
break;
|
|
16472
|
-
case "f32":
|
|
16473
|
-
dv.setFloat32(off, val, true);
|
|
16474
|
-
break;
|
|
16475
|
-
case "f64":
|
|
16476
|
-
dv.setFloat64(off, val, true);
|
|
16477
|
-
break;
|
|
16478
|
-
case "ptr":
|
|
16479
|
-
writePtr(dv, off, val);
|
|
16480
|
-
break;
|
|
16481
|
-
case "wstr":
|
|
16482
|
-
dv.setUint16(off, val, true);
|
|
16483
|
-
break;
|
|
16484
|
-
}
|
|
16485
|
-
}
|
|
16486
|
-
function writePtr(dv, off, val) {
|
|
16487
|
-
if (PTR === 8)
|
|
16488
|
-
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16489
|
-
else
|
|
16490
|
-
dv.setUint32(off, val >>> 0, true);
|
|
16491
|
-
}
|
|
16492
|
-
function readField(dv, base, f) {
|
|
16493
|
-
const off = base + f.offset;
|
|
16494
|
-
if (f.child)
|
|
16495
|
-
return readInto(f.child, dv.buffer, off);
|
|
16496
|
-
if (f.count > 1) {
|
|
16497
|
-
if (f.base === "wstr") {
|
|
16498
|
-
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16499
|
-
let end = 0;
|
|
16500
|
-
while (end < arr.length && arr[end] !== 0)
|
|
16501
|
-
end++;
|
|
16502
|
-
let s = "";
|
|
16503
|
-
for (let i = 0; i < end; i++)
|
|
16504
|
-
s += String.fromCharCode(arr[i]);
|
|
16505
|
-
return s;
|
|
16506
|
-
}
|
|
16507
|
-
const out = [];
|
|
16508
|
-
const step = AS[f.base][1];
|
|
16509
|
-
for (let i = 0; i < f.count; i++)
|
|
16510
|
-
out.push(readScalar(dv, off + i * step, f.base));
|
|
16511
|
-
return out;
|
|
16512
|
-
}
|
|
16513
|
-
return readScalar(dv, off, f.base);
|
|
16514
|
-
}
|
|
16515
|
-
function writeField(dv, base, f, v) {
|
|
16516
|
-
const off = base + f.offset;
|
|
16517
|
-
if (f.child) {
|
|
16518
|
-
writeInto(f.child, v, dv.buffer, off);
|
|
16519
|
-
return;
|
|
16520
|
-
}
|
|
16521
|
-
if (f.count > 1) {
|
|
16522
|
-
if (f.base === "wstr") {
|
|
16523
|
-
const s = String(v ?? "");
|
|
16524
|
-
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16525
|
-
for (let i = 0; i < arr.length; i++)
|
|
16526
|
-
arr[i] = 0;
|
|
16527
|
-
const n = Math.min(s.length, f.count - 1);
|
|
16528
|
-
for (let i = 0; i < n; i++)
|
|
16529
|
-
arr[i] = s.charCodeAt(i);
|
|
16530
|
-
return;
|
|
16531
|
-
}
|
|
16532
|
-
const step = AS[f.base][1];
|
|
16533
|
-
const list = v ?? [];
|
|
16534
|
-
for (let i = 0; i < f.count; i++)
|
|
16535
|
-
writeScalar(dv, off + i * step, f.base, list[i] ?? 0);
|
|
16536
|
-
return;
|
|
16537
|
-
}
|
|
16538
|
-
writeScalar(dv, off, f.base, Number(v));
|
|
16539
|
-
}
|
|
16540
|
-
function doSize(def) {
|
|
16541
|
-
return buildLayout(def).size;
|
|
16542
|
-
}
|
|
16543
|
-
function readInto(child, buf, offset) {
|
|
16544
|
-
const r = child;
|
|
16545
|
-
return r.read(buf, offset);
|
|
16546
|
-
}
|
|
16547
|
-
function doRead(_def, fields, buf, offset) {
|
|
16548
|
-
const out = {};
|
|
16549
|
-
const dv = new DataView(buf);
|
|
16550
|
-
for (const f of fields)
|
|
16551
|
-
out[f.name] = readField(dv, offset, f);
|
|
16552
|
-
return out;
|
|
16553
|
-
}
|
|
16554
|
-
function doWrite(def, fields, v, buf, offset = 0) {
|
|
16555
|
-
buf = buf ?? new ArrayBuffer(doSize(def));
|
|
16556
|
-
const dv = new DataView(buf);
|
|
16557
|
-
for (const f of fields)
|
|
16558
|
-
writeField(dv, offset, f, v[f.name]);
|
|
16559
|
-
return buf;
|
|
16560
|
-
}
|
|
16561
|
-
function writeInto(child, v, buf, offset) {
|
|
16562
|
-
const w = child;
|
|
16563
|
-
w.write(v, buf, offset);
|
|
16564
|
-
}
|
|
16565
|
-
function struct(def) {
|
|
16566
|
-
const { fields, size, structAlign } = buildLayout(def);
|
|
16567
|
-
return {
|
|
16568
|
-
__fields: def,
|
|
16569
|
-
size,
|
|
16570
|
-
structAlign,
|
|
16571
|
-
read: (buf, offset = 0) => doRead(def, fields, buf, offset),
|
|
16572
|
-
write: (v, buf, offset = 0) => doWrite(def, fields, v, buf, offset),
|
|
16573
|
-
offsetOf: (name) => {
|
|
16574
|
-
for (const f of fields)
|
|
16575
|
-
if (f.name === name)
|
|
16576
|
-
return f.offset;
|
|
16577
|
-
throw new Error(`ffi-struct: no field "${String(name)}"`);
|
|
16578
|
-
}
|
|
16579
|
-
};
|
|
16580
|
-
}
|
|
16581
17271
|
|
|
16582
17272
|
// _build/lib/react-qw/nmhdr.js
|
|
16583
|
-
import * as os3 from "os";
|
|
16584
|
-
import * as ffi3 from "ffi";
|
|
16585
|
-
var IS64 = os3.arch === "x64";
|
|
16586
|
-
var PTR_SIZE = IS64 ? 8 : 4;
|
|
16587
|
-
var NMHDR = struct({ hwndFrom: "ptr", idFrom: "ptr", code: "i32" });
|
|
16588
|
-
var NMHDR_SIZE = NMHDR.size;
|
|
16589
|
-
var NMHDR_CODE = NMHDR.offsetOf("code");
|
|
16590
|
-
function readI32At(ptr, offset) {
|
|
16591
|
-
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8 | ffi3.readByte(ptr + offset + 2) << 16 | ffi3.readByte(ptr + offset + 3) << 24;
|
|
16592
|
-
}
|
|
16593
|
-
function readU16At(ptr, offset) {
|
|
16594
|
-
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8;
|
|
16595
|
-
}
|
|
16596
17273
|
function nmCode(lParam) {
|
|
16597
|
-
return
|
|
17274
|
+
return NMHDR.decode(lParam).code;
|
|
16598
17275
|
}
|
|
16599
17276
|
|
|
16600
17277
|
// _build/lib/react-qw/components/DateTimePicker.js
|
|
16601
|
-
var SYSTEMTIME = struct({
|
|
16602
|
-
wYear: "u16",
|
|
16603
|
-
wMonth: "u16",
|
|
16604
|
-
wDayOfWeek: "u16",
|
|
16605
|
-
wDay: "u16",
|
|
16606
|
-
wHour: "u16",
|
|
16607
|
-
wMinute: "u16",
|
|
16608
|
-
wSecond: "u16",
|
|
16609
|
-
wMilliseconds: "u16"
|
|
16610
|
-
});
|
|
16611
|
-
var NMDATETIMECHANGE = struct({
|
|
16612
|
-
hdr: NMHDR,
|
|
16613
|
-
dwFlags: "u32",
|
|
16614
|
-
st: SYSTEMTIME
|
|
16615
|
-
});
|
|
16616
|
-
function bufPtr(buf) {
|
|
16617
|
-
return ffi4.bufferPtr(buf);
|
|
16618
|
-
}
|
|
16619
17278
|
function dateToSysTimeBuf(d) {
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
|
|
16628
|
-
|
|
16629
|
-
dv.setUint16(14, d.getMilliseconds(), true);
|
|
16630
|
-
return buf;
|
|
17279
|
+
return SYSTEMTIME.encode({
|
|
17280
|
+
wYear: d.getFullYear(),
|
|
17281
|
+
wMonth: d.getMonth() + 1,
|
|
17282
|
+
wDay: d.getDate(),
|
|
17283
|
+
wHour: d.getHours(),
|
|
17284
|
+
wMinute: d.getMinutes(),
|
|
17285
|
+
wSecond: d.getSeconds(),
|
|
17286
|
+
wMilliseconds: d.getMilliseconds()
|
|
17287
|
+
});
|
|
16631
17288
|
}
|
|
16632
17289
|
var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ value, onChange, defaultValue, format = "short", allowNone, updown, style }, ref) {
|
|
16633
17290
|
const [internalDate, setInternalDate] = (0, import_react5.useState)(defaultValue ?? null);
|
|
@@ -16652,7 +17309,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16652
17309
|
const d = effectiveDate;
|
|
16653
17310
|
if (d) {
|
|
16654
17311
|
const buf = dateToSysTimeBuf(d);
|
|
16655
|
-
gui6.SendMessage(h, 4098, 0,
|
|
17312
|
+
gui6.SendMessage(h, 4098, 0, buf.ptr);
|
|
16656
17313
|
} else {
|
|
16657
17314
|
gui6.SendMessage(h, 4098, 1, 0);
|
|
16658
17315
|
}
|
|
@@ -16661,7 +17318,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16661
17318
|
const h = dpRef.current;
|
|
16662
17319
|
if (!h)
|
|
16663
17320
|
return;
|
|
16664
|
-
|
|
17321
|
+
InvalidateRect(h, NULL, 1);
|
|
16665
17322
|
const cr = gui6.GetClientRect(h);
|
|
16666
17323
|
if (cr) {
|
|
16667
17324
|
const w = cr.right - cr.left;
|
|
@@ -16673,20 +17330,13 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16673
17330
|
if (e.msg === 78) {
|
|
16674
17331
|
const code = nmCode(e.lParam);
|
|
16675
17332
|
if (code === -759) {
|
|
16676
|
-
const st = NMDATETIMECHANGE.
|
|
16677
|
-
const dwFlags = readI32At(e.lParam, NMDATETIMECHANGE.offsetOf("dwFlags"));
|
|
17333
|
+
const { dwFlags, st } = NMDATETIMECHANGE.decode(e.lParam);
|
|
16678
17334
|
if (dwFlags === 1) {
|
|
16679
17335
|
if (!isControlled)
|
|
16680
17336
|
setInternalDate(null);
|
|
16681
17337
|
onChangeRef.current?.(null);
|
|
16682
17338
|
} else {
|
|
16683
|
-
const
|
|
16684
|
-
const month = readU16At(e.lParam, st + 2);
|
|
16685
|
-
const day = readU16At(e.lParam, st + 6);
|
|
16686
|
-
const hour = readU16At(e.lParam, st + 8);
|
|
16687
|
-
const min = readU16At(e.lParam, st + 10);
|
|
16688
|
-
const sec = readU16At(e.lParam, st + 12);
|
|
16689
|
-
const d = new Date(year, month - 1, day, hour, min, sec);
|
|
17339
|
+
const d = new Date(st.wYear, st.wMonth - 1, st.wDay, st.wHour, st.wMinute, st.wSecond);
|
|
16690
17340
|
if (!isControlled)
|
|
16691
17341
|
setInternalDate(d);
|
|
16692
17342
|
onChangeRef.current?.(d);
|
|
@@ -16702,14 +17352,6 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16702
17352
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
16703
17353
|
var import_react6 = __toESM(require_react(), 1);
|
|
16704
17354
|
import * as gui7 from "gui";
|
|
16705
|
-
import * as ffi5 from "ffi";
|
|
16706
|
-
function textToUtf16(s) {
|
|
16707
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16708
|
-
const dv = new DataView(buf);
|
|
16709
|
-
for (let i = 0; i < s.length; i++)
|
|
16710
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16711
|
-
return buf;
|
|
16712
|
-
}
|
|
16713
17355
|
var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValue = "", onChange, placeholder, password, multiline, readonly, number, disabled, style }, ref) => {
|
|
16714
17356
|
const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue);
|
|
16715
17357
|
const isControlled = controlledValue !== void 0;
|
|
@@ -16728,8 +17370,8 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16728
17370
|
const h = inputRef.current;
|
|
16729
17371
|
if (!h || !placeholder)
|
|
16730
17372
|
return;
|
|
16731
|
-
const buf =
|
|
16732
|
-
gui7.SendMessage(h, 5377, 1,
|
|
17373
|
+
const buf = WCHAR.encode(placeholder);
|
|
17374
|
+
gui7.SendMessage(h, 5377, 1, buf.ptr);
|
|
16733
17375
|
}, [placeholder]);
|
|
16734
17376
|
return (0, import_jsx_runtime5.jsx)("w", { type: "EDIT", text: displayValue, ws, style, disabled, ref: (h) => {
|
|
16735
17377
|
inputRef.current = h;
|
|
@@ -16753,20 +17395,6 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16753
17395
|
// _build/lib/react-qw/components/Link.js
|
|
16754
17396
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
16755
17397
|
var import_react7 = __toESM(require_react(), 1);
|
|
16756
|
-
import * as gui8 from "gui";
|
|
16757
|
-
import * as ffi6 from "ffi";
|
|
16758
|
-
function readUtf16(ptr, offset, maxWords) {
|
|
16759
|
-
const chars = [];
|
|
16760
|
-
for (let i = 0; i < maxWords; i++) {
|
|
16761
|
-
const lo = ffi6.readByte(ptr + offset + i * 2);
|
|
16762
|
-
const hi = ffi6.readByte(ptr + offset + i * 2 + 1);
|
|
16763
|
-
const code = hi << 8 | lo;
|
|
16764
|
-
if (code === 0)
|
|
16765
|
-
break;
|
|
16766
|
-
chars.push(String.fromCharCode(code));
|
|
16767
|
-
}
|
|
16768
|
-
return chars.join("");
|
|
16769
|
-
}
|
|
16770
17398
|
var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClick, style }, ref) {
|
|
16771
17399
|
const displayText = children != null ? String(children) : href ?? "";
|
|
16772
17400
|
const linkText = href ? `<A HREF="${href}">${displayText}</A>` : displayText;
|
|
@@ -16777,14 +17405,13 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16777
17405
|
const h = linkRef.current;
|
|
16778
17406
|
if (!h)
|
|
16779
17407
|
return;
|
|
16780
|
-
|
|
17408
|
+
InvalidateRect(h, NULL, 1);
|
|
16781
17409
|
}, [linkText]);
|
|
16782
17410
|
return (0, import_jsx_runtime6.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16783
17411
|
if (e.msg === 78) {
|
|
16784
17412
|
const code = nmCode(e.lParam);
|
|
16785
17413
|
if (code === -2 || code === -4) {
|
|
16786
|
-
|
|
16787
|
-
onClickRef.current?.(url);
|
|
17414
|
+
onClickRef.current?.(NMLINK.decode(e.lParam).item.szUrl);
|
|
16788
17415
|
}
|
|
16789
17416
|
}
|
|
16790
17417
|
}, children: (0, import_jsx_runtime6.jsx)("w", { type: "SysLink", ws: 268435456 | 65536, text: linkText, style: { flexGrow: 1 }, ref: (h) => {
|
|
@@ -16795,7 +17422,7 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16795
17422
|
// _build/lib/react-qw/components/ListBox.js
|
|
16796
17423
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
16797
17424
|
var import_react8 = __toESM(require_react(), 1);
|
|
16798
|
-
import * as
|
|
17425
|
+
import * as gui8 from "gui";
|
|
16799
17426
|
var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledIndex, defaultSelectedIndex = -1, onChange, style, sort, scrollToBottom }, ref) => {
|
|
16800
17427
|
const [internalIndex, setInternalIndex] = (0, import_react8.useState)(defaultSelectedIndex);
|
|
16801
17428
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -16807,18 +17434,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16807
17434
|
const h = lbRef.current;
|
|
16808
17435
|
if (!h)
|
|
16809
17436
|
return;
|
|
16810
|
-
|
|
17437
|
+
gui8.SendMessage(h, 388, 0, 0);
|
|
16811
17438
|
for (const item of items)
|
|
16812
|
-
|
|
17439
|
+
gui8.SendMessage(h, 384, 0, item);
|
|
16813
17440
|
if (sel >= 0 && sel < items.length)
|
|
16814
|
-
|
|
17441
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16815
17442
|
if (scrollToBottom && items.length > 0)
|
|
16816
|
-
|
|
17443
|
+
gui8.SendMessage(h, 407, items.length - 1, 0);
|
|
16817
17444
|
}, [items]);
|
|
16818
17445
|
(0, import_react8.useEffect)(() => {
|
|
16819
17446
|
const h = lbRef.current;
|
|
16820
17447
|
if (h)
|
|
16821
|
-
|
|
17448
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16822
17449
|
}, [sel]);
|
|
16823
17450
|
return (0, import_jsx_runtime7.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, onEvent: (e) => {
|
|
16824
17451
|
if (e.msg !== 273)
|
|
@@ -16828,7 +17455,7 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16828
17455
|
const h = lbRef.current;
|
|
16829
17456
|
if (!h)
|
|
16830
17457
|
return;
|
|
16831
|
-
const newSel =
|
|
17458
|
+
const newSel = gui8.SendMessage(h, 392, 0, 0);
|
|
16832
17459
|
if (newSel !== sel && newSel >= 0) {
|
|
16833
17460
|
if (!isControlled)
|
|
16834
17461
|
setInternalIndex(newSel);
|
|
@@ -16843,138 +17470,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16843
17470
|
// _build/lib/react-qw/components/ListView.js
|
|
16844
17471
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
16845
17472
|
var import_react9 = __toESM(require_react(), 1);
|
|
16846
|
-
import * as
|
|
16847
|
-
import * as
|
|
16848
|
-
import * as win2 from "win";
|
|
16849
|
-
function textToUtf162(s) {
|
|
16850
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16851
|
-
const dv = new DataView(buf);
|
|
16852
|
-
for (let i = 0; i < s.length; i++)
|
|
16853
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16854
|
-
return buf;
|
|
16855
|
-
}
|
|
16856
|
-
function readI32(ptr, offset) {
|
|
16857
|
-
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24;
|
|
16858
|
-
}
|
|
16859
|
-
function readU32(ptr, offset) {
|
|
16860
|
-
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24 >>> 0;
|
|
16861
|
-
}
|
|
16862
|
-
function readU64(ptr, offset) {
|
|
16863
|
-
const lo = readU32(ptr, offset);
|
|
16864
|
-
const hi = readU32(ptr, offset + 4);
|
|
16865
|
-
return lo + hi * 4294967296;
|
|
16866
|
-
}
|
|
17473
|
+
import * as gui9 from "gui";
|
|
17474
|
+
import * as ffi3 from "ffi";
|
|
16867
17475
|
function writeU32(ptr, offset, v) {
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
}
|
|
16873
|
-
function bufPtr2(buf) {
|
|
16874
|
-
return ffi7.bufferPtr(buf);
|
|
17476
|
+
ffi3.writeByte(ptr + offset, v & 255);
|
|
17477
|
+
ffi3.writeByte(ptr + offset + 1, v >> 8 & 255);
|
|
17478
|
+
ffi3.writeByte(ptr + offset + 2, v >> 16 & 255);
|
|
17479
|
+
ffi3.writeByte(ptr + offset + 3, v >> 24 & 255);
|
|
16875
17480
|
}
|
|
16876
17481
|
var LV_WS = 268435456 | 8388608 | 2097152 | 1048576 | 1 | 4;
|
|
16877
|
-
var NMCUSTOMDRAW = struct({
|
|
16878
|
-
hdr: NMHDR,
|
|
16879
|
-
dwDrawStage: "u32",
|
|
16880
|
-
hdc: "ptr",
|
|
16881
|
-
rc: "i32[4]",
|
|
16882
|
-
dwItemSpec: "ptr",
|
|
16883
|
-
uItemState: "u32",
|
|
16884
|
-
lItemlParam: "ptr"
|
|
16885
|
-
});
|
|
16886
|
-
var NMLVCUSTOMDRAW = struct({
|
|
16887
|
-
hdr: NMHDR,
|
|
16888
|
-
dwDrawStage: "u32",
|
|
16889
|
-
hdc: "ptr",
|
|
16890
|
-
rc: "i32[4]",
|
|
16891
|
-
dwItemSpec: "ptr",
|
|
16892
|
-
uItemState: "u32",
|
|
16893
|
-
lItemlParam: "ptr",
|
|
16894
|
-
clrText: "u32",
|
|
16895
|
-
clrTextBk: "u32",
|
|
16896
|
-
iSubItem: "i32",
|
|
16897
|
-
dwItemType: "u32"
|
|
16898
|
-
});
|
|
16899
|
-
var NMLISTVIEW = struct({
|
|
16900
|
-
hdr: NMHDR,
|
|
16901
|
-
iItem: "i32",
|
|
16902
|
-
iSubItem: "i32",
|
|
16903
|
-
uNewState: "u32",
|
|
16904
|
-
uOldState: "u32",
|
|
16905
|
-
uChanged: "u32",
|
|
16906
|
-
ptAction: "i32[2]",
|
|
16907
|
-
lParam: "ptr"
|
|
16908
|
-
});
|
|
16909
|
-
var CD_STAGE = NMCUSTOMDRAW.offsetOf("dwDrawStage");
|
|
16910
|
-
var CD_HDC = NMCUSTOMDRAW.offsetOf("hdc");
|
|
16911
|
-
var CD_ITEM = NMCUSTOMDRAW.offsetOf("dwItemSpec");
|
|
16912
17482
|
var CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf("clrText");
|
|
16913
17483
|
var CD_CLRTEXTBK = NMLVCUSTOMDRAW.offsetOf("clrTextBk");
|
|
16914
|
-
var CD_SUBITEM = NMLVCUSTOMDRAW.offsetOf("iSubItem");
|
|
16915
|
-
var NMIA_ITEM = NMLISTVIEW.offsetOf("iItem");
|
|
16916
|
-
var NMIA_SUBITEM = NMLISTVIEW.offsetOf("iSubItem");
|
|
16917
|
-
var NMLV_UNEW = NMLISTVIEW.offsetOf("uNewState");
|
|
16918
|
-
var NMLV_UOLD = NMLISTVIEW.offsetOf("uOldState");
|
|
16919
|
-
var LVITEMW = struct({
|
|
16920
|
-
mask: "u32",
|
|
16921
|
-
iItem: "i32",
|
|
16922
|
-
iSubItem: "i32",
|
|
16923
|
-
state: "u32",
|
|
16924
|
-
stateMask: "u32",
|
|
16925
|
-
pszText: "ptr",
|
|
16926
|
-
cchTextMax: "i32",
|
|
16927
|
-
iImage: "i32",
|
|
16928
|
-
lParam: "ptr",
|
|
16929
|
-
iIndent: "i32",
|
|
16930
|
-
iGroupId: "i32",
|
|
16931
|
-
cColumns: "u32",
|
|
16932
|
-
puColumns: "ptr",
|
|
16933
|
-
piColFmt: "ptr",
|
|
16934
|
-
iGroup: "i32"
|
|
16935
|
-
});
|
|
16936
|
-
var LVCOLUMNW = struct({
|
|
16937
|
-
mask: "u32",
|
|
16938
|
-
fmt: "i32",
|
|
16939
|
-
cx: "i32",
|
|
16940
|
-
pszText: "ptr",
|
|
16941
|
-
cchTextMax: "i32",
|
|
16942
|
-
iSubItem: "i32",
|
|
16943
|
-
iImage: "i32",
|
|
16944
|
-
iOrder: "i32",
|
|
16945
|
-
cxMin: "i32",
|
|
16946
|
-
cxDefault: "i32",
|
|
16947
|
-
cxIdeal: "i32"
|
|
16948
|
-
});
|
|
16949
17484
|
var fontCache = /* @__PURE__ */ new Map();
|
|
16950
|
-
var gdi322 = null;
|
|
16951
|
-
var createFontIndirectW = null;
|
|
16952
|
-
var selectObjectFn = null;
|
|
16953
|
-
var getObjectW = null;
|
|
16954
|
-
function ensureGdi() {
|
|
16955
|
-
if (gdi322 !== null)
|
|
16956
|
-
return;
|
|
16957
|
-
gdi322 = win2.LoadLibrary("gdi32.dll");
|
|
16958
|
-
if (!gdi322)
|
|
16959
|
-
return;
|
|
16960
|
-
createFontIndirectW = win2.GetProcAddress(gdi322, "CreateFontIndirectW");
|
|
16961
|
-
selectObjectFn = win2.GetProcAddress(gdi322, "SelectObject");
|
|
16962
|
-
getObjectW = win2.GetProcAddress(gdi322, "GetObjectW");
|
|
16963
|
-
}
|
|
16964
|
-
var user322 = null;
|
|
16965
|
-
var loadCursorW = null;
|
|
16966
|
-
var setCursorFn = null;
|
|
16967
|
-
var screenToClient = null;
|
|
16968
|
-
function ensureUser32() {
|
|
16969
|
-
if (user322 !== null)
|
|
16970
|
-
return;
|
|
16971
|
-
user322 = win2.LoadLibrary("user32.dll");
|
|
16972
|
-
if (!user322)
|
|
16973
|
-
return;
|
|
16974
|
-
loadCursorW = win2.GetProcAddress(user322, "LoadCursorW");
|
|
16975
|
-
setCursorFn = win2.GetProcAddress(user322, "SetCursor");
|
|
16976
|
-
screenToClient = win2.GetProcAddress(user322, "ScreenToClient");
|
|
16977
|
-
}
|
|
16978
17485
|
function getCellFont(hwnd, style) {
|
|
16979
17486
|
const key = (style.bold ? "b" : "") + (style.italic ? "i" : "") + (style.underline ? "u" : "");
|
|
16980
17487
|
if (key === "")
|
|
@@ -16982,39 +17489,37 @@ function getCellFont(hwnd, style) {
|
|
|
16982
17489
|
const cached = fontCache.get(key);
|
|
16983
17490
|
if (cached !== void 0)
|
|
16984
17491
|
return cached === 0 ? null : cached;
|
|
16985
|
-
|
|
16986
|
-
if (!createFontIndirectW || !getObjectW || !hwnd)
|
|
17492
|
+
if (!hwnd)
|
|
16987
17493
|
return null;
|
|
16988
|
-
|
|
16989
|
-
const
|
|
16990
|
-
const cur = gui10.SendMessage(hwnd, 49, 0, 0);
|
|
17494
|
+
let base = { lfHeight: -13 };
|
|
17495
|
+
const cur = gui9.SendMessage(hwnd, 49, 0, 0);
|
|
16991
17496
|
if (cur) {
|
|
16992
|
-
const
|
|
16993
|
-
if (!
|
|
17497
|
+
const lf = LOGFONTW.alloc();
|
|
17498
|
+
if (!GetObject(cur, LOGFONTW.size, lf))
|
|
16994
17499
|
return null;
|
|
16995
|
-
|
|
16996
|
-
dv.setInt32(0, -13, true);
|
|
17500
|
+
base = LOGFONTW.decode(lf);
|
|
16997
17501
|
}
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17502
|
+
const h = CreateFontIndirect({
|
|
17503
|
+
...base,
|
|
17504
|
+
...style.bold ? {
|
|
17505
|
+
lfWeight: 700
|
|
17506
|
+
/* gui.FontWeight.BOLD */
|
|
17507
|
+
} : {},
|
|
17508
|
+
...style.italic ? { lfItalic: 1 } : {},
|
|
17509
|
+
...style.underline ? { lfUnderline: 1 } : {}
|
|
17510
|
+
});
|
|
17005
17511
|
fontCache.set(key, h ? h : 0);
|
|
17006
17512
|
return h ? h : null;
|
|
17007
17513
|
}
|
|
17008
17514
|
function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
17009
|
-
const stage =
|
|
17515
|
+
const { dwDrawStage: stage } = NMCUSTOMDRAW.decode(lParam);
|
|
17010
17516
|
if (stage === 1)
|
|
17011
17517
|
return 32;
|
|
17012
17518
|
if (stage === 65537)
|
|
17013
17519
|
return 32;
|
|
17014
17520
|
if (stage === 196609) {
|
|
17015
|
-
const
|
|
17016
|
-
const
|
|
17017
|
-
const style = resolveCellStyle(columns, data, row, colIndex);
|
|
17521
|
+
const cd = NMLVCUSTOMDRAW.decode(lParam);
|
|
17522
|
+
const style = resolveCellStyle(columns, data, cd.dwItemSpec, cd.iSubItem);
|
|
17018
17523
|
if (!style)
|
|
17019
17524
|
return 0;
|
|
17020
17525
|
if (style.color !== void 0)
|
|
@@ -17022,12 +17527,9 @@ function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
|
17022
17527
|
if (style.background !== void 0)
|
|
17023
17528
|
writeU32(lParam, CD_CLRTEXTBK, style.background);
|
|
17024
17529
|
const hfont = getCellFont(hwnd, style);
|
|
17025
|
-
if (hfont &&
|
|
17026
|
-
|
|
17027
|
-
|
|
17028
|
-
ffi7.ffiCall(selectObjectFn, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_POINTER], [hdc, hfont], ffi7.FFI_TYPE_POINTER);
|
|
17029
|
-
return 2;
|
|
17030
|
-
}
|
|
17530
|
+
if (hfont && cd.hdc) {
|
|
17531
|
+
SelectObject(cd.hdc, hfont);
|
|
17532
|
+
return 2;
|
|
17031
17533
|
}
|
|
17032
17534
|
}
|
|
17033
17535
|
return 0;
|
|
@@ -17058,14 +17560,14 @@ function resolveCellStyle(columns, data, row, colIndex) {
|
|
|
17058
17560
|
return style || void 0;
|
|
17059
17561
|
}
|
|
17060
17562
|
function makeLVItem(i, sub, text, image) {
|
|
17061
|
-
const textBuf =
|
|
17062
|
-
const
|
|
17563
|
+
const textBuf = WCHAR.encode(text);
|
|
17564
|
+
const b6 = LVITEMW.encode({
|
|
17063
17565
|
mask: 1 | (image !== void 0 ? 2 : 0),
|
|
17064
17566
|
iItem: i,
|
|
17065
17567
|
iSubItem: sub,
|
|
17066
17568
|
state: 0,
|
|
17067
17569
|
stateMask: 0,
|
|
17068
|
-
pszText:
|
|
17570
|
+
pszText: textBuf.ptr,
|
|
17069
17571
|
cchTextMax: 0,
|
|
17070
17572
|
iImage: image ?? 0,
|
|
17071
17573
|
lParam: 0,
|
|
@@ -17076,8 +17578,8 @@ function makeLVItem(i, sub, text, image) {
|
|
|
17076
17578
|
piColFmt: 0,
|
|
17077
17579
|
iGroup: 0
|
|
17078
17580
|
});
|
|
17079
|
-
|
|
17080
|
-
return
|
|
17581
|
+
b6.__textBuf = textBuf;
|
|
17582
|
+
return b6;
|
|
17081
17583
|
}
|
|
17082
17584
|
var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, data, style, icons, iconSize, getIcon }, ref) {
|
|
17083
17585
|
const lvRef = (0, import_react9.useRef)(null);
|
|
@@ -17089,36 +17591,36 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17089
17591
|
const il = iconListRef.current;
|
|
17090
17592
|
iconListRef.current = 0;
|
|
17091
17593
|
if (il) {
|
|
17092
|
-
|
|
17093
|
-
|
|
17594
|
+
gui9.SendMessage(h, 4099, 1, 0);
|
|
17595
|
+
gui9.ImageListDestroy(il);
|
|
17094
17596
|
}
|
|
17095
17597
|
if (!icons || icons.length === 0)
|
|
17096
17598
|
return;
|
|
17097
17599
|
const size = iconSize ?? 32;
|
|
17098
|
-
const img =
|
|
17600
|
+
const img = gui9.ImageListCreate(size, size, 32, icons.length, 1);
|
|
17099
17601
|
if (!img)
|
|
17100
17602
|
return;
|
|
17101
17603
|
for (const p of icons) {
|
|
17102
|
-
const hbm =
|
|
17604
|
+
const hbm = gui9.CreateBitmapFromPixels(size, size, p);
|
|
17103
17605
|
if (hbm) {
|
|
17104
|
-
|
|
17105
|
-
|
|
17606
|
+
gui9.ImageListAdd(img, hbm);
|
|
17607
|
+
DeleteObject(hbm);
|
|
17106
17608
|
}
|
|
17107
17609
|
}
|
|
17108
|
-
|
|
17610
|
+
gui9.SendMessage(h, 4099, 1, img);
|
|
17109
17611
|
iconListRef.current = img;
|
|
17110
17612
|
}, [icons, iconSize]);
|
|
17111
17613
|
(0, import_react9.useEffect)(() => {
|
|
17112
17614
|
const h = lvRef.current;
|
|
17113
17615
|
if (!h)
|
|
17114
17616
|
return;
|
|
17115
|
-
const hdr =
|
|
17617
|
+
const hdr = gui9.SendMessage(h, 4127, 0, 0);
|
|
17116
17618
|
if (hdr) {
|
|
17117
|
-
let n2 =
|
|
17619
|
+
let n2 = gui9.SendMessage(hdr, 4608, 0, 0);
|
|
17118
17620
|
for (let k = n2 - 1; k >= 0; k--)
|
|
17119
|
-
|
|
17621
|
+
gui9.SendMessage(h, 4124, k, 0);
|
|
17120
17622
|
}
|
|
17121
|
-
|
|
17623
|
+
gui9.SendMessage(
|
|
17122
17624
|
h,
|
|
17123
17625
|
4150,
|
|
17124
17626
|
0,
|
|
@@ -17127,12 +17629,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17127
17629
|
);
|
|
17128
17630
|
const n = columns.length;
|
|
17129
17631
|
for (let j = 0; j < n; j++) {
|
|
17130
|
-
const titleBuf =
|
|
17131
|
-
const lvc = LVCOLUMNW.
|
|
17632
|
+
const titleBuf = WCHAR.encode(columns[j].name);
|
|
17633
|
+
const lvc = LVCOLUMNW.encode({
|
|
17132
17634
|
mask: 4 | 2 | 1,
|
|
17133
17635
|
fmt: alignToFmt(columns[j].align),
|
|
17134
17636
|
cx: columns[j].width ?? 100,
|
|
17135
|
-
pszText:
|
|
17637
|
+
pszText: titleBuf.ptr,
|
|
17136
17638
|
cchTextMax: 0,
|
|
17137
17639
|
iSubItem: j,
|
|
17138
17640
|
iImage: 0,
|
|
@@ -17142,28 +17644,28 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17142
17644
|
cxIdeal: 0
|
|
17143
17645
|
});
|
|
17144
17646
|
lvc.__titleBuf = titleBuf;
|
|
17145
|
-
|
|
17647
|
+
gui9.SendMessage(h, 4193, j, lvc.ptr);
|
|
17146
17648
|
}
|
|
17147
17649
|
}, [columns]);
|
|
17148
17650
|
(0, import_react9.useEffect)(() => {
|
|
17149
17651
|
const h = lvRef.current;
|
|
17150
17652
|
if (!h)
|
|
17151
17653
|
return;
|
|
17152
|
-
|
|
17654
|
+
gui9.SendMessage(h, 4105, 0, 0);
|
|
17153
17655
|
const nCols = columns.length;
|
|
17154
17656
|
for (let i = 0; i < data.length; i++) {
|
|
17155
17657
|
const record = data[i];
|
|
17156
17658
|
const img = getIcon ? getIcon(record, i) : void 0;
|
|
17157
17659
|
const itemBuf = makeLVItem(i, 0, cellText(record, columns[0], i), img);
|
|
17158
|
-
|
|
17660
|
+
gui9.SendMessage(h, 4173, 0, itemBuf.ptr);
|
|
17159
17661
|
for (let j = 1; j < nCols; j++) {
|
|
17160
17662
|
const subBuf = makeLVItem(i, j, cellText(record, columns[j], i));
|
|
17161
|
-
|
|
17663
|
+
gui9.SendMessage(h, 4172, 0, subBuf.ptr);
|
|
17162
17664
|
}
|
|
17163
17665
|
}
|
|
17164
17666
|
for (let j = 0; j < columns.length; j++) {
|
|
17165
17667
|
if (columns[j].width == null) {
|
|
17166
|
-
|
|
17668
|
+
gui9.SendMessage(
|
|
17167
17669
|
h,
|
|
17168
17670
|
4126,
|
|
17169
17671
|
j,
|
|
@@ -17180,14 +17682,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17180
17682
|
return handleCustomDraw(e.lParam, columns, data, lvRef.current);
|
|
17181
17683
|
}
|
|
17182
17684
|
if (code === -100) {
|
|
17183
|
-
const uNewState =
|
|
17184
|
-
const uOldState = readU32(e.lParam, NMLV_UOLD);
|
|
17685
|
+
const { uNewState, uOldState } = NMLISTVIEW.decode(e.lParam);
|
|
17185
17686
|
if ((uNewState & 2) !== (uOldState & 2))
|
|
17186
17687
|
return 1;
|
|
17187
17688
|
}
|
|
17188
17689
|
if (code === -2) {
|
|
17189
|
-
const iItem =
|
|
17190
|
-
const iSubItem = readI32(e.lParam, NMIA_SUBITEM);
|
|
17690
|
+
const { iItem, iSubItem } = NMLISTVIEW.decode(e.lParam);
|
|
17191
17691
|
const col = columns[iSubItem];
|
|
17192
17692
|
const record = data[iItem];
|
|
17193
17693
|
if (col?.onCellClick && record !== void 0)
|
|
@@ -17205,33 +17705,20 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17205
17705
|
const h = lvRef.current;
|
|
17206
17706
|
if (!h)
|
|
17207
17707
|
return;
|
|
17208
|
-
|
|
17209
|
-
if (!
|
|
17210
|
-
return;
|
|
17211
|
-
const sp = gui10.GetCursorPos();
|
|
17212
|
-
if (!sp)
|
|
17708
|
+
const pt = POINT.alloc();
|
|
17709
|
+
if (!GetCursorPos(pt.ptr))
|
|
17213
17710
|
return;
|
|
17214
|
-
|
|
17215
|
-
const
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
const lvhi = new ArrayBuffer(24);
|
|
17220
|
-
const lvd = new DataView(lvhi);
|
|
17221
|
-
lvd.setInt32(0, sdv.getInt32(0, true), true);
|
|
17222
|
-
lvd.setInt32(4, sdv.getInt32(4, true), true);
|
|
17223
|
-
lvd.setInt32(12, -1, true);
|
|
17224
|
-
lvd.setInt32(16, -1, true);
|
|
17225
|
-
const lvhiPtr = bufPtr2(lvhi);
|
|
17226
|
-
gui10.SendMessage(h, 4153, 0, lvhiPtr);
|
|
17227
|
-
const iItem = readI32(lvhiPtr, 12);
|
|
17228
|
-
const iSubItem = readI32(lvhiPtr, 16);
|
|
17711
|
+
ScreenToClient(h, pt.ptr);
|
|
17712
|
+
const { x: sx, y: sy } = POINT.decode(pt);
|
|
17713
|
+
const hit = LVHITTESTINFO.encode({ pt: [sx, sy], iItem: -1, iSubItem: -1 });
|
|
17714
|
+
gui9.SendMessage(h, 4153, 0, hit.ptr);
|
|
17715
|
+
const { iItem, iSubItem } = LVHITTESTINFO.decode(hit);
|
|
17229
17716
|
const style2 = resolveCellStyle(columns, data, iItem, iSubItem);
|
|
17230
17717
|
if (!style2 || style2.cursor === void 0)
|
|
17231
17718
|
return;
|
|
17232
|
-
const hc =
|
|
17719
|
+
const hc = LoadCursor(NULL, style2.cursor);
|
|
17233
17720
|
if (hc) {
|
|
17234
|
-
|
|
17721
|
+
SetCursor(hc);
|
|
17235
17722
|
return 1;
|
|
17236
17723
|
}
|
|
17237
17724
|
return;
|
|
@@ -17241,7 +17728,7 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17241
17728
|
// _build/lib/react-qw/components/ProgressBar.js
|
|
17242
17729
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
17243
17730
|
var import_react10 = __toESM(require_react(), 1);
|
|
17244
|
-
import * as
|
|
17731
|
+
import * as gui10 from "gui";
|
|
17245
17732
|
var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style, smooth }, ref) => {
|
|
17246
17733
|
const pbRef = (0, import_react10.useRef)(null);
|
|
17247
17734
|
const ws = 268435456 | 8388608 | (smooth ? 1 : 0);
|
|
@@ -17249,8 +17736,8 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17249
17736
|
const h = pbRef.current;
|
|
17250
17737
|
if (!h)
|
|
17251
17738
|
return;
|
|
17252
|
-
|
|
17253
|
-
|
|
17739
|
+
gui10.SendMessage(h, 1030, 0, max);
|
|
17740
|
+
gui10.SendMessage(h, 1026, Math.min(value, max), 0);
|
|
17254
17741
|
}, [value, max]);
|
|
17255
17742
|
return (0, import_jsx_runtime9.jsx)("w", { type: "msctls_progress32", ws, style, ref: (h) => {
|
|
17256
17743
|
pbRef.current = h;
|
|
@@ -17264,7 +17751,7 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17264
17751
|
// _build/lib/react-qw/components/RadioButton.js
|
|
17265
17752
|
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
17266
17753
|
var import_react11 = __toESM(require_react(), 1);
|
|
17267
|
-
import * as
|
|
17754
|
+
import * as gui11 from "gui";
|
|
17268
17755
|
var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked, defaultChecked = false, onChange, label, style, disabled }, ref) => {
|
|
17269
17756
|
const [internalChecked, setInternalChecked] = (0, import_react11.useState)(defaultChecked);
|
|
17270
17757
|
const isControlled = controlledChecked !== void 0;
|
|
@@ -17274,7 +17761,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17274
17761
|
const h = rbRef.current;
|
|
17275
17762
|
if (!h)
|
|
17276
17763
|
return;
|
|
17277
|
-
|
|
17764
|
+
gui11.SendMessage(h, 241, displayChecked ? 1 : 0, 0);
|
|
17278
17765
|
}, [displayChecked]);
|
|
17279
17766
|
return (0, import_jsx_runtime10.jsx)("w", { type: "BUTTON", text: label ?? "", ws: 268435456 | 9, style, disabled, ref: (h) => {
|
|
17280
17767
|
rbRef.current = h;
|
|
@@ -17284,7 +17771,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17284
17771
|
ref.current = h;
|
|
17285
17772
|
}, onEvent: (e) => {
|
|
17286
17773
|
if (e.msg === 514) {
|
|
17287
|
-
const newChecked =
|
|
17774
|
+
const newChecked = gui11.SendMessage(e.hwnd, 240, 0, 0) !== 0;
|
|
17288
17775
|
if (newChecked !== displayChecked) {
|
|
17289
17776
|
if (!isControlled)
|
|
17290
17777
|
setInternalChecked(newChecked);
|
|
@@ -17297,24 +17784,27 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17297
17784
|
// _build/lib/react-qw/components/ScrollView.js
|
|
17298
17785
|
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
17299
17786
|
var import_react12 = __toESM(require_react(), 1);
|
|
17300
|
-
import * as
|
|
17787
|
+
import * as gui12 from "gui";
|
|
17301
17788
|
var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth, contentHeight }, ref) => {
|
|
17302
17789
|
const svRef = (0, import_react12.useRef)(null);
|
|
17303
17790
|
const contentRef = (0, import_react12.useRef)(null);
|
|
17304
17791
|
const scrollXRef = (0, import_react12.useRef)(0);
|
|
17305
17792
|
const scrollYRef = (0, import_react12.useRef)(0);
|
|
17306
17793
|
function updateScroll(sv, content) {
|
|
17307
|
-
const svRect =
|
|
17794
|
+
const svRect = gui12.GetClientRect(sv);
|
|
17308
17795
|
if (!svRect)
|
|
17309
17796
|
return;
|
|
17310
17797
|
const svW = svRect.right - svRect.left;
|
|
17311
17798
|
const svH = svRect.bottom - svRect.top;
|
|
17312
|
-
const
|
|
17799
|
+
const hdc = GetDC(NULL);
|
|
17800
|
+
const scale = hdc ? GetDeviceCaps(hdc, 88) / 96 : 1;
|
|
17801
|
+
if (hdc)
|
|
17802
|
+
ReleaseDC(NULL, hdc);
|
|
17313
17803
|
const natW = Math.round((contentWidth ?? svW / scale) * scale);
|
|
17314
17804
|
const natH = Math.round((contentHeight ?? svH / scale) * scale);
|
|
17315
17805
|
scrollXRef.current = Math.max(0, Math.min(scrollXRef.current, natW - svW));
|
|
17316
17806
|
scrollYRef.current = Math.max(0, Math.min(scrollYRef.current, natH - svH));
|
|
17317
|
-
|
|
17807
|
+
SetWindowPos(
|
|
17318
17808
|
content,
|
|
17319
17809
|
0,
|
|
17320
17810
|
-scrollXRef.current,
|
|
@@ -17326,18 +17816,18 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17326
17816
|
);
|
|
17327
17817
|
forceFlexLayout(content);
|
|
17328
17818
|
if (natW > svW) {
|
|
17329
|
-
|
|
17330
|
-
|
|
17819
|
+
gui12.SetScrollInfo(sv, 0, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
|
|
17820
|
+
ShowScrollBar(sv, 0, 1);
|
|
17331
17821
|
} else {
|
|
17332
17822
|
scrollXRef.current = 0;
|
|
17333
|
-
|
|
17823
|
+
ShowScrollBar(sv, 0, 0);
|
|
17334
17824
|
}
|
|
17335
17825
|
if (natH > svH) {
|
|
17336
|
-
|
|
17337
|
-
|
|
17826
|
+
gui12.SetScrollInfo(sv, 1, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
|
|
17827
|
+
ShowScrollBar(sv, 1, 1);
|
|
17338
17828
|
} else {
|
|
17339
17829
|
scrollYRef.current = 0;
|
|
17340
|
-
|
|
17830
|
+
ShowScrollBar(sv, 1, 0);
|
|
17341
17831
|
}
|
|
17342
17832
|
}
|
|
17343
17833
|
(0, import_react12.useLayoutEffect)(() => {
|
|
@@ -17353,7 +17843,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17353
17843
|
} else {
|
|
17354
17844
|
scrollXRef.current = newPos;
|
|
17355
17845
|
}
|
|
17356
|
-
|
|
17846
|
+
SetWindowPos(
|
|
17357
17847
|
content,
|
|
17358
17848
|
0,
|
|
17359
17849
|
-scrollXRef.current,
|
|
@@ -17363,14 +17853,14 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17363
17853
|
1 | 4
|
|
17364
17854
|
/* gui.SetWindowPosFlag.SWP_NOZORDER */
|
|
17365
17855
|
);
|
|
17366
|
-
|
|
17856
|
+
gui12.SetScrollInfo(sv, bar, { pos: newPos }, true);
|
|
17367
17857
|
}
|
|
17368
17858
|
function handleScroll(e, bar) {
|
|
17369
17859
|
const sv = svRef.current;
|
|
17370
17860
|
const content = contentRef.current;
|
|
17371
17861
|
if (!sv || !content)
|
|
17372
17862
|
return;
|
|
17373
|
-
const info =
|
|
17863
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17374
17864
|
const maxPos = info.max - info.page + 1;
|
|
17375
17865
|
const code = e.wParam & 65535;
|
|
17376
17866
|
const ref_ = bar === 1 ? scrollYRef : scrollXRef;
|
|
@@ -17404,7 +17894,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17404
17894
|
if (!isHorz && contentHeight === void 0)
|
|
17405
17895
|
return;
|
|
17406
17896
|
const bar = isHorz ? 0 : 1;
|
|
17407
|
-
const info =
|
|
17897
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17408
17898
|
const maxPos = info.max - info.page + 1;
|
|
17409
17899
|
const ref_ = isHorz ? scrollXRef : scrollYRef;
|
|
17410
17900
|
let newPos = ref_.current + dy;
|
|
@@ -17421,7 +17911,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17421
17911
|
}, onEvent: {
|
|
17422
17912
|
fn: (e) => {
|
|
17423
17913
|
if (e.msg === 132 || e.msg === 161) {
|
|
17424
|
-
return
|
|
17914
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17425
17915
|
}
|
|
17426
17916
|
if (e.msg === 277) {
|
|
17427
17917
|
handleScroll(
|
|
@@ -17453,7 +17943,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17453
17943
|
// _build/lib/react-qw/components/Slider.js
|
|
17454
17944
|
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
|
|
17455
17945
|
var import_react13 = __toESM(require_react(), 1);
|
|
17456
|
-
import * as
|
|
17946
|
+
import * as gui13 from "gui";
|
|
17457
17947
|
var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 100, vertical = false, disabled, style }, ref) => {
|
|
17458
17948
|
const wrapperRef = (0, import_react13.useRef)(null);
|
|
17459
17949
|
const sliderRef = (0, import_react13.useRef)(null);
|
|
@@ -17462,14 +17952,14 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17462
17952
|
if (!h)
|
|
17463
17953
|
return;
|
|
17464
17954
|
const lParam = min & 65535 | (max & 65535) << 16;
|
|
17465
|
-
|
|
17466
|
-
|
|
17955
|
+
gui13.SendMessage(h, 1030, 0, lParam);
|
|
17956
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17467
17957
|
}, [min, max]);
|
|
17468
17958
|
(0, import_react13.useEffect)(() => {
|
|
17469
17959
|
const h = sliderRef.current;
|
|
17470
17960
|
if (!h)
|
|
17471
17961
|
return;
|
|
17472
|
-
|
|
17962
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17473
17963
|
}, [value]);
|
|
17474
17964
|
const tbStyle = 268435456 | 65536 | 1 | (vertical ? 2 : 0);
|
|
17475
17965
|
return (0, import_jsx_runtime12.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style, ref: (h) => {
|
|
@@ -17480,13 +17970,13 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17480
17970
|
ref.current = h;
|
|
17481
17971
|
}, onEvent: (e) => {
|
|
17482
17972
|
if (e.msg === 132 || e.msg === 161) {
|
|
17483
|
-
return
|
|
17973
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17484
17974
|
}
|
|
17485
17975
|
if (e.msg === 276 || e.msg === 277) {
|
|
17486
17976
|
const h = sliderRef.current;
|
|
17487
17977
|
if (!h)
|
|
17488
17978
|
return 0;
|
|
17489
|
-
const pos =
|
|
17979
|
+
const pos = gui13.SendMessage(h, 1024, 0, 0);
|
|
17490
17980
|
onChange?.(pos);
|
|
17491
17981
|
return 0;
|
|
17492
17982
|
}
|
|
@@ -17499,24 +17989,7 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17499
17989
|
// _build/lib/react-qw/components/Tab.js
|
|
17500
17990
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
17501
17991
|
var import_react14 = __toESM(require_react(), 1);
|
|
17502
|
-
import * as
|
|
17503
|
-
import * as ffi8 from "ffi";
|
|
17504
|
-
var TCITEMW = struct({
|
|
17505
|
-
mask: "u32",
|
|
17506
|
-
dwState: "u32",
|
|
17507
|
-
dwStateMask: "u32",
|
|
17508
|
-
pszText: "ptr",
|
|
17509
|
-
cchTextMax: "i32",
|
|
17510
|
-
iImage: "i32",
|
|
17511
|
-
lParam: "ptr"
|
|
17512
|
-
});
|
|
17513
|
-
function textToUtf163(s) {
|
|
17514
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
17515
|
-
const dv = new DataView(buf);
|
|
17516
|
-
for (let i = 0; i < s.length; i++)
|
|
17517
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
17518
|
-
return buf;
|
|
17519
|
-
}
|
|
17992
|
+
import * as gui14 from "gui";
|
|
17520
17993
|
var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex, defaultSelectedIndex = 0, onChange, style }, ref) => {
|
|
17521
17994
|
const [internalIndex, setInternalIndex] = (0, import_react14.useState)(defaultSelectedIndex);
|
|
17522
17995
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -17526,27 +17999,27 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17526
17999
|
const h = tabHwnd.current;
|
|
17527
18000
|
if (!h)
|
|
17528
18001
|
return;
|
|
17529
|
-
|
|
18002
|
+
gui14.SendMessage(h, 4873, 0, 0);
|
|
17530
18003
|
for (let i = 0; i < tabs.length; i++) {
|
|
17531
|
-
const titleBuf =
|
|
17532
|
-
const tci = TCITEMW.
|
|
18004
|
+
const titleBuf = WCHAR.encode(tabs[i].title);
|
|
18005
|
+
const tci = TCITEMW.encode({
|
|
17533
18006
|
mask: 1,
|
|
17534
18007
|
dwState: 0,
|
|
17535
18008
|
dwStateMask: 0,
|
|
17536
|
-
pszText:
|
|
18009
|
+
pszText: titleBuf.ptr,
|
|
17537
18010
|
cchTextMax: tabs[i].title.length + 1,
|
|
17538
18011
|
iImage: 0,
|
|
17539
18012
|
lParam: 0
|
|
17540
18013
|
});
|
|
17541
|
-
const tciPtr =
|
|
17542
|
-
|
|
18014
|
+
const tciPtr = tci.ptr;
|
|
18015
|
+
gui14.SendMessage(h, 4926, i, tciPtr);
|
|
17543
18016
|
}
|
|
17544
|
-
|
|
18017
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17545
18018
|
}, [tabs]);
|
|
17546
18019
|
(0, import_react14.useEffect)(() => {
|
|
17547
18020
|
const h = tabHwnd.current;
|
|
17548
18021
|
if (h)
|
|
17549
|
-
|
|
18022
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17550
18023
|
}, [sel]);
|
|
17551
18024
|
return (0, import_jsx_runtime13.jsxs)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17552
18025
|
if (e.msg === 78) {
|
|
@@ -17555,7 +18028,7 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17555
18028
|
return;
|
|
17556
18029
|
const code = nmCode(e.lParam);
|
|
17557
18030
|
if (code === -552 || code === -2) {
|
|
17558
|
-
const newSel =
|
|
18031
|
+
const newSel = gui14.SendMessage(h, 4875, 0, 0);
|
|
17559
18032
|
if (newSel !== sel) {
|
|
17560
18033
|
if (!isControlled)
|
|
17561
18034
|
setInternalIndex(newSel);
|
|
@@ -17568,54 +18041,17 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17568
18041
|
|
|
17569
18042
|
// _build/lib/react-qw/components/Tooltip.js
|
|
17570
18043
|
var import_react15 = __toESM(require_react(), 1);
|
|
17571
|
-
import * as
|
|
17572
|
-
import * as ffi9 from "ffi";
|
|
17573
|
-
var TTTOOLINFOW = struct({
|
|
17574
|
-
cbSize: "u32",
|
|
17575
|
-
uFlags: "u32",
|
|
17576
|
-
hwnd: "ptr",
|
|
17577
|
-
uId: "ptr",
|
|
17578
|
-
rect: "i32[4]",
|
|
17579
|
-
hinst: "ptr",
|
|
17580
|
-
lpszText: "ptr",
|
|
17581
|
-
lParam: "ptr",
|
|
17582
|
-
lpReserved: "ptr"
|
|
17583
|
-
// WinXP+ 追加字段(系统 sizeof 含之)
|
|
17584
|
-
});
|
|
18044
|
+
import * as gui15 from "gui";
|
|
17585
18045
|
|
|
17586
18046
|
// _build/lib/react-qw/components/TreeView.js
|
|
17587
18047
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
17588
18048
|
var import_react16 = __toESM(require_react(), 1);
|
|
17589
|
-
import * as
|
|
17590
|
-
import * as ffi10 from "ffi";
|
|
17591
|
-
var TVITEM = struct({
|
|
17592
|
-
mask: "u32",
|
|
17593
|
-
hItem: "ptr",
|
|
17594
|
-
state: "u32",
|
|
17595
|
-
stateMask: "u32",
|
|
17596
|
-
pszText: "ptr",
|
|
17597
|
-
cchTextMax: "i32",
|
|
17598
|
-
iImage: "i32",
|
|
17599
|
-
iSelectedImage: "i32",
|
|
17600
|
-
cChildren: "i32",
|
|
17601
|
-
lParam: "ptr"
|
|
17602
|
-
});
|
|
17603
|
-
var TVINSERTSTRUCT = struct({ hParent: "ptr", hInsertAfter: "ptr", item: TVITEM });
|
|
17604
|
-
function textToUtf164(s) {
|
|
17605
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
17606
|
-
const dv = new DataView(buf);
|
|
17607
|
-
for (let i = 0; i < s.length; i++)
|
|
17608
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
17609
|
-
return buf;
|
|
17610
|
-
}
|
|
17611
|
-
function bufPtr3(buf) {
|
|
17612
|
-
return ffi10.bufferPtr(buf);
|
|
17613
|
-
}
|
|
18049
|
+
import * as gui16 from "gui";
|
|
17614
18050
|
function buildTvItem(textPtr, cChildren) {
|
|
17615
18051
|
let mask = 1;
|
|
17616
18052
|
if (cChildren > 0)
|
|
17617
18053
|
mask |= 64;
|
|
17618
|
-
return TVITEM.
|
|
18054
|
+
return TVITEM.encode({
|
|
17619
18055
|
mask,
|
|
17620
18056
|
hItem: 0,
|
|
17621
18057
|
state: 0,
|
|
@@ -17631,24 +18067,24 @@ function buildTvItem(textPtr, cChildren) {
|
|
|
17631
18067
|
function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
|
|
17632
18068
|
for (const node of nodes) {
|
|
17633
18069
|
const cChildren = node.children && node.children.length > 0 ? 1 : 0;
|
|
17634
|
-
const textBuf =
|
|
17635
|
-
const itemBuf = buildTvItem(
|
|
17636
|
-
const item = TVITEM.
|
|
17637
|
-
const tvins = TVINSERTSTRUCT.
|
|
17638
|
-
const hItem =
|
|
18070
|
+
const textBuf = WCHAR.encode(node.label);
|
|
18071
|
+
const itemBuf = buildTvItem(textBuf.ptr, cChildren);
|
|
18072
|
+
const item = TVITEM.decode(itemBuf);
|
|
18073
|
+
const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536, item });
|
|
18074
|
+
const hItem = gui16.SendMessage(hTree, 4402, 0, tvins.ptr);
|
|
17639
18075
|
hItemMap.set(hItem, node);
|
|
17640
18076
|
if (node.key)
|
|
17641
18077
|
keyMap.set(node.key, hItem);
|
|
17642
18078
|
if (node.children && node.children.length > 0) {
|
|
17643
18079
|
insertItems(hTree, node.children, hItem, hItemMap, keyMap);
|
|
17644
|
-
|
|
18080
|
+
gui16.SendMessage(hTree, 4354, 2, hItem);
|
|
17645
18081
|
}
|
|
17646
18082
|
}
|
|
17647
18083
|
}
|
|
17648
18084
|
function deleteAllItems(hTree) {
|
|
17649
|
-
const n =
|
|
18085
|
+
const n = gui16.SendMessage(hTree, 4357, 0, 0);
|
|
17650
18086
|
if (n > 0)
|
|
17651
|
-
|
|
18087
|
+
gui16.SendMessage(
|
|
17652
18088
|
hTree,
|
|
17653
18089
|
4353,
|
|
17654
18090
|
1,
|
|
@@ -17680,7 +18116,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17680
18116
|
const h = tvRef.current;
|
|
17681
18117
|
if (!h)
|
|
17682
18118
|
return;
|
|
17683
|
-
|
|
18119
|
+
gui16.SendMessage(
|
|
17684
18120
|
h,
|
|
17685
18121
|
4396,
|
|
17686
18122
|
0,
|
|
@@ -17696,7 +18132,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17696
18132
|
return;
|
|
17697
18133
|
const hItem = keyMapRef.current.get(selKey);
|
|
17698
18134
|
if (hItem !== void 0)
|
|
17699
|
-
|
|
18135
|
+
gui16.SendMessage(h, 4363, 9, hItem);
|
|
17700
18136
|
}, [selKey]);
|
|
17701
18137
|
return (0, import_jsx_runtime14.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17702
18138
|
if (e.msg === 78) {
|
|
@@ -17705,7 +18141,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17705
18141
|
const h = tvRef.current;
|
|
17706
18142
|
if (!h)
|
|
17707
18143
|
return;
|
|
17708
|
-
const hCaret =
|
|
18144
|
+
const hCaret = gui16.SendMessage(h, 4362, 9, 0);
|
|
17709
18145
|
const node = hItemMapRef.current.get(hCaret) ?? null;
|
|
17710
18146
|
const key = node?.key ?? null;
|
|
17711
18147
|
if (!isControlled)
|
|
@@ -17721,153 +18157,63 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17721
18157
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17722
18158
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
17723
18159
|
var import_react17 = __toESM(require_react(), 1);
|
|
17724
|
-
import * as ffi11 from "ffi";
|
|
17725
|
-
import * as win3 from "win";
|
|
17726
18160
|
|
|
17727
|
-
// _build/lib/
|
|
17728
|
-
var
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
nMaxFileTitle: "u32",
|
|
17740
|
-
lpstrInitialDir: "ptr",
|
|
17741
|
-
lpstrTitle: "ptr",
|
|
17742
|
-
Flags: "u32",
|
|
17743
|
-
nFileOffset: "u16",
|
|
17744
|
-
nFileExtension: "u16",
|
|
17745
|
-
lpstrDefExt: "ptr",
|
|
17746
|
-
lCustData: "ptr",
|
|
17747
|
-
lpfnHook: "ptr",
|
|
17748
|
-
lpTemplateName: "ptr",
|
|
17749
|
-
pvReserved: "ptr",
|
|
17750
|
-
dwReserved: "u32",
|
|
17751
|
-
FlagsEx: "u32"
|
|
17752
|
-
});
|
|
17753
|
-
var BROWSEINFOW = struct({
|
|
17754
|
-
hwndOwner: "ptr",
|
|
17755
|
-
pidlRoot: "ptr",
|
|
17756
|
-
pszDisplayName: "ptr",
|
|
17757
|
-
lpszTitle: "ptr",
|
|
17758
|
-
ulFlags: "u32",
|
|
17759
|
-
lpfn: "ptr",
|
|
17760
|
-
lParam: "ptr",
|
|
17761
|
-
iImage: "i32"
|
|
17762
|
-
});
|
|
18161
|
+
// _build/lib/windows/comdlg32.js
|
|
18162
|
+
var b3 = (name, sig) => bind("comdlg32.dll", name, sig);
|
|
18163
|
+
var GetOpenFileName = /* @__PURE__ */ b3("GetOpenFileNameW", "<OPENFILENAMEW>ptr -> u32");
|
|
18164
|
+
|
|
18165
|
+
// _build/lib/windows/shell32.js
|
|
18166
|
+
var b4 = (name, sig) => bind("shell32.dll", name, sig);
|
|
18167
|
+
var SHBrowseForFolder = /* @__PURE__ */ b4("SHBrowseForFolderW", "<BROWSEINFOW>ptr -> <>ptr");
|
|
18168
|
+
var SHGetPathFromIDList = /* @__PURE__ */ b4("SHGetPathFromIDListW", "<>ptr <BYTE>ptr -> u32");
|
|
18169
|
+
|
|
18170
|
+
// _build/lib/windows/ole32.js
|
|
18171
|
+
var b5 = (name, sig) => bind("ole32.dll", name, sig);
|
|
18172
|
+
var CoTaskMemFree = /* @__PURE__ */ b5("CoTaskMemFree", "<>ptr -> void");
|
|
17763
18173
|
|
|
17764
18174
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17765
|
-
var FFI_PTR = ffi11.FFI_TYPE_POINTER;
|
|
17766
|
-
var FFI_U32 = ffi11.FFI_TYPE_UINT32;
|
|
17767
|
-
var _GetOpenFileNameW = 0;
|
|
17768
|
-
var _SHBrowseForFolderW = 0;
|
|
17769
|
-
var _SHGetPathFromIDListW = 0;
|
|
17770
|
-
var _CoTaskMemFree = 0;
|
|
17771
|
-
function ensureDlls() {
|
|
17772
|
-
if (_GetOpenFileNameW)
|
|
17773
|
-
return true;
|
|
17774
|
-
const comdlg32 = win3.LoadLibrary("comdlg32.dll");
|
|
17775
|
-
const shell32 = win3.LoadLibrary("shell32.dll");
|
|
17776
|
-
const ole32 = win3.LoadLibrary("ole32.dll");
|
|
17777
|
-
if (!comdlg32 || !shell32 || !ole32)
|
|
17778
|
-
return false;
|
|
17779
|
-
const load = (lib, name) => win3.GetProcAddress(lib, name) || 0;
|
|
17780
|
-
_GetOpenFileNameW = load(comdlg32, "GetOpenFileNameW");
|
|
17781
|
-
_SHBrowseForFolderW = load(shell32, "SHBrowseForFolderW");
|
|
17782
|
-
_SHGetPathFromIDListW = load(shell32, "SHGetPathFromIDListW");
|
|
17783
|
-
_CoTaskMemFree = load(ole32, "CoTaskMemFree");
|
|
17784
|
-
return !!_GetOpenFileNameW && !!_SHBrowseForFolderW && !!_SHGetPathFromIDListW && !!_CoTaskMemFree;
|
|
17785
|
-
}
|
|
17786
|
-
function strToWide(s) {
|
|
17787
|
-
return new TextEncoder("utf-16le").encode(s + "\0").buffer;
|
|
17788
|
-
}
|
|
17789
|
-
var _decoder = new TextDecoder("utf-16le");
|
|
17790
|
-
function wideToStr(buf, offset = 0) {
|
|
17791
|
-
const str = _decoder.decode(new Uint8Array(buf, offset));
|
|
17792
|
-
const nullIdx = str.indexOf("\0");
|
|
17793
|
-
return nullIdx >= 0 ? str.substring(0, nullIdx) : str;
|
|
17794
|
-
}
|
|
17795
18175
|
function openFileDialog(owner, filter, title, multiple) {
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
const
|
|
17799
|
-
const filterWide = strToWide(filter);
|
|
17800
|
-
const titleWide = title ? strToWide(title) : null;
|
|
18176
|
+
const fileBuf = WCHAR.alloc(260);
|
|
18177
|
+
const filterWide = WCHAR.encode(filter);
|
|
18178
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
17801
18179
|
let flags = 4096 | 2048 | 8;
|
|
17802
18180
|
if (multiple)
|
|
17803
18181
|
flags |= 512;
|
|
17804
18182
|
flags |= 524288;
|
|
17805
|
-
const ofn = OPENFILENAMEW.
|
|
18183
|
+
const ofn = OPENFILENAMEW.encode({
|
|
17806
18184
|
lStructSize: OPENFILENAMEW.size,
|
|
17807
18185
|
hwndOwner: owner,
|
|
17808
|
-
|
|
17809
|
-
|
|
17810
|
-
lpstrCustomFilter: 0,
|
|
17811
|
-
nMaxCustFilter: 0,
|
|
17812
|
-
nFilterIndex: 0,
|
|
17813
|
-
lpstrFile: ffi11.bufferPtr(fileBuf),
|
|
18186
|
+
lpstrFilter: filterWide.ptr,
|
|
18187
|
+
lpstrFile: fileBuf.ptr,
|
|
17814
18188
|
nMaxFile: 260,
|
|
17815
|
-
|
|
17816
|
-
|
|
17817
|
-
lpstrInitialDir: 0,
|
|
17818
|
-
lpstrTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17819
|
-
Flags: flags,
|
|
17820
|
-
nFileOffset: 0,
|
|
17821
|
-
nFileExtension: 0,
|
|
17822
|
-
lpstrDefExt: 0,
|
|
17823
|
-
lCustData: 0,
|
|
17824
|
-
lpfnHook: 0,
|
|
17825
|
-
lpTemplateName: 0,
|
|
17826
|
-
pvReserved: 0,
|
|
17827
|
-
dwReserved: 0,
|
|
17828
|
-
FlagsEx: 0
|
|
18189
|
+
lpstrTitle: titleWide?.ptr ?? 0,
|
|
18190
|
+
Flags: flags
|
|
17829
18191
|
});
|
|
17830
|
-
const ret =
|
|
18192
|
+
const ret = GetOpenFileName(ofn.ptr);
|
|
17831
18193
|
if (!ret)
|
|
17832
18194
|
return null;
|
|
17833
18195
|
if (!multiple) {
|
|
17834
|
-
return
|
|
18196
|
+
return WCHAR.decode(fileBuf);
|
|
17835
18197
|
}
|
|
17836
|
-
const
|
|
17837
|
-
|
|
17838
|
-
const files =
|
|
17839
|
-
|
|
17840
|
-
const f = wideToStr(fileBuf, pos);
|
|
17841
|
-
if (f.length === 0)
|
|
17842
|
-
break;
|
|
17843
|
-
files.push(dir + "\\" + f);
|
|
17844
|
-
pos += (f.length + 1) * 2;
|
|
17845
|
-
}
|
|
17846
|
-
if (files.length === 0)
|
|
17847
|
-
return [dir];
|
|
17848
|
-
return files;
|
|
18198
|
+
const strs = new TextDecoder("utf-16le").decode(new Uint8Array(fileBuf)).split("\0");
|
|
18199
|
+
const dir = strs[0] ?? "";
|
|
18200
|
+
const files = strs.slice(1).filter((f) => f.length > 0).map((f) => dir + "\\" + f);
|
|
18201
|
+
return files.length > 0 ? files : [dir];
|
|
17849
18202
|
}
|
|
17850
18203
|
function openFolderDialog(owner, title) {
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
const titleWide = title ? strToWide(title) : null;
|
|
17854
|
-
const bi = BROWSEINFOW.write({
|
|
18204
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
18205
|
+
const bi = BROWSEINFOW.encode({
|
|
17855
18206
|
hwndOwner: owner,
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
lpszTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17859
|
-
ulFlags: 65,
|
|
17860
|
-
lpfn: 0,
|
|
17861
|
-
lParam: 0,
|
|
17862
|
-
iImage: 0
|
|
18207
|
+
lpszTitle: titleWide?.ptr ?? 0,
|
|
18208
|
+
ulFlags: 65
|
|
17863
18209
|
});
|
|
17864
|
-
const pidl =
|
|
18210
|
+
const pidl = SHBrowseForFolder(bi.ptr);
|
|
17865
18211
|
if (!pidl)
|
|
17866
18212
|
return null;
|
|
17867
|
-
const pathBuf =
|
|
17868
|
-
const ok =
|
|
17869
|
-
|
|
17870
|
-
return ok ?
|
|
18213
|
+
const pathBuf = WCHAR.alloc(260);
|
|
18214
|
+
const ok = SHGetPathFromIDList(pidl, pathBuf);
|
|
18215
|
+
CoTaskMemFree(pidl);
|
|
18216
|
+
return ok ? WCHAR.decode(pathBuf) : null;
|
|
17871
18217
|
}
|
|
17872
18218
|
var PathPicker = (0, import_react17.forwardRef)((props, ref) => {
|
|
17873
18219
|
const { type = "file", filter = "All Files\0*.*\0\0", title, disabled, style } = props;
|
|
@@ -17918,7 +18264,7 @@ var rootMap = /* @__PURE__ */ new Map();
|
|
|
17918
18264
|
function ensureDefaultClass() {
|
|
17919
18265
|
if (defaultClassRegistered)
|
|
17920
18266
|
return DEFAULT_CLASS;
|
|
17921
|
-
|
|
18267
|
+
gui17.RegisterClass(DEFAULT_CLASS, (hwnd, msg, wParam, lParam) => {
|
|
17922
18268
|
const entry = rootMap.get(hwnd);
|
|
17923
18269
|
if (msg === 2 && entry) {
|
|
17924
18270
|
rootMap.delete(hwnd);
|
|
@@ -17931,7 +18277,7 @@ function ensureDefaultClass() {
|
|
|
17931
18277
|
return result;
|
|
17932
18278
|
if (msg === 5)
|
|
17933
18279
|
forceFlexLayout(hwnd);
|
|
17934
|
-
return
|
|
18280
|
+
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
17935
18281
|
});
|
|
17936
18282
|
defaultClassRegistered = true;
|
|
17937
18283
|
return DEFAULT_CLASS;
|
|
@@ -17944,19 +18290,19 @@ function createRoot(container) {
|
|
|
17944
18290
|
const ws = (cfg.ws ?? 0) | 13565952;
|
|
17945
18291
|
const w = (cfg.width ?? 800) * scaleFactor;
|
|
17946
18292
|
const h = (cfg.height ?? 600) * scaleFactor;
|
|
17947
|
-
const [sw, sh] =
|
|
18293
|
+
const [sw, sh] = [GetSystemMetrics(0), GetSystemMetrics(1)];
|
|
17948
18294
|
const x = cfg.x === void 0 ? (sw - w) / 2 | 0 : cfg.x === -2147483648 ? -2147483648 : cfg.x * scaleFactor;
|
|
17949
18295
|
const y = cfg.y === void 0 ? (sh - h) / 2 | 0 : cfg.y === -2147483648 ? -2147483648 : cfg.y * scaleFactor;
|
|
17950
|
-
const hwin =
|
|
18296
|
+
const hwin = gui17.CreateWindow(className, cfg.text || "", ws, x, y, w, h, null, null);
|
|
17951
18297
|
if (!hwin)
|
|
17952
18298
|
throw new Error("CreateWindow failed");
|
|
17953
18299
|
hwnd = hwin;
|
|
17954
18300
|
if (!cfg.noShowWindow)
|
|
17955
|
-
|
|
18301
|
+
gui17.ShowWindow(hwnd);
|
|
17956
18302
|
} else {
|
|
17957
18303
|
hwnd = container;
|
|
17958
18304
|
}
|
|
17959
|
-
const root = reconciler_default.createContainer(hwnd, 0, null, false, null, "",
|
|
18305
|
+
const root = reconciler_default.createContainer(hwnd, 0, null, false, null, "", (error, info) => console.log("[React uncaught]", error, error.stack, info.componentStack), (error, info) => console.log("[React caught]", error, error.stack, info.componentStack), (error, info) => console.log("[React recoverable]", error, error.stack, info.componentStack), noop);
|
|
17960
18306
|
const rootInst = { hwnd, type: "_root", props: { type: "_root", style: { flexDirection: "column", alignItems: "stretch" } }, children: [] };
|
|
17961
18307
|
instancesByHwnd.set(hwnd, rootInst);
|
|
17962
18308
|
if (typeof container === "object")
|
|
@@ -17982,33 +18328,8 @@ function render(element, containerOrConfig, _callback) {
|
|
|
17982
18328
|
// _build/examples/PdfCanvas.js
|
|
17983
18329
|
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
|
|
17984
18330
|
var import_react18 = __toESM(require_react(), 1);
|
|
17985
|
-
import * as win4 from "win";
|
|
17986
|
-
import * as ffi12 from "ffi";
|
|
17987
|
-
var _user32 = win4.LoadLibrary("user32.dll");
|
|
17988
|
-
var _gdi32 = win4.LoadLibrary("gdi32.dll");
|
|
17989
|
-
if (!_user32 || !_gdi32)
|
|
17990
|
-
throw new Error("Failed to load user32/gdi32");
|
|
17991
|
-
function loadProc(lib, name) {
|
|
17992
|
-
const ptr = win4.GetProcAddress(lib, name);
|
|
17993
|
-
if (!ptr)
|
|
17994
|
-
throw new Error("Failed to load " + name);
|
|
17995
|
-
return ptr;
|
|
17996
|
-
}
|
|
17997
|
-
var GetDC_ = loadProc(_user32, "GetDC");
|
|
17998
|
-
var ReleaseDC_ = loadProc(_user32, "ReleaseDC");
|
|
17999
|
-
var SetDIBitsToDevice_ = loadProc(_gdi32, "SetDIBitsToDevice");
|
|
18000
|
-
var FFI_PTR2 = ffi12.FFI_TYPE_POINTER;
|
|
18001
|
-
var FFI_U322 = ffi12.FFI_TYPE_UINT32;
|
|
18002
|
-
var FFI_S32 = ffi12.FFI_TYPE_SINT32;
|
|
18003
18331
|
function makeBitmapInfo(w, h) {
|
|
18004
|
-
|
|
18005
|
-
const bv = new DataView(bmi);
|
|
18006
|
-
bv.setUint32(0, 40, true);
|
|
18007
|
-
bv.setInt32(4, w, true);
|
|
18008
|
-
bv.setInt32(8, -h, true);
|
|
18009
|
-
bv.setUint16(12, 1, true);
|
|
18010
|
-
bv.setUint16(14, 24, true);
|
|
18011
|
-
return bmi;
|
|
18332
|
+
return BITMAPINFOHEADER.encode({ biSize: BITMAPINFOHEADER.size, biWidth: w, biHeight: -h, biPlanes: 1, biBitCount: 24 });
|
|
18012
18333
|
}
|
|
18013
18334
|
var PdfCanvas = (0, import_react18.forwardRef)(({ pixmap, style }, ref) => {
|
|
18014
18335
|
const canvasRef = (0, import_react18.useRef)(null);
|
|
@@ -18028,37 +18349,11 @@ var PdfCanvas = (0, import_react18.forwardRef)(({ pixmap, style }, ref) => {
|
|
|
18028
18349
|
const pm = pixmapRef.current;
|
|
18029
18350
|
if (!pm)
|
|
18030
18351
|
return 0;
|
|
18031
|
-
const hdc =
|
|
18352
|
+
const hdc = GetDC(hwnd);
|
|
18032
18353
|
if (hdc) {
|
|
18033
18354
|
const bmi = makeBitmapInfo(pm.w, pm.h);
|
|
18034
|
-
|
|
18035
|
-
|
|
18036
|
-
FFI_S32,
|
|
18037
|
-
FFI_S32,
|
|
18038
|
-
FFI_U322,
|
|
18039
|
-
FFI_U322,
|
|
18040
|
-
FFI_S32,
|
|
18041
|
-
FFI_S32,
|
|
18042
|
-
FFI_U322,
|
|
18043
|
-
FFI_U322,
|
|
18044
|
-
FFI_PTR2,
|
|
18045
|
-
FFI_PTR2,
|
|
18046
|
-
FFI_U322
|
|
18047
|
-
], [
|
|
18048
|
-
hdc,
|
|
18049
|
-
0,
|
|
18050
|
-
0,
|
|
18051
|
-
pm.w,
|
|
18052
|
-
pm.h,
|
|
18053
|
-
0,
|
|
18054
|
-
0,
|
|
18055
|
-
0,
|
|
18056
|
-
pm.h,
|
|
18057
|
-
pm.data,
|
|
18058
|
-
bmi,
|
|
18059
|
-
0
|
|
18060
|
-
], FFI_S32);
|
|
18061
|
-
ffi12.ffiCall(ReleaseDC_, [ffi12.FFI_TYPE_POINTER, ffi12.FFI_TYPE_POINTER], [hwnd, hdc], FFI_S32);
|
|
18355
|
+
SetDIBitsToDevice(hdc, 0, 0, pm.w, pm.h, 0, 0, 0, pm.h, pm.data, bmi, 0);
|
|
18356
|
+
ReleaseDC(hwnd, hdc);
|
|
18062
18357
|
}
|
|
18063
18358
|
return 0;
|
|
18064
18359
|
}
|
|
@@ -18067,80 +18362,29 @@ var PdfCanvas = (0, import_react18.forwardRef)(({ pixmap, style }, ref) => {
|
|
|
18067
18362
|
});
|
|
18068
18363
|
|
|
18069
18364
|
// _build/examples/pdf_viewer.js
|
|
18070
|
-
var _user322 = win5.LoadLibrary("user32.dll");
|
|
18071
|
-
var _gdi322 = win5.LoadLibrary("gdi32.dll");
|
|
18072
|
-
var _comdlg32 = win5.LoadLibrary("comdlg32.dll");
|
|
18073
|
-
if (!_user322 || !_gdi322 || !_comdlg32) {
|
|
18074
|
-
gui19.MessageBox("Failed to load system libraries");
|
|
18075
|
-
std.exit(0);
|
|
18076
|
-
}
|
|
18077
|
-
function loadProc2(lib, name) {
|
|
18078
|
-
const ptr = win5.GetProcAddress(lib, name);
|
|
18079
|
-
if (!ptr)
|
|
18080
|
-
throw new Error("Failed to load " + name);
|
|
18081
|
-
return ptr;
|
|
18082
|
-
}
|
|
18083
|
-
var GetOpenFileNameW_ = loadProc2(_comdlg32, "GetOpenFileNameW");
|
|
18084
|
-
var FFI_PTR3 = ffi13.FFI_TYPE_POINTER;
|
|
18085
|
-
var FFI_U323 = ffi13.FFI_TYPE_UINT32;
|
|
18086
|
-
function strToWide2(str) {
|
|
18087
|
-
const buf = new ArrayBuffer((str.length + 1) * 2);
|
|
18088
|
-
const dv = new DataView(buf);
|
|
18089
|
-
for (let i = 0; i < str.length; i++)
|
|
18090
|
-
dv.setUint16(i * 2, str.charCodeAt(i), true);
|
|
18091
|
-
return buf;
|
|
18092
|
-
}
|
|
18093
|
-
function wideToStr2(buf) {
|
|
18094
|
-
const dv = new DataView(buf);
|
|
18095
|
-
const chars = [];
|
|
18096
|
-
for (let i = 0; i < buf.byteLength; i += 2) {
|
|
18097
|
-
const c = dv.getUint16(i, true);
|
|
18098
|
-
if (c === 0)
|
|
18099
|
-
break;
|
|
18100
|
-
chars.push(c);
|
|
18101
|
-
}
|
|
18102
|
-
return String.fromCharCode(...chars);
|
|
18103
|
-
}
|
|
18104
18365
|
function openPdfFileDialog(owner) {
|
|
18105
|
-
const fileBuf =
|
|
18106
|
-
const filterWide =
|
|
18107
|
-
const ofn = OPENFILENAMEW.
|
|
18366
|
+
const fileBuf = WCHAR.alloc(260);
|
|
18367
|
+
const filterWide = WCHAR.encode("PDF Files\0*.pdf\0All Files\0*.*\0\0");
|
|
18368
|
+
const ofn = OPENFILENAMEW.encode({
|
|
18108
18369
|
lStructSize: OPENFILENAMEW.size,
|
|
18109
18370
|
hwndOwner: owner,
|
|
18110
|
-
|
|
18111
|
-
|
|
18112
|
-
lpstrCustomFilter: 0,
|
|
18113
|
-
nMaxCustFilter: 0,
|
|
18114
|
-
nFilterIndex: 0,
|
|
18115
|
-
lpstrFile: ffi13.bufferPtr(fileBuf),
|
|
18371
|
+
lpstrFilter: filterWide.ptr,
|
|
18372
|
+
lpstrFile: fileBuf.ptr,
|
|
18116
18373
|
nMaxFile: 260,
|
|
18117
|
-
|
|
18118
|
-
nMaxFileTitle: 0,
|
|
18119
|
-
lpstrInitialDir: 0,
|
|
18120
|
-
lpstrTitle: 0,
|
|
18121
|
-
Flags: 4096 | 2048 | 4,
|
|
18122
|
-
nFileOffset: 0,
|
|
18123
|
-
nFileExtension: 0,
|
|
18124
|
-
lpstrDefExt: 0,
|
|
18125
|
-
lCustData: 0,
|
|
18126
|
-
lpfnHook: 0,
|
|
18127
|
-
lpTemplateName: 0,
|
|
18128
|
-
pvReserved: 0,
|
|
18129
|
-
dwReserved: 0,
|
|
18130
|
-
FlagsEx: 0
|
|
18374
|
+
Flags: 4096 | 2048 | 4
|
|
18131
18375
|
});
|
|
18132
18376
|
ofn.__keep = [fileBuf, filterWide];
|
|
18133
|
-
const ret =
|
|
18377
|
+
const ret = GetOpenFileName(ofn.ptr);
|
|
18134
18378
|
if (!ret)
|
|
18135
18379
|
return null;
|
|
18136
|
-
const path =
|
|
18380
|
+
const path = WCHAR.decode(fileBuf);
|
|
18137
18381
|
return path.length > 0 ? path : null;
|
|
18138
18382
|
}
|
|
18139
18383
|
async function loadMupdf() {
|
|
18140
18384
|
const wasmPath = "./vendor/mupdf-wasm/mupdf-wasm.wasm";
|
|
18141
|
-
const fp =
|
|
18385
|
+
const fp = std2.open(wasmPath, "rb");
|
|
18142
18386
|
if (!fp) {
|
|
18143
|
-
|
|
18387
|
+
std2.printf("Error: cannot open %s\n", wasmPath);
|
|
18144
18388
|
return null;
|
|
18145
18389
|
}
|
|
18146
18390
|
fp.seek(0, 2);
|
|
@@ -18156,7 +18400,7 @@ async function loadMupdf() {
|
|
|
18156
18400
|
try {
|
|
18157
18401
|
return await import("../vendor/mupdf-wasm/mupdf.js");
|
|
18158
18402
|
} catch (e) {
|
|
18159
|
-
|
|
18403
|
+
std2.printf("Error: mupdf load failed: %s\n", String(e));
|
|
18160
18404
|
return null;
|
|
18161
18405
|
}
|
|
18162
18406
|
}
|
|
@@ -18174,9 +18418,9 @@ function renderPdfPage(mupdf, filePath, pageIndex) {
|
|
|
18174
18418
|
cachedDoc = null;
|
|
18175
18419
|
cachedPath = "";
|
|
18176
18420
|
cachedTotalPages = 0;
|
|
18177
|
-
const fp =
|
|
18421
|
+
const fp = std2.open(filePath, "rb");
|
|
18178
18422
|
if (!fp) {
|
|
18179
|
-
|
|
18423
|
+
std2.printf("Error: cannot open %s\n", filePath);
|
|
18180
18424
|
return null;
|
|
18181
18425
|
}
|
|
18182
18426
|
let buf = null;
|
|
@@ -18196,7 +18440,7 @@ function renderPdfPage(mupdf, filePath, pageIndex) {
|
|
|
18196
18440
|
cachedTotalPages = cachedDoc.countPages();
|
|
18197
18441
|
cachedPath = filePath;
|
|
18198
18442
|
} catch (e) {
|
|
18199
|
-
|
|
18443
|
+
std2.printf("Error opening document: %s\n", String(e));
|
|
18200
18444
|
return null;
|
|
18201
18445
|
}
|
|
18202
18446
|
}
|
|
@@ -18218,7 +18462,7 @@ function renderPdfPage(mupdf, filePath, pageIndex) {
|
|
|
18218
18462
|
const h = pixmap.getHeight();
|
|
18219
18463
|
const dibStride = Math.floor((w * 3 + 3) / 4) * 4;
|
|
18220
18464
|
const dibSize = h * dibStride;
|
|
18221
|
-
const dibBuffer = new
|
|
18465
|
+
const dibBuffer = new PtrArrayBuffer(dibSize);
|
|
18222
18466
|
const dib = new Uint8Array(dibBuffer);
|
|
18223
18467
|
for (let y = 0; y < h; y++) {
|
|
18224
18468
|
const srcOff = y * srcStride;
|
|
@@ -18233,7 +18477,7 @@ function renderPdfPage(mupdf, filePath, pageIndex) {
|
|
|
18233
18477
|
}
|
|
18234
18478
|
return { data: dibBuffer, w, h, totalPages: cachedTotalPages };
|
|
18235
18479
|
} catch (e) {
|
|
18236
|
-
|
|
18480
|
+
std2.printf("Error rendering: %s\n", String(e));
|
|
18237
18481
|
if (cachedDoc) {
|
|
18238
18482
|
try {
|
|
18239
18483
|
cachedDoc.destroy();
|
|
@@ -18271,7 +18515,7 @@ function App({ mupdf, mainHwnd: hwnd }) {
|
|
|
18271
18515
|
setCurrentPage(page);
|
|
18272
18516
|
setTotalPages(result.totalPages);
|
|
18273
18517
|
} else {
|
|
18274
|
-
|
|
18518
|
+
gui18.MessageBox("Failed to render PDF page");
|
|
18275
18519
|
}
|
|
18276
18520
|
}
|
|
18277
18521
|
function handleOpen() {
|
|
@@ -18294,14 +18538,14 @@ function App({ mupdf, mainHwnd: hwnd }) {
|
|
|
18294
18538
|
async function main() {
|
|
18295
18539
|
const mupdf = await loadMupdf();
|
|
18296
18540
|
if (!mupdf) {
|
|
18297
|
-
|
|
18541
|
+
gui18.MessageBox("Loading mupdf WASM failed.\nEnsure vendor/mupdf-wasm/ is present.");
|
|
18298
18542
|
return;
|
|
18299
18543
|
}
|
|
18300
|
-
|
|
18301
|
-
const hwnd =
|
|
18544
|
+
gui18.RegisterClass("PdfViewerWin");
|
|
18545
|
+
const hwnd = gui18.CreateWindow("PdfViewerWin", "PDF Viewer", 13565952, 100, 100, 1200, 800, null, null);
|
|
18302
18546
|
if (hwnd) {
|
|
18303
18547
|
render((0, import_jsx_runtime17.jsx)(App, { mupdf, mainHwnd: hwnd }), hwnd);
|
|
18304
|
-
setTimeout(() =>
|
|
18548
|
+
setTimeout(() => gui18.ShowWindow(hwnd), 0);
|
|
18305
18549
|
}
|
|
18306
18550
|
}
|
|
18307
18551
|
main();
|