@zaly/tui 0.0.4

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  3. package/assets/schemas/theme.schema.json +899 -0
  4. package/assets/themes/LICENSE-tokyonight.txt +201 -0
  5. package/assets/themes/NOTICES.md +69 -0
  6. package/assets/themes/ayu-dark.json +119 -0
  7. package/assets/themes/catppuccin-frappe.json +124 -0
  8. package/assets/themes/catppuccin-latte.json +124 -0
  9. package/assets/themes/catppuccin-macchiato.json +124 -0
  10. package/assets/themes/catppuccin-mocha.json +124 -0
  11. package/assets/themes/dracula-soft.json +119 -0
  12. package/assets/themes/dracula.json +119 -0
  13. package/assets/themes/everforest-dark.json +118 -0
  14. package/assets/themes/everforest-light.json +118 -0
  15. package/assets/themes/github-dark.json +123 -0
  16. package/assets/themes/github-light.json +123 -0
  17. package/assets/themes/gruvbox-dark-medium.json +112 -0
  18. package/assets/themes/kanagawa-dragon.json +115 -0
  19. package/assets/themes/kanagawa-wave.json +115 -0
  20. package/assets/themes/material-theme-palenight.json +114 -0
  21. package/assets/themes/min-dark.json +55 -0
  22. package/assets/themes/min-light.json +59 -0
  23. package/assets/themes/monokai.json +116 -0
  24. package/assets/themes/night-owl.json +116 -0
  25. package/assets/themes/nord.json +101 -0
  26. package/assets/themes/one-dark-pro.json +110 -0
  27. package/assets/themes/one-light.json +108 -0
  28. package/assets/themes/poimandres.json +123 -0
  29. package/assets/themes/rose-pine.json +98 -0
  30. package/assets/themes/solarized-dark.json +116 -0
  31. package/assets/themes/solarized-light.json +116 -0
  32. package/assets/themes/synthwave-84.json +100 -0
  33. package/assets/themes/tokyonight-day.json +157 -0
  34. package/assets/themes/tokyonight-moon.json +157 -0
  35. package/assets/themes/tokyonight-night.json +157 -0
  36. package/assets/themes/tokyonight-storm.json +157 -0
  37. package/assets/themes/vesper.json +103 -0
  38. package/assets/themes/vitesse-dark.json +126 -0
  39. package/assets/themes/vitesse-light.json +126 -0
  40. package/dist/ansi-Clq0ozyA.mjs +206 -0
  41. package/dist/ansi-Clq0ozyA.mjs.map +1 -0
  42. package/dist/ansi.d.mts +48 -0
  43. package/dist/ansi.d.mts.map +1 -0
  44. package/dist/ansi.mjs +2 -0
  45. package/dist/autocomplete-Dfw-yQDa.d.mts +100 -0
  46. package/dist/autocomplete-Dfw-yQDa.d.mts.map +1 -0
  47. package/dist/box-DyaByEiG.mjs +386 -0
  48. package/dist/box-DyaByEiG.mjs.map +1 -0
  49. package/dist/builder-D49ECBEf.mjs +385 -0
  50. package/dist/builder-D49ECBEf.mjs.map +1 -0
  51. package/dist/callbacks-CNjGNxVw.mjs +279 -0
  52. package/dist/callbacks-CNjGNxVw.mjs.map +1 -0
  53. package/dist/client-D6C_uczF.mjs +142 -0
  54. package/dist/client-D6C_uczF.mjs.map +1 -0
  55. package/dist/clipboard.d.mts +104 -0
  56. package/dist/clipboard.d.mts.map +1 -0
  57. package/dist/clipboard.mjs +404 -0
  58. package/dist/clipboard.mjs.map +1 -0
  59. package/dist/flex-Bguo-fUe.mjs +202 -0
  60. package/dist/flex-Bguo-fUe.mjs.map +1 -0
  61. package/dist/image-Cm5T-uw-.mjs +108 -0
  62. package/dist/image-Cm5T-uw-.mjs.map +1 -0
  63. package/dist/image.d.mts +123 -0
  64. package/dist/image.d.mts.map +1 -0
  65. package/dist/image.mjs +2 -0
  66. package/dist/index.d.mts +64 -0
  67. package/dist/index.d.mts.map +1 -0
  68. package/dist/index.mjs +222 -0
  69. package/dist/index.mjs.map +1 -0
  70. package/dist/input-B5Vy-iaa.d.mts +141 -0
  71. package/dist/input-B5Vy-iaa.d.mts.map +1 -0
  72. package/dist/inspect-D1d9t-ni.mjs +101 -0
  73. package/dist/inspect-D1d9t-ni.mjs.map +1 -0
  74. package/dist/inspect-D6FW_QUo.d.mts +67 -0
  75. package/dist/inspect-D6FW_QUo.d.mts.map +1 -0
  76. package/dist/kitty-JbCJC0iQ.mjs +673 -0
  77. package/dist/kitty-JbCJC0iQ.mjs.map +1 -0
  78. package/dist/markdown.d.mts +24 -0
  79. package/dist/markdown.d.mts.map +1 -0
  80. package/dist/markdown.mjs +2 -0
  81. package/dist/md.bun.d.mts +14 -0
  82. package/dist/md.bun.d.mts.map +1 -0
  83. package/dist/md.bun.mjs +28 -0
  84. package/dist/md.bun.mjs.map +1 -0
  85. package/dist/md.node.d.mts +14 -0
  86. package/dist/md.node.d.mts.map +1 -0
  87. package/dist/md.node.mjs +126 -0
  88. package/dist/md.node.mjs.map +1 -0
  89. package/dist/node-BZ7f6HzU.mjs +316 -0
  90. package/dist/node-BZ7f6HzU.mjs.map +1 -0
  91. package/dist/picker-D8OLb6kZ.d.mts +36 -0
  92. package/dist/picker-D8OLb6kZ.d.mts.map +1 -0
  93. package/dist/picker-ndVVt6qF.mjs +621 -0
  94. package/dist/picker-ndVVt6qF.mjs.map +1 -0
  95. package/dist/queries-DH3bj74K.d.mts +1963 -0
  96. package/dist/queries-DH3bj74K.d.mts.map +1 -0
  97. package/dist/reactive-f7NpAi69.mjs +623 -0
  98. package/dist/reactive-f7NpAi69.mjs.map +1 -0
  99. package/dist/registry-U654j61Y.mjs +356 -0
  100. package/dist/registry-U654j61Y.mjs.map +1 -0
  101. package/dist/render-DxVLqqB9.mjs +74 -0
  102. package/dist/render-DxVLqqB9.mjs.map +1 -0
  103. package/dist/renderer-CdLCkJB-.mjs +42 -0
  104. package/dist/renderer-CdLCkJB-.mjs.map +1 -0
  105. package/dist/renderer-CxL4xbkl.mjs +2644 -0
  106. package/dist/renderer-CxL4xbkl.mjs.map +1 -0
  107. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  108. package/dist/search-FvGnswRl.d.mts +49 -0
  109. package/dist/search-FvGnswRl.d.mts.map +1 -0
  110. package/dist/select-CbmAZdpt.d.mts +116 -0
  111. package/dist/select-CbmAZdpt.d.mts.map +1 -0
  112. package/dist/services/logger.d.mts +2 -0
  113. package/dist/services/logger.mjs +71 -0
  114. package/dist/services/logger.mjs.map +1 -0
  115. package/dist/services/notifier.d.mts +17 -0
  116. package/dist/services/notifier.d.mts.map +1 -0
  117. package/dist/services/notifier.mjs +71 -0
  118. package/dist/services/notifier.mjs.map +1 -0
  119. package/dist/services/picker.d.mts +36 -0
  120. package/dist/services/picker.d.mts.map +1 -0
  121. package/dist/services/picker.mjs +137 -0
  122. package/dist/services/picker.mjs.map +1 -0
  123. package/dist/services/prompt.d.mts +30 -0
  124. package/dist/services/prompt.d.mts.map +1 -0
  125. package/dist/services/prompt.mjs +83 -0
  126. package/dist/services/prompt.mjs.map +1 -0
  127. package/dist/shiki-BrjVUkeh.mjs +423 -0
  128. package/dist/shiki-BrjVUkeh.mjs.map +1 -0
  129. package/dist/size-D8JogYLy.mjs +34 -0
  130. package/dist/size-D8JogYLy.mjs.map +1 -0
  131. package/dist/style.d.mts +10 -0
  132. package/dist/style.d.mts.map +1 -0
  133. package/dist/style.mjs +4 -0
  134. package/dist/text.d.mts +33 -0
  135. package/dist/text.d.mts.map +1 -0
  136. package/dist/text.mjs +111 -0
  137. package/dist/text.mjs.map +1 -0
  138. package/dist/theme.config-CU3B50HN.mjs +832 -0
  139. package/dist/theme.config-CU3B50HN.mjs.map +1 -0
  140. package/dist/themes.d.mts +113 -0
  141. package/dist/themes.d.mts.map +1 -0
  142. package/dist/themes.mjs +2 -0
  143. package/dist/tree-C28QOVIK.d.mts +23 -0
  144. package/dist/tree-C28QOVIK.d.mts.map +1 -0
  145. package/dist/types-B9Eh7k2v.d.mts +212 -0
  146. package/dist/types-B9Eh7k2v.d.mts.map +1 -0
  147. package/dist/types-D3jk1rtk.d.mts +140 -0
  148. package/dist/types-D3jk1rtk.d.mts.map +1 -0
  149. package/dist/utils-3M4D_AXZ.mjs +40 -0
  150. package/dist/utils-3M4D_AXZ.mjs.map +1 -0
  151. package/dist/widgets/autocomplete.d.mts +2 -0
  152. package/dist/widgets/autocomplete.mjs +165 -0
  153. package/dist/widgets/autocomplete.mjs.map +1 -0
  154. package/dist/widgets/box.d.mts +2 -0
  155. package/dist/widgets/box.mjs +2 -0
  156. package/dist/widgets/code.d.mts +48 -0
  157. package/dist/widgets/code.d.mts.map +1 -0
  158. package/dist/widgets/code.mjs +59 -0
  159. package/dist/widgets/code.mjs.map +1 -0
  160. package/dist/widgets/completions/actions.d.mts +41 -0
  161. package/dist/widgets/completions/actions.d.mts.map +1 -0
  162. package/dist/widgets/completions/actions.mjs +48 -0
  163. package/dist/widgets/completions/actions.mjs.map +1 -0
  164. package/dist/widgets/completions/files.d.mts +29 -0
  165. package/dist/widgets/completions/files.d.mts.map +1 -0
  166. package/dist/widgets/completions/files.mjs +42 -0
  167. package/dist/widgets/completions/files.mjs.map +1 -0
  168. package/dist/widgets/completions/github.d.mts +64 -0
  169. package/dist/widgets/completions/github.d.mts.map +1 -0
  170. package/dist/widgets/completions/github.mjs +137 -0
  171. package/dist/widgets/completions/github.mjs.map +1 -0
  172. package/dist/widgets/completions/index.d.mts +4 -0
  173. package/dist/widgets/completions/index.mjs +4 -0
  174. package/dist/widgets/diff.d.mts +57 -0
  175. package/dist/widgets/diff.d.mts.map +1 -0
  176. package/dist/widgets/diff.mjs +199 -0
  177. package/dist/widgets/diff.mjs.map +1 -0
  178. package/dist/widgets/divider.d.mts +11 -0
  179. package/dist/widgets/divider.d.mts.map +1 -0
  180. package/dist/widgets/divider.mjs +9 -0
  181. package/dist/widgets/divider.mjs.map +1 -0
  182. package/dist/widgets/image.d.mts +37 -0
  183. package/dist/widgets/image.d.mts.map +1 -0
  184. package/dist/widgets/image.mjs +77 -0
  185. package/dist/widgets/image.mjs.map +1 -0
  186. package/dist/widgets/input.d.mts +2 -0
  187. package/dist/widgets/input.mjs +497 -0
  188. package/dist/widgets/input.mjs.map +1 -0
  189. package/dist/widgets/log.d.mts +2 -0
  190. package/dist/widgets/log.mjs +130 -0
  191. package/dist/widgets/log.mjs.map +1 -0
  192. package/dist/widgets/markdown.d.mts +45 -0
  193. package/dist/widgets/markdown.d.mts.map +1 -0
  194. package/dist/widgets/markdown.mjs +124 -0
  195. package/dist/widgets/markdown.mjs.map +1 -0
  196. package/dist/widgets/overlay.d.mts +2 -0
  197. package/dist/widgets/overlay.mjs +18 -0
  198. package/dist/widgets/overlay.mjs.map +1 -0
  199. package/dist/widgets/picker.d.mts +2 -0
  200. package/dist/widgets/picker.mjs +2 -0
  201. package/dist/widgets/progress.d.mts +48 -0
  202. package/dist/widgets/progress.d.mts.map +1 -0
  203. package/dist/widgets/progress.mjs +48 -0
  204. package/dist/widgets/progress.mjs.map +1 -0
  205. package/dist/widgets/select.d.mts +2 -0
  206. package/dist/widgets/select.mjs +195 -0
  207. package/dist/widgets/select.mjs.map +1 -0
  208. package/dist/widgets/show.d.mts +55 -0
  209. package/dist/widgets/show.d.mts.map +1 -0
  210. package/dist/widgets/show.mjs +85 -0
  211. package/dist/widgets/show.mjs.map +1 -0
  212. package/dist/widgets/spinner.d.mts +65 -0
  213. package/dist/widgets/spinner.d.mts.map +1 -0
  214. package/dist/widgets/spinner.mjs +147 -0
  215. package/dist/widgets/spinner.mjs.map +1 -0
  216. package/dist/widgets/text.d.mts +2 -0
  217. package/dist/widgets/text.mjs +32 -0
  218. package/dist/widgets/text.mjs.map +1 -0
  219. package/dist/widgets/tree.d.mts +2 -0
  220. package/dist/widgets/tree.mjs +73 -0
  221. package/dist/widgets/tree.mjs.map +1 -0
  222. package/dist/widgets/widget.d.mts +49 -0
  223. package/dist/widgets/widget.d.mts.map +1 -0
  224. package/dist/widgets/widget.mjs +40 -0
  225. package/dist/widgets/widget.mjs.map +1 -0
  226. package/dist/worker-DjHuQSbY.mjs +27 -0
  227. package/dist/worker-DjHuQSbY.mjs.map +1 -0
  228. package/package.json +117 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queries-DH3bj74K.d.mts","names":[],"sources":["../src/input/keys.ts","../src/input/decoder.ts","../src/input/actions.ts","../src/layout/size.ts","../src/core/reactive.ts","../src/core/state.ts","../src/layout/border.ts","../src/widgets/text.ts","../src/widgets/box.ts","../src/widgets/overlay.ts","../src/core/ctx.ts","../src/widgets/log.ts","../src/services/logger.ts","../src/renderer/terminal.ts","../src/renderer/frame.ts","../src/renderer/surface.ts","../src/renderer/overlay.ts","../src/renderer/selection.ts","../src/renderer/stream.ts","../src/renderer/ui.ts","../src/renderer/renderer.ts","../src/core/node.ts","../src/input/router.ts","../src/input/queries.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0BiB;;EAEf;;;;;;;EAOA;EACA;EACA;EACA;EACA;;;KAIU;;;;;KAMA,yBAAyB;cAEvB;;KAGF;YAAkC;;cAGxC;cAuCO,wBAAwB;EACnC,YAAY,iBAAiB;;iBAgDf,aAAa,YAAY,KAAK;;;;;;;;iBAgB9B,UAAU,yBAAyB,WAAW;;;;;;;iBAkB9C,WAAW,IAAI,UAAU;;;;;;;;;;;;KCvK7B;KAEA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;EAEI;EAAgB;;EAChB;EAA8B,QAAQ;EAAa;;KAG7C;EACN;EAAuB;EAAa;EAAkB;EAAgB;;EACtE;EAAuB;EAA6B;EAAkB;;KAEhE;EACN;EAAa,OAAO;;EACpB;EAAe;;EACf;EAAe;IACjB,wBACA;;;;;;;;KCrBQ,UAAU,UAAU,WAAW,UAAU;;WAE1C;WACA,OAAO;;;;WAIP,SAAS;;WAET;;WAEA,MAAM;EACf,OAAO,WAAW;KACf,UAAU;;;;WAKA,MAAM;;KAIT,SAAS,UAAU,WAAW,UAAU,aAClD,KAAK,UAAU,GAAG,OACf;KAEO,aAAa,KAAK;EAC5B;EACA,IAAI;EACJ;;;;;;;;;;;;;;;UAgBe,UAAU,UAAU,WAAW,UAAU;EACxD;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK,SAAS,GAAG;;;EAGjB;;KAGU,OAAO,UAAU,WAAW,UAAU,YAAY,UAAU,GAAG;EAAO;;KAEtE,YAAY,eAAe;KA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I;;;;;KAMlB,uBAAuB;;;;;;;UAQlB;EACf;EACA;EACA;EACA;EACA;EACA;;;EAGA;EACA;EACA;;;UAIe;EACf;EACA;EACA;;KAGU;EACV;IAAoB;;EACpB;IAAO,OAAO;;EACd;IAAS,OAAO;;EAChB;IAAmB,OAAO;;EAC1B;IAAS,MAAM;;EACf;IAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;cAqBH,oBAAoB,QAAQ;;EASvC,YAAY,SAAS;;EAMrB,WAAW,SAAS;;MAKhB,WAAW;;;;;;EAUf,MAAM,MAAM;;;EAqBZ,KAAK,MAAM;MAoBP;;;;EAOJ,SAAS,IAAI;;;;KCnJH,cAAc,IAAI,yBAAyB;EACrD;EACA,QAAQ,OAAO,0BAA0B;;KAG/B;EACV;EACA,QAAQ;;KAGL;EACH,QAAQ;;cAGG;;EAIX,YAAY,QAAQ,aAAa,UAAU;EAK3C,MAAM,GAAG,OAAO,cAAc,KAAK,QAAQ;EAwB3C,wBAAwB,OAAM,oBAAsB,SAAA;;;EAWpD,0BAA0B,OAAM,oBAAsB,SAAA;;;EAWtD,UAAU,OAAM,oBAAsB,SAAA;;;;;iBAcxB,WAAW"}
@@ -0,0 +1,623 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ //#region src/core/reactive.ts
3
+ const activeCtx = new AsyncLocalStorage();
4
+ function withTracking(ctx, fn) {
5
+ return activeCtx.run(ctx, fn);
6
+ }
7
+ /** Run `fn` outside any tracking scope. Signal reads inside don't
8
+ * subscribe the surrounding render, and async work started inside
9
+ * (timers, promises, intervals) doesn't capture the current ctx —
10
+ * callbacks fire with `getStore() === undefined`.
11
+ *
12
+ * Use this when starting persistent async work from inside a render
13
+ * pass: a `setInterval` set up during `_render` would otherwise
14
+ * inherit the render's ALS context, and every timer tick would look
15
+ * like it's "inside" that render — its invalidates would be silently
16
+ * suppressed.
17
+ *
18
+ * ```ts
19
+ * // inside _render() or a render-driven reconcile():
20
+ * untracked(() => {
21
+ * this.#timer = setInterval(() => this.invalidate(), speed)
22
+ * })
23
+ * ```
24
+ *
25
+ * Equivalent to Solid's `untrack`. */
26
+ function untrack(fn) {
27
+ return activeCtx.run(void 0, fn);
28
+ }
29
+ /** Resolve a `Reactive<T>` to its current `T` without subscribing to
30
+ * any tracking context. */
31
+ function peek(s) {
32
+ return untrack(() => unwrap(s));
33
+ }
34
+ function createContext(defaultValue) {
35
+ return {
36
+ defaultValue,
37
+ id: Symbol("@zaly/tui/context")
38
+ };
39
+ }
40
+ /** Publish `value` for `ctx` on the active Owner. Persistent for the
41
+ * Owner's lifetime. Descendants (in the render-call sense) that read
42
+ * via `useContext` walk up the Owner chain and find it. */
43
+ function provideContext(ctx, value) {
44
+ const owner = activeOwnerStore.getStore();
45
+ if (owner === void 0) throw new Error("provideContext: no active Owner — call from a widget body / _render");
46
+ owner.setContext(ctx.id, value);
47
+ }
48
+ /** Read the current value of `ctx`. Walks the Owner chain
49
+ * (render-call ancestry, not mount tree). Returns the context's
50
+ * default when no ancestor has provided a value. */
51
+ function useContext(ctx) {
52
+ for (let o = activeOwnerStore.getStore(); o !== void 0; o = o.parent) {
53
+ const map = o.contexts;
54
+ if (map?.has(ctx.id)) return map.get(ctx.id);
55
+ }
56
+ return ctx.defaultValue;
57
+ }
58
+ /** Brand tag: every accessor / setter returned by `signal` / `memo`
59
+ * carries this symbol so `unwrap` can tell a reactive source from a
60
+ * plain function-valued prop (label formatter, text callback, etc.). */
61
+ const REACTIVE = Symbol.for("@zaly/tui/reactive");
62
+ /** Runtime check: `true` when `v` was produced by `signal` / `memo`.
63
+ * False for plain callables (text-content functions, label formatters).
64
+ *
65
+ * @internal */
66
+ function isAccessor(v) {
67
+ return typeof v === "function" && v[REACTIVE] === "get";
68
+ }
69
+ /** Resolve a `Reactive<T>` to its current `T`. Call inside `_render`
70
+ * so accessor reads subscribe the rendering node. Only brand-tagged
71
+ * accessors are invoked — other function values pass through
72
+ * untouched, so widgets whose `T` is itself a function type (label
73
+ * formatters etc.) don't need a hand-rolled guard. */
74
+ function unwrap(v) {
75
+ return isAccessor(v) ? v() : v;
76
+ }
77
+ function brand(fn, tag) {
78
+ Object.defineProperty(fn, REACTIVE, {
79
+ configurable: false,
80
+ enumerable: false,
81
+ value: tag,
82
+ writable: false
83
+ });
84
+ return fn;
85
+ }
86
+ /**
87
+ * Reactive ownership scope — bundles cleanups + provided contexts
88
+ * scoped to a single widget body (or a `createRoot` headless scope).
89
+ *
90
+ * Owners form a chain via `parent` mirroring the call-time widget
91
+ * nesting: when `widget()` is invoked inside another widget's body,
92
+ * `createNode` creates the inner Owner with `parent =
93
+ * activeOwnerStore.getStore()` (the outer widget's Owner). That chain
94
+ * is what `useContext` walks.
95
+ *
96
+ * Owners are **not** bound to Nodes anymore — a widget's `createNode`
97
+ * pairs the Owner with the constructed Node only through
98
+ * `Node.once("unmount", () => owner.dispose())`. Primitive Nodes
99
+ * (`text`, `box`, …) don't get their own Owner; they share whatever
100
+ * Owner created them.
101
+ *
102
+ * Use `onCleanup(cb)` to register cleanups against the active Owner.
103
+ * Disposing the Owner runs them in reverse-registration order.
104
+ *
105
+ * @internal
106
+ */
107
+ var Owner = class {
108
+ parent;
109
+ #cleanups = [];
110
+ #contexts;
111
+ #disposed = false;
112
+ constructor(parent) {
113
+ this.parent = parent;
114
+ }
115
+ get disposed() {
116
+ return this.#disposed;
117
+ }
118
+ /** Live view of this Owner's provided contexts. Populated by
119
+ * `provideContext`. Walked upward via `parent` by `useContext`. */
120
+ get contexts() {
121
+ return this.#contexts;
122
+ }
123
+ setContext(id, value) {
124
+ (this.#contexts ??= /* @__PURE__ */ new Map()).set(id, value);
125
+ }
126
+ /** Register a cleanup. Runs on `dispose()`. */
127
+ addCleanup(fn) {
128
+ if (this.#disposed) {
129
+ fn();
130
+ return;
131
+ }
132
+ this.#cleanups.push(fn);
133
+ }
134
+ /** Fire cleanups in reverse-registration order. Idempotent. */
135
+ dispose() {
136
+ if (this.#disposed) return;
137
+ this.#disposed = true;
138
+ for (let i = this.#cleanups.length - 1; i >= 0; i--) try {
139
+ this.#cleanups[i]();
140
+ } catch (error) {
141
+ console.error("Owner cleanup threw:", error);
142
+ }
143
+ this.#cleanups = [];
144
+ this.#contexts = void 0;
145
+ }
146
+ };
147
+ const activeOwnerStore = new AsyncLocalStorage();
148
+ /** Run `fn` as the `node`'s render pass. Signal reads inside subscribe
149
+ * the node's tracking ctx; the ctx's `notify` is `node.invalidate`,
150
+ * so any signal write that this render depended on invalidates the
151
+ * node and clears its cache. Cleanups are registered against the
152
+ * Node's `unmount` event.
153
+ *
154
+ * Does **not** push an Owner — primitive Nodes share whatever Owner
155
+ * was active in their caller. Widget bodies install their own Owner
156
+ * via `createNode` at construction time, which is when `useContext`
157
+ * / `provideContext` / `effect` / `memo` care about the active scope.
158
+ *
159
+ * @internal */
160
+ function withActiveNode(node, fn) {
161
+ return withTracking(getNodeTrackingCtx(node), fn);
162
+ }
163
+ /** Run `fn` with a pre-existing Owner restored. Used by `effect` /
164
+ * `memo` to re-establish their creation-time owner chain on re-fire,
165
+ * so `useContext` walks the same ancestry regardless of whether the
166
+ * re-fire was triggered from inside or outside a render.
167
+ *
168
+ * @internal */
169
+ function withOwner(owner, fn) {
170
+ return activeOwnerStore.run(owner, fn);
171
+ }
172
+ function getNodeTrackingCtx(node) {
173
+ let ctx = nodeCtx.get(node);
174
+ if (ctx === void 0) {
175
+ ctx = {
176
+ notify: () => node.invalidate(),
177
+ register: (cleanup) => {
178
+ node.once("unmount", cleanup);
179
+ }
180
+ };
181
+ nodeCtx.set(node, ctx);
182
+ }
183
+ return ctx;
184
+ }
185
+ /** Create a fresh Owner scope and run `fn` inside it. Returns
186
+ * whatever `fn` returns. The Owner's parent is whatever was active at
187
+ * the call site (or `undefined` at module top).
188
+ *
189
+ * The Owner is *not* auto-disposed — callers manage its lifetime via
190
+ * the Owner returned alongside the result, or (more commonly) by
191
+ * binding the Owner to a Node and disposing it on that Node's
192
+ * unmount.
193
+ *
194
+ * Typical use is via a surface's function-shape `add(fn)` API which
195
+ * wraps this internally:
196
+ *
197
+ * ```ts
198
+ * ui.add(() => {
199
+ * const [count, setCount] = signal(0)
200
+ * onCleanup(() => console.log("gone"))
201
+ * return text(() => `count: ${count()}`)
202
+ * })
203
+ * ```
204
+ *
205
+ * For headless reactive scopes (tests, programmatic effects), call
206
+ * `createRoot` directly:
207
+ *
208
+ * ```ts
209
+ * const { result, owner } = createRoot(() => signal(0))
210
+ * // ... use result ...
211
+ * owner.dispose()
212
+ * ```
213
+ */
214
+ function createRoot(fn) {
215
+ const owner = new Owner(activeOwnerStore.getStore());
216
+ return withOwner(owner, () => fn(() => owner.dispose()));
217
+ }
218
+ /** Run `fn` inside a fresh Owner scope and bind the returned Node to
219
+ * that scope — when the Node unmounts, the Owner disposes (firing
220
+ * every `onCleanup`, tearing down every `effect` / `memo` /
221
+ * `createAsync` registered in the body).
222
+ *
223
+ * This is what `widget()` calls under the hood: it's the per-instance
224
+ * scope boundary. Surfaces also call it directly at their `add` /
225
+ * `append` entry points so each appended subtree gets its own root.
226
+ *
227
+ * ```ts
228
+ * ui.add(() => {
229
+ * const [c, setC] = signal(0)
230
+ * onCleanup(() => clearInterval(timer))
231
+ * const timer = setInterval(() => setC(x => x + 1), 1000)
232
+ * return text(() => `count: ${c()}`)
233
+ * })
234
+ * ```
235
+ */
236
+ function createNode(fn) {
237
+ return createRoot((dispose) => fn().once("unmount", dispose));
238
+ }
239
+ /** Register a cleanup against the active Owner. Fires when the Owner
240
+ * disposes — i.e. when the widget body's `createNode` Node unmounts,
241
+ * or when the surrounding `createRoot` is disposed.
242
+ *
243
+ * ```ts
244
+ * function widgetBody() {
245
+ * const id = setInterval(() => tick(), 1000)
246
+ * onCleanup(() => clearInterval(id))
247
+ * return box(…)
248
+ * }
249
+ * ```
250
+ *
251
+ * Throws if called outside any active Owner — the cleanup would
252
+ * never fire and the caller is almost certainly mistaken. */
253
+ function onCleanup(fn) {
254
+ const owner = activeOwnerStore.getStore();
255
+ if (owner === void 0) throw new Error("onCleanup: no active Owner — call from inside a widget body / createRoot");
256
+ owner.addCleanup(fn);
257
+ }
258
+ /** Current Owner, or `undefined` outside any render. Captured by
259
+ * effects/memos at creation time and restored on re-fire.
260
+ *
261
+ * @internal */
262
+ function useActiveOwner() {
263
+ return activeOwnerStore.getStore();
264
+ }
265
+ /** Whether we're currently executing inside `node`'s own render call
266
+ * stack — i.e. this code path was reached synchronously (or via an
267
+ * await preserved by `AsyncLocalStorage`) from `node`'s `withActiveNode`.
268
+ *
269
+ * Used by `invalidate()` to suppress *internal* cascades — e.g.
270
+ * Markdown mutating its child Text inside its own `_render`. External
271
+ * mutations (network callbacks, event handlers) run outside any
272
+ * render's ALS scope, so this returns `false` for them and they emit
273
+ * normally even when a render is in flight.
274
+ *
275
+ * @internal */
276
+ function inRenderContextOf(node) {
277
+ const active = activeCtx.getStore();
278
+ return active !== void 0 && active === nodeCtx.get(node);
279
+ }
280
+ const nodeCtx = /* @__PURE__ */ new WeakMap();
281
+ /**
282
+ * Reactive value. Returns a `[get, set]` tuple that's also accessible
283
+ * as `.get` / `.set` for destructure-skipping callers. Reads inside a
284
+ * tracking context (node render, effect, memo) auto-subscribe; writes
285
+ * notify every subscriber synchronously.
286
+ *
287
+ * ```ts
288
+ * const [count, setCount] = signal(0)
289
+ * setCount(1) // value form
290
+ * setCount((prev) => prev + 1) // updater form
291
+ * ```
292
+ *
293
+ * **Storing a function as a value — gotcha**: `set` interprets any
294
+ * function argument as the *updater* form `(prev) => next`, calls it
295
+ * with the current value, and stores the result. To store a function
296
+ * value (e.g. a callable `StyleBuilder` or a handler ref), wrap with
297
+ * the updater form so the call resolves to the function you wanted:
298
+ *
299
+ * ```ts
300
+ * const [style, setStyle] = signal<StyleBuilder | undefined>(undefined)
301
+ * setStyle(ctx.style) // ✗ stored as `ctx.style(undefined)` — a string
302
+ * setStyle(() => ctx.style) // ✓ stored as the StyleBuilder itself
303
+ * ```
304
+ *
305
+ * Same trap exists in Solid and React's `useState`. If you find
306
+ * yourself reaching for it, also consider whether storing a *plain*
307
+ * value (the underlying data, not the chain/builder) and recomputing
308
+ * the function-y derivative inside a `memo` is cleaner — usually it
309
+ * is.
310
+ *
311
+ * Equality is reference-based: `set(v)` where `v === current` skips
312
+ * the notify. Wrap mutable values you want to "publish" in a fresh
313
+ * object/array, or use a counter signal to force fan-out.
314
+ */
315
+ function signal(initial, opts = {}) {
316
+ let value = initial;
317
+ const subs = /* @__PURE__ */ new Set();
318
+ const equals = opts.equals === false ? () => false : opts.equals ?? ((a, b) => a === b);
319
+ const get = brand(() => {
320
+ const ctx = activeCtx.getStore();
321
+ if (ctx && !subs.has(ctx.notify)) {
322
+ subs.add(ctx.notify);
323
+ ctx.register(() => subs.delete(ctx.notify));
324
+ }
325
+ return value;
326
+ }, "get");
327
+ const set = brand((next) => {
328
+ const resolved = typeof next === "function" ? next(value) : next;
329
+ if (equals(value, resolved)) return;
330
+ value = resolved;
331
+ const snapshot = [...subs];
332
+ for (const notify of snapshot) notify();
333
+ }, "set");
334
+ return Object.assign([get, set], {
335
+ get,
336
+ set
337
+ });
338
+ }
339
+ /**
340
+ * Lift a plain value to an `Accessor<T>`. The returned function always
341
+ * returns `value`, never tracks, never notifies — useful at the boundary
342
+ * where a static value enters a tree that otherwise expects `Accessor<T>`.
343
+ *
344
+ * Branded so `isAccessor` reports `true` and downstream `unwrap` calls
345
+ * resolve to a stable function call rather than treating the value as
346
+ * a ctx-aware thunk.
347
+ *
348
+ * ```ts
349
+ * // Component expects `Accessor<Theme>` deep in the tree:
350
+ * <CodeBlock theme={toAccessor(myStaticTheme)} />
351
+ * ```
352
+ */
353
+ function toAccessor(fn) {
354
+ return brand(() => fn(), "get");
355
+ }
356
+ /**
357
+ * Run `fn` immediately, then re-run whenever a signal it read writes.
358
+ * Returns a disposer that stops the effect and drops all tracked
359
+ * subscriptions. Unlike node render, effect dependencies are re-tracked
360
+ * from scratch on every run — reads that disappear from `fn` stop
361
+ * triggering re-runs.
362
+ *
363
+ * ```ts
364
+ * const dispose = effect(() => {
365
+ * console.log("status is", status())
366
+ * })
367
+ * // ...
368
+ * dispose()
369
+ * ```
370
+ *
371
+ * **Footgun**: don't write a signal from inside an effect that reads
372
+ * the same signal — you'll loop. Writing unrelated signals is fine.
373
+ */
374
+ function effect(fn) {
375
+ let cleanups = [];
376
+ let disposed = false;
377
+ const owner = useActiveOwner();
378
+ const ctx = {
379
+ notify: () => {
380
+ if (disposed) return;
381
+ run();
382
+ },
383
+ register: (cleanup) => {
384
+ cleanups.push(cleanup);
385
+ }
386
+ };
387
+ const run = () => {
388
+ const old = cleanups;
389
+ cleanups = [];
390
+ for (const c of old) c();
391
+ const tracked = () => withTracking(ctx, fn);
392
+ const cleanup = owner !== void 0 ? withOwner(owner, tracked) : tracked();
393
+ if (typeof cleanup === "function") cleanups.push(cleanup);
394
+ };
395
+ const dispose = () => {
396
+ if (disposed) return;
397
+ disposed = true;
398
+ for (const c of cleanups) c();
399
+ cleanups = [];
400
+ };
401
+ owner?.addCleanup(dispose);
402
+ run();
403
+ return dispose;
404
+ }
405
+ /**
406
+ * Derived, cached signal. `fn` runs once eagerly; the cached value is
407
+ * returned from the accessor. When any signal `fn` reads writes, the
408
+ * memo recomputes and notifies its own subscribers — but only if the
409
+ * new value differs from the cached one (reference equality).
410
+ *
411
+ * ```ts
412
+ * const [value, setValue] = signal(0)
413
+ * const pct = memo(() => Math.round(value() * 100))
414
+ * text(({ style }) => `${pct()}%`) // subscribes to pct, not value
415
+ * ```
416
+ *
417
+ * Returns an `Accessor<T>`, not a `[read, write]` tuple — memos are
418
+ * read-only by construction.
419
+ */
420
+ function memo(fn) {
421
+ const [get, set] = signal(void 0);
422
+ effect(() => {
423
+ set(() => fn());
424
+ });
425
+ return get;
426
+ }
427
+ function createStore(initial) {
428
+ const state = { ...initial };
429
+ const sigs = {};
430
+ const ensure = (key) => sigs[key] ??= signal(state[key]);
431
+ const setKey = (key, value) => {
432
+ if (state[key] === value) return;
433
+ state[key] = value;
434
+ sigs[key]?.set(() => value);
435
+ };
436
+ const set = (patch) => {
437
+ const p = typeof patch === "function" ? patch(state) : patch;
438
+ for (const k of Object.keys(p)) {
439
+ const v = p[k];
440
+ setKey(k, v);
441
+ }
442
+ };
443
+ return new Proxy({}, {
444
+ get(_, key) {
445
+ if (key === "set") return set;
446
+ return ensure(key).get();
447
+ },
448
+ getOwnPropertyDescriptor(_, key) {
449
+ if (!Object.hasOwn(state, key)) return void 0;
450
+ return {
451
+ configurable: true,
452
+ enumerable: true,
453
+ value: state[key]
454
+ };
455
+ },
456
+ has(_, key) {
457
+ return key === "set" || key in state;
458
+ },
459
+ ownKeys() {
460
+ return Reflect.ownKeys(state);
461
+ },
462
+ set(_, key, value) {
463
+ setKey(key, value);
464
+ return true;
465
+ }
466
+ });
467
+ }
468
+ /** Nearest Suspense provider in the Owner chain. `undefined` when no
469
+ * boundary is installed — `createAsync` runs fire-and-forget in that
470
+ * case (signal resolves later, normal invalidation re-renders). */
471
+ const SuspenseContext = createContext(void 0);
472
+ /**
473
+ * Build a boundary whose count flips propagate to `parent` on the 0→1
474
+ * and 1→0 transitions. Used by Stream's `append` and the `suspense()`
475
+ * widget. Internal-ish — most callers shouldn't construct boundaries
476
+ * directly.
477
+ *
478
+ * @internal
479
+ */
480
+ function createSuspenseBoundary(parent) {
481
+ let count = 0;
482
+ let idle;
483
+ return {
484
+ active: () => count > 0,
485
+ decrement: () => {
486
+ if (count === 0) return;
487
+ count--;
488
+ if (count === 0) {
489
+ parent?.decrement();
490
+ idle?.resolve();
491
+ idle = void 0;
492
+ }
493
+ },
494
+ increment: () => {
495
+ count++;
496
+ if (count === 1) parent?.increment();
497
+ },
498
+ whenIdle: () => {
499
+ if (count === 0) return Promise.resolve();
500
+ if (idle === void 0) {
501
+ const { promise, resolve } = Promise.withResolvers();
502
+ idle = {
503
+ promise,
504
+ resolve
505
+ };
506
+ }
507
+ return idle.promise;
508
+ }
509
+ };
510
+ }
511
+ function createAsync(fn, opts) {
512
+ const [value, setValue] = signal(opts?.initialValue);
513
+ const suspense = useContext(SuspenseContext);
514
+ let gen = 0;
515
+ effect(() => {
516
+ const my = ++gen;
517
+ let p;
518
+ try {
519
+ p = fn(untrack(value));
520
+ } catch (error) {
521
+ p = Promise.reject(error);
522
+ }
523
+ suspense?.increment();
524
+ p.then((v) => {
525
+ if (my === gen) setValue(() => v);
526
+ }, () => {}).finally(() => suspense?.decrement());
527
+ });
528
+ return value;
529
+ }
530
+ function createProgressive(fn, opts = {}) {
531
+ const throttle = opts.throttle ?? 16;
532
+ const [loading, setLoading] = signal(true);
533
+ const [state, setState] = signal(opts.initialValue, { equals: false });
534
+ const ret = Object.assign(state, {
535
+ get loading() {
536
+ return loading;
537
+ },
538
+ whenIdle: () => {
539
+ if (!loading()) return Promise.resolve();
540
+ idle ??= Promise.withResolvers();
541
+ return idle.promise;
542
+ }
543
+ });
544
+ let gen = 0;
545
+ let idle;
546
+ effect(() => {
547
+ const my = ++gen;
548
+ const ac = new AbortController();
549
+ (async () => {
550
+ try {
551
+ setLoading(true);
552
+ let prev = 0;
553
+ const result = await fn({
554
+ set: (value) => {
555
+ if (ac.signal.aborted || my !== gen) return;
556
+ const now = performance.now();
557
+ if (now - prev >= throttle) {
558
+ prev = now;
559
+ setState(() => value);
560
+ }
561
+ },
562
+ signal: ac.signal
563
+ });
564
+ if (my === gen) {
565
+ setState(() => result);
566
+ setLoading(false);
567
+ idle?.resolve();
568
+ idle = void 0;
569
+ }
570
+ } catch (error) {
571
+ if (my === gen) {
572
+ setLoading(false);
573
+ idle?.reject(error);
574
+ idle = void 0;
575
+ }
576
+ } finally {
577
+ ac.abort();
578
+ }
579
+ })();
580
+ return () => {
581
+ ac.abort();
582
+ };
583
+ });
584
+ return ret;
585
+ }
586
+ function createIterable(fn, opts = {}) {
587
+ return createProgressive(async ({ signal: s, set }) => {
588
+ const results = [];
589
+ for await (const item of fn({ signal: s })) {
590
+ if (s.aborted) return results;
591
+ results.push(...Array.isArray(item) ? item : [item]);
592
+ set(results);
593
+ }
594
+ return results;
595
+ }, {
596
+ ...opts,
597
+ initialValue: opts.initialValue ?? []
598
+ });
599
+ }
600
+ function createRef(value, opts = {}) {
601
+ let current = value;
602
+ let cleanup;
603
+ const get = () => {
604
+ if (current === void 0) throw new Error("Ref value accessed before initialization");
605
+ return current;
606
+ };
607
+ Object.defineProperty(get, "value", {
608
+ get: () => current,
609
+ set: (v) => {
610
+ if (current === v) return;
611
+ cleanup?.();
612
+ cleanup = void 0;
613
+ const prev = current;
614
+ current = v;
615
+ cleanup = opts.onSet?.(v, prev) ?? void 0;
616
+ }
617
+ });
618
+ return get;
619
+ }
620
+ //#endregion
621
+ export { useActiveOwner as C, withOwner as E, unwrap as S, withActiveNode as T, peek as _, createIterable as a, toAccessor as b, createRef as c, createSuspenseBoundary as d, effect as f, onCleanup as g, memo as h, createContext as i, createRoot as l, isAccessor as m, SuspenseContext as n, createNode as o, inRenderContextOf as p, createAsync as r, createProgressive as s, Owner as t, createStore as u, provideContext as v, useContext as w, untrack as x, signal as y };
622
+
623
+ //# sourceMappingURL=reactive-f7NpAi69.mjs.map