quickwin 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +1 -2
- package/README.md +19 -23
- package/examples/PdfCanvas.js +8 -37
- package/examples/PdfCanvas.tsx +11 -41
- package/examples/exec_server.js +20054 -1423
- package/examples/exec_server.tsx +489 -0
- package/examples/exec_server_worker.js +383 -33
- package/examples/exec_server_worker.ts +408 -30
- package/examples/pdf_preview2.js +25 -82
- package/examples/pdf_preview2.ts +27 -84
- package/examples/pdf_viewer.js +1318 -1178
- package/examples/pdf_viewer.tsx +16 -67
- package/examples/setres.js +22 -47
- package/examples/setres.ts +23 -57
- package/examples/test_gallery.js +1313 -1074
- package/examples/test_react_lazy.js +1284 -1056
- package/examples/test_react_listbox.js +1283 -1055
- package/examples/test_root_window.js +1279 -1051
- package/examples/test_tab.js +1284 -1056
- package/lib/abort.js +70 -0
- package/lib/abort.ts +69 -0
- package/lib/certs.js +214 -0
- package/lib/certs.ts +224 -0
- package/lib/exec-log.js +15 -0
- package/lib/exec-log.ts +30 -0
- package/lib/fetch.js +37 -4
- package/lib/fetch.ts +35 -4
- package/lib/ffi/bind.js +352 -0
- package/lib/ffi/bind.ts +442 -0
- package/lib/ffi/ctype.js +168 -0
- package/lib/ffi/ctype.ts +331 -0
- package/lib/ffi/index.js +6 -0
- package/lib/ffi/index.ts +6 -0
- package/lib/ffi/struct.js +412 -0
- package/lib/ffi/struct.ts +664 -0
- package/lib/http-common.js +43 -5
- package/lib/http-common.ts +48 -6
- package/lib/http-server.js +187 -29
- package/lib/http-server.ts +177 -26
- package/lib/react-qw/components/DateTimePicker.js +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 +49 -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 +4 -2
- package/lib/react-qw/index.ts +4 -2
- 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 +18 -23
- package/lib/text-measure.ts +20 -25
- package/lib/websocket.js +12 -2
- package/lib/websocket.ts +15 -2
- package/lib/windows/comctl32.js +18 -0
- package/lib/windows/comctl32.ts +20 -0
- package/lib/windows/comdlg32.js +7 -0
- package/lib/windows/comdlg32.ts +9 -0
- package/lib/windows/gdi32.js +90 -0
- package/lib/windows/gdi32.ts +97 -0
- package/lib/windows/kernel32.js +66 -0
- package/lib/windows/kernel32.ts +76 -0
- package/lib/windows/ntdll.js +8 -0
- package/lib/windows/ntdll.ts +10 -0
- package/lib/windows/ole32.js +7 -0
- package/lib/windows/ole32.ts +9 -0
- package/lib/windows/shell32.js +11 -0
- package/lib/windows/shell32.ts +14 -0
- package/lib/windows/structs.js +384 -0
- package/lib/windows/structs.ts +422 -0
- package/lib/windows/user32.js +469 -0
- package/lib/windows/user32.ts +502 -0
- package/package.json +1 -1
- package/quickwin.d.ts +22 -37
- package/quickwin_const.d.ts +1 -0
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/test/bench_ffi_callraw.js +236 -0
- package/test/bench_ffi_callraw.ts +236 -0
- package/test/bench_ffi_overhead.js +139 -0
- package/test/bench_ffi_overhead.ts +141 -0
- package/test/bench_sendmessage.js +104 -0
- package/test/bench_sendmessage.ts +100 -0
- package/test/bench_sendmessage_nonnull.js +187 -0
- package/test/bench_sendmessage_nonnull.ts +188 -0
- package/test/run.js +12 -4
- package/test/run.ts +13 -5
- package/test/test_basic_fetch.js +8 -0
- package/test/test_basic_fetch.ts +9 -0
- package/test/test_ffi.js +25 -43
- package/test/test_ffi.ts +33 -52
- package/test/test_ffi_abi.js +235 -0
- package/test/test_ffi_abi.ts +218 -0
- package/test/test_ffi_bind.js +538 -8
- package/test/test_ffi_bind.ts +559 -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_helper.js +8 -1
- package/test/test_helper.ts +9 -1
- package/test/test_http_import.js +18 -0
- package/test/test_http_import.ts +19 -0
- package/test/test_http_server.js +73 -1
- package/test/test_http_server.ts +75 -1
- package/test/test_ipv6.js +2 -2
- package/test/test_ipv6.ts +2 -2
- package/test/test_net_fetch.js +70 -8
- package/test/test_net_fetch.ts +69 -7
- package/test/test_net_websocket.js +1 -1
- package/test/test_net_websocket.ts +1 -1
- package/test/test_react_complex.js +1294 -1066
- package/test/test_react_counter.js +1284 -1056
- package/test/test_react_flex.js +1304 -1069
- package/test/test_react_hidden.js +1287 -1059
- package/test/test_react_listview_link.js +1284 -1056
- package/test/test_react_notify.js +18534 -0
- package/test/test_react_render.js +1284 -1056
- package/test/test_wolfssl_read.js +3 -2
- package/test/test_wolfssl_read.ts +3 -1
- package/test/test_worker_net.js +35 -17
- package/test/test_worker_net.ts +27 -15
- package/tsconfig.json +1 -1
- package/examples/exec_server.ts +0 -80
- package/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/test/test_react_flex.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 hwnd = 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(hwnd, 176, 0, 0);
|
|
15382
|
-
cursor = sel >>> 16;
|
|
15383
|
-
}
|
|
15384
|
-
gui.SetWindowText(hwnd, textVal);
|
|
15385
|
-
if (instance.type === "EDIT" && cursor >= 0) {
|
|
15386
|
-
gui.SendMessage(hwnd, 177, cursor, cursor);
|
|
15387
|
-
}
|
|
15388
|
-
}
|
|
15389
|
-
if ("disabled" in newProps) {
|
|
15390
|
-
gui.EnableWindow(hwnd, !newProps.disabled);
|
|
15391
|
-
}
|
|
15392
|
-
if ("hidden" in newProps) {
|
|
15393
|
-
gui.ShowWindow(
|
|
15394
|
-
hwnd,
|
|
15395
|
-
newProps.hidden ? 0 : 5
|
|
15396
|
-
/* gui.ShowWindowCmd.SHOW */
|
|
15397
|
-
);
|
|
15398
|
-
}
|
|
15399
|
-
if ("visible" in newProps) {
|
|
15400
|
-
gui.ShowWindow(
|
|
15401
|
-
hwnd,
|
|
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,66 +15584,151 @@ 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 = /^<([^<>\s]*)>ptr(!|@[A-Za-z_]\w*)?$/;
|
|
15605
|
+
function isCPtrToken(t) {
|
|
15606
|
+
return PTR_TOKEN_RE.test(t);
|
|
15607
|
+
}
|
|
15608
|
+
function ptrName(t) {
|
|
15609
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15610
|
+
return m?.[1] || "";
|
|
15611
|
+
}
|
|
15612
|
+
var cTokenToType = (t) => {
|
|
15613
|
+
if (isCPtrToken(t))
|
|
15614
|
+
return "ptr";
|
|
15615
|
+
else
|
|
15616
|
+
return t;
|
|
15725
15617
|
};
|
|
15726
|
-
var
|
|
15727
|
-
|
|
15728
|
-
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
HRESULT: "i32",
|
|
15739
|
-
SHORT: "i16",
|
|
15740
|
-
USHORT: "u16",
|
|
15741
|
-
BYTE: "u8",
|
|
15742
|
-
LONG_PTR: "ptr",
|
|
15743
|
-
ULONG_PTR: "ptr",
|
|
15744
|
-
INT_PTR: "ptr",
|
|
15745
|
-
UINT_PTR: "ptr",
|
|
15746
|
-
DWORD_PTR: "ptr",
|
|
15747
|
-
SIZE_T: "ptr",
|
|
15748
|
-
WPARAM: "ptr",
|
|
15749
|
-
LPARAM: "ptr",
|
|
15750
|
-
HANDLE: "ptr",
|
|
15751
|
-
HWND: "ptr",
|
|
15752
|
-
HDC: "ptr",
|
|
15753
|
-
HMODULE: "ptr",
|
|
15754
|
-
HFONT: "ptr",
|
|
15755
|
-
HBRUSH: "ptr",
|
|
15756
|
-
HICON: "ptr",
|
|
15757
|
-
HBITMAP: "ptr",
|
|
15758
|
-
LPVOID: "ptr",
|
|
15759
|
-
LPCVOID: "ptr",
|
|
15760
|
-
LPCWSTR: "ptr",
|
|
15761
|
-
PCWSTR: "ptr",
|
|
15762
|
-
LPWSTR: "ptr"
|
|
15618
|
+
var PTR_SIZE = os.arch === "x64" ? 8 : 4;
|
|
15619
|
+
var SizeAlign = {
|
|
15620
|
+
u8: 1,
|
|
15621
|
+
i8: 1,
|
|
15622
|
+
u16: 2,
|
|
15623
|
+
i16: 2,
|
|
15624
|
+
u32: 4,
|
|
15625
|
+
i32: 4,
|
|
15626
|
+
u64: 8,
|
|
15627
|
+
i64: 8,
|
|
15628
|
+
f32: 4,
|
|
15629
|
+
f64: 8
|
|
15763
15630
|
};
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
if (
|
|
15767
|
-
|
|
15768
|
-
|
|
15631
|
+
var NULL = 0;
|
|
15632
|
+
function normToken(t) {
|
|
15633
|
+
if (isCPtrToken(t)) {
|
|
15634
|
+
const m = PTR_TOKEN_RE.exec(t);
|
|
15635
|
+
return m?.[2]?.startsWith("@") ? `<${m[1]}>ptr` : t;
|
|
15636
|
+
}
|
|
15637
|
+
const at = t.indexOf("@");
|
|
15638
|
+
const base = at >= 0 ? t.slice(0, at) : t;
|
|
15639
|
+
const suffixOk = at < 0 || /^[A-Za-z_]\w*$/.test(t.slice(at + 1));
|
|
15640
|
+
if (suffixOk && base !== "ptr" && C_BASIC_TYPE.includes(base))
|
|
15641
|
+
return base;
|
|
15642
|
+
throw new Error("Unknown token: " + t);
|
|
15643
|
+
}
|
|
15644
|
+
function readScalar(dv, off, k) {
|
|
15645
|
+
switch (k) {
|
|
15646
|
+
case "u8":
|
|
15647
|
+
return dv.getUint8(off);
|
|
15648
|
+
case "i8":
|
|
15649
|
+
return dv.getInt8(off);
|
|
15650
|
+
case "u16":
|
|
15651
|
+
return dv.getUint16(off, true);
|
|
15652
|
+
case "i16":
|
|
15653
|
+
return dv.getInt16(off, true);
|
|
15654
|
+
case "u32":
|
|
15655
|
+
return dv.getUint32(off, true);
|
|
15656
|
+
case "i32":
|
|
15657
|
+
return dv.getInt32(off, true);
|
|
15658
|
+
case "u64":
|
|
15659
|
+
return dv.getBigUint64(off, true);
|
|
15660
|
+
case "i64":
|
|
15661
|
+
return dv.getBigInt64(off, true);
|
|
15662
|
+
case "f32":
|
|
15663
|
+
return dv.getFloat32(off, true);
|
|
15664
|
+
case "f64":
|
|
15665
|
+
return dv.getFloat64(off, true);
|
|
15666
|
+
case "ptr": {
|
|
15667
|
+
return PTR_SIZE === 8 ? Number(dv.getBigInt64(off, true)) : dv.getInt32(off, true);
|
|
15668
|
+
}
|
|
15669
|
+
}
|
|
15769
15670
|
}
|
|
15671
|
+
function writeScalar(dv, off, { k, v }) {
|
|
15672
|
+
switch (k) {
|
|
15673
|
+
case "u8":
|
|
15674
|
+
dv.setUint8(off, Number(v));
|
|
15675
|
+
break;
|
|
15676
|
+
case "i8":
|
|
15677
|
+
dv.setInt8(off, Number(v));
|
|
15678
|
+
break;
|
|
15679
|
+
case "u16":
|
|
15680
|
+
dv.setUint16(off, Number(v), true);
|
|
15681
|
+
break;
|
|
15682
|
+
case "i16":
|
|
15683
|
+
dv.setInt16(off, Number(v), true);
|
|
15684
|
+
break;
|
|
15685
|
+
case "u32":
|
|
15686
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15687
|
+
break;
|
|
15688
|
+
case "i32":
|
|
15689
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15690
|
+
break;
|
|
15691
|
+
case "u64":
|
|
15692
|
+
dv.setBigUint64(off, v, true);
|
|
15693
|
+
break;
|
|
15694
|
+
case "i64":
|
|
15695
|
+
dv.setBigInt64(off, v, true);
|
|
15696
|
+
break;
|
|
15697
|
+
case "f32":
|
|
15698
|
+
dv.setFloat32(off, v, true);
|
|
15699
|
+
break;
|
|
15700
|
+
case "f64":
|
|
15701
|
+
dv.setFloat64(off, v, true);
|
|
15702
|
+
break;
|
|
15703
|
+
case "ptr": {
|
|
15704
|
+
if (v == null) {
|
|
15705
|
+
throw new Error("ffi: got null/undefined for a ptr slot; pass the imported NULL constant for empty");
|
|
15706
|
+
}
|
|
15707
|
+
if (PTR_SIZE === 8)
|
|
15708
|
+
dv.setBigUint64(off, BigInt.asUintN(64, BigInt(v)), true);
|
|
15709
|
+
else
|
|
15710
|
+
dv.setUint32(off, v >>> 0, true);
|
|
15711
|
+
break;
|
|
15712
|
+
}
|
|
15713
|
+
}
|
|
15714
|
+
}
|
|
15715
|
+
function writeSlot(dv, off, e) {
|
|
15716
|
+
const { k, v } = e;
|
|
15717
|
+
if (k === "u8" || k === "i8" || k === "u16" || k === "i16") {
|
|
15718
|
+
dv.setUint32(off, Number(v) >>> 0, true);
|
|
15719
|
+
return;
|
|
15720
|
+
}
|
|
15721
|
+
writeScalar(dv, off, e);
|
|
15722
|
+
}
|
|
15723
|
+
var PtrArrayBuffer = class extends ArrayBuffer {
|
|
15724
|
+
ptr;
|
|
15725
|
+
constructor(byteLength) {
|
|
15726
|
+
super(byteLength);
|
|
15727
|
+
this.ptr = bufferPtr(this);
|
|
15728
|
+
}
|
|
15729
|
+
};
|
|
15730
|
+
|
|
15731
|
+
// _build/lib/ffi/bind.js
|
|
15770
15732
|
var _dllCache = /* @__PURE__ */ new Map();
|
|
15771
15733
|
function loadDll(dll) {
|
|
15772
15734
|
const cached = _dllCache.get(dll);
|
|
@@ -15780,77 +15742,923 @@ function loadDll(dll) {
|
|
|
15780
15742
|
}
|
|
15781
15743
|
function parseSig(sig) {
|
|
15782
15744
|
const parts = sig.split(" -> ");
|
|
15783
|
-
|
|
15784
|
-
if (ret === void 0 || parts.length > 2) {
|
|
15745
|
+
if (parts.length !== 2) {
|
|
15785
15746
|
throw new Error(`ffi-bind: invalid signature "${sig}" (expected "arg1 arg2 -> ret")`);
|
|
15786
15747
|
}
|
|
15787
|
-
const
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15791
|
-
|
|
15792
|
-
|
|
15748
|
+
const rawArgs = parts[0].split(" ").filter((t) => t !== "");
|
|
15749
|
+
const argTokens = [];
|
|
15750
|
+
for (const raw of rawArgs) {
|
|
15751
|
+
const tok = normToken(raw);
|
|
15752
|
+
if (tok === "void") {
|
|
15753
|
+
throw new Error("Void can not in args");
|
|
15754
|
+
}
|
|
15755
|
+
argTokens.push(tok);
|
|
15756
|
+
}
|
|
15757
|
+
return {
|
|
15758
|
+
argTokens,
|
|
15759
|
+
retToken: normToken(parts[1]),
|
|
15760
|
+
sig
|
|
15761
|
+
};
|
|
15762
|
+
}
|
|
15763
|
+
function makeFn(proc, sig, encoders, decoders) {
|
|
15764
|
+
const ps = parseSig(sig);
|
|
15765
|
+
return (...a) => callPacked(proc, ps, a, encoders, decoders);
|
|
15793
15766
|
}
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15767
|
+
var IA32_ARG_SIZE = {
|
|
15768
|
+
u8: 4,
|
|
15769
|
+
i8: 4,
|
|
15770
|
+
u16: 4,
|
|
15771
|
+
i16: 4,
|
|
15772
|
+
u32: 4,
|
|
15773
|
+
i32: 4,
|
|
15774
|
+
u64: 8,
|
|
15775
|
+
i64: 8,
|
|
15776
|
+
f32: 4,
|
|
15777
|
+
f64: 8,
|
|
15778
|
+
ptr: PTR_SIZE
|
|
15779
|
+
};
|
|
15780
|
+
var X64_MIN_SLOTS = 4;
|
|
15781
|
+
function callPacked(proc, { argTokens, retToken, sig }, args, encoders, decoders) {
|
|
15782
|
+
const is64 = os2.arch === "x64";
|
|
15783
|
+
const getWidth = (t, is642) => {
|
|
15784
|
+
if (is642)
|
|
15785
|
+
return 8;
|
|
15786
|
+
if (isCPtrToken(t))
|
|
15787
|
+
return PTR_SIZE;
|
|
15788
|
+
return IA32_ARG_SIZE[t];
|
|
15801
15789
|
};
|
|
15790
|
+
let total = 0;
|
|
15791
|
+
for (const t of argTokens)
|
|
15792
|
+
total += getWidth(t, is64);
|
|
15793
|
+
if (is64 && argTokens.length < X64_MIN_SLOTS)
|
|
15794
|
+
total = X64_MIN_SLOTS * 8;
|
|
15795
|
+
const argFrame = new ArrayBuffer(total);
|
|
15796
|
+
const dv = new DataView(argFrame);
|
|
15797
|
+
const held = [];
|
|
15798
|
+
let off = 0;
|
|
15799
|
+
for (let i = 0; i < argTokens.length; i++) {
|
|
15800
|
+
const argToken = argTokens[i];
|
|
15801
|
+
const nonnull = argToken.endsWith("!");
|
|
15802
|
+
const arg = args[i];
|
|
15803
|
+
if (isCPtrToken(argToken)) {
|
|
15804
|
+
const name = ptrName(argToken);
|
|
15805
|
+
if (typeof arg === "number") {
|
|
15806
|
+
if (nonnull && arg === 0)
|
|
15807
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! got 0 (null pointer forbidden here; the token marks this position non-null)`);
|
|
15808
|
+
writeSlot(dv, off, { k: "ptr", v: arg });
|
|
15809
|
+
} else {
|
|
15810
|
+
if (arg === null || arg === void 0) {
|
|
15811
|
+
throw new Error(`ffi-bind: <${name}>ptr got ${String(arg)}; pass the imported NULL constant for an empty pointer`);
|
|
15812
|
+
}
|
|
15813
|
+
const codec = encoders[name];
|
|
15814
|
+
if (!codec) {
|
|
15815
|
+
throw new Error(name === "" ? `ffi-bind: <>ptr expects number (NULL | Ptr), got ${typeof arg}; use <BYTE>ptr with a PtrArrayBuffer (new PtrArrayBuffer(n)), or ffi.bufferPtr(buf) for an address` : `ffi-bind: unknown layout "<${name}>ptr" (available: ${Object.keys(encoders).join(", ") || "none"})`);
|
|
15816
|
+
}
|
|
15817
|
+
if (!codec.encode) {
|
|
15818
|
+
throw new Error(`ffi-bind: <${name}>ptr has no encoder (out-only codec)`);
|
|
15819
|
+
}
|
|
15820
|
+
const buf = codec.encode(arg);
|
|
15821
|
+
held.push(buf);
|
|
15822
|
+
const p = buf.ptr;
|
|
15823
|
+
if (typeof p !== "number")
|
|
15824
|
+
throw new Error("ffi-bind: codec.encode must return a PtrArrayBuffer, got plain ArrayBuffer");
|
|
15825
|
+
if (nonnull && p === 0)
|
|
15826
|
+
throw new Error(`ffi-bind: ${sig}: arg#${i + 1} <${name}>ptr! encode produced 0 (null pointer forbidden here)`);
|
|
15827
|
+
writeSlot(dv, off, { k: "ptr", v: p });
|
|
15828
|
+
}
|
|
15829
|
+
} else {
|
|
15830
|
+
writeSlot(dv, off, { k: argToken, v: arg });
|
|
15831
|
+
}
|
|
15832
|
+
off += getWidth(argToken, is64);
|
|
15833
|
+
}
|
|
15834
|
+
const retBuf = new ArrayBuffer(8);
|
|
15835
|
+
const retIsFp = retToken === "f32" || retToken === "f64";
|
|
15836
|
+
ffi.ffiCall(proc, argFrame, retBuf, retIsFp ? 1 : 0);
|
|
15837
|
+
const raw = readRet(cTokenToType(retToken), retBuf);
|
|
15838
|
+
if (retToken.endsWith("!") && raw === 0)
|
|
15839
|
+
throw new Error(`ffi-bind: ${sig}: return ${retToken} got 0 (the token promises C never returns null here)`);
|
|
15840
|
+
if (isCPtrToken(retToken) && raw !== 0) {
|
|
15841
|
+
const name = ptrName(retToken);
|
|
15842
|
+
if (name !== "") {
|
|
15843
|
+
const codec = decoders[name];
|
|
15844
|
+
if (codec?.decode)
|
|
15845
|
+
return codec.decode(raw);
|
|
15846
|
+
}
|
|
15847
|
+
}
|
|
15848
|
+
return raw;
|
|
15849
|
+
}
|
|
15850
|
+
function readRet(ret, retBuf) {
|
|
15851
|
+
if (ret === "void")
|
|
15852
|
+
return void 0;
|
|
15853
|
+
return readScalar(new DataView(retBuf), 0, ret);
|
|
15854
|
+
}
|
|
15855
|
+
var WCHAR = {
|
|
15856
|
+
encode: (v) => {
|
|
15857
|
+
const u8 = new TextEncoder("utf-16le").encode(v + "\0");
|
|
15858
|
+
const out = new PtrArrayBuffer(u8.byteLength);
|
|
15859
|
+
new Uint8Array(out).set(u8);
|
|
15860
|
+
return out;
|
|
15861
|
+
},
|
|
15862
|
+
decode: (p) => {
|
|
15863
|
+
if (typeof p === "number") {
|
|
15864
|
+
let s2 = "";
|
|
15865
|
+
let addr = p;
|
|
15866
|
+
const start = addr;
|
|
15867
|
+
for (; ; ) {
|
|
15868
|
+
const lo = ffi.readByte(addr);
|
|
15869
|
+
const hi = ffi.readByte(addr + 1);
|
|
15870
|
+
if (lo === 0 && hi === 0)
|
|
15871
|
+
return s2;
|
|
15872
|
+
s2 += String.fromCharCode(lo | hi << 8);
|
|
15873
|
+
addr += 2;
|
|
15874
|
+
if (addr - start > 1 << 21) {
|
|
15875
|
+
throw new Error("ffi-bind: WCHAR decode exceeded 4MiB without NUL");
|
|
15876
|
+
}
|
|
15877
|
+
}
|
|
15878
|
+
}
|
|
15879
|
+
const u8 = new Uint8Array(p);
|
|
15880
|
+
const limit = u8.length & ~1;
|
|
15881
|
+
let s = "";
|
|
15882
|
+
for (let i = 0; i < limit; i += 2) {
|
|
15883
|
+
const c = u8[i] | u8[i + 1] << 8;
|
|
15884
|
+
if (c === 0)
|
|
15885
|
+
return s;
|
|
15886
|
+
s += String.fromCharCode(c);
|
|
15887
|
+
}
|
|
15888
|
+
return s;
|
|
15889
|
+
},
|
|
15890
|
+
alloc: (size = 256) => new PtrArrayBuffer(size * 2)
|
|
15891
|
+
};
|
|
15892
|
+
var BYTE = {
|
|
15893
|
+
encode: (v) => {
|
|
15894
|
+
if (!(v instanceof PtrArrayBuffer))
|
|
15895
|
+
throw new Error("ffi-bind: <BYTE>ptr wants a PtrArrayBuffer (new PtrArrayBuffer(n) / BYTE.alloc / struct.encode), not a plain ArrayBuffer");
|
|
15896
|
+
return v;
|
|
15897
|
+
},
|
|
15898
|
+
alloc: (byteLen) => new PtrArrayBuffer(byteLen)
|
|
15899
|
+
};
|
|
15900
|
+
var builtinCodecs = { WCHAR, BYTE };
|
|
15901
|
+
function bind(dll, name, sig, encoders, decoders) {
|
|
15902
|
+
const proc = win.GetProcAddress(loadDll(dll), name);
|
|
15903
|
+
if (!proc)
|
|
15904
|
+
throw new Error(`ffi-bind: proc "${name}" not found in ${dll}`);
|
|
15905
|
+
const effDec = decoders ?? encoders;
|
|
15906
|
+
return makeFn(proc, sig, { ...builtinCodecs, ...encoders }, { ...builtinCodecs, ...effDec ?? {} });
|
|
15907
|
+
}
|
|
15908
|
+
var leakRegistry = new FinalizationRegistry((held) => {
|
|
15909
|
+
std.printf('[ffi] closure leaked (GCed without dispose): sig="%s" ptr=0x%x\n', held.sig, held.ptr);
|
|
15910
|
+
});
|
|
15911
|
+
|
|
15912
|
+
// _build/lib/ffi/struct.js
|
|
15913
|
+
import * as ffi2 from "ffi";
|
|
15914
|
+
function alignUp(v, a) {
|
|
15915
|
+
return v + a - 1 & ~(a - 1);
|
|
15916
|
+
}
|
|
15917
|
+
var isCNumberToken = (t) => SizeAlign[t] !== void 0;
|
|
15918
|
+
function lower(v) {
|
|
15919
|
+
if (typeof v === "string") {
|
|
15920
|
+
const st = /^(u8|u16)\[(\d+)\]@(utf-8|utf-16le)$/.exec(v);
|
|
15921
|
+
if (st) {
|
|
15922
|
+
const length = Number(st[2]);
|
|
15923
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15924
|
+
throw new Error(`ffi-struct: string length must be an integer >= 1, got ${length}`);
|
|
15925
|
+
const s2 = st[1] === "u8" ? 1 : 2;
|
|
15926
|
+
return { size: s2 * length, align: s2, type: { tag: "string", encoding: st[3] } };
|
|
15927
|
+
}
|
|
15928
|
+
const a = /^([^\[\]]+)\[(\d+)\]$/.exec(v);
|
|
15929
|
+
if (a) {
|
|
15930
|
+
const length = Number(a[2]);
|
|
15931
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15932
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${length}`);
|
|
15933
|
+
const el = lower(a[1]);
|
|
15934
|
+
if (el.type.tag === "bitfield")
|
|
15935
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
15936
|
+
return {
|
|
15937
|
+
size: el.size * length,
|
|
15938
|
+
align: el.align,
|
|
15939
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
15940
|
+
};
|
|
15941
|
+
}
|
|
15942
|
+
const b6 = /^([A-Za-z_]\w*):(\d+)$/.exec(v);
|
|
15943
|
+
if (b6) {
|
|
15944
|
+
const rawUnit = b6[1];
|
|
15945
|
+
const unit = normToken(rawUnit);
|
|
15946
|
+
if (!isCNumberToken(unit) || unit === "f32" || unit === "f64")
|
|
15947
|
+
throw new Error(`ffi-struct: bitfield unit must be an integer type, got "${rawUnit}"`);
|
|
15948
|
+
const width = Number(b6[2]);
|
|
15949
|
+
const s2 = SizeAlign[unit];
|
|
15950
|
+
const cap = s2 * 8;
|
|
15951
|
+
if (!Number.isInteger(width) || width < 1)
|
|
15952
|
+
throw new Error(`ffi-struct: bitfield width must be an integer >= 1, got ${width}`);
|
|
15953
|
+
if (width > cap)
|
|
15954
|
+
throw new Error(`ffi-struct: bitfield width ${width} exceeds unit width ${cap}`);
|
|
15955
|
+
return { size: s2, align: s2, type: { tag: "bitfield", unit, bit: 0, width } };
|
|
15956
|
+
}
|
|
15957
|
+
const k = normToken(v);
|
|
15958
|
+
if (isCPtrToken(k))
|
|
15959
|
+
return { size: PTR_SIZE, align: PTR_SIZE, type: { tag: "basic", kind: "ptr" } };
|
|
15960
|
+
if (!isCNumberToken(k))
|
|
15961
|
+
throw new Error(`ffi-struct: unknown kind "${v}"`);
|
|
15962
|
+
const s = SizeAlign[k];
|
|
15963
|
+
return { size: s, align: s, type: { tag: "basic", kind: k } };
|
|
15964
|
+
}
|
|
15965
|
+
if (v && typeof v === "object") {
|
|
15966
|
+
const o = v;
|
|
15967
|
+
const tag = o["#"];
|
|
15968
|
+
if (tag === void 0)
|
|
15969
|
+
throw new Error(`ffi-struct: nested object value requires a '#' key ('struct' | 'union' | 'array')`);
|
|
15970
|
+
if (tag === "array" && "#pack" in o)
|
|
15971
|
+
throw new Error(`ffi-struct: '#pack' is only allowed on struct/union, got '${tag}'`);
|
|
15972
|
+
if (tag === "array") {
|
|
15973
|
+
const length = o["length"];
|
|
15974
|
+
if (!Number.isInteger(length) || length < 1)
|
|
15975
|
+
throw new Error(`ffi-struct: array length must be an integer >= 1, got ${String(length)}`);
|
|
15976
|
+
const el = lower(o["element"]);
|
|
15977
|
+
if (el.type.tag === "bitfield")
|
|
15978
|
+
throw new Error("ffi-struct: bitfields cannot be array elements");
|
|
15979
|
+
return {
|
|
15980
|
+
size: el.size * length,
|
|
15981
|
+
align: el.align,
|
|
15982
|
+
type: { tag: "array", elementType: el.type, elementSize: el.size }
|
|
15983
|
+
};
|
|
15984
|
+
}
|
|
15985
|
+
if (tag === "struct" || tag === "union") {
|
|
15986
|
+
const l = computeStructLayout(v);
|
|
15987
|
+
return { size: l.size, align: l.maxEffectiveAlign, type: { tag, fields: l.fields } };
|
|
15988
|
+
}
|
|
15989
|
+
throw new Error(`ffi-struct: unknown '#' declaration ${JSON.stringify(String(tag))}`);
|
|
15990
|
+
}
|
|
15991
|
+
throw new Error(`ffi-struct: invalid member value: ${String(v)}`);
|
|
15992
|
+
}
|
|
15993
|
+
function computeStructLayout(t) {
|
|
15994
|
+
const isStruct = t["#"] === "struct";
|
|
15995
|
+
const pack = t["#pack"] ?? 8;
|
|
15996
|
+
let maxEffectiveAlign = 1;
|
|
15997
|
+
let maxMemberSize = 0;
|
|
15998
|
+
const fields = [];
|
|
15999
|
+
let cursor = 0;
|
|
16000
|
+
let unitBase = -1;
|
|
16001
|
+
let unitBits = 0;
|
|
16002
|
+
let unitSize = 0;
|
|
16003
|
+
const flushUnit = () => {
|
|
16004
|
+
if (unitBase < 0)
|
|
16005
|
+
return;
|
|
16006
|
+
cursor = alignUp(unitBase + Math.ceil(unitBits / 8), unitSize);
|
|
16007
|
+
unitBase = -1;
|
|
16008
|
+
};
|
|
16009
|
+
for (const [rawName, v] of Object.entries(t)) {
|
|
16010
|
+
if (rawName.startsWith("#"))
|
|
16011
|
+
continue;
|
|
16012
|
+
const m = /^([^@]+)@(\d+)$/.exec(rawName);
|
|
16013
|
+
const name = m ? m[1] : rawName;
|
|
16014
|
+
const alignas = m ? Number(m[2]) : 0;
|
|
16015
|
+
const { size, align: natural, type } = lower(v);
|
|
16016
|
+
const nonnull = typeof v === "string" && v.endsWith("!");
|
|
16017
|
+
let align = natural;
|
|
16018
|
+
if (pack > 0)
|
|
16019
|
+
align = Math.min(pack, align);
|
|
16020
|
+
if (alignas)
|
|
16021
|
+
align = Math.max(align, alignas);
|
|
16022
|
+
if (type.tag === "bitfield") {
|
|
16023
|
+
if (name.startsWith("$"))
|
|
16024
|
+
throw new Error("ffi-struct: bitfield members must be named");
|
|
16025
|
+
if (!isStruct) {
|
|
16026
|
+
fields.push({ name, offset: 0, size, type: { ...type, bit: 0 } });
|
|
16027
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16028
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16029
|
+
continue;
|
|
16030
|
+
}
|
|
16031
|
+
const width = type.width;
|
|
16032
|
+
if (unitBase < 0 || size !== unitSize || unitBits + width > unitSize * 8) {
|
|
16033
|
+
if (unitBase >= 0)
|
|
16034
|
+
flushUnit();
|
|
16035
|
+
const offset2 = alignUp(cursor, align);
|
|
16036
|
+
unitBase = offset2;
|
|
16037
|
+
unitBits = 0;
|
|
16038
|
+
unitSize = size;
|
|
16039
|
+
}
|
|
16040
|
+
fields.push({
|
|
16041
|
+
name,
|
|
16042
|
+
offset: unitBase,
|
|
16043
|
+
// 单元基址(不是位域自己的地址)
|
|
16044
|
+
size,
|
|
16045
|
+
type: { ...type, bit: unitBits }
|
|
16046
|
+
});
|
|
16047
|
+
unitBits += width;
|
|
16048
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16049
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16050
|
+
continue;
|
|
16051
|
+
}
|
|
16052
|
+
flushUnit();
|
|
16053
|
+
const offset = alignUp(cursor, align);
|
|
16054
|
+
if (!name.startsWith("$")) {
|
|
16055
|
+
fields.push({ name, offset, size, type, ...nonnull ? { nonnull: true } : {} });
|
|
16056
|
+
} else {
|
|
16057
|
+
if (type.tag !== "struct" && type.tag !== "union")
|
|
16058
|
+
throw new Error(`ffi-struct: anonymous member "${name}" must be a struct/union`);
|
|
16059
|
+
for (const cf of type.fields)
|
|
16060
|
+
fields.push({ ...cf, offset: cf.offset + offset });
|
|
16061
|
+
}
|
|
16062
|
+
if (isStruct)
|
|
16063
|
+
cursor = offset + size;
|
|
16064
|
+
maxEffectiveAlign = Math.max(maxEffectiveAlign, align);
|
|
16065
|
+
maxMemberSize = Math.max(maxMemberSize, size);
|
|
16066
|
+
}
|
|
16067
|
+
flushUnit();
|
|
16068
|
+
return {
|
|
16069
|
+
size: isStruct ? alignUp(cursor, maxEffectiveAlign) : alignUp(maxMemberSize, maxEffectiveAlign),
|
|
16070
|
+
maxEffectiveAlign,
|
|
16071
|
+
fields
|
|
16072
|
+
};
|
|
16073
|
+
}
|
|
16074
|
+
function readUnitRaw(dv, off, unit) {
|
|
16075
|
+
const s = SizeAlign[unit];
|
|
16076
|
+
if (s === 1)
|
|
16077
|
+
return BigInt(dv.getUint8(off));
|
|
16078
|
+
if (s === 2)
|
|
16079
|
+
return BigInt(dv.getUint16(off, true));
|
|
16080
|
+
if (s === 4)
|
|
16081
|
+
return BigInt(dv.getUint32(off, true));
|
|
16082
|
+
return dv.getBigUint64(off, true);
|
|
16083
|
+
}
|
|
16084
|
+
function writeUnitRaw(dv, off, unit, v) {
|
|
16085
|
+
const s = SizeAlign[unit];
|
|
16086
|
+
if (s === 1) {
|
|
16087
|
+
dv.setUint8(off, Number(v & 0xffn));
|
|
16088
|
+
return;
|
|
16089
|
+
}
|
|
16090
|
+
if (s === 2) {
|
|
16091
|
+
dv.setUint16(off, Number(v & 0xffffn), true);
|
|
16092
|
+
return;
|
|
16093
|
+
}
|
|
16094
|
+
if (s === 4) {
|
|
16095
|
+
dv.setUint32(off, Number(v & 0xffffffffn), true);
|
|
16096
|
+
return;
|
|
16097
|
+
}
|
|
16098
|
+
dv.setBigUint64(off, v & 0xffffffffffffffffn, true);
|
|
16099
|
+
}
|
|
16100
|
+
function readBitfield(dv, off, t) {
|
|
16101
|
+
const w = BigInt(t.width);
|
|
16102
|
+
let v = readUnitRaw(dv, off, t.unit) >> BigInt(t.bit) & (1n << w) - 1n;
|
|
16103
|
+
if (t.unit[0] === "i" && v & 1n << w - 1n)
|
|
16104
|
+
v -= 1n << w;
|
|
16105
|
+
if (t.width > 53)
|
|
16106
|
+
return v;
|
|
16107
|
+
return Number(v);
|
|
16108
|
+
}
|
|
16109
|
+
function writeBitfield(dv, off, t, val) {
|
|
16110
|
+
const w = BigInt(t.width);
|
|
16111
|
+
const bit = BigInt(t.bit);
|
|
16112
|
+
const widthMask = (1n << w) - 1n;
|
|
16113
|
+
const posMask = widthMask << bit;
|
|
16114
|
+
const raw = readUnitRaw(dv, off, t.unit);
|
|
16115
|
+
const bits = (typeof val === "bigint" ? val : BigInt(Math.trunc(val))) & widthMask;
|
|
16116
|
+
writeUnitRaw(dv, off, t.unit, raw & ~posMask | bits << bit);
|
|
16117
|
+
}
|
|
16118
|
+
var stringEncoders = {
|
|
16119
|
+
"utf-8": new TextEncoder("utf-8"),
|
|
16120
|
+
"utf-16le": new TextEncoder("utf-16le")
|
|
16121
|
+
};
|
|
16122
|
+
var stringDecoders = {
|
|
16123
|
+
"utf-8": new TextDecoder("utf-8", { ignoreBOM: true }),
|
|
16124
|
+
"utf-16le": new TextDecoder("utf-16le", { ignoreBOM: true })
|
|
16125
|
+
};
|
|
16126
|
+
function readString(dv, off, size, enc) {
|
|
16127
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16128
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16129
|
+
let end = size;
|
|
16130
|
+
for (let i = 0; i + unit <= size; i += unit) {
|
|
16131
|
+
if (bytes[i] === 0 && (unit === 1 || bytes[i + 1] === 0)) {
|
|
16132
|
+
end = i;
|
|
16133
|
+
break;
|
|
16134
|
+
}
|
|
16135
|
+
}
|
|
16136
|
+
return stringDecoders[enc].decode(bytes.subarray(0, end));
|
|
16137
|
+
}
|
|
16138
|
+
function writeString(dv, off, size, enc, v) {
|
|
16139
|
+
const bytes = new Uint8Array(dv.buffer, dv.byteOffset + off, size);
|
|
16140
|
+
bytes.fill(0);
|
|
16141
|
+
const unit = enc === "utf-16le" ? 2 : 1;
|
|
16142
|
+
const cap = size - unit;
|
|
16143
|
+
if (cap <= 0)
|
|
16144
|
+
return;
|
|
16145
|
+
const src = stringEncoders[enc].encode(String(v ?? ""));
|
|
16146
|
+
bytes.set(src.subarray(0, Math.min(src.length, cap)));
|
|
16147
|
+
}
|
|
16148
|
+
function readArray(dv, off, size, t) {
|
|
16149
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16150
|
+
const out = [];
|
|
16151
|
+
for (let i = 0; i < count; i++)
|
|
16152
|
+
out.push(readElement(dv, off + i * t.elementSize, t.elementType, t.elementSize));
|
|
16153
|
+
return out;
|
|
16154
|
+
}
|
|
16155
|
+
function writeArray(dv, off, size, t, v) {
|
|
16156
|
+
const count = t.elementSize > 0 ? size / t.elementSize : 0;
|
|
16157
|
+
const list = v ?? [];
|
|
16158
|
+
for (let i = 0; i < count; i++)
|
|
16159
|
+
writeElement(dv, off + i * t.elementSize, t.elementType, t.elementSize, list[i]);
|
|
16160
|
+
}
|
|
16161
|
+
function readElement(dv, off, t, size) {
|
|
16162
|
+
switch (t.tag) {
|
|
16163
|
+
case "basic":
|
|
16164
|
+
return readScalar(dv, off, t.kind);
|
|
16165
|
+
case "bitfield":
|
|
16166
|
+
return readBitfield(dv, off, t);
|
|
16167
|
+
case "string":
|
|
16168
|
+
return readString(dv, off, size, t.encoding);
|
|
16169
|
+
case "struct":
|
|
16170
|
+
case "union":
|
|
16171
|
+
return doDecode(dv, off, t.fields);
|
|
16172
|
+
case "array":
|
|
16173
|
+
return readArray(dv, off, size, t);
|
|
16174
|
+
}
|
|
16175
|
+
}
|
|
16176
|
+
function writeElement(dv, off, t, size, val) {
|
|
16177
|
+
switch (t.tag) {
|
|
16178
|
+
// TODO: remove this any
|
|
16179
|
+
case "basic":
|
|
16180
|
+
writeScalar(dv, off, { k: t.kind, v: val });
|
|
16181
|
+
break;
|
|
16182
|
+
// 直传(不 Number()):writeBitfield 的 val 是 number | bigint,
|
|
16183
|
+
// 64 位单元走 bigint,先 Number() 会把 >2^53 的位域值截断。
|
|
16184
|
+
case "bitfield":
|
|
16185
|
+
writeBitfield(dv, off, t, val ?? 0);
|
|
16186
|
+
break;
|
|
16187
|
+
case "string":
|
|
16188
|
+
writeString(dv, off, size, t.encoding, val);
|
|
16189
|
+
break;
|
|
16190
|
+
case "struct":
|
|
16191
|
+
case "union":
|
|
16192
|
+
doEncode(dv, off, t.fields, val ?? {});
|
|
16193
|
+
break;
|
|
16194
|
+
case "array":
|
|
16195
|
+
writeArray(dv, off, size, t, val);
|
|
16196
|
+
break;
|
|
16197
|
+
}
|
|
15802
16198
|
}
|
|
15803
|
-
function
|
|
16199
|
+
function doDecode(dv, base, fields) {
|
|
15804
16200
|
const out = {};
|
|
15805
|
-
const
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
|
|
15809
|
-
|
|
15810
|
-
out[name] = makeFn(proc, sig);
|
|
16201
|
+
for (const f of fields) {
|
|
16202
|
+
const v = readElement(dv, base + f.offset, f.type, f.size);
|
|
16203
|
+
if (f.nonnull && v === 0)
|
|
16204
|
+
throw new Error(`ffi-struct: decode: '!' field "${f.name}" got 0 (C did not fill it, or decode was called on an unfilled slot)`);
|
|
16205
|
+
out[f.name] = v;
|
|
15811
16206
|
}
|
|
15812
16207
|
return out;
|
|
15813
16208
|
}
|
|
16209
|
+
function doEncode(dv, base, fields, v) {
|
|
16210
|
+
for (const f of fields) {
|
|
16211
|
+
if (v[f.name] === void 0)
|
|
16212
|
+
continue;
|
|
16213
|
+
writeElement(dv, base + f.offset, f.type, f.size, v[f.name]);
|
|
16214
|
+
}
|
|
16215
|
+
}
|
|
16216
|
+
function createStruct(t) {
|
|
16217
|
+
const { fields, size, maxEffectiveAlign } = computeStructLayout(t);
|
|
16218
|
+
return {
|
|
16219
|
+
__struct: t,
|
|
16220
|
+
size,
|
|
16221
|
+
structAlign: maxEffectiveAlign,
|
|
16222
|
+
decode: (p) => {
|
|
16223
|
+
if (typeof p === "number") {
|
|
16224
|
+
const buf = new ArrayBuffer(size);
|
|
16225
|
+
const u8 = new Uint8Array(buf);
|
|
16226
|
+
for (let i = 0; i < size; i++)
|
|
16227
|
+
u8[i] = ffi2.readByte(p + i);
|
|
16228
|
+
return doDecode(new DataView(buf), 0, fields);
|
|
16229
|
+
}
|
|
16230
|
+
return doDecode(new DataView(p), 0, fields);
|
|
16231
|
+
},
|
|
16232
|
+
alloc: (() => new PtrArrayBuffer(size)),
|
|
16233
|
+
encode: ((v, buf) => {
|
|
16234
|
+
if (v === void 0 || v === null)
|
|
16235
|
+
throw new Error(`ffi-struct: encode(v) requires an argument; use alloc() for a zeroed out-param slot`);
|
|
16236
|
+
const out = buf ?? new PtrArrayBuffer(size);
|
|
16237
|
+
doEncode(new DataView(out), 0, fields, v);
|
|
16238
|
+
return out;
|
|
16239
|
+
}),
|
|
16240
|
+
offsetOf: (name) => {
|
|
16241
|
+
for (const f of fields)
|
|
16242
|
+
if (f.name === name)
|
|
16243
|
+
return f.offset;
|
|
16244
|
+
throw new Error(`ffi-struct: no field "${name}"`);
|
|
16245
|
+
}
|
|
16246
|
+
};
|
|
16247
|
+
}
|
|
16248
|
+
function buildDecl(kind, member, pack) {
|
|
16249
|
+
const decl = { "#": kind };
|
|
16250
|
+
if (pack !== void 0)
|
|
16251
|
+
decl["#pack"] = pack;
|
|
16252
|
+
for (const [k, v] of Object.entries(member))
|
|
16253
|
+
if (!k.startsWith("#"))
|
|
16254
|
+
decl[k] = v;
|
|
16255
|
+
return decl;
|
|
16256
|
+
}
|
|
16257
|
+
function struct(a, b6, c) {
|
|
16258
|
+
const isNamed = typeof a === "string";
|
|
16259
|
+
const raw = isNamed ? b6 : a;
|
|
16260
|
+
const opts = isNamed ? c : b6;
|
|
16261
|
+
return createStruct(buildDecl("struct", raw, opts?.pack));
|
|
16262
|
+
}
|
|
16263
|
+
|
|
16264
|
+
// _build/lib/windows/structs.js
|
|
16265
|
+
var RECT = /* @__PURE__ */ struct("RECT", {
|
|
16266
|
+
left: "i32",
|
|
16267
|
+
top: "i32",
|
|
16268
|
+
right: "i32",
|
|
16269
|
+
bottom: "i32"
|
|
16270
|
+
});
|
|
16271
|
+
var POINT = /* @__PURE__ */ struct("POINT", {
|
|
16272
|
+
x: "i32",
|
|
16273
|
+
y: "i32"
|
|
16274
|
+
});
|
|
16275
|
+
var SIZE = /* @__PURE__ */ struct("SIZE", {
|
|
16276
|
+
cx: "i32",
|
|
16277
|
+
cy: "i32"
|
|
16278
|
+
});
|
|
16279
|
+
var LOGFONTW = /* @__PURE__ */ struct("LOGFONTW", {
|
|
16280
|
+
lfHeight: "i32",
|
|
16281
|
+
lfWidth: "i32",
|
|
16282
|
+
lfEscapement: "i32",
|
|
16283
|
+
lfOrientation: "i32",
|
|
16284
|
+
lfWeight: "i32",
|
|
16285
|
+
lfItalic: "u8",
|
|
16286
|
+
lfUnderline: "u8",
|
|
16287
|
+
lfStrikeOut: "u8",
|
|
16288
|
+
lfCharSet: "u8",
|
|
16289
|
+
lfOutPrecision: "u8",
|
|
16290
|
+
lfClipPrecision: "u8",
|
|
16291
|
+
lfQuality: "u8",
|
|
16292
|
+
lfPitchAndFamily: "u8",
|
|
16293
|
+
lfFaceName: "u16[32]@utf-16le"
|
|
16294
|
+
});
|
|
16295
|
+
var OPENFILENAMEW = /* @__PURE__ */ struct("OPENFILENAMEW", {
|
|
16296
|
+
lStructSize: "u32",
|
|
16297
|
+
hwndOwner: "<HWND>ptr",
|
|
16298
|
+
hInstance: "<HMODULE>ptr",
|
|
16299
|
+
lpstrFilter: "<>ptr",
|
|
16300
|
+
lpstrCustomFilter: "<>ptr",
|
|
16301
|
+
nMaxCustFilter: "u32",
|
|
16302
|
+
nFilterIndex: "u32",
|
|
16303
|
+
lpstrFile: "<>ptr",
|
|
16304
|
+
nMaxFile: "u32",
|
|
16305
|
+
lpstrFileTitle: "<>ptr",
|
|
16306
|
+
nMaxFileTitle: "u32",
|
|
16307
|
+
lpstrInitialDir: "<>ptr",
|
|
16308
|
+
lpstrTitle: "<>ptr",
|
|
16309
|
+
Flags: "u32",
|
|
16310
|
+
nFileOffset: "u16",
|
|
16311
|
+
nFileExtension: "u16",
|
|
16312
|
+
lpstrDefExt: "<>ptr",
|
|
16313
|
+
lCustData: "<>ptr",
|
|
16314
|
+
lpfnHook: "<>ptr",
|
|
16315
|
+
lpTemplateName: "<>ptr",
|
|
16316
|
+
pvReserved: "<>ptr",
|
|
16317
|
+
dwReserved: "u32",
|
|
16318
|
+
FlagsEx: "u32"
|
|
16319
|
+
});
|
|
16320
|
+
var BROWSEINFOW = /* @__PURE__ */ struct("BROWSEINFOW", {
|
|
16321
|
+
hwndOwner: "<HWND>ptr",
|
|
16322
|
+
pidlRoot: "<>ptr",
|
|
16323
|
+
pszDisplayName: "<>ptr",
|
|
16324
|
+
lpszTitle: "<>ptr",
|
|
16325
|
+
ulFlags: "u32",
|
|
16326
|
+
lpfn: "<>ptr",
|
|
16327
|
+
lParam: "<>ptr",
|
|
16328
|
+
iImage: "i32"
|
|
16329
|
+
});
|
|
16330
|
+
var NMHDR = /* @__PURE__ */ struct("NMHDR", {
|
|
16331
|
+
hwndFrom: "<HWND>ptr",
|
|
16332
|
+
idFrom: "<>ptr",
|
|
16333
|
+
code: "i32"
|
|
16334
|
+
});
|
|
16335
|
+
var SYSTEMTIME = /* @__PURE__ */ struct("SYSTEMTIME", {
|
|
16336
|
+
wYear: "u16",
|
|
16337
|
+
wMonth: "u16",
|
|
16338
|
+
wDayOfWeek: "u16",
|
|
16339
|
+
wDay: "u16",
|
|
16340
|
+
wHour: "u16",
|
|
16341
|
+
wMinute: "u16",
|
|
16342
|
+
wSecond: "u16",
|
|
16343
|
+
wMilliseconds: "u16"
|
|
16344
|
+
});
|
|
16345
|
+
var NMDATETIMECHANGE = /* @__PURE__ */ struct("NMDATETIMECHANGE", {
|
|
16346
|
+
hdr: NMHDR.__struct,
|
|
16347
|
+
dwFlags: "u32",
|
|
16348
|
+
st: SYSTEMTIME.__struct
|
|
16349
|
+
});
|
|
16350
|
+
var LITEM = /* @__PURE__ */ struct("LITEM", {
|
|
16351
|
+
mask: "u32",
|
|
16352
|
+
iLink: "i32",
|
|
16353
|
+
state: "u32",
|
|
16354
|
+
stateMask: "u32",
|
|
16355
|
+
szID: "u16[48]@utf-16le",
|
|
16356
|
+
szUrl: "u16[2084]@utf-16le"
|
|
16357
|
+
});
|
|
16358
|
+
var NMLINK = /* @__PURE__ */ struct("NMLINK", {
|
|
16359
|
+
hdr: NMHDR.__struct,
|
|
16360
|
+
item: LITEM.__struct
|
|
16361
|
+
});
|
|
16362
|
+
var NMCUSTOMDRAW = /* @__PURE__ */ struct("NMCUSTOMDRAW", {
|
|
16363
|
+
hdr: NMHDR.__struct,
|
|
16364
|
+
dwDrawStage: "u32",
|
|
16365
|
+
hdc: "<HDC>ptr",
|
|
16366
|
+
rc: "i32[4]",
|
|
16367
|
+
dwItemSpec: "<>ptr",
|
|
16368
|
+
uItemState: "u32",
|
|
16369
|
+
lItemlParam: "<>ptr"
|
|
16370
|
+
});
|
|
16371
|
+
var NMLVCUSTOMDRAW = /* @__PURE__ */ struct("NMLVCUSTOMDRAW", {
|
|
16372
|
+
hdr: NMHDR.__struct,
|
|
16373
|
+
dwDrawStage: "u32",
|
|
16374
|
+
hdc: "<HDC>ptr",
|
|
16375
|
+
rc: "i32[4]",
|
|
16376
|
+
dwItemSpec: "<>ptr",
|
|
16377
|
+
uItemState: "u32",
|
|
16378
|
+
lItemlParam: "<>ptr",
|
|
16379
|
+
clrText: "u32",
|
|
16380
|
+
clrTextBk: "u32",
|
|
16381
|
+
iSubItem: "i32",
|
|
16382
|
+
dwItemType: "u32"
|
|
16383
|
+
});
|
|
16384
|
+
var NMLISTVIEW = /* @__PURE__ */ struct("NMLISTVIEW", {
|
|
16385
|
+
hdr: NMHDR.__struct,
|
|
16386
|
+
iItem: "i32",
|
|
16387
|
+
iSubItem: "i32",
|
|
16388
|
+
uNewState: "u32",
|
|
16389
|
+
uOldState: "u32",
|
|
16390
|
+
uChanged: "u32",
|
|
16391
|
+
ptAction: "i32[2]",
|
|
16392
|
+
lParam: "<>ptr"
|
|
16393
|
+
});
|
|
16394
|
+
var TCITEMW = /* @__PURE__ */ struct("TCITEMW", {
|
|
16395
|
+
mask: "u32",
|
|
16396
|
+
dwState: "u32",
|
|
16397
|
+
dwStateMask: "u32",
|
|
16398
|
+
pszText: "<>ptr",
|
|
16399
|
+
cchTextMax: "i32",
|
|
16400
|
+
iImage: "i32",
|
|
16401
|
+
lParam: "<>ptr"
|
|
16402
|
+
});
|
|
16403
|
+
var TVITEM = /* @__PURE__ */ struct("TVITEM", {
|
|
16404
|
+
mask: "u32",
|
|
16405
|
+
hItem: "<>ptr",
|
|
16406
|
+
state: "u32",
|
|
16407
|
+
stateMask: "u32",
|
|
16408
|
+
pszText: "<>ptr",
|
|
16409
|
+
cchTextMax: "i32",
|
|
16410
|
+
iImage: "i32",
|
|
16411
|
+
iSelectedImage: "i32",
|
|
16412
|
+
cChildren: "i32",
|
|
16413
|
+
lParam: "<>ptr"
|
|
16414
|
+
});
|
|
16415
|
+
var TVINSERTSTRUCT = /* @__PURE__ */ struct("TVINSERTSTRUCT", {
|
|
16416
|
+
hParent: "<>ptr",
|
|
16417
|
+
hInsertAfter: "<>ptr",
|
|
16418
|
+
item: TVITEM.__struct
|
|
16419
|
+
});
|
|
16420
|
+
var LVHITTESTINFO = /* @__PURE__ */ struct("LVHITTESTINFO", {
|
|
16421
|
+
pt: "i32[2]",
|
|
16422
|
+
flags: "u32",
|
|
16423
|
+
iItem: "i32",
|
|
16424
|
+
iSubItem: "i32",
|
|
16425
|
+
iGroup: "i32"
|
|
16426
|
+
});
|
|
16427
|
+
var LVITEMW = /* @__PURE__ */ struct("LVITEMW", {
|
|
16428
|
+
mask: "u32",
|
|
16429
|
+
iItem: "i32",
|
|
16430
|
+
iSubItem: "i32",
|
|
16431
|
+
state: "u32",
|
|
16432
|
+
stateMask: "u32",
|
|
16433
|
+
pszText: "<>ptr",
|
|
16434
|
+
cchTextMax: "i32",
|
|
16435
|
+
iImage: "i32",
|
|
16436
|
+
lParam: "<>ptr",
|
|
16437
|
+
iIndent: "i32",
|
|
16438
|
+
iGroupId: "i32",
|
|
16439
|
+
cColumns: "u32",
|
|
16440
|
+
puColumns: "<>ptr",
|
|
16441
|
+
piColFmt: "<>ptr",
|
|
16442
|
+
iGroup: "i32"
|
|
16443
|
+
});
|
|
16444
|
+
var LVCOLUMNW = /* @__PURE__ */ struct("LVCOLUMNW", {
|
|
16445
|
+
mask: "u32",
|
|
16446
|
+
fmt: "i32",
|
|
16447
|
+
cx: "i32",
|
|
16448
|
+
pszText: "<>ptr",
|
|
16449
|
+
cchTextMax: "i32",
|
|
16450
|
+
iSubItem: "i32",
|
|
16451
|
+
iImage: "i32",
|
|
16452
|
+
iOrder: "i32",
|
|
16453
|
+
cxMin: "i32",
|
|
16454
|
+
cxDefault: "i32",
|
|
16455
|
+
cxIdeal: "i32"
|
|
16456
|
+
});
|
|
16457
|
+
var MSG = /* @__PURE__ */ struct("MSG", {
|
|
16458
|
+
hwnd: "<HWND>ptr",
|
|
16459
|
+
message: "u32",
|
|
16460
|
+
wParam: "<>ptr",
|
|
16461
|
+
lParam: "<>ptr",
|
|
16462
|
+
time: "u32",
|
|
16463
|
+
pt: POINT.__struct
|
|
16464
|
+
});
|
|
16465
|
+
var PAINTSTRUCT = /* @__PURE__ */ struct("PAINTSTRUCT", {
|
|
16466
|
+
hdc: "<HDC>ptr",
|
|
16467
|
+
fErase: "i32",
|
|
16468
|
+
rcPaint: RECT.__struct,
|
|
16469
|
+
fRestore: "i32",
|
|
16470
|
+
fIncUpdate: "i32",
|
|
16471
|
+
rgbReserved: "u8[32]"
|
|
16472
|
+
});
|
|
16473
|
+
|
|
16474
|
+
// _build/lib/windows/user32.js
|
|
16475
|
+
var b = (name, sig, encoders) => bind("user32.dll", name, sig, encoders);
|
|
16476
|
+
var _bProbe = b("GetDesktopWindow", " -> <HWND>ptr");
|
|
16477
|
+
var LONG_PTR_SYM = os3.arch === "x64" ? "PtrW" : "W";
|
|
16478
|
+
var SetWindowPos = /* @__PURE__ */ b("SetWindowPos", "<HWND>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32");
|
|
16479
|
+
var SetWindowText = /* @__PURE__ */ b("SetWindowTextW", "<HWND>ptr <WCHAR>ptr -> i32");
|
|
16480
|
+
var GetWindowLongPtr = /* @__PURE__ */ b("GetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp -> <>ptr");
|
|
16481
|
+
var SetWindowLongPtr = /* @__PURE__ */ b("SetWindowLong" + LONG_PTR_SYM, "<HWND>ptr i32@Gwlp <>ptr -> <>ptr");
|
|
16482
|
+
var EnableWindow = /* @__PURE__ */ b("EnableWindow", "<HWND>ptr i32 -> i32");
|
|
16483
|
+
var SetParent = /* @__PURE__ */ b("SetParent", "<HWND>ptr <HWND>ptr -> <HWND>ptr");
|
|
16484
|
+
var DefWindowProc = /* @__PURE__ */ b("DefWindowProcW", "<HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16485
|
+
var CallWindowProc = /* @__PURE__ */ b("CallWindowProcW", "<>ptr <HWND>ptr u32@AnyMsg <>ptr <>ptr -> <>ptr");
|
|
16486
|
+
var GetDC = /* @__PURE__ */ b("GetDC", "<HWND>ptr -> <HDC>ptr");
|
|
16487
|
+
var ReleaseDC = /* @__PURE__ */ b("ReleaseDC", "<HWND>ptr <HDC>ptr! -> i32");
|
|
16488
|
+
var DrawText = /* @__PURE__ */ b("DrawTextW", "<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32");
|
|
16489
|
+
var InvalidateRect = /* @__PURE__ */ b("InvalidateRect", "<HWND>ptr <RECT>ptr i32 -> i32", { RECT });
|
|
16490
|
+
var SetCursor = /* @__PURE__ */ b("SetCursor", "<HCURSOR>ptr -> <HCURSOR>ptr");
|
|
16491
|
+
var LoadCursor = /* @__PURE__ */ b("LoadCursorW", "<HMODULE>ptr <>ptr -> <HCURSOR>ptr");
|
|
16492
|
+
var GetCursorPos = /* @__PURE__ */ b("GetCursorPos", "<POINT>ptr -> i32");
|
|
16493
|
+
var ScreenToClient = /* @__PURE__ */ b("ScreenToClient", "<HWND>ptr <POINT>ptr -> i32");
|
|
16494
|
+
var ShowScrollBar = /* @__PURE__ */ b("ShowScrollBar", "<HWND>ptr u32 i32 -> i32");
|
|
16495
|
+
var GetSystemMetrics = /* @__PURE__ */ b("GetSystemMetrics", "i32 -> i32");
|
|
16496
|
+
|
|
16497
|
+
// _build/lib/react-qw/reconciler.js
|
|
16498
|
+
var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
16499
|
+
var import_react = __toESM(require_react(), 1);
|
|
16500
|
+
var import_constants = __toESM(require_constants(), 1);
|
|
16501
|
+
import * as gui3 from "gui";
|
|
16502
|
+
import * as os4 from "os";
|
|
16503
|
+
|
|
16504
|
+
// _build/lib/windows/gdi32.js
|
|
16505
|
+
var b2 = (name, sig, encoders) => bind("gdi32.dll", name, sig, encoders);
|
|
16506
|
+
var DeleteObject = /* @__PURE__ */ b2("DeleteObject", "<>ptr -> i32");
|
|
16507
|
+
var GetDeviceCaps = /* @__PURE__ */ b2("GetDeviceCaps", "<HDC>ptr! i32@DeviceCap -> i32");
|
|
16508
|
+
var CreateFontIndirect = /* @__PURE__ */ b2("CreateFontIndirectW", "<LOGFONTW>ptr -> <>ptr", { LOGFONTW });
|
|
16509
|
+
var SelectObject = /* @__PURE__ */ b2("SelectObject", "<HDC>ptr! <>ptr -> <>ptr");
|
|
16510
|
+
var GetObject = /* @__PURE__ */ b2("GetObjectW", "<>ptr i32 <BYTE>ptr -> i32");
|
|
16511
|
+
|
|
16512
|
+
// _build/lib/react-qw/props.js
|
|
16513
|
+
import * as gui from "gui";
|
|
16514
|
+
function applyProps(instance, newProps, _oldProps) {
|
|
16515
|
+
const hwnd = instance.hwnd;
|
|
16516
|
+
instance.props = newProps;
|
|
16517
|
+
if (hwnd === null)
|
|
16518
|
+
return;
|
|
16519
|
+
const textVal = "text" in newProps ? newProps.text : typeof newProps.children === "string" ? newProps.children : typeof newProps.children === "number" ? String(newProps.children) : void 0;
|
|
16520
|
+
if (textVal !== void 0) {
|
|
16521
|
+
let cursor = -1;
|
|
16522
|
+
if (instance.type === "EDIT") {
|
|
16523
|
+
const sel = gui.SendMessage(hwnd, 176, 0, 0);
|
|
16524
|
+
cursor = sel >>> 16;
|
|
16525
|
+
}
|
|
16526
|
+
SetWindowText(hwnd, textVal);
|
|
16527
|
+
if (instance.type === "EDIT" && cursor >= 0) {
|
|
16528
|
+
gui.SendMessage(hwnd, 177, cursor, cursor);
|
|
16529
|
+
}
|
|
16530
|
+
}
|
|
16531
|
+
if ("disabled" in newProps) {
|
|
16532
|
+
EnableWindow(hwnd, !newProps.disabled ? 1 : 0);
|
|
16533
|
+
}
|
|
16534
|
+
if ("hidden" in newProps) {
|
|
16535
|
+
gui.ShowWindow(
|
|
16536
|
+
hwnd,
|
|
16537
|
+
newProps.hidden ? 0 : 5
|
|
16538
|
+
/* gui.ShowWindowCmd.SHOW */
|
|
16539
|
+
);
|
|
16540
|
+
}
|
|
16541
|
+
if ("visible" in newProps) {
|
|
16542
|
+
gui.ShowWindow(
|
|
16543
|
+
hwnd,
|
|
16544
|
+
newProps.visible ? 5 : 0
|
|
16545
|
+
/* gui.ShowWindowCmd.HIDE */
|
|
16546
|
+
);
|
|
16547
|
+
}
|
|
16548
|
+
}
|
|
16549
|
+
|
|
16550
|
+
// _build/lib/react-qw/layout.js
|
|
16551
|
+
var DEFAULT_W = 100;
|
|
16552
|
+
var DEFAULT_H = 30;
|
|
16553
|
+
function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
16554
|
+
const dir = flex.flexDirection || "column";
|
|
16555
|
+
const gap = flex.gap ?? 0;
|
|
16556
|
+
const justify = flex.justifyContent || "flex-start";
|
|
16557
|
+
const align = flex.alignItems || "stretch";
|
|
16558
|
+
const isRow = dir === "row";
|
|
16559
|
+
const n = children.length;
|
|
16560
|
+
const mainSize = isRow ? "w" : "h";
|
|
16561
|
+
const crossSize = isRow ? "h" : "w";
|
|
16562
|
+
const mainPos = isRow ? "x" : "y";
|
|
16563
|
+
const crossPos = isRow ? "y" : "x";
|
|
16564
|
+
const mainDim = isRow ? "width" : "height";
|
|
16565
|
+
const crossDim = isRow ? "height" : "width";
|
|
16566
|
+
const pt = flex.paddingTop ?? flex.padding ?? 0;
|
|
16567
|
+
const pr = flex.paddingRight ?? flex.padding ?? 0;
|
|
16568
|
+
const pb = flex.paddingBottom ?? flex.padding ?? 0;
|
|
16569
|
+
const pl = flex.paddingLeft ?? flex.padding ?? 0;
|
|
16570
|
+
const mainPadding = isRow ? pl + pr : pt + pb;
|
|
16571
|
+
const crossPadding = isRow ? pt + pb : pl + pr;
|
|
16572
|
+
const parentMain = (isRow ? parentW : parentH) - mainPadding;
|
|
16573
|
+
const parentCross = (isRow ? parentH : parentW) - crossPadding;
|
|
16574
|
+
const sizes = children.map((c) => ({
|
|
16575
|
+
w: typeof c.style.width === "number" ? c.style.width : DEFAULT_W,
|
|
16576
|
+
h: typeof c.style.height === "number" ? c.style.height : DEFAULT_H
|
|
16577
|
+
}));
|
|
16578
|
+
const flexGrows = children.map((c) => c.style.flexGrow ?? 0);
|
|
16579
|
+
const totalGrow = flexGrows.reduce((s, g) => s + g, 0);
|
|
16580
|
+
const baseMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16581
|
+
let freeGrow = parentMain - baseMain - Math.max(0, n - 1) * gap;
|
|
16582
|
+
if (totalGrow > 0 && freeGrow > 0) {
|
|
16583
|
+
for (let i = 0; i < n; i++) {
|
|
16584
|
+
sizes[i][mainSize] += freeGrow * flexGrows[i] / totalGrow;
|
|
16585
|
+
}
|
|
16586
|
+
}
|
|
16587
|
+
const totalMain = sizes.reduce((s, c) => s + c[mainSize], 0);
|
|
16588
|
+
const free = parentMain - totalMain - Math.max(0, n - 1) * gap;
|
|
16589
|
+
let offset = 0, extraGap = 0;
|
|
16590
|
+
if (justify === "flex-end")
|
|
16591
|
+
offset = free;
|
|
16592
|
+
else if (justify === "center")
|
|
16593
|
+
offset = Math.max(0, free / 2);
|
|
16594
|
+
else if (justify === "space-between" && n > 1)
|
|
16595
|
+
extraGap = free / (n - 1);
|
|
16596
|
+
else if (justify === "space-around") {
|
|
16597
|
+
extraGap = free / n;
|
|
16598
|
+
offset = extraGap / 2;
|
|
16599
|
+
} else if (justify === "space-evenly") {
|
|
16600
|
+
extraGap = free / (n + 1);
|
|
16601
|
+
offset = extraGap;
|
|
16602
|
+
}
|
|
16603
|
+
let cursor = offset;
|
|
16604
|
+
return sizes.map((sz, i) => {
|
|
16605
|
+
const childCrossBase = sz[crossSize];
|
|
16606
|
+
const childAlign = children[i].style.alignSelf ?? "auto";
|
|
16607
|
+
const effectiveAlign = childAlign === "auto" ? align : childAlign;
|
|
16608
|
+
let childMain = sz[mainSize];
|
|
16609
|
+
let childCross = childCrossBase;
|
|
16610
|
+
const res = { x: 0, y: 0, width: 0, height: 0 };
|
|
16611
|
+
res[mainPos] = cursor;
|
|
16612
|
+
res[crossPos] = 0;
|
|
16613
|
+
res[mainDim] = childMain;
|
|
16614
|
+
res[crossDim] = childCross;
|
|
16615
|
+
if (effectiveAlign === "stretch") {
|
|
16616
|
+
const hasExplicitCross = typeof children[i].style[crossDim] === "number";
|
|
16617
|
+
if (!hasExplicitCross) {
|
|
16618
|
+
res[crossDim] = parentCross;
|
|
16619
|
+
res[crossPos] = 0;
|
|
16620
|
+
}
|
|
16621
|
+
} else if (effectiveAlign === "flex-end") {
|
|
16622
|
+
res[crossPos] = parentCross - childCross;
|
|
16623
|
+
} else if (effectiveAlign === "center") {
|
|
16624
|
+
res[crossPos] = Math.max(0, (parentCross - childCross) / 2);
|
|
16625
|
+
}
|
|
16626
|
+
cursor += childMain + gap + extraGap;
|
|
16627
|
+
return res;
|
|
16628
|
+
});
|
|
16629
|
+
}
|
|
15814
16630
|
|
|
15815
16631
|
// _build/lib/text-measure.js
|
|
15816
|
-
|
|
15817
|
-
DrawTextW: "ptr wstr i32 ptr i32 -> i32",
|
|
15818
|
-
GetDC: "ptr -> ptr",
|
|
15819
|
-
ReleaseDC: "ptr ptr -> i32"
|
|
15820
|
-
});
|
|
15821
|
-
var gdi32 = bindLib("gdi32.dll", {
|
|
15822
|
-
SelectObject: "ptr ptr -> ptr"
|
|
15823
|
-
});
|
|
16632
|
+
import * as gui2 from "gui";
|
|
15824
16633
|
function measureText(hdc, text, maxWidth) {
|
|
15825
|
-
const
|
|
15826
|
-
|
|
15827
|
-
dv.setInt32(8, maxWidth, true);
|
|
15828
|
-
user32.DrawTextW(
|
|
16634
|
+
const r = RECT.encode({ right: maxWidth });
|
|
16635
|
+
DrawText(
|
|
15829
16636
|
hdc,
|
|
15830
16637
|
text,
|
|
15831
16638
|
-1,
|
|
15832
|
-
|
|
16639
|
+
r.ptr,
|
|
15833
16640
|
1024
|
|
15834
16641
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15835
16642
|
);
|
|
15836
|
-
|
|
16643
|
+
const { right, bottom } = RECT.decode(r);
|
|
16644
|
+
return { width: right, height: bottom };
|
|
15837
16645
|
}
|
|
15838
16646
|
function getButtonIdealSize(hwnd) {
|
|
15839
|
-
const size =
|
|
15840
|
-
gui2.SendMessage(hwnd, 5633, 0,
|
|
15841
|
-
const
|
|
15842
|
-
return { width:
|
|
16647
|
+
const size = SIZE.alloc();
|
|
16648
|
+
gui2.SendMessage(hwnd, 5633, 0, size.ptr);
|
|
16649
|
+
const { cx, cy } = SIZE.decode(size);
|
|
16650
|
+
return { width: cx, height: cy };
|
|
15843
16651
|
}
|
|
15844
16652
|
function measureTextForHwnd(hwnd, text) {
|
|
15845
|
-
const hdc =
|
|
16653
|
+
const hdc = GetDC(hwnd);
|
|
15846
16654
|
if (!hdc)
|
|
15847
16655
|
return { width: 0, height: 0 };
|
|
15848
16656
|
const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
|
|
15849
|
-
const oldFont = hFont ?
|
|
16657
|
+
const oldFont = hFont ? SelectObject(hdc, hFont) : 0;
|
|
15850
16658
|
const result = measureText(hdc, text, 0);
|
|
15851
16659
|
if (hFont)
|
|
15852
|
-
|
|
15853
|
-
|
|
16660
|
+
SelectObject(hdc, oldFont);
|
|
16661
|
+
ReleaseDC(hwnd, hdc);
|
|
15854
16662
|
const wr = gui2.GetWindowRect(hwnd);
|
|
15855
16663
|
const cr = gui2.GetClientRect(hwnd);
|
|
15856
16664
|
if (wr && cr) {
|
|
@@ -15862,14 +16670,20 @@ function measureTextForHwnd(hwnd, text) {
|
|
|
15862
16670
|
|
|
15863
16671
|
// _build/lib/react-qw/reconciler.js
|
|
15864
16672
|
var dpiFont = gui3.CreateSystemDpiFont();
|
|
15865
|
-
var scaleFactor =
|
|
16673
|
+
var scaleFactor = (() => {
|
|
16674
|
+
const hdc = GetDC(NULL);
|
|
16675
|
+
const dpi = hdc ? GetDeviceCaps(hdc, 88) : 96;
|
|
16676
|
+
if (hdc)
|
|
16677
|
+
ReleaseDC(NULL, hdc);
|
|
16678
|
+
return dpi / 96;
|
|
16679
|
+
})();
|
|
15866
16680
|
var DELAYED_CONTROLS = /* @__PURE__ */ new Set(["SysListView32", "SysTreeView32", "LISTBOX", "COMBOBOX", "msctls_trackbar32", "SysDateTimePick32", "SysLink"]);
|
|
15867
16681
|
function isDelayedControl(winClass) {
|
|
15868
16682
|
return DELAYED_CONTROLS.has(winClass);
|
|
15869
16683
|
}
|
|
15870
16684
|
function setupWindowProc(instance, hwnd) {
|
|
15871
16685
|
instance.hwnd = hwnd;
|
|
15872
|
-
const oldProc =
|
|
16686
|
+
const oldProc = GetWindowLongPtr(
|
|
15873
16687
|
hwnd,
|
|
15874
16688
|
-4
|
|
15875
16689
|
/* gui.Gwlp.WNDPROC */
|
|
@@ -15878,11 +16692,11 @@ function setupWindowProc(instance, hwnd) {
|
|
|
15878
16692
|
gui3.SetWindowProc(hwnd, (hwnd2, msg, wParam, lParam) => {
|
|
15879
16693
|
const ev = instance.props.onEvent;
|
|
15880
16694
|
if (!ev)
|
|
15881
|
-
return
|
|
16695
|
+
return CallWindowProc(oldProc, hwnd2, msg, wParam, lParam);
|
|
15882
16696
|
if (typeof ev === "object") {
|
|
15883
|
-
return ev.fn({ hwnd: hwnd2, msg, wParam, lParam, callOldWndProc: () =>
|
|
16697
|
+
return ev.fn({ hwnd: hwnd2, msg, wParam, lParam, callOldWndProc: () => CallWindowProc(oldProc, hwnd2, msg, wParam, lParam) });
|
|
15884
16698
|
}
|
|
15885
|
-
const result =
|
|
16699
|
+
const result = CallWindowProc(oldProc, hwnd2, msg, wParam, lParam);
|
|
15886
16700
|
const override = ev({ hwnd: hwnd2, msg, wParam, lParam });
|
|
15887
16701
|
return typeof override === "number" && Number.isInteger(override) ? override : result;
|
|
15888
16702
|
});
|
|
@@ -15952,7 +16766,7 @@ function runFlexLayout(inst) {
|
|
|
15952
16766
|
if (lr && lr.x === r.x && lr.y === r.y && lr.w === r.width && lr.h === r.height)
|
|
15953
16767
|
continue;
|
|
15954
16768
|
console.log("flex: set", child.type, child.hwnd, "to", r.x, r.y, r.width, r.height);
|
|
15955
|
-
|
|
16769
|
+
SetWindowPos(
|
|
15956
16770
|
child.hwnd,
|
|
15957
16771
|
0,
|
|
15958
16772
|
(r.x + pl) * scaleFactor,
|
|
@@ -15962,7 +16776,7 @@ function runFlexLayout(inst) {
|
|
|
15962
16776
|
64
|
|
15963
16777
|
/* gui.SetWindowPosFlag.SWP_SHOWWINDOW */
|
|
15964
16778
|
);
|
|
15965
|
-
|
|
16779
|
+
InvalidateRect(child.hwnd, NULL, 1);
|
|
15966
16780
|
child.lastRect = { x: r.x, y: r.y, w: r.width, h: r.height };
|
|
15967
16781
|
}
|
|
15968
16782
|
for (const c of children)
|
|
@@ -16008,7 +16822,7 @@ var hostConfig = {
|
|
|
16008
16822
|
if (child.hwnd === null) {
|
|
16009
16823
|
ensureChildWindow(child, parent.hwnd);
|
|
16010
16824
|
} else {
|
|
16011
|
-
|
|
16825
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16012
16826
|
}
|
|
16013
16827
|
if (false)
|
|
16014
16828
|
console.log("[reconciler] appendInitialChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16018,7 +16832,7 @@ var hostConfig = {
|
|
|
16018
16832
|
if (child.hwnd === null) {
|
|
16019
16833
|
ensureChildWindow(child, parent.hwnd);
|
|
16020
16834
|
} else {
|
|
16021
|
-
|
|
16835
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16022
16836
|
}
|
|
16023
16837
|
if (false)
|
|
16024
16838
|
console.log("[reconciler] appendChild parent:", parent.hwnd, "child:", child.hwnd);
|
|
@@ -16028,7 +16842,7 @@ var hostConfig = {
|
|
|
16028
16842
|
if (child.hwnd === null) {
|
|
16029
16843
|
ensureChildWindow(child, container);
|
|
16030
16844
|
} else {
|
|
16031
|
-
|
|
16845
|
+
SetParent(child.hwnd, container);
|
|
16032
16846
|
}
|
|
16033
16847
|
const rootInst = instancesByHwnd.get(container);
|
|
16034
16848
|
if (rootInst)
|
|
@@ -16040,7 +16854,7 @@ var hostConfig = {
|
|
|
16040
16854
|
if (child.hwnd === null) {
|
|
16041
16855
|
ensureChildWindow(child, parent.hwnd);
|
|
16042
16856
|
} else {
|
|
16043
|
-
|
|
16857
|
+
SetParent(child.hwnd, parent.hwnd ?? NULL);
|
|
16044
16858
|
}
|
|
16045
16859
|
if (false)
|
|
16046
16860
|
console.log("[reconciler] insertBefore parent:", parent.hwnd, "child:", child.hwnd, "before:", beforeChild.hwnd);
|
|
@@ -16052,7 +16866,7 @@ var hostConfig = {
|
|
|
16052
16866
|
if (child.hwnd === null) {
|
|
16053
16867
|
ensureChildWindow(child, container);
|
|
16054
16868
|
} else {
|
|
16055
|
-
|
|
16869
|
+
SetParent(child.hwnd, container);
|
|
16056
16870
|
}
|
|
16057
16871
|
const rootInst = instancesByHwnd.get(container);
|
|
16058
16872
|
if (!rootInst)
|
|
@@ -16109,7 +16923,7 @@ var hostConfig = {
|
|
|
16109
16923
|
resetTextContent(_instance) {
|
|
16110
16924
|
},
|
|
16111
16925
|
commitTextUpdate(instance, _oldText, newText) {
|
|
16112
|
-
|
|
16926
|
+
SetWindowText(instance.hwnd, newText);
|
|
16113
16927
|
},
|
|
16114
16928
|
hideInstance(instance) {
|
|
16115
16929
|
if (instance.hwnd !== null)
|
|
@@ -16163,10 +16977,10 @@ var hostConfig = {
|
|
|
16163
16977
|
clearContainer(_container) {
|
|
16164
16978
|
},
|
|
16165
16979
|
scheduleTimeout(fn, delay) {
|
|
16166
|
-
return
|
|
16980
|
+
return os4.setTimeout(fn, delay);
|
|
16167
16981
|
},
|
|
16168
16982
|
cancelTimeout(id) {
|
|
16169
|
-
|
|
16983
|
+
os4.clearTimeout?.(id);
|
|
16170
16984
|
},
|
|
16171
16985
|
noTimeout: -1,
|
|
16172
16986
|
supportsMutation: true,
|
|
@@ -16333,298 +17147,23 @@ var ComboBox = (0, import_react4.forwardRef)(({ items, selectedIndex: controlled
|
|
|
16333
17147
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
16334
17148
|
var import_react5 = __toESM(require_react(), 1);
|
|
16335
17149
|
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
17150
|
|
|
16579
17151
|
// _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
17152
|
function nmCode(lParam) {
|
|
16594
|
-
return
|
|
17153
|
+
return NMHDR.decode(lParam).code;
|
|
16595
17154
|
}
|
|
16596
17155
|
|
|
16597
17156
|
// _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
17157
|
function dateToSysTimeBuf(d) {
|
|
16617
|
-
|
|
16618
|
-
|
|
16619
|
-
|
|
16620
|
-
|
|
16621
|
-
|
|
16622
|
-
|
|
16623
|
-
|
|
16624
|
-
|
|
16625
|
-
|
|
16626
|
-
dv.setUint16(14, d.getMilliseconds(), true);
|
|
16627
|
-
return buf;
|
|
17158
|
+
return SYSTEMTIME.encode({
|
|
17159
|
+
wYear: d.getFullYear(),
|
|
17160
|
+
wMonth: d.getMonth() + 1,
|
|
17161
|
+
wDay: d.getDate(),
|
|
17162
|
+
wHour: d.getHours(),
|
|
17163
|
+
wMinute: d.getMinutes(),
|
|
17164
|
+
wSecond: d.getSeconds(),
|
|
17165
|
+
wMilliseconds: d.getMilliseconds()
|
|
17166
|
+
});
|
|
16628
17167
|
}
|
|
16629
17168
|
var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ value, onChange, defaultValue, format = "short", allowNone, updown, style }, ref) {
|
|
16630
17169
|
const [internalDate, setInternalDate] = (0, import_react5.useState)(defaultValue ?? null);
|
|
@@ -16649,7 +17188,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16649
17188
|
const d = effectiveDate;
|
|
16650
17189
|
if (d) {
|
|
16651
17190
|
const buf = dateToSysTimeBuf(d);
|
|
16652
|
-
gui6.SendMessage(h, 4098, 0,
|
|
17191
|
+
gui6.SendMessage(h, 4098, 0, buf.ptr);
|
|
16653
17192
|
} else {
|
|
16654
17193
|
gui6.SendMessage(h, 4098, 1, 0);
|
|
16655
17194
|
}
|
|
@@ -16658,7 +17197,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16658
17197
|
const h = dpRef.current;
|
|
16659
17198
|
if (!h)
|
|
16660
17199
|
return;
|
|
16661
|
-
|
|
17200
|
+
InvalidateRect(h, NULL, 1);
|
|
16662
17201
|
const cr = gui6.GetClientRect(h);
|
|
16663
17202
|
if (cr) {
|
|
16664
17203
|
const w = cr.right - cr.left;
|
|
@@ -16670,20 +17209,13 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16670
17209
|
if (e.msg === 78) {
|
|
16671
17210
|
const code = nmCode(e.lParam);
|
|
16672
17211
|
if (code === -759) {
|
|
16673
|
-
const st = NMDATETIMECHANGE.
|
|
16674
|
-
const dwFlags = readI32At(e.lParam, NMDATETIMECHANGE.offsetOf("dwFlags"));
|
|
17212
|
+
const { dwFlags, st } = NMDATETIMECHANGE.decode(e.lParam);
|
|
16675
17213
|
if (dwFlags === 1) {
|
|
16676
17214
|
if (!isControlled)
|
|
16677
17215
|
setInternalDate(null);
|
|
16678
17216
|
onChangeRef.current?.(null);
|
|
16679
17217
|
} 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);
|
|
17218
|
+
const d = new Date(st.wYear, st.wMonth - 1, st.wDay, st.wHour, st.wMinute, st.wSecond);
|
|
16687
17219
|
if (!isControlled)
|
|
16688
17220
|
setInternalDate(d);
|
|
16689
17221
|
onChangeRef.current?.(d);
|
|
@@ -16699,14 +17231,6 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16699
17231
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
16700
17232
|
var import_react6 = __toESM(require_react(), 1);
|
|
16701
17233
|
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
17234
|
var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValue = "", onChange, placeholder, password, multiline, readonly, number, disabled, style }, ref) => {
|
|
16711
17235
|
const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue);
|
|
16712
17236
|
const isControlled = controlledValue !== void 0;
|
|
@@ -16725,8 +17249,8 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16725
17249
|
const h = inputRef.current;
|
|
16726
17250
|
if (!h || !placeholder)
|
|
16727
17251
|
return;
|
|
16728
|
-
const buf =
|
|
16729
|
-
gui7.SendMessage(h, 5377, 1,
|
|
17252
|
+
const buf = WCHAR.encode(placeholder);
|
|
17253
|
+
gui7.SendMessage(h, 5377, 1, buf.ptr);
|
|
16730
17254
|
}, [placeholder]);
|
|
16731
17255
|
return (0, import_jsx_runtime5.jsx)("w", { type: "EDIT", text: displayValue, ws, style, disabled, ref: (h) => {
|
|
16732
17256
|
inputRef.current = h;
|
|
@@ -16750,20 +17274,6 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16750
17274
|
// _build/lib/react-qw/components/Link.js
|
|
16751
17275
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
16752
17276
|
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
17277
|
var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClick, style }, ref) {
|
|
16768
17278
|
const displayText = children != null ? String(children) : href ?? "";
|
|
16769
17279
|
const linkText = href ? `<A HREF="${href}">${displayText}</A>` : displayText;
|
|
@@ -16774,14 +17284,13 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16774
17284
|
const h = linkRef.current;
|
|
16775
17285
|
if (!h)
|
|
16776
17286
|
return;
|
|
16777
|
-
|
|
17287
|
+
InvalidateRect(h, NULL, 1);
|
|
16778
17288
|
}, [linkText]);
|
|
16779
17289
|
return (0, import_jsx_runtime6.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16780
17290
|
if (e.msg === 78) {
|
|
16781
17291
|
const code = nmCode(e.lParam);
|
|
16782
17292
|
if (code === -2 || code === -4) {
|
|
16783
|
-
|
|
16784
|
-
onClickRef.current?.(url);
|
|
17293
|
+
onClickRef.current?.(NMLINK.decode(e.lParam).item.szUrl);
|
|
16785
17294
|
}
|
|
16786
17295
|
}
|
|
16787
17296
|
}, children: (0, import_jsx_runtime6.jsx)("w", { type: "SysLink", ws: 268435456 | 65536, text: linkText, style: { flexGrow: 1 }, ref: (h) => {
|
|
@@ -16792,7 +17301,7 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16792
17301
|
// _build/lib/react-qw/components/ListBox.js
|
|
16793
17302
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
16794
17303
|
var import_react8 = __toESM(require_react(), 1);
|
|
16795
|
-
import * as
|
|
17304
|
+
import * as gui8 from "gui";
|
|
16796
17305
|
var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledIndex, defaultSelectedIndex = -1, onChange, style, sort, scrollToBottom }, ref) => {
|
|
16797
17306
|
const [internalIndex, setInternalIndex] = (0, import_react8.useState)(defaultSelectedIndex);
|
|
16798
17307
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -16804,18 +17313,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16804
17313
|
const h = lbRef.current;
|
|
16805
17314
|
if (!h)
|
|
16806
17315
|
return;
|
|
16807
|
-
|
|
17316
|
+
gui8.SendMessage(h, 388, 0, 0);
|
|
16808
17317
|
for (const item of items)
|
|
16809
|
-
|
|
17318
|
+
gui8.SendMessage(h, 384, 0, item);
|
|
16810
17319
|
if (sel >= 0 && sel < items.length)
|
|
16811
|
-
|
|
17320
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16812
17321
|
if (scrollToBottom && items.length > 0)
|
|
16813
|
-
|
|
17322
|
+
gui8.SendMessage(h, 407, items.length - 1, 0);
|
|
16814
17323
|
}, [items]);
|
|
16815
17324
|
(0, import_react8.useEffect)(() => {
|
|
16816
17325
|
const h = lbRef.current;
|
|
16817
17326
|
if (h)
|
|
16818
|
-
|
|
17327
|
+
gui8.SendMessage(h, 390, sel, 0);
|
|
16819
17328
|
}, [sel]);
|
|
16820
17329
|
return (0, import_jsx_runtime7.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, onEvent: (e) => {
|
|
16821
17330
|
if (e.msg !== 273)
|
|
@@ -16825,7 +17334,7 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16825
17334
|
const h = lbRef.current;
|
|
16826
17335
|
if (!h)
|
|
16827
17336
|
return;
|
|
16828
|
-
const newSel =
|
|
17337
|
+
const newSel = gui8.SendMessage(h, 392, 0, 0);
|
|
16829
17338
|
if (newSel !== sel && newSel >= 0) {
|
|
16830
17339
|
if (!isControlled)
|
|
16831
17340
|
setInternalIndex(newSel);
|
|
@@ -16840,138 +17349,18 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16840
17349
|
// _build/lib/react-qw/components/ListView.js
|
|
16841
17350
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
16842
17351
|
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
|
-
}
|
|
17352
|
+
import * as gui9 from "gui";
|
|
17353
|
+
import * as ffi3 from "ffi";
|
|
16864
17354
|
function writeU32(ptr, offset, v) {
|
|
16865
|
-
|
|
16866
|
-
|
|
16867
|
-
|
|
16868
|
-
|
|
16869
|
-
}
|
|
16870
|
-
function bufPtr2(buf) {
|
|
16871
|
-
return ffi7.bufferPtr(buf);
|
|
17355
|
+
ffi3.writeByte(ptr + offset, v & 255);
|
|
17356
|
+
ffi3.writeByte(ptr + offset + 1, v >> 8 & 255);
|
|
17357
|
+
ffi3.writeByte(ptr + offset + 2, v >> 16 & 255);
|
|
17358
|
+
ffi3.writeByte(ptr + offset + 3, v >> 24 & 255);
|
|
16872
17359
|
}
|
|
16873
17360
|
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
17361
|
var CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf("clrText");
|
|
16910
17362
|
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
17363
|
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
17364
|
function getCellFont(hwnd, style) {
|
|
16976
17365
|
const key = (style.bold ? "b" : "") + (style.italic ? "i" : "") + (style.underline ? "u" : "");
|
|
16977
17366
|
if (key === "")
|
|
@@ -16979,39 +17368,37 @@ function getCellFont(hwnd, style) {
|
|
|
16979
17368
|
const cached = fontCache.get(key);
|
|
16980
17369
|
if (cached !== void 0)
|
|
16981
17370
|
return cached === 0 ? null : cached;
|
|
16982
|
-
|
|
16983
|
-
if (!createFontIndirectW || !getObjectW || !hwnd)
|
|
17371
|
+
if (!hwnd)
|
|
16984
17372
|
return null;
|
|
16985
|
-
|
|
16986
|
-
const
|
|
16987
|
-
const cur = gui10.SendMessage(hwnd, 49, 0, 0);
|
|
17373
|
+
let base = { lfHeight: -13 };
|
|
17374
|
+
const cur = gui9.SendMessage(hwnd, 49, 0, 0);
|
|
16988
17375
|
if (cur) {
|
|
16989
|
-
const
|
|
16990
|
-
if (!
|
|
17376
|
+
const lf = LOGFONTW.alloc();
|
|
17377
|
+
if (!GetObject(cur, LOGFONTW.size, lf))
|
|
16991
17378
|
return null;
|
|
16992
|
-
|
|
16993
|
-
dv.setInt32(0, -13, true);
|
|
17379
|
+
base = LOGFONTW.decode(lf);
|
|
16994
17380
|
}
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17381
|
+
const h = CreateFontIndirect({
|
|
17382
|
+
...base,
|
|
17383
|
+
...style.bold ? {
|
|
17384
|
+
lfWeight: 700
|
|
17385
|
+
/* gui.FontWeight.BOLD */
|
|
17386
|
+
} : {},
|
|
17387
|
+
...style.italic ? { lfItalic: 1 } : {},
|
|
17388
|
+
...style.underline ? { lfUnderline: 1 } : {}
|
|
17389
|
+
});
|
|
17002
17390
|
fontCache.set(key, h ? h : 0);
|
|
17003
17391
|
return h ? h : null;
|
|
17004
17392
|
}
|
|
17005
17393
|
function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
17006
|
-
const stage =
|
|
17394
|
+
const { dwDrawStage: stage } = NMCUSTOMDRAW.decode(lParam);
|
|
17007
17395
|
if (stage === 1)
|
|
17008
17396
|
return 32;
|
|
17009
17397
|
if (stage === 65537)
|
|
17010
17398
|
return 32;
|
|
17011
17399
|
if (stage === 196609) {
|
|
17012
|
-
const
|
|
17013
|
-
const
|
|
17014
|
-
const style = resolveCellStyle(columns, data, row, colIndex);
|
|
17400
|
+
const cd = NMLVCUSTOMDRAW.decode(lParam);
|
|
17401
|
+
const style = resolveCellStyle(columns, data, cd.dwItemSpec, cd.iSubItem);
|
|
17015
17402
|
if (!style)
|
|
17016
17403
|
return 0;
|
|
17017
17404
|
if (style.color !== void 0)
|
|
@@ -17019,12 +17406,9 @@ function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
|
17019
17406
|
if (style.background !== void 0)
|
|
17020
17407
|
writeU32(lParam, CD_CLRTEXTBK, style.background);
|
|
17021
17408
|
const hfont = getCellFont(hwnd, 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
|
-
}
|
|
17409
|
+
if (hfont && cd.hdc) {
|
|
17410
|
+
SelectObject(cd.hdc, hfont);
|
|
17411
|
+
return 2;
|
|
17028
17412
|
}
|
|
17029
17413
|
}
|
|
17030
17414
|
return 0;
|
|
@@ -17055,14 +17439,14 @@ function resolveCellStyle(columns, data, row, colIndex) {
|
|
|
17055
17439
|
return style || void 0;
|
|
17056
17440
|
}
|
|
17057
17441
|
function makeLVItem(i, sub, text, image) {
|
|
17058
|
-
const textBuf =
|
|
17059
|
-
const
|
|
17442
|
+
const textBuf = WCHAR.encode(text);
|
|
17443
|
+
const b6 = LVITEMW.encode({
|
|
17060
17444
|
mask: 1 | (image !== void 0 ? 2 : 0),
|
|
17061
17445
|
iItem: i,
|
|
17062
17446
|
iSubItem: sub,
|
|
17063
17447
|
state: 0,
|
|
17064
17448
|
stateMask: 0,
|
|
17065
|
-
pszText:
|
|
17449
|
+
pszText: textBuf.ptr,
|
|
17066
17450
|
cchTextMax: 0,
|
|
17067
17451
|
iImage: image ?? 0,
|
|
17068
17452
|
lParam: 0,
|
|
@@ -17073,8 +17457,8 @@ function makeLVItem(i, sub, text, image) {
|
|
|
17073
17457
|
piColFmt: 0,
|
|
17074
17458
|
iGroup: 0
|
|
17075
17459
|
});
|
|
17076
|
-
|
|
17077
|
-
return
|
|
17460
|
+
b6.__textBuf = textBuf;
|
|
17461
|
+
return b6;
|
|
17078
17462
|
}
|
|
17079
17463
|
var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, data, style, icons, iconSize, getIcon }, ref) {
|
|
17080
17464
|
const lvRef = (0, import_react9.useRef)(null);
|
|
@@ -17086,36 +17470,36 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17086
17470
|
const il = iconListRef.current;
|
|
17087
17471
|
iconListRef.current = 0;
|
|
17088
17472
|
if (il) {
|
|
17089
|
-
|
|
17090
|
-
|
|
17473
|
+
gui9.SendMessage(h, 4099, 1, 0);
|
|
17474
|
+
gui9.ImageListDestroy(il);
|
|
17091
17475
|
}
|
|
17092
17476
|
if (!icons || icons.length === 0)
|
|
17093
17477
|
return;
|
|
17094
17478
|
const size = iconSize ?? 32;
|
|
17095
|
-
const img =
|
|
17479
|
+
const img = gui9.ImageListCreate(size, size, 32, icons.length, 1);
|
|
17096
17480
|
if (!img)
|
|
17097
17481
|
return;
|
|
17098
17482
|
for (const p of icons) {
|
|
17099
|
-
const hbm =
|
|
17483
|
+
const hbm = gui9.CreateBitmapFromPixels(size, size, p);
|
|
17100
17484
|
if (hbm) {
|
|
17101
|
-
|
|
17102
|
-
|
|
17485
|
+
gui9.ImageListAdd(img, hbm);
|
|
17486
|
+
DeleteObject(hbm);
|
|
17103
17487
|
}
|
|
17104
17488
|
}
|
|
17105
|
-
|
|
17489
|
+
gui9.SendMessage(h, 4099, 1, img);
|
|
17106
17490
|
iconListRef.current = img;
|
|
17107
17491
|
}, [icons, iconSize]);
|
|
17108
17492
|
(0, import_react9.useEffect)(() => {
|
|
17109
17493
|
const h = lvRef.current;
|
|
17110
17494
|
if (!h)
|
|
17111
17495
|
return;
|
|
17112
|
-
const hdr =
|
|
17496
|
+
const hdr = gui9.SendMessage(h, 4127, 0, 0);
|
|
17113
17497
|
if (hdr) {
|
|
17114
|
-
let n2 =
|
|
17498
|
+
let n2 = gui9.SendMessage(hdr, 4608, 0, 0);
|
|
17115
17499
|
for (let k = n2 - 1; k >= 0; k--)
|
|
17116
|
-
|
|
17500
|
+
gui9.SendMessage(h, 4124, k, 0);
|
|
17117
17501
|
}
|
|
17118
|
-
|
|
17502
|
+
gui9.SendMessage(
|
|
17119
17503
|
h,
|
|
17120
17504
|
4150,
|
|
17121
17505
|
0,
|
|
@@ -17124,12 +17508,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17124
17508
|
);
|
|
17125
17509
|
const n = columns.length;
|
|
17126
17510
|
for (let j = 0; j < n; j++) {
|
|
17127
|
-
const titleBuf =
|
|
17128
|
-
const lvc = LVCOLUMNW.
|
|
17511
|
+
const titleBuf = WCHAR.encode(columns[j].name);
|
|
17512
|
+
const lvc = LVCOLUMNW.encode({
|
|
17129
17513
|
mask: 4 | 2 | 1,
|
|
17130
17514
|
fmt: alignToFmt(columns[j].align),
|
|
17131
17515
|
cx: columns[j].width ?? 100,
|
|
17132
|
-
pszText:
|
|
17516
|
+
pszText: titleBuf.ptr,
|
|
17133
17517
|
cchTextMax: 0,
|
|
17134
17518
|
iSubItem: j,
|
|
17135
17519
|
iImage: 0,
|
|
@@ -17139,28 +17523,28 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17139
17523
|
cxIdeal: 0
|
|
17140
17524
|
});
|
|
17141
17525
|
lvc.__titleBuf = titleBuf;
|
|
17142
|
-
|
|
17526
|
+
gui9.SendMessage(h, 4193, j, lvc.ptr);
|
|
17143
17527
|
}
|
|
17144
17528
|
}, [columns]);
|
|
17145
17529
|
(0, import_react9.useEffect)(() => {
|
|
17146
17530
|
const h = lvRef.current;
|
|
17147
17531
|
if (!h)
|
|
17148
17532
|
return;
|
|
17149
|
-
|
|
17533
|
+
gui9.SendMessage(h, 4105, 0, 0);
|
|
17150
17534
|
const nCols = columns.length;
|
|
17151
17535
|
for (let i = 0; i < data.length; i++) {
|
|
17152
17536
|
const record = data[i];
|
|
17153
17537
|
const img = getIcon ? getIcon(record, i) : void 0;
|
|
17154
17538
|
const itemBuf = makeLVItem(i, 0, cellText(record, columns[0], i), img);
|
|
17155
|
-
|
|
17539
|
+
gui9.SendMessage(h, 4173, 0, itemBuf.ptr);
|
|
17156
17540
|
for (let j = 1; j < nCols; j++) {
|
|
17157
17541
|
const subBuf = makeLVItem(i, j, cellText(record, columns[j], i));
|
|
17158
|
-
|
|
17542
|
+
gui9.SendMessage(h, 4172, 0, subBuf.ptr);
|
|
17159
17543
|
}
|
|
17160
17544
|
}
|
|
17161
17545
|
for (let j = 0; j < columns.length; j++) {
|
|
17162
17546
|
if (columns[j].width == null) {
|
|
17163
|
-
|
|
17547
|
+
gui9.SendMessage(
|
|
17164
17548
|
h,
|
|
17165
17549
|
4126,
|
|
17166
17550
|
j,
|
|
@@ -17177,14 +17561,12 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17177
17561
|
return handleCustomDraw(e.lParam, columns, data, lvRef.current);
|
|
17178
17562
|
}
|
|
17179
17563
|
if (code === -100) {
|
|
17180
|
-
const uNewState =
|
|
17181
|
-
const uOldState = readU32(e.lParam, NMLV_UOLD);
|
|
17564
|
+
const { uNewState, uOldState } = NMLISTVIEW.decode(e.lParam);
|
|
17182
17565
|
if ((uNewState & 2) !== (uOldState & 2))
|
|
17183
17566
|
return 1;
|
|
17184
17567
|
}
|
|
17185
17568
|
if (code === -2) {
|
|
17186
|
-
const iItem =
|
|
17187
|
-
const iSubItem = readI32(e.lParam, NMIA_SUBITEM);
|
|
17569
|
+
const { iItem, iSubItem } = NMLISTVIEW.decode(e.lParam);
|
|
17188
17570
|
const col = columns[iSubItem];
|
|
17189
17571
|
const record = data[iItem];
|
|
17190
17572
|
if (col?.onCellClick && record !== void 0)
|
|
@@ -17202,33 +17584,20 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17202
17584
|
const h = lvRef.current;
|
|
17203
17585
|
if (!h)
|
|
17204
17586
|
return;
|
|
17205
|
-
|
|
17206
|
-
if (!
|
|
17207
|
-
return;
|
|
17208
|
-
const sp = gui10.GetCursorPos();
|
|
17209
|
-
if (!sp)
|
|
17587
|
+
const pt = POINT.alloc();
|
|
17588
|
+
if (!GetCursorPos(pt.ptr))
|
|
17210
17589
|
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);
|
|
17590
|
+
ScreenToClient(h, pt.ptr);
|
|
17591
|
+
const { x: sx, y: sy } = POINT.decode(pt);
|
|
17592
|
+
const hit = LVHITTESTINFO.encode({ pt: [sx, sy], iItem: -1, iSubItem: -1 });
|
|
17593
|
+
gui9.SendMessage(h, 4153, 0, hit.ptr);
|
|
17594
|
+
const { iItem, iSubItem } = LVHITTESTINFO.decode(hit);
|
|
17226
17595
|
const style2 = resolveCellStyle(columns, data, iItem, iSubItem);
|
|
17227
17596
|
if (!style2 || style2.cursor === void 0)
|
|
17228
17597
|
return;
|
|
17229
|
-
const hc =
|
|
17598
|
+
const hc = LoadCursor(NULL, style2.cursor);
|
|
17230
17599
|
if (hc) {
|
|
17231
|
-
|
|
17600
|
+
SetCursor(hc);
|
|
17232
17601
|
return 1;
|
|
17233
17602
|
}
|
|
17234
17603
|
return;
|
|
@@ -17238,7 +17607,7 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
17238
17607
|
// _build/lib/react-qw/components/ProgressBar.js
|
|
17239
17608
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
17240
17609
|
var import_react10 = __toESM(require_react(), 1);
|
|
17241
|
-
import * as
|
|
17610
|
+
import * as gui10 from "gui";
|
|
17242
17611
|
var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style, smooth }, ref) => {
|
|
17243
17612
|
const pbRef = (0, import_react10.useRef)(null);
|
|
17244
17613
|
const ws = 268435456 | 8388608 | (smooth ? 1 : 0);
|
|
@@ -17246,8 +17615,8 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17246
17615
|
const h = pbRef.current;
|
|
17247
17616
|
if (!h)
|
|
17248
17617
|
return;
|
|
17249
|
-
|
|
17250
|
-
|
|
17618
|
+
gui10.SendMessage(h, 1030, 0, max);
|
|
17619
|
+
gui10.SendMessage(h, 1026, Math.min(value, max), 0);
|
|
17251
17620
|
}, [value, max]);
|
|
17252
17621
|
return (0, import_jsx_runtime9.jsx)("w", { type: "msctls_progress32", ws, style, ref: (h) => {
|
|
17253
17622
|
pbRef.current = h;
|
|
@@ -17261,7 +17630,7 @@ var ProgressBar = (0, import_react10.forwardRef)(({ value = 0, max = 100, style,
|
|
|
17261
17630
|
// _build/lib/react-qw/components/RadioButton.js
|
|
17262
17631
|
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
17263
17632
|
var import_react11 = __toESM(require_react(), 1);
|
|
17264
|
-
import * as
|
|
17633
|
+
import * as gui11 from "gui";
|
|
17265
17634
|
var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked, defaultChecked = false, onChange, label, style, disabled }, ref) => {
|
|
17266
17635
|
const [internalChecked, setInternalChecked] = (0, import_react11.useState)(defaultChecked);
|
|
17267
17636
|
const isControlled = controlledChecked !== void 0;
|
|
@@ -17271,7 +17640,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17271
17640
|
const h = rbRef.current;
|
|
17272
17641
|
if (!h)
|
|
17273
17642
|
return;
|
|
17274
|
-
|
|
17643
|
+
gui11.SendMessage(h, 241, displayChecked ? 1 : 0, 0);
|
|
17275
17644
|
}, [displayChecked]);
|
|
17276
17645
|
return (0, import_jsx_runtime10.jsx)("w", { type: "BUTTON", text: label ?? "", ws: 268435456 | 9, style, disabled, ref: (h) => {
|
|
17277
17646
|
rbRef.current = h;
|
|
@@ -17281,7 +17650,7 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17281
17650
|
ref.current = h;
|
|
17282
17651
|
}, onEvent: (e) => {
|
|
17283
17652
|
if (e.msg === 514) {
|
|
17284
|
-
const newChecked =
|
|
17653
|
+
const newChecked = gui11.SendMessage(e.hwnd, 240, 0, 0) !== 0;
|
|
17285
17654
|
if (newChecked !== displayChecked) {
|
|
17286
17655
|
if (!isControlled)
|
|
17287
17656
|
setInternalChecked(newChecked);
|
|
@@ -17294,24 +17663,27 @@ var RadioButton = (0, import_react11.forwardRef)(({ checked: controlledChecked,
|
|
|
17294
17663
|
// _build/lib/react-qw/components/ScrollView.js
|
|
17295
17664
|
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
17296
17665
|
var import_react12 = __toESM(require_react(), 1);
|
|
17297
|
-
import * as
|
|
17666
|
+
import * as gui12 from "gui";
|
|
17298
17667
|
var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth, contentHeight }, ref) => {
|
|
17299
17668
|
const svRef = (0, import_react12.useRef)(null);
|
|
17300
17669
|
const contentRef = (0, import_react12.useRef)(null);
|
|
17301
17670
|
const scrollXRef = (0, import_react12.useRef)(0);
|
|
17302
17671
|
const scrollYRef = (0, import_react12.useRef)(0);
|
|
17303
17672
|
function updateScroll(sv, content) {
|
|
17304
|
-
const svRect =
|
|
17673
|
+
const svRect = gui12.GetClientRect(sv);
|
|
17305
17674
|
if (!svRect)
|
|
17306
17675
|
return;
|
|
17307
17676
|
const svW = svRect.right - svRect.left;
|
|
17308
17677
|
const svH = svRect.bottom - svRect.top;
|
|
17309
|
-
const
|
|
17678
|
+
const hdc = GetDC(NULL);
|
|
17679
|
+
const scale = hdc ? GetDeviceCaps(hdc, 88) / 96 : 1;
|
|
17680
|
+
if (hdc)
|
|
17681
|
+
ReleaseDC(NULL, hdc);
|
|
17310
17682
|
const natW = Math.round((contentWidth ?? svW / scale) * scale);
|
|
17311
17683
|
const natH = Math.round((contentHeight ?? svH / scale) * scale);
|
|
17312
17684
|
scrollXRef.current = Math.max(0, Math.min(scrollXRef.current, natW - svW));
|
|
17313
17685
|
scrollYRef.current = Math.max(0, Math.min(scrollYRef.current, natH - svH));
|
|
17314
|
-
|
|
17686
|
+
SetWindowPos(
|
|
17315
17687
|
content,
|
|
17316
17688
|
0,
|
|
17317
17689
|
-scrollXRef.current,
|
|
@@ -17323,18 +17695,18 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17323
17695
|
);
|
|
17324
17696
|
forceFlexLayout(content);
|
|
17325
17697
|
if (natW > svW) {
|
|
17326
|
-
|
|
17327
|
-
|
|
17698
|
+
gui12.SetScrollInfo(sv, 0, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
|
|
17699
|
+
ShowScrollBar(sv, 0, 1);
|
|
17328
17700
|
} else {
|
|
17329
17701
|
scrollXRef.current = 0;
|
|
17330
|
-
|
|
17702
|
+
ShowScrollBar(sv, 0, 0);
|
|
17331
17703
|
}
|
|
17332
17704
|
if (natH > svH) {
|
|
17333
|
-
|
|
17334
|
-
|
|
17705
|
+
gui12.SetScrollInfo(sv, 1, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
|
|
17706
|
+
ShowScrollBar(sv, 1, 1);
|
|
17335
17707
|
} else {
|
|
17336
17708
|
scrollYRef.current = 0;
|
|
17337
|
-
|
|
17709
|
+
ShowScrollBar(sv, 1, 0);
|
|
17338
17710
|
}
|
|
17339
17711
|
}
|
|
17340
17712
|
(0, import_react12.useLayoutEffect)(() => {
|
|
@@ -17350,7 +17722,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17350
17722
|
} else {
|
|
17351
17723
|
scrollXRef.current = newPos;
|
|
17352
17724
|
}
|
|
17353
|
-
|
|
17725
|
+
SetWindowPos(
|
|
17354
17726
|
content,
|
|
17355
17727
|
0,
|
|
17356
17728
|
-scrollXRef.current,
|
|
@@ -17360,14 +17732,14 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17360
17732
|
1 | 4
|
|
17361
17733
|
/* gui.SetWindowPosFlag.SWP_NOZORDER */
|
|
17362
17734
|
);
|
|
17363
|
-
|
|
17735
|
+
gui12.SetScrollInfo(sv, bar, { pos: newPos }, true);
|
|
17364
17736
|
}
|
|
17365
17737
|
function handleScroll(e, bar) {
|
|
17366
17738
|
const sv = svRef.current;
|
|
17367
17739
|
const content = contentRef.current;
|
|
17368
17740
|
if (!sv || !content)
|
|
17369
17741
|
return;
|
|
17370
|
-
const info =
|
|
17742
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17371
17743
|
const maxPos = info.max - info.page + 1;
|
|
17372
17744
|
const code = e.wParam & 65535;
|
|
17373
17745
|
const ref_ = bar === 1 ? scrollYRef : scrollXRef;
|
|
@@ -17401,7 +17773,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17401
17773
|
if (!isHorz && contentHeight === void 0)
|
|
17402
17774
|
return;
|
|
17403
17775
|
const bar = isHorz ? 0 : 1;
|
|
17404
|
-
const info =
|
|
17776
|
+
const info = gui12.GetScrollInfo(sv, bar);
|
|
17405
17777
|
const maxPos = info.max - info.page + 1;
|
|
17406
17778
|
const ref_ = isHorz ? scrollXRef : scrollYRef;
|
|
17407
17779
|
let newPos = ref_.current + dy;
|
|
@@ -17418,7 +17790,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17418
17790
|
}, onEvent: {
|
|
17419
17791
|
fn: (e) => {
|
|
17420
17792
|
if (e.msg === 132 || e.msg === 161) {
|
|
17421
|
-
return
|
|
17793
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17422
17794
|
}
|
|
17423
17795
|
if (e.msg === 277) {
|
|
17424
17796
|
handleScroll(
|
|
@@ -17450,7 +17822,7 @@ var ScrollView = (0, import_react12.forwardRef)(({ children, style, contentWidth
|
|
|
17450
17822
|
// _build/lib/react-qw/components/Slider.js
|
|
17451
17823
|
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
|
|
17452
17824
|
var import_react13 = __toESM(require_react(), 1);
|
|
17453
|
-
import * as
|
|
17825
|
+
import * as gui13 from "gui";
|
|
17454
17826
|
var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 100, vertical = false, disabled, style }, ref) => {
|
|
17455
17827
|
const wrapperRef = (0, import_react13.useRef)(null);
|
|
17456
17828
|
const sliderRef = (0, import_react13.useRef)(null);
|
|
@@ -17459,14 +17831,14 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17459
17831
|
if (!h)
|
|
17460
17832
|
return;
|
|
17461
17833
|
const lParam = min & 65535 | (max & 65535) << 16;
|
|
17462
|
-
|
|
17463
|
-
|
|
17834
|
+
gui13.SendMessage(h, 1030, 0, lParam);
|
|
17835
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17464
17836
|
}, [min, max]);
|
|
17465
17837
|
(0, import_react13.useEffect)(() => {
|
|
17466
17838
|
const h = sliderRef.current;
|
|
17467
17839
|
if (!h)
|
|
17468
17840
|
return;
|
|
17469
|
-
|
|
17841
|
+
gui13.SendMessage(h, 1029, 1, value);
|
|
17470
17842
|
}, [value]);
|
|
17471
17843
|
const tbStyle = 268435456 | 65536 | 1 | (vertical ? 2 : 0);
|
|
17472
17844
|
return (0, import_jsx_runtime12.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style, ref: (h) => {
|
|
@@ -17477,13 +17849,13 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17477
17849
|
ref.current = h;
|
|
17478
17850
|
}, onEvent: (e) => {
|
|
17479
17851
|
if (e.msg === 132 || e.msg === 161) {
|
|
17480
|
-
return
|
|
17852
|
+
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
17481
17853
|
}
|
|
17482
17854
|
if (e.msg === 276 || e.msg === 277) {
|
|
17483
17855
|
const h = sliderRef.current;
|
|
17484
17856
|
if (!h)
|
|
17485
17857
|
return 0;
|
|
17486
|
-
const pos =
|
|
17858
|
+
const pos = gui13.SendMessage(h, 1024, 0, 0);
|
|
17487
17859
|
onChange?.(pos);
|
|
17488
17860
|
return 0;
|
|
17489
17861
|
}
|
|
@@ -17496,24 +17868,7 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
17496
17868
|
// _build/lib/react-qw/components/Tab.js
|
|
17497
17869
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
17498
17870
|
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
|
-
}
|
|
17871
|
+
import * as gui14 from "gui";
|
|
17517
17872
|
var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex, defaultSelectedIndex = 0, onChange, style }, ref) => {
|
|
17518
17873
|
const [internalIndex, setInternalIndex] = (0, import_react14.useState)(defaultSelectedIndex);
|
|
17519
17874
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -17523,27 +17878,27 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17523
17878
|
const h = tabHwnd.current;
|
|
17524
17879
|
if (!h)
|
|
17525
17880
|
return;
|
|
17526
|
-
|
|
17881
|
+
gui14.SendMessage(h, 4873, 0, 0);
|
|
17527
17882
|
for (let i = 0; i < tabs.length; i++) {
|
|
17528
|
-
const titleBuf =
|
|
17529
|
-
const tci = TCITEMW.
|
|
17883
|
+
const titleBuf = WCHAR.encode(tabs[i].title);
|
|
17884
|
+
const tci = TCITEMW.encode({
|
|
17530
17885
|
mask: 1,
|
|
17531
17886
|
dwState: 0,
|
|
17532
17887
|
dwStateMask: 0,
|
|
17533
|
-
pszText:
|
|
17888
|
+
pszText: titleBuf.ptr,
|
|
17534
17889
|
cchTextMax: tabs[i].title.length + 1,
|
|
17535
17890
|
iImage: 0,
|
|
17536
17891
|
lParam: 0
|
|
17537
17892
|
});
|
|
17538
|
-
const tciPtr =
|
|
17539
|
-
|
|
17893
|
+
const tciPtr = tci.ptr;
|
|
17894
|
+
gui14.SendMessage(h, 4926, i, tciPtr);
|
|
17540
17895
|
}
|
|
17541
|
-
|
|
17896
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17542
17897
|
}, [tabs]);
|
|
17543
17898
|
(0, import_react14.useEffect)(() => {
|
|
17544
17899
|
const h = tabHwnd.current;
|
|
17545
17900
|
if (h)
|
|
17546
|
-
|
|
17901
|
+
gui14.SendMessage(h, 4876, sel, 0);
|
|
17547
17902
|
}, [sel]);
|
|
17548
17903
|
return (0, import_jsx_runtime13.jsxs)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17549
17904
|
if (e.msg === 78) {
|
|
@@ -17552,7 +17907,7 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17552
17907
|
return;
|
|
17553
17908
|
const code = nmCode(e.lParam);
|
|
17554
17909
|
if (code === -552 || code === -2) {
|
|
17555
|
-
const newSel =
|
|
17910
|
+
const newSel = gui14.SendMessage(h, 4875, 0, 0);
|
|
17556
17911
|
if (newSel !== sel) {
|
|
17557
17912
|
if (!isControlled)
|
|
17558
17913
|
setInternalIndex(newSel);
|
|
@@ -17565,54 +17920,17 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
17565
17920
|
|
|
17566
17921
|
// _build/lib/react-qw/components/Tooltip.js
|
|
17567
17922
|
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
|
-
});
|
|
17923
|
+
import * as gui15 from "gui";
|
|
17582
17924
|
|
|
17583
17925
|
// _build/lib/react-qw/components/TreeView.js
|
|
17584
17926
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
17585
17927
|
var import_react16 = __toESM(require_react(), 1);
|
|
17586
|
-
import * as
|
|
17587
|
-
import * as ffi10 from "ffi";
|
|
17588
|
-
var TVITEM = struct({
|
|
17589
|
-
mask: "u32",
|
|
17590
|
-
hItem: "ptr",
|
|
17591
|
-
state: "u32",
|
|
17592
|
-
stateMask: "u32",
|
|
17593
|
-
pszText: "ptr",
|
|
17594
|
-
cchTextMax: "i32",
|
|
17595
|
-
iImage: "i32",
|
|
17596
|
-
iSelectedImage: "i32",
|
|
17597
|
-
cChildren: "i32",
|
|
17598
|
-
lParam: "ptr"
|
|
17599
|
-
});
|
|
17600
|
-
var TVINSERTSTRUCT = struct({ hParent: "ptr", hInsertAfter: "ptr", item: TVITEM });
|
|
17601
|
-
function textToUtf164(s) {
|
|
17602
|
-
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
17603
|
-
const dv = new DataView(buf);
|
|
17604
|
-
for (let i = 0; i < s.length; i++)
|
|
17605
|
-
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
17606
|
-
return buf;
|
|
17607
|
-
}
|
|
17608
|
-
function bufPtr3(buf) {
|
|
17609
|
-
return ffi10.bufferPtr(buf);
|
|
17610
|
-
}
|
|
17928
|
+
import * as gui16 from "gui";
|
|
17611
17929
|
function buildTvItem(textPtr, cChildren) {
|
|
17612
17930
|
let mask = 1;
|
|
17613
17931
|
if (cChildren > 0)
|
|
17614
17932
|
mask |= 64;
|
|
17615
|
-
return TVITEM.
|
|
17933
|
+
return TVITEM.encode({
|
|
17616
17934
|
mask,
|
|
17617
17935
|
hItem: 0,
|
|
17618
17936
|
state: 0,
|
|
@@ -17628,24 +17946,24 @@ function buildTvItem(textPtr, cChildren) {
|
|
|
17628
17946
|
function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
|
|
17629
17947
|
for (const node of nodes) {
|
|
17630
17948
|
const cChildren = node.children && node.children.length > 0 ? 1 : 0;
|
|
17631
|
-
const textBuf =
|
|
17632
|
-
const itemBuf = buildTvItem(
|
|
17633
|
-
const item = TVITEM.
|
|
17634
|
-
const tvins = TVINSERTSTRUCT.
|
|
17635
|
-
const hItem =
|
|
17949
|
+
const textBuf = WCHAR.encode(node.label);
|
|
17950
|
+
const itemBuf = buildTvItem(textBuf.ptr, cChildren);
|
|
17951
|
+
const item = TVITEM.decode(itemBuf);
|
|
17952
|
+
const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536, item });
|
|
17953
|
+
const hItem = gui16.SendMessage(hTree, 4402, 0, tvins.ptr);
|
|
17636
17954
|
hItemMap.set(hItem, node);
|
|
17637
17955
|
if (node.key)
|
|
17638
17956
|
keyMap.set(node.key, hItem);
|
|
17639
17957
|
if (node.children && node.children.length > 0) {
|
|
17640
17958
|
insertItems(hTree, node.children, hItem, hItemMap, keyMap);
|
|
17641
|
-
|
|
17959
|
+
gui16.SendMessage(hTree, 4354, 2, hItem);
|
|
17642
17960
|
}
|
|
17643
17961
|
}
|
|
17644
17962
|
}
|
|
17645
17963
|
function deleteAllItems(hTree) {
|
|
17646
|
-
const n =
|
|
17964
|
+
const n = gui16.SendMessage(hTree, 4357, 0, 0);
|
|
17647
17965
|
if (n > 0)
|
|
17648
|
-
|
|
17966
|
+
gui16.SendMessage(
|
|
17649
17967
|
hTree,
|
|
17650
17968
|
4353,
|
|
17651
17969
|
1,
|
|
@@ -17677,7 +17995,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17677
17995
|
const h = tvRef.current;
|
|
17678
17996
|
if (!h)
|
|
17679
17997
|
return;
|
|
17680
|
-
|
|
17998
|
+
gui16.SendMessage(
|
|
17681
17999
|
h,
|
|
17682
18000
|
4396,
|
|
17683
18001
|
0,
|
|
@@ -17693,7 +18011,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17693
18011
|
return;
|
|
17694
18012
|
const hItem = keyMapRef.current.get(selKey);
|
|
17695
18013
|
if (hItem !== void 0)
|
|
17696
|
-
|
|
18014
|
+
gui16.SendMessage(h, 4363, 9, hItem);
|
|
17697
18015
|
}, [selKey]);
|
|
17698
18016
|
return (0, import_jsx_runtime14.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17699
18017
|
if (e.msg === 78) {
|
|
@@ -17702,7 +18020,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17702
18020
|
const h = tvRef.current;
|
|
17703
18021
|
if (!h)
|
|
17704
18022
|
return;
|
|
17705
|
-
const hCaret =
|
|
18023
|
+
const hCaret = gui16.SendMessage(h, 4362, 9, 0);
|
|
17706
18024
|
const node = hItemMapRef.current.get(hCaret) ?? null;
|
|
17707
18025
|
const key = node?.key ?? null;
|
|
17708
18026
|
if (!isControlled)
|
|
@@ -17718,153 +18036,63 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17718
18036
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17719
18037
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
17720
18038
|
var import_react17 = __toESM(require_react(), 1);
|
|
17721
|
-
import * as ffi11 from "ffi";
|
|
17722
|
-
import * as win3 from "win";
|
|
17723
18039
|
|
|
17724
|
-
// _build/lib/
|
|
17725
|
-
var
|
|
17726
|
-
|
|
17727
|
-
|
|
17728
|
-
|
|
17729
|
-
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
|
|
17736
|
-
nMaxFileTitle: "u32",
|
|
17737
|
-
lpstrInitialDir: "ptr",
|
|
17738
|
-
lpstrTitle: "ptr",
|
|
17739
|
-
Flags: "u32",
|
|
17740
|
-
nFileOffset: "u16",
|
|
17741
|
-
nFileExtension: "u16",
|
|
17742
|
-
lpstrDefExt: "ptr",
|
|
17743
|
-
lCustData: "ptr",
|
|
17744
|
-
lpfnHook: "ptr",
|
|
17745
|
-
lpTemplateName: "ptr",
|
|
17746
|
-
pvReserved: "ptr",
|
|
17747
|
-
dwReserved: "u32",
|
|
17748
|
-
FlagsEx: "u32"
|
|
17749
|
-
});
|
|
17750
|
-
var BROWSEINFOW = struct({
|
|
17751
|
-
hwndOwner: "ptr",
|
|
17752
|
-
pidlRoot: "ptr",
|
|
17753
|
-
pszDisplayName: "ptr",
|
|
17754
|
-
lpszTitle: "ptr",
|
|
17755
|
-
ulFlags: "u32",
|
|
17756
|
-
lpfn: "ptr",
|
|
17757
|
-
lParam: "ptr",
|
|
17758
|
-
iImage: "i32"
|
|
17759
|
-
});
|
|
18040
|
+
// _build/lib/windows/comdlg32.js
|
|
18041
|
+
var b3 = (name, sig) => bind("comdlg32.dll", name, sig);
|
|
18042
|
+
var GetOpenFileName = /* @__PURE__ */ b3("GetOpenFileNameW", "<BYTE>ptr -> u32");
|
|
18043
|
+
|
|
18044
|
+
// _build/lib/windows/shell32.js
|
|
18045
|
+
var b4 = (name, sig) => bind("shell32.dll", name, sig);
|
|
18046
|
+
var SHBrowseForFolder = /* @__PURE__ */ b4("SHBrowseForFolderW", "<BYTE>ptr -> <>ptr");
|
|
18047
|
+
var SHGetPathFromIDList = /* @__PURE__ */ b4("SHGetPathFromIDListW", "<>ptr <BYTE>ptr -> u32");
|
|
18048
|
+
|
|
18049
|
+
// _build/lib/windows/ole32.js
|
|
18050
|
+
var b5 = (name, sig) => bind("ole32.dll", name, sig);
|
|
18051
|
+
var CoTaskMemFree = /* @__PURE__ */ b5("CoTaskMemFree", "<>ptr -> void");
|
|
17760
18052
|
|
|
17761
18053
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17762
|
-
var FFI_PTR = ffi11.FFI_TYPE_POINTER;
|
|
17763
|
-
var FFI_U32 = ffi11.FFI_TYPE_UINT32;
|
|
17764
|
-
var _GetOpenFileNameW = 0;
|
|
17765
|
-
var _SHBrowseForFolderW = 0;
|
|
17766
|
-
var _SHGetPathFromIDListW = 0;
|
|
17767
|
-
var _CoTaskMemFree = 0;
|
|
17768
|
-
function ensureDlls() {
|
|
17769
|
-
if (_GetOpenFileNameW)
|
|
17770
|
-
return true;
|
|
17771
|
-
const comdlg32 = win3.LoadLibrary("comdlg32.dll");
|
|
17772
|
-
const shell32 = win3.LoadLibrary("shell32.dll");
|
|
17773
|
-
const ole32 = win3.LoadLibrary("ole32.dll");
|
|
17774
|
-
if (!comdlg32 || !shell32 || !ole32)
|
|
17775
|
-
return false;
|
|
17776
|
-
const load = (lib, name) => win3.GetProcAddress(lib, name) || 0;
|
|
17777
|
-
_GetOpenFileNameW = load(comdlg32, "GetOpenFileNameW");
|
|
17778
|
-
_SHBrowseForFolderW = load(shell32, "SHBrowseForFolderW");
|
|
17779
|
-
_SHGetPathFromIDListW = load(shell32, "SHGetPathFromIDListW");
|
|
17780
|
-
_CoTaskMemFree = load(ole32, "CoTaskMemFree");
|
|
17781
|
-
return !!_GetOpenFileNameW && !!_SHBrowseForFolderW && !!_SHGetPathFromIDListW && !!_CoTaskMemFree;
|
|
17782
|
-
}
|
|
17783
|
-
function strToWide(s) {
|
|
17784
|
-
return new TextEncoder("utf-16le").encode(s + "\0").buffer;
|
|
17785
|
-
}
|
|
17786
|
-
var _decoder = new TextDecoder("utf-16le");
|
|
17787
|
-
function wideToStr(buf, offset = 0) {
|
|
17788
|
-
const str = _decoder.decode(new Uint8Array(buf, offset));
|
|
17789
|
-
const nullIdx = str.indexOf("\0");
|
|
17790
|
-
return nullIdx >= 0 ? str.substring(0, nullIdx) : str;
|
|
17791
|
-
}
|
|
17792
18054
|
function openFileDialog(owner, filter, title, multiple) {
|
|
17793
|
-
|
|
17794
|
-
|
|
17795
|
-
const
|
|
17796
|
-
const filterWide = strToWide(filter);
|
|
17797
|
-
const titleWide = title ? strToWide(title) : null;
|
|
18055
|
+
const fileBuf = WCHAR.alloc(260);
|
|
18056
|
+
const filterWide = WCHAR.encode(filter);
|
|
18057
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
17798
18058
|
let flags = 4096 | 2048 | 8;
|
|
17799
18059
|
if (multiple)
|
|
17800
18060
|
flags |= 512;
|
|
17801
18061
|
flags |= 524288;
|
|
17802
|
-
const ofn = OPENFILENAMEW.
|
|
18062
|
+
const ofn = OPENFILENAMEW.encode({
|
|
17803
18063
|
lStructSize: OPENFILENAMEW.size,
|
|
17804
18064
|
hwndOwner: owner,
|
|
17805
|
-
|
|
17806
|
-
|
|
17807
|
-
lpstrCustomFilter: 0,
|
|
17808
|
-
nMaxCustFilter: 0,
|
|
17809
|
-
nFilterIndex: 0,
|
|
17810
|
-
lpstrFile: ffi11.bufferPtr(fileBuf),
|
|
18065
|
+
lpstrFilter: filterWide.ptr,
|
|
18066
|
+
lpstrFile: fileBuf.ptr,
|
|
17811
18067
|
nMaxFile: 260,
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
lpstrInitialDir: 0,
|
|
17815
|
-
lpstrTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17816
|
-
Flags: flags,
|
|
17817
|
-
nFileOffset: 0,
|
|
17818
|
-
nFileExtension: 0,
|
|
17819
|
-
lpstrDefExt: 0,
|
|
17820
|
-
lCustData: 0,
|
|
17821
|
-
lpfnHook: 0,
|
|
17822
|
-
lpTemplateName: 0,
|
|
17823
|
-
pvReserved: 0,
|
|
17824
|
-
dwReserved: 0,
|
|
17825
|
-
FlagsEx: 0
|
|
18068
|
+
lpstrTitle: titleWide?.ptr ?? 0,
|
|
18069
|
+
Flags: flags
|
|
17826
18070
|
});
|
|
17827
|
-
const ret =
|
|
18071
|
+
const ret = GetOpenFileName(ofn);
|
|
17828
18072
|
if (!ret)
|
|
17829
18073
|
return null;
|
|
17830
18074
|
if (!multiple) {
|
|
17831
|
-
return
|
|
18075
|
+
return WCHAR.decode(fileBuf);
|
|
17832
18076
|
}
|
|
17833
|
-
const
|
|
17834
|
-
|
|
17835
|
-
const files =
|
|
17836
|
-
|
|
17837
|
-
const f = wideToStr(fileBuf, pos);
|
|
17838
|
-
if (f.length === 0)
|
|
17839
|
-
break;
|
|
17840
|
-
files.push(dir + "\\" + f);
|
|
17841
|
-
pos += (f.length + 1) * 2;
|
|
17842
|
-
}
|
|
17843
|
-
if (files.length === 0)
|
|
17844
|
-
return [dir];
|
|
17845
|
-
return files;
|
|
18077
|
+
const strs = new TextDecoder("utf-16le").decode(new Uint8Array(fileBuf)).split("\0");
|
|
18078
|
+
const dir = strs[0] ?? "";
|
|
18079
|
+
const files = strs.slice(1).filter((f) => f.length > 0).map((f) => dir + "\\" + f);
|
|
18080
|
+
return files.length > 0 ? files : [dir];
|
|
17846
18081
|
}
|
|
17847
18082
|
function openFolderDialog(owner, title) {
|
|
17848
|
-
|
|
17849
|
-
|
|
17850
|
-
const titleWide = title ? strToWide(title) : null;
|
|
17851
|
-
const bi = BROWSEINFOW.write({
|
|
18083
|
+
const titleWide = title ? WCHAR.encode(title) : null;
|
|
18084
|
+
const bi = BROWSEINFOW.encode({
|
|
17852
18085
|
hwndOwner: owner,
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
lpszTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17856
|
-
ulFlags: 65,
|
|
17857
|
-
lpfn: 0,
|
|
17858
|
-
lParam: 0,
|
|
17859
|
-
iImage: 0
|
|
18086
|
+
lpszTitle: titleWide?.ptr ?? 0,
|
|
18087
|
+
ulFlags: 65
|
|
17860
18088
|
});
|
|
17861
|
-
const pidl =
|
|
18089
|
+
const pidl = SHBrowseForFolder(bi);
|
|
17862
18090
|
if (!pidl)
|
|
17863
18091
|
return null;
|
|
17864
|
-
const pathBuf =
|
|
17865
|
-
const ok =
|
|
17866
|
-
|
|
17867
|
-
return ok ?
|
|
18092
|
+
const pathBuf = WCHAR.alloc(260);
|
|
18093
|
+
const ok = SHGetPathFromIDList(pidl, pathBuf);
|
|
18094
|
+
CoTaskMemFree(pidl);
|
|
18095
|
+
return ok ? WCHAR.decode(pathBuf) : null;
|
|
17868
18096
|
}
|
|
17869
18097
|
var PathPicker = (0, import_react17.forwardRef)((props, ref) => {
|
|
17870
18098
|
const { type = "file", filter = "All Files\0*.*\0\0", title, disabled, style } = props;
|
|
@@ -17915,7 +18143,7 @@ var rootMap = /* @__PURE__ */ new Map();
|
|
|
17915
18143
|
function ensureDefaultClass() {
|
|
17916
18144
|
if (defaultClassRegistered)
|
|
17917
18145
|
return DEFAULT_CLASS;
|
|
17918
|
-
|
|
18146
|
+
gui17.RegisterClass(DEFAULT_CLASS, (hwnd, msg, wParam, lParam) => {
|
|
17919
18147
|
const entry = rootMap.get(hwnd);
|
|
17920
18148
|
if (msg === 2 && entry) {
|
|
17921
18149
|
rootMap.delete(hwnd);
|
|
@@ -17928,7 +18156,7 @@ function ensureDefaultClass() {
|
|
|
17928
18156
|
return result;
|
|
17929
18157
|
if (msg === 5)
|
|
17930
18158
|
forceFlexLayout(hwnd);
|
|
17931
|
-
return
|
|
18159
|
+
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
17932
18160
|
});
|
|
17933
18161
|
defaultClassRegistered = true;
|
|
17934
18162
|
return DEFAULT_CLASS;
|
|
@@ -17941,15 +18169,15 @@ function createRoot(container) {
|
|
|
17941
18169
|
const ws = (cfg.ws ?? 0) | 13565952;
|
|
17942
18170
|
const w = (cfg.width ?? 800) * scaleFactor;
|
|
17943
18171
|
const h = (cfg.height ?? 600) * scaleFactor;
|
|
17944
|
-
const [sw, sh] =
|
|
18172
|
+
const [sw, sh] = [GetSystemMetrics(0), GetSystemMetrics(1)];
|
|
17945
18173
|
const x = cfg.x === void 0 ? (sw - w) / 2 | 0 : cfg.x === -2147483648 ? -2147483648 : cfg.x * scaleFactor;
|
|
17946
18174
|
const y = cfg.y === void 0 ? (sh - h) / 2 | 0 : cfg.y === -2147483648 ? -2147483648 : cfg.y * scaleFactor;
|
|
17947
|
-
const hwin =
|
|
18175
|
+
const hwin = gui17.CreateWindow(className, cfg.text || "", ws, x, y, w, h, null, null);
|
|
17948
18176
|
if (!hwin)
|
|
17949
18177
|
throw new Error("CreateWindow failed");
|
|
17950
18178
|
hwnd = hwin;
|
|
17951
18179
|
if (!cfg.noShowWindow)
|
|
17952
|
-
|
|
18180
|
+
gui17.ShowWindow(hwnd);
|
|
17953
18181
|
} else {
|
|
17954
18182
|
hwnd = container;
|
|
17955
18183
|
}
|
|
@@ -17970,9 +18198,10 @@ function createRoot(container) {
|
|
|
17970
18198
|
}
|
|
17971
18199
|
|
|
17972
18200
|
// _build/test/test_helper.js
|
|
17973
|
-
import * as
|
|
18201
|
+
import * as std2 from "std";
|
|
17974
18202
|
var GREEN = "\x1B[32m";
|
|
17975
18203
|
var RED = "\x1B[31m";
|
|
18204
|
+
var YELLOW = "\x1B[33m";
|
|
17976
18205
|
var BOLD = "\x1B[1m";
|
|
17977
18206
|
var RESET = "\x1B[0m";
|
|
17978
18207
|
function formatDuration(ms) {
|
|
@@ -17983,6 +18212,7 @@ function formatDuration(ms) {
|
|
|
17983
18212
|
var Tester = class {
|
|
17984
18213
|
ok = 0;
|
|
17985
18214
|
fail = 0;
|
|
18215
|
+
skip = 0;
|
|
17986
18216
|
startTime = Date.now();
|
|
17987
18217
|
sectionStart = this.startTime;
|
|
17988
18218
|
lastSection = "";
|
|
@@ -17990,65 +18220,70 @@ var Tester = class {
|
|
|
17990
18220
|
const now = Date.now();
|
|
17991
18221
|
if (this.lastSection) {
|
|
17992
18222
|
const elapsed = now - this.sectionStart;
|
|
17993
|
-
|
|
18223
|
+
std2.printf(" (%s)\n", formatDuration(elapsed));
|
|
17994
18224
|
}
|
|
17995
18225
|
this.sectionStart = now;
|
|
17996
18226
|
this.lastSection = name;
|
|
17997
|
-
|
|
18227
|
+
std2.printf("\n%s=== %s ===%s\n", BOLD, name, RESET);
|
|
17998
18228
|
}
|
|
17999
18229
|
check(name, expected, actual) {
|
|
18000
18230
|
if (typeof expected === "number" && typeof actual === "number") {
|
|
18001
18231
|
if (Math.abs(expected - actual) < 1e-4) {
|
|
18002
18232
|
this.ok++;
|
|
18003
|
-
|
|
18233
|
+
std2.printf(" %sPASS:%s %s = %s\n", GREEN, RESET, name, String(actual));
|
|
18004
18234
|
} else {
|
|
18005
18235
|
this.fail++;
|
|
18006
|
-
|
|
18236
|
+
std2.printf(" %sFAIL:%s %s = %s (expected %s)\n", RED, RESET, name, String(actual), String(expected));
|
|
18007
18237
|
}
|
|
18008
18238
|
} else if (expected === actual) {
|
|
18009
18239
|
this.ok++;
|
|
18010
|
-
|
|
18240
|
+
std2.printf(" %sPASS:%s %s = %s\n", GREEN, RESET, name, String(actual));
|
|
18011
18241
|
} else {
|
|
18012
18242
|
this.fail++;
|
|
18013
|
-
|
|
18243
|
+
std2.printf(" %sFAIL:%s %s = %s (expected %s)\n", RED, RESET, name, String(actual), String(expected));
|
|
18014
18244
|
}
|
|
18015
18245
|
}
|
|
18016
18246
|
checkTrue(name, actual) {
|
|
18017
18247
|
this.check(name, true, actual);
|
|
18018
18248
|
}
|
|
18249
|
+
skipCase(name) {
|
|
18250
|
+
this.skip++;
|
|
18251
|
+
std2.printf(" %sSKIP:%s %s\n", YELLOW, RESET, name);
|
|
18252
|
+
}
|
|
18019
18253
|
summary() {
|
|
18020
18254
|
const now = Date.now();
|
|
18021
18255
|
if (this.lastSection) {
|
|
18022
18256
|
const elapsed = now - this.sectionStart;
|
|
18023
|
-
|
|
18257
|
+
std2.printf(" (%s)\n", formatDuration(elapsed));
|
|
18024
18258
|
}
|
|
18025
18259
|
const total = now - this.startTime;
|
|
18026
18260
|
const color = this.fail > 0 ? RED : GREEN;
|
|
18027
|
-
|
|
18261
|
+
const skipped = this.skip > 0 ? ` (${this.skip} skipped)` : "";
|
|
18262
|
+
std2.printf("\n%s%d/%d passed%s (%s)%s\n", color, this.ok, this.ok + this.fail, skipped, formatDuration(total), RESET);
|
|
18028
18263
|
}
|
|
18029
18264
|
};
|
|
18030
18265
|
|
|
18031
18266
|
// _build/test/test_react_flex.js
|
|
18032
18267
|
var __setItems = null;
|
|
18033
|
-
|
|
18268
|
+
gui18.RegisterClass("FlexTest", (hwnd, msg, wParam, lParam) => {
|
|
18034
18269
|
if (!hwnd)
|
|
18035
|
-
return
|
|
18270
|
+
return gui18.DefWindowProc(hwnd, msg, wParam, lParam);
|
|
18036
18271
|
if (msg === 2) {
|
|
18037
|
-
|
|
18272
|
+
gui18.PostQuitMessage(0);
|
|
18038
18273
|
return 0;
|
|
18039
18274
|
}
|
|
18040
|
-
return
|
|
18275
|
+
return gui18.DefWindowProc(hwnd, msg, wParam, lParam);
|
|
18041
18276
|
});
|
|
18042
18277
|
function childrenOf(hwnd) {
|
|
18043
18278
|
const kids = [];
|
|
18044
|
-
let child =
|
|
18279
|
+
let child = gui18.GetWindow(
|
|
18045
18280
|
hwnd,
|
|
18046
18281
|
5
|
|
18047
18282
|
/* gui.GetWindowCmd.CHILD */
|
|
18048
18283
|
);
|
|
18049
18284
|
while (child) {
|
|
18050
18285
|
kids.push(child);
|
|
18051
|
-
child =
|
|
18286
|
+
child = gui18.GetWindow(
|
|
18052
18287
|
child,
|
|
18053
18288
|
2
|
|
18054
18289
|
/* gui.GetWindowCmd.NEXT */
|
|
@@ -18057,8 +18292,8 @@ function childrenOf(hwnd) {
|
|
|
18057
18292
|
return kids.reverse();
|
|
18058
18293
|
}
|
|
18059
18294
|
function getRelativeRect(childHwnd, parentHwnd) {
|
|
18060
|
-
const pr =
|
|
18061
|
-
const cr =
|
|
18295
|
+
const pr = gui18.GetWindowRect(parentHwnd);
|
|
18296
|
+
const cr = gui18.GetWindowRect(childHwnd);
|
|
18062
18297
|
if (!pr || !cr)
|
|
18063
18298
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
18064
18299
|
return {
|
|
@@ -18175,7 +18410,7 @@ async function testRowCol(tester, root, rootHwnd, name, dir, parentW, parentH, c
|
|
|
18175
18410
|
}
|
|
18176
18411
|
async function main() {
|
|
18177
18412
|
const tester = new Tester();
|
|
18178
|
-
const hwnd =
|
|
18413
|
+
const hwnd = gui18.CreateWindow("FlexTest", "", 0, 0, 0, 800, 600, null, null);
|
|
18179
18414
|
if (!hwnd) {
|
|
18180
18415
|
tester.check("create root window", true, false);
|
|
18181
18416
|
tester.summary();
|
|
@@ -18309,7 +18544,7 @@ async function main() {
|
|
|
18309
18544
|
outer4 = childrenOf(hwnd);
|
|
18310
18545
|
checkDynamic(outer4, [175]);
|
|
18311
18546
|
tester.summary();
|
|
18312
|
-
|
|
18547
|
+
gui18.PostQuitMessage(0);
|
|
18313
18548
|
}
|
|
18314
18549
|
main();
|
|
18315
18550
|
/*! Bundled license information:
|