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
|
@@ -1367,9 +1367,9 @@ var require_scheduler_development = __commonJS({
|
|
|
1367
1367
|
}
|
|
1368
1368
|
return first;
|
|
1369
1369
|
}
|
|
1370
|
-
function compare(a,
|
|
1371
|
-
var diff = a.sortIndex -
|
|
1372
|
-
return 0 !== diff ? diff : a.id -
|
|
1370
|
+
function compare(a, b6) {
|
|
1371
|
+
var diff = a.sortIndex - b6.sortIndex;
|
|
1372
|
+
return 0 !== diff ? diff : a.id - b6.id;
|
|
1373
1373
|
}
|
|
1374
1374
|
function advanceTimers(currentTime) {
|
|
1375
1375
|
for (var timer = peek(timerQueue); null !== timer; ) {
|
|
@@ -1667,14 +1667,14 @@ var require_react_reconciler_development = __commonJS({
|
|
|
1667
1667
|
throw Error("Unable to find node on an unmounted component.");
|
|
1668
1668
|
return alternate !== fiber ? null : fiber;
|
|
1669
1669
|
}
|
|
1670
|
-
for (var a = fiber,
|
|
1670
|
+
for (var a = fiber, b6 = alternate; ; ) {
|
|
1671
1671
|
var parentA = a.return;
|
|
1672
1672
|
if (null === parentA) break;
|
|
1673
1673
|
var parentB = parentA.alternate;
|
|
1674
1674
|
if (null === parentB) {
|
|
1675
|
-
|
|
1676
|
-
if (null !==
|
|
1677
|
-
a =
|
|
1675
|
+
b6 = parentA.return;
|
|
1676
|
+
if (null !== b6) {
|
|
1677
|
+
a = b6;
|
|
1678
1678
|
continue;
|
|
1679
1679
|
}
|
|
1680
1680
|
break;
|
|
@@ -1682,23 +1682,23 @@ var require_react_reconciler_development = __commonJS({
|
|
|
1682
1682
|
if (parentA.child === parentB.child) {
|
|
1683
1683
|
for (parentB = parentA.child; parentB; ) {
|
|
1684
1684
|
if (parentB === a) return assertIsMounted(parentA), fiber;
|
|
1685
|
-
if (parentB ===
|
|
1685
|
+
if (parentB === b6) return assertIsMounted(parentA), alternate;
|
|
1686
1686
|
parentB = parentB.sibling;
|
|
1687
1687
|
}
|
|
1688
1688
|
throw Error("Unable to find node on an unmounted component.");
|
|
1689
1689
|
}
|
|
1690
|
-
if (a.return !==
|
|
1690
|
+
if (a.return !== b6.return) a = parentA, b6 = parentB;
|
|
1691
1691
|
else {
|
|
1692
1692
|
for (var didFindChild = false, _child = parentA.child; _child; ) {
|
|
1693
1693
|
if (_child === a) {
|
|
1694
1694
|
didFindChild = true;
|
|
1695
1695
|
a = parentA;
|
|
1696
|
-
|
|
1696
|
+
b6 = parentB;
|
|
1697
1697
|
break;
|
|
1698
1698
|
}
|
|
1699
|
-
if (_child ===
|
|
1699
|
+
if (_child === b6) {
|
|
1700
1700
|
didFindChild = true;
|
|
1701
|
-
|
|
1701
|
+
b6 = parentA;
|
|
1702
1702
|
a = parentB;
|
|
1703
1703
|
break;
|
|
1704
1704
|
}
|
|
@@ -1709,12 +1709,12 @@ var require_react_reconciler_development = __commonJS({
|
|
|
1709
1709
|
if (_child === a) {
|
|
1710
1710
|
didFindChild = true;
|
|
1711
1711
|
a = parentB;
|
|
1712
|
-
|
|
1712
|
+
b6 = parentA;
|
|
1713
1713
|
break;
|
|
1714
1714
|
}
|
|
1715
|
-
if (_child ===
|
|
1715
|
+
if (_child === b6) {
|
|
1716
1716
|
didFindChild = true;
|
|
1717
|
-
|
|
1717
|
+
b6 = parentB;
|
|
1718
1718
|
a = parentA;
|
|
1719
1719
|
break;
|
|
1720
1720
|
}
|
|
@@ -1726,7 +1726,7 @@ var require_react_reconciler_development = __commonJS({
|
|
|
1726
1726
|
);
|
|
1727
1727
|
}
|
|
1728
1728
|
}
|
|
1729
|
-
if (a.alternate !==
|
|
1729
|
+
if (a.alternate !== b6)
|
|
1730
1730
|
throw Error(
|
|
1731
1731
|
"Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue."
|
|
1732
1732
|
);
|
|
@@ -15071,10 +15071,10 @@ var require_react_reconciler_development = __commonJS({
|
|
|
15071
15071
|
setCurrentUpdatePriority(previousPriority), ReactSharedInternals.T = prevTransition;
|
|
15072
15072
|
}
|
|
15073
15073
|
};
|
|
15074
|
-
exports2.discreteUpdates = function(fn, a,
|
|
15074
|
+
exports2.discreteUpdates = function(fn, a, b6, c, d) {
|
|
15075
15075
|
var prevTransition = ReactSharedInternals.T, previousPriority = getCurrentUpdatePriority();
|
|
15076
15076
|
try {
|
|
15077
|
-
return setCurrentUpdatePriority(2), ReactSharedInternals.T = null, fn(a,
|
|
15077
|
+
return setCurrentUpdatePriority(2), ReactSharedInternals.T = null, fn(a, b6, c, d);
|
|
15078
15078
|
} finally {
|
|
15079
15079
|
setCurrentUpdatePriority(previousPriority), ReactSharedInternals.T = prevTransition, executionContext === NoContext && (workInProgressRootRenderTargetTime = now$1() + RENDER_TIMEOUT_MS);
|
|
15080
15080
|
}
|
|
@@ -15357,142 +15357,19 @@ var require_constants = __commonJS({
|
|
|
15357
15357
|
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
|
|
15358
15358
|
var import_react18 = __toESM(require_react(), 1);
|
|
15359
15359
|
import "../lib/polyfill.js";
|
|
15360
|
-
import * as gui19 from "gui";
|
|
15361
|
-
import * as os4 from "os";
|
|
15362
|
-
|
|
15363
|
-
// _build/lib/react-qw/index.js
|
|
15364
15360
|
import * as gui18 from "gui";
|
|
15361
|
+
import * as os5 from "os";
|
|
15365
15362
|
|
|
15366
|
-
// _build/lib/react-qw/
|
|
15367
|
-
|
|
15368
|
-
var import_react = __toESM(require_react(), 1);
|
|
15369
|
-
var import_constants = __toESM(require_constants(), 1);
|
|
15370
|
-
import * as gui3 from "gui";
|
|
15371
|
-
import * as os from "os";
|
|
15372
|
-
|
|
15373
|
-
// _build/lib/react-qw/props.js
|
|
15374
|
-
import * as gui from "gui";
|
|
15375
|
-
function applyProps(instance, newProps, _oldProps) {
|
|
15376
|
-
const hwnd2 = instance.hwnd;
|
|
15377
|
-
instance.props = newProps;
|
|
15378
|
-
const textVal = "text" in newProps ? newProps.text : typeof newProps.children === "string" ? newProps.children : typeof newProps.children === "number" ? String(newProps.children) : void 0;
|
|
15379
|
-
if (textVal !== void 0) {
|
|
15380
|
-
let cursor = -1;
|
|
15381
|
-
if (instance.type === "EDIT") {
|
|
15382
|
-
const sel = gui.SendMessage(hwnd2, 176, 0, 0);
|
|
15383
|
-
cursor = sel >>> 16;
|
|
15384
|
-
}
|
|
15385
|
-
gui.SetWindowText(hwnd2, textVal);
|
|
15386
|
-
if (instance.type === "EDIT" && cursor >= 0) {
|
|
15387
|
-
gui.SendMessage(hwnd2, 177, cursor, cursor);
|
|
15388
|
-
}
|
|
15389
|
-
}
|
|
15390
|
-
if ("disabled" in newProps) {
|
|
15391
|
-
gui.EnableWindow(hwnd2, !newProps.disabled);
|
|
15392
|
-
}
|
|
15393
|
-
if ("hidden" in newProps) {
|
|
15394
|
-
gui.ShowWindow(
|
|
15395
|
-
hwnd2,
|
|
15396
|
-
newProps.hidden ? 0 : 5
|
|
15397
|
-
/* gui.ShowWindowCmd.SHOW */
|
|
15398
|
-
);
|
|
15399
|
-
}
|
|
15400
|
-
if ("visible" in newProps) {
|
|
15401
|
-
gui.ShowWindow(
|
|
15402
|
-
hwnd2,
|
|
15403
|
-
newProps.visible ? 5 : 0
|
|
15404
|
-
/* gui.ShowWindowCmd.HIDE */
|
|
15405
|
-
);
|
|
15406
|
-
}
|
|
15407
|
-
}
|
|
15408
|
-
|
|
15409
|
-
// _build/lib/react-qw/layout.js
|
|
15410
|
-
var DEFAULT_W = 100;
|
|
15411
|
-
var DEFAULT_H = 30;
|
|
15412
|
-
function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
15413
|
-
const dir = flex.flexDirection || "column";
|
|
15414
|
-
const gap = flex.gap ?? 0;
|
|
15415
|
-
const justify = flex.justifyContent || "flex-start";
|
|
15416
|
-
const align = flex.alignItems || "stretch";
|
|
15417
|
-
const isRow = dir === "row";
|
|
15418
|
-
const n = children.length;
|
|
15419
|
-
const mainSize = isRow ? "w" : "h";
|
|
15420
|
-
const crossSize = isRow ? "h" : "w";
|
|
15421
|
-
const mainPos = isRow ? "x" : "y";
|
|
15422
|
-
const crossPos = isRow ? "y" : "x";
|
|
15423
|
-
const mainDim = isRow ? "width" : "height";
|
|
15424
|
-
const crossDim = isRow ? "height" : "width";
|
|
15425
|
-
const pt = flex.paddingTop ?? flex.padding ?? 0;
|
|
15426
|
-
const pr = flex.paddingRight ?? flex.padding ?? 0;
|
|
15427
|
-
const pb = flex.paddingBottom ?? flex.padding ?? 0;
|
|
15428
|
-
const pl = flex.paddingLeft ?? flex.padding ?? 0;
|
|
15429
|
-
const mainPadding = isRow ? pl + pr : pt + pb;
|
|
15430
|
-
const crossPadding = isRow ? pt + pb : pl + pr;
|
|
15431
|
-
const parentMain = (isRow ? parentW : parentH) - mainPadding;
|
|
15432
|
-
const parentCross = (isRow ? parentH : parentW) - crossPadding;
|
|
15433
|
-
const sizes = children.map((c) => ({
|
|
15434
|
-
w: typeof c.style.width === "number" ? c.style.width : DEFAULT_W,
|
|
15435
|
-
h: typeof c.style.height === "number" ? c.style.height : DEFAULT_H
|
|
15436
|
-
}));
|
|
15437
|
-
const flexGrows = children.map((c) => c.style.flexGrow ?? 0);
|
|
15438
|
-
const totalGrow = flexGrows.reduce((s, g) => s + g, 0);
|
|
15439
|
-
const baseMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
15440
|
-
let freeGrow = parentMain - baseMain - Math.max(0, n - 1) * gap;
|
|
15441
|
-
if (totalGrow > 0 && freeGrow > 0) {
|
|
15442
|
-
for (let i = 0; i < n; i++) {
|
|
15443
|
-
sizes[i][mainSize] += freeGrow * flexGrows[i] / totalGrow;
|
|
15444
|
-
}
|
|
15445
|
-
}
|
|
15446
|
-
const totalMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
15447
|
-
const free = parentMain - totalMain - Math.max(0, n - 1) * gap;
|
|
15448
|
-
let offset = 0, extraGap = 0;
|
|
15449
|
-
if (justify === "flex-end")
|
|
15450
|
-
offset = free;
|
|
15451
|
-
else if (justify === "center")
|
|
15452
|
-
offset = Math.max(0, free / 2);
|
|
15453
|
-
else if (justify === "space-between" && n > 1)
|
|
15454
|
-
extraGap = free / (n - 1);
|
|
15455
|
-
else if (justify === "space-around") {
|
|
15456
|
-
extraGap = free / n;
|
|
15457
|
-
offset = extraGap / 2;
|
|
15458
|
-
} else if (justify === "space-evenly") {
|
|
15459
|
-
extraGap = free / (n + 1);
|
|
15460
|
-
offset = extraGap;
|
|
15461
|
-
}
|
|
15462
|
-
let cursor = offset;
|
|
15463
|
-
return sizes.map((sz, i) => {
|
|
15464
|
-
const childCrossBase = sz[crossSize];
|
|
15465
|
-
const childAlign = children[i].style.alignSelf ?? "auto";
|
|
15466
|
-
const effectiveAlign = childAlign === "auto" ? align : childAlign;
|
|
15467
|
-
let childMain = sz[mainSize];
|
|
15468
|
-
let childCross = childCrossBase;
|
|
15469
|
-
const res = { x: 0, y: 0, width: 0, height: 0 };
|
|
15470
|
-
res[mainPos] = cursor;
|
|
15471
|
-
res[crossPos] = 0;
|
|
15472
|
-
res[mainDim] = childMain;
|
|
15473
|
-
res[crossDim] = childCross;
|
|
15474
|
-
if (effectiveAlign === "stretch") {
|
|
15475
|
-
const hasExplicitCross = typeof children[i].style[crossDim] === "number";
|
|
15476
|
-
if (!hasExplicitCross) {
|
|
15477
|
-
res[crossDim] = parentCross;
|
|
15478
|
-
res[crossPos] = 0;
|
|
15479
|
-
}
|
|
15480
|
-
} else if (effectiveAlign === "flex-end") {
|
|
15481
|
-
res[crossPos] = parentCross - childCross;
|
|
15482
|
-
} else if (effectiveAlign === "center") {
|
|
15483
|
-
res[crossPos] = Math.max(0, (parentCross - childCross) / 2);
|
|
15484
|
-
}
|
|
15485
|
-
cursor += childMain + gap + extraGap;
|
|
15486
|
-
return res;
|
|
15487
|
-
});
|
|
15488
|
-
}
|
|
15363
|
+
// _build/lib/react-qw/index.js
|
|
15364
|
+
import * as gui17 from "gui";
|
|
15489
15365
|
|
|
15490
|
-
// _build/lib/
|
|
15491
|
-
import * as
|
|
15492
|
-
import * as gui2 from "gui";
|
|
15366
|
+
// _build/lib/windows/user32.js
|
|
15367
|
+
import * as os3 from "os";
|
|
15493
15368
|
|
|
15494
|
-
// _build/lib/ffi
|
|
15369
|
+
// _build/lib/ffi/bind.js
|
|
15495
15370
|
import * as ffi from "ffi";
|
|
15371
|
+
import * as os2 from "os";
|
|
15372
|
+
import * as std from "std";
|
|
15496
15373
|
import * as win from "win";
|
|
15497
15374
|
|
|
15498
15375
|
// _build/lib/text-codec.js
|
|
@@ -15515,62 +15392,62 @@ function _normalizeLabel(label) {
|
|
|
15515
15392
|
function _decodeUTF8(buf, fatal) {
|
|
15516
15393
|
let out = "";
|
|
15517
15394
|
for (let i = 0; i < buf.length; ) {
|
|
15518
|
-
const
|
|
15519
|
-
if (
|
|
15520
|
-
out += String.fromCharCode(
|
|
15395
|
+
const b6 = buf[i++];
|
|
15396
|
+
if (b6 < 128) {
|
|
15397
|
+
out += String.fromCharCode(b6);
|
|
15521
15398
|
continue;
|
|
15522
15399
|
}
|
|
15523
|
-
if (
|
|
15400
|
+
if (b6 < 192) {
|
|
15524
15401
|
out += fatal ? (() => {
|
|
15525
15402
|
throw new TypeError("unexpected continuation byte");
|
|
15526
15403
|
})() : "\uFFFD";
|
|
15527
15404
|
continue;
|
|
15528
15405
|
}
|
|
15529
15406
|
let c, min;
|
|
15530
|
-
if (
|
|
15407
|
+
if (b6 < 224) {
|
|
15531
15408
|
if (i >= buf.length) {
|
|
15532
15409
|
out += fatal ? (() => {
|
|
15533
15410
|
throw new TypeError("incomplete utf-8");
|
|
15534
15411
|
})() : "\uFFFD";
|
|
15535
15412
|
break;
|
|
15536
15413
|
}
|
|
15537
|
-
const
|
|
15538
|
-
if ((
|
|
15414
|
+
const b22 = buf[i++];
|
|
15415
|
+
if ((b22 & 192) !== 128) {
|
|
15539
15416
|
out += "\uFFFD";
|
|
15540
15417
|
continue;
|
|
15541
15418
|
}
|
|
15542
|
-
c = (
|
|
15419
|
+
c = (b6 & 31) << 6 | b22 & 63;
|
|
15543
15420
|
min = 128;
|
|
15544
|
-
} else if (
|
|
15421
|
+
} else if (b6 < 240) {
|
|
15545
15422
|
if (i + 1 >= buf.length) {
|
|
15546
15423
|
out += fatal ? (() => {
|
|
15547
15424
|
throw new TypeError("incomplete utf-8");
|
|
15548
15425
|
})() : "\uFFFD";
|
|
15549
15426
|
break;
|
|
15550
15427
|
}
|
|
15551
|
-
const
|
|
15552
|
-
const
|
|
15553
|
-
if ((
|
|
15428
|
+
const b22 = buf[i++];
|
|
15429
|
+
const b32 = buf[i++];
|
|
15430
|
+
if ((b22 & 192) !== 128 || (b32 & 192) !== 128) {
|
|
15554
15431
|
out += "\uFFFD";
|
|
15555
15432
|
continue;
|
|
15556
15433
|
}
|
|
15557
|
-
c = (
|
|
15434
|
+
c = (b6 & 15) << 12 | (b22 & 63) << 6 | b32 & 63;
|
|
15558
15435
|
min = 2048;
|
|
15559
|
-
} else if (
|
|
15436
|
+
} else if (b6 < 248) {
|
|
15560
15437
|
if (i + 2 >= buf.length) {
|
|
15561
15438
|
out += fatal ? (() => {
|
|
15562
15439
|
throw new TypeError("incomplete utf-8");
|
|
15563
15440
|
})() : "\uFFFD";
|
|
15564
15441
|
break;
|
|
15565
15442
|
}
|
|
15566
|
-
const
|
|
15567
|
-
const
|
|
15568
|
-
const
|
|
15569
|
-
if ((
|
|
15443
|
+
const b22 = buf[i++];
|
|
15444
|
+
const b32 = buf[i++];
|
|
15445
|
+
const b42 = buf[i++];
|
|
15446
|
+
if ((b22 & 192) !== 128 || (b32 & 192) !== 128 || (b42 & 192) !== 128) {
|
|
15570
15447
|
out += "\uFFFD";
|
|
15571
15448
|
continue;
|
|
15572
15449
|
}
|
|
15573
|
-
c = (
|
|
15450
|
+
c = (b6 & 7) << 18 | (b22 & 63) << 12 | (b32 & 63) << 6 | b42 & 63;
|
|
15574
15451
|
min = 65536;
|
|
15575
15452
|
} else {
|
|
15576
15453
|
out += fatal ? (() => {
|
|
@@ -15708,65 +15585,166 @@ if (typeof globalThis.TextEncoder === "undefined") {
|
|
|
15708
15585
|
globalThis.TextEncoder = TextEncoderImpl;
|
|
15709
15586
|
}
|
|
15710
15587
|
|
|
15711
|
-
// _build/lib/ffi
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
|
|
15725
|
-
|
|
15588
|
+
// _build/lib/ffi/ctype.js
|
|
15589
|
+
import { bufferPtr } from "ffi";
|
|
15590
|
+
import * as os from "os";
|
|
15591
|
+
var C_BASIC_TYPE = [
|
|
15592
|
+
"void",
|
|
15593
|
+
"u8",
|
|
15594
|
+
"i8",
|
|
15595
|
+
"u16",
|
|
15596
|
+
"i16",
|
|
15597
|
+
"u32",
|
|
15598
|
+
"i32",
|
|
15599
|
+
"u64",
|
|
15600
|
+
"i64",
|
|
15601
|
+
"f32",
|
|
15602
|
+
"f64",
|
|
15603
|
+
"ptr"
|
|
15604
|
+
];
|
|
15605
|
+
var PTR_TOKEN_RE = /^<([A-Za-z_]\w*|)>ptr(!|@[A-Za-z_]\w*)?$/;
|
|
15606
|
+
function isCPtrToken(t) {
|
|
15607
|
+
return PTR_TOKEN_RE.test(t);
|
|
15608
|
+
}
|
|
15609
|
+
var VAL_TOKEN_RE = /^<([A-Za-z_]\w*)>$/;
|
|
15610
|
+
function isCValToken(t) {
|
|
15611
|
+
return VAL_TOKEN_RE.test(t);
|
|
15612
|
+
}
|
|
15613
|
+
function valName(t) {
|
|
15614
|
+
const m = VAL_TOKEN_RE.exec(t);
|
|
15615
|
+
return m?.[1] || "";
|
|
15616
|
+
}
|
|
15617
|
+
function ptrName(t) {
|
|
15618
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15619
|
+
return m?.[1] || "";
|
|
15620
|
+
}
|
|
15621
|
+
var cTokenToType = (t) => {
|
|
15622
|
+
if (isCPtrToken(t))
|
|
15623
|
+
return "ptr";
|
|
15624
|
+
if (isCValToken(t))
|
|
15625
|
+
throw new Error(`ffi: cTokenToType: by-value token "${t}" has no scalar slot type`);
|
|
15626
|
+
return t;
|
|
15726
15627
|
};
|
|
15727
|
-
var
|
|
15728
|
-
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
|
|
15742
|
-
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
|
|
15749
|
-
|
|
15750
|
-
|
|
15751
|
-
|
|
15752
|
-
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
|
|
15763
|
-
|
|
15628
|
+
var PTR_SIZE = os.arch === "x64" ? 8 : 4;
|
|
15629
|
+
var SizeAlign = {
|
|
15630
|
+
u8: 1,
|
|
15631
|
+
i8: 1,
|
|
15632
|
+
u16: 2,
|
|
15633
|
+
i16: 2,
|
|
15634
|
+
u32: 4,
|
|
15635
|
+
i32: 4,
|
|
15636
|
+
u64: 8,
|
|
15637
|
+
i64: 8,
|
|
15638
|
+
f32: 4,
|
|
15639
|
+
f64: 8
|
|
15640
|
+
};
|
|
15641
|
+
var NULL = 0;
|
|
15642
|
+
function normToken(t) {
|
|
15643
|
+
if (isCPtrToken(t)) {
|
|
15644
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15645
|
+
const name = m?.[1] || "";
|
|
15646
|
+
const mod = m?.[2];
|
|
15647
|
+
return mod?.startsWith("@") ? `<${name}>ptr` : t;
|
|
15648
|
+
}
|
|
15649
|
+
if (isCValToken(t))
|
|
15650
|
+
return t;
|
|
15651
|
+
const at = t.indexOf("@");
|
|
15652
|
+
const base = at >= 0 ? t.slice(0, at) : t;
|
|
15653
|
+
const suffixOk = at < 0 || /^[A-Za-z_]\w*$/.test(t.slice(at + 1));
|
|
15654
|
+
if (suffixOk && base !== "ptr" && C_BASIC_TYPE.includes(base))
|
|
15655
|
+
return base;
|
|
15656
|
+
throw new Error("Unknown token: " + t);
|
|
15657
|
+
}
|
|
15658
|
+
function readScalar(dv, off, k) {
|
|
15659
|
+
switch (k) {
|
|
15660
|
+
case "u8":
|
|
15661
|
+
return dv.getUint8(off);
|
|
15662
|
+
case "i8":
|
|
15663
|
+
return dv.getInt8(off);
|
|
15664
|
+
case "u16":
|
|
15665
|
+
return dv.getUint16(off, true);
|
|
15666
|
+
case "i16":
|
|
15667
|
+
return dv.getInt16(off, true);
|
|
15668
|
+
case "u32":
|
|
15669
|
+
return dv.getUint32(off, true);
|
|
15670
|
+
case "i32":
|
|
15671
|
+
return dv.getInt32(off, true);
|
|
15672
|
+
case "u64":
|
|
15673
|
+
return dv.getBigUint64(off, true);
|
|
15674
|
+
case "i64":
|
|
15675
|
+
return dv.getBigInt64(off, true);
|
|
15676
|
+
case "f32":
|
|
15677
|
+
return dv.getFloat32(off, true);
|
|
15678
|
+
case "f64":
|
|
15679
|
+
return dv.getFloat64(off, true);
|
|
15680
|
+
case "ptr": {
|
|
15681
|
+
return PTR_SIZE === 8 ? Number(dv.getBigInt64(off, true)) : dv.getInt32(off, true);
|
|
15682
|
+
}
|
|
15683
|
+
}
|
|
15684
|
+
}
|
|
15685
|
+
function writeScalar(dv, off, { k, v }) {
|
|
15686
|
+
switch (k) {
|
|
15687
|
+
case "u8":
|
|
15688
|
+
dv.setUint8(off, Number(v));
|
|
15689
|
+
break;
|
|
15690
|
+
case "i8":
|
|
15691
|
+
dv.setInt8(off, Number(v));
|
|
15692
|
+
break;
|
|
15693
|
+
case "u16":
|
|
15694
|
+
dv.setUint16(off, Number(v), true);
|
|
15695
|
+
break;
|
|
15696
|
+
case "i16":
|
|
15697
|
+
dv.setInt16(off, Number(v), true);
|
|
15698
|
+
break;
|
|
15699
|
+
case "u32":
|
|
15700
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15701
|
+
break;
|
|
15702
|
+
case "i32":
|
|
15703
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15704
|
+
break;
|
|
15705
|
+
case "u64":
|
|
15706
|
+
dv.setBigUint64(off, v, true);
|
|
15707
|
+
break;
|
|
15708
|
+
case "i64":
|
|
15709
|
+
dv.setBigInt64(off, v, true);
|
|
15710
|
+
break;
|
|
15711
|
+
case "f32":
|
|
15712
|
+
dv.setFloat32(off, v, true);
|
|
15713
|
+
break;
|
|
15714
|
+
case "f64":
|
|
15715
|
+
dv.setFloat64(off, v, true);
|
|
15716
|
+
break;
|
|
15717
|
+
case "ptr": {
|
|
15718
|
+
if (v == null) {
|
|
15719
|
+
throw new Error("ffi: got null/undefined for a ptr slot; pass the imported NULL constant for empty");
|
|
15720
|
+
}
|
|
15721
|
+
if (PTR_SIZE === 8)
|
|
15722
|
+
dv.setBigUint64(off, BigInt.asUintN(64, BigInt(v)), true);
|
|
15723
|
+
else
|
|
15724
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15725
|
+
break;
|
|
15726
|
+
}
|
|
15727
|
+
}
|
|
15728
|
+
}
|
|
15729
|
+
function writeSlot(dv, off, e) {
|
|
15730
|
+
const { k, v } = e;
|
|
15731
|
+
if (k === "u8" || k === "i8" || k === "u16" || k === "i16") {
|
|
15732
|
+
dv.setUint32(off, Number(v) >>> 0, true);
|
|
15733
|
+
return;
|
|
15734
|
+
}
|
|
15735
|
+
writeScalar(dv, off, e);
|
|
15736
|
+
}
|
|
15737
|
+
var PtrArrayBuffer = class extends ArrayBuffer {
|
|
15738
|
+
ptr;
|
|
15739
|
+
constructor(byteLength) {
|
|
15740
|
+
super(byteLength);
|
|
15741
|
+
this.ptr = bufferPtr(this);
|
|
15742
|
+
}
|
|
15764
15743
|
};
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
return k;
|
|
15744
|
+
|
|
15745
|
+
// _build/lib/ffi/bind.js
|
|
15746
|
+
function valCodec(name, encoders) {
|
|
15747
|
+
return encoders[name];
|
|
15770
15748
|
}
|
|
15771
15749
|
var _dllCache = /* @__PURE__ */ new Map();
|
|
15772
15750
|
function loadDll(dll) {
|
|
@@ -15781,77 +15759,1011 @@ function loadDll(dll) {
|
|
|
15781
15759
|
}
|
|
15782
15760
|
function parseSig(sig) {
|
|
15783
15761
|
const parts = sig.split(" -> ");
|
|
15784
|
-
|
|
15785
|
-
if (ret === void 0 || parts.length > 2) {
|
|
15762
|
+
if (parts.length !== 2) {
|
|
15786
15763
|
throw new Error(`ffi-bind: invalid signature "${sig}" (expected "arg1 arg2 -> ret")`);
|
|
15787
15764
|
}
|
|
15788
|
-
const
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15793
|
-
|
|
15765
|
+
const rawArgs = parts[0].split(" ").filter((t) => t !== "");
|
|
15766
|
+
const argTokens = [];
|
|
15767
|
+
for (const raw of rawArgs) {
|
|
15768
|
+
const tok = normToken(raw);
|
|
15769
|
+
if (tok === "void") {
|
|
15770
|
+
throw new Error("Void can not in args");
|
|
15771
|
+
}
|
|
15772
|
+
argTokens.push(tok);
|
|
15773
|
+
}
|
|
15774
|
+
const retToken = normToken(parts[1]);
|
|
15775
|
+
if (isCValToken(retToken))
|
|
15776
|
+
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)`);
|
|
15777
|
+
return {
|
|
15778
|
+
argTokens,
|
|
15779
|
+
retToken,
|
|
15780
|
+
sig
|
|
15781
|
+
};
|
|
15794
15782
|
}
|
|
15795
|
-
function makeFn(proc, sig) {
|
|
15796
|
-
const
|
|
15797
|
-
const
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
const
|
|
15801
|
-
|
|
15783
|
+
function makeFn(proc, sig, encoders, decoders) {
|
|
15784
|
+
const ps = parseSig(sig);
|
|
15785
|
+
for (const t of ps.argTokens) {
|
|
15786
|
+
if (!isCValToken(t))
|
|
15787
|
+
continue;
|
|
15788
|
+
const name = valName(t);
|
|
15789
|
+
const codec = valCodec(name, encoders);
|
|
15790
|
+
if (!codec || typeof codec.encode !== "function")
|
|
15791
|
+
throw new Error(`ffi-bind: ${sig}: by-value position <${name}> has no registered layout (available: ${Object.keys(encoders).join(", ") || "none"})`);
|
|
15792
|
+
if (typeof codec.size !== "number" || codec.size < 1)
|
|
15793
|
+
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)`);
|
|
15794
|
+
}
|
|
15795
|
+
return (...a) => callPacked(proc, ps, a, encoders, decoders);
|
|
15796
|
+
}
|
|
15797
|
+
var IA32_ARG_SIZE = {
|
|
15798
|
+
u8: 4,
|
|
15799
|
+
i8: 4,
|
|
15800
|
+
u16: 4,
|
|
15801
|
+
i16: 4,
|
|
15802
|
+
u32: 4,
|
|
15803
|
+
i32: 4,
|
|
15804
|
+
u64: 8,
|
|
15805
|
+
i64: 8,
|
|
15806
|
+
f32: 4,
|
|
15807
|
+
f64: 8,
|
|
15808
|
+
ptr: PTR_SIZE
|
|
15809
|
+
};
|
|
15810
|
+
var X64_MIN_SLOTS = 4;
|
|
15811
|
+
function callPacked(proc, { argTokens, retToken, sig }, args, encoders, decoders) {
|
|
15812
|
+
const is64 = os2.arch === "x64";
|
|
15813
|
+
const getWidth = (t, is642) => {
|
|
15814
|
+
if (isCValToken(t))
|
|
15815
|
+
throw new Error(`ffi-bind: getWidth: by-value token "${t}" (dispatched by widthOf)`);
|
|
15816
|
+
if (is642)
|
|
15817
|
+
return 8;
|
|
15818
|
+
if (isCPtrToken(t))
|
|
15819
|
+
return PTR_SIZE;
|
|
15820
|
+
return IA32_ARG_SIZE[t];
|
|
15802
15821
|
};
|
|
15822
|
+
const widthOf = (t) => {
|
|
15823
|
+
if (isCValToken(t)) {
|
|
15824
|
+
if (is64)
|
|
15825
|
+
return 8;
|
|
15826
|
+
const layout = valCodec(valName(t), encoders);
|
|
15827
|
+
if (!layout)
|
|
15828
|
+
throw new Error(`ffi-bind: <${valName(t)}> by-value position has no registered layout`);
|
|
15829
|
+
const size = layout.size;
|
|
15830
|
+
return size % 4 === 0 ? size : size + 4 - size % 4;
|
|
15831
|
+
}
|
|
15832
|
+
return getWidth(t, is64);
|
|
15833
|
+
};
|
|
15834
|
+
let total = 0;
|
|
15835
|
+
for (const t of argTokens)
|
|
15836
|
+
total += widthOf(t);
|
|
15837
|
+
if (is64 && argTokens.length < X64_MIN_SLOTS)
|
|
15838
|
+
total = X64_MIN_SLOTS * 8;
|
|
15839
|
+
const argFrame = new ArrayBuffer(total);
|
|
15840
|
+
const dv = new DataView(argFrame);
|
|
15841
|
+
const held = [];
|
|
15842
|
+
let off = 0;
|
|
15843
|
+
for (let i = 0; i < argTokens.length; i++) {
|
|
15844
|
+
const argToken = argTokens[i];
|
|
15845
|
+
const nonnull = argToken.endsWith("!");
|
|
15846
|
+
const arg = args[i];
|
|
15847
|
+
if (isCPtrToken(argToken)) {
|
|
15848
|
+
const name = ptrName(argToken);
|
|
15849
|
+
if (typeof arg === "number") {
|
|
15850
|
+
if (nonnull && arg === 0)
|
|
15851
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! got 0 (null pointer forbidden here; the token marks this position non-null)`);
|
|
15852
|
+
writeSlot(dv, off, { k: "ptr", v: arg });
|
|
15853
|
+
} else {
|
|
15854
|
+
if (arg === null || arg === void 0) {
|
|
15855
|
+
throw new Error(`ffi-bind: <${name}>ptr got ${String(arg)}; pass the imported NULL constant for an empty pointer`);
|
|
15856
|
+
}
|
|
15857
|
+
const codec = encoders[name];
|
|
15858
|
+
if (!codec) {
|
|
15859
|
+
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"})`);
|
|
15860
|
+
}
|
|
15861
|
+
if (!codec.encode) {
|
|
15862
|
+
throw new Error(`ffi-bind: <${name}>ptr has no encoder (out-only codec)`);
|
|
15863
|
+
}
|
|
15864
|
+
const buf = codec.encode(arg);
|
|
15865
|
+
held.push(buf);
|
|
15866
|
+
const p = buf.ptr;
|
|
15867
|
+
if (typeof p !== "number")
|
|
15868
|
+
throw new Error("ffi-bind: codec.encode must return a PtrArrayBuffer, got plain ArrayBuffer");
|
|
15869
|
+
if (nonnull && p === 0)
|
|
15870
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! encode produced 0 (null pointer forbidden here)`);
|
|
15871
|
+
writeSlot(dv, off, { k: "ptr", v: p });
|
|
15872
|
+
}
|
|
15873
|
+
} else if (isCValToken(argToken)) {
|
|
15874
|
+
const name = valName(argToken);
|
|
15875
|
+
const codec = valCodec(name, encoders);
|
|
15876
|
+
if (!codec)
|
|
15877
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}> by-value position has no registered layout`);
|
|
15878
|
+
if (arg === null || arg === void 0)
|
|
15879
|
+
throw new Error(`ffi-bind: <${name}> value position got ${String(arg)}; pass a struct object (use <${name}>ptr to pass a pointer)`);
|
|
15880
|
+
const size = codec.size;
|
|
15881
|
+
if (!is64 || size <= 8 && (size & size - 1) === 0) {
|
|
15882
|
+
codec.encode(arg, argFrame, off);
|
|
15883
|
+
} else {
|
|
15884
|
+
const buf = new ArrayBuffer(size + 15);
|
|
15885
|
+
const base = ffi.bufferPtr(buf);
|
|
15886
|
+
const pad = (16 - base % 16) % 16;
|
|
15887
|
+
codec.encode(arg, buf, pad);
|
|
15888
|
+
held.push(buf);
|
|
15889
|
+
writeSlot(dv, off, { k: "ptr", v: base + pad });
|
|
15890
|
+
}
|
|
15891
|
+
} else {
|
|
15892
|
+
writeSlot(dv, off, { k: argToken, v: arg });
|
|
15893
|
+
}
|
|
15894
|
+
off += widthOf(argToken);
|
|
15895
|
+
}
|
|
15896
|
+
const retBuf = new ArrayBuffer(8);
|
|
15897
|
+
const retIsFp = retToken === "f32" || retToken === "f64";
|
|
15898
|
+
ffi.ffiCall(proc, argFrame, retBuf, retIsFp ? 1 : 0);
|
|
15899
|
+
const raw = readRet(cTokenToType(retToken), retBuf);
|
|
15900
|
+
if (retToken.endsWith("!") && raw === 0)
|
|
15901
|
+
throw new Error(`ffi-bind: ${sig}: return ${retToken} got 0 (the token promises C never returns null here)`);
|
|
15902
|
+
if (isCPtrToken(retToken) && raw !== 0) {
|
|
15903
|
+
const name = ptrName(retToken);
|
|
15904
|
+
if (name !== "") {
|
|
15905
|
+
const codec = decoders[name];
|
|
15906
|
+
if (codec?.decode)
|
|
15907
|
+
return codec.decode(raw);
|
|
15908
|
+
}
|
|
15909
|
+
}
|
|
15910
|
+
return raw;
|
|
15803
15911
|
}
|
|
15804
|
-
function
|
|
15805
|
-
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
|
|
15811
|
-
|
|
15912
|
+
function readRet(ret, retBuf) {
|
|
15913
|
+
if (ret === "void")
|
|
15914
|
+
return void 0;
|
|
15915
|
+
return readScalar(new DataView(retBuf), 0, ret);
|
|
15916
|
+
}
|
|
15917
|
+
var WCHAR = {
|
|
15918
|
+
encode: (v) => {
|
|
15919
|
+
const u8 = new TextEncoder("utf-16le").encode(v + "\0");
|
|
15920
|
+
const out = new PtrArrayBuffer(u8.byteLength);
|
|
15921
|
+
new Uint8Array(out).set(u8);
|
|
15922
|
+
return out;
|
|
15923
|
+
},
|
|
15924
|
+
decode: (p) => {
|
|
15925
|
+
if (typeof p === "number") {
|
|
15926
|
+
let s2 = "";
|
|
15927
|
+
let addr = p;
|
|
15928
|
+
const start = addr;
|
|
15929
|
+
for (; ; ) {
|
|
15930
|
+
const lo = ffi.readByte(addr);
|
|
15931
|
+
const hi = ffi.readByte(addr + 1);
|
|
15932
|
+
if (lo === 0 && hi === 0)
|
|
15933
|
+
return s2;
|
|
15934
|
+
s2 += String.fromCharCode(lo | hi << 8);
|
|
15935
|
+
addr += 2;
|
|
15936
|
+
if (addr - start > 1 << 21) {
|
|
15937
|
+
throw new Error("ffi-bind: WCHAR decode exceeded 4MiB without NUL");
|
|
15938
|
+
}
|
|
15939
|
+
}
|
|
15940
|
+
}
|
|
15941
|
+
const u8 = new Uint8Array(p);
|
|
15942
|
+
const limit = u8.length & ~1;
|
|
15943
|
+
let s = "";
|
|
15944
|
+
for (let i = 0; i < limit; i += 2) {
|
|
15945
|
+
const c = u8[i] | u8[i + 1] << 8;
|
|
15946
|
+
if (c === 0)
|
|
15947
|
+
return s;
|
|
15948
|
+
s += String.fromCharCode(c);
|
|
15949
|
+
}
|
|
15950
|
+
return s;
|
|
15951
|
+
},
|
|
15952
|
+
alloc: (size = 256) => new PtrArrayBuffer(size * 2)
|
|
15953
|
+
};
|
|
15954
|
+
var BYTE = {
|
|
15955
|
+
encode: (v) => {
|
|
15956
|
+
if (!(v instanceof PtrArrayBuffer))
|
|
15957
|
+
throw new Error("ffi-bind: <BYTE>ptr wants a PtrArrayBuffer (new PtrArrayBuffer(n) / BYTE.alloc / struct.encode), not a plain ArrayBuffer");
|
|
15958
|
+
return v;
|
|
15959
|
+
},
|
|
15960
|
+
alloc: (byteLen) => new PtrArrayBuffer(byteLen)
|
|
15961
|
+
};
|
|
15962
|
+
var builtinCodecs = { WCHAR, BYTE };
|
|
15963
|
+
function bind(dll, name, sig, encoders, decoders) {
|
|
15964
|
+
const proc = win.GetProcAddress(loadDll(dll), name);
|
|
15965
|
+
if (!proc)
|
|
15966
|
+
throw new Error(`ffi-bind: proc "${name}" not found in ${dll}`);
|
|
15967
|
+
const effDec = decoders ?? encoders;
|
|
15968
|
+
return makeFn(proc, sig, { ...builtinCodecs, ...encoders }, { ...builtinCodecs, ...effDec ?? {} });
|
|
15969
|
+
}
|
|
15970
|
+
var leakRegistry = new FinalizationRegistry((held) => {
|
|
15971
|
+
std.printf('[ffi] closure leaked (GCed without dispose): sig="%s" ptr=0x%x\n', held.sig, held.ptr);
|
|
15972
|
+
});
|
|
15973
|
+
|
|
15974
|
+
// _build/lib/ffi/struct.js
|
|
15975
|
+
import * as ffi2 from "ffi";
|
|
15976
|
+
function alignUp(v, a) {
|
|
15977
|
+
return v + a - 1 & ~(a - 1);
|
|
15978
|
+
}
|
|
15979
|
+
var isCNumberToken = (t) => SizeAlign[t] !== void 0;
|
|
15980
|
+
function lower(v) {
|
|
15981
|
+
if (typeof v === "string") {
|
|
15982
|
+
const st = /^(u8|u16)\[(\d+)\]@(utf-8|utf-16le)$/.exec(v);
|
|
15983
|
+
if (st) {
|
|
15984
|
+
const length = Number(st[2]);
|
|
15985
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15986
|
+
throw new Error(`ffi-struct: string length must be an integer >= 1, got ${length}`);
|
|
15987
|
+
const s2 = st[1] === "u8" ? 1 : 2;
|
|
15988
|
+
return { size: s2 * length, align: s2, type: { tag: "string", encoding: st[3] } };
|
|
15989
|
+
}
|
|
15990
|
+
const a = /^([^\[\]]+)\[(\d+)\]$/.exec(v);
|
|
15991
|
+
if (a) {
|
|
15992
|
+
const length = Number(a[2]);
|
|
15993
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15994
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${length}`);
|
|
15995
|
+
const el = lower(a[1]);
|
|
15996
|
+
if (el.type.tag === "bitfield")
|
|
15997
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
15998
|
+
return {
|
|
15999
|
+
size: el.size * length,
|
|
16000
|
+
align: el.align,
|
|
16001
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
16002
|
+
};
|
|
16003
|
+
}
|
|
16004
|
+
const b6 = /^([A-Za-z_]\w*):(\d+)$/.exec(v);
|
|
16005
|
+
if (b6) {
|
|
16006
|
+
const rawUnit = b6[1];
|
|
16007
|
+
const unit = normToken(rawUnit);
|
|
16008
|
+
if (!isCNumberToken(unit) || unit === "f32" || unit === "f64")
|
|
16009
|
+
throw new Error(`ffi-struct: bitfield unit must be an integer type, got "${rawUnit}"`);
|
|
16010
|
+
const width = Number(b6[2]);
|
|
16011
|
+
const s2 = SizeAlign[unit];
|
|
16012
|
+
const cap = s2 * 8;
|
|
16013
|
+
if (!Number.isInteger(width) || width < 1)
|
|
16014
|
+
throw new Error(`ffi-struct: bitfield width must be an integer >= 1, got ${width}`);
|
|
16015
|
+
if (width > cap)
|
|
16016
|
+
throw new Error(`ffi-struct: bitfield width ${width} exceeds unit width ${cap}`);
|
|
16017
|
+
return { size: s2, align: s2, type: { tag: "bitfield", unit, bit: 0, width } };
|
|
16018
|
+
}
|
|
16019
|
+
const k = normToken(v);
|
|
16020
|
+
if (isCPtrToken(k))
|
|
16021
|
+
return { size: PTR_SIZE, align: PTR_SIZE, type: { tag: "basic", kind: "ptr" } };
|
|
16022
|
+
if (!isCNumberToken(k))
|
|
16023
|
+
throw new Error(`ffi-struct: unknown kind "${v}"`);
|
|
16024
|
+
const s = SizeAlign[k];
|
|
16025
|
+
return { size: s, align: s, type: { tag: "basic", kind: k } };
|
|
15812
16026
|
}
|
|
15813
|
-
|
|
16027
|
+
if (v && typeof v === "object") {
|
|
16028
|
+
const o = v;
|
|
16029
|
+
const tag = o["#"];
|
|
16030
|
+
if (tag === void 0)
|
|
16031
|
+
throw new Error(`ffi-struct: nested object value requires a '#' key ('struct' | 'union' | 'array')`);
|
|
16032
|
+
if (tag === "array" && "#pack" in o)
|
|
16033
|
+
throw new Error(`ffi-struct: '#pack' is only allowed on struct/union, got '${tag}'`);
|
|
16034
|
+
if (tag === "array") {
|
|
16035
|
+
const length = o["length"];
|
|
16036
|
+
if (!Number.isInteger(length) || length < 1)
|
|
16037
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${String(length)}`);
|
|
16038
|
+
const el = lower(o["element"]);
|
|
16039
|
+
if (el.type.tag === "bitfield")
|
|
16040
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
16041
|
+
return {
|
|
16042
|
+
size: el.size * length,
|
|
16043
|
+
align: el.align,
|
|
16044
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
16045
|
+
};
|
|
16046
|
+
}
|
|
16047
|
+
if (tag === "struct" || tag === "union") {
|
|
16048
|
+
const l = computeStructLayout(v);
|
|
16049
|
+
return { size: l.size, align: l.maxEffectiveAlign, type: { tag, fields: l.fields } };
|
|
16050
|
+
}
|
|
16051
|
+
throw new Error(`ffi-struct: unknown '#' declaration ${JSON.stringify(String(tag))}`);
|
|
16052
|
+
}
|
|
16053
|
+
throw new Error(`ffi-struct: invalid member value: ${String(v)}`);
|
|
16054
|
+
}
|
|
16055
|
+
function computeStructLayout(t) {
|
|
16056
|
+
const isStruct = t["#"] === "struct";
|
|
16057
|
+
const pack = t["#pack"] ?? 8;
|
|
16058
|
+
let maxEffectiveAlign = 1;
|
|
16059
|
+
let maxMemberSize = 0;
|
|
16060
|
+
const fields = [];
|
|
16061
|
+
let cursor = 0;
|
|
16062
|
+
let unitBase = -1;
|
|
16063
|
+
let unitBits = 0;
|
|
16064
|
+
let unitSize = 0;
|
|
16065
|
+
const flushUnit = () => {
|
|
16066
|
+
if (unitBase < 0)
|
|
16067
|
+
return;
|
|
16068
|
+
cursor = alignUp(unitBase + Math.ceil(unitBits / 8), unitSize);
|
|
16069
|
+
unitBase = -1;
|
|
16070
|
+
};
|
|
16071
|
+
for (const [rawName, v] of Object.entries(t)) {
|
|
16072
|
+
if (rawName.startsWith("#"))
|
|
16073
|
+
continue;
|
|
16074
|
+
const m = /^([^@]+)@(\d+)$/.exec(rawName);
|
|
16075
|
+
const name = m ? m[1] : rawName;
|
|
16076
|
+
const alignas = m ? Number(m[2]) : 0;
|
|
16077
|
+
const { size, align: natural, type } = lower(v);
|
|
16078
|
+
const nonnull = typeof v === "string" && v.endsWith("!");
|
|
16079
|
+
let align = natural;
|
|
16080
|
+
if (pack > 0)
|
|
16081
|
+
align = Math.min(pack, align);
|
|
16082
|
+
if (alignas)
|
|
16083
|
+
align = Math.max(align, alignas);
|
|
16084
|
+
if (type.tag === "bitfield") {
|
|
16085
|
+
if (name.startsWith("$"))
|
|
16086
|
+
throw new Error("ffi-struct: bitfield members must be named");
|
|
16087
|
+
if (!isStruct) {
|
|
16088
|
+
fields.push({ name, offset: 0, size, type: { ...type, bit: 0 } });
|
|
16089
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16090
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16091
|
+
continue;
|
|
16092
|
+
}
|
|
16093
|
+
const width = type.width;
|
|
16094
|
+
if (unitBase < 0 || size !== unitSize || unitBits + width > unitSize * 8) {
|
|
16095
|
+
if (unitBase >= 0)
|
|
16096
|
+
flushUnit();
|
|
16097
|
+
const offset2 = alignUp(cursor, align);
|
|
16098
|
+
unitBase = offset2;
|
|
16099
|
+
unitBits = 0;
|
|
16100
|
+
unitSize = size;
|
|
16101
|
+
}
|
|
16102
|
+
fields.push({
|
|
16103
|
+
name,
|
|
16104
|
+
offset: unitBase,
|
|
16105
|
+
// 单元基址(不是位域自己的地址)
|
|
16106
|
+
size,
|
|
16107
|
+
type: { ...type, bit: unitBits }
|
|
16108
|
+
});
|
|
16109
|
+
unitBits += width;
|
|
16110
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16111
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16112
|
+
continue;
|
|
16113
|
+
}
|
|
16114
|
+
flushUnit();
|
|
16115
|
+
const offset = alignUp(cursor, align);
|
|
16116
|
+
if (!name.startsWith("$")) {
|
|
16117
|
+
fields.push({ name, offset, size, type, ...nonnull ? { nonnull: true } : {} });
|
|
16118
|
+
} else {
|
|
16119
|
+
if (type.tag !== "struct" && type.tag !== "union")
|
|
16120
|
+
throw new Error(`ffi-struct: anonymous member "${name}" must be a struct/union`);
|
|
16121
|
+
for (const cf of type.fields)
|
|
16122
|
+
fields.push({ ...cf, offset: cf.offset + offset });
|
|
16123
|
+
}
|
|
16124
|
+
if (isStruct)
|
|
16125
|
+
cursor = offset + size;
|
|
16126
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16127
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16128
|
+
}
|
|
16129
|
+
flushUnit();
|
|
16130
|
+
return {
|
|
16131
|
+
size: isStruct ? alignUp(cursor, maxEffectiveAlign) : alignUp(maxMemberSize, maxEffectiveAlign),
|
|
16132
|
+
maxEffectiveAlign,
|
|
16133
|
+
fields
|
|
16134
|
+
};
|
|
16135
|
+
}
|
|
16136
|
+
function readUnitRaw(dv, off, unit) {
|
|
16137
|
+
const s = SizeAlign[unit];
|
|
16138
|
+
if (s === 1)
|
|
16139
|
+
return BigInt(dv.getUint8(off));
|
|
16140
|
+
if (s === 2)
|
|
16141
|
+
return BigInt(dv.getUint16(off, true));
|
|
16142
|
+
if (s === 4)
|
|
16143
|
+
return BigInt(dv.getUint32(off, true));
|
|
16144
|
+
return dv.getBigUint64(off, true);
|
|
16145
|
+
}
|
|
16146
|
+
function writeUnitRaw(dv, off, unit, v) {
|
|
16147
|
+
const s = SizeAlign[unit];
|
|
16148
|
+
if (s === 1) {
|
|
16149
|
+
dv.setUint8(off, Number(v & 0xffn));
|
|
16150
|
+
return;
|
|
16151
|
+
}
|
|
16152
|
+
if (s === 2) {
|
|
16153
|
+
dv.setUint16(off, Number(v & 0xffffn), true);
|
|
16154
|
+
return;
|
|
16155
|
+
}
|
|
16156
|
+
if (s === 4) {
|
|
16157
|
+
dv.setUint32(off, Number(v & 0xffffffffn), true);
|
|
16158
|
+
return;
|
|
16159
|
+
}
|
|
16160
|
+
dv.setBigUint64(off, v & 0xffffffffffffffffn, true);
|
|
16161
|
+
}
|
|
16162
|
+
function readBitfield(dv, off, t) {
|
|
16163
|
+
const w = BigInt(t.width);
|
|
16164
|
+
let v = readUnitRaw(dv, off, t.unit) >> BigInt(t.bit) & (1n << w) - 1n;
|
|
16165
|
+
if (t.unit[0] === "i" && v & 1n << w - 1n)
|
|
16166
|
+
v -= 1n << w;
|
|
16167
|
+
if (t.width > 53)
|
|
16168
|
+
return v;
|
|
16169
|
+
return Number(v);
|
|
16170
|
+
}
|
|
16171
|
+
function writeBitfield(dv, off, t, val) {
|
|
16172
|
+
const w = BigInt(t.width);
|
|
16173
|
+
const bit = BigInt(t.bit);
|
|
16174
|
+
const widthMask = (1n << w) - 1n;
|
|
16175
|
+
const posMask = widthMask << bit;
|
|
16176
|
+
const raw = readUnitRaw(dv, off, t.unit);
|
|
16177
|
+
const bits = (typeof val === "bigint" ? val : BigInt(Math.trunc(val))) & widthMask;
|
|
16178
|
+
writeUnitRaw(dv, off, t.unit, raw & ~posMask | bits << bit);
|
|
16179
|
+
}
|
|
16180
|
+
var stringEncoders = {
|
|
16181
|
+
"utf-8": new TextEncoder("utf-8"),
|
|
16182
|
+
"utf-16le": new TextEncoder("utf-16le")
|
|
16183
|
+
};
|
|
16184
|
+
var stringDecoders = {
|
|
16185
|
+
"utf-8": new TextDecoder("utf-8", { ignoreBOM: true }),
|
|
16186
|
+
"utf-16le": new TextDecoder("utf-16le", { ignoreBOM: true })
|
|
16187
|
+
};
|
|
16188
|
+
function readString(dv, off, size, enc) {
|
|
16189
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16190
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16191
|
+
let end = size;
|
|
16192
|
+
for (let i = 0; i + unit <= size; i += unit) {
|
|
16193
|
+
if (bytes[i] === 0 && (unit === 1 || bytes[i + 1] === 0)) {
|
|
16194
|
+
end = i;
|
|
16195
|
+
break;
|
|
16196
|
+
}
|
|
16197
|
+
}
|
|
16198
|
+
return stringDecoders[enc].decode(bytes.subarray(0, end));
|
|
16199
|
+
}
|
|
16200
|
+
function writeString(dv, off, size, enc, v) {
|
|
16201
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16202
|
+
bytes.fill(0);
|
|
16203
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16204
|
+
const cap = size - unit;
|
|
16205
|
+
if (cap <= 0)
|
|
16206
|
+
return;
|
|
16207
|
+
const src = stringEncoders[enc].encode(String(v ?? ""));
|
|
16208
|
+
bytes.set(src.subarray(0, Math.min(src.length, cap)));
|
|
16209
|
+
}
|
|
16210
|
+
function readArray(dv, off, size, t) {
|
|
16211
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16212
|
+
const out = [];
|
|
16213
|
+
for (let i = 0; i < count; i++)
|
|
16214
|
+
out.push(readElement(dv, off + i * t.elementSize, t.elementType, t.elementSize));
|
|
16215
|
+
return out;
|
|
16216
|
+
}
|
|
16217
|
+
function writeArray(dv, off, size, t, v) {
|
|
16218
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16219
|
+
const list = v ?? [];
|
|
16220
|
+
for (let i = 0; i < count; i++)
|
|
16221
|
+
writeElement(dv, off + i * t.elementSize, t.elementType, t.elementSize, list[i]);
|
|
16222
|
+
}
|
|
16223
|
+
function readElement(dv, off, t, size) {
|
|
16224
|
+
switch (t.tag) {
|
|
16225
|
+
case "basic":
|
|
16226
|
+
return readScalar(dv, off, t.kind);
|
|
16227
|
+
case "bitfield":
|
|
16228
|
+
return readBitfield(dv, off, t);
|
|
16229
|
+
case "string":
|
|
16230
|
+
return readString(dv, off, size, t.encoding);
|
|
16231
|
+
case "struct":
|
|
16232
|
+
case "union":
|
|
16233
|
+
return doDecode(dv, off, t.fields);
|
|
16234
|
+
case "array":
|
|
16235
|
+
return readArray(dv, off, size, t);
|
|
16236
|
+
}
|
|
16237
|
+
}
|
|
16238
|
+
function writeElement(dv, off, t, size, val) {
|
|
16239
|
+
switch (t.tag) {
|
|
16240
|
+
// TODO: remove this any
|
|
16241
|
+
case "basic":
|
|
16242
|
+
writeScalar(dv, off, { k: t.kind, v: val });
|
|
16243
|
+
break;
|
|
16244
|
+
// 直传(不 Number()):writeBitfield 的 val 是 number | bigint,
|
|
16245
|
+
// 64 位单元走 bigint,先 Number() 会把 >2^53 的位域值截断。
|
|
16246
|
+
case "bitfield":
|
|
16247
|
+
writeBitfield(dv, off, t, val ?? 0);
|
|
16248
|
+
break;
|
|
16249
|
+
case "string":
|
|
16250
|
+
writeString(dv, off, size, t.encoding, val);
|
|
16251
|
+
break;
|
|
16252
|
+
case "struct":
|
|
16253
|
+
case "union":
|
|
16254
|
+
doEncode(dv, off, t.fields, val ?? {});
|
|
16255
|
+
break;
|
|
16256
|
+
case "array":
|
|
16257
|
+
writeArray(dv, off, size, t, val);
|
|
16258
|
+
break;
|
|
16259
|
+
}
|
|
16260
|
+
}
|
|
16261
|
+
function doDecode(dv, base, fields) {
|
|
16262
|
+
const out = {};
|
|
16263
|
+
for (const f of fields) {
|
|
16264
|
+
const v = readElement(dv, base + f.offset, f.type, f.size);
|
|
16265
|
+
if (f.nonnull && v === 0)
|
|
16266
|
+
throw new Error(`ffi-struct: decode: '!' field "${f.name}" got 0 (C did not fill it, or decode was called on an unfilled slot)`);
|
|
16267
|
+
out[f.name] = v;
|
|
16268
|
+
}
|
|
16269
|
+
return out;
|
|
16270
|
+
}
|
|
16271
|
+
function doEncode(dv, base, fields, v) {
|
|
16272
|
+
for (const f of fields) {
|
|
16273
|
+
if (v[f.name] === void 0)
|
|
16274
|
+
continue;
|
|
16275
|
+
writeElement(dv, base + f.offset, f.type, f.size, v[f.name]);
|
|
16276
|
+
}
|
|
16277
|
+
}
|
|
16278
|
+
function createStruct(t) {
|
|
16279
|
+
const { fields, size, maxEffectiveAlign } = computeStructLayout(t);
|
|
16280
|
+
return {
|
|
16281
|
+
__struct: t,
|
|
16282
|
+
size,
|
|
16283
|
+
structAlign: maxEffectiveAlign,
|
|
16284
|
+
decode: (p) => {
|
|
16285
|
+
if (typeof p === "number")
|
|
16286
|
+
return doDecode(new DataView(ffi2.readBytes(p, size)), 0, fields);
|
|
16287
|
+
return doDecode(new DataView(p), 0, fields);
|
|
16288
|
+
},
|
|
16289
|
+
alloc: ((n) => {
|
|
16290
|
+
if (n !== void 0 && (!Number.isInteger(n) || n < 1))
|
|
16291
|
+
throw new Error(`ffi-struct: alloc(n) requires an integer n >= 1 (PAB(0) never escapes \u2014 pass NULL for an empty pointer position)`);
|
|
16292
|
+
return new PtrArrayBuffer(size * (n ?? 1));
|
|
16293
|
+
}),
|
|
16294
|
+
encode: ((v, buf, offset) => {
|
|
16295
|
+
if (v === void 0 || v === null)
|
|
16296
|
+
throw new Error(`ffi-struct: encode(v) requires an argument; use alloc() for a zeroed out-param slot`);
|
|
16297
|
+
const out = buf ?? new PtrArrayBuffer(size);
|
|
16298
|
+
doEncode(new DataView(out), offset ?? 0, fields, v);
|
|
16299
|
+
return out;
|
|
16300
|
+
}),
|
|
16301
|
+
offsetOf: (name) => {
|
|
16302
|
+
for (const f of fields)
|
|
16303
|
+
if (f.name === name)
|
|
16304
|
+
return f.offset;
|
|
16305
|
+
throw new Error(`ffi-struct: no field "${name}"`);
|
|
16306
|
+
}
|
|
16307
|
+
};
|
|
16308
|
+
}
|
|
16309
|
+
function buildDecl(kind, member, pack) {
|
|
16310
|
+
const decl = { "#": kind };
|
|
16311
|
+
if (pack !== void 0)
|
|
16312
|
+
decl["#pack"] = pack;
|
|
16313
|
+
for (const [k, v] of Object.entries(member))
|
|
16314
|
+
if (!k.startsWith("#"))
|
|
16315
|
+
decl[k] = v;
|
|
16316
|
+
return decl;
|
|
16317
|
+
}
|
|
16318
|
+
function structArray(def) {
|
|
16319
|
+
const { fields, size } = computeStructLayout(def.__struct);
|
|
16320
|
+
const readN = (dv, n) => {
|
|
16321
|
+
const out = [];
|
|
16322
|
+
for (let i = 0; i < n; i++)
|
|
16323
|
+
out.push(doDecode(dv, i * size, fields));
|
|
16324
|
+
return out;
|
|
16325
|
+
};
|
|
16326
|
+
return {
|
|
16327
|
+
encode: (els) => {
|
|
16328
|
+
if (!Array.isArray(els) || els.length === 0)
|
|
16329
|
+
throw new Error(`ffi-struct: structArray(def).encode(els) requires a non-empty element array (pass NULL for an empty pointer position)`);
|
|
16330
|
+
const out = def.alloc(els.length);
|
|
16331
|
+
for (let i = 0; i < els.length; i++)
|
|
16332
|
+
def.encode(els[i], out, i * def.size);
|
|
16333
|
+
return out;
|
|
16334
|
+
},
|
|
16335
|
+
decode: ((p, count) => {
|
|
16336
|
+
if (count !== void 0 && (!Number.isInteger(count) || count < 0))
|
|
16337
|
+
throw new Error(`ffi-struct: structArray.decode(p, count) requires a non-negative integer count, got ${count}`);
|
|
16338
|
+
if (typeof p === "number") {
|
|
16339
|
+
if (count === void 0)
|
|
16340
|
+
throw new Error(`ffi-struct: structArray.decode(address, count) requires an explicit count (a bare address carries no length)`);
|
|
16341
|
+
if (count === 0)
|
|
16342
|
+
return [];
|
|
16343
|
+
return readN(new DataView(ffi2.readBytes(p, count * size)), count);
|
|
16344
|
+
}
|
|
16345
|
+
let n;
|
|
16346
|
+
if (count !== void 0) {
|
|
16347
|
+
n = count;
|
|
16348
|
+
if (n * size > p.byteLength)
|
|
16349
|
+
throw new Error(`ffi-struct: structArray.decode: count ${n} \xD7 size ${size} = ${n * size} exceeds buffer byteLength ${p.byteLength}`);
|
|
16350
|
+
} else {
|
|
16351
|
+
if (p.byteLength % size !== 0)
|
|
16352
|
+
throw new Error(`ffi-struct: structArray.decode: byteLength ${p.byteLength} is not a multiple of size ${size} (mixed buffer? pass count explicitly)`);
|
|
16353
|
+
n = p.byteLength / size;
|
|
16354
|
+
}
|
|
16355
|
+
if (n === 0)
|
|
16356
|
+
return [];
|
|
16357
|
+
return readN(new DataView(p), n);
|
|
16358
|
+
})
|
|
16359
|
+
};
|
|
16360
|
+
}
|
|
16361
|
+
function struct(a, b6, c) {
|
|
16362
|
+
const isNamed = typeof a === "string";
|
|
16363
|
+
const raw = isNamed ? b6 : a;
|
|
16364
|
+
const opts = isNamed ? c : b6;
|
|
16365
|
+
return createStruct(buildDecl("struct", raw, opts?.pack));
|
|
16366
|
+
}
|
|
16367
|
+
|
|
16368
|
+
// _build/lib/windows/structs.js
|
|
16369
|
+
var RECT = /* @__PURE__ */ struct("RECT", {
|
|
16370
|
+
left: "i32",
|
|
16371
|
+
top: "i32",
|
|
16372
|
+
right: "i32",
|
|
16373
|
+
bottom: "i32"
|
|
16374
|
+
});
|
|
16375
|
+
var POINT = /* @__PURE__ */ struct("POINT", {
|
|
16376
|
+
x: "i32",
|
|
16377
|
+
y: "i32"
|
|
16378
|
+
});
|
|
16379
|
+
var SIZE = /* @__PURE__ */ struct("SIZE", {
|
|
16380
|
+
cx: "i32",
|
|
16381
|
+
cy: "i32"
|
|
16382
|
+
});
|
|
16383
|
+
var LOGFONTW = /* @__PURE__ */ struct("LOGFONTW", {
|
|
16384
|
+
lfHeight: "i32",
|
|
16385
|
+
lfWidth: "i32",
|
|
16386
|
+
lfEscapement: "i32",
|
|
16387
|
+
lfOrientation: "i32",
|
|
16388
|
+
lfWeight: "i32",
|
|
16389
|
+
lfItalic: "u8",
|
|
16390
|
+
lfUnderline: "u8",
|
|
16391
|
+
lfStrikeOut: "u8",
|
|
16392
|
+
lfCharSet: "u8",
|
|
16393
|
+
lfOutPrecision: "u8",
|
|
16394
|
+
lfClipPrecision: "u8",
|
|
16395
|
+
lfQuality: "u8",
|
|
16396
|
+
lfPitchAndFamily: "u8",
|
|
16397
|
+
lfFaceName: "u16[32]@utf-16le"
|
|
16398
|
+
});
|
|
16399
|
+
var OPENFILENAMEW = /* @__PURE__ */ struct("OPENFILENAMEW", {
|
|
16400
|
+
lStructSize: "u32",
|
|
16401
|
+
hwndOwner: "<HWND>ptr",
|
|
16402
|
+
hInstance: "<HMODULE>ptr",
|
|
16403
|
+
lpstrFilter: "<>ptr",
|
|
16404
|
+
lpstrCustomFilter: "<>ptr",
|
|
16405
|
+
nMaxCustFilter: "u32",
|
|
16406
|
+
nFilterIndex: "u32",
|
|
16407
|
+
lpstrFile: "<>ptr",
|
|
16408
|
+
nMaxFile: "u32",
|
|
16409
|
+
lpstrFileTitle: "<>ptr",
|
|
16410
|
+
nMaxFileTitle: "u32",
|
|
16411
|
+
lpstrInitialDir: "<>ptr",
|
|
16412
|
+
lpstrTitle: "<>ptr",
|
|
16413
|
+
Flags: "u32",
|
|
16414
|
+
nFileOffset: "u16",
|
|
16415
|
+
nFileExtension: "u16",
|
|
16416
|
+
lpstrDefExt: "<>ptr",
|
|
16417
|
+
lCustData: "<>ptr",
|
|
16418
|
+
lpfnHook: "<>ptr",
|
|
16419
|
+
lpTemplateName: "<>ptr",
|
|
16420
|
+
pvReserved: "<>ptr",
|
|
16421
|
+
dwReserved: "u32",
|
|
16422
|
+
FlagsEx: "u32"
|
|
16423
|
+
});
|
|
16424
|
+
var BROWSEINFOW = /* @__PURE__ */ struct("BROWSEINFOW", {
|
|
16425
|
+
hwndOwner: "<HWND>ptr",
|
|
16426
|
+
pidlRoot: "<>ptr",
|
|
16427
|
+
pszDisplayName: "<>ptr",
|
|
16428
|
+
lpszTitle: "<>ptr",
|
|
16429
|
+
ulFlags: "u32",
|
|
16430
|
+
lpfn: "<>ptr",
|
|
16431
|
+
lParam: "<>ptr",
|
|
16432
|
+
iImage: "i32"
|
|
16433
|
+
});
|
|
16434
|
+
var NMHDR = /* @__PURE__ */ struct("NMHDR", {
|
|
16435
|
+
hwndFrom: "<HWND>ptr",
|
|
16436
|
+
idFrom: "<>ptr",
|
|
16437
|
+
code: "i32"
|
|
16438
|
+
});
|
|
16439
|
+
var SYSTEMTIME = /* @__PURE__ */ struct("SYSTEMTIME", {
|
|
16440
|
+
wYear: "u16",
|
|
16441
|
+
wMonth: "u16",
|
|
16442
|
+
wDayOfWeek: "u16",
|
|
16443
|
+
wDay: "u16",
|
|
16444
|
+
wHour: "u16",
|
|
16445
|
+
wMinute: "u16",
|
|
16446
|
+
wSecond: "u16",
|
|
16447
|
+
wMilliseconds: "u16"
|
|
16448
|
+
});
|
|
16449
|
+
var NMDATETIMECHANGE = /* @__PURE__ */ struct("NMDATETIMECHANGE", {
|
|
16450
|
+
hdr: NMHDR.__struct,
|
|
16451
|
+
dwFlags: "u32",
|
|
16452
|
+
st: SYSTEMTIME.__struct
|
|
16453
|
+
});
|
|
16454
|
+
var LITEM = /* @__PURE__ */ struct("LITEM", {
|
|
16455
|
+
mask: "u32",
|
|
16456
|
+
iLink: "i32",
|
|
16457
|
+
state: "u32",
|
|
16458
|
+
stateMask: "u32",
|
|
16459
|
+
szID: "u16[48]@utf-16le",
|
|
16460
|
+
szUrl: "u16[2084]@utf-16le"
|
|
16461
|
+
});
|
|
16462
|
+
var NMLINK = /* @__PURE__ */ struct("NMLINK", {
|
|
16463
|
+
hdr: NMHDR.__struct,
|
|
16464
|
+
item: LITEM.__struct
|
|
16465
|
+
});
|
|
16466
|
+
var NMCUSTOMDRAW = /* @__PURE__ */ struct("NMCUSTOMDRAW", {
|
|
16467
|
+
hdr: NMHDR.__struct,
|
|
16468
|
+
dwDrawStage: "u32",
|
|
16469
|
+
hdc: "<HDC>ptr",
|
|
16470
|
+
rc: "i32[4]",
|
|
16471
|
+
dwItemSpec: "<>ptr",
|
|
16472
|
+
uItemState: "u32",
|
|
16473
|
+
lItemlParam: "<>ptr"
|
|
16474
|
+
});
|
|
16475
|
+
var NMLVCUSTOMDRAW = /* @__PURE__ */ struct("NMLVCUSTOMDRAW", {
|
|
16476
|
+
hdr: NMHDR.__struct,
|
|
16477
|
+
dwDrawStage: "u32",
|
|
16478
|
+
hdc: "<HDC>ptr",
|
|
16479
|
+
rc: "i32[4]",
|
|
16480
|
+
dwItemSpec: "<>ptr",
|
|
16481
|
+
uItemState: "u32",
|
|
16482
|
+
lItemlParam: "<>ptr",
|
|
16483
|
+
clrText: "u32",
|
|
16484
|
+
clrTextBk: "u32",
|
|
16485
|
+
iSubItem: "i32",
|
|
16486
|
+
dwItemType: "u32"
|
|
16487
|
+
});
|
|
16488
|
+
var NMLISTVIEW = /* @__PURE__ */ struct("NMLISTVIEW", {
|
|
16489
|
+
hdr: NMHDR.__struct,
|
|
16490
|
+
iItem: "i32",
|
|
16491
|
+
iSubItem: "i32",
|
|
16492
|
+
uNewState: "u32",
|
|
16493
|
+
uOldState: "u32",
|
|
16494
|
+
uChanged: "u32",
|
|
16495
|
+
ptAction: "i32[2]",
|
|
16496
|
+
lParam: "<>ptr"
|
|
16497
|
+
});
|
|
16498
|
+
var TCITEMW = /* @__PURE__ */ struct("TCITEMW", {
|
|
16499
|
+
mask: "u32",
|
|
16500
|
+
dwState: "u32",
|
|
16501
|
+
dwStateMask: "u32",
|
|
16502
|
+
pszText: "<>ptr",
|
|
16503
|
+
cchTextMax: "i32",
|
|
16504
|
+
iImage: "i32",
|
|
16505
|
+
lParam: "<>ptr"
|
|
16506
|
+
});
|
|
16507
|
+
var TVITEM = /* @__PURE__ */ struct("TVITEM", {
|
|
16508
|
+
mask: "u32",
|
|
16509
|
+
hItem: "<>ptr",
|
|
16510
|
+
state: "u32",
|
|
16511
|
+
stateMask: "u32",
|
|
16512
|
+
pszText: "<>ptr",
|
|
16513
|
+
cchTextMax: "i32",
|
|
16514
|
+
iImage: "i32",
|
|
16515
|
+
iSelectedImage: "i32",
|
|
16516
|
+
cChildren: "i32",
|
|
16517
|
+
lParam: "<>ptr"
|
|
16518
|
+
});
|
|
16519
|
+
var TVINSERTSTRUCT = /* @__PURE__ */ struct("TVINSERTSTRUCT", {
|
|
16520
|
+
hParent: "<>ptr",
|
|
16521
|
+
hInsertAfter: "<>ptr",
|
|
16522
|
+
item: TVITEM.__struct
|
|
16523
|
+
});
|
|
16524
|
+
var LVHITTESTINFO = /* @__PURE__ */ struct("LVHITTESTINFO", {
|
|
16525
|
+
pt: "i32[2]",
|
|
16526
|
+
flags: "u32",
|
|
16527
|
+
iItem: "i32",
|
|
16528
|
+
iSubItem: "i32",
|
|
16529
|
+
iGroup: "i32"
|
|
16530
|
+
});
|
|
16531
|
+
var LVITEMW = /* @__PURE__ */ struct("LVITEMW", {
|
|
16532
|
+
mask: "u32",
|
|
16533
|
+
iItem: "i32",
|
|
16534
|
+
iSubItem: "i32",
|
|
16535
|
+
state: "u32",
|
|
16536
|
+
stateMask: "u32",
|
|
16537
|
+
pszText: "<>ptr",
|
|
16538
|
+
cchTextMax: "i32",
|
|
16539
|
+
iImage: "i32",
|
|
16540
|
+
lParam: "<>ptr",
|
|
16541
|
+
iIndent: "i32",
|
|
16542
|
+
iGroupId: "i32",
|
|
16543
|
+
cColumns: "u32",
|
|
16544
|
+
puColumns: "<>ptr",
|
|
16545
|
+
piColFmt: "<>ptr",
|
|
16546
|
+
iGroup: "i32"
|
|
16547
|
+
});
|
|
16548
|
+
var LVCOLUMNW = /* @__PURE__ */ struct("LVCOLUMNW", {
|
|
16549
|
+
mask: "u32",
|
|
16550
|
+
fmt: "i32",
|
|
16551
|
+
cx: "i32",
|
|
16552
|
+
pszText: "<>ptr",
|
|
16553
|
+
cchTextMax: "i32",
|
|
16554
|
+
iSubItem: "i32",
|
|
16555
|
+
iImage: "i32",
|
|
16556
|
+
iOrder: "i32",
|
|
16557
|
+
cxMin: "i32",
|
|
16558
|
+
cxDefault: "i32",
|
|
16559
|
+
cxIdeal: "i32"
|
|
16560
|
+
});
|
|
16561
|
+
var MSG = /* @__PURE__ */ struct("MSG", {
|
|
16562
|
+
hwnd: "<HWND>ptr",
|
|
16563
|
+
message: "u32",
|
|
16564
|
+
wParam: "<>ptr",
|
|
16565
|
+
lParam: "<>ptr",
|
|
16566
|
+
time: "u32",
|
|
16567
|
+
pt: POINT.__struct
|
|
16568
|
+
});
|
|
16569
|
+
var PAINTSTRUCT = /* @__PURE__ */ struct("PAINTSTRUCT", {
|
|
16570
|
+
hdc: "<HDC>ptr",
|
|
16571
|
+
fErase: "i32",
|
|
16572
|
+
rcPaint: RECT.__struct,
|
|
16573
|
+
fRestore: "i32",
|
|
16574
|
+
fIncUpdate: "i32",
|
|
16575
|
+
rgbReserved: "u8[32]"
|
|
16576
|
+
});
|
|
16577
|
+
|
|
16578
|
+
// _build/lib/windows/user32.js
|
|
16579
|
+
var b = (name, sig, encoders) => bind("user32.dll", name, sig, encoders);
|
|
16580
|
+
var _bProbe = b("GetDesktopWindow", " -> <HWND>ptr");
|
|
16581
|
+
var LONG_PTR_SYM = os3.arch === "x64" ? "PtrW" : "W";
|
|
16582
|
+
var SetWindowPos = /* @__PURE__ */ b("SetWindowPos", "<HWND>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32");
|
|
16583
|
+
var SetWindowText = /* @__PURE__ */ b("SetWindowTextW", "<HWND>ptr <WCHAR>ptr -> i32");
|
|
16584
|
+
var GetWindowLongPtr = /* @__PURE__ */ b("GetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp -> <>ptr");
|
|
16585
|
+
var SetWindowLongPtr = /* @__PURE__ */ b("SetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp <>ptr -> <>ptr");
|
|
16586
|
+
var EnableWindow = /* @__PURE__ */ b("EnableWindow", "<HWND>ptr i32 -> i32");
|
|
16587
|
+
var SetParent = /* @__PURE__ */ b("SetParent", "<HWND>ptr <HWND>ptr -> <HWND>ptr");
|
|
16588
|
+
var DefWindowProc = /* @__PURE__ */ b("DefWindowProcW", "<HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16589
|
+
var CallWindowProc = /* @__PURE__ */ b("CallWindowProcW", "<>ptr <HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16590
|
+
var GetDC = /* @__PURE__ */ b("GetDC", "<HWND>ptr -> <HDC>ptr");
|
|
16591
|
+
var ReleaseDC = /* @__PURE__ */ b("ReleaseDC", "<HWND>ptr <HDC>ptr! -> i32");
|
|
16592
|
+
var DrawText = /* @__PURE__ */ b("DrawTextW", "<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32");
|
|
16593
|
+
var InvalidateRect = /* @__PURE__ */ b("InvalidateRect", "<HWND>ptr <RECT>ptr i32 -> i32", { RECT });
|
|
16594
|
+
var SetCursor = /* @__PURE__ */ b("SetCursor", "<HCURSOR>ptr -> <HCURSOR>ptr");
|
|
16595
|
+
var LoadCursor = /* @__PURE__ */ b("LoadCursorW", "<HMODULE>ptr <>ptr -> <HCURSOR>ptr");
|
|
16596
|
+
var GetCursorPos = /* @__PURE__ */ b("GetCursorPos", "<POINT>ptr -> i32");
|
|
16597
|
+
var ScreenToClient = /* @__PURE__ */ b("ScreenToClient", "<HWND>ptr <POINT>ptr -> i32");
|
|
16598
|
+
var ShowScrollBar = /* @__PURE__ */ b("ShowScrollBar", "<HWND>ptr u32 i32 -> i32");
|
|
16599
|
+
var GetSystemMetrics = /* @__PURE__ */ b("GetSystemMetrics", "i32 -> i32");
|
|
16600
|
+
|
|
16601
|
+
// _build/lib/react-qw/reconciler.js
|
|
16602
|
+
var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
16603
|
+
var import_react = __toESM(require_react(), 1);
|
|
16604
|
+
var import_constants = __toESM(require_constants(), 1);
|
|
16605
|
+
import * as gui3 from "gui";
|
|
16606
|
+
import * as os4 from "os";
|
|
16607
|
+
|
|
16608
|
+
// _build/lib/windows/gdi32.js
|
|
16609
|
+
var b2 = (name, sig, encoders) => bind("gdi32.dll", name, sig, encoders);
|
|
16610
|
+
var POINTArr = structArray(POINT);
|
|
16611
|
+
var DeleteObject = /* @__PURE__ */ b2("DeleteObject", "<HGDIOBJ>ptr -> i32");
|
|
16612
|
+
var GetDeviceCaps = /* @__PURE__ */ b2("GetDeviceCaps", "<HDC>ptr! i32@DeviceCap -> i32");
|
|
16613
|
+
var CreateFontIndirect = /* @__PURE__ */ b2("CreateFontIndirectW", "<LOGFONTW>ptr -> <HGDIOBJ>ptr", { LOGFONTW });
|
|
16614
|
+
var SelectObject = /* @__PURE__ */ b2("SelectObject", "<HDC>ptr! <HGDIOBJ>ptr -> <HGDIOBJ>ptr");
|
|
16615
|
+
var GetObject = /* @__PURE__ */ b2("GetObjectW", "<HGDIOBJ>ptr i32 <BYTE>ptr -> i32");
|
|
16616
|
+
|
|
16617
|
+
// _build/lib/react-qw/props.js
|
|
16618
|
+
import * as gui from "gui";
|
|
16619
|
+
function applyProps(instance, newProps, _oldProps) {
|
|
16620
|
+
const hwnd2 = instance.hwnd;
|
|
16621
|
+
instance.props = newProps;
|
|
16622
|
+
if (hwnd2 === null)
|
|
16623
|
+
return;
|
|
16624
|
+
const textVal = "text" in newProps ? newProps.text : typeof newProps.children === "string" ? newProps.children : typeof newProps.children === "number" ? String(newProps.children) : void 0;
|
|
16625
|
+
if (textVal !== void 0) {
|
|
16626
|
+
let cursor = -1;
|
|
16627
|
+
if (instance.type === "EDIT") {
|
|
16628
|
+
const sel = gui.SendMessage(hwnd2, 176, 0, 0);
|
|
16629
|
+
cursor = sel >>> 16;
|
|
16630
|
+
}
|
|
16631
|
+
SetWindowText(hwnd2, textVal);
|
|
16632
|
+
if (instance.type === "EDIT" && cursor >= 0) {
|
|
16633
|
+
gui.SendMessage(hwnd2, 177, cursor, cursor);
|
|
16634
|
+
}
|
|
16635
|
+
}
|
|
16636
|
+
if ("disabled" in newProps) {
|
|
16637
|
+
EnableWindow(hwnd2, !newProps.disabled ? 1 : 0);
|
|
16638
|
+
}
|
|
16639
|
+
if ("hidden" in newProps) {
|
|
16640
|
+
gui.ShowWindow(
|
|
16641
|
+
hwnd2,
|
|
16642
|
+
newProps.hidden ? 0 : 5
|
|
16643
|
+
/* gui.ShowWindowCmd.SHOW */
|
|
16644
|
+
);
|
|
16645
|
+
}
|
|
16646
|
+
if ("visible" in newProps) {
|
|
16647
|
+
gui.ShowWindow(
|
|
16648
|
+
hwnd2,
|
|
16649
|
+
newProps.visible ? 5 : 0
|
|
16650
|
+
/* gui.ShowWindowCmd.HIDE */
|
|
16651
|
+
);
|
|
16652
|
+
}
|
|
16653
|
+
}
|
|
16654
|
+
|
|
16655
|
+
// _build/lib/react-qw/layout.js
|
|
16656
|
+
var DEFAULT_W = 100;
|
|
16657
|
+
var DEFAULT_H = 30;
|
|
16658
|
+
function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
16659
|
+
const dir = flex.flexDirection || "column";
|
|
16660
|
+
const gap = flex.gap ?? 0;
|
|
16661
|
+
const justify = flex.justifyContent || "flex-start";
|
|
16662
|
+
const align = flex.alignItems || "stretch";
|
|
16663
|
+
const isRow = dir === "row";
|
|
16664
|
+
const n = children.length;
|
|
16665
|
+
const mainSize = isRow ? "w" : "h";
|
|
16666
|
+
const crossSize = isRow ? "h" : "w";
|
|
16667
|
+
const mainPos = isRow ? "x" : "y";
|
|
16668
|
+
const crossPos = isRow ? "y" : "x";
|
|
16669
|
+
const mainDim = isRow ? "width" : "height";
|
|
16670
|
+
const crossDim = isRow ? "height" : "width";
|
|
16671
|
+
const pt = flex.paddingTop ?? flex.padding ?? 0;
|
|
16672
|
+
const pr = flex.paddingRight ?? flex.padding ?? 0;
|
|
16673
|
+
const pb = flex.paddingBottom ?? flex.padding ?? 0;
|
|
16674
|
+
const pl = flex.paddingLeft ?? flex.padding ?? 0;
|
|
16675
|
+
const mainPadding = isRow ? pl + pr : pt + pb;
|
|
16676
|
+
const crossPadding = isRow ? pt + pb : pl + pr;
|
|
16677
|
+
const parentMain = (isRow ? parentW : parentH) - mainPadding;
|
|
16678
|
+
const parentCross = (isRow ? parentH : parentW) - crossPadding;
|
|
16679
|
+
const sizes = children.map((c) => ({
|
|
16680
|
+
w: typeof c.style.width === "number" ? c.style.width : DEFAULT_W,
|
|
16681
|
+
h: typeof c.style.height === "number" ? c.style.height : DEFAULT_H
|
|
16682
|
+
}));
|
|
16683
|
+
const flexGrows = children.map((c) => c.style.flexGrow ?? 0);
|
|
16684
|
+
const totalGrow = flexGrows.reduce((s, g) => s + g, 0);
|
|
16685
|
+
const baseMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16686
|
+
let freeGrow = parentMain - baseMain - Math.max(0, n - 1) * gap;
|
|
16687
|
+
if (totalGrow > 0 && freeGrow > 0) {
|
|
16688
|
+
for (let i = 0; i < n; i++) {
|
|
16689
|
+
sizes[i][mainSize] += freeGrow * flexGrows[i] / totalGrow;
|
|
16690
|
+
}
|
|
16691
|
+
}
|
|
16692
|
+
const totalMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16693
|
+
const free = parentMain - totalMain - Math.max(0, n - 1) * gap;
|
|
16694
|
+
let offset = 0, extraGap = 0;
|
|
16695
|
+
if (justify === "flex-end")
|
|
16696
|
+
offset = free;
|
|
16697
|
+
else if (justify === "center")
|
|
16698
|
+
offset = Math.max(0, free / 2);
|
|
16699
|
+
else if (justify === "space-between" && n > 1)
|
|
16700
|
+
extraGap = free / (n - 1);
|
|
16701
|
+
else if (justify === "space-around") {
|
|
16702
|
+
extraGap = free / n;
|
|
16703
|
+
offset = extraGap / 2;
|
|
16704
|
+
} else if (justify === "space-evenly") {
|
|
16705
|
+
extraGap = free / (n + 1);
|
|
16706
|
+
offset = extraGap;
|
|
16707
|
+
}
|
|
16708
|
+
let cursor = offset;
|
|
16709
|
+
return sizes.map((sz, i) => {
|
|
16710
|
+
const childCrossBase = sz[crossSize];
|
|
16711
|
+
const childAlign = children[i].style.alignSelf ?? "auto";
|
|
16712
|
+
const effectiveAlign = childAlign === "auto" ? align : childAlign;
|
|
16713
|
+
let childMain = sz[mainSize];
|
|
16714
|
+
let childCross = childCrossBase;
|
|
16715
|
+
const res = { x: 0, y: 0, width: 0, height: 0 };
|
|
16716
|
+
res[mainPos] = cursor;
|
|
16717
|
+
res[crossPos] = 0;
|
|
16718
|
+
res[mainDim] = childMain;
|
|
16719
|
+
res[crossDim] = childCross;
|
|
16720
|
+
if (effectiveAlign === "stretch") {
|
|
16721
|
+
const hasExplicitCross = typeof children[i].style[crossDim] === "number";
|
|
16722
|
+
if (!hasExplicitCross) {
|
|
16723
|
+
res[crossDim] = parentCross;
|
|
16724
|
+
res[crossPos] = 0;
|
|
16725
|
+
}
|
|
16726
|
+
} else if (effectiveAlign === "flex-end") {
|
|
16727
|
+
res[crossPos] = parentCross - childCross;
|
|
16728
|
+
} else if (effectiveAlign === "center") {
|
|
16729
|
+
res[crossPos] = Math.max(0, (parentCross - childCross) / 2);
|
|
16730
|
+
}
|
|
16731
|
+
cursor += childMain + gap + extraGap;
|
|
16732
|
+
return res;
|
|
16733
|
+
});
|
|
15814
16734
|
}
|
|
15815
16735
|
|
|
15816
16736
|
// _build/lib/text-measure.js
|
|
15817
|
-
|
|
15818
|
-
DrawTextW: "ptr wstr i32 ptr i32 -> i32",
|
|
15819
|
-
GetDC: "ptr -> ptr",
|
|
15820
|
-
ReleaseDC: "ptr ptr -> i32"
|
|
15821
|
-
});
|
|
15822
|
-
var gdi32 = bindLib("gdi32.dll", {
|
|
15823
|
-
SelectObject: "ptr ptr -> ptr"
|
|
15824
|
-
});
|
|
16737
|
+
import * as gui2 from "gui";
|
|
15825
16738
|
function measureText(hdc, text, maxWidth) {
|
|
15826
|
-
const
|
|
15827
|
-
|
|
15828
|
-
dv.setInt32(8, maxWidth, true);
|
|
15829
|
-
user32.DrawTextW(
|
|
16739
|
+
const r = RECT.encode({ right: maxWidth });
|
|
16740
|
+
DrawText(
|
|
15830
16741
|
hdc,
|
|
15831
16742
|
text,
|
|
15832
16743
|
-1,
|
|
15833
|
-
|
|
16744
|
+
r.ptr,
|
|
15834
16745
|
1024
|
|
15835
16746
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15836
16747
|
);
|
|
15837
|
-
|
|
16748
|
+
const { right, bottom } = RECT.decode(r);
|
|
16749
|
+
return { width: right, height: bottom };
|
|
15838
16750
|
}
|
|
15839
16751
|
function getButtonIdealSize(hwnd2) {
|
|
15840
|
-
const size =
|
|
15841
|
-
gui2.SendMessage(hwnd2, 5633, 0,
|
|
15842
|
-
const
|
|
15843
|
-
return { width:
|
|
16752
|
+
const size = SIZE.alloc();
|
|
16753
|
+
gui2.SendMessage(hwnd2, 5633, 0, size.ptr);
|
|
16754
|
+
const { cx, cy } = SIZE.decode(size);
|
|
16755
|
+
return { width: cx, height: cy };
|
|
15844
16756
|
}
|
|
15845
16757
|
function measureTextForHwnd(hwnd2, text) {
|
|
15846
|
-
const hdc =
|
|
16758
|
+
const hdc = GetDC(hwnd2);
|
|
15847
16759
|
if (!hdc)
|
|
15848
16760
|
return { width: 0, height: 0 };
|
|
15849
16761
|
const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
|
|
15850
|
-
const oldFont = hFont ?
|
|
16762
|
+
const oldFont = hFont ? SelectObject(hdc, hFont) : NULL;
|
|
15851
16763
|
const result = measureText(hdc, text, 0);
|
|
15852
16764
|
if (hFont)
|
|
15853
|
-
|
|
15854
|
-
|
|
16765
|
+
SelectObject(hdc, oldFont);
|
|
16766
|
+
ReleaseDC(hwnd2, hdc);
|
|
15855
16767
|
const wr = gui2.GetWindowRect(hwnd2);
|
|
15856
16768
|
const cr = gui2.GetClientRect(hwnd2);
|
|
15857
16769
|
if (wr && cr) {
|
|
@@ -15863,14 +16775,20 @@ function measureTextForHwnd(hwnd2, text) {
|
|
|
15863
16775
|
|
|
15864
16776
|
// _build/lib/react-qw/reconciler.js
|
|
15865
16777
|
var dpiFont = gui3.CreateSystemDpiFont();
|
|
15866
|
-
var scaleFactor =
|
|
16778
|
+
var scaleFactor = (() => {
|
|
16779
|
+
const hdc = GetDC(NULL);
|
|
16780
|
+
const dpi = hdc ? GetDeviceCaps(hdc, 88) : 96;
|
|
16781
|
+
if (hdc)
|
|
16782
|
+
ReleaseDC(NULL, hdc);
|
|
16783
|
+
return dpi / 96;
|
|
16784
|
+
})();
|
|
15867
16785
|
var DELAYED_CONTROLS = /* @__PURE__ */ new Set(["SysListView32", "SysTreeView32", "LISTBOX", "COMBOBOX", "msctls_trackbar32", "SysDateTimePick32", "SysLink"]);
|
|
15868
16786
|
function isDelayedControl(winClass) {
|
|
15869
16787
|
return DELAYED_CONTROLS.has(winClass);
|
|
15870
16788
|
}
|
|
15871
16789
|
function setupWindowProc(instance, hwnd2) {
|
|
15872
16790
|
instance.hwnd = hwnd2;
|
|
15873
|
-
const oldProc =
|
|
16791
|
+
const oldProc = GetWindowLongPtr(
|
|
15874
16792
|
hwnd2,
|
|
15875
16793
|
-4
|
|
15876
16794
|
/* gui.Gwlp.WNDPROC */
|
|
@@ -15879,11 +16797,11 @@ function setupWindowProc(instance, hwnd2) {
|
|
|
15879
16797
|
gui3.SetWindowProc(hwnd2, (hwnd3, msg, wParam, lParam) => {
|
|
15880
16798
|
const ev = instance.props.onEvent;
|
|
15881
16799
|
if (!ev)
|
|
15882
|
-
return
|
|
16800
|
+
return CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
|
|
15883
16801
|
if (typeof ev === "object") {
|
|
15884
|
-
return ev.fn({ hwnd: hwnd3, msg, wParam, lParam, callOldWndProc: () =>
|
|
16802
|
+
return ev.fn({ hwnd: hwnd3, msg, wParam, lParam, callOldWndProc: () => CallWindowProc(oldProc, hwnd3, msg, wParam, lParam) });
|
|
15885
16803
|
}
|
|
15886
|
-
const result =
|
|
16804
|
+
const result = CallWindowProc(oldProc, hwnd3, msg, wParam, lParam);
|
|
15887
16805
|
const override = ev({ hwnd: hwnd3, msg, wParam, lParam });
|
|
15888
16806
|
return typeof override === "number" && Number.isInteger(override) ? override : result;
|
|
15889
16807
|
});
|
|
@@ -15953,7 +16871,7 @@ function runFlexLayout(inst) {
|
|
|
15953
16871
|
if (lr && lr.x === r.x && lr.y === r.y && lr.w === r.width && lr.h === r.height)
|
|
15954
16872
|
continue;
|
|
15955
16873
|
console.log("flex: set", child.type, child.hwnd, "to", r.x, r.y, r.width, r.height);
|
|
15956
|
-
|
|
16874
|
+
SetWindowPos(
|
|
15957
16875
|
child.hwnd,
|
|
15958
16876
|
0,
|
|
15959
16877
|
(r.x + pl) * scaleFactor,
|
|
@@ -15963,7 +16881,7 @@ function runFlexLayout(inst) {
|
|
|
15963
16881
|
64
|
|
15964
16882
|
/* gui.SetWindowPosFlag.SWP_SHOWWINDOW */
|
|
15965
16883
|
);
|
|
15966
|
-
|
|
16884
|
+
InvalidateRect(child.hwnd, NULL, 1);
|
|
15967
16885
|
child.lastRect = { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
15968
16886
|
}
|
|
15969
16887
|
for (const c of children)
|
|
@@ -16009,7 +16927,7 @@ var hostConfig = {
|
|
|
16009
16927
|
if (child.hwnd === null) {
|
|
16010
16928
|
ensureChildWindow(child, parent.hwnd);
|
|
16011
16929
|
} else {
|
|
16012
|
-
|
|
16930
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16013
16931
|
}
|
|
16014
16932
|
if (false)
|
|
16015
16933
|
console.log("[reconciler] appendInitialChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16019,7 +16937,7 @@ var hostConfig = {
|
|
|
16019
16937
|
if (child.hwnd === null) {
|
|
16020
16938
|
ensureChildWindow(child, parent.hwnd);
|
|
16021
16939
|
} else {
|
|
16022
|
-
|
|
16940
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16023
16941
|
}
|
|
16024
16942
|
if (false)
|
|
16025
16943
|
console.log("[reconciler] appendChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16029,7 +16947,7 @@ var hostConfig = {
|
|
|
16029
16947
|
if (child.hwnd === null) {
|
|
16030
16948
|
ensureChildWindow(child, container);
|
|
16031
16949
|
} else {
|
|
16032
|
-
|
|
16950
|
+
SetParent(child.hwnd, container);
|
|
16033
16951
|
}
|
|
16034
16952
|
const rootInst = instancesByHwnd.get(container);
|
|
16035
16953
|
if (rootInst)
|
|
@@ -16041,7 +16959,7 @@ var hostConfig = {
|
|
|
16041
16959
|
if (child.hwnd === null) {
|
|
16042
16960
|
ensureChildWindow(child, parent.hwnd);
|
|
16043
16961
|
} else {
|
|
16044
|
-
|
|
16962
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16045
16963
|
}
|
|
16046
16964
|
if (false)
|
|
16047
16965
|
console.log("[reconciler] insertBefore parent:", parent.hwnd, "child:", child.hwnd, "before:", beforeChild.hwnd);
|
|
@@ -16053,7 +16971,7 @@ var hostConfig = {
|
|
|
16053
16971
|
if (child.hwnd === null) {
|
|
16054
16972
|
ensureChildWindow(child, container);
|
|
16055
16973
|
} else {
|
|
16056
|
-
|
|
16974
|
+
SetParent(child.hwnd, container);
|
|
16057
16975
|
}
|
|
16058
16976
|
const rootInst = instancesByHwnd.get(container);
|
|
16059
16977
|
if (!rootInst)
|
|
@@ -16110,7 +17028,7 @@ var hostConfig = {
|
|
|
16110
17028
|
resetTextContent(_instance) {
|
|
16111
17029
|
},
|
|
16112
17030
|
commitTextUpdate(instance, _oldText, newText) {
|
|
16113
|
-
|
|
17031
|
+
SetWindowText(instance.hwnd, newText);
|
|
16114
17032
|
},
|
|
16115
17033
|
hideInstance(instance) {
|
|
16116
17034
|
if (instance.hwnd !== null)
|
|
@@ -16164,10 +17082,10 @@ var hostConfig = {
|
|
|
16164
17082
|
clearContainer(_container) {
|
|
16165
17083
|
},
|
|
16166
17084
|
scheduleTimeout(fn, delay) {
|
|
16167
|
-
return
|
|
17085
|
+
return os4.setTimeout(fn, delay);
|
|
16168
17086
|
},
|
|
16169
17087
|
cancelTimeout(id) {
|
|
16170
|
-
|
|
17088
|
+
os4.clearTimeout?.(id);
|
|
16171
17089
|
},
|
|
16172
17090
|
noTimeout: -1,
|
|
16173
17091
|
supportsMutation: true,
|
|
@@ -16334,298 +17252,23 @@ var ComboBox = (0, import_react4.forwardRef)(({ items, selectedIndex: controlled
|
|
|
16334
17252
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
16335
17253
|
var import_react5 = __toESM(require_react(), 1);
|
|
16336
17254
|
import * as gui6 from "gui";
|
|
16337
|
-
import * as ffi4 from "ffi";
|
|
16338
|
-
|
|
16339
|
-
// _build/lib/ffi-struct.js
|
|
16340
|
-
import * as os2 from "os";
|
|
16341
|
-
var PTR = os2.arch === "x64" ? 8 : 4;
|
|
16342
|
-
var AS = {
|
|
16343
|
-
u8: [1, 1],
|
|
16344
|
-
i8: [1, 1],
|
|
16345
|
-
u16: [2, 2],
|
|
16346
|
-
i16: [2, 2],
|
|
16347
|
-
u32: [4, 4],
|
|
16348
|
-
i32: [4, 4],
|
|
16349
|
-
u64: [8, 8],
|
|
16350
|
-
i64: [8, 8],
|
|
16351
|
-
f32: [4, 4],
|
|
16352
|
-
f64: [8, 8],
|
|
16353
|
-
ptr: [PTR, PTR],
|
|
16354
|
-
wstr: [2, 2]
|
|
16355
|
-
// 仅定长数组元素用(wchar)
|
|
16356
|
-
};
|
|
16357
|
-
function alignUp(v, a) {
|
|
16358
|
-
return v + a - 1 & ~(a - 1);
|
|
16359
|
-
}
|
|
16360
|
-
function parseField(f) {
|
|
16361
|
-
const arr = /^(.+)\[(\d+)\]$/.exec(f);
|
|
16362
|
-
if (arr) {
|
|
16363
|
-
const b2 = normKind(arr[1]);
|
|
16364
|
-
if (b2 === "void")
|
|
16365
|
-
throw new Error(`ffi-struct: "void" cannot be an array base`);
|
|
16366
|
-
return { base: b2, count: Number(arr[2]) };
|
|
16367
|
-
}
|
|
16368
|
-
const b = normKind(f);
|
|
16369
|
-
if (b === "void" || b === "wstr")
|
|
16370
|
-
throw new Error(`ffi-struct: invalid scalar field type "${f}"`);
|
|
16371
|
-
return { base: b, count: 1 };
|
|
16372
|
-
}
|
|
16373
|
-
function layout(def) {
|
|
16374
|
-
const fields = [];
|
|
16375
|
-
let cursor = 0;
|
|
16376
|
-
let maxAlign = 1;
|
|
16377
|
-
for (const key of Object.keys(def)) {
|
|
16378
|
-
const v = def[key];
|
|
16379
|
-
let a;
|
|
16380
|
-
let w;
|
|
16381
|
-
if (typeof v === "string") {
|
|
16382
|
-
const { base, count } = parseField(v);
|
|
16383
|
-
const [align, elem] = AS[base];
|
|
16384
|
-
a = align;
|
|
16385
|
-
w = count >= 1 ? elem * count : elem;
|
|
16386
|
-
fields.push({ name: key, base, count, offset: 0 });
|
|
16387
|
-
} else {
|
|
16388
|
-
const child = v;
|
|
16389
|
-
a = child.structAlign;
|
|
16390
|
-
w = child.size;
|
|
16391
|
-
fields.push({ name: key, base: "u8", count: 0, offset: 0, child });
|
|
16392
|
-
}
|
|
16393
|
-
const off = alignUp(cursor, a);
|
|
16394
|
-
const f = fields[fields.length - 1];
|
|
16395
|
-
f.offset = off;
|
|
16396
|
-
cursor = off + w;
|
|
16397
|
-
if (a > maxAlign)
|
|
16398
|
-
maxAlign = a;
|
|
16399
|
-
}
|
|
16400
|
-
return { fields, size: alignUp(cursor, maxAlign), structAlign: maxAlign };
|
|
16401
|
-
}
|
|
16402
|
-
var _layoutCache = /* @__PURE__ */ new WeakMap();
|
|
16403
|
-
function buildLayout(def) {
|
|
16404
|
-
let hit = _layoutCache.get(def);
|
|
16405
|
-
if (hit)
|
|
16406
|
-
return hit;
|
|
16407
|
-
hit = layout(def);
|
|
16408
|
-
_layoutCache.set(def, hit);
|
|
16409
|
-
return hit;
|
|
16410
|
-
}
|
|
16411
|
-
function readScalar(dv, off, k) {
|
|
16412
|
-
switch (k) {
|
|
16413
|
-
case "u8":
|
|
16414
|
-
return dv.getUint8(off);
|
|
16415
|
-
case "i8":
|
|
16416
|
-
return dv.getInt8(off);
|
|
16417
|
-
case "u16":
|
|
16418
|
-
return dv.getUint16(off, true);
|
|
16419
|
-
case "i16":
|
|
16420
|
-
return dv.getInt16(off, true);
|
|
16421
|
-
case "u32":
|
|
16422
|
-
return dv.getUint32(off, true);
|
|
16423
|
-
case "i32":
|
|
16424
|
-
return dv.getInt32(off, true);
|
|
16425
|
-
case "u64":
|
|
16426
|
-
return Number(dv.getBigUint64(off, true));
|
|
16427
|
-
case "i64":
|
|
16428
|
-
return Number(dv.getBigInt64(off, true));
|
|
16429
|
-
case "f32":
|
|
16430
|
-
return dv.getFloat32(off, true);
|
|
16431
|
-
case "f64":
|
|
16432
|
-
return dv.getFloat64(off, true);
|
|
16433
|
-
case "ptr":
|
|
16434
|
-
return readPtr(dv, off);
|
|
16435
|
-
case "wstr":
|
|
16436
|
-
return dv.getUint16(off, true);
|
|
16437
|
-
}
|
|
16438
|
-
}
|
|
16439
|
-
function readPtr(dv, off) {
|
|
16440
|
-
if (PTR === 8)
|
|
16441
|
-
return Number(dv.getBigUint64(off, true));
|
|
16442
|
-
return dv.getUint32(off, true);
|
|
16443
|
-
}
|
|
16444
|
-
function writeScalar(dv, off, k, val) {
|
|
16445
|
-
switch (k) {
|
|
16446
|
-
case "u8":
|
|
16447
|
-
dv.setUint8(off, val);
|
|
16448
|
-
break;
|
|
16449
|
-
case "i8":
|
|
16450
|
-
dv.setInt8(off, val);
|
|
16451
|
-
break;
|
|
16452
|
-
case "u16":
|
|
16453
|
-
dv.setUint16(off, val, true);
|
|
16454
|
-
break;
|
|
16455
|
-
case "i16":
|
|
16456
|
-
dv.setInt16(off, val, true);
|
|
16457
|
-
break;
|
|
16458
|
-
case "u32":
|
|
16459
|
-
dv.setUint32(off, val >>> 0, true);
|
|
16460
|
-
break;
|
|
16461
|
-
case "i32":
|
|
16462
|
-
dv.setInt32(off, val | 0, true);
|
|
16463
|
-
break;
|
|
16464
|
-
case "u64":
|
|
16465
|
-
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16466
|
-
break;
|
|
16467
|
-
case "i64":
|
|
16468
|
-
dv.setBigInt64(off, BigInt(Math.trunc(val)), true);
|
|
16469
|
-
break;
|
|
16470
|
-
case "f32":
|
|
16471
|
-
dv.setFloat32(off, val, true);
|
|
16472
|
-
break;
|
|
16473
|
-
case "f64":
|
|
16474
|
-
dv.setFloat64(off, val, true);
|
|
16475
|
-
break;
|
|
16476
|
-
case "ptr":
|
|
16477
|
-
writePtr(dv, off, val);
|
|
16478
|
-
break;
|
|
16479
|
-
case "wstr":
|
|
16480
|
-
dv.setUint16(off, val, true);
|
|
16481
|
-
break;
|
|
16482
|
-
}
|
|
16483
|
-
}
|
|
16484
|
-
function writePtr(dv, off, val) {
|
|
16485
|
-
if (PTR === 8)
|
|
16486
|
-
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16487
|
-
else
|
|
16488
|
-
dv.setUint32(off, val >>> 0, true);
|
|
16489
|
-
}
|
|
16490
|
-
function readField(dv, base, f) {
|
|
16491
|
-
const off = base + f.offset;
|
|
16492
|
-
if (f.child)
|
|
16493
|
-
return readInto(f.child, dv.buffer, off);
|
|
16494
|
-
if (f.count > 1) {
|
|
16495
|
-
if (f.base === "wstr") {
|
|
16496
|
-
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16497
|
-
let end = 0;
|
|
16498
|
-
while (end < arr.length && arr[end] !== 0)
|
|
16499
|
-
end++;
|
|
16500
|
-
let s = "";
|
|
16501
|
-
for (let i = 0; i < end; i++)
|
|
16502
|
-
s += String.fromCharCode(arr[i]);
|
|
16503
|
-
return s;
|
|
16504
|
-
}
|
|
16505
|
-
const out = [];
|
|
16506
|
-
const step = AS[f.base][1];
|
|
16507
|
-
for (let i = 0; i < f.count; i++)
|
|
16508
|
-
out.push(readScalar(dv, off + i * step, f.base));
|
|
16509
|
-
return out;
|
|
16510
|
-
}
|
|
16511
|
-
return readScalar(dv, off, f.base);
|
|
16512
|
-
}
|
|
16513
|
-
function writeField(dv, base, f, v) {
|
|
16514
|
-
const off = base + f.offset;
|
|
16515
|
-
if (f.child) {
|
|
16516
|
-
writeInto(f.child, v, dv.buffer, off);
|
|
16517
|
-
return;
|
|
16518
|
-
}
|
|
16519
|
-
if (f.count > 1) {
|
|
16520
|
-
if (f.base === "wstr") {
|
|
16521
|
-
const s = String(v ?? "");
|
|
16522
|
-
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16523
|
-
for (let i = 0; i < arr.length; i++)
|
|
16524
|
-
arr[i] = 0;
|
|
16525
|
-
const n = Math.min(s.length, f.count - 1);
|
|
16526
|
-
for (let i = 0; i < n; i++)
|
|
16527
|
-
arr[i] = s.charCodeAt(i);
|
|
16528
|
-
return;
|
|
16529
|
-
}
|
|
16530
|
-
const step = AS[f.base][1];
|
|
16531
|
-
const list = v ?? [];
|
|
16532
|
-
for (let i = 0; i < f.count; i++)
|
|
16533
|
-
writeScalar(dv, off + i * step, f.base, list[i] ?? 0);
|
|
16534
|
-
return;
|
|
16535
|
-
}
|
|
16536
|
-
writeScalar(dv, off, f.base, Number(v));
|
|
16537
|
-
}
|
|
16538
|
-
function doSize(def) {
|
|
16539
|
-
return buildLayout(def).size;
|
|
16540
|
-
}
|
|
16541
|
-
function readInto(child, buf, offset) {
|
|
16542
|
-
const r = child;
|
|
16543
|
-
return r.read(buf, offset);
|
|
16544
|
-
}
|
|
16545
|
-
function doRead(_def, fields, buf, offset) {
|
|
16546
|
-
const out = {};
|
|
16547
|
-
const dv = new DataView(buf);
|
|
16548
|
-
for (const f of fields)
|
|
16549
|
-
out[f.name] = readField(dv, offset, f);
|
|
16550
|
-
return out;
|
|
16551
|
-
}
|
|
16552
|
-
function doWrite(def, fields, v, buf, offset = 0) {
|
|
16553
|
-
buf = buf ?? new ArrayBuffer(doSize(def));
|
|
16554
|
-
const dv = new DataView(buf);
|
|
16555
|
-
for (const f of fields)
|
|
16556
|
-
writeField(dv, offset, f, v[f.name]);
|
|
16557
|
-
return buf;
|
|
16558
|
-
}
|
|
16559
|
-
function writeInto(child, v, buf, offset) {
|
|
16560
|
-
const w = child;
|
|
16561
|
-
w.write(v, buf, offset);
|
|
16562
|
-
}
|
|
16563
|
-
function struct(def) {
|
|
16564
|
-
const { fields, size, structAlign } = buildLayout(def);
|
|
16565
|
-
return {
|
|
16566
|
-
__fields: def,
|
|
16567
|
-
size,
|
|
16568
|
-
structAlign,
|
|
16569
|
-
read: (buf, offset = 0) => doRead(def, fields, buf, offset),
|
|
16570
|
-
write: (v, buf, offset = 0) => doWrite(def, fields, v, buf, offset),
|
|
16571
|
-
offsetOf: (name) => {
|
|
16572
|
-
for (const f of fields)
|
|
16573
|
-
if (f.name === name)
|
|
16574
|
-
return f.offset;
|
|
16575
|
-
throw new Error(`ffi-struct: no field "${String(name)}"`);
|
|
16576
|
-
}
|
|
16577
|
-
};
|
|
16578
|
-
}
|
|
16579
17255
|
|
|
16580
17256
|
// _build/lib/react-qw/nmhdr.js
|
|
16581
|
-
import * as os3 from "os";
|
|
16582
|
-
import * as ffi3 from "ffi";
|
|
16583
|
-
var IS64 = os3.arch === "x64";
|
|
16584
|
-
var PTR_SIZE = IS64 ? 8 : 4;
|
|
16585
|
-
var NMHDR = struct({ hwndFrom: "ptr", idFrom: "ptr", code: "i32" });
|
|
16586
|
-
var NMHDR_SIZE = NMHDR.size;
|
|
16587
|
-
var NMHDR_CODE = NMHDR.offsetOf("code");
|
|
16588
|
-
function readI32At(ptr, offset) {
|
|
16589
|
-
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8 | ffi3.readByte(ptr + offset + 2) << 16 | ffi3.readByte(ptr + offset + 3) << 24;
|
|
16590
|
-
}
|
|
16591
|
-
function readU16At(ptr, offset) {
|
|
16592
|
-
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8;
|
|
16593
|
-
}
|
|
16594
17257
|
function nmCode(lParam) {
|
|
16595
|
-
return
|
|
17258
|
+
return NMHDR.decode(lParam).code;
|
|
16596
17259
|
}
|
|
16597
17260
|
|
|
16598
17261
|
// _build/lib/react-qw/components/DateTimePicker.js
|
|
16599
|
-
var SYSTEMTIME = struct({
|
|
16600
|
-
wYear: "u16",
|
|
16601
|
-
wMonth: "u16",
|
|
16602
|
-
wDayOfWeek: "u16",
|
|
16603
|
-
wDay: "u16",
|
|
16604
|
-
wHour: "u16",
|
|
16605
|
-
wMinute: "u16",
|
|
16606
|
-
wSecond: "u16",
|
|
16607
|
-
wMilliseconds: "u16"
|
|
16608
|
-
});
|
|
16609
|
-
var NMDATETIMECHANGE = struct({
|
|
16610
|
-
hdr: NMHDR,
|
|
16611
|
-
dwFlags: "u32",
|
|
16612
|
-
st: SYSTEMTIME
|
|
16613
|
-
});
|
|
16614
|
-
function bufPtr(buf) {
|
|
16615
|
-
return ffi4.bufferPtr(buf);
|
|
16616
|
-
}
|
|
16617
17262
|
function dateToSysTimeBuf(d) {
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
|
|
16627
|
-
dv.setUint16(14, d.getMilliseconds(), true);
|
|
16628
|
-
return buf;
|
|
17263
|
+
return SYSTEMTIME.encode({
|
|
17264
|
+
wYear: d.getFullYear(),
|
|
17265
|
+
wMonth: d.getMonth() + 1,
|
|
17266
|
+
wDay: d.getDate(),
|
|
17267
|
+
wHour: d.getHours(),
|
|
17268
|
+
wMinute: d.getMinutes(),
|
|
17269
|
+
wSecond: d.getSeconds(),
|
|
17270
|
+
wMilliseconds: d.getMilliseconds()
|
|
17271
|
+
});
|
|
16629
17272
|
}
|
|
16630
17273
|
var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ value, onChange, defaultValue, format = "short", allowNone, updown, style }, ref) {
|
|
16631
17274
|
const [internalDate, setInternalDate] = (0, import_react5.useState)(defaultValue ?? null);
|
|
@@ -16650,7 +17293,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16650
17293
|
const d = effectiveDate;
|
|
16651
17294
|
if (d) {
|
|
16652
17295
|
const buf = dateToSysTimeBuf(d);
|
|
16653
|
-
gui6.SendMessage(h, 4098, 0,
|
|
17296
|
+
gui6.SendMessage(h, 4098, 0, buf.ptr);
|
|
16654
17297
|
} else {
|
|
16655
17298
|
gui6.SendMessage(h, 4098, 1, 0);
|
|
16656
17299
|
}
|
|
@@ -16659,7 +17302,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16659
17302
|
const h = dpRef.current;
|
|
16660
17303
|
if (!h)
|
|
16661
17304
|
return;
|
|
16662
|
-
|
|
17305
|
+
InvalidateRect(h, NULL, 1);
|
|
16663
17306
|
const cr = gui6.GetClientRect(h);
|
|
16664
17307
|
if (cr) {
|
|
16665
17308
|
const w = cr.right - cr.left;
|
|
@@ -16671,20 +17314,13 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16671
17314
|
if (e.msg === 78) {
|
|
16672
17315
|
const code = nmCode(e.lParam);
|
|
16673
17316
|
if (code === -759) {
|
|
16674
|
-
const st = NMDATETIMECHANGE.
|
|
16675
|
-
const dwFlags = readI32At(e.lParam, NMDATETIMECHANGE.offsetOf("dwFlags"));
|
|
17317
|
+
const { dwFlags, st } = NMDATETIMECHANGE.decode(e.lParam);
|
|
16676
17318
|
if (dwFlags === 1) {
|
|
16677
17319
|
if (!isControlled)
|
|
16678
17320
|
setInternalDate(null);
|
|
16679
17321
|
onChangeRef.current?.(null);
|
|
16680
17322
|
} else {
|
|
16681
|
-
const
|
|
16682
|
-
const month = readU16At(e.lParam, st + 2);
|
|
16683
|
-
const day = readU16At(e.lParam, st + 6);
|
|
16684
|
-
const hour = readU16At(e.lParam, st + 8);
|
|
16685
|
-
const min = readU16At(e.lParam, st + 10);
|
|
16686
|
-
const sec = readU16At(e.lParam, st + 12);
|
|
16687
|
-
const d = new Date(year, month - 1, day, hour, min, sec);
|
|
17323
|
+
const d = new Date(st.wYear, st.wMonth - 1, st.wDay, st.wHour, st.wMinute, st.wSecond);
|
|
16688
17324
|
if (!isControlled)
|
|
16689
17325
|
setInternalDate(d);
|
|
16690
17326
|
onChangeRef.current?.(d);
|
|
@@ -16700,14 +17336,6 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16700
17336
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
16701
17337
|
var import_react6 = __toESM(require_react(), 1);
|
|
16702
17338
|
import * as gui7 from "gui";
|
|
16703
|
-
import * as ffi5 from "ffi";
|
|
16704
|
-
function textToUtf16(s) {
|
|
16705
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16706
|
-
const dv = new DataView(buf);
|
|
16707
|
-
for (let i = 0; i < s.length; i++)
|
|
16708
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16709
|
-
return buf;
|
|
16710
|
-
}
|
|
16711
17339
|
var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValue = "", onChange, placeholder, password, multiline, readonly, number, disabled, style }, ref) => {
|
|
16712
17340
|
const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue);
|
|
16713
17341
|
const isControlled = controlledValue !== void 0;
|
|
@@ -16726,8 +17354,8 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16726
17354
|
const h = inputRef.current;
|
|
16727
17355
|
if (!h || !placeholder)
|
|
16728
17356
|
return;
|
|
16729
|
-
const buf =
|
|
16730
|
-
gui7.SendMessage(h, 5377, 1,
|
|
17357
|
+
const buf = WCHAR.encode(placeholder);
|
|
17358
|
+
gui7.SendMessage(h, 5377, 1, buf.ptr);
|
|
16731
17359
|
}, [placeholder]);
|
|
16732
17360
|
return (0, import_jsx_runtime5.jsx)("w", { type: "EDIT", text: displayValue, ws, style, disabled, ref: (h) => {
|
|
16733
17361
|
inputRef.current = h;
|
|
@@ -16751,20 +17379,6 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16751
17379
|
// _build/lib/react-qw/components/Link.js
|
|
16752
17380
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
16753
17381
|
var import_react7 = __toESM(require_react(), 1);
|
|
16754
|
-
import * as gui8 from "gui";
|
|
16755
|
-
import * as ffi6 from "ffi";
|
|
16756
|
-
function readUtf16(ptr, offset, maxWords) {
|
|
16757
|
-
const chars = [];
|
|
16758
|
-
for (let i = 0; i < maxWords; i++) {
|
|
16759
|
-
const lo = ffi6.readByte(ptr + offset + i * 2);
|
|
16760
|
-
const hi = ffi6.readByte(ptr + offset + i * 2 + 1);
|
|
16761
|
-
const code = hi << 8 | lo;
|
|
16762
|
-
if (code === 0)
|
|
16763
|
-
break;
|
|
16764
|
-
chars.push(String.fromCharCode(code));
|
|
16765
|
-
}
|
|
16766
|
-
return chars.join("");
|
|
16767
|
-
}
|
|
16768
17382
|
var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClick, style }, ref) {
|
|
16769
17383
|
const displayText = children != null ? String(children) : href ?? "";
|
|
16770
17384
|
const linkText = href ? `<A HREF="${href}">${displayText}</A>` : displayText;
|
|
@@ -16775,14 +17389,13 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16775
17389
|
const h = linkRef.current;
|
|
16776
17390
|
if (!h)
|
|
16777
17391
|
return;
|
|
16778
|
-
|
|
17392
|
+
InvalidateRect(h, NULL, 1);
|
|
16779
17393
|
}, [linkText]);
|
|
16780
17394
|
return (0, import_jsx_runtime6.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16781
17395
|
if (e.msg === 78) {
|
|
16782
17396
|
const code = nmCode(e.lParam);
|
|
16783
17397
|
if (code === -2 || code === -4) {
|
|
16784
|
-
|
|
16785
|
-
onClickRef.current?.(url);
|
|
17398
|
+
onClickRef.current?.(NMLINK.decode(e.lParam).item.szUrl);
|
|
16786
17399
|
}
|
|
16787
17400
|
}
|
|
16788
17401
|
}, children: (0, import_jsx_runtime6.jsx)("w", { type: "SysLink", ws: 268435456 | 65536, text: linkText, style: { flexGrow: 1 }, ref: (h) => {
|
|
@@ -16793,7 +17406,7 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16793
17406
|
// _build/lib/react-qw/components/ListBox.js
|
|
16794
17407
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
16795
17408
|
var import_react8 = __toESM(require_react(), 1);
|
|
16796
|
-
import * as
|
|
17409
|
+
import * as gui8 from "gui";
|
|
16797
17410
|
var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledIndex, defaultSelectedIndex = -1, onChange, style, sort, scrollToBottom }, ref) => {
|
|
16798
17411
|
const [internalIndex, setInternalIndex] = (0, import_react8.useState)(defaultSelectedIndex);
|
|
16799
17412
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -16805,18 +17418,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16805
17418
|
const h = lbRef.current;
|
|
16806
17419
|
if (!h)
|
|
16807
17420
|
return;
|
|
16808
|
-
|
|
17421
|
+
gui8.SendMessage(h, 388, 0, 0);
|
|
16809
17422
|
for (const item of items)
|
|
16810
|
-
|
|
17423
|
+
gui8.SendMessage(h, 384, 0, item);
|
|
16811
17424
|
if (sel >= 0 && sel < items.length)
|
|
16812
|
-
|
|
17425
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16813
17426
|
if (scrollToBottom && items.length > 0)
|
|
16814
|
-
|
|
17427
|
+
gui8.SendMessage(h, 407, items.length - 1, 0);
|
|
16815
17428
|
}, [items]);
|
|
16816
17429
|
(0, import_react8.useEffect)(() => {
|
|
16817
17430
|
const h = lbRef.current;
|
|
16818
17431
|
if (h)
|
|
16819
|
-
|
|
17432
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16820
17433
|
}, [sel]);
|
|
16821
17434
|
return (0, import_jsx_runtime7.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, onEvent: (e) => {
|
|
16822
17435
|
if (e.msg !== 273)
|
|
@@ -16826,7 +17439,7 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16826
17439
|
const h = lbRef.current;
|
|
16827
17440
|
if (!h)
|
|
16828
17441
|
return;
|
|
16829
|
-
const newSel =
|
|
17442
|
+
const newSel = gui8.SendMessage(h, 392, 0, 0);
|
|
16830
17443
|
if (newSel !== sel && newSel >= 0) {
|
|
16831
17444
|
if (!isControlled)
|
|
16832
17445
|
setInternalIndex(newSel);
|
|
@@ -16841,138 +17454,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16841
17454
|
// _build/lib/react-qw/components/ListView.js
|
|
16842
17455
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
16843
17456
|
var import_react9 = __toESM(require_react(), 1);
|
|
16844
|
-
import * as
|
|
16845
|
-
import * as
|
|
16846
|
-
import * as win2 from "win";
|
|
16847
|
-
function textToUtf162(s) {
|
|
16848
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16849
|
-
const dv = new DataView(buf);
|
|
16850
|
-
for (let i = 0; i < s.length; i++)
|
|
16851
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16852
|
-
return buf;
|
|
16853
|
-
}
|
|
16854
|
-
function readI32(ptr, offset) {
|
|
16855
|
-
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24;
|
|
16856
|
-
}
|
|
16857
|
-
function readU32(ptr, offset) {
|
|
16858
|
-
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24 >>> 0;
|
|
16859
|
-
}
|
|
16860
|
-
function readU64(ptr, offset) {
|
|
16861
|
-
const lo = readU32(ptr, offset);
|
|
16862
|
-
const hi = readU32(ptr, offset + 4);
|
|
16863
|
-
return lo + hi * 4294967296;
|
|
16864
|
-
}
|
|
17457
|
+
import * as gui9 from "gui";
|
|
17458
|
+
import * as ffi3 from "ffi";
|
|
16865
17459
|
function writeU32(ptr, offset, v) {
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
|
|
16870
|
-
}
|
|
16871
|
-
function bufPtr2(buf) {
|
|
16872
|
-
return ffi7.bufferPtr(buf);
|
|
17460
|
+
ffi3.writeByte(ptr + offset, v & 255);
|
|
17461
|
+
ffi3.writeByte(ptr + offset + 1, v >> 8 & 255);
|
|
17462
|
+
ffi3.writeByte(ptr + offset + 2, v >> 16 & 255);
|
|
17463
|
+
ffi3.writeByte(ptr + offset + 3, v >> 24 & 255);
|
|
16873
17464
|
}
|
|
16874
17465
|
var LV_WS = 268435456 | 8388608 | 2097152 | 1048576 | 1 | 4;
|
|
16875
|
-
var NMCUSTOMDRAW = struct({
|
|
16876
|
-
hdr: NMHDR,
|
|
16877
|
-
dwDrawStage: "u32",
|
|
16878
|
-
hdc: "ptr",
|
|
16879
|
-
rc: "i32[4]",
|
|
16880
|
-
dwItemSpec: "ptr",
|
|
16881
|
-
uItemState: "u32",
|
|
16882
|
-
lItemlParam: "ptr"
|
|
16883
|
-
});
|
|
16884
|
-
var NMLVCUSTOMDRAW = struct({
|
|
16885
|
-
hdr: NMHDR,
|
|
16886
|
-
dwDrawStage: "u32",
|
|
16887
|
-
hdc: "ptr",
|
|
16888
|
-
rc: "i32[4]",
|
|
16889
|
-
dwItemSpec: "ptr",
|
|
16890
|
-
uItemState: "u32",
|
|
16891
|
-
lItemlParam: "ptr",
|
|
16892
|
-
clrText: "u32",
|
|
16893
|
-
clrTextBk: "u32",
|
|
16894
|
-
iSubItem: "i32",
|
|
16895
|
-
dwItemType: "u32"
|
|
16896
|
-
});
|
|
16897
|
-
var NMLISTVIEW = struct({
|
|
16898
|
-
hdr: NMHDR,
|
|
16899
|
-
iItem: "i32",
|
|
16900
|
-
iSubItem: "i32",
|
|
16901
|
-
uNewState: "u32",
|
|
16902
|
-
uOldState: "u32",
|
|
16903
|
-
uChanged: "u32",
|
|
16904
|
-
ptAction: "i32[2]",
|
|
16905
|
-
lParam: "ptr"
|
|
16906
|
-
});
|
|
16907
|
-
var CD_STAGE = NMCUSTOMDRAW.offsetOf("dwDrawStage");
|
|
16908
|
-
var CD_HDC = NMCUSTOMDRAW.offsetOf("hdc");
|
|
16909
|
-
var CD_ITEM = NMCUSTOMDRAW.offsetOf("dwItemSpec");
|
|
16910
17466
|
var CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf("clrText");
|
|
16911
17467
|
var CD_CLRTEXTBK = NMLVCUSTOMDRAW.offsetOf("clrTextBk");
|
|
16912
|
-
var CD_SUBITEM = NMLVCUSTOMDRAW.offsetOf("iSubItem");
|
|
16913
|
-
var NMIA_ITEM = NMLISTVIEW.offsetOf("iItem");
|
|
16914
|
-
var NMIA_SUBITEM = NMLISTVIEW.offsetOf("iSubItem");
|
|
16915
|
-
var NMLV_UNEW = NMLISTVIEW.offsetOf("uNewState");
|
|
16916
|
-
var NMLV_UOLD = NMLISTVIEW.offsetOf("uOldState");
|
|
16917
|
-
var LVITEMW = struct({
|
|
16918
|
-
mask: "u32",
|
|
16919
|
-
iItem: "i32",
|
|
16920
|
-
iSubItem: "i32",
|
|
16921
|
-
state: "u32",
|
|
16922
|
-
stateMask: "u32",
|
|
16923
|
-
pszText: "ptr",
|
|
16924
|
-
cchTextMax: "i32",
|
|
16925
|
-
iImage: "i32",
|
|
16926
|
-
lParam: "ptr",
|
|
16927
|
-
iIndent: "i32",
|
|
16928
|
-
iGroupId: "i32",
|
|
16929
|
-
cColumns: "u32",
|
|
16930
|
-
puColumns: "ptr",
|
|
16931
|
-
piColFmt: "ptr",
|
|
16932
|
-
iGroup: "i32"
|
|
16933
|
-
});
|
|
16934
|
-
var LVCOLUMNW = struct({
|
|
16935
|
-
mask: "u32",
|
|
16936
|
-
fmt: "i32",
|
|
16937
|
-
cx: "i32",
|
|
16938
|
-
pszText: "ptr",
|
|
16939
|
-
cchTextMax: "i32",
|
|
16940
|
-
iSubItem: "i32",
|
|
16941
|
-
iImage: "i32",
|
|
16942
|
-
iOrder: "i32",
|
|
16943
|
-
cxMin: "i32",
|
|
16944
|
-
cxDefault: "i32",
|
|
16945
|
-
cxIdeal: "i32"
|
|
16946
|
-
});
|
|
16947
17468
|
var fontCache = /* @__PURE__ */ new Map();
|
|
16948
|
-
var gdi322 = null;
|
|
16949
|
-
var createFontIndirectW = null;
|
|
16950
|
-
var selectObjectFn = null;
|
|
16951
|
-
var getObjectW = null;
|
|
16952
|
-
function ensureGdi() {
|
|
16953
|
-
if (gdi322 !== null)
|
|
16954
|
-
return;
|
|
16955
|
-
gdi322 = win2.LoadLibrary("gdi32.dll");
|
|
16956
|
-
if (!gdi322)
|
|
16957
|
-
return;
|
|
16958
|
-
createFontIndirectW = win2.GetProcAddress(gdi322, "CreateFontIndirectW");
|
|
16959
|
-
selectObjectFn = win2.GetProcAddress(gdi322, "SelectObject");
|
|
16960
|
-
getObjectW = win2.GetProcAddress(gdi322, "GetObjectW");
|
|
16961
|
-
}
|
|
16962
|
-
var user322 = null;
|
|
16963
|
-
var loadCursorW = null;
|
|
16964
|
-
var setCursorFn = null;
|
|
16965
|
-
var screenToClient = null;
|
|
16966
|
-
function ensureUser32() {
|
|
16967
|
-
if (user322 !== null)
|
|
16968
|
-
return;
|
|
16969
|
-
user322 = win2.LoadLibrary("user32.dll");
|
|
16970
|
-
if (!user322)
|
|
16971
|
-
return;
|
|
16972
|
-
loadCursorW = win2.GetProcAddress(user322, "LoadCursorW");
|
|
16973
|
-
setCursorFn = win2.GetProcAddress(user322, "SetCursor");
|
|
16974
|
-
screenToClient = win2.GetProcAddress(user322, "ScreenToClient");
|
|
16975
|
-
}
|
|
16976
17469
|
function getCellFont(hwnd2, style) {
|
|
16977
17470
|
const key = (style.bold ? "b" : "") + (style.italic ? "i" : "") + (style.underline ? "u" : "");
|
|
16978
17471
|
if (key === "")
|
|
@@ -16980,39 +17473,37 @@ function getCellFont(hwnd2, style) {
|
|
|
16980
17473
|
const cached = fontCache.get(key);
|
|
16981
17474
|
if (cached !== void 0)
|
|
16982
17475
|
return cached === 0 ? null : cached;
|
|
16983
|
-
|
|
16984
|
-
if (!createFontIndirectW || !getObjectW || !hwnd2)
|
|
17476
|
+
if (!hwnd2)
|
|
16985
17477
|
return null;
|
|
16986
|
-
|
|
16987
|
-
const
|
|
16988
|
-
const cur = gui10.SendMessage(hwnd2, 49, 0, 0);
|
|
17478
|
+
let base = { lfHeight: -13 };
|
|
17479
|
+
const cur = gui9.SendMessage(hwnd2, 49, 0, 0);
|
|
16989
17480
|
if (cur) {
|
|
16990
|
-
const
|
|
16991
|
-
if (!
|
|
17481
|
+
const lf = LOGFONTW.alloc();
|
|
17482
|
+
if (!GetObject(cur, LOGFONTW.size, lf))
|
|
16992
17483
|
return null;
|
|
16993
|
-
|
|
16994
|
-
dv.setInt32(0, -13, true);
|
|
17484
|
+
base = LOGFONTW.decode(lf);
|
|
16995
17485
|
}
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17486
|
+
const h = CreateFontIndirect({
|
|
17487
|
+
...base,
|
|
17488
|
+
...style.bold ? {
|
|
17489
|
+
lfWeight: 700
|
|
17490
|
+
/* gui.FontWeight.BOLD */
|
|
17491
|
+
} : {},
|
|
17492
|
+
...style.italic ? { lfItalic: 1 } : {},
|
|
17493
|
+
...style.underline ? { lfUnderline: 1 } : {}
|
|
17494
|
+
});
|
|
17003
17495
|
fontCache.set(key, h ? h : 0);
|
|
17004
17496
|
return h ? h : null;
|
|
17005
17497
|
}
|
|
17006
17498
|
function handleCustomDraw(lParam, columns, data, hwnd2) {
|
|
17007
|
-
const stage =
|
|
17499
|
+
const { dwDrawStage: stage } = NMCUSTOMDRAW.decode(lParam);
|
|
17008
17500
|
if (stage === 1)
|
|
17009
17501
|
return 32;
|
|
17010
17502
|
if (stage === 65537)
|
|
17011
17503
|
return 32;
|
|
17012
17504
|
if (stage === 196609) {
|
|
17013
|
-
const
|
|
17014
|
-
const
|
|
17015
|
-
const style = resolveCellStyle(columns, data, row, colIndex);
|
|
17505
|
+
const cd = NMLVCUSTOMDRAW.decode(lParam);
|
|
17506
|
+
const style = resolveCellStyle(columns, data, cd.dwItemSpec, cd.iSubItem);
|
|
17016
17507
|
if (!style)
|
|
17017
17508
|
return 0;
|
|
17018
17509
|
if (style.color !== void 0)
|
|
@@ -17020,12 +17511,9 @@ function handleCustomDraw(lParam, columns, data, hwnd2) {
|
|
|
17020
17511
|
if (style.background !== void 0)
|
|
17021
17512
|
writeU32(lParam, CD_CLRTEXTBK, style.background);
|
|
17022
17513
|
const hfont = getCellFont(hwnd2, style);
|
|
17023
|
-
if (hfont &&
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
ffi7.ffiCall(selectObjectFn, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_POINTER], [hdc, hfont], ffi7.FFI_TYPE_POINTER);
|
|
17027
|
-
return 2;
|
|
17028
|
-
}
|
|
17514
|
+
if (hfont && cd.hdc) {
|
|
17515
|
+
SelectObject(cd.hdc, hfont);
|
|
17516
|
+
return 2;
|
|
17029
17517
|
}
|
|
17030
17518
|
}
|
|
17031
17519
|
return 0;
|
|
@@ -17056,14 +17544,14 @@ function resolveCellStyle(columns, data, row, colIndex) {
|
|
|
17056
17544
|
return style || void 0;
|
|
17057
17545
|
}
|
|
17058
17546
|
function makeLVItem(i, sub, text, image) {
|
|
17059
|
-
const textBuf =
|
|
17060
|
-
const
|
|
17547
|
+
const textBuf = WCHAR.encode(text);
|
|
17548
|
+
const b6 = LVITEMW.encode({
|
|
17061
17549
|
mask: 1 | (image !== void 0 ? 2 : 0),
|
|
17062
17550
|
iItem: i,
|
|
17063
17551
|
iSubItem: sub,
|
|
17064
17552
|
state: 0,
|
|
17065
17553
|
stateMask: 0,
|
|
17066
|
-
pszText:
|
|
17554
|
+
pszText: textBuf.ptr,
|
|
17067
17555
|
cchTextMax: 0,
|
|
17068
17556
|
iImage: image ?? 0,
|
|
17069
17557
|
lParam: 0,
|
|
@@ -17074,8 +17562,8 @@ function makeLVItem(i, sub, text, image) {
|
|
|
17074
17562
|
piColFmt: 0,
|
|
17075
17563
|
iGroup: 0
|
|
17076
17564
|
});
|
|
17077
|
-
|
|
17078
|
-
return
|
|
17565
|
+
b6.__textBuf = textBuf;
|
|
17566
|
+
return b6;
|
|
17079
17567
|
}
|
|
17080
17568
|
var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, data, style, icons, iconSize, getIcon }, ref) {
|
|
17081
17569
|
const lvRef = (0, import_react9.useRef)(null);
|
|
@@ -17087,36 +17575,36 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17087
17575
|
const il = iconListRef.current;
|
|
17088
17576
|
iconListRef.current = 0;
|
|
17089
17577
|
if (il) {
|
|
17090
|
-
|
|
17091
|
-
|
|
17578
|
+
gui9.SendMessage(h, 4099, 1, 0);
|
|
17579
|
+
gui9.ImageListDestroy(il);
|
|
17092
17580
|
}
|
|
17093
17581
|
if (!icons || icons.length === 0)
|
|
17094
17582
|
return;
|
|
17095
17583
|
const size = iconSize ?? 32;
|
|
17096
|
-
const img =
|
|
17584
|
+
const img = gui9.ImageListCreate(size, size, 32, icons.length, 1);
|
|
17097
17585
|
if (!img)
|
|
17098
17586
|
return;
|
|
17099
17587
|
for (const p of icons) {
|
|
17100
|
-
const hbm =
|
|
17588
|
+
const hbm = gui9.CreateBitmapFromPixels(size, size, p);
|
|
17101
17589
|
if (hbm) {
|
|
17102
|
-
|
|
17103
|
-
|
|
17590
|
+
gui9.ImageListAdd(img, hbm);
|
|
17591
|
+
DeleteObject(hbm);
|
|
17104
17592
|
}
|
|
17105
17593
|
}
|
|
17106
|
-
|
|
17594
|
+
gui9.SendMessage(h, 4099, 1, img);
|
|
17107
17595
|
iconListRef.current = img;
|
|
17108
17596
|
}, [icons, iconSize]);
|
|
17109
17597
|
(0, import_react9.useEffect)(() => {
|
|
17110
17598
|
const h = lvRef.current;
|
|
17111
17599
|
if (!h)
|
|
17112
17600
|
return;
|
|
17113
|
-
const hdr =
|
|
17601
|
+
const hdr = gui9.SendMessage(h, 4127, 0, 0);
|
|
17114
17602
|
if (hdr) {
|
|
17115
|
-
let n2 =
|
|
17603
|
+
let n2 = gui9.SendMessage(hdr, 4608, 0, 0);
|
|
17116
17604
|
for (let k = n2 - 1; k >= 0; k--)
|
|
17117
|
-
|
|
17605
|
+
gui9.SendMessage(h, 4124, k, 0);
|
|
17118
17606
|
}
|
|
17119
|
-
|
|
17607
|
+
gui9.SendMessage(
|
|
17120
17608
|
h,
|
|
17121
17609
|
4150,
|
|
17122
17610
|
0,
|
|
@@ -17125,12 +17613,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17125
17613
|
);
|
|
17126
17614
|
const n = columns.length;
|
|
17127
17615
|
for (let j = 0; j < n; j++) {
|
|
17128
|
-
const titleBuf =
|
|
17129
|
-
const lvc = LVCOLUMNW.
|
|
17616
|
+
const titleBuf = WCHAR.encode(columns[j].name);
|
|
17617
|
+
const lvc = LVCOLUMNW.encode({
|
|
17130
17618
|
mask: 4 | 2 | 1,
|
|
17131
17619
|
fmt: alignToFmt(columns[j].align),
|
|
17132
17620
|
cx: columns[j].width ?? 100,
|
|
17133
|
-
pszText:
|
|
17621
|
+
pszText: titleBuf.ptr,
|
|
17134
17622
|
cchTextMax: 0,
|
|
17135
17623
|
iSubItem: j,
|
|
17136
17624
|
iImage: 0,
|
|
@@ -17140,28 +17628,28 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17140
17628
|
cxIdeal: 0
|
|
17141
17629
|
});
|
|
17142
17630
|
lvc.__titleBuf = titleBuf;
|
|
17143
|
-
|
|
17631
|
+
gui9.SendMessage(h, 4193, j, lvc.ptr);
|
|
17144
17632
|
}
|
|
17145
17633
|
}, [columns]);
|
|
17146
17634
|
(0, import_react9.useEffect)(() => {
|
|
17147
17635
|
const h = lvRef.current;
|
|
17148
17636
|
if (!h)
|
|
17149
17637
|
return;
|
|
17150
|
-
|
|
17638
|
+
gui9.SendMessage(h, 4105, 0, 0);
|
|
17151
17639
|
const nCols = columns.length;
|
|
17152
17640
|
for (let i = 0; i < data.length; i++) {
|
|
17153
17641
|
const record = data[i];
|
|
17154
17642
|
const img = getIcon ? getIcon(record, i) : void 0;
|
|
17155
17643
|
const itemBuf = makeLVItem(i, 0, cellText(record, columns[0], i), img);
|
|
17156
|
-
|
|
17644
|
+
gui9.SendMessage(h, 4173, 0, itemBuf.ptr);
|
|
17157
17645
|
for (let j = 1; j < nCols; j++) {
|
|
17158
17646
|
const subBuf = makeLVItem(i, j, cellText(record, columns[j], i));
|
|
17159
|
-
|
|
17647
|
+
gui9.SendMessage(h, 4172, 0, subBuf.ptr);
|
|
17160
17648
|
}
|
|
17161
17649
|
}
|
|
17162
17650
|
for (let j = 0; j < columns.length; j++) {
|
|
17163
17651
|
if (columns[j].width == null) {
|
|
17164
|
-
|
|
17652
|
+
gui9.SendMessage(
|
|
17165
17653
|
h,
|
|
17166
17654
|
4126,
|
|
17167
17655
|
j,
|
|
@@ -17178,14 +17666,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17178
17666
|
return handleCustomDraw(e.lParam, columns, data, lvRef.current);
|
|
17179
17667
|
}
|
|
17180
17668
|
if (code === -100) {
|
|
17181
|
-
const uNewState =
|
|
17182
|
-
const uOldState = readU32(e.lParam, NMLV_UOLD);
|
|
17669
|
+
const { uNewState, uOldState } = NMLISTVIEW.decode(e.lParam);
|
|
17183
17670
|
if ((uNewState & 2) !== (uOldState & 2))
|
|
17184
17671
|
return 1;
|
|
17185
17672
|
}
|
|
17186
17673
|
if (code === -2) {
|
|
17187
|
-
const iItem =
|
|
17188
|
-
const iSubItem = readI32(e.lParam, NMIA_SUBITEM);
|
|
17674
|
+
const { iItem, iSubItem } = NMLISTVIEW.decode(e.lParam);
|
|
17189
17675
|
const col = columns[iSubItem];
|
|
17190
17676
|
const record = data[iItem];
|
|
17191
17677
|
if (col?.onCellClick && record !== void 0)
|
|
@@ -17203,33 +17689,20 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17203
17689
|
const h = lvRef.current;
|
|
17204
17690
|
if (!h)
|
|
17205
17691
|
return;
|
|
17206
|
-
|
|
17207
|
-
if (!
|
|
17208
|
-
return;
|
|
17209
|
-
const sp = gui10.GetCursorPos();
|
|
17210
|
-
if (!sp)
|
|
17692
|
+
const pt = POINT.alloc();
|
|
17693
|
+
if (!GetCursorPos(pt.ptr))
|
|
17211
17694
|
return;
|
|
17212
|
-
|
|
17213
|
-
const
|
|
17214
|
-
|
|
17215
|
-
|
|
17216
|
-
|
|
17217
|
-
const lvhi = new ArrayBuffer(24);
|
|
17218
|
-
const lvd = new DataView(lvhi);
|
|
17219
|
-
lvd.setInt32(0, sdv.getInt32(0, true), true);
|
|
17220
|
-
lvd.setInt32(4, sdv.getInt32(4, true), true);
|
|
17221
|
-
lvd.setInt32(12, -1, true);
|
|
17222
|
-
lvd.setInt32(16, -1, true);
|
|
17223
|
-
const lvhiPtr = bufPtr2(lvhi);
|
|
17224
|
-
gui10.SendMessage(h, 4153, 0, lvhiPtr);
|
|
17225
|
-
const iItem = readI32(lvhiPtr, 12);
|
|
17226
|
-
const iSubItem = readI32(lvhiPtr, 16);
|
|
17695
|
+
ScreenToClient(h, pt.ptr);
|
|
17696
|
+
const { x: sx, y: sy } = POINT.decode(pt);
|
|
17697
|
+
const hit = LVHITTESTINFO.encode({ pt: [sx, sy], iItem: -1, iSubItem: -1 });
|
|
17698
|
+
gui9.SendMessage(h, 4153, 0, hit.ptr);
|
|
17699
|
+
const { iItem, iSubItem } = LVHITTESTINFO.decode(hit);
|
|
17227
17700
|
const style2 = resolveCellStyle(columns, data, iItem, iSubItem);
|
|
17228
17701
|
if (!style2 || style2.cursor === void 0)
|
|
17229
17702
|
return;
|
|
17230
|
-
const hc =
|
|
17703
|
+
const hc = LoadCursor(NULL, style2.cursor);
|
|
17231
17704
|
if (hc) {
|
|
17232
|
-
|
|
17705
|
+
SetCursor(hc);
|
|
17233
17706
|
return 1;
|
|
17234
17707
|
}
|
|
17235
17708
|
return;
|
|
@@ -17239,7 +17712,7 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17239
17712
|
// _build/lib/react-qw/components/ProgressBar.js
|
|
17240
17713
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
17241
17714
|
var import_react10 = __toESM(require_react(), 1);
|
|
17242
|
-
import * as
|
|
17715
|
+
import * as gui10 from "gui";
|
|
17243
17716
|
var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style, smooth }, ref) => {
|
|
17244
17717
|
const pbRef = (0, import_react10.useRef)(null);
|
|
17245
17718
|
const ws = 268435456 | 8388608 | (smooth ? 1 : 0);
|
|
@@ -17247,8 +17720,8 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17247
17720
|
const h = pbRef.current;
|
|
17248
17721
|
if (!h)
|
|
17249
17722
|
return;
|
|
17250
|
-
|
|
17251
|
-
|
|
17723
|
+
gui10.SendMessage(h, 1030, 0, max);
|
|
17724
|
+
gui10.SendMessage(h, 1026, Math.min(value, max), 0);
|
|
17252
17725
|
}, [value, max]);
|
|
17253
17726
|
return (0, import_jsx_runtime9.jsx)("w", { type: "msctls_progress32", ws, style, ref: (h) => {
|
|
17254
17727
|
pbRef.current = h;
|
|
@@ -17262,7 +17735,7 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17262
17735
|
// _build/lib/react-qw/components/RadioButton.js
|
|
17263
17736
|
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
17264
17737
|
var import_react11 = __toESM(require_react(), 1);
|
|
17265
|
-
import * as
|
|
17738
|
+
import * as gui11 from "gui";
|
|
17266
17739
|
var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked, defaultChecked = false, onChange, label, style, disabled }, ref) => {
|
|
17267
17740
|
const [internalChecked, setInternalChecked] = (0, import_react11.useState)(defaultChecked);
|
|
17268
17741
|
const isControlled = controlledChecked !== void 0;
|
|
@@ -17272,7 +17745,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17272
17745
|
const h = rbRef.current;
|
|
17273
17746
|
if (!h)
|
|
17274
17747
|
return;
|
|
17275
|
-
|
|
17748
|
+
gui11.SendMessage(h, 241, displayChecked ? 1 : 0, 0);
|
|
17276
17749
|
}, [displayChecked]);
|
|
17277
17750
|
return (0, import_jsx_runtime10.jsx)("w", { type: "BUTTON", text: label ?? "", ws: 268435456 | 9, style, disabled, ref: (h) => {
|
|
17278
17751
|
rbRef.current = h;
|
|
@@ -17282,7 +17755,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17282
17755
|
ref.current = h;
|
|
17283
17756
|
}, onEvent: (e) => {
|
|
17284
17757
|
if (e.msg === 514) {
|
|
17285
|
-
const newChecked =
|
|
17758
|
+
const newChecked = gui11.SendMessage(e.hwnd, 240, 0, 0) !== 0;
|
|
17286
17759
|
if (newChecked !== displayChecked) {
|
|
17287
17760
|
if (!isControlled)
|
|
17288
17761
|
setInternalChecked(newChecked);
|
|
@@ -17295,24 +17768,27 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17295
17768
|
// _build/lib/react-qw/components/ScrollView.js
|
|
17296
17769
|
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
17297
17770
|
var import_react12 = __toESM(require_react(), 1);
|
|
17298
|
-
import * as
|
|
17771
|
+
import * as gui12 from "gui";
|
|
17299
17772
|
var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth, contentHeight }, ref) => {
|
|
17300
17773
|
const svRef = (0, import_react12.useRef)(null);
|
|
17301
17774
|
const contentRef = (0, import_react12.useRef)(null);
|
|
17302
17775
|
const scrollXRef = (0, import_react12.useRef)(0);
|
|
17303
17776
|
const scrollYRef = (0, import_react12.useRef)(0);
|
|
17304
17777
|
function updateScroll(sv, content) {
|
|
17305
|
-
const svRect =
|
|
17778
|
+
const svRect = gui12.GetClientRect(sv);
|
|
17306
17779
|
if (!svRect)
|
|
17307
17780
|
return;
|
|
17308
17781
|
const svW = svRect.right - svRect.left;
|
|
17309
17782
|
const svH = svRect.bottom - svRect.top;
|
|
17310
|
-
const
|
|
17783
|
+
const hdc = GetDC(NULL);
|
|
17784
|
+
const scale = hdc ? GetDeviceCaps(hdc, 88) / 96 : 1;
|
|
17785
|
+
if (hdc)
|
|
17786
|
+
ReleaseDC(NULL, hdc);
|
|
17311
17787
|
const natW = Math.round((contentWidth ?? svW / scale) * scale);
|
|
17312
17788
|
const natH = Math.round((contentHeight ?? svH / scale) * scale);
|
|
17313
17789
|
scrollXRef.current = Math.max(0, Math.min(scrollXRef.current, natW - svW));
|
|
17314
17790
|
scrollYRef.current = Math.max(0, Math.min(scrollYRef.current, natH - svH));
|
|
17315
|
-
|
|
17791
|
+
SetWindowPos(
|
|
17316
17792
|
content,
|
|
17317
17793
|
0,
|
|
17318
17794
|
-scrollXRef.current,
|
|
@@ -17324,18 +17800,18 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17324
17800
|
);
|
|
17325
17801
|
forceFlexLayout(content);
|
|
17326
17802
|
if (natW > svW) {
|
|
17327
|
-
|
|
17328
|
-
|
|
17803
|
+
gui12.SetScrollInfo(sv, 0, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
|
|
17804
|
+
ShowScrollBar(sv, 0, 1);
|
|
17329
17805
|
} else {
|
|
17330
17806
|
scrollXRef.current = 0;
|
|
17331
|
-
|
|
17807
|
+
ShowScrollBar(sv, 0, 0);
|
|
17332
17808
|
}
|
|
17333
17809
|
if (natH > svH) {
|
|
17334
|
-
|
|
17335
|
-
|
|
17810
|
+
gui12.SetScrollInfo(sv, 1, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
|
|
17811
|
+
ShowScrollBar(sv, 1, 1);
|
|
17336
17812
|
} else {
|
|
17337
17813
|
scrollYRef.current = 0;
|
|
17338
|
-
|
|
17814
|
+
ShowScrollBar(sv, 1, 0);
|
|
17339
17815
|
}
|
|
17340
17816
|
}
|
|
17341
17817
|
(0, import_react12.useLayoutEffect)(() => {
|
|
@@ -17351,7 +17827,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17351
17827
|
} else {
|
|
17352
17828
|
scrollXRef.current = newPos;
|
|
17353
17829
|
}
|
|
17354
|
-
|
|
17830
|
+
SetWindowPos(
|
|
17355
17831
|
content,
|
|
17356
17832
|
0,
|
|
17357
17833
|
-scrollXRef.current,
|
|
@@ -17361,14 +17837,14 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17361
17837
|
1 | 4
|
|
17362
17838
|
/* gui.SetWindowPosFlag.SWP_NOZORDER */
|
|
17363
17839
|
);
|
|
17364
|
-
|
|
17840
|
+
gui12.SetScrollInfo(sv, bar, { pos: newPos }, true);
|
|
17365
17841
|
}
|
|
17366
17842
|
function handleScroll(e, bar) {
|
|
17367
17843
|
const sv = svRef.current;
|
|
17368
17844
|
const content = contentRef.current;
|
|
17369
17845
|
if (!sv || !content)
|
|
17370
17846
|
return;
|
|
17371
|
-
const info =
|
|
17847
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17372
17848
|
const maxPos = info.max - info.page + 1;
|
|
17373
17849
|
const code = e.wParam & 65535;
|
|
17374
17850
|
const ref_ = bar === 1 ? scrollYRef : scrollXRef;
|
|
@@ -17402,7 +17878,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17402
17878
|
if (!isHorz && contentHeight === void 0)
|
|
17403
17879
|
return;
|
|
17404
17880
|
const bar = isHorz ? 0 : 1;
|
|
17405
|
-
const info =
|
|
17881
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17406
17882
|
const maxPos = info.max - info.page + 1;
|
|
17407
17883
|
const ref_ = isHorz ? scrollXRef : scrollYRef;
|
|
17408
17884
|
let newPos = ref_.current + dy;
|
|
@@ -17419,7 +17895,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17419
17895
|
}, onEvent: {
|
|
17420
17896
|
fn: (e) => {
|
|
17421
17897
|
if (e.msg === 132 || e.msg === 161) {
|
|
17422
|
-
return
|
|
17898
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17423
17899
|
}
|
|
17424
17900
|
if (e.msg === 277) {
|
|
17425
17901
|
handleScroll(
|
|
@@ -17451,7 +17927,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17451
17927
|
// _build/lib/react-qw/components/Slider.js
|
|
17452
17928
|
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
|
|
17453
17929
|
var import_react13 = __toESM(require_react(), 1);
|
|
17454
|
-
import * as
|
|
17930
|
+
import * as gui13 from "gui";
|
|
17455
17931
|
var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 100, vertical = false, disabled, style }, ref) => {
|
|
17456
17932
|
const wrapperRef = (0, import_react13.useRef)(null);
|
|
17457
17933
|
const sliderRef = (0, import_react13.useRef)(null);
|
|
@@ -17460,14 +17936,14 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17460
17936
|
if (!h)
|
|
17461
17937
|
return;
|
|
17462
17938
|
const lParam = min & 65535 | (max & 65535) << 16;
|
|
17463
|
-
|
|
17464
|
-
|
|
17939
|
+
gui13.SendMessage(h, 1030, 0, lParam);
|
|
17940
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17465
17941
|
}, [min, max]);
|
|
17466
17942
|
(0, import_react13.useEffect)(() => {
|
|
17467
17943
|
const h = sliderRef.current;
|
|
17468
17944
|
if (!h)
|
|
17469
17945
|
return;
|
|
17470
|
-
|
|
17946
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17471
17947
|
}, [value]);
|
|
17472
17948
|
const tbStyle = 268435456 | 65536 | 1 | (vertical ? 2 : 0);
|
|
17473
17949
|
return (0, import_jsx_runtime12.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style, ref: (h) => {
|
|
@@ -17478,13 +17954,13 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17478
17954
|
ref.current = h;
|
|
17479
17955
|
}, onEvent: (e) => {
|
|
17480
17956
|
if (e.msg === 132 || e.msg === 161) {
|
|
17481
|
-
return
|
|
17957
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17482
17958
|
}
|
|
17483
17959
|
if (e.msg === 276 || e.msg === 277) {
|
|
17484
17960
|
const h = sliderRef.current;
|
|
17485
17961
|
if (!h)
|
|
17486
17962
|
return 0;
|
|
17487
|
-
const pos =
|
|
17963
|
+
const pos = gui13.SendMessage(h, 1024, 0, 0);
|
|
17488
17964
|
onChange?.(pos);
|
|
17489
17965
|
return 0;
|
|
17490
17966
|
}
|
|
@@ -17497,24 +17973,7 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17497
17973
|
// _build/lib/react-qw/components/Tab.js
|
|
17498
17974
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
17499
17975
|
var import_react14 = __toESM(require_react(), 1);
|
|
17500
|
-
import * as
|
|
17501
|
-
import * as ffi8 from "ffi";
|
|
17502
|
-
var TCITEMW = struct({
|
|
17503
|
-
mask: "u32",
|
|
17504
|
-
dwState: "u32",
|
|
17505
|
-
dwStateMask: "u32",
|
|
17506
|
-
pszText: "ptr",
|
|
17507
|
-
cchTextMax: "i32",
|
|
17508
|
-
iImage: "i32",
|
|
17509
|
-
lParam: "ptr"
|
|
17510
|
-
});
|
|
17511
|
-
function textToUtf163(s) {
|
|
17512
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
17513
|
-
const dv = new DataView(buf);
|
|
17514
|
-
for (let i = 0; i < s.length; i++)
|
|
17515
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
17516
|
-
return buf;
|
|
17517
|
-
}
|
|
17976
|
+
import * as gui14 from "gui";
|
|
17518
17977
|
var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex, defaultSelectedIndex = 0, onChange, style }, ref) => {
|
|
17519
17978
|
const [internalIndex, setInternalIndex] = (0, import_react14.useState)(defaultSelectedIndex);
|
|
17520
17979
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -17524,27 +17983,27 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17524
17983
|
const h = tabHwnd.current;
|
|
17525
17984
|
if (!h)
|
|
17526
17985
|
return;
|
|
17527
|
-
|
|
17986
|
+
gui14.SendMessage(h, 4873, 0, 0);
|
|
17528
17987
|
for (let i = 0; i < tabs.length; i++) {
|
|
17529
|
-
const titleBuf =
|
|
17530
|
-
const tci = TCITEMW.
|
|
17988
|
+
const titleBuf = WCHAR.encode(tabs[i].title);
|
|
17989
|
+
const tci = TCITEMW.encode({
|
|
17531
17990
|
mask: 1,
|
|
17532
17991
|
dwState: 0,
|
|
17533
17992
|
dwStateMask: 0,
|
|
17534
|
-
pszText:
|
|
17993
|
+
pszText: titleBuf.ptr,
|
|
17535
17994
|
cchTextMax: tabs[i].title.length + 1,
|
|
17536
17995
|
iImage: 0,
|
|
17537
17996
|
lParam: 0
|
|
17538
17997
|
});
|
|
17539
|
-
const tciPtr =
|
|
17540
|
-
|
|
17998
|
+
const tciPtr = tci.ptr;
|
|
17999
|
+
gui14.SendMessage(h, 4926, i, tciPtr);
|
|
17541
18000
|
}
|
|
17542
|
-
|
|
18001
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17543
18002
|
}, [tabs]);
|
|
17544
18003
|
(0, import_react14.useEffect)(() => {
|
|
17545
18004
|
const h = tabHwnd.current;
|
|
17546
18005
|
if (h)
|
|
17547
|
-
|
|
18006
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17548
18007
|
}, [sel]);
|
|
17549
18008
|
return (0, import_jsx_runtime13.jsxs)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17550
18009
|
if (e.msg === 78) {
|
|
@@ -17553,7 +18012,7 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17553
18012
|
return;
|
|
17554
18013
|
const code = nmCode(e.lParam);
|
|
17555
18014
|
if (code === -552 || code === -2) {
|
|
17556
|
-
const newSel =
|
|
18015
|
+
const newSel = gui14.SendMessage(h, 4875, 0, 0);
|
|
17557
18016
|
if (newSel !== sel) {
|
|
17558
18017
|
if (!isControlled)
|
|
17559
18018
|
setInternalIndex(newSel);
|
|
@@ -17566,54 +18025,17 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17566
18025
|
|
|
17567
18026
|
// _build/lib/react-qw/components/Tooltip.js
|
|
17568
18027
|
var import_react15 = __toESM(require_react(), 1);
|
|
17569
|
-
import * as
|
|
17570
|
-
import * as ffi9 from "ffi";
|
|
17571
|
-
var TTTOOLINFOW = struct({
|
|
17572
|
-
cbSize: "u32",
|
|
17573
|
-
uFlags: "u32",
|
|
17574
|
-
hwnd: "ptr",
|
|
17575
|
-
uId: "ptr",
|
|
17576
|
-
rect: "i32[4]",
|
|
17577
|
-
hinst: "ptr",
|
|
17578
|
-
lpszText: "ptr",
|
|
17579
|
-
lParam: "ptr",
|
|
17580
|
-
lpReserved: "ptr"
|
|
17581
|
-
// WinXP+ 追加字段(系统 sizeof 含之)
|
|
17582
|
-
});
|
|
18028
|
+
import * as gui15 from "gui";
|
|
17583
18029
|
|
|
17584
18030
|
// _build/lib/react-qw/components/TreeView.js
|
|
17585
18031
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
17586
18032
|
var import_react16 = __toESM(require_react(), 1);
|
|
17587
|
-
import * as
|
|
17588
|
-
import * as ffi10 from "ffi";
|
|
17589
|
-
var TVITEM = struct({
|
|
17590
|
-
mask: "u32",
|
|
17591
|
-
hItem: "ptr",
|
|
17592
|
-
state: "u32",
|
|
17593
|
-
stateMask: "u32",
|
|
17594
|
-
pszText: "ptr",
|
|
17595
|
-
cchTextMax: "i32",
|
|
17596
|
-
iImage: "i32",
|
|
17597
|
-
iSelectedImage: "i32",
|
|
17598
|
-
cChildren: "i32",
|
|
17599
|
-
lParam: "ptr"
|
|
17600
|
-
});
|
|
17601
|
-
var TVINSERTSTRUCT = struct({ hParent: "ptr", hInsertAfter: "ptr", item: TVITEM });
|
|
17602
|
-
function textToUtf164(s) {
|
|
17603
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
17604
|
-
const dv = new DataView(buf);
|
|
17605
|
-
for (let i = 0; i < s.length; i++)
|
|
17606
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
17607
|
-
return buf;
|
|
17608
|
-
}
|
|
17609
|
-
function bufPtr3(buf) {
|
|
17610
|
-
return ffi10.bufferPtr(buf);
|
|
17611
|
-
}
|
|
18033
|
+
import * as gui16 from "gui";
|
|
17612
18034
|
function buildTvItem(textPtr, cChildren) {
|
|
17613
18035
|
let mask = 1;
|
|
17614
18036
|
if (cChildren > 0)
|
|
17615
18037
|
mask |= 64;
|
|
17616
|
-
return TVITEM.
|
|
18038
|
+
return TVITEM.encode({
|
|
17617
18039
|
mask,
|
|
17618
18040
|
hItem: 0,
|
|
17619
18041
|
state: 0,
|
|
@@ -17629,24 +18051,24 @@ function buildTvItem(textPtr, cChildren) {
|
|
|
17629
18051
|
function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
|
|
17630
18052
|
for (const node of nodes) {
|
|
17631
18053
|
const cChildren = node.children && node.children.length > 0 ? 1 : 0;
|
|
17632
|
-
const textBuf =
|
|
17633
|
-
const itemBuf = buildTvItem(
|
|
17634
|
-
const item = TVITEM.
|
|
17635
|
-
const tvins = TVINSERTSTRUCT.
|
|
17636
|
-
const hItem =
|
|
18054
|
+
const textBuf = WCHAR.encode(node.label);
|
|
18055
|
+
const itemBuf = buildTvItem(textBuf.ptr, cChildren);
|
|
18056
|
+
const item = TVITEM.decode(itemBuf);
|
|
18057
|
+
const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536, item });
|
|
18058
|
+
const hItem = gui16.SendMessage(hTree, 4402, 0, tvins.ptr);
|
|
17637
18059
|
hItemMap.set(hItem, node);
|
|
17638
18060
|
if (node.key)
|
|
17639
18061
|
keyMap.set(node.key, hItem);
|
|
17640
18062
|
if (node.children && node.children.length > 0) {
|
|
17641
18063
|
insertItems(hTree, node.children, hItem, hItemMap, keyMap);
|
|
17642
|
-
|
|
18064
|
+
gui16.SendMessage(hTree, 4354, 2, hItem);
|
|
17643
18065
|
}
|
|
17644
18066
|
}
|
|
17645
18067
|
}
|
|
17646
18068
|
function deleteAllItems(hTree) {
|
|
17647
|
-
const n =
|
|
18069
|
+
const n = gui16.SendMessage(hTree, 4357, 0, 0);
|
|
17648
18070
|
if (n > 0)
|
|
17649
|
-
|
|
18071
|
+
gui16.SendMessage(
|
|
17650
18072
|
hTree,
|
|
17651
18073
|
4353,
|
|
17652
18074
|
1,
|
|
@@ -17678,7 +18100,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17678
18100
|
const h = tvRef.current;
|
|
17679
18101
|
if (!h)
|
|
17680
18102
|
return;
|
|
17681
|
-
|
|
18103
|
+
gui16.SendMessage(
|
|
17682
18104
|
h,
|
|
17683
18105
|
4396,
|
|
17684
18106
|
0,
|
|
@@ -17694,7 +18116,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17694
18116
|
return;
|
|
17695
18117
|
const hItem = keyMapRef.current.get(selKey);
|
|
17696
18118
|
if (hItem !== void 0)
|
|
17697
|
-
|
|
18119
|
+
gui16.SendMessage(h, 4363, 9, hItem);
|
|
17698
18120
|
}, [selKey]);
|
|
17699
18121
|
return (0, import_jsx_runtime14.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17700
18122
|
if (e.msg === 78) {
|
|
@@ -17703,7 +18125,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17703
18125
|
const h = tvRef.current;
|
|
17704
18126
|
if (!h)
|
|
17705
18127
|
return;
|
|
17706
|
-
const hCaret =
|
|
18128
|
+
const hCaret = gui16.SendMessage(h, 4362, 9, 0);
|
|
17707
18129
|
const node = hItemMapRef.current.get(hCaret) ?? null;
|
|
17708
18130
|
const key = node?.key ?? null;
|
|
17709
18131
|
if (!isControlled)
|
|
@@ -17719,153 +18141,63 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17719
18141
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17720
18142
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
17721
18143
|
var import_react17 = __toESM(require_react(), 1);
|
|
17722
|
-
import * as ffi11 from "ffi";
|
|
17723
|
-
import * as win3 from "win";
|
|
17724
18144
|
|
|
17725
|
-
// _build/lib/
|
|
17726
|
-
var
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
|
|
17737
|
-
nMaxFileTitle: "u32",
|
|
17738
|
-
lpstrInitialDir: "ptr",
|
|
17739
|
-
lpstrTitle: "ptr",
|
|
17740
|
-
Flags: "u32",
|
|
17741
|
-
nFileOffset: "u16",
|
|
17742
|
-
nFileExtension: "u16",
|
|
17743
|
-
lpstrDefExt: "ptr",
|
|
17744
|
-
lCustData: "ptr",
|
|
17745
|
-
lpfnHook: "ptr",
|
|
17746
|
-
lpTemplateName: "ptr",
|
|
17747
|
-
pvReserved: "ptr",
|
|
17748
|
-
dwReserved: "u32",
|
|
17749
|
-
FlagsEx: "u32"
|
|
17750
|
-
});
|
|
17751
|
-
var BROWSEINFOW = struct({
|
|
17752
|
-
hwndOwner: "ptr",
|
|
17753
|
-
pidlRoot: "ptr",
|
|
17754
|
-
pszDisplayName: "ptr",
|
|
17755
|
-
lpszTitle: "ptr",
|
|
17756
|
-
ulFlags: "u32",
|
|
17757
|
-
lpfn: "ptr",
|
|
17758
|
-
lParam: "ptr",
|
|
17759
|
-
iImage: "i32"
|
|
17760
|
-
});
|
|
18145
|
+
// _build/lib/windows/comdlg32.js
|
|
18146
|
+
var b3 = (name, sig) => bind("comdlg32.dll", name, sig);
|
|
18147
|
+
var GetOpenFileName = /* @__PURE__ */ b3("GetOpenFileNameW", "<OPENFILENAMEW>ptr -> u32");
|
|
18148
|
+
|
|
18149
|
+
// _build/lib/windows/shell32.js
|
|
18150
|
+
var b4 = (name, sig) => bind("shell32.dll", name, sig);
|
|
18151
|
+
var SHBrowseForFolder = /* @__PURE__ */ b4("SHBrowseForFolderW", "<BROWSEINFOW>ptr -> <>ptr");
|
|
18152
|
+
var SHGetPathFromIDList = /* @__PURE__ */ b4("SHGetPathFromIDListW", "<>ptr <BYTE>ptr -> u32");
|
|
18153
|
+
|
|
18154
|
+
// _build/lib/windows/ole32.js
|
|
18155
|
+
var b5 = (name, sig) => bind("ole32.dll", name, sig);
|
|
18156
|
+
var CoTaskMemFree = /* @__PURE__ */ b5("CoTaskMemFree", "<>ptr -> void");
|
|
17761
18157
|
|
|
17762
18158
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17763
|
-
var FFI_PTR = ffi11.FFI_TYPE_POINTER;
|
|
17764
|
-
var FFI_U32 = ffi11.FFI_TYPE_UINT32;
|
|
17765
|
-
var _GetOpenFileNameW = 0;
|
|
17766
|
-
var _SHBrowseForFolderW = 0;
|
|
17767
|
-
var _SHGetPathFromIDListW = 0;
|
|
17768
|
-
var _CoTaskMemFree = 0;
|
|
17769
|
-
function ensureDlls() {
|
|
17770
|
-
if (_GetOpenFileNameW)
|
|
17771
|
-
return true;
|
|
17772
|
-
const comdlg32 = win3.LoadLibrary("comdlg32.dll");
|
|
17773
|
-
const shell32 = win3.LoadLibrary("shell32.dll");
|
|
17774
|
-
const ole32 = win3.LoadLibrary("ole32.dll");
|
|
17775
|
-
if (!comdlg32 || !shell32 || !ole32)
|
|
17776
|
-
return false;
|
|
17777
|
-
const load = (lib, name) => win3.GetProcAddress(lib, name) || 0;
|
|
17778
|
-
_GetOpenFileNameW = load(comdlg32, "GetOpenFileNameW");
|
|
17779
|
-
_SHBrowseForFolderW = load(shell32, "SHBrowseForFolderW");
|
|
17780
|
-
_SHGetPathFromIDListW = load(shell32, "SHGetPathFromIDListW");
|
|
17781
|
-
_CoTaskMemFree = load(ole32, "CoTaskMemFree");
|
|
17782
|
-
return !!_GetOpenFileNameW && !!_SHBrowseForFolderW && !!_SHGetPathFromIDListW && !!_CoTaskMemFree;
|
|
17783
|
-
}
|
|
17784
|
-
function strToWide(s) {
|
|
17785
|
-
return new TextEncoder("utf-16le").encode(s + "\0").buffer;
|
|
17786
|
-
}
|
|
17787
|
-
var _decoder = new TextDecoder("utf-16le");
|
|
17788
|
-
function wideToStr(buf, offset = 0) {
|
|
17789
|
-
const str = _decoder.decode(new Uint8Array(buf, offset));
|
|
17790
|
-
const nullIdx = str.indexOf("\0");
|
|
17791
|
-
return nullIdx >= 0 ? str.substring(0, nullIdx) : str;
|
|
17792
|
-
}
|
|
17793
18159
|
function openFileDialog(owner, filter, title, multiple) {
|
|
17794
|
-
|
|
17795
|
-
|
|
17796
|
-
const
|
|
17797
|
-
const filterWide = strToWide(filter);
|
|
17798
|
-
const titleWide = title ? strToWide(title) : null;
|
|
18160
|
+
const fileBuf = WCHAR.alloc(260);
|
|
18161
|
+
const filterWide = WCHAR.encode(filter);
|
|
18162
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
17799
18163
|
let flags = 4096 | 2048 | 8;
|
|
17800
18164
|
if (multiple)
|
|
17801
18165
|
flags |= 512;
|
|
17802
18166
|
flags |= 524288;
|
|
17803
|
-
const ofn = OPENFILENAMEW.
|
|
18167
|
+
const ofn = OPENFILENAMEW.encode({
|
|
17804
18168
|
lStructSize: OPENFILENAMEW.size,
|
|
17805
18169
|
hwndOwner: owner,
|
|
17806
|
-
|
|
17807
|
-
|
|
17808
|
-
lpstrCustomFilter: 0,
|
|
17809
|
-
nMaxCustFilter: 0,
|
|
17810
|
-
nFilterIndex: 0,
|
|
17811
|
-
lpstrFile: ffi11.bufferPtr(fileBuf),
|
|
18170
|
+
lpstrFilter: filterWide.ptr,
|
|
18171
|
+
lpstrFile: fileBuf.ptr,
|
|
17812
18172
|
nMaxFile: 260,
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
lpstrInitialDir: 0,
|
|
17816
|
-
lpstrTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17817
|
-
Flags: flags,
|
|
17818
|
-
nFileOffset: 0,
|
|
17819
|
-
nFileExtension: 0,
|
|
17820
|
-
lpstrDefExt: 0,
|
|
17821
|
-
lCustData: 0,
|
|
17822
|
-
lpfnHook: 0,
|
|
17823
|
-
lpTemplateName: 0,
|
|
17824
|
-
pvReserved: 0,
|
|
17825
|
-
dwReserved: 0,
|
|
17826
|
-
FlagsEx: 0
|
|
18173
|
+
lpstrTitle: titleWide?.ptr ?? 0,
|
|
18174
|
+
Flags: flags
|
|
17827
18175
|
});
|
|
17828
|
-
const ret =
|
|
18176
|
+
const ret = GetOpenFileName(ofn.ptr);
|
|
17829
18177
|
if (!ret)
|
|
17830
18178
|
return null;
|
|
17831
18179
|
if (!multiple) {
|
|
17832
|
-
return
|
|
17833
|
-
}
|
|
17834
|
-
const dir = wideToStr(fileBuf);
|
|
17835
|
-
let pos = (dir.length + 1) * 2;
|
|
17836
|
-
const files = [];
|
|
17837
|
-
while (pos < fileBuf.byteLength) {
|
|
17838
|
-
const f = wideToStr(fileBuf, pos);
|
|
17839
|
-
if (f.length === 0)
|
|
17840
|
-
break;
|
|
17841
|
-
files.push(dir + "\\" + f);
|
|
17842
|
-
pos += (f.length + 1) * 2;
|
|
18180
|
+
return WCHAR.decode(fileBuf);
|
|
17843
18181
|
}
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
18182
|
+
const strs = new TextDecoder("utf-16le").decode(new Uint8Array(fileBuf)).split("\0");
|
|
18183
|
+
const dir = strs[0] ?? "";
|
|
18184
|
+
const files = strs.slice(1).filter((f) => f.length > 0).map((f) => dir + "\\" + f);
|
|
18185
|
+
return files.length > 0 ? files : [dir];
|
|
17847
18186
|
}
|
|
17848
18187
|
function openFolderDialog(owner, title) {
|
|
17849
|
-
|
|
17850
|
-
|
|
17851
|
-
const titleWide = title ? strToWide(title) : null;
|
|
17852
|
-
const bi = BROWSEINFOW.write({
|
|
18188
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
18189
|
+
const bi = BROWSEINFOW.encode({
|
|
17853
18190
|
hwndOwner: owner,
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
lpszTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17857
|
-
ulFlags: 65,
|
|
17858
|
-
lpfn: 0,
|
|
17859
|
-
lParam: 0,
|
|
17860
|
-
iImage: 0
|
|
18191
|
+
lpszTitle: titleWide?.ptr ?? 0,
|
|
18192
|
+
ulFlags: 65
|
|
17861
18193
|
});
|
|
17862
|
-
const pidl =
|
|
18194
|
+
const pidl = SHBrowseForFolder(bi.ptr);
|
|
17863
18195
|
if (!pidl)
|
|
17864
18196
|
return null;
|
|
17865
|
-
const pathBuf =
|
|
17866
|
-
const ok =
|
|
17867
|
-
|
|
17868
|
-
return ok ?
|
|
18197
|
+
const pathBuf = WCHAR.alloc(260);
|
|
18198
|
+
const ok = SHGetPathFromIDList(pidl, pathBuf);
|
|
18199
|
+
CoTaskMemFree(pidl);
|
|
18200
|
+
return ok ? WCHAR.decode(pathBuf) : null;
|
|
17869
18201
|
}
|
|
17870
18202
|
var PathPicker = (0, import_react17.forwardRef)((props, ref) => {
|
|
17871
18203
|
const { type = "file", filter = "All Files\0*.*\0\0", title, disabled, style } = props;
|
|
@@ -17916,7 +18248,7 @@ var rootMap = /* @__PURE__ */ new Map();
|
|
|
17916
18248
|
function ensureDefaultClass() {
|
|
17917
18249
|
if (defaultClassRegistered)
|
|
17918
18250
|
return DEFAULT_CLASS;
|
|
17919
|
-
|
|
18251
|
+
gui17.RegisterClass(DEFAULT_CLASS, (hwnd2, msg, wParam, lParam) => {
|
|
17920
18252
|
const entry = rootMap.get(hwnd2);
|
|
17921
18253
|
if (msg === 2 && entry) {
|
|
17922
18254
|
rootMap.delete(hwnd2);
|
|
@@ -17929,7 +18261,7 @@ function ensureDefaultClass() {
|
|
|
17929
18261
|
return result;
|
|
17930
18262
|
if (msg === 5)
|
|
17931
18263
|
forceFlexLayout(hwnd2);
|
|
17932
|
-
return
|
|
18264
|
+
return DefWindowProc(hwnd2, msg, wParam, lParam);
|
|
17933
18265
|
});
|
|
17934
18266
|
defaultClassRegistered = true;
|
|
17935
18267
|
return DEFAULT_CLASS;
|
|
@@ -17942,19 +18274,19 @@ function createRoot(container) {
|
|
|
17942
18274
|
const ws = (cfg.ws ?? 0) | 13565952;
|
|
17943
18275
|
const w = (cfg.width ?? 800) * scaleFactor;
|
|
17944
18276
|
const h = (cfg.height ?? 600) * scaleFactor;
|
|
17945
|
-
const [sw, sh] =
|
|
18277
|
+
const [sw, sh] = [GetSystemMetrics(0), GetSystemMetrics(1)];
|
|
17946
18278
|
const x = cfg.x === void 0 ? (sw - w) / 2 | 0 : cfg.x === -2147483648 ? -2147483648 : cfg.x * scaleFactor;
|
|
17947
18279
|
const y = cfg.y === void 0 ? (sh - h) / 2 | 0 : cfg.y === -2147483648 ? -2147483648 : cfg.y * scaleFactor;
|
|
17948
|
-
const hwin =
|
|
18280
|
+
const hwin = gui17.CreateWindow(className, cfg.text || "", ws, x, y, w, h, null, null);
|
|
17949
18281
|
if (!hwin)
|
|
17950
18282
|
throw new Error("CreateWindow failed");
|
|
17951
18283
|
hwnd2 = hwin;
|
|
17952
18284
|
if (!cfg.noShowWindow)
|
|
17953
|
-
|
|
18285
|
+
gui17.ShowWindow(hwnd2);
|
|
17954
18286
|
} else {
|
|
17955
18287
|
hwnd2 = container;
|
|
17956
18288
|
}
|
|
17957
|
-
const root = reconciler_default.createContainer(hwnd2, 0, null, false, null, "",
|
|
18289
|
+
const root = reconciler_default.createContainer(hwnd2, 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);
|
|
17958
18290
|
const rootInst = { hwnd: hwnd2, type: "_root", props: { type: "_root", style: { flexDirection: "column", alignItems: "stretch" } }, children: [] };
|
|
17959
18291
|
instancesByHwnd.set(hwnd2, rootInst);
|
|
17960
18292
|
if (typeof container === "object")
|
|
@@ -17980,29 +18312,29 @@ function render(element, containerOrConfig, _callback) {
|
|
|
17980
18312
|
// _build/test/test_react_hidden.js
|
|
17981
18313
|
var WS_CHILD = 1073741824;
|
|
17982
18314
|
var WS_VISIBLE = 268435456;
|
|
17983
|
-
|
|
18315
|
+
gui18.RegisterClass("ReactHidden", (hwnd2, msg, wParam, lParam) => {
|
|
17984
18316
|
if (!hwnd2)
|
|
17985
|
-
return
|
|
18317
|
+
return gui18.DefWindowProc(hwnd2, msg, wParam, lParam);
|
|
17986
18318
|
if (msg === 2) {
|
|
17987
|
-
|
|
18319
|
+
gui18.PostQuitMessage(0);
|
|
17988
18320
|
return 0;
|
|
17989
18321
|
}
|
|
17990
18322
|
if (msg === 513) {
|
|
17991
|
-
|
|
18323
|
+
gui18.PostQuitMessage(0);
|
|
17992
18324
|
return 0;
|
|
17993
18325
|
}
|
|
17994
|
-
return
|
|
18326
|
+
return gui18.DefWindowProc(hwnd2, msg, wParam, lParam);
|
|
17995
18327
|
});
|
|
17996
18328
|
function App() {
|
|
17997
18329
|
const [hidden, setHidden] = (0, import_react18.useState)(true);
|
|
17998
18330
|
(0, import_react18.useEffect)(() => {
|
|
17999
|
-
|
|
18331
|
+
os5.setTimeout(() => setHidden(false), 2e3);
|
|
18000
18332
|
}, []);
|
|
18001
18333
|
return (0, import_jsx_runtime16.jsxs)("w", { type: "STATIC", ws: WS_CHILD | WS_VISIBLE, style: { width: 480, height: 360, flexDirection: "column", padding: 10, gap: 10 }, children: [(0, import_jsx_runtime16.jsx)("w", { type: "STATIC", text: "Click to close", ws: WS_CHILD | WS_VISIBLE, style: { width: 200, height: 30 } }), (0, import_jsx_runtime16.jsx)("w", { type: "STATIC", text: hidden ? "HIDDEN" : "VISIBLE", ws: WS_CHILD | WS_VISIBLE, hidden, style: { width: 200, height: 100 } })] });
|
|
18002
18334
|
}
|
|
18003
|
-
var hwnd =
|
|
18335
|
+
var hwnd = gui18.CreateWindow("ReactHidden", "Hidden Prop Test", 13565952, 200, 200, 500, 400, null, null);
|
|
18004
18336
|
if (hwnd) {
|
|
18005
|
-
|
|
18337
|
+
gui18.ShowWindow(hwnd);
|
|
18006
18338
|
render((0, import_jsx_runtime16.jsx)(App, {}), hwnd);
|
|
18007
18339
|
}
|
|
18008
18340
|
/*! Bundled license information:
|