quickwin 2.1.1 → 2.3.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.
Files changed (117) hide show
  1. package/README.en.md +9 -9
  2. package/README.md +9 -9
  3. package/constants.ts +1063 -0
  4. package/enum_map.d.ts +129 -0
  5. package/examples/PdfCanvas.js +2 -2
  6. package/examples/PdfCanvas.tsx +3 -2
  7. package/examples/{exec_server.js → execd/main.js} +1114 -287
  8. package/examples/execd/tray.js +192 -0
  9. package/examples/execd/worker.js +122 -0
  10. package/examples/pdf_preview2.js +46 -46
  11. package/examples/pdf_preview2.ts +55 -54
  12. package/examples/pdf_viewer.js +134 -130
  13. package/examples/pdf_viewer.tsx +6 -5
  14. package/examples/test_gallery.js +135 -131
  15. package/examples/test_gallery.tsx +9 -8
  16. package/examples/test_react_lazy.js +130 -128
  17. package/examples/test_react_lazy.tsx +7 -6
  18. package/examples/test_react_listbox.js +130 -128
  19. package/examples/test_react_listbox.tsx +8 -7
  20. package/examples/test_root_window.js +130 -128
  21. package/examples/test_root_window.tsx +5 -5
  22. package/examples/test_tab.js +130 -128
  23. package/examples/test_tab.tsx +7 -6
  24. package/examples/tray_demo.js +8 -8
  25. package/examples/tray_demo.tsx +9 -8
  26. package/lib/dumpRects.js +2 -2
  27. package/lib/dumpRects.ts +3 -2
  28. package/lib/fetch.js +15 -15
  29. package/lib/fetch.ts +16 -15
  30. package/lib/ffi/bind.js +3 -3
  31. package/lib/ffi/bind.ts +3 -3
  32. package/lib/ffi/ctype.ts +3 -1
  33. package/lib/ffi/struct.js +23 -7
  34. package/lib/ffi/struct.ts +50 -23
  35. package/lib/http-server.js +5 -5
  36. package/lib/http-server.ts +6 -5
  37. package/lib/react-qw/components/Button.js +2 -2
  38. package/lib/react-qw/components/CheckBox.js +4 -4
  39. package/lib/react-qw/components/ComboBox.js +10 -10
  40. package/lib/react-qw/components/DateTimePicker.js +12 -12
  41. package/lib/react-qw/components/Input.js +7 -7
  42. package/lib/react-qw/components/Link.js +4 -4
  43. package/lib/react-qw/components/ListBox.js +12 -12
  44. package/lib/react-qw/components/ListView.js +35 -35
  45. package/lib/react-qw/components/PathPicker.js +3 -3
  46. package/lib/react-qw/components/ProgressBar.js +4 -4
  47. package/lib/react-qw/components/RadioButton.js +4 -4
  48. package/lib/react-qw/components/ScrollView.js +28 -28
  49. package/lib/react-qw/components/Slider.js +11 -11
  50. package/lib/react-qw/components/Tab.js +10 -10
  51. package/lib/react-qw/components/Tooltip.js +8 -8
  52. package/lib/react-qw/components/TreeView.js +20 -20
  53. package/lib/react-qw/index.js +5 -5
  54. package/lib/react-qw/index.ts +6 -5
  55. package/lib/react-qw/props.js +4 -4
  56. package/lib/react-qw/props.ts +5 -4
  57. package/lib/react-qw/reconciler.js +10 -10
  58. package/lib/react-qw/reconciler.ts +11 -10
  59. package/lib/text-measure.js +3 -3
  60. package/lib/text-measure.ts +4 -3
  61. package/lib/websocket.js +17 -17
  62. package/lib/websocket.ts +18 -17
  63. package/lib/windows/advapi32.js +7 -7
  64. package/lib/windows/advapi32.ts +7 -7
  65. package/lib/windows/gdi32.js +17 -17
  66. package/lib/windows/gdi32.ts +17 -17
  67. package/lib/windows/kernel32.js +41 -2
  68. package/lib/windows/kernel32.ts +45 -2
  69. package/lib/windows/shell32.js +24 -3
  70. package/lib/windows/shell32.ts +27 -4
  71. package/lib/windows/structs.js +230 -92
  72. package/lib/windows/structs.ts +278 -92
  73. package/lib/windows/user32.js +18 -6
  74. package/lib/windows/user32.ts +18 -6
  75. package/lib/windows/winspool.js +3 -3
  76. package/lib/windows/winspool.ts +3 -3
  77. package/package.json +4 -3
  78. package/quickwin.d.ts +32 -10
  79. package/qwin-nowasm-x86.exe +0 -0
  80. package/qwin-nowasm.exe +0 -0
  81. package/qwin-x86.exe +0 -0
  82. package/qwin.exe +0 -0
  83. package/test/test_ffi_bind.js +12 -10
  84. package/test/test_ffi_bind.ts +14 -12
  85. package/test/test_ffi_struct.js +60 -26
  86. package/test/test_ffi_struct.ts +58 -28
  87. package/test/test_ffi_windows.js +1 -1
  88. package/test/test_ffi_windows.ts +1 -1
  89. package/test/test_files.js +7 -7
  90. package/test/test_files.ts +8 -8
  91. package/test/test_gdi_draw.js +51 -51
  92. package/test/test_gdi_draw.ts +57 -57
  93. package/test/test_http_server.js +3 -3
  94. package/test/test_http_server.ts +4 -3
  95. package/test/test_ipv6.js +3 -3
  96. package/test/test_ipv6.ts +4 -3
  97. package/test/test_net_event.js +3 -3
  98. package/test/test_net_event.ts +4 -3
  99. package/test/test_printer.js +4 -4
  100. package/test/test_printer.ts +5 -5
  101. package/test/test_react_complex.js +132 -130
  102. package/test/test_react_counter.js +130 -128
  103. package/test/test_react_flex.js +132 -130
  104. package/test/test_react_hidden.js +130 -128
  105. package/test/test_react_listview_link.js +131 -129
  106. package/test/test_react_notify.js +148 -146
  107. package/test/test_react_render.js +130 -128
  108. package/test/test_registry.js +6 -6
  109. package/test/test_registry.ts +8 -8
  110. package/test/test_wolfssl_read.js +8 -8
  111. package/test/test_wolfssl_read.ts +9 -8
  112. package/examples/exec_server.tsx +0 -488
  113. package/examples/exec_server_worker.js +0 -395
  114. package/examples/exec_server_worker.ts +0 -417
  115. package/examples/setres.js +0 -79
  116. package/examples/setres.ts +0 -86
  117. package/quickwin_const.d.ts +0 -1037
@@ -1,4 +1,4 @@
1
- // user32.dll 精选高频 API(85 个),逐函数独立导出:
1
+ // user32.dll 精选高频 API(99 个),逐函数独立导出:
2
2
  // - 签名对照 mingw winuser.h 原型手写;未被 import 的绑定经 esbuild 摇树不进产物
3
3
  // - WPARAM / LPARAM / LRESULT / UINT_PTR / LONG_PTR 及句柄混合值一律 <>ptr(指针宽度跨
4
4
  // 架构正确;返回值 0 保真(C→JS 不做 0→null)、有符号读对齐 C 版 JS_NewInt64——-1 哨兵等负值保真)
@@ -24,8 +24,9 @@
24
24
  // <HGLOBAL>ptr 自产自收)
25
25
  import * as os from 'os';
26
26
  import { bind } from '../ffi/bind.js';
27
+ import { structArray } from '../ffi/struct.js';
27
28
  // 只 import 注册了 encoder 的结构(纯入参位);POINT 等出/就地位不注册,运行时无需引用
28
- import { MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js';
29
+ import { INPUT, MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js';
29
30
  // dll 名部分应用:85 个绑定共用,签名字符串不再重复 'user32.dll'。
30
31
  // 不能用 bind.bind(null, dll)——泛型在部分应用点坍缩(返回 never);工厂转调让
31
32
  // S/LE/LD 在调用点正常 infer。第三参透传 encoders(结构入参位注册,见头注释方向约定)。
@@ -43,7 +44,7 @@ const LONG_PTR_SYM = os.arch === 'x64' ? 'PtrW' : 'W';
43
44
  * @param args_0 dwExStyle WS_EX_*
44
45
  * @param args_1 lpClassName 窗口类名 string 或 NULL
45
46
  * @param args_2 lpWindowName 窗口标题 string 或 NULL
46
- * @param args_3 dwStyle WS_*(gui.WindowStyle 类常量)
47
+ * @param args_3 dwStyle WS_*(WindowStyle 类常量)
47
48
  * @param args_4 x 初始左上角(CW_USEDEFAULT = -1)
48
49
  * @param args_5 y 初始左上角(CW_USEDEFAULT = -1)
49
50
  * @param args_6 nWidth
@@ -57,7 +58,7 @@ export const CreateWindowEx = /*@__PURE__*/ b('CreateWindowExW', 'u32 <WCHAR>ptr
57
58
  * @returns 成功 → 非 0
58
59
  * @param args_0 hWnd */
59
60
  export const DestroyWindow = /*@__PURE__*/ b('DestroyWindow', '<HWND>ptr -> i32');
60
- /** 显示/隐藏窗口(nCmdShow = gui.WindowStyle 类常量)
61
+ /** 显示/隐藏窗口(nCmdShow = WindowStyle 类常量)
61
62
  * @returns 先前可见性
62
63
  * @param args_0 hWnd
63
64
  * @param args_1 nCmdShow 显示命令(SW_SHOW/SW_HIDE 等) */
@@ -300,7 +301,7 @@ export const EndPaint = /*@__PURE__*/ b('EndPaint', '<HWND>ptr <PAINTSTRUCT>ptr
300
301
  * @param args_1 lpchText 文本 string(自动 UTF-16 编码)
301
302
  * @param args_2 cchText 字符数(-1 = 自动算到 NUL)
302
303
  * @param args_3 lpRect 矩形(双向不注册 encoder;CALCRECT 就地写回:RECT.encode(初值) 传 .ptr、decode 读回)
303
- * @param args_4 uFormat DT_* 排版标志(gui.DrawTextFlag) */
304
+ * @param args_4 uFormat DT_* 排版标志(DrawTextFlag) */
304
305
  export const DrawText = /*@__PURE__*/ b('DrawTextW', '<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32');
305
306
  /** 用画刷填充矩形
306
307
  * @returns 填充高度
@@ -394,6 +395,17 @@ export const GetKeyboardState = /*@__PURE__*/ b('GetKeyboardState', '<BYTE>ptr -
394
395
  * @returns SHORT(低字节 VK、高位 shift/ctrl/alt 掩码),无 → -1
395
396
  * @param args_0 ch 字符码(如 65 = 'A') */
396
397
  export const VkKeyScan = /*@__PURE__*/ b('VkKeyScanW', 'u32 -> i32');
398
+ // INPUT 数组 encoder(SendInput 的 <INPUT>ptr 位注册后值域即元素数组——与 gdi32
399
+ // POINTArr 同机制,token/引擎层零数组概念)
400
+ const INPUTArr = /*@__PURE__*/ structArray(INPUT);
401
+ /** 批量注入输入事件(一次调用 = cInputs 个 INPUT 紧密数组 = 一个原子输入块)
402
+ * @returns 成功注入的事件数;0 = 全部失败(UIPI:目标进程完整性更高),< cInputs = 部分成功
403
+ * @param args_0 events INPUT 元素数组(structArray(INPUT) encoder 直传
404
+ * [{type:0|1, data:{mi|ki:{...}}}];绝对坐标 dx/dy 是 0-65535 归一化物理像素——本引擎
405
+ * SetProcessDPIAware,GetSystemMetrics/GetWindowRect 同空间,换算 x*65535/(SM_CXSCREEN-1))
406
+ * @param args_1 cbSize 传 INPUT.size(MSDN 要求 = sizeof(INPUT),x86 28 / x64 40,
407
+ * 传错整体静默失败) */
408
+ export const SendInput = /*@__PURE__*/ b('SendInput', 'u32 <INPUT>ptr i32 -> u32', { INPUT: INPUTArr });
397
409
  // ============ 计时器 ============
398
410
  /** 设定时器(hWnd/id 传 NULL/0 = 自动分配 id;lpTimerFunc 传 NULL 用 WM_TIMER)
399
411
  * @returns 定时器 ID(自动分配时从返回值读回);失败 → 0
@@ -520,7 +532,7 @@ export const ShowScrollBar = /*@__PURE__*/ b('ShowScrollBar', '<HWND>ptr u32 i32
520
532
  * @param args_3 uType MB_* 样式(MB_OK/MB_YESNO 等) */
521
533
  export const MessageBox = /*@__PURE__*/ b('MessageBoxW', '<HWND>ptr <WCHAR>ptr <WCHAR>ptr u32 -> i32');
522
534
  // ============ 图像 ============
523
- /** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 gui.ImageType 枚举当前值
535
+ /** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 ImageType 枚举当前值
524
536
  * 不同)
525
537
  * @returns 图像句柄;失败 → 0
526
538
  * @param args_0 hinst 模块句柄,NULL = 系统资源或 .ico 文件
@@ -1,4 +1,4 @@
1
- // user32.dll 精选高频 API(85 个),逐函数独立导出:
1
+ // user32.dll 精选高频 API(99 个),逐函数独立导出:
2
2
  // - 签名对照 mingw winuser.h 原型手写;未被 import 的绑定经 esbuild 摇树不进产物
3
3
  // - WPARAM / LPARAM / LRESULT / UINT_PTR / LONG_PTR 及句柄混合值一律 <>ptr(指针宽度跨
4
4
  // 架构正确;返回值 0 保真(C→JS 不做 0→null)、有符号读对齐 C 版 JS_NewInt64——-1 哨兵等负值保真)
@@ -24,8 +24,9 @@
24
24
  // <HGLOBAL>ptr 自产自收)
25
25
  import * as os from 'os'
26
26
  import { bind, type CodecMap } from '../ffi/bind.js'
27
+ import { structArray } from '../ffi/struct.js'
27
28
  // 只 import 注册了 encoder 的结构(纯入参位);POINT 等出/就地位不注册,运行时无需引用
28
- import { MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js'
29
+ import { INPUT, MSG, RECT, SCROLLINFO, WNDCLASSEXW } from './structs.js'
29
30
 
30
31
  // dll 名部分应用:85 个绑定共用,签名字符串不再重复 'user32.dll'。
31
32
  // 不能用 bind.bind(null, dll)——泛型在部分应用点坍缩(返回 never);工厂转调让
@@ -48,7 +49,7 @@ const LONG_PTR_SYM = os.arch === 'x64' ? 'PtrW' : 'W'
48
49
  * @param args_0 dwExStyle WS_EX_*
49
50
  * @param args_1 lpClassName 窗口类名 string 或 NULL
50
51
  * @param args_2 lpWindowName 窗口标题 string 或 NULL
51
- * @param args_3 dwStyle WS_*(gui.WindowStyle 类常量)
52
+ * @param args_3 dwStyle WS_*(WindowStyle 类常量)
52
53
  * @param args_4 x 初始左上角(CW_USEDEFAULT = -1)
53
54
  * @param args_5 y 初始左上角(CW_USEDEFAULT = -1)
54
55
  * @param args_6 nWidth
@@ -63,7 +64,7 @@ export const CreateWindowEx = /*@__PURE__*/ b('CreateWindowExW',
63
64
  * @returns 成功 → 非 0
64
65
  * @param args_0 hWnd */
65
66
  export const DestroyWindow = /*@__PURE__*/ b('DestroyWindow', '<HWND>ptr -> i32')
66
- /** 显示/隐藏窗口(nCmdShow = gui.WindowStyle 类常量)
67
+ /** 显示/隐藏窗口(nCmdShow = WindowStyle 类常量)
67
68
  * @returns 先前可见性
68
69
  * @param args_0 hWnd
69
70
  * @param args_1 nCmdShow 显示命令(SW_SHOW/SW_HIDE 等) */
@@ -313,7 +314,7 @@ export const EndPaint = /*@__PURE__*/ b('EndPaint', '<HWND>ptr <PAINTSTRUCT>ptr
313
314
  * @param args_1 lpchText 文本 string(自动 UTF-16 编码)
314
315
  * @param args_2 cchText 字符数(-1 = 自动算到 NUL)
315
316
  * @param args_3 lpRect 矩形(双向不注册 encoder;CALCRECT 就地写回:RECT.encode(初值) 传 .ptr、decode 读回)
316
- * @param args_4 uFormat DT_* 排版标志(gui.DrawTextFlag) */
317
+ * @param args_4 uFormat DT_* 排版标志(DrawTextFlag) */
317
318
  export const DrawText = /*@__PURE__*/ b('DrawTextW', '<HDC>ptr! <WCHAR>ptr i32 <RECT>ptr i32 -> i32')
318
319
  /** 用画刷填充矩形
319
320
  * @returns 填充高度
@@ -413,6 +414,17 @@ export const GetKeyboardState = /*@__PURE__*/ b('GetKeyboardState', '<BYTE>ptr -
413
414
  * @returns SHORT(低字节 VK、高位 shift/ctrl/alt 掩码),无 → -1
414
415
  * @param args_0 ch 字符码(如 65 = 'A') */
415
416
  export const VkKeyScan = /*@__PURE__*/ b('VkKeyScanW', 'u32 -> i32')
417
+ // INPUT 数组 encoder(SendInput 的 <INPUT>ptr 位注册后值域即元素数组——与 gdi32
418
+ // POINTArr 同机制,token/引擎层零数组概念)
419
+ const INPUTArr = /*@__PURE__*/ structArray(INPUT)
420
+ /** 批量注入输入事件(一次调用 = cInputs 个 INPUT 紧密数组 = 一个原子输入块)
421
+ * @returns 成功注入的事件数;0 = 全部失败(UIPI:目标进程完整性更高),< cInputs = 部分成功
422
+ * @param args_0 events INPUT 元素数组(structArray(INPUT) encoder 直传
423
+ * [{type:0|1, data:{mi|ki:{...}}}];绝对坐标 dx/dy 是 0-65535 归一化物理像素——本引擎
424
+ * SetProcessDPIAware,GetSystemMetrics/GetWindowRect 同空间,换算 x*65535/(SM_CXSCREEN-1))
425
+ * @param args_1 cbSize 传 INPUT.size(MSDN 要求 = sizeof(INPUT),x86 28 / x64 40,
426
+ * 传错整体静默失败) */
427
+ export const SendInput = /*@__PURE__*/ b('SendInput', 'u32 <INPUT>ptr i32 -> u32', { INPUT: INPUTArr })
416
428
 
417
429
  // ============ 计时器 ============
418
430
 
@@ -551,7 +563,7 @@ export const MessageBox = /*@__PURE__*/ b('MessageBoxW', '<HWND>ptr <WCHAR>ptr <
551
563
 
552
564
  // ============ 图像 ============
553
565
 
554
- /** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 gui.ImageType 枚举当前值
566
+ /** 按名加载图像(string 自动编码;uType/fuLoad 用 Win32 真值——与 ImageType 枚举当前值
555
567
  * 不同)
556
568
  * @returns 图像句柄;失败 → 0
557
569
  * @param args_0 hinst 模块句柄,NULL = 系统资源或 .ico 文件
@@ -14,7 +14,7 @@ const b = (name, sig, encoders) => bind('winspool.drv', name, sig, encoders);
14
14
  /** 枚举打印队列(Level=2 → PRINTER_INFO_2W 数组);两段式:先
15
15
  * NULL+cbBuf 0 拿 pcbNeeded,再按需分配缓冲重调
16
16
  * @returns 成功 → 非 0
17
- * @param args_0 dwFlags 枚举范围:gui.PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
17
+ * @param args_0 dwFlags 枚举范围:PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
18
18
  * 已连接,组合 OR 传裸数(可组合 flags 不标枚举)
19
19
  * @param args_1 pName 服务器名(仅 Level=4/5/6 用),本地枚举传 NULL
20
20
  * @param args_2 dwLevel 信息级别,取 2(PRINTER_INFO_2W)
@@ -28,12 +28,12 @@ export const EnumPrinters = /*@__PURE__*/ b('EnumPrintersW', 'u32 <WCHAR>ptr u32
28
28
  * @param args_0 pszBuffer 出参缓冲,WCHAR.alloc(n)、WCHAR.decode 读回
29
29
  * @param args_1 pcchBuffer 出入长度槽(入 = 缓冲 WCHAR 容量,出 = 实际长度),PtrArrayBuffer(4) */
30
30
  export const GetDefaultPrinter = /*@__PURE__*/ b('GetDefaultPrinterW', '<BYTE>ptr <BYTE>ptr -> i32');
31
- /** 查设备能力;nCapability 单选 gui.DeviceCap.*
31
+ /** 查设备能力;nCapability 单选 DeviceCap.*
32
32
  * @returns 返回值随能力(数值能力 = 数值,
33
33
  * -1 = 失败)
34
34
  * @param args_0 pDevice 打印机名(禁空)
35
35
  * @param args_1 pPort 端口名,传 NULL 用打印机配置端口
36
- * @param args_2 nCapability 能力码(gui.DeviceCap.HORZRES 等单选)
36
+ * @param args_2 nCapability 能力码(DeviceCap.HORZRES 等单选)
37
37
  * @param args_3 pOutput 字符串列表型能力的缓冲;数值型查询传 NULL
38
38
  * @param args_4 pDevmode DEVMODE,传 NULL */
39
39
  export const DeviceCapabilities = /*@__PURE__*/ b('DeviceCapabilitiesW', '<WCHAR>ptr! <WCHAR>ptr u32@DeviceCap <BYTE>ptr <>ptr -> i32');
@@ -17,7 +17,7 @@ const b = <const S extends string, const LE extends CodecMap = {}>(name: string,
17
17
  /** 枚举打印队列(Level=2 → PRINTER_INFO_2W 数组);两段式:先
18
18
  * NULL+cbBuf 0 拿 pcbNeeded,再按需分配缓冲重调
19
19
  * @returns 成功 → 非 0
20
- * @param args_0 dwFlags 枚举范围:gui.PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
20
+ * @param args_0 dwFlags 枚举范围:PrinterEnum.LOCAL(0x2) 本地 | CONNECTIONS(0x4)
21
21
  * 已连接,组合 OR 传裸数(可组合 flags 不标枚举)
22
22
  * @param args_1 pName 服务器名(仅 Level=4/5/6 用),本地枚举传 NULL
23
23
  * @param args_2 dwLevel 信息级别,取 2(PRINTER_INFO_2W)
@@ -34,12 +34,12 @@ export const EnumPrinters = /*@__PURE__*/ b('EnumPrintersW',
34
34
  * @param args_1 pcchBuffer 出入长度槽(入 = 缓冲 WCHAR 容量,出 = 实际长度),PtrArrayBuffer(4) */
35
35
  export const GetDefaultPrinter = /*@__PURE__*/ b('GetDefaultPrinterW', '<BYTE>ptr <BYTE>ptr -> i32')
36
36
 
37
- /** 查设备能力;nCapability 单选 gui.DeviceCap.*
37
+ /** 查设备能力;nCapability 单选 DeviceCap.*
38
38
  * @returns 返回值随能力(数值能力 = 数值,
39
39
  * -1 = 失败)
40
40
  * @param args_0 pDevice 打印机名(禁空)
41
41
  * @param args_1 pPort 端口名,传 NULL 用打印机配置端口
42
- * @param args_2 nCapability 能力码(gui.DeviceCap.HORZRES 等单选)
42
+ * @param args_2 nCapability 能力码(DeviceCap.HORZRES 等单选)
43
43
  * @param args_3 pOutput 字符串列表型能力的缓冲;数值型查询传 NULL
44
44
  * @param args_4 pDevmode DEVMODE,传 NULL */
45
45
  export const DeviceCapabilities = /*@__PURE__*/ b('DeviceCapabilitiesW',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "quickwin",
4
- "version": "2.1.1",
4
+ "version": "2.3.0",
5
5
  "description": "QuickJS Win32 runtime — GUI, networking, WASM, FFI, and more",
6
6
  "bin": {
7
7
  "quickwin": "qwin.exe",
@@ -24,7 +24,8 @@
24
24
  "examples/",
25
25
  "vendor/",
26
26
  "quickwin.d.ts",
27
- "quickwin_const.d.ts",
27
+ "constants.ts",
28
+ "enum_map.d.ts",
28
29
  "tsconfig.json",
29
30
  "README.md",
30
31
  "README.en.md"
@@ -32,7 +33,7 @@
32
33
  "license": "MIT",
33
34
  "repository": {
34
35
  "type": "git",
35
- "url": "git+https://github.com/xna00/quickwin.git"
36
+ "url": "git+https://github.com/quickwinlabs/quickwin.git"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@types/node": "^24.13.2",
package/quickwin.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference path="quickwin_const.d.ts" />
2
- /// <reference path="quickwin_enum_map.d.ts" />
1
+ /// <reference path="enum_map.d.ts" />
3
2
  interface ImportMeta {
4
3
  url: string
5
4
  }
@@ -348,6 +347,12 @@ declare module "os" {
348
347
  declare module "sock" {
349
348
  type SockHandle = number & { readonly __brand: unique symbol };
350
349
  type SockFd = number & { readonly __brand: unique symbol };
350
+ // 枚举唯一定义在 constants.ts(真实 .ts,tsc/esbuild 均内联);此处别名仅供签名引用,
351
+ // 使用方请直接 import { AddrFamily } from 'quickwin/constants'。
352
+ type AddrFamily = import('./constants').AddrFamily;
353
+ type SockType = import('./constants').SockType;
354
+ type Protocol = import('./constants').Protocol;
355
+ type Shutdown = import('./constants').Shutdown;
351
356
 
352
357
  function socket(domain?: AddrFamily, type?: SockType, protocol?: Protocol): SockHandle;
353
358
  function connect(sock: SockHandle, addr: string, port: number): number;
@@ -374,6 +379,10 @@ declare module "wolfssl" {
374
379
  type WOLFSSL = number & { readonly __brand: unique symbol };
375
380
  type WOLFSSL_CTX = number & { readonly __brand: unique symbol };
376
381
  type WOLFSSL_METHOD = number & { readonly __brand: unique symbol };
382
+ // 枚举唯一定义在 constants.ts(见 sock 块注释)。
383
+ type VerifyMode = import('./constants').VerifyMode;
384
+ type SniType = import('./constants').SniType;
385
+ type FileType = import('./constants').FileType;
377
386
 
378
387
  function wolfSSL_library_init(): number;
379
388
  function wolfSSL_CTX_new(method: WOLFSSL_METHOD): WOLFSSL_CTX | null;
@@ -433,6 +442,18 @@ declare module "gui" {
433
442
  type HFONT = number & { readonly ptrBrand: "HFONT" };
434
443
  type HICON = number & { readonly ptrBrand: "HICON" };
435
444
  type WNDPROC = number & { readonly ptrBrand: "WNDPROC" };
445
+ // 枚举唯一定义在 constants.ts(真实 .ts,tsc/esbuild 均内联);此处别名仅供签名引用,
446
+ // 使用方请直接 import { WindowStyle } from 'quickwin/constants'。
447
+ // Gwlp/ImageType 的成员访问(如 Gwlp.WNDPROC)需写 import('./constants').Gwlp.WNDPROC
448
+ // ——类型别名不建命名空间,无法穿透取成员。
449
+ type GetWindowCmd = import('./constants').GetWindowCmd;
450
+ type ShowWindowCmd = import('./constants').ShowWindowCmd;
451
+ type SetWindowPosHwnd = import('./constants').SetWindowPosHwnd;
452
+ type Gwlp = import('./constants').Gwlp;
453
+ type NotifyIconCmd = import('./constants').NotifyIconCmd;
454
+ type ImageType = import('./constants').ImageType;
455
+ type IDI = import('./constants').IDI;
456
+ type ScrollBar = import('./constants').ScrollBar;
436
457
 
437
458
  function RegisterClass(className: string, wndProc?: (hwnd: HWND, msg: number, wParam: number, lParam: number) => number): number;
438
459
  function CreateWindow(className: string, title: string, style: number, x: number, y: number, width: number, height: number, parent: HWND | null, menu: HMENU | null): HWND | null;
@@ -450,7 +471,7 @@ declare module "gui" {
450
471
  function GetWindowText(hwnd: HWND): string;
451
472
  function GetScaleFactor(): number;
452
473
  function CreateSystemDpiFont(): HFONT | null;
453
- type GwlpReturnType<T extends Gwlp> = T extends Gwlp.WNDPROC ? WNDPROC : number;
474
+ type GwlpReturnType<T extends Gwlp> = T extends import('./constants').Gwlp.WNDPROC ? WNDPROC : number;
454
475
  function GetWindowLongPtr<T extends Gwlp>(hwnd: HWND, nIndex: T): GwlpReturnType<T>;
455
476
  function SetWindowLongPtr(hwnd: HWND, nIndex: Gwlp, newLong: number): number;
456
477
  function UnsetWindowProc(hwnd: HWND): boolean;
@@ -475,20 +496,21 @@ declare module "gui" {
475
496
  * Thin wrapper around LoadImageW. Parameter order matches Win32 LoadImageW: (hinst, name, uType?, cx?, cy?, fuLoad?).
476
497
  * hinst: null for system resources/file path, number for module handle;
477
498
  * name: when hinst=null, a system icon IDI or .ico file path; when hinst=module handle, a resource ID (number) or resource name (string);
478
- * uType: gui.ImageType constant, default IMAGE_ICON (returns HICON), pass BITMAP/CURSOR for number return;
479
- * cx/cy: target size (0 for default, use gui.LoadImageFlag.DEFAULTSIZE for system default size);
480
- * fuLoad: gui.LoadImageFlag constants. Note: loading system icons (IDI_*, hinst=null) requires gui.LoadImageFlag.SHARED.
481
- * Example: gui.LoadImage(null, "app.ico", gui.ImageType.ICON, 32, 32, gui.LoadImageFlag.LOADFROMFILE)
482
- * gui.LoadImage(null, gui.IDI.APPLICATION, gui.ImageType.ICON, 0, 0, gui.LoadImageFlag.SHARED)
499
+ * uType: ImageType constant, default IMAGE_ICON (returns HICON), pass BITMAP/CURSOR for number return;
500
+ * cx/cy: target size (0 for default, use LoadImageFlag.DEFAULTSIZE for system default size);
501
+ * fuLoad: LoadImageFlag constants. Note: loading system icons (IDI_*, hinst=null) requires LoadImageFlag.SHARED.
502
+ * Example: import { IDI, ImageType, LoadImageFlag } from 'quickwin/constants'
503
+ * gui.LoadImage(null, "app.ico", ImageType.ICON, 32, 32, LoadImageFlag.LOADFROMFILE)
504
+ * gui.LoadImage(null, IDI.APPLICATION, ImageType.ICON, 0, 0, LoadImageFlag.SHARED)
483
505
  */
484
- function LoadImage<H extends (import("win").HMODULE) | null, T extends ImageType = ImageType.ICON>(
506
+ function LoadImage<H extends (import("win").HMODULE) | null, T extends ImageType = import('./constants').ImageType.ICON>(
485
507
  hinst: H,
486
508
  name: H extends null ? string | IDI : string | number,
487
509
  uType?: T,
488
510
  cx?: number,
489
511
  cy?: number,
490
512
  fuLoad?: number
491
- ): T extends ImageType.ICON ? HICON | null : number | null;
513
+ ): T extends import('./constants').ImageType.ICON ? HICON | null : number | null;
492
514
  /**
493
515
  * Loads the first icon group (RT_GROUP_ICON) from this exe, i.e. the custom icon
494
516
  * embedded by rcedit. Works with any resource ID including 0. Returns null if the
Binary file
package/qwin-nowasm.exe CHANGED
Binary file
package/qwin-x86.exe CHANGED
Binary file
package/qwin.exe CHANGED
Binary file
@@ -88,7 +88,7 @@ export const suite = {
88
88
  const rect = new PtrArrayBuffer(16);
89
89
  const dv = new DataView(rect);
90
90
  dv.setInt32(8, 500, true);
91
- const lines = user32.DrawTextW(dc, 'hello ffi-bind', -1, rect, 1024 /* gui.DrawTextFlag.CALCRECT */);
91
+ const lines = user32.DrawTextW(dc, 'hello ffi-bind', -1, rect, 1024 /* DrawTextFlag.CALCRECT */);
92
92
  t.checkTrue('DrawTextW returns line count > 0', lines > 0);
93
93
  t.checkTrue('measured width > 0', dv.getInt32(8, true) > 0);
94
94
  t.checkTrue('measured height > 0', dv.getInt32(12, true) > 0);
@@ -238,13 +238,15 @@ export const suite = {
238
238
  if (brushL)
239
239
  t.checkTrue('bindLib DeleteObject succeeds', gdi32Lib.DeleteObject(brushL) !== 0);
240
240
  // 嵌套 struct(LOGPEN 内含 POINT)验证 ShapeOf 递归 + 子结构写入
241
- const POINT = struct('POINT', {
241
+ const POINT_DECL = {
242
+ '#': 'struct',
242
243
  x: 'i32',
243
244
  y: 'i32',
244
- });
245
+ };
246
+ const POINT = /* @__PURE__ */ struct('POINT', POINT_DECL);
245
247
  const LOGPEN = struct('LOGPEN', {
246
248
  lopnStyle: 'u32',
247
- lopnWidth: POINT.__struct,
249
+ lopnWidth: POINT_DECL,
248
250
  lopnColor: 'u32',
249
251
  });
250
252
  const createPenIndirect = bind('gdi32.dll', 'CreatePenIndirect', '<LOGPEN>ptr -> <>ptr', { LOGPEN });
@@ -527,7 +529,7 @@ export const suite = {
527
529
  t.check('closure 返回 ! 非零:正常写槽', 0x3000, readScalar(new DataView(rr3), 0, 'ptr'));
528
530
  nnRet.dispose();
529
531
  // 返回位负例:fn 返回 0 → printf 诊断 + 不写槽;C 侧 retbuf 初值恒零
530
- // (quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
532
+ // (src/quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
531
533
  // 值层面只验分发不炸、槽保持 0(诊断走 stdout,见上方 printf)。
532
534
  const nnRet0 = closure('i32 -> <>ptr!', (_n) => 0);
533
535
  const rr4 = new ArrayBuffer(8);
@@ -585,9 +587,9 @@ export const suite = {
585
587
  const drawText = bind('user32.dll', 'DrawTextW', '<>ptr! <WCHAR>ptr i32 <BYTE>ptr i32 -> i32');
586
588
  const dtRect = new PtrArrayBuffer(16);
587
589
  if (dcScreen) {
588
- t.checkTrue('DrawTextW 非空 DC 通过 ! 参数位', drawText(dcScreen, 'hi !', -1, dtRect, 1024 /* gui.DrawTextFlag.CALCRECT */) > 0);
590
+ t.checkTrue('DrawTextW 非空 DC 通过 ! 参数位', drawText(dcScreen, 'hi !', -1, dtRect, 1024 /* DrawTextFlag.CALCRECT */) > 0);
589
591
  try {
590
- drawText(0, 'hi !', -1, dtRect, 1024 /* gui.DrawTextFlag.CALCRECT */);
592
+ drawText(0, 'hi !', -1, dtRect, 1024 /* DrawTextFlag.CALCRECT */);
591
593
  t.checkTrue('DrawTextW NULL DC 标 ! 后应 throw', false);
592
594
  }
593
595
  catch (e) {
@@ -642,13 +644,13 @@ export const suite = {
642
644
  if (false) {
643
645
  const sw = bind('user32.dll', 'ShowWindow', '<X>ptr i32@ShowWindowCmd -> i32');
644
646
  const sp = bind('user32.dll', 'SetWindowPos', '<X>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32');
645
- sw(NULL, 5 /* gui.ShowWindowCmd.SHOW */); // 枚举成员
647
+ sw(NULL, 5 /* ShowWindowCmd.SHOW */); // 枚举成员
646
648
  sw(NULL, 5); // 域内字面量(5 = SW_SHOW)
647
- sp(NULL, 0 /* gui.SetWindowPosHwnd.TOP */, 0, 0, 0, 0, 1 /* gui.SetWindowPosFlag.SWP_NOSIZE */);
649
+ sp(NULL, 0 /* SetWindowPosHwnd.TOP */, 0, 0, 0, 0, 1 /* SetWindowPosFlag.SWP_NOSIZE */);
648
650
  // @ts-expect-error 域外字面量被拦(11152 不是任何 ShowWindow 命令)
649
651
  sw(NULL, 0x2B90);
650
652
  // @ts-expect-error 跨枚举误用:HWND_TOP/TOPMOST 不是 ShowWindow 命令
651
- sw(NULL, 0 /* gui.SetWindowPosHwnd.TOP */);
653
+ sw(NULL, 0 /* SetWindowPosHwnd.TOP */);
652
654
  }
653
655
  },
654
656
  };
@@ -1,11 +1,11 @@
1
1
  import * as std from 'std'
2
- import * as gui from 'gui'
3
2
  import * as ffi from 'ffi'
4
3
  import * as os from 'os'
5
4
  import { Tester } from './test_helper.js'
6
5
  import { bind, bindLib, closure, WCHAR, BYTE, type CodecMap } from '../lib/ffi/bind.js'
7
6
  import { struct } from '../lib/ffi/struct.js'
8
- import { NULL, type MaybePtr, Ptr, PtrArrayBuffer, readScalar, writeScalar, PTR_SIZE, normToken } from '../lib/ffi/ctype.js'
7
+ import { NULL, type C_Struct, type MaybePtr, Ptr, PtrArrayBuffer, readScalar, writeScalar, PTR_SIZE, normToken } from '../lib/ffi/ctype.js'
8
+ import { DrawTextFlag, SetWindowPosFlag, SetWindowPosHwnd, ShowWindowCmd } from '../constants'
9
9
 
10
10
  // 编译期断言工具(仅类型层,运行时无开销)
11
11
  type Equal<A, B> = (<G>() => G extends A ? 1 : 2) extends (<G>() => G extends B ? 1 : 2) ? true : false
@@ -86,7 +86,7 @@ export const suite = {
86
86
  const rect = new PtrArrayBuffer(16)
87
87
  const dv = new DataView(rect)
88
88
  dv.setInt32(8, 500, true)
89
- const lines = user32.DrawTextW(dc, 'hello ffi-bind', -1, rect, gui.DrawTextFlag.CALCRECT)
89
+ const lines = user32.DrawTextW(dc, 'hello ffi-bind', -1, rect, DrawTextFlag.CALCRECT)
90
90
  t.checkTrue('DrawTextW returns line count > 0', lines > 0)
91
91
  t.checkTrue('measured width > 0', dv.getInt32(8, true) > 0)
92
92
  t.checkTrue('measured height > 0', dv.getInt32(12, true) > 0)
@@ -238,13 +238,15 @@ export const suite = {
238
238
  if (brushL) t.checkTrue('bindLib DeleteObject succeeds', gdi32Lib.DeleteObject(brushL) !== 0)
239
239
 
240
240
  // 嵌套 struct(LOGPEN 内含 POINT)验证 ShapeOf 递归 + 子结构写入
241
- const POINT = struct('POINT', {
241
+ const POINT_DECL = {
242
+ '#': 'struct',
242
243
  x: 'i32',
243
244
  y: 'i32',
244
- })
245
+ } satisfies C_Struct
246
+ const POINT = /* @__PURE__ */ struct('POINT', POINT_DECL)
245
247
  const LOGPEN = struct('LOGPEN', {
246
248
  lopnStyle: 'u32',
247
- lopnWidth: POINT.__struct,
249
+ lopnWidth: POINT_DECL,
248
250
  lopnColor: 'u32',
249
251
  })
250
252
  const createPenIndirect = bind('gdi32.dll', 'CreatePenIndirect', '<LOGPEN>ptr -> <>ptr', { LOGPEN })
@@ -539,7 +541,7 @@ export const suite = {
539
541
  t.check('closure 返回 ! 非零:正常写槽', 0x3000, readScalar(new DataView(rr3), 0, 'ptr'))
540
542
  nnRet.dispose()
541
543
  // 返回位负例:fn 返回 0 → printf 诊断 + 不写槽;C 侧 retbuf 初值恒零
542
- // (quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
544
+ // (src/quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
543
545
  // 值层面只验分发不炸、槽保持 0(诊断走 stdout,见上方 printf)。
544
546
  const nnRet0 = closure('i32 -> <>ptr!', (_n) => 0)
545
547
  const rr4 = new ArrayBuffer(8)
@@ -600,9 +602,9 @@ export const suite = {
600
602
  const dtRect = new PtrArrayBuffer(16)
601
603
  if (dcScreen) {
602
604
  t.checkTrue('DrawTextW 非空 DC 通过 ! 参数位',
603
- drawText(dcScreen, 'hi !', -1, dtRect, gui.DrawTextFlag.CALCRECT) > 0)
605
+ drawText(dcScreen, 'hi !', -1, dtRect, DrawTextFlag.CALCRECT) > 0)
604
606
  try {
605
- drawText(0, 'hi !', -1, dtRect, gui.DrawTextFlag.CALCRECT)
607
+ drawText(0, 'hi !', -1, dtRect, DrawTextFlag.CALCRECT)
606
608
  t.checkTrue('DrawTextW NULL DC 标 ! 后应 throw', false)
607
609
  } catch (e) { t.checkTrue('! 参数位(第 1 位)throw 指明 arg#1', String(e).includes('arg#1')) }
608
610
  }
@@ -656,13 +658,13 @@ export const suite = {
656
658
  if (false) {
657
659
  const sw = bind('user32.dll', 'ShowWindow', '<X>ptr i32@ShowWindowCmd -> i32')
658
660
  const sp = bind('user32.dll', 'SetWindowPos', '<X>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32')
659
- sw(NULL, gui.ShowWindowCmd.SHOW) // 枚举成员
661
+ sw(NULL, ShowWindowCmd.SHOW) // 枚举成员
660
662
  sw(NULL, 5) // 域内字面量(5 = SW_SHOW)
661
- sp(NULL, gui.SetWindowPosHwnd.TOP, 0, 0, 0, 0, gui.SetWindowPosFlag.SWP_NOSIZE)
663
+ sp(NULL, SetWindowPosHwnd.TOP, 0, 0, 0, 0, SetWindowPosFlag.SWP_NOSIZE)
662
664
  // @ts-expect-error 域外字面量被拦(11152 不是任何 ShowWindow 命令)
663
665
  sw(NULL, 0x2B90)
664
666
  // @ts-expect-error 跨枚举误用:HWND_TOP/TOPMOST 不是 ShowWindow 命令
665
- sw(NULL, gui.SetWindowPosHwnd.TOP)
667
+ sw(NULL, SetWindowPosHwnd.TOP)
666
668
  }
667
669
  },
668
670
  }