@tishlang/tish 1.9.2 → 1.12.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 (84) hide show
  1. package/bin/tish +0 -0
  2. package/crates/js_to_tish/src/transform/expr.rs +8 -6
  3. package/crates/js_to_tish/src/transform/stmt.rs +12 -13
  4. package/crates/tish/Cargo.toml +1 -1
  5. package/crates/tish/src/cargo_native_registry.rs +4 -1
  6. package/crates/tish/src/cli_help.rs +9 -1
  7. package/crates/tish/src/main.rs +66 -11
  8. package/crates/tish/tests/integration_test.rs +145 -7
  9. package/crates/tish_ast/src/ast.rs +3 -9
  10. package/crates/tish_build_utils/src/lib.rs +74 -23
  11. package/crates/tish_builtins/src/array.rs +2 -3
  12. package/crates/tish_builtins/src/construct.rs +15 -28
  13. package/crates/tish_builtins/src/globals.rs +18 -16
  14. package/crates/tish_builtins/src/helpers.rs +1 -4
  15. package/crates/tish_builtins/src/lib.rs +1 -0
  16. package/crates/tish_builtins/src/math.rs +7 -0
  17. package/crates/tish_builtins/src/object.rs +10 -10
  18. package/crates/tish_builtins/src/string.rs +27 -3
  19. package/crates/tish_builtins/src/symbol.rs +83 -0
  20. package/crates/tish_compile/src/codegen.rs +324 -158
  21. package/crates/tish_compile/src/lib.rs +39 -7
  22. package/crates/tish_compile/src/resolve.rs +191 -6
  23. package/crates/tish_compile/src/types.rs +6 -6
  24. package/crates/tish_compile_js/src/codegen.rs +8 -5
  25. package/crates/tish_core/src/console_style.rs +9 -0
  26. package/crates/tish_core/src/json.rs +17 -7
  27. package/crates/tish_core/src/macros.rs +2 -2
  28. package/crates/tish_core/src/value.rs +213 -4
  29. package/crates/tish_cranelift/src/link.rs +1 -1
  30. package/crates/tish_cranelift_runtime/Cargo.toml +4 -0
  31. package/crates/tish_eval/src/eval.rs +135 -73
  32. package/crates/tish_eval/src/http.rs +18 -12
  33. package/crates/tish_eval/src/lib.rs +29 -0
  34. package/crates/tish_eval/src/regex.rs +1 -1
  35. package/crates/tish_eval/src/value.rs +89 -4
  36. package/crates/tish_eval/src/value_convert.rs +30 -8
  37. package/crates/tish_fmt/src/lib.rs +4 -1
  38. package/crates/tish_lexer/src/lib.rs +7 -2
  39. package/crates/tish_llvm/src/lib.rs +2 -2
  40. package/crates/tish_lsp/src/builtin_goto.rs +111 -10
  41. package/crates/tish_lsp/src/import_goto.rs +35 -22
  42. package/crates/tish_lsp/src/main.rs +118 -85
  43. package/crates/tish_native/src/build.rs +270 -24
  44. package/crates/tish_native/src/config.rs +48 -0
  45. package/crates/tish_native/src/lib.rs +139 -12
  46. package/crates/tish_parser/src/lib.rs +5 -2
  47. package/crates/tish_parser/src/parser.rs +45 -75
  48. package/crates/tish_pg/src/error.rs +1 -1
  49. package/crates/tish_pg/src/lib.rs +61 -73
  50. package/crates/tish_resolve/src/lib.rs +283 -158
  51. package/crates/tish_resolve/src/pos.rs +10 -2
  52. package/crates/tish_runtime/Cargo.toml +3 -0
  53. package/crates/tish_runtime/src/http.rs +39 -39
  54. package/crates/tish_runtime/src/http_fetch.rs +12 -12
  55. package/crates/tish_runtime/src/lib.rs +35 -44
  56. package/crates/tish_runtime/src/native_promise.rs +0 -11
  57. package/crates/tish_runtime/src/promise.rs +14 -1
  58. package/crates/tish_runtime/src/promise_io.rs +1 -4
  59. package/crates/tish_runtime/src/timers.rs +12 -7
  60. package/crates/tish_runtime/src/ws.rs +40 -27
  61. package/crates/tish_runtime/tests/fetch_readable_stream.rs +10 -8
  62. package/crates/tish_ui/src/jsx.rs +6 -4
  63. package/crates/tish_ui/src/lib.rs +5 -4
  64. package/crates/tish_ui/src/runtime/hooks.rs +123 -37
  65. package/crates/tish_ui/src/runtime/mod.rs +21 -41
  66. package/crates/tish_vm/Cargo.toml +2 -0
  67. package/crates/tish_vm/src/vm.rs +258 -153
  68. package/crates/tish_wasm/src/lib.rs +60 -7
  69. package/crates/tish_wasm_runtime/Cargo.toml +10 -1
  70. package/crates/tish_wasm_runtime/src/gpu.rs +413 -0
  71. package/crates/tish_wasm_runtime/src/lib.rs +7 -1
  72. package/crates/tishlang_cargo_bindgen/src/classify.rs +1 -3
  73. package/crates/tishlang_cargo_bindgen/src/discover.rs +10 -5
  74. package/crates/tishlang_cargo_bindgen/src/infer.rs +18 -8
  75. package/crates/tishlang_cargo_bindgen/src/lib.rs +25 -26
  76. package/crates/tishlang_cargo_bindgen/src/main.rs +41 -38
  77. package/crates/tishlang_cargo_bindgen/src/metadata.rs +4 -1
  78. package/justfile +3 -3
  79. package/package.json +1 -1
  80. package/platform/darwin-arm64/tish +0 -0
  81. package/platform/darwin-x64/tish +0 -0
  82. package/platform/linux-arm64/tish +0 -0
  83. package/platform/linux-x64/tish +0 -0
  84. package/platform/win32-x64/tish.exe +0 -0
@@ -2,20 +2,23 @@
2
2
 
3
3
  mod hooks;
4
4
 
5
- use std::cell::RefCell;
6
- use std::rc::Rc;
7
5
  use std::sync::Arc;
8
6
 
9
7
  pub use hooks::{
10
- alloc_root_id, current_root_id, drop_host_for_root, install_host_for_root, native_create_root,
11
- native_use_effect, native_use_memo, native_use_state, run_with_current_root, schedule_flush,
12
- unregister_root, unregister_root_hooks_and_effects, with_host_for_root, HookState,
13
- LEGACY_ROOT_ID, RootId,
8
+ alloc_root_id, current_root_id, drop_host_for_root, install_host_for_root,
9
+ install_thread_local_host, native_create_root,
10
+ native_use_effect, native_use_layout_effect, native_use_memo, native_use_ref,
11
+ native_use_state, run_with_current_root,
12
+ schedule_flush,
13
+ unregister_root, unregister_root_hooks_and_effects, with_host_for_root,
14
+ with_thread_local_host, HookState, RootId, LEGACY_ROOT_ID,
14
15
  };
15
16
 
16
17
  use tishlang_core::{ObjectMap, Value, VmRef};
17
18
 
18
- /// Sentinel string for `Fragment` (native). JS/Lattish uses `Symbol`; hosts compare via equality.
19
+ /// Sentinel string for `Fragment` (native). Full runtimes may also use `Symbol.for("tish.fragment")`
20
+ /// when the global `Symbol` is present; [`is_fragment_tag`] accepts both that registry symbol and
21
+ /// this string for compatibility.
19
22
  pub const FRAGMENT_SENTINEL: &str = "__tish_ui_Fragment__";
20
23
 
21
24
  /// `Fragment` marker value for `h(Fragment, null, children)`.
@@ -25,7 +28,11 @@ pub fn fragment_value() -> Value {
25
28
 
26
29
  /// Returns true if `tag` refers to [`fragment_value`].
27
30
  pub fn is_fragment_tag(tag: &Value) -> bool {
28
- matches!(tag, Value::String(s) if s.as_ref() == FRAGMENT_SENTINEL)
31
+ match tag {
32
+ Value::String(s) => s.as_ref() == FRAGMENT_SENTINEL,
33
+ Value::Symbol(s) => s.registry_key.as_deref() == Some("tish.fragment"),
34
+ _ => false,
35
+ }
29
36
  }
30
37
 
31
38
  /// `text(s)` helper — returns string as `Value::String` for JSX text nodes.
@@ -49,7 +56,7 @@ pub fn ui_h(args: &[Value]) -> Value {
49
56
  let mut merged = if matches!(props, Value::Null) {
50
57
  ObjectMap::default()
51
58
  } else if let Value::Object(obj) = props {
52
- obj.borrow().clone()
59
+ obj.borrow().strings.clone()
53
60
  } else {
54
61
  ObjectMap::default()
55
62
  };
@@ -59,7 +66,7 @@ pub fn ui_h(args: &[Value]) -> Value {
59
66
  Value::Array(VmRef::new(children_vec.clone())),
60
67
  );
61
68
  }
62
- return f(&[Value::Object(VmRef::new(merged))]);
69
+ return f(&[Value::object(merged)]);
63
70
  }
64
71
 
65
72
  if is_fragment_tag(&tag) {
@@ -107,24 +114,18 @@ fn vnode_element(tag: Arc<str>, props: Value, children: Vec<Value>) -> Value {
107
114
  props
108
115
  },
109
116
  );
110
- m.insert(
111
- Arc::from("children"),
112
- Value::Array(VmRef::new(children)),
113
- );
117
+ m.insert(Arc::from("children"), Value::Array(VmRef::new(children)));
114
118
  m.insert(Arc::from("_el"), Value::Null);
115
- Value::Object(VmRef::new(m))
119
+ Value::object(m)
116
120
  }
117
121
 
118
122
  fn vnode_fragment(children: Vec<Value>) -> Value {
119
123
  let mut m = ObjectMap::default();
120
124
  m.insert(Arc::from("tag"), fragment_value());
121
125
  m.insert(Arc::from("props"), Value::Null);
122
- m.insert(
123
- Arc::from("children"),
124
- Value::Array(VmRef::new(children)),
125
- );
126
+ m.insert(Arc::from("children"), Value::Array(VmRef::new(children)));
126
127
  m.insert(Arc::from("_el"), Value::Null);
127
- Value::Object(VmRef::new(m))
128
+ Value::object(m)
128
129
  }
129
130
 
130
131
  /// Pluggable UI backend (Floem, DOM, SwiftUI, …). Main-thread / single-threaded by default.
@@ -158,27 +159,6 @@ impl Host for HeadlessHost {
158
159
  }
159
160
  }
160
161
 
161
- thread_local! {
162
- static ACTIVE_HOST: RefCell<Option<Box<dyn Host>>> = RefCell::new(None);
163
- }
164
-
165
- /// Install the thread-local host used by [`schedule_flush`] / `createRoot`.
166
- pub fn install_thread_local_host(host: Box<dyn Host>) {
167
- ACTIVE_HOST.with(|c| {
168
- *c.borrow_mut() = Some(host);
169
- });
170
- }
171
-
172
- pub fn with_thread_local_host<R>(f: impl FnOnce(&mut dyn Host) -> R) -> Option<R> {
173
- ACTIVE_HOST.with(|c| {
174
- let mut opt = c.borrow_mut();
175
- match opt.as_deref_mut() {
176
- Some(host) => Some(f(host)),
177
- None => None,
178
- }
179
- })
180
- }
181
-
182
162
  /// Tag registry hook for future host-specific intrinsic mapping (HTML tag → component kind).
183
163
  #[derive(Default)]
184
164
  pub struct TagRegistry;
@@ -25,6 +25,8 @@ timers = ["dep:tishlang_runtime"]
25
25
  # Any HTTP build needs Send-safe values so handlers can be dispatched
26
26
  # across worker threads or processes. HTTP implies timers (fetch/Promise often pair with setTimeout).
27
27
  http = ["dep:tishlang_runtime", "tishlang_runtime/http", "send-values", "timers"]
28
+ # Promise + `tish:http.await` / `Promise` export without the full HTTP client stack (e.g. wasm32-wasip1).
29
+ promise = ["dep:tishlang_runtime", "tishlang_runtime/promise", "send-values"]
28
30
  ws = ["dep:tishlang_runtime", "tishlang_runtime/ws"]
29
31
 
30
32
  [dependencies]