xw-devtool-cli 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,6 +21,7 @@
21
21
  > 2. 由于涉及跨进程通信,按下空格后可能存在轻微延时,请耐心等待结果。
22
22
  > 3. 取色模式下会显示全屏十字辅助线,按 **回车键** 退出模式。
23
23
  - **占位图生成**:快速生成指定尺寸、颜色、文字的占位图片 (Placeholder Image)。
24
+ - **全屏十字辅助线**:显示跟随鼠标的全屏红色十字线,用于屏幕对齐和定位。
24
25
  - **Mock 数据生成**:
25
26
  - 支持生成:英文段落 (Lorem Ipsum)、中文字符、中国居民身份证号、电子邮箱、URL、订单号、手机号、座机号。
26
27
  - 支持批量生成。
package/README_EN.md CHANGED
@@ -16,6 +16,7 @@ Key features include: Base64 encoding/decoding, image format conversion, image <
16
16
  - **Placeholder Image**: Quickly generate placeholder images with custom size, color, and text.
17
17
  - **Color Picker**: Pick a single pixel color or area average from an image; supports px/% coordinates; shows preview bar and auto-copies Hex/Hex8.
18
18
  - **Screen Picker**: Pick color directly from the screen at the mouse position; move the cursor and press Enter to sample; supports alpha preview.
19
+ - **Screen Crosshair**: Display a full-screen red crosshair following the mouse for alignment.
19
20
  - **Mock Data**:
20
21
  - Generate: Lorem Ipsum, Chinese characters, ID cards, Emails, URLs, Order IDs, Phone numbers.
21
22
  - Supports batch generation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xw-devtool-cli",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "type": "module",
5
5
  "description": "基于node的开发者助手cli",
6
6
  "main": "index.js",
@@ -0,0 +1,94 @@
1
+ import { spawn } from 'child_process';
2
+ import i18next from '../i18n.js';
3
+
4
+ export async function crosshairHandler() {
5
+ if (process.platform !== 'win32') {
6
+ console.log(i18next.t('crosshair.notSupported'));
7
+ return;
8
+ }
9
+
10
+ console.log(i18next.t('crosshair.startPrompt'));
11
+
12
+ const overlayScript = `
13
+ Add-Type -AssemblyName System.Windows.Forms; Add-Type -AssemblyName System.Drawing;
14
+ Add-Type -TypeDefinition @'
15
+ using System;
16
+ using System.Drawing;
17
+ using System.Windows.Forms;
18
+ using System.Runtime.InteropServices;
19
+ public class OverlayForm : Form {
20
+ const int WS_EX_TRANSPARENT=0x20;
21
+ const int WS_EX_LAYERED=0x80000;
22
+ const int GWL_EXSTYLE=-20;
23
+ [DllImport("user32.dll")] static extern int GetWindowLong(IntPtr hWnd, int nIndex);
24
+ [DllImport("user32.dll")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
25
+ Timer t;
26
+ public OverlayForm(){
27
+ this.FormBorderStyle=FormBorderStyle.None;
28
+ this.TopMost=true;
29
+ this.ShowInTaskbar=false;
30
+ this.WindowState=FormWindowState.Maximized;
31
+ this.BackColor=Color.Fuchsia;
32
+ this.TransparencyKey=this.BackColor;
33
+ this.DoubleBuffered=true;
34
+ this.Cursor = Cursors.Default;
35
+ }
36
+ protected override void OnShown(EventArgs e){
37
+ base.OnShown(e);
38
+ int ex=GetWindowLong(this.Handle,GWL_EXSTYLE);
39
+ SetWindowLong(this.Handle,GWL_EXSTYLE,ex|WS_EX_LAYERED|WS_EX_TRANSPARENT);
40
+ t=new Timer();
41
+ t.Interval=16;
42
+ t.Tick+=(s,ev)=>{ this.Invalidate(); };
43
+ t.Start();
44
+ }
45
+ protected override void OnPaint(PaintEventArgs e){
46
+ var p=Cursor.Position;
47
+ var g=e.Graphics;
48
+ using(var pen=new Pen(Color.Red,1)){
49
+ g.DrawLine(pen,0,p.Y,this.Width,p.Y);
50
+ g.DrawLine(pen,p.X,0,p.X,this.Height);
51
+ }
52
+ }
53
+ }
54
+ public static class Entry {
55
+ public static void Main(){ Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new OverlayForm()); }
56
+ }
57
+ '@ -ReferencedAssemblies System.Windows.Forms,System.Drawing;
58
+ [Entry]::Main()
59
+ `;
60
+
61
+ const overlay = spawn('powershell', ['-NoProfile', '-Command', overlayScript], { windowsHide: true });
62
+
63
+ // Handle exit
64
+ const cleanup = () => {
65
+ if (overlay && !overlay.killed) {
66
+ try {
67
+ overlay.kill();
68
+ } catch (e) {
69
+ // ignore
70
+ }
71
+ }
72
+ };
73
+
74
+ // Ensure cleanup on process exit
75
+ const exitHandler = () => cleanup();
76
+ process.once('exit', exitHandler);
77
+ process.once('SIGINT', exitHandler);
78
+
79
+ await new Promise((resolve) => {
80
+ const stdin = process.stdin;
81
+ try { stdin.setRawMode(true); } catch {}
82
+ stdin.resume();
83
+ const onData = (data) => {
84
+ stdin.removeListener('data', onData);
85
+ try { stdin.setRawMode(false); } catch {}
86
+ stdin.pause();
87
+ process.removeListener('exit', exitHandler);
88
+ process.removeListener('SIGINT', exitHandler);
89
+ cleanup();
90
+ resolve();
91
+ };
92
+ stdin.once('data', onData);
93
+ });
94
+ }
package/src/index.js CHANGED
@@ -29,6 +29,7 @@ import { markdownHandler } from './commands/markdown.js';
29
29
  import { vscodeSnippetHandler } from './commands/vscodeSnippet.js';
30
30
  import { dominantColorHandler } from './commands/dominantColor.js';
31
31
  import { colorPickHandler } from './commands/colorPick.js';
32
+ import { crosshairHandler } from './commands/crosshair.js';
32
33
 
33
34
  process.on('SIGINT', () => {
34
35
  console.log(`\n${i18next.t('menu.bye')}`);
@@ -53,6 +54,7 @@ function getFeatures() {
53
54
  { name: i18next.t('menu.features.imgSplit'), value: 'imgSplit' },
54
55
  { name: i18next.t('menu.features.dominantColor'), value: 'dominantColor' },
55
56
  { name: i18next.t('menu.features.colorPick'), value: 'colorPick' },
57
+ { name: i18next.t('menu.features.crosshair'), value: 'crosshair' },
56
58
  { name: i18next.t('menu.features.placeholderImg'), value: 'placeholderImg' },
57
59
  { name: i18next.t('menu.features.qrcode'), value: 'qrcode' },
58
60
 
@@ -194,6 +196,9 @@ async function handleAction(action) {
194
196
  case 'colorPick':
195
197
  await colorPickHandler();
196
198
  break;
199
+ case 'crosshair':
200
+ await crosshairHandler();
201
+ break;
197
202
  case 'timeFormat':
198
203
  await timeFormatHandler();
199
204
  break;
package/src/locales/en.js CHANGED
@@ -14,6 +14,7 @@ export default {
14
14
  imgSplit: 'Image Splitter',
15
15
  dominantColor: 'Image Dominant Color',
16
16
  colorPick: 'Color Picker',
17
+ crosshair: 'Screen Crosshair',
17
18
  placeholderImg: 'Placeholder Image Generator',
18
19
  qrcode: 'QR Code Generator',
19
20
  url: 'URL Encode/Decode',
package/src/locales/zh.js CHANGED
@@ -2,6 +2,10 @@ export default {
2
2
  common: {
3
3
  back: '返回上一步'
4
4
  },
5
+ crosshair: {
6
+ notSupported: '当前系统不支持屏幕辅助线。',
7
+ startPrompt: '屏幕十字辅助线已启动。按任意键退出...'
8
+ },
5
9
  menu: {
6
10
  title: 'xw-devtool-cli 菜单',
7
11
  exit: '退出',
@@ -14,6 +18,7 @@ export default {
14
18
  imgSplit: '图片分割工具',
15
19
  dominantColor: '图片主色识别',
16
20
  colorPick: '颜色吸取',
21
+ crosshair: '全屏十字辅助线',
17
22
  placeholderImg: '占位图生成器',
18
23
  qrcode: '二维码生成器',
19
24
  url: 'URL 编码/解码',