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