@tishlang/tish 1.6.0 → 1.8.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 (113) hide show
  1. package/Cargo.toml +2 -0
  2. package/README.md +2 -0
  3. package/bin/tish +0 -0
  4. package/crates/js_to_tish/src/error.rs +2 -8
  5. package/crates/js_to_tish/src/transform/expr.rs +128 -137
  6. package/crates/js_to_tish/src/transform/stmt.rs +62 -32
  7. package/crates/tish/Cargo.toml +15 -5
  8. package/crates/tish/src/cargo_native_registry.rs +29 -0
  9. package/crates/tish/src/cli_help.rs +92 -39
  10. package/crates/tish/src/main.rs +172 -86
  11. package/crates/tish/src/repl_completion.rs +3 -3
  12. package/crates/tish/tests/cargo_example_compile.rs +4 -2
  13. package/crates/tish/tests/integration_test.rs +216 -54
  14. package/crates/tish/tests/run_optimize_stdout_parity.rs +3 -7
  15. package/crates/tish/tests/shortcircuit.rs +20 -5
  16. package/crates/tish_ast/src/ast.rs +92 -23
  17. package/crates/tish_build_utils/Cargo.toml +4 -0
  18. package/crates/tish_build_utils/src/lib.rs +136 -8
  19. package/crates/tish_builtins/Cargo.toml +5 -1
  20. package/crates/tish_builtins/src/array.rs +65 -33
  21. package/crates/tish_builtins/src/construct.rs +34 -39
  22. package/crates/tish_builtins/src/globals.rs +42 -26
  23. package/crates/tish_builtins/src/helpers.rs +2 -1
  24. package/crates/tish_builtins/src/lib.rs +5 -5
  25. package/crates/tish_builtins/src/math.rs +5 -3
  26. package/crates/tish_builtins/src/object.rs +3 -2
  27. package/crates/tish_builtins/src/string.rs +144 -22
  28. package/crates/tish_bytecode/src/chunk.rs +0 -1
  29. package/crates/tish_bytecode/src/compiler.rs +173 -71
  30. package/crates/tish_bytecode/src/opcode.rs +24 -6
  31. package/crates/tish_bytecode/src/peephole.rs +2 -2
  32. package/crates/tish_compile/Cargo.toml +1 -0
  33. package/crates/tish_compile/src/codegen.rs +1621 -453
  34. package/crates/tish_compile/src/infer.rs +75 -19
  35. package/crates/tish_compile/src/lib.rs +19 -8
  36. package/crates/tish_compile/src/resolve.rs +278 -137
  37. package/crates/tish_compile/src/types.rs +184 -24
  38. package/crates/tish_compile_js/Cargo.toml +1 -0
  39. package/crates/tish_compile_js/src/codegen.rs +181 -37
  40. package/crates/tish_compile_js/src/lib.rs +3 -1
  41. package/crates/tish_compile_js/src/tests_jsx.rs +30 -6
  42. package/crates/tish_compiler_wasm/src/lib.rs +16 -13
  43. package/crates/tish_compiler_wasm/src/resolve_virtual.rs +69 -59
  44. package/crates/tish_core/Cargo.toml +8 -0
  45. package/crates/tish_core/src/json.rs +107 -56
  46. package/crates/tish_core/src/lib.rs +4 -2
  47. package/crates/tish_core/src/macros.rs +5 -5
  48. package/crates/tish_core/src/uri.rs +9 -6
  49. package/crates/tish_core/src/value.rs +145 -43
  50. package/crates/tish_core/src/vmref.rs +178 -0
  51. package/crates/tish_cranelift/src/link.rs +6 -9
  52. package/crates/tish_cranelift/src/lower.rs +14 -8
  53. package/crates/tish_eval/Cargo.toml +17 -2
  54. package/crates/tish_eval/src/eval.rs +474 -165
  55. package/crates/tish_eval/src/http.rs +61 -0
  56. package/crates/tish_eval/src/lib.rs +12 -8
  57. package/crates/tish_eval/src/natives.rs +136 -38
  58. package/crates/tish_eval/src/promise.rs +14 -8
  59. package/crates/tish_eval/src/timers.rs +28 -19
  60. package/crates/tish_eval/src/value.rs +17 -6
  61. package/crates/tish_eval/src/value_convert.rs +13 -5
  62. package/crates/tish_fmt/src/lib.rs +149 -43
  63. package/crates/tish_lexer/src/lib.rs +232 -63
  64. package/crates/tish_lexer/src/token.rs +10 -6
  65. package/crates/tish_llvm/src/lib.rs +17 -8
  66. package/crates/tish_lsp/Cargo.toml +4 -1
  67. package/crates/tish_lsp/README.md +1 -1
  68. package/crates/tish_lsp/src/builtin_goto.rs +261 -0
  69. package/crates/tish_lsp/src/import_goto.rs +549 -0
  70. package/crates/tish_lsp/src/main.rs +504 -106
  71. package/crates/tish_native/src/build.rs +4 -8
  72. package/crates/tish_native/src/lib.rs +54 -21
  73. package/crates/tish_opt/src/lib.rs +84 -52
  74. package/crates/tish_parser/src/lib.rs +45 -13
  75. package/crates/tish_parser/src/parser.rs +505 -130
  76. package/crates/tish_resolve/Cargo.toml +13 -0
  77. package/crates/tish_resolve/src/lib.rs +3436 -0
  78. package/crates/tish_resolve/src/pos.rs +133 -0
  79. package/crates/tish_runtime/Cargo.toml +68 -3
  80. package/crates/tish_runtime/src/http.rs +1136 -145
  81. package/crates/tish_runtime/src/http_fetch.rs +38 -27
  82. package/crates/tish_runtime/src/http_hyper.rs +418 -0
  83. package/crates/tish_runtime/src/http_prefork.rs +189 -0
  84. package/crates/tish_runtime/src/lib.rs +375 -189
  85. package/crates/tish_runtime/src/promise.rs +199 -40
  86. package/crates/tish_runtime/src/promise_io.rs +2 -1
  87. package/crates/tish_runtime/src/timers.rs +37 -1
  88. package/crates/tish_runtime/src/ws.rs +65 -42
  89. package/crates/tish_runtime/tests/fetch_readable_stream.rs +5 -4
  90. package/crates/tish_ui/src/jsx.rs +317 -27
  91. package/crates/tish_ui/src/lib.rs +5 -2
  92. package/crates/tish_ui/src/runtime/hooks.rs +406 -45
  93. package/crates/tish_ui/src/runtime/mod.rs +36 -9
  94. package/crates/tish_vm/Cargo.toml +15 -5
  95. package/crates/tish_vm/src/vm.rs +725 -281
  96. package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +11 -4
  97. package/crates/tish_wasm/src/lib.rs +55 -42
  98. package/crates/tish_wasm_runtime/Cargo.toml +2 -1
  99. package/crates/tish_wasm_runtime/src/lib.rs +1 -1
  100. package/crates/tishlang_cargo_bindgen/Cargo.toml +26 -0
  101. package/crates/tishlang_cargo_bindgen/src/classify.rs +265 -0
  102. package/crates/tishlang_cargo_bindgen/src/discover.rs +120 -0
  103. package/crates/tishlang_cargo_bindgen/src/infer.rs +372 -0
  104. package/crates/tishlang_cargo_bindgen/src/lib.rs +350 -0
  105. package/crates/tishlang_cargo_bindgen/src/main.rs +164 -0
  106. package/crates/tishlang_cargo_bindgen/src/metadata.rs +114 -0
  107. package/justfile +8 -0
  108. package/package.json +1 -1
  109. package/platform/darwin-arm64/tish +0 -0
  110. package/platform/darwin-x64/tish +0 -0
  111. package/platform/linux-arm64/tish +0 -0
  112. package/platform/linux-x64/tish +0 -0
  113. package/platform/win32-x64/tish.exe +0 -0
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "tishlang"
3
- version = "1.6.0"
3
+ version = "1.8.0"
4
4
  edition = "2021"
5
5
  description = "Tish CLI - run, REPL, compile to native"
6
6
  license-file = { workspace = true }
@@ -11,12 +11,21 @@ name = "tish"
11
11
  path = "src/main.rs"
12
12
 
13
13
  [features]
14
- # Default: secure mode with no dangerous capabilities
15
- default = []
16
- # Full: all capabilities enabled (for development/trusted environments)
17
- full = ["http", "fs", "process", "regex", "ws"]
14
+ # The published `tish` CLI always includes every optional runtime (http, timers, fs, process, regex, ws).
15
+ # Use `cargo build -p tishlang --no-default-features` when you need a locked-down toolchain
16
+ # (see workspace `justfile`). `tish run --feature …` / `tish build --feature …` gate what runs
17
+ # or what gets linked into a *native output* binary — they are not the primary way to ship a
18
+ # “full” vs “empty” CLI.
19
+ default = ["full"]
20
+ # Alias: same dependency edges as `default` (kept for `--features full` in CI and docs).
21
+ # Includes `pg` so `tish run` can resolve `import … from 'tish-pg'` (`cargo:tish_pg`) on the bytecode VM.
22
+ # Requires `tish-pg` next to this workspace root (`…/tish/tish-pg`); CI runs `scripts/ci/ensure-tish-pg.sh`.
23
+ full = ["http", "fs", "process", "regex", "ws", "timers", "pg"]
24
+ # Opt-out: build without Postgres (`cargo build -p tishlang --no-default-features --features http,...`).
25
+ pg = ["dep:tish_pg"]
18
26
  # Individual capability flags
19
27
  http = ["tishlang_eval/http", "tishlang_runtime/http", "tishlang_compile/http", "tishlang_vm/http"]
28
+ timers = ["tishlang_eval/timers", "tishlang_compile/timers", "tishlang_vm/timers"]
20
29
  fs = ["tishlang_eval/fs", "tishlang_runtime/fs", "tishlang_compile/fs", "tishlang_vm/fs"]
21
30
  process = ["tishlang_eval/process", "tishlang_runtime/process", "tishlang_compile/process", "tishlang_vm/process"]
22
31
  regex = ["tishlang_eval/regex", "tishlang_runtime/regex", "tishlang_compile/regex", "tishlang_vm/regex"]
@@ -40,6 +49,7 @@ tishlang_runtime = { path = "../tish_runtime", version = ">=0.1" }
40
49
  tishlang_core = { path = "../tish_core", version = ">=0.1" }
41
50
  tishlang_js_to_tish = { path = "../js_to_tish", version = ">=0.1" }
42
51
  clap = { version = "4.6.0", features = ["derive", "color"] }
52
+ tish_pg = { path = "../../../tish-pg", package = "tish-pg", optional = true }
43
53
 
44
54
  [dev-dependencies]
45
55
  rayon = "1.11"
@@ -0,0 +1,29 @@
1
+ //! Registers `cargo:*` Rust shims on the bytecode VM (`tish run`, REPL).
2
+ //!
3
+ //! Native `tish build` outputs register their own crates at link time; the
4
+ //! interpreter path must populate [`tishlang_vm::Vm::register_native_module`].
5
+
6
+ #[cfg(feature = "pg")]
7
+ pub(crate) fn register_bytecode_native_modules(vm: &mut tishlang_vm::Vm) {
8
+ use std::sync::Arc;
9
+ use tishlang_core::{ObjectMap, Value};
10
+
11
+ let mut om = ObjectMap::with_capacity(8);
12
+ om.insert(
13
+ Arc::from("per_worker_client"),
14
+ Value::native(tish_pg::per_worker_client),
15
+ );
16
+ om.insert(Arc::from("connect"), Value::native(tish_pg::connect));
17
+ om.insert(Arc::from("prepare"), Value::native(tish_pg::prepare));
18
+ om.insert(
19
+ Arc::from("query_prepared"),
20
+ Value::native(tish_pg::query_prepared),
21
+ );
22
+ om.insert(Arc::from("query_all"), Value::native(tish_pg::query_all));
23
+ om.insert(Arc::from("migrate"), Value::native(tish_pg::migrate));
24
+ om.insert(Arc::from("close"), Value::native(tish_pg::close));
25
+ vm.register_native_module("cargo:tish_pg", om);
26
+ }
27
+
28
+ #[cfg(not(feature = "pg"))]
29
+ pub(crate) fn register_bytecode_native_modules(_vm: &mut tishlang_vm::Vm) {}
@@ -9,7 +9,7 @@ use clap::{CommandFactory, Parser, Subcommand};
9
9
 
10
10
  /// FIGlet-style block letters (UTF-8). On a TTY, a short expand + palette-color animation runs.
11
11
  const TISH_BANNER_LINES: &[&str] = &[
12
- "",
12
+ "",
13
13
  "████████╗██╗███████╗██╗ ██╗",
14
14
  "╚══██╔══╝██║██╔════╝██║ ██║",
15
15
  " ██║ ██║███████╗███████║",
@@ -26,13 +26,13 @@ const BANNER_FRAME_MS: u64 = 20;
26
26
 
27
27
  /// Orange → Yellow → Green → Teal → Blue → Purple → Pink (matching the brand palette).
28
28
  const PALETTE: &[(u8, u8, u8)] = &[
29
- (255, 159, 64), // Orange
30
- (255, 213, 64), // Yellow
31
- ( 52, 199, 89), // Green
32
- ( 48, 209, 188), // Teal
33
- ( 10, 132, 255), // Blue
34
- (175, 82, 222), // Purple
35
- (255, 55, 148), // Pink
29
+ (255, 159, 64), // Orange
30
+ (255, 213, 64), // Yellow
31
+ (52, 199, 89), // Green
32
+ (48, 209, 188), // Teal
33
+ (10, 132, 255), // Blue
34
+ (175, 82, 222), // Purple
35
+ (255, 55, 148), // Pink
36
36
  ];
37
37
 
38
38
  fn ease_out_cubic(t: f32) -> f32 {
@@ -128,8 +128,8 @@ pub fn print_tish_banner() {
128
128
  pub fn build_command() -> clap::Command {
129
129
  Cli::command()
130
130
  .after_help(cli_after_help())
131
- .mut_subcommand("run", |sub| sub.after_help(run_after_help()))
132
- .mut_subcommand("repl", |sub| sub.after_help(repl_after_help()))
131
+ .mut_subcommand("run", |sub| sub.after_help(run_after_help()))
132
+ .mut_subcommand("repl", |sub| sub.after_help(repl_after_help()))
133
133
  .mut_subcommand("build", |sub| sub.after_long_help(build_after_help()))
134
134
  }
135
135
 
@@ -138,7 +138,10 @@ fn count_help_lines(cmd: &mut clap::Command, sub_name: Option<&str>) -> usize {
138
138
  let mut buf = Vec::<u8>::new();
139
139
  if let Some(name) = sub_name {
140
140
  if cmd.find_subcommand(name).is_some() {
141
- let _ = cmd.find_subcommand_mut(name).unwrap().write_long_help(&mut buf);
141
+ let _ = cmd
142
+ .find_subcommand_mut(name)
143
+ .unwrap()
144
+ .write_long_help(&mut buf);
142
145
  } else {
143
146
  let _ = cmd.write_long_help(&mut buf);
144
147
  }
@@ -236,8 +239,11 @@ pub fn print_banner_with_help(argv: &[String]) {
236
239
  let mut out = io::stdout().lock();
237
240
  write_tish_banner_frame(&mut out, 1.0, 0);
238
241
  let _ = writeln!(out); // blank separator (row n+1)
239
- // ── Manual prefix (MAIN_PREFIX_LINES = 4 lines) ──────────────────
240
- let _ = writeln!(out, "{H_PURPLE}Tish{H_RESET} {H_GREY}(version {VERSION}){H_RESET}");
242
+ // ── Manual prefix (MAIN_PREFIX_LINES = 4 lines) ──────────────────
243
+ let _ = writeln!(
244
+ out,
245
+ "{H_PURPLE}Tish{H_RESET} {H_GREY}(version {VERSION}){H_RESET}"
246
+ );
241
247
  let _ = writeln!(out, "Minimal TS/JS-ish language");
242
248
  let _ = writeln!(out, "{H_PINK}https://tishlang.com{H_RESET}");
243
249
  let _ = writeln!(out); // blank before Usage
@@ -289,20 +295,24 @@ fn rgb_bold(r: u8, g: u8, b: u8) -> Style {
289
295
  /// Orange → section headers / usage. Teal → literals (commands, flags). Yellow → placeholders.
290
296
  pub fn cargo_help_styles() -> Styles {
291
297
  Styles::styled()
292
- .header(rgb_bold(255, 159, 64)) // Orange – "Commands:", "Options:", "Usage:"
293
- .usage(rgb_bold(255, 159, 64)) // Orange
294
- .literal(rgb_bold( 48, 209, 188)) // Teal – run, repl, --help, -V …
295
- .placeholder(rgb_bold(255, 213, 64)) // Yellow – <FILE>, <NAME>, …
296
- .error(rgb_bold(255, 55, 148)) // Pink – error messages
297
- .valid(rgb_bold( 52, 199, 89)) // Green – valid values
298
- .invalid(rgb_bold(255, 55, 148)) // Pink – invalid values
298
+ .header(rgb_bold(255, 159, 64)) // Orange – "Commands:", "Options:", "Usage:"
299
+ .usage(rgb_bold(255, 159, 64)) // Orange
300
+ .literal(rgb_bold(48, 209, 188)) // Teal – run, repl, --help, -V …
301
+ .placeholder(rgb_bold(255, 213, 64)) // Yellow – <FILE>, <NAME>, …
302
+ .error(rgb_bold(255, 55, 148)) // Pink – error messages
303
+ .valid(rgb_bold(52, 199, 89)) // Green – valid values
304
+ .invalid(rgb_bold(255, 55, 148)) // Pink – invalid values
299
305
  }
300
306
 
301
307
  /// Returns the colored `after_help` text for the top-level `tish --help`.
302
308
  /// Colors are emitted only when stdout is a TTY.
303
309
  pub fn cli_after_help() -> String {
304
310
  let (oh, t, r) = if io::stdout().is_terminal() {
305
- ("\x1b[1;38;2;255;159;64m", "\x1b[1;38;2;48;209;188m", "\x1b[0m")
311
+ (
312
+ "\x1b[1;38;2;255;159;64m",
313
+ "\x1b[1;38;2;48;209;188m",
314
+ "\x1b[0m",
315
+ )
306
316
  } else {
307
317
  ("", "", "")
308
318
  };
@@ -327,7 +337,9 @@ fn capabilities_section(oh: &str, t: &str, r: &str) -> String {
327
337
 
328
338
  {oh}Capabilities{r} (--feature, repeatable; comma-separated values are split):
329
339
  {t}http{r}
330
- Network: fetch, serve, Promise / timers (native async)
340
+ Network: fetch, fetchAll, serve, Promise (and `await`); enabling http also enables timers
341
+ {t}timers{r}
342
+ setTimeout, setInterval, clearTimeout, clearInterval (global + `import from \"timers\"` / tish:timers)
331
343
  {t}fs{r}
332
344
  Filesystem: readFile, writeFile, fileExists, isDir, readDir, mkdir
333
345
  {t}process{r}
@@ -337,16 +349,20 @@ fn capabilities_section(oh: &str, t: &str, r: &str) -> String {
337
349
  {t}ws{r}
338
350
  WebSocket client / server
339
351
  {t}full{r}
340
- All of the above (http, fs, process, regex, ws)
352
+ All of the above (http, timers, fs, process, regex, ws)
341
353
 
342
- Omit --feature to use every capability linked into this binary."
354
+ Omit --feature to allow every capability compiled into this `tish` binary; pass flags to restrict what scripts may use. The CLI is normally built with all of them (Cargo default on `tishlang`)."
343
355
  )
344
356
  }
345
357
 
346
358
  /// Returns the colored `after_help` for `tish run --help`.
347
359
  pub fn run_after_help() -> String {
348
360
  let (oh, t, r) = if io::stdout().is_terminal() {
349
- ("\x1b[1;38;2;255;159;64m", "\x1b[1;38;2;48;209;188m", "\x1b[0m")
361
+ (
362
+ "\x1b[1;38;2;255;159;64m",
363
+ "\x1b[1;38;2;48;209;188m",
364
+ "\x1b[0m",
365
+ )
350
366
  } else {
351
367
  ("", "", "")
352
368
  };
@@ -356,7 +372,11 @@ pub fn run_after_help() -> String {
356
372
  /// Returns the colored `after_help` for `tish repl --help`.
357
373
  pub fn repl_after_help() -> String {
358
374
  let (oh, t, r) = if io::stdout().is_terminal() {
359
- ("\x1b[1;38;2;255;159;64m", "\x1b[1;38;2;48;209;188m", "\x1b[0m")
375
+ (
376
+ "\x1b[1;38;2;255;159;64m",
377
+ "\x1b[1;38;2;48;209;188m",
378
+ "\x1b[0m",
379
+ )
360
380
  } else {
361
381
  ("", "", "")
362
382
  };
@@ -366,7 +386,11 @@ pub fn repl_after_help() -> String {
366
386
  /// Returns the colored `after_long_help` for `tish build --help`.
367
387
  pub fn build_after_help() -> String {
368
388
  let (oh, t, r) = if io::stdout().is_terminal() {
369
- ("\x1b[1;38;2;255;159;64m", "\x1b[1;38;2;48;209;188m", "\x1b[0m")
389
+ (
390
+ "\x1b[1;38;2;255;159;64m",
391
+ "\x1b[1;38;2;48;209;188m",
392
+ "\x1b[0m",
393
+ )
370
394
  } else {
371
395
  ("", "", "")
372
396
  };
@@ -392,7 +416,9 @@ pub fn build_after_help() -> String {
392
416
 
393
417
  {oh}Capabilities{r} (--feature, repeatable; comma-separated values are split):
394
418
  {t}http{r}
395
- Network: fetch, serve, Promise / timers (native async)
419
+ Network: fetch, fetchAll, serve, Promise (and `await`); enabling http also enables timers
420
+ {t}timers{r}
421
+ setTimeout, setInterval, clearTimeout, clearInterval (global + `import from \"timers\"` / tish:timers)
396
422
  {t}fs{r}
397
423
  Filesystem: readFile, writeFile, fileExists, isDir, readDir, mkdir
398
424
  {t}process{r}
@@ -402,10 +428,9 @@ pub fn build_after_help() -> String {
402
428
  {t}ws{r}
403
429
  WebSocket client / server
404
430
  {t}full{r}
405
- All of the above (http, fs, process, regex, ws)
431
+ All of the above (http, timers, fs, process, regex, ws)
406
432
 
407
- Omit --feature to use every capability linked into this binary.
408
- Build `tish` with matching Cargo features (e.g. cargo build -p tishlang --features full)."
433
+ For `--target native`, these choose what is linked into the **output** executable (omit = same set as this `tish` binary was built with). Minimal native outputs still use a full `tish` CLI unless you built it with `cargo build -p tishlang --no-default-features`."
409
434
  )
410
435
  }
411
436
 
@@ -421,12 +446,22 @@ pub(crate) struct Cli {
421
446
  #[derive(Parser)]
422
447
  pub(crate) struct RunArgs {
423
448
  /// Path to a `.tish` file, or `-` to read the program from stdin (like `node -`).
424
- #[arg(required = true, allow_hyphen_values = true, value_name = "FILE", help_heading = "Arguments")]
449
+ #[arg(
450
+ required = true,
451
+ allow_hyphen_values = true,
452
+ value_name = "FILE",
453
+ help_heading = "Arguments"
454
+ )]
425
455
  pub file: String,
426
456
  /// `vm` or `interp` (see `tish --help` for capabilities / `--feature`).
427
- #[arg(long, default_value = "vm", value_name = "NAME", help_heading = "Options")]
457
+ #[arg(
458
+ long,
459
+ default_value = "vm",
460
+ value_name = "NAME",
461
+ help_heading = "Options"
462
+ )]
428
463
  pub backend: String,
429
- /// Subset of capabilities (see `tish --help` for the full list).
464
+ /// Restrict which platform APIs the script may use (omit = all capabilities compiled into this `tish`).
430
465
  #[arg(
431
466
  long = "feature",
432
467
  value_name = "NAME",
@@ -442,9 +477,14 @@ pub(crate) struct RunArgs {
442
477
  #[derive(Parser)]
443
478
  pub(crate) struct ReplArgs {
444
479
  /// `vm` or `interp` (see `tish --help`).
445
- #[arg(long, default_value = "vm", value_name = "NAME", help_heading = "Options")]
480
+ #[arg(
481
+ long,
482
+ default_value = "vm",
483
+ value_name = "NAME",
484
+ help_heading = "Options"
485
+ )]
446
486
  pub backend: String,
447
- /// Subset of capabilities (see `tish --help` for the full list).
487
+ /// Restrict which platform APIs the REPL may use (omit = all capabilities compiled into this `tish`).
448
488
  #[arg(
449
489
  long = "feature",
450
490
  value_name = "NAME",
@@ -467,12 +507,22 @@ pub(crate) struct BuildArgs {
467
507
  )]
468
508
  pub output: String,
469
509
  /// `native`, `js`, `wasm`, or `wasi` (see long help below).
470
- #[arg(long, default_value = "native", value_name = "TARGET", help_heading = "Options")]
510
+ #[arg(
511
+ long,
512
+ default_value = "native",
513
+ value_name = "TARGET",
514
+ help_heading = "Options"
515
+ )]
471
516
  pub target: String,
472
517
  /// `rust`, `cranelift`, or `llvm` (only for `--target native`).
473
- #[arg(long, default_value = "rust", value_name = "BACKEND", help_heading = "Options")]
518
+ #[arg(
519
+ long,
520
+ default_value = "rust",
521
+ value_name = "BACKEND",
522
+ help_heading = "Options"
523
+ )]
474
524
  pub native_backend: String,
475
- /// Capability subset for native output (see long help below).
525
+ /// For `--target native`: which capabilities to link into the produced binary (omit = same as this `tish`; see long help).
476
526
  #[arg(
477
527
  long = "feature",
478
528
  value_name = "NAME",
@@ -482,6 +532,9 @@ pub(crate) struct BuildArgs {
482
532
  pub features: Vec<String>,
483
533
  #[arg(long, help_heading = "Options")]
484
534
  pub no_optimize: bool,
535
+ /// For `--target js` project builds: emit `OUTPUT.js.map` and `//# sourceMappingURL=…` so JS/TS tools can jump to original `.tish` (implies `--no-optimize` for that build).
536
+ #[arg(long, help_heading = "Options")]
537
+ pub source_map: bool,
485
538
  /// Entry `.tish` file (or `.js` where supported).
486
539
  #[arg(required = true, value_name = "FILE", help_heading = "Arguments")]
487
540
  pub file: String,