quickwin 2.1.0 → 2.1.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/README.en.md CHANGED
@@ -41,7 +41,7 @@ quickwin script.js # run a script
41
41
  quickwin -o CON script.js # run with console (AllocConsole)
42
42
  quickwin -o LOG script.js # run with auto-generated log file
43
43
  quickwin -e "console.log('hi')" # execute expression
44
- quickwin -- script.js --flag # -- stops option parsing
44
+ quickwin script.js --flag # everything after the script goes to it
45
45
  ```
46
46
 
47
47
  ### Options
@@ -53,10 +53,10 @@ quickwin -- script.js --flag # -- stops option parsing
53
53
  | `-o LOG` | Redirect stdout+stderr to `log_YYYY_MM_DD_HH_MM_SS.txt` (exe directory) |
54
54
  | `-o <file>` | Redirect stdout+stderr to specified file |
55
55
  | `-d` | Enable HTTP debug logging |
56
- | `--` | Stop option parsing, remaining args passed to script |
57
56
 
58
- All unknown flags are transparently forwarded to `scriptArgs` — no error,
59
- no consumption. Script file is the first non-flag argument after option parsing.
57
+ The command line parses in fixed slots: `exe [-d] [-o target] [-e code | file]`;
58
+ everything past the slots reaches `scriptArgs` untouched — no error, no
59
+ consumption. The file slot rejects `-`-leading names (run those as `./-name.js`).
60
60
 
61
61
  ## Embedded Script
62
62
 
package/README.md CHANGED
@@ -41,7 +41,7 @@ quickwin script.js # 运行脚本
41
41
  quickwin -o CON script.js # 带控制台运行(AllocConsole)
42
42
  quickwin -o LOG script.js # 自动生成日志文件运行
43
43
  quickwin -e "console.log('hi')" # 执行表达式
44
- quickwin -- script.js --flag # -- 停止选项解析
44
+ quickwin script.js --flag # 槽位之后的参数全部传给脚本
45
45
  ```
46
46
 
47
47
  ### 选项
@@ -53,9 +53,8 @@ quickwin -- script.js --flag # -- 停止选项解析
53
53
  | `-o LOG` | 将 stdout+stderr 重定向到 `log_YYYY_MM_DD_HH_MM_SS.txt`(exe 所在目录) |
54
54
  | `-o <file>` | 将 stdout+stderr 重定向到指定文件 |
55
55
  | `-d` | 开启 HTTP 调试日志 |
56
- | `--` | 停止选项解析,其余参数传给脚本 |
57
56
 
58
- 所有未知参数都会透明转发给 `scriptArgs` —— 不报错、不消费。选项解析后的第一个非参数即脚本文件。
57
+ 命令行按固定槽位解析:`exe [-d] [-o 目标] [-e code | 脚本文件]`;槽位之后的所有参数原样进入 `scriptArgs`,不报错、不消费。文件槽不接受 `-` 开头的文件名(用 `./-name.js` 运行这类脚本)。
59
58
 
60
59
  ## 内嵌脚本
61
60
 
@@ -21804,15 +21804,19 @@ function parseArgs() {
21804
21804
  let gui19 = true;
21805
21805
  let token = null;
21806
21806
  const args = typeof scriptArgs === "undefined" ? [] : scriptArgs;
21807
+ const normToken2 = (v2) => v2 === "" ? null : v2;
21807
21808
  for (let i2 = 0; i2 < args.length; i2++) {
21808
21809
  const a2 = args[i2] ?? "";
21809
21810
  if (a2 === "--nogui") {
21810
21811
  gui19 = false;
21812
+ } else if (a2 === "--gui") {
21813
+ gui19 = (args[++i2] ?? "") !== "0";
21811
21814
  } else if (a2.startsWith("--gui=")) {
21812
21815
  gui19 = a2.slice(6) !== "0";
21816
+ } else if (a2 === "--token") {
21817
+ token = normToken2(args[++i2] ?? "");
21813
21818
  } else if (a2.startsWith("--token=")) {
21814
- const v2 = a2.slice(8);
21815
- token = v2 === "" ? null : v2;
21819
+ token = normToken2(a2.slice(8));
21816
21820
  }
21817
21821
  }
21818
21822
  return { gui: gui19, token };
@@ -25,22 +25,21 @@ interface Cfg {
25
25
  token: string | null
26
26
  }
27
27
 
28
- // 只支持无值开关(--nogui)与等号形式(--gui=0/--token=x)。
29
- // 不支持空格分隔值形式 "--gui 0"/"--token x":main.c 的 js_file 探测(main.c:214-250)
30
- // 会把裸值("0"/"x")当成脚本文件名,进程启动即 Failed to load 退出(见 .agents/TODO.md)。
28
+ // 参数经 scriptArgs 透传:C 层只消费 -e/-o/-d,遇到未知选项即停止
29
+ // 解析并把剩余全部交给脚本(见 main.c 参数解析段)。因此空格分隔
30
+ // ("--gui 0") 与等号 ("--gui=0") 两种形式都由本函数自行解析。
31
31
  function parseArgs(): Cfg {
32
32
  let gui = true
33
33
  let token: string | null = null
34
34
  const args = typeof scriptArgs === 'undefined' ? [] : scriptArgs
35
+ const normToken = (v: string) => (v === '' ? null : v) // 空串=未配置(放行)
35
36
  for (let i = 0; i < args.length; i++) {
36
37
  const a = args[i] ?? ''
37
38
  if (a === '--nogui') { gui = false }
39
+ else if (a === '--gui') { gui = (args[++i] ?? '') !== '0' }
38
40
  else if (a.startsWith('--gui=')) { gui = a.slice(6) !== '0' }
39
- else if (a.startsWith('--token=')) {
40
- // 空串归一为 null(未配置放行):要求 Bearer 空串的"鉴权"无意义
41
- const v = a.slice(8)
42
- token = v === '' ? null : v
43
- }
41
+ else if (a === '--token') { token = normToken(args[++i] ?? '') }
42
+ else if (a.startsWith('--token=')) { token = normToken(a.slice(8)) }
44
43
  }
45
44
  return { gui, token }
46
45
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "quickwin",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "description": "QuickJS Win32 runtime — GUI, networking, WASM, FFI, and more",
6
6
  "bin": {
7
7
  "quickwin": "qwin.exe",
Binary file
package/qwin-nowasm.exe CHANGED
Binary file
package/qwin-x86.exe CHANGED
Binary file
package/qwin.exe CHANGED
Binary file