quickwin 1.2.0 → 1.2.1
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/examples/pdf_viewer.js +11 -10
- package/examples/test_gallery.js +11 -10
- package/examples/test_react_lazy.js +11 -10
- package/examples/test_react_listbox.js +11 -10
- package/examples/test_root_window.js +11 -10
- package/examples/test_tab.js +11 -10
- package/lib/fetch.js +35 -7
- package/lib/fetch.ts +24 -4
- package/lib/text-measure.js +8 -6
- package/lib/text-measure.ts +8 -6
- package/main.js +46 -0
- package/package.json +2 -1
- package/quickwin.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/run.js +1 -0
- package/test/run.ts +1 -0
- package/test/test_net_fetch.js +62 -0
- package/test/test_net_fetch.ts +72 -0
- package/test/test_react_complex.js +14 -13
- package/test/test_react_counter.js +11 -10
- package/test/test_react_flex.js +11 -10
- package/test/test_react_hidden.js +13 -12
- package/test/test_react_listview_link.js +11 -10
- package/test/test_react_render.js +11 -10
- package/test/test_wolfssl_read.js +201 -0
- package/test/test_wolfssl_read.ts +181 -0
package/examples/pdf_viewer.js
CHANGED
|
@@ -15370,7 +15370,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15370
15370
|
var import_react = __toESM(require_react(), 1);
|
|
15371
15371
|
var import_constants = __toESM(require_constants(), 1);
|
|
15372
15372
|
import * as gui3 from "gui";
|
|
15373
|
-
import * as
|
|
15373
|
+
import * as os2 from "os";
|
|
15374
15374
|
|
|
15375
15375
|
// _build/lib/react-qw/props.js
|
|
15376
15376
|
import * as gui from "gui";
|
|
@@ -15491,6 +15491,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15491
15491
|
|
|
15492
15492
|
// _build/lib/text-measure.js
|
|
15493
15493
|
import * as ffi from "ffi";
|
|
15494
|
+
import * as os from "os";
|
|
15494
15495
|
import * as win from "win";
|
|
15495
15496
|
import * as gui2 from "gui";
|
|
15496
15497
|
function loadProc(lib, name) {
|
|
@@ -15507,7 +15508,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15507
15508
|
var GetDC = loadProc(user32, "GetDC");
|
|
15508
15509
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15509
15510
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15510
|
-
var
|
|
15511
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15511
15512
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15512
15513
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15513
15514
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15515,14 +15516,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15515
15516
|
const rect = new ArrayBuffer(16);
|
|
15516
15517
|
const dv = new DataView(rect);
|
|
15517
15518
|
dv.setInt32(8, maxWidth, true);
|
|
15518
|
-
ffi.ffiCall(DrawTextW, [
|
|
15519
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15519
15520
|
hdc,
|
|
15520
15521
|
textBuf,
|
|
15521
15522
|
-1,
|
|
15522
15523
|
rect,
|
|
15523
15524
|
1024
|
|
15524
15525
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15525
|
-
],
|
|
15526
|
+
], FFI_S32);
|
|
15526
15527
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15527
15528
|
}
|
|
15528
15529
|
function getButtonIdealSize(hwnd) {
|
|
@@ -15532,15 +15533,15 @@ function getButtonIdealSize(hwnd) {
|
|
|
15532
15533
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15533
15534
|
}
|
|
15534
15535
|
function measureTextForHwnd(hwnd, text) {
|
|
15535
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15536
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd], FFI_HND);
|
|
15536
15537
|
if (!hdc)
|
|
15537
15538
|
return { width: 0, height: 0 };
|
|
15538
15539
|
const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
|
|
15539
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15540
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15540
15541
|
const result = measureText(hdc, text, 0);
|
|
15541
15542
|
if (hFont)
|
|
15542
|
-
ffi.ffiCall(SelectObject, [
|
|
15543
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15543
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15544
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd, hdc], FFI_S32);
|
|
15544
15545
|
const wr = gui2.GetWindowRect(hwnd);
|
|
15545
15546
|
const cr = gui2.GetClientRect(hwnd);
|
|
15546
15547
|
if (wr && cr) {
|
|
@@ -15853,10 +15854,10 @@ var hostConfig = {
|
|
|
15853
15854
|
clearContainer(_container) {
|
|
15854
15855
|
},
|
|
15855
15856
|
scheduleTimeout(fn, delay) {
|
|
15856
|
-
return
|
|
15857
|
+
return os2.setTimeout(fn, delay);
|
|
15857
15858
|
},
|
|
15858
15859
|
cancelTimeout(id) {
|
|
15859
|
-
|
|
15860
|
+
os2.clearTimeout?.(id);
|
|
15860
15861
|
},
|
|
15861
15862
|
noTimeout: -1,
|
|
15862
15863
|
supportsMutation: true,
|
package/examples/test_gallery.js
CHANGED
|
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15367
15367
|
var import_react = __toESM(require_react(), 1);
|
|
15368
15368
|
var import_constants = __toESM(require_constants(), 1);
|
|
15369
15369
|
import * as gui3 from "gui";
|
|
15370
|
-
import * as
|
|
15370
|
+
import * as os2 from "os";
|
|
15371
15371
|
|
|
15372
15372
|
// _build/lib/react-qw/props.js
|
|
15373
15373
|
import * as gui from "gui";
|
|
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15488
15488
|
|
|
15489
15489
|
// _build/lib/text-measure.js
|
|
15490
15490
|
import * as ffi from "ffi";
|
|
15491
|
+
import * as os from "os";
|
|
15491
15492
|
import * as win from "win";
|
|
15492
15493
|
import * as gui2 from "gui";
|
|
15493
15494
|
function loadProc(lib, name) {
|
|
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15504
15505
|
var GetDC = loadProc(user32, "GetDC");
|
|
15505
15506
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15506
15507
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15507
|
-
var
|
|
15508
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15508
15509
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15509
15510
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15510
15511
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15512
15513
|
const rect = new ArrayBuffer(16);
|
|
15513
15514
|
const dv = new DataView(rect);
|
|
15514
15515
|
dv.setInt32(8, maxWidth, true);
|
|
15515
|
-
ffi.ffiCall(DrawTextW, [
|
|
15516
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15516
15517
|
hdc,
|
|
15517
15518
|
textBuf,
|
|
15518
15519
|
-1,
|
|
15519
15520
|
rect,
|
|
15520
15521
|
1024
|
|
15521
15522
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15522
|
-
],
|
|
15523
|
+
], FFI_S32);
|
|
15523
15524
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15524
15525
|
}
|
|
15525
15526
|
function getButtonIdealSize(hwnd2) {
|
|
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd2) {
|
|
|
15529
15530
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15530
15531
|
}
|
|
15531
15532
|
function measureTextForHwnd(hwnd2, text) {
|
|
15532
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15533
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
|
|
15533
15534
|
if (!hdc)
|
|
15534
15535
|
return { width: 0, height: 0 };
|
|
15535
15536
|
const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
|
|
15536
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15537
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15537
15538
|
const result = measureText(hdc, text, 0);
|
|
15538
15539
|
if (hFont)
|
|
15539
|
-
ffi.ffiCall(SelectObject, [
|
|
15540
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15540
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15541
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
|
|
15541
15542
|
const wr = gui2.GetWindowRect(hwnd2);
|
|
15542
15543
|
const cr = gui2.GetClientRect(hwnd2);
|
|
15543
15544
|
if (wr && cr) {
|
|
@@ -15850,10 +15851,10 @@ var hostConfig = {
|
|
|
15850
15851
|
clearContainer(_container) {
|
|
15851
15852
|
},
|
|
15852
15853
|
scheduleTimeout(fn, delay) {
|
|
15853
|
-
return
|
|
15854
|
+
return os2.setTimeout(fn, delay);
|
|
15854
15855
|
},
|
|
15855
15856
|
cancelTimeout(id) {
|
|
15856
|
-
|
|
15857
|
+
os2.clearTimeout?.(id);
|
|
15857
15858
|
},
|
|
15858
15859
|
noTimeout: -1,
|
|
15859
15860
|
supportsMutation: true,
|
|
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15367
15367
|
var import_react = __toESM(require_react(), 1);
|
|
15368
15368
|
var import_constants = __toESM(require_constants(), 1);
|
|
15369
15369
|
import * as gui3 from "gui";
|
|
15370
|
-
import * as
|
|
15370
|
+
import * as os2 from "os";
|
|
15371
15371
|
|
|
15372
15372
|
// _build/lib/react-qw/props.js
|
|
15373
15373
|
import * as gui from "gui";
|
|
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15488
15488
|
|
|
15489
15489
|
// _build/lib/text-measure.js
|
|
15490
15490
|
import * as ffi from "ffi";
|
|
15491
|
+
import * as os from "os";
|
|
15491
15492
|
import * as win from "win";
|
|
15492
15493
|
import * as gui2 from "gui";
|
|
15493
15494
|
function loadProc(lib, name) {
|
|
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15504
15505
|
var GetDC = loadProc(user32, "GetDC");
|
|
15505
15506
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15506
15507
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15507
|
-
var
|
|
15508
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15508
15509
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15509
15510
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15510
15511
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15512
15513
|
const rect = new ArrayBuffer(16);
|
|
15513
15514
|
const dv = new DataView(rect);
|
|
15514
15515
|
dv.setInt32(8, maxWidth, true);
|
|
15515
|
-
ffi.ffiCall(DrawTextW, [
|
|
15516
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15516
15517
|
hdc,
|
|
15517
15518
|
textBuf,
|
|
15518
15519
|
-1,
|
|
15519
15520
|
rect,
|
|
15520
15521
|
1024
|
|
15521
15522
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15522
|
-
],
|
|
15523
|
+
], FFI_S32);
|
|
15523
15524
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15524
15525
|
}
|
|
15525
15526
|
function getButtonIdealSize(hwnd2) {
|
|
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd2) {
|
|
|
15529
15530
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15530
15531
|
}
|
|
15531
15532
|
function measureTextForHwnd(hwnd2, text) {
|
|
15532
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15533
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
|
|
15533
15534
|
if (!hdc)
|
|
15534
15535
|
return { width: 0, height: 0 };
|
|
15535
15536
|
const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
|
|
15536
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15537
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15537
15538
|
const result = measureText(hdc, text, 0);
|
|
15538
15539
|
if (hFont)
|
|
15539
|
-
ffi.ffiCall(SelectObject, [
|
|
15540
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15540
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15541
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
|
|
15541
15542
|
const wr = gui2.GetWindowRect(hwnd2);
|
|
15542
15543
|
const cr = gui2.GetClientRect(hwnd2);
|
|
15543
15544
|
if (wr && cr) {
|
|
@@ -15850,10 +15851,10 @@ var hostConfig = {
|
|
|
15850
15851
|
clearContainer(_container) {
|
|
15851
15852
|
},
|
|
15852
15853
|
scheduleTimeout(fn, delay) {
|
|
15853
|
-
return
|
|
15854
|
+
return os2.setTimeout(fn, delay);
|
|
15854
15855
|
},
|
|
15855
15856
|
cancelTimeout(id) {
|
|
15856
|
-
|
|
15857
|
+
os2.clearTimeout?.(id);
|
|
15857
15858
|
},
|
|
15858
15859
|
noTimeout: -1,
|
|
15859
15860
|
supportsMutation: true,
|
|
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15367
15367
|
var import_react = __toESM(require_react(), 1);
|
|
15368
15368
|
var import_constants = __toESM(require_constants(), 1);
|
|
15369
15369
|
import * as gui3 from "gui";
|
|
15370
|
-
import * as
|
|
15370
|
+
import * as os2 from "os";
|
|
15371
15371
|
|
|
15372
15372
|
// _build/lib/react-qw/props.js
|
|
15373
15373
|
import * as gui from "gui";
|
|
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15488
15488
|
|
|
15489
15489
|
// _build/lib/text-measure.js
|
|
15490
15490
|
import * as ffi from "ffi";
|
|
15491
|
+
import * as os from "os";
|
|
15491
15492
|
import * as win from "win";
|
|
15492
15493
|
import * as gui2 from "gui";
|
|
15493
15494
|
function loadProc(lib, name) {
|
|
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15504
15505
|
var GetDC = loadProc(user32, "GetDC");
|
|
15505
15506
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15506
15507
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15507
|
-
var
|
|
15508
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15508
15509
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15509
15510
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15510
15511
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15512
15513
|
const rect = new ArrayBuffer(16);
|
|
15513
15514
|
const dv = new DataView(rect);
|
|
15514
15515
|
dv.setInt32(8, maxWidth, true);
|
|
15515
|
-
ffi.ffiCall(DrawTextW, [
|
|
15516
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15516
15517
|
hdc,
|
|
15517
15518
|
textBuf,
|
|
15518
15519
|
-1,
|
|
15519
15520
|
rect,
|
|
15520
15521
|
1024
|
|
15521
15522
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15522
|
-
],
|
|
15523
|
+
], FFI_S32);
|
|
15523
15524
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15524
15525
|
}
|
|
15525
15526
|
function getButtonIdealSize(hwnd2) {
|
|
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd2) {
|
|
|
15529
15530
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15530
15531
|
}
|
|
15531
15532
|
function measureTextForHwnd(hwnd2, text) {
|
|
15532
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15533
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
|
|
15533
15534
|
if (!hdc)
|
|
15534
15535
|
return { width: 0, height: 0 };
|
|
15535
15536
|
const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
|
|
15536
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15537
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15537
15538
|
const result = measureText(hdc, text, 0);
|
|
15538
15539
|
if (hFont)
|
|
15539
|
-
ffi.ffiCall(SelectObject, [
|
|
15540
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15540
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15541
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
|
|
15541
15542
|
const wr = gui2.GetWindowRect(hwnd2);
|
|
15542
15543
|
const cr = gui2.GetClientRect(hwnd2);
|
|
15543
15544
|
if (wr && cr) {
|
|
@@ -15850,10 +15851,10 @@ var hostConfig = {
|
|
|
15850
15851
|
clearContainer(_container) {
|
|
15851
15852
|
},
|
|
15852
15853
|
scheduleTimeout(fn, delay) {
|
|
15853
|
-
return
|
|
15854
|
+
return os2.setTimeout(fn, delay);
|
|
15854
15855
|
},
|
|
15855
15856
|
cancelTimeout(id) {
|
|
15856
|
-
|
|
15857
|
+
os2.clearTimeout?.(id);
|
|
15857
15858
|
},
|
|
15858
15859
|
noTimeout: -1,
|
|
15859
15860
|
supportsMutation: true,
|
|
@@ -15366,7 +15366,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15366
15366
|
var import_react = __toESM(require_react(), 1);
|
|
15367
15367
|
var import_constants = __toESM(require_constants(), 1);
|
|
15368
15368
|
import * as gui3 from "gui";
|
|
15369
|
-
import * as
|
|
15369
|
+
import * as os2 from "os";
|
|
15370
15370
|
|
|
15371
15371
|
// _build/lib/react-qw/props.js
|
|
15372
15372
|
import * as gui from "gui";
|
|
@@ -15487,6 +15487,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15487
15487
|
|
|
15488
15488
|
// _build/lib/text-measure.js
|
|
15489
15489
|
import * as ffi from "ffi";
|
|
15490
|
+
import * as os from "os";
|
|
15490
15491
|
import * as win from "win";
|
|
15491
15492
|
import * as gui2 from "gui";
|
|
15492
15493
|
function loadProc(lib, name) {
|
|
@@ -15503,7 +15504,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15503
15504
|
var GetDC = loadProc(user32, "GetDC");
|
|
15504
15505
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15505
15506
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15506
|
-
var
|
|
15507
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15507
15508
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15508
15509
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15509
15510
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15511,14 +15512,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15511
15512
|
const rect = new ArrayBuffer(16);
|
|
15512
15513
|
const dv = new DataView(rect);
|
|
15513
15514
|
dv.setInt32(8, maxWidth, true);
|
|
15514
|
-
ffi.ffiCall(DrawTextW, [
|
|
15515
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15515
15516
|
hdc,
|
|
15516
15517
|
textBuf,
|
|
15517
15518
|
-1,
|
|
15518
15519
|
rect,
|
|
15519
15520
|
1024
|
|
15520
15521
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15521
|
-
],
|
|
15522
|
+
], FFI_S32);
|
|
15522
15523
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15523
15524
|
}
|
|
15524
15525
|
function getButtonIdealSize(hwnd) {
|
|
@@ -15528,15 +15529,15 @@ function getButtonIdealSize(hwnd) {
|
|
|
15528
15529
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15529
15530
|
}
|
|
15530
15531
|
function measureTextForHwnd(hwnd, text) {
|
|
15531
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15532
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd], FFI_HND);
|
|
15532
15533
|
if (!hdc)
|
|
15533
15534
|
return { width: 0, height: 0 };
|
|
15534
15535
|
const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
|
|
15535
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15536
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15536
15537
|
const result = measureText(hdc, text, 0);
|
|
15537
15538
|
if (hFont)
|
|
15538
|
-
ffi.ffiCall(SelectObject, [
|
|
15539
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15539
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15540
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd, hdc], FFI_S32);
|
|
15540
15541
|
const wr = gui2.GetWindowRect(hwnd);
|
|
15541
15542
|
const cr = gui2.GetClientRect(hwnd);
|
|
15542
15543
|
if (wr && cr) {
|
|
@@ -15849,10 +15850,10 @@ var hostConfig = {
|
|
|
15849
15850
|
clearContainer(_container) {
|
|
15850
15851
|
},
|
|
15851
15852
|
scheduleTimeout(fn, delay) {
|
|
15852
|
-
return
|
|
15853
|
+
return os2.setTimeout(fn, delay);
|
|
15853
15854
|
},
|
|
15854
15855
|
cancelTimeout(id) {
|
|
15855
|
-
|
|
15856
|
+
os2.clearTimeout?.(id);
|
|
15856
15857
|
},
|
|
15857
15858
|
noTimeout: -1,
|
|
15858
15859
|
supportsMutation: true,
|
package/examples/test_tab.js
CHANGED
|
@@ -15367,7 +15367,7 @@ var import_react_reconciler = __toESM(require_react_reconciler(), 1);
|
|
|
15367
15367
|
var import_react = __toESM(require_react(), 1);
|
|
15368
15368
|
var import_constants = __toESM(require_constants(), 1);
|
|
15369
15369
|
import * as gui3 from "gui";
|
|
15370
|
-
import * as
|
|
15370
|
+
import * as os2 from "os";
|
|
15371
15371
|
|
|
15372
15372
|
// _build/lib/react-qw/props.js
|
|
15373
15373
|
import * as gui from "gui";
|
|
@@ -15488,6 +15488,7 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15488
15488
|
|
|
15489
15489
|
// _build/lib/text-measure.js
|
|
15490
15490
|
import * as ffi from "ffi";
|
|
15491
|
+
import * as os from "os";
|
|
15491
15492
|
import * as win from "win";
|
|
15492
15493
|
import * as gui2 from "gui";
|
|
15493
15494
|
function loadProc(lib, name) {
|
|
@@ -15504,7 +15505,7 @@ var DrawTextW = loadProc(user32, "DrawTextW");
|
|
|
15504
15505
|
var GetDC = loadProc(user32, "GetDC");
|
|
15505
15506
|
var ReleaseDC = loadProc(user32, "ReleaseDC");
|
|
15506
15507
|
var SelectObject = loadProc(gdi32, "SelectObject");
|
|
15507
|
-
var
|
|
15508
|
+
var FFI_HND = os.arch === "ia32" ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
15508
15509
|
var FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
15509
15510
|
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15510
15511
|
function measureText(hdc, text, maxWidth) {
|
|
@@ -15512,14 +15513,14 @@ function measureText(hdc, text, maxWidth) {
|
|
|
15512
15513
|
const rect = new ArrayBuffer(16);
|
|
15513
15514
|
const dv = new DataView(rect);
|
|
15514
15515
|
dv.setInt32(8, maxWidth, true);
|
|
15515
|
-
ffi.ffiCall(DrawTextW, [
|
|
15516
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [
|
|
15516
15517
|
hdc,
|
|
15517
15518
|
textBuf,
|
|
15518
15519
|
-1,
|
|
15519
15520
|
rect,
|
|
15520
15521
|
1024
|
|
15521
15522
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15522
|
-
],
|
|
15523
|
+
], FFI_S32);
|
|
15523
15524
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15524
15525
|
}
|
|
15525
15526
|
function getButtonIdealSize(hwnd2) {
|
|
@@ -15529,15 +15530,15 @@ function getButtonIdealSize(hwnd2) {
|
|
|
15529
15530
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15530
15531
|
}
|
|
15531
15532
|
function measureTextForHwnd(hwnd2, text) {
|
|
15532
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
15533
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd2], FFI_HND);
|
|
15533
15534
|
if (!hdc)
|
|
15534
15535
|
return { width: 0, height: 0 };
|
|
15535
15536
|
const hFont = gui2.SendMessage(hwnd2, 49, 0, 0);
|
|
15536
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
15537
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
15537
15538
|
const result = measureText(hdc, text, 0);
|
|
15538
15539
|
if (hFont)
|
|
15539
|
-
ffi.ffiCall(SelectObject, [
|
|
15540
|
-
ffi.ffiCall(ReleaseDC, [
|
|
15540
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
15541
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd2, hdc], FFI_S32);
|
|
15541
15542
|
const wr = gui2.GetWindowRect(hwnd2);
|
|
15542
15543
|
const cr = gui2.GetClientRect(hwnd2);
|
|
15543
15544
|
if (wr && cr) {
|
|
@@ -15850,10 +15851,10 @@ var hostConfig = {
|
|
|
15850
15851
|
clearContainer(_container) {
|
|
15851
15852
|
},
|
|
15852
15853
|
scheduleTimeout(fn, delay) {
|
|
15853
|
-
return
|
|
15854
|
+
return os2.setTimeout(fn, delay);
|
|
15854
15855
|
},
|
|
15855
15856
|
cancelTimeout(id) {
|
|
15856
|
-
|
|
15857
|
+
os2.clearTimeout?.(id);
|
|
15857
15858
|
},
|
|
15858
15859
|
noTimeout: -1,
|
|
15859
15860
|
supportsMutation: true,
|
package/lib/fetch.js
CHANGED
|
@@ -81,6 +81,10 @@ async function fetchRequest(req) {
|
|
|
81
81
|
let receivedBytes = 0;
|
|
82
82
|
const cleanupSocket = () => {
|
|
83
83
|
state = ST_DONE;
|
|
84
|
+
if (timerId) {
|
|
85
|
+
clearTimeout(timerId);
|
|
86
|
+
timerId = undefined;
|
|
87
|
+
}
|
|
84
88
|
if (ssl) {
|
|
85
89
|
wolfssl.wolfSSL_free(ssl);
|
|
86
90
|
ssl = null;
|
|
@@ -100,12 +104,38 @@ async function fetchRequest(req) {
|
|
|
100
104
|
timerId = undefined;
|
|
101
105
|
}
|
|
102
106
|
};
|
|
107
|
+
const armTimeout = () => {
|
|
108
|
+
if (timerId) {
|
|
109
|
+
clearTimeout(timerId);
|
|
110
|
+
timerId = undefined;
|
|
111
|
+
}
|
|
112
|
+
timerId = setTimeout(() => {
|
|
113
|
+
timerId = undefined;
|
|
114
|
+
if (state === ST_DONE)
|
|
115
|
+
return;
|
|
116
|
+
if (!resolved) {
|
|
117
|
+
doReject(new Error('Request timeout'));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (state === ST_RECV_BODY && stream && _controller) {
|
|
121
|
+
try {
|
|
122
|
+
_controller.error(new Error('Body timeout'));
|
|
123
|
+
}
|
|
124
|
+
catch { /* already closed */ }
|
|
125
|
+
stream = null;
|
|
126
|
+
cleanupSocket();
|
|
127
|
+
}
|
|
128
|
+
}, timeout);
|
|
129
|
+
};
|
|
103
130
|
const doResolve = (response) => {
|
|
104
|
-
if (
|
|
105
|
-
|
|
131
|
+
if (resolved)
|
|
132
|
+
return;
|
|
133
|
+
resolved = true;
|
|
134
|
+
if (state === ST_DONE)
|
|
106
135
|
cleanup();
|
|
107
|
-
|
|
108
|
-
|
|
136
|
+
else
|
|
137
|
+
armTimeout();
|
|
138
|
+
resolve(response);
|
|
109
139
|
};
|
|
110
140
|
const doReject = (error) => {
|
|
111
141
|
if (!resolved) {
|
|
@@ -115,9 +145,7 @@ async function fetchRequest(req) {
|
|
|
115
145
|
reject(error);
|
|
116
146
|
}
|
|
117
147
|
};
|
|
118
|
-
|
|
119
|
-
doReject(new Error('Request timeout'));
|
|
120
|
-
}, timeout);
|
|
148
|
+
armTimeout();
|
|
121
149
|
s = sock.socket();
|
|
122
150
|
if (s < 0) {
|
|
123
151
|
doReject(new Error('Failed to create socket'));
|
package/lib/fetch.ts
CHANGED
|
@@ -107,6 +107,7 @@ async function fetchRequest(req: RequestImpl): Promise<ResponseImpl> {
|
|
|
107
107
|
|
|
108
108
|
const cleanupSocket = (): void => {
|
|
109
109
|
state = ST_DONE
|
|
110
|
+
if (timerId) { clearTimeout(timerId); timerId = undefined }
|
|
110
111
|
if (ssl) { wolfssl.wolfSSL_free(ssl); ssl = null }
|
|
111
112
|
if (ctx) { wolfssl.wolfSSL_CTX_free(ctx); ctx = null }
|
|
112
113
|
if (s !== null && s >= 0) { sock.closesocket(s); s = null }
|
|
@@ -116,17 +117,36 @@ async function fetchRequest(req: RequestImpl): Promise<ResponseImpl> {
|
|
|
116
117
|
if (timerId) { clearTimeout(timerId); timerId = undefined }
|
|
117
118
|
}
|
|
118
119
|
|
|
120
|
+
const armTimeout = (): void => {
|
|
121
|
+
if (timerId) { clearTimeout(timerId); timerId = undefined }
|
|
122
|
+
timerId = setTimeout(() => {
|
|
123
|
+
timerId = undefined
|
|
124
|
+
if (state === ST_DONE) return
|
|
125
|
+
if (!resolved) {
|
|
126
|
+
doReject(new Error('Request timeout'))
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
if (state === ST_RECV_BODY && stream && _controller) {
|
|
130
|
+
try { _controller.error(new Error('Body timeout')) } catch { /* already closed */ }
|
|
131
|
+
stream = null
|
|
132
|
+
cleanupSocket()
|
|
133
|
+
}
|
|
134
|
+
}, timeout)
|
|
135
|
+
}
|
|
136
|
+
|
|
119
137
|
const doResolve = (response: ResponseImpl): void => {
|
|
120
|
-
if (
|
|
138
|
+
if (resolved) return
|
|
139
|
+
resolved = true
|
|
140
|
+
if (state === ST_DONE) cleanup()
|
|
141
|
+
else armTimeout()
|
|
142
|
+
resolve(response)
|
|
121
143
|
}
|
|
122
144
|
|
|
123
145
|
const doReject = (error: Error): void => {
|
|
124
146
|
if (!resolved) { resolved = true; cleanup(); cleanupSocket(); reject(error) }
|
|
125
147
|
}
|
|
126
148
|
|
|
127
|
-
|
|
128
|
-
doReject(new Error('Request timeout'))
|
|
129
|
-
}, timeout)
|
|
149
|
+
armTimeout()
|
|
130
150
|
|
|
131
151
|
s = sock.socket()
|
|
132
152
|
if (s < 0) { doReject(new Error('Failed to create socket')); return }
|
package/lib/text-measure.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ffi from 'ffi';
|
|
2
|
+
import * as os from 'os';
|
|
2
3
|
import * as win from 'win';
|
|
3
4
|
import * as gui from 'gui';
|
|
4
5
|
function loadProc(lib, name) {
|
|
@@ -15,7 +16,8 @@ const DrawTextW = loadProc(user32, 'DrawTextW');
|
|
|
15
16
|
const GetDC = loadProc(user32, 'GetDC');
|
|
16
17
|
const ReleaseDC = loadProc(user32, 'ReleaseDC');
|
|
17
18
|
const SelectObject = loadProc(gdi32, 'SelectObject');
|
|
18
|
-
|
|
19
|
+
// 句柄宽度随架构:ia32 上 HDC/HWND 是 32-bit,错用 UINT64 会导致 DrawTextW 参数错位、测宽为 0
|
|
20
|
+
const FFI_HND = os.arch === 'ia32' ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64;
|
|
19
21
|
const FFI_S32 = ffi.FFI_TYPE_SINT32;
|
|
20
22
|
const FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
21
23
|
export function measureText(hdc, text, maxWidth) {
|
|
@@ -23,7 +25,7 @@ export function measureText(hdc, text, maxWidth) {
|
|
|
23
25
|
const rect = new ArrayBuffer(16);
|
|
24
26
|
const dv = new DataView(rect);
|
|
25
27
|
dv.setInt32(8, maxWidth, true);
|
|
26
|
-
ffi.ffiCall(DrawTextW, [
|
|
28
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [hdc, textBuf, -1, rect, 1024 /* gui.DrawTextFlag.CALCRECT */], FFI_S32);
|
|
27
29
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
28
30
|
}
|
|
29
31
|
export function getButtonIdealSize(hwnd) {
|
|
@@ -33,15 +35,15 @@ export function getButtonIdealSize(hwnd) {
|
|
|
33
35
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
34
36
|
}
|
|
35
37
|
export function measureTextForHwnd(hwnd, text) {
|
|
36
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
38
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd], FFI_HND);
|
|
37
39
|
if (!hdc)
|
|
38
40
|
return { width: 0, height: 0 };
|
|
39
41
|
const hFont = gui.SendMessage(hwnd, 49 /* gui.WmMsg.GETFONT */, 0, 0);
|
|
40
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
42
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0;
|
|
41
43
|
const result = measureText(hdc, text, 0);
|
|
42
44
|
if (hFont)
|
|
43
|
-
ffi.ffiCall(SelectObject, [
|
|
44
|
-
ffi.ffiCall(ReleaseDC, [
|
|
45
|
+
ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND);
|
|
46
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd, hdc], FFI_S32);
|
|
45
47
|
const wr = gui.GetWindowRect(hwnd);
|
|
46
48
|
const cr = gui.GetClientRect(hwnd);
|
|
47
49
|
if (wr && cr) {
|
package/lib/text-measure.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ffi from 'ffi'
|
|
2
|
+
import * as os from 'os'
|
|
2
3
|
import * as win from 'win'
|
|
3
4
|
import * as gui from 'gui'
|
|
4
5
|
|
|
@@ -16,7 +17,8 @@ const GetDC = loadProc(user32, 'GetDC')
|
|
|
16
17
|
const ReleaseDC = loadProc(user32, 'ReleaseDC')
|
|
17
18
|
const SelectObject = loadProc(gdi32, 'SelectObject')
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
// 句柄宽度随架构:ia32 上 HDC/HWND 是 32-bit,错用 UINT64 会导致 DrawTextW 参数错位、测宽为 0
|
|
21
|
+
const FFI_HND = os.arch === 'ia32' ? ffi.FFI_TYPE_UINT32 : ffi.FFI_TYPE_UINT64
|
|
20
22
|
const FFI_S32 = ffi.FFI_TYPE_SINT32
|
|
21
23
|
const FFI_PTR = ffi.FFI_TYPE_POINTER
|
|
22
24
|
|
|
@@ -25,7 +27,7 @@ export function measureText(hdc: number, text: string, maxWidth: number): { widt
|
|
|
25
27
|
const rect = new ArrayBuffer(16)
|
|
26
28
|
const dv = new DataView(rect)
|
|
27
29
|
dv.setInt32(8, maxWidth, true)
|
|
28
|
-
ffi.ffiCall(DrawTextW, [
|
|
30
|
+
ffi.ffiCall(DrawTextW, [FFI_HND, FFI_PTR, FFI_S32, FFI_PTR, FFI_S32], [hdc, textBuf, -1, rect, gui.DrawTextFlag.CALCRECT], FFI_S32)
|
|
29
31
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) }
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -37,13 +39,13 @@ export function getButtonIdealSize(hwnd: gui.HWND): { width: number; height: num
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export function measureTextForHwnd(hwnd: gui.HWND, text: string): { width: number; height: number } {
|
|
40
|
-
const hdc = ffi.ffiCall(GetDC, [
|
|
42
|
+
const hdc = ffi.ffiCall(GetDC, [FFI_HND], [hwnd], FFI_HND)
|
|
41
43
|
if (!hdc) return { width: 0, height: 0 }
|
|
42
44
|
const hFont = gui.SendMessage(hwnd, gui.WmMsg.GETFONT, 0, 0)
|
|
43
|
-
const oldFont = hFont ? ffi.ffiCall(SelectObject, [
|
|
45
|
+
const oldFont = hFont ? ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, hFont], FFI_HND) : 0
|
|
44
46
|
const result = measureText(hdc, text, 0)
|
|
45
|
-
if (hFont) ffi.ffiCall(SelectObject, [
|
|
46
|
-
ffi.ffiCall(ReleaseDC, [
|
|
47
|
+
if (hFont) ffi.ffiCall(SelectObject, [FFI_HND, FFI_HND], [hdc, oldFont], FFI_HND)
|
|
48
|
+
ffi.ffiCall(ReleaseDC, [FFI_HND, FFI_HND], [hwnd, hdc], FFI_S32)
|
|
47
49
|
const wr = gui.GetWindowRect(hwnd)
|
|
48
50
|
const cr = gui.GetClientRect(hwnd)
|
|
49
51
|
if (wr && cr) {
|