quickwin 2.2.0 → 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 (111) hide show
  1. package/README.en.md +7 -7
  2. package/README.md +7 -7
  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/{execd.js → execd/main.js} +563 -122
  8. package/examples/execd/tray.js +192 -0
  9. package/examples/{execd_worker.js → execd/worker.js} +7 -7
  10. package/examples/pdf_preview2.js +46 -46
  11. package/examples/pdf_preview2.ts +55 -54
  12. package/examples/pdf_viewer.js +34 -19
  13. package/examples/pdf_viewer.tsx +6 -5
  14. package/examples/test_gallery.js +35 -20
  15. package/examples/test_gallery.tsx +9 -8
  16. package/examples/test_react_lazy.js +34 -19
  17. package/examples/test_react_lazy.tsx +7 -6
  18. package/examples/test_react_listbox.js +34 -19
  19. package/examples/test_react_listbox.tsx +8 -7
  20. package/examples/test_root_window.js +34 -19
  21. package/examples/test_root_window.tsx +5 -5
  22. package/examples/test_tab.js +34 -19
  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/http-server.js +4 -4
  33. package/lib/http-server.ts +5 -4
  34. package/lib/react-qw/components/Button.js +2 -2
  35. package/lib/react-qw/components/CheckBox.js +4 -4
  36. package/lib/react-qw/components/ComboBox.js +10 -10
  37. package/lib/react-qw/components/DateTimePicker.js +12 -12
  38. package/lib/react-qw/components/Input.js +7 -7
  39. package/lib/react-qw/components/Link.js +4 -4
  40. package/lib/react-qw/components/ListBox.js +12 -12
  41. package/lib/react-qw/components/ListView.js +35 -35
  42. package/lib/react-qw/components/PathPicker.js +3 -3
  43. package/lib/react-qw/components/ProgressBar.js +4 -4
  44. package/lib/react-qw/components/RadioButton.js +4 -4
  45. package/lib/react-qw/components/ScrollView.js +28 -28
  46. package/lib/react-qw/components/Slider.js +11 -11
  47. package/lib/react-qw/components/Tab.js +10 -10
  48. package/lib/react-qw/components/Tooltip.js +8 -8
  49. package/lib/react-qw/components/TreeView.js +20 -20
  50. package/lib/react-qw/index.js +5 -5
  51. package/lib/react-qw/index.ts +6 -5
  52. package/lib/react-qw/props.js +4 -4
  53. package/lib/react-qw/props.ts +5 -4
  54. package/lib/react-qw/reconciler.js +10 -10
  55. package/lib/react-qw/reconciler.ts +11 -10
  56. package/lib/text-measure.js +3 -3
  57. package/lib/text-measure.ts +4 -3
  58. package/lib/websocket.js +17 -17
  59. package/lib/websocket.ts +18 -17
  60. package/lib/windows/advapi32.js +7 -7
  61. package/lib/windows/advapi32.ts +7 -7
  62. package/lib/windows/gdi32.js +16 -16
  63. package/lib/windows/gdi32.ts +16 -16
  64. package/lib/windows/kernel32.js +41 -2
  65. package/lib/windows/kernel32.ts +45 -2
  66. package/lib/windows/shell32.js +24 -3
  67. package/lib/windows/shell32.ts +27 -4
  68. package/lib/windows/structs.js +54 -0
  69. package/lib/windows/structs.ts +63 -1
  70. package/lib/windows/user32.js +18 -6
  71. package/lib/windows/user32.ts +18 -6
  72. package/lib/windows/winspool.js +3 -3
  73. package/lib/windows/winspool.ts +3 -3
  74. package/package.json +4 -3
  75. package/quickwin.d.ts +32 -10
  76. package/qwin-nowasm-x86.exe +0 -0
  77. package/qwin-nowasm.exe +0 -0
  78. package/qwin-x86.exe +0 -0
  79. package/qwin.exe +0 -0
  80. package/test/test_ffi_bind.js +7 -7
  81. package/test/test_ffi_bind.ts +8 -8
  82. package/test/test_ffi_struct.js +2 -2
  83. package/test/test_ffi_struct.ts +3 -3
  84. package/test/test_ffi_windows.js +1 -1
  85. package/test/test_ffi_windows.ts +1 -1
  86. package/test/test_files.js +7 -7
  87. package/test/test_files.ts +8 -8
  88. package/test/test_gdi_draw.js +51 -51
  89. package/test/test_gdi_draw.ts +57 -57
  90. package/test/test_http_server.js +3 -3
  91. package/test/test_http_server.ts +4 -3
  92. package/test/test_ipv6.js +3 -3
  93. package/test/test_ipv6.ts +4 -3
  94. package/test/test_net_event.js +3 -3
  95. package/test/test_net_event.ts +4 -3
  96. package/test/test_printer.js +4 -4
  97. package/test/test_printer.ts +5 -5
  98. package/test/test_react_complex.js +36 -21
  99. package/test/test_react_counter.js +34 -19
  100. package/test/test_react_flex.js +36 -21
  101. package/test/test_react_hidden.js +34 -19
  102. package/test/test_react_listview_link.js +35 -20
  103. package/test/test_react_notify.js +52 -37
  104. package/test/test_react_render.js +34 -19
  105. package/test/test_registry.js +6 -6
  106. package/test/test_registry.ts +8 -8
  107. package/test/test_wolfssl_read.js +8 -8
  108. package/test/test_wolfssl_read.ts +9 -8
  109. package/examples/execd.tsx +0 -798
  110. package/examples/execd_worker.ts +0 -127
  111. package/quickwin_const.d.ts +0 -1063
@@ -1,5 +1,5 @@
1
1
  import { struct } from '../ffi/struct.js'
2
- import type { C_Struct } from '../ffi/ctype.js'
2
+ import type { C_Struct, C_Union } from '../ffi/ctype.js'
3
3
 
4
4
  // 全仓库 Win32 结构的集中定义点(CType IR,按本机架构 MSVC 对齐;这批全为定长标量/字符串,
5
5
  // ia32/x64 同布局)。形参位方向约定见 lib/windows/user32.ts 头注释:
@@ -688,3 +688,65 @@ export const PROCESS_MEMORY_COUNTERS_DECL = {
688
688
  } satisfies C_Struct
689
689
 
690
690
  export const PROCESS_MEMORY_COUNTERS = /* @__PURE__ */ struct('PROCESS_MEMORY_COUNTERS', PROCESS_MEMORY_COUNTERS_DECL)
691
+
692
+ /** MOUSEINPUT(SendInput 鼠标事件体;x86 24B / x64 32B——dwExtraInfo 是 ULONG_PTR,
693
+ * 随位宽)。dx/dy 相对位移,或 dwFlags 带 MOUSEEVENTF_ABSOLUTE 时为 0-65535 归一化
694
+ * 物理像素(本引擎 SetProcessDPIAware,见 src/main.c,全坐标 API 同空间);
695
+ * mouseData 滚轮增量(±120)或 X 系按钮编号(XBUTTON1/2) */
696
+ export const MOUSEINPUT_DECL = {
697
+ '#': 'struct',
698
+ dx: 'i32',
699
+ dy: 'i32',
700
+ mouseData: 'u32',
701
+ dwFlags: 'u32',
702
+ time: 'u32',
703
+ dwExtraInfo: '<>ptr',
704
+ } satisfies C_Struct
705
+
706
+ export const MOUSEINPUT = /* @__PURE__ */ struct('MOUSEINPUT', MOUSEINPUT_DECL)
707
+
708
+ /** KEYBDINPUT(SendInput 键盘事件体;x86 16B / x64 24B):wVk 虚拟键码,
709
+ * dwFlags 带 KEYEVENTF_UNICODE 时 wScan = 字符码 */
710
+ export const KEYBDINPUT_DECL = {
711
+ '#': 'struct',
712
+ wVk: 'u16',
713
+ wScan: 'u16',
714
+ dwFlags: 'u32',
715
+ time: 'u32',
716
+ dwExtraInfo: '<>ptr',
717
+ } satisfies C_Struct
718
+
719
+ export const KEYBDINPUT = /* @__PURE__ */ struct('KEYBDINPUT', KEYBDINPUT_DECL)
720
+
721
+ /** INPUT(SendInput 元素;x86 28B / x64 40B):type(INPUT_MOUSE=0 / INPUT_KEYBOARD=1)
722
+ * + 三选一 union——C 的 DUMMYUNIONNAME 匿名成员在此命名嵌套(encode 形
723
+ * {type, data:{mi|ki:{...}}})。union 随 MOUSEINPUT 的 ULONG_PTR 位宽,x64 下 type 后
724
+ * 自动补 4B padding 使 union 8 对齐(MSVC 布局)。HARDWAREINPUT 不注入,省略不改
725
+ * 尺寸(union 尺寸 = max 成员 = MOUSEINPUT)。dwExtraInfo 是 ULONG_PTR 信息位(非句柄)
726
+ * → <>ptr 裸档(uintptr 双态先例:WPARAM/LPARAM/void*),恒传 0 */
727
+ export const INPUT_DECL = {
728
+ '#': 'struct',
729
+ type: 'u32',
730
+ data: {
731
+ '#': 'union',
732
+ mi: MOUSEINPUT_DECL,
733
+ ki: KEYBDINPUT_DECL,
734
+ } satisfies C_Union,
735
+ } satisfies C_Struct
736
+
737
+ export const INPUT = /* @__PURE__ */ struct('INPUT', INPUT_DECL)
738
+
739
+ /** NOTIFYICONIDENTIFIER(Shell_NotifyIconGetRect 定位托盘通知图标;x86 28B / x64 40B——
740
+ * hWnd 是 HWND 随位宽,guidItem = GUID 固定 16B 不随)。定位二法取一:guidItem 非全 0
741
+ * 时忽略 hWnd/uID,否则走 hWnd+uID(deskmon 等自注册图标即此形,与 Shell_NotifyIcon
742
+ * 的 {hwnd,uID} 同源);guidItem 缺省 = GUID_NULL 走 hWnd+uID。cbSize 调用前填
743
+ * NOTIFYICONIDENTIFIER.size(cb 结构惯例,见 PROCESS_MEMORY_COUNTERS 同) */
744
+ export const NOTIFYICONIDENTIFIER_DECL = {
745
+ '#': 'struct',
746
+ cbSize: 'u32',
747
+ hWnd: '<HWND>ptr',
748
+ uID: 'u32',
749
+ guidItem: 'u32[4]',
750
+ } satisfies C_Struct
751
+
752
+ export const NOTIFYICONIDENTIFIER = /* @__PURE__ */ struct('NOTIFYICONIDENTIFIER', NOTIFYICONIDENTIFIER_DECL)
@@ -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.2.0",
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);
@@ -529,7 +529,7 @@ export const suite = {
529
529
  t.check('closure 返回 ! 非零:正常写槽', 0x3000, readScalar(new DataView(rr3), 0, 'ptr'));
530
530
  nnRet.dispose();
531
531
  // 返回位负例:fn 返回 0 → printf 诊断 + 不写槽;C 侧 retbuf 初值恒零
532
- // (quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
532
+ // (src/quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
533
533
  // 值层面只验分发不炸、槽保持 0(诊断走 stdout,见上方 printf)。
534
534
  const nnRet0 = closure('i32 -> <>ptr!', (_n) => 0);
535
535
  const rr4 = new ArrayBuffer(8);
@@ -587,9 +587,9 @@ export const suite = {
587
587
  const drawText = bind('user32.dll', 'DrawTextW', '<>ptr! <WCHAR>ptr i32 <BYTE>ptr i32 -> i32');
588
588
  const dtRect = new PtrArrayBuffer(16);
589
589
  if (dcScreen) {
590
- 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);
591
591
  try {
592
- drawText(0, 'hi !', -1, dtRect, 1024 /* gui.DrawTextFlag.CALCRECT */);
592
+ drawText(0, 'hi !', -1, dtRect, 1024 /* DrawTextFlag.CALCRECT */);
593
593
  t.checkTrue('DrawTextW NULL DC 标 ! 后应 throw', false);
594
594
  }
595
595
  catch (e) {
@@ -644,13 +644,13 @@ export const suite = {
644
644
  if (false) {
645
645
  const sw = bind('user32.dll', 'ShowWindow', '<X>ptr i32@ShowWindowCmd -> i32');
646
646
  const sp = bind('user32.dll', 'SetWindowPos', '<X>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32');
647
- sw(NULL, 5 /* gui.ShowWindowCmd.SHOW */); // 枚举成员
647
+ sw(NULL, 5 /* ShowWindowCmd.SHOW */); // 枚举成员
648
648
  sw(NULL, 5); // 域内字面量(5 = SW_SHOW)
649
- 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 */);
650
650
  // @ts-expect-error 域外字面量被拦(11152 不是任何 ShowWindow 命令)
651
651
  sw(NULL, 0x2B90);
652
652
  // @ts-expect-error 跨枚举误用:HWND_TOP/TOPMOST 不是 ShowWindow 命令
653
- sw(NULL, 0 /* gui.SetWindowPosHwnd.TOP */);
653
+ sw(NULL, 0 /* SetWindowPosHwnd.TOP */);
654
654
  }
655
655
  },
656
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
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)
@@ -541,7 +541,7 @@ export const suite = {
541
541
  t.check('closure 返回 ! 非零:正常写槽', 0x3000, readScalar(new DataView(rr3), 0, 'ptr'))
542
542
  nnRet.dispose()
543
543
  // 返回位负例:fn 返回 0 → printf 诊断 + 不写槽;C 侧 retbuf 初值恒零
544
- // (quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
544
+ // (src/quickjs-ffi-closure.c zero8 拷贝),终值 0 与「写了 0」不可分——
545
545
  // 值层面只验分发不炸、槽保持 0(诊断走 stdout,见上方 printf)。
546
546
  const nnRet0 = closure('i32 -> <>ptr!', (_n) => 0)
547
547
  const rr4 = new ArrayBuffer(8)
@@ -602,9 +602,9 @@ export const suite = {
602
602
  const dtRect = new PtrArrayBuffer(16)
603
603
  if (dcScreen) {
604
604
  t.checkTrue('DrawTextW 非空 DC 通过 ! 参数位',
605
- drawText(dcScreen, 'hi !', -1, dtRect, gui.DrawTextFlag.CALCRECT) > 0)
605
+ drawText(dcScreen, 'hi !', -1, dtRect, DrawTextFlag.CALCRECT) > 0)
606
606
  try {
607
- drawText(0, 'hi !', -1, dtRect, gui.DrawTextFlag.CALCRECT)
607
+ drawText(0, 'hi !', -1, dtRect, DrawTextFlag.CALCRECT)
608
608
  t.checkTrue('DrawTextW NULL DC 标 ! 后应 throw', false)
609
609
  } catch (e) { t.checkTrue('! 参数位(第 1 位)throw 指明 arg#1', String(e).includes('arg#1')) }
610
610
  }
@@ -658,13 +658,13 @@ export const suite = {
658
658
  if (false) {
659
659
  const sw = bind('user32.dll', 'ShowWindow', '<X>ptr i32@ShowWindowCmd -> i32')
660
660
  const sp = bind('user32.dll', 'SetWindowPos', '<X>ptr <>ptr@SetWindowPosHwnd i32 i32 i32 i32 u32 -> i32')
661
- sw(NULL, gui.ShowWindowCmd.SHOW) // 枚举成员
661
+ sw(NULL, ShowWindowCmd.SHOW) // 枚举成员
662
662
  sw(NULL, 5) // 域内字面量(5 = SW_SHOW)
663
- 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)
664
664
  // @ts-expect-error 域外字面量被拦(11152 不是任何 ShowWindow 命令)
665
665
  sw(NULL, 0x2B90)
666
666
  // @ts-expect-error 跨枚举误用:HWND_TOP/TOPMOST 不是 ShowWindow 命令
667
- sw(NULL, gui.SetWindowPosHwnd.TOP)
667
+ sw(NULL, SetWindowPosHwnd.TOP)
668
668
  }
669
669
  },
670
670
  }
@@ -724,14 +724,14 @@ export const suite = {
724
724
  t.check('数字位 @ 字段归一往返', 4, dev.key);
725
725
  // encode 必填判定:0 ∉ 值域的 @ 字段必填(省略 = 新槽写 0 = 静默违约);
726
726
  // 0 ∈ 值域可省。下面 { key } 行能编译即 msg/hp 可省的断言。
727
- EV.encode({ key: 4 /* gui.MouseKeyFlag.MK_SHIFT */ });
727
+ EV.encode({ key: 4 /* MouseKeyFlag.MK_SHIFT */ });
728
728
  // @ts-expect-error key 必填:省略即编译错(0 ∉ MouseKeyFlag)
729
729
  EV.encode({ msg: 0 });
730
730
  if (false) {
731
731
  // @ts-expect-error 域外字面量(3 不是任何 MK_ 标志)
732
732
  EV.encode({ key: 3 });
733
733
  // @ts-expect-error 跨枚举误用(WmMsg 成员不是 MouseKeyFlag)
734
- EV.encode({ key: 1 /* gui.WmMsg.CREATE */ });
734
+ EV.encode({ key: 1 /* WmMsg.CREATE */ });
735
735
  }
736
736
  // 数组糖元素带 @:lower 递归归一(normToken 剥 @)+ 元素值域
737
737
  const EA = struct('EA', { msgs: 'u32@WmMsg[4]' });
@@ -1,10 +1,10 @@
1
1
  import * as os from 'os'
2
- import * as gui from 'gui'
3
2
  import { Tester } from './test_helper.js'
4
3
  import { struct, union } from '../lib/ffi/struct.js'
5
4
  import { bind, } from '../lib/ffi/bind.js'
6
5
  import { type MaybePtr, Ptr, PtrArrayBuffer } from '../lib/ffi/ctype.js'
7
6
  import type { C_Struct, C_Union } from '../lib/ffi/ctype.js'
7
+ import { MouseKeyFlag, WmMsg } from '../constants'
8
8
 
9
9
  // 编译期断言工具(仅类型层,运行时无开销)
10
10
  type Equal<A, B> = (<G>() => G extends A ? 1 : 2) extends (<G>() => G extends B ? 1 : 2) ? true : false
@@ -769,14 +769,14 @@ export const suite = {
769
769
 
770
770
  // encode 必填判定:0 ∉ 值域的 @ 字段必填(省略 = 新槽写 0 = 静默违约);
771
771
  // 0 ∈ 值域可省。下面 { key } 行能编译即 msg/hp 可省的断言。
772
- EV.encode({ key: gui.MouseKeyFlag.MK_SHIFT })
772
+ EV.encode({ key: MouseKeyFlag.MK_SHIFT })
773
773
  // @ts-expect-error key 必填:省略即编译错(0 ∉ MouseKeyFlag)
774
774
  EV.encode({ msg: 0 })
775
775
  if (false) {
776
776
  // @ts-expect-error 域外字面量(3 不是任何 MK_ 标志)
777
777
  EV.encode({ key: 3 })
778
778
  // @ts-expect-error 跨枚举误用(WmMsg 成员不是 MouseKeyFlag)
779
- EV.encode({ key: gui.WmMsg.CREATE })
779
+ EV.encode({ key: WmMsg.CREATE })
780
780
  }
781
781
 
782
782
  // 数组糖元素带 @:lower 递归归一(normToken 剥 @)+ 元素值域
@@ -74,7 +74,7 @@ export const suite = {
74
74
  if (himl !== 0)
75
75
  t.checkTrue('ImageListDestroy(himl) 成功', ImageListDestroy(himl) !== 0);
76
76
  t.section('user32: LoadImage 双变体(string 自动编码 / ordinal MAKEINTRESOURCE)');
77
- // Win32 IMAGE_* 真值:BITMAP=0 CURSOR=1 ICON=2;LR_SHARED=0x8000(注意 gui.ImageType d.ts 当前值与此不一致)
77
+ // Win32 IMAGE_* 真值:BITMAP=0 CURSOR=1 ICON=2;LR_SHARED=0x8000(注意 ImageType d.ts 当前值与此不一致)
78
78
  t.checkTrue('LoadImageOrdinal(NULL, IDI_APPLICATION, IMAGE_ICON, LR_SHARED) 非 0', LoadImageOrdinal(NULL, 32512, 2, 0, 0, 0x8000) !== 0);
79
79
  t.check('LoadImage(LOADFROMFILE, 不存在文件) → 0', 0, LoadImage(NULL, 'qw_no_such_icon_xyz.ico', 2, 0, 0, 0x10));
80
80
  t.section('user32: 滚动条(入参对象直传 / 出参 encode → call → decode)');
@@ -83,7 +83,7 @@ export const suite = {
83
83
  if (himl !== 0) t.checkTrue('ImageListDestroy(himl) 成功', ImageListDestroy(himl) !== 0)
84
84
 
85
85
  t.section('user32: LoadImage 双变体(string 自动编码 / ordinal MAKEINTRESOURCE)')
86
- // Win32 IMAGE_* 真值:BITMAP=0 CURSOR=1 ICON=2;LR_SHARED=0x8000(注意 gui.ImageType d.ts 当前值与此不一致)
86
+ // Win32 IMAGE_* 真值:BITMAP=0 CURSOR=1 ICON=2;LR_SHARED=0x8000(注意 ImageType d.ts 当前值与此不一致)
87
87
  t.checkTrue('LoadImageOrdinal(NULL, IDI_APPLICATION, IMAGE_ICON, LR_SHARED) 非 0',
88
88
  LoadImageOrdinal(NULL, 32512, 2, 0, 0, 0x8000) !== 0)
89
89
  t.check('LoadImage(LOADFROMFILE, 不存在文件) → 0', 0,
@@ -40,7 +40,7 @@ export const suite = {
40
40
  const pathC = `${dir}\\c.txt`;
41
41
  const pathCn = `${dir}\\中文文件.txt`;
42
42
  t.section('CreateFile + WriteFile: write payload');
43
- const hW = CreateFile(pathA, GENERIC_WRITE, 0, NULL, 2 /* gui.FileCreation.CREATE_ALWAYS */, 0x80 /* FILE_ATTRIBUTE_NORMAL */, NULL);
43
+ const hW = CreateFile(pathA, GENERIC_WRITE, 0, NULL, 2 /* FileCreation.CREATE_ALWAYS */, 0x80 /* FILE_ATTRIBUTE_NORMAL */, NULL);
44
44
  t.checkTrue(`write handle valid (${hW})`, hW !== -1); // 失败 = INVALID_HANDLE_VALUE(-1)
45
45
  const payload = 'hello files';
46
46
  const wData = toWide(payload);
@@ -49,34 +49,34 @@ export const suite = {
49
49
  t.check('bytes written', payload.length * 2, new DataView(pWr).getUint32(0, true));
50
50
  t.checkTrue('CloseHandle (writer)', CloseHandle(hW) !== 0);
51
51
  t.section('CreateFile(READ) + GetFileSize + SetFilePointer + ReadFile');
52
- const hR = CreateFile(pathA, GENERIC_READ, 0, NULL, 3 /* gui.FileCreation.OPEN_EXISTING */, 0x80, NULL);
52
+ const hR = CreateFile(pathA, GENERIC_READ, 0, NULL, 3 /* FileCreation.OPEN_EXISTING */, 0x80, NULL);
53
53
  t.checkTrue(`read handle valid (${hR})`, hR !== -1);
54
54
  t.check('GetFileSize', payload.length * 2, GetFileSize(hR, NULL));
55
- t.check('SetFilePointer BEGIN → 0', 0, SetFilePointer(hR, 0, NULL, 0 /* gui.FileSeekFrom.BEGIN */));
55
+ t.check('SetFilePointer BEGIN → 0', 0, SetFilePointer(hR, 0, NULL, 0 /* FileSeekFrom.BEGIN */));
56
56
  const rData = new PtrArrayBuffer(payload.length * 2);
57
57
  const pRd = new PtrArrayBuffer(4);
58
58
  t.checkTrue('ReadFile ok', ReadFile(hR, rData, payload.length * 2, pRd, NULL) !== 0);
59
59
  t.check('read roundtrip', payload, fromWide(rData, payload.length));
60
60
  // seek 到 END-4 验证负偏移 + 读尾 4 字节
61
- t.check('SetFilePointer END-4', payload.length * 2 - 4, SetFilePointer(hR, -4, NULL, 2 /* gui.FileSeekFrom.END */));
61
+ t.check('SetFilePointer END-4', payload.length * 2 - 4, SetFilePointer(hR, -4, NULL, 2 /* FileSeekFrom.END */));
62
62
  const rTail = new PtrArrayBuffer(8);
63
63
  ReadFile(hR, rTail, 4, pRd, NULL);
64
64
  t.check('seeked tail', payload.slice(-2), fromWide(rTail, 2));
65
65
  CloseHandle(hR);
66
66
  t.section('CopyFile + MoveFileEx + GetFileAttributes');
67
- const hB = CreateFile(pathB, GENERIC_WRITE, 0, NULL, 2 /* gui.FileCreation.CREATE_ALWAYS */, 0x80, NULL);
67
+ const hB = CreateFile(pathB, GENERIC_WRITE, 0, NULL, 2 /* FileCreation.CREATE_ALWAYS */, 0x80, NULL);
68
68
  const bData = toWide('bb');
69
69
  WriteFile(hB, bData, 4, pWr, NULL);
70
70
  CloseHandle(hB);
71
71
  t.checkTrue('CopyFile ok', CopyFile(pathB, pathC, 0) !== 0);
72
- const hC = CreateFile(pathC, GENERIC_READ, 0, NULL, 3 /* gui.FileCreation.OPEN_EXISTING */, 0x80, NULL);
72
+ const hC = CreateFile(pathC, GENERIC_READ, 0, NULL, 3 /* FileCreation.OPEN_EXISTING */, 0x80, NULL);
73
73
  t.check('copied size', 4, GetFileSize(hC, NULL));
74
74
  t.checkTrue('CloseHandle (copy reader)', CloseHandle(hC) !== 0);
75
75
  t.checkTrue('MoveFileEx replace ok', MoveFileEx(pathB, pathC, 0x1 /* MOVEFILE_REPLACE_EXISTING */) !== 0);
76
76
  t.check('moved: source gone', INVALID32, GetFileAttributes(pathB));
77
77
  t.checkTrue('dest is file (not dir)', (GetFileAttributes(pathC) & FILE_ATTRIBUTE_DIRECTORY) === 0);
78
78
  t.section('FindFirstFile/FindNextFile: enumerate *.txt incl. CJK name');
79
- const hCn = CreateFile(pathCn, GENERIC_WRITE, 0, NULL, 2 /* gui.FileCreation.CREATE_ALWAYS */, 0x80, NULL);
79
+ const hCn = CreateFile(pathCn, GENERIC_WRITE, 0, NULL, 2 /* FileCreation.CREATE_ALWAYS */, 0x80, NULL);
80
80
  CloseHandle(hCn); // 0 字节中文名文件
81
81
  const fd = WIN32_FIND_DATAW.alloc();
82
82
  const hFind = FindFirstFile(`${dir}\\a.txt`, fd.ptr);