sigmx 0.1.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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/dist/auto.d.ts +1 -0
  4. package/dist/auto.js +7 -0
  5. package/dist/auto.js.map +7 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +26 -0
  8. package/dist/cli.js.map +7 -0
  9. package/dist/core/csp.d.ts +7 -0
  10. package/dist/core/csp.js +20 -0
  11. package/dist/core/csp.js.map +7 -0
  12. package/dist/core/engine.d.ts +10 -0
  13. package/dist/core/engine.js +200 -0
  14. package/dist/core/engine.js.map +7 -0
  15. package/dist/core/expr.d.ts +12 -0
  16. package/dist/core/expr.js +94 -0
  17. package/dist/core/expr.js.map +7 -0
  18. package/dist/core/index.d.ts +16 -0
  19. package/dist/core/index.js +46 -0
  20. package/dist/core/index.js.map +7 -0
  21. package/dist/core/signals.d.ts +42 -0
  22. package/dist/core/signals.js +195 -0
  23. package/dist/core/signals.js.map +7 -0
  24. package/dist/core/store.d.ts +32 -0
  25. package/dist/core/store.js +185 -0
  26. package/dist/core/store.js.map +7 -0
  27. package/dist/core/types.d.ts +101 -0
  28. package/dist/core/types.js +1 -0
  29. package/dist/core/types.js.map +7 -0
  30. package/dist/kernel/compile.d.ts +16 -0
  31. package/dist/kernel/compile.js +96 -0
  32. package/dist/kernel/compile.js.map +7 -0
  33. package/dist/kernel/contracts.d.ts +121 -0
  34. package/dist/kernel/contracts.js +1 -0
  35. package/dist/kernel/contracts.js.map +7 -0
  36. package/dist/kernel/index.d.ts +20 -0
  37. package/dist/kernel/index.js +54 -0
  38. package/dist/kernel/index.js.map +7 -0
  39. package/dist/kernel/precompile.d.ts +25 -0
  40. package/dist/kernel/precompile.js +111 -0
  41. package/dist/kernel/precompile.js.map +7 -0
  42. package/dist/kernel/precompiled.d.ts +11 -0
  43. package/dist/kernel/precompiled.js +13 -0
  44. package/dist/kernel/precompiled.js.map +7 -0
  45. package/dist/kernel/reactive.d.ts +42 -0
  46. package/dist/kernel/reactive.js +201 -0
  47. package/dist/kernel/reactive.js.map +7 -0
  48. package/dist/kernel/runtime.d.ts +11 -0
  49. package/dist/kernel/runtime.js +210 -0
  50. package/dist/kernel/runtime.js.map +7 -0
  51. package/dist/kernel/scan.d.ts +42 -0
  52. package/dist/kernel/scan.js +68 -0
  53. package/dist/kernel/scan.js.map +7 -0
  54. package/dist/kernel/state.d.ts +32 -0
  55. package/dist/kernel/state.js +186 -0
  56. package/dist/kernel/state.js.map +7 -0
  57. package/dist/kernel/strict-csp.d.ts +7 -0
  58. package/dist/kernel/strict-csp.js +20 -0
  59. package/dist/kernel/strict-csp.js.map +7 -0
  60. package/dist/lib/casing.d.ts +7 -0
  61. package/dist/lib/casing.js +16 -0
  62. package/dist/lib/casing.js.map +7 -0
  63. package/dist/lib/objects.d.ts +9 -0
  64. package/dist/lib/objects.js +26 -0
  65. package/dist/lib/objects.js.map +7 -0
  66. package/dist/lib/schedule.d.ts +14 -0
  67. package/dist/lib/schedule.js +51 -0
  68. package/dist/lib/schedule.js.map +7 -0
  69. package/dist/lib/sse.d.ts +10 -0
  70. package/dist/lib/sse.js +55 -0
  71. package/dist/lib/sse.js.map +7 -0
  72. package/dist/plugins/actions/clipboard.d.ts +2 -0
  73. package/dist/plugins/actions/clipboard.js +11 -0
  74. package/dist/plugins/actions/clipboard.js.map +7 -0
  75. package/dist/plugins/actions/fit.d.ts +2 -0
  76. package/dist/plugins/actions/fit.js +14 -0
  77. package/dist/plugins/actions/fit.js.map +7 -0
  78. package/dist/plugins/actions/intl.d.ts +2 -0
  79. package/dist/plugins/actions/intl.js +21 -0
  80. package/dist/plugins/actions/intl.js.map +7 -0
  81. package/dist/plugins/actions/peek.d.ts +2 -0
  82. package/dist/plugins/actions/peek.js +6 -0
  83. package/dist/plugins/actions/peek.js.map +7 -0
  84. package/dist/plugins/actions/setAll.d.ts +2 -0
  85. package/dist/plugins/actions/setAll.js +11 -0
  86. package/dist/plugins/actions/setAll.js.map +7 -0
  87. package/dist/plugins/actions/toggleAll.d.ts +2 -0
  88. package/dist/plugins/actions/toggleAll.js +11 -0
  89. package/dist/plugins/actions/toggleAll.js.map +7 -0
  90. package/dist/plugins/attributes/attr.d.ts +2 -0
  91. package/dist/plugins/attributes/attr.js +20 -0
  92. package/dist/plugins/attributes/attr.js.map +7 -0
  93. package/dist/plugins/attributes/bind.d.ts +6 -0
  94. package/dist/plugins/attributes/bind.js +81 -0
  95. package/dist/plugins/attributes/bind.js.map +7 -0
  96. package/dist/plugins/attributes/class.d.ts +2 -0
  97. package/dist/plugins/attributes/class.js +22 -0
  98. package/dist/plugins/attributes/class.js.map +7 -0
  99. package/dist/plugins/attributes/computed.d.ts +2 -0
  100. package/dist/plugins/attributes/computed.js +20 -0
  101. package/dist/plugins/attributes/computed.js.map +7 -0
  102. package/dist/plugins/attributes/customValidity.d.ts +2 -0
  103. package/dist/plugins/attributes/customValidity.js +14 -0
  104. package/dist/plugins/attributes/customValidity.js.map +7 -0
  105. package/dist/plugins/attributes/effect.d.ts +2 -0
  106. package/dist/plugins/attributes/effect.js +12 -0
  107. package/dist/plugins/attributes/effect.js.map +7 -0
  108. package/dist/plugins/attributes/indicator.d.ts +2 -0
  109. package/dist/plugins/attributes/indicator.js +20 -0
  110. package/dist/plugins/attributes/indicator.js.map +7 -0
  111. package/dist/plugins/attributes/init.d.ts +2 -0
  112. package/dist/plugins/attributes/init.js +14 -0
  113. package/dist/plugins/attributes/init.js.map +7 -0
  114. package/dist/plugins/attributes/jsonSignals.d.ts +2 -0
  115. package/dist/plugins/attributes/jsonSignals.js +15 -0
  116. package/dist/plugins/attributes/jsonSignals.js.map +7 -0
  117. package/dist/plugins/attributes/matchMedia.d.ts +2 -0
  118. package/dist/plugins/attributes/matchMedia.js +19 -0
  119. package/dist/plugins/attributes/matchMedia.js.map +7 -0
  120. package/dist/plugins/attributes/on.d.ts +5 -0
  121. package/dist/plugins/attributes/on.js +28 -0
  122. package/dist/plugins/attributes/on.js.map +7 -0
  123. package/dist/plugins/attributes/onIntersect.d.ts +2 -0
  124. package/dist/plugins/attributes/onIntersect.js +28 -0
  125. package/dist/plugins/attributes/onIntersect.js.map +7 -0
  126. package/dist/plugins/attributes/onInterval.d.ts +2 -0
  127. package/dist/plugins/attributes/onInterval.js +18 -0
  128. package/dist/plugins/attributes/onInterval.js.map +7 -0
  129. package/dist/plugins/attributes/onRaf.d.ts +1 -0
  130. package/dist/plugins/attributes/onRaf.js +19 -0
  131. package/dist/plugins/attributes/onRaf.js.map +7 -0
  132. package/dist/plugins/attributes/onResize.d.ts +1 -0
  133. package/dist/plugins/attributes/onResize.js +17 -0
  134. package/dist/plugins/attributes/onResize.js.map +7 -0
  135. package/dist/plugins/attributes/onSignalPatch.d.ts +5 -0
  136. package/dist/plugins/attributes/onSignalPatch.js +35 -0
  137. package/dist/plugins/attributes/onSignalPatch.js.map +7 -0
  138. package/dist/plugins/attributes/persist.d.ts +6 -0
  139. package/dist/plugins/attributes/persist.js +16 -0
  140. package/dist/plugins/attributes/persist.js.map +7 -0
  141. package/dist/plugins/attributes/queryString.d.ts +5 -0
  142. package/dist/plugins/attributes/queryString.js +54 -0
  143. package/dist/plugins/attributes/queryString.js.map +7 -0
  144. package/dist/plugins/attributes/ref.d.ts +2 -0
  145. package/dist/plugins/attributes/ref.js +13 -0
  146. package/dist/plugins/attributes/ref.js.map +7 -0
  147. package/dist/plugins/attributes/replaceUrl.d.ts +1 -0
  148. package/dist/plugins/attributes/replaceUrl.js +11 -0
  149. package/dist/plugins/attributes/replaceUrl.js.map +7 -0
  150. package/dist/plugins/attributes/scrollIntoView.d.ts +2 -0
  151. package/dist/plugins/attributes/scrollIntoView.js +19 -0
  152. package/dist/plugins/attributes/scrollIntoView.js.map +7 -0
  153. package/dist/plugins/attributes/show.d.ts +2 -0
  154. package/dist/plugins/attributes/show.js +19 -0
  155. package/dist/plugins/attributes/show.js.map +7 -0
  156. package/dist/plugins/attributes/signals.d.ts +2 -0
  157. package/dist/plugins/attributes/signals.js +13 -0
  158. package/dist/plugins/attributes/signals.js.map +7 -0
  159. package/dist/plugins/attributes/style.d.ts +2 -0
  160. package/dist/plugins/attributes/style.js +25 -0
  161. package/dist/plugins/attributes/style.js.map +7 -0
  162. package/dist/plugins/attributes/text.d.ts +1 -0
  163. package/dist/plugins/attributes/text.js +13 -0
  164. package/dist/plugins/attributes/text.js.map +7 -0
  165. package/dist/plugins/attributes/viewTransition.d.ts +1 -0
  166. package/dist/plugins/attributes/viewTransition.js +11 -0
  167. package/dist/plugins/attributes/viewTransition.js.map +7 -0
  168. package/dist/plugins/directives/attribute-sync.d.ts +2 -0
  169. package/dist/plugins/directives/attribute-sync.js +20 -0
  170. package/dist/plugins/directives/attribute-sync.js.map +7 -0
  171. package/dist/plugins/directives/boost.d.ts +6 -0
  172. package/dist/plugins/directives/boost.js +35 -0
  173. package/dist/plugins/directives/boost.js.map +7 -0
  174. package/dist/plugins/directives/busy-flag.d.ts +2 -0
  175. package/dist/plugins/directives/busy-flag.js +21 -0
  176. package/dist/plugins/directives/busy-flag.js.map +7 -0
  177. package/dist/plugins/directives/class-toggle.d.ts +2 -0
  178. package/dist/plugins/directives/class-toggle.js +22 -0
  179. package/dist/plugins/directives/class-toggle.js.map +7 -0
  180. package/dist/plugins/directives/cloak.d.ts +5 -0
  181. package/dist/plugins/directives/cloak.js +11 -0
  182. package/dist/plugins/directives/cloak.js.map +7 -0
  183. package/dist/plugins/directives/collapse.d.ts +5 -0
  184. package/dist/plugins/directives/collapse.js +42 -0
  185. package/dist/plugins/directives/collapse.js.map +7 -0
  186. package/dist/plugins/directives/declare.d.ts +2 -0
  187. package/dist/plugins/directives/declare.js +13 -0
  188. package/dist/plugins/directives/declare.js.map +7 -0
  189. package/dist/plugins/directives/derive.d.ts +2 -0
  190. package/dist/plugins/directives/derive.js +20 -0
  191. package/dist/plugins/directives/derive.js.map +7 -0
  192. package/dist/plugins/directives/element-ref.d.ts +2 -0
  193. package/dist/plugins/directives/element-ref.js +13 -0
  194. package/dist/plugins/directives/element-ref.js.map +7 -0
  195. package/dist/plugins/directives/event-listener.d.ts +5 -0
  196. package/dist/plugins/directives/event-listener.js +28 -0
  197. package/dist/plugins/directives/event-listener.js.map +7 -0
  198. package/dist/plugins/directives/frame-loop.d.ts +1 -0
  199. package/dist/plugins/directives/frame-loop.js +19 -0
  200. package/dist/plugins/directives/frame-loop.js.map +7 -0
  201. package/dist/plugins/directives/html.d.ts +2 -0
  202. package/dist/plugins/directives/html.js +13 -0
  203. package/dist/plugins/directives/html.js.map +7 -0
  204. package/dist/plugins/directives/inline-style.d.ts +2 -0
  205. package/dist/plugins/directives/inline-style.js +25 -0
  206. package/dist/plugins/directives/inline-style.js.map +7 -0
  207. package/dist/plugins/directives/mask.d.ts +7 -0
  208. package/dist/plugins/directives/mask.js +47 -0
  209. package/dist/plugins/directives/mask.js.map +7 -0
  210. package/dist/plugins/directives/media-query.d.ts +2 -0
  211. package/dist/plugins/directives/media-query.js +19 -0
  212. package/dist/plugins/directives/media-query.js.map +7 -0
  213. package/dist/plugins/directives/on-mount.d.ts +2 -0
  214. package/dist/plugins/directives/on-mount.js +14 -0
  215. package/dist/plugins/directives/on-mount.js.map +7 -0
  216. package/dist/plugins/directives/patch-listener.d.ts +5 -0
  217. package/dist/plugins/directives/patch-listener.js +35 -0
  218. package/dist/plugins/directives/patch-listener.js.map +7 -0
  219. package/dist/plugins/directives/remove-me.d.ts +2 -0
  220. package/dist/plugins/directives/remove-me.js +13 -0
  221. package/dist/plugins/directives/remove-me.js.map +7 -0
  222. package/dist/plugins/directives/scroll-to.d.ts +2 -0
  223. package/dist/plugins/directives/scroll-to.js +19 -0
  224. package/dist/plugins/directives/scroll-to.js.map +7 -0
  225. package/dist/plugins/directives/size-watch.d.ts +1 -0
  226. package/dist/plugins/directives/size-watch.js +17 -0
  227. package/dist/plugins/directives/size-watch.js.map +7 -0
  228. package/dist/plugins/directives/state-dump.d.ts +2 -0
  229. package/dist/plugins/directives/state-dump.js +15 -0
  230. package/dist/plugins/directives/state-dump.js.map +7 -0
  231. package/dist/plugins/directives/storage-sync.d.ts +6 -0
  232. package/dist/plugins/directives/storage-sync.js +16 -0
  233. package/dist/plugins/directives/storage-sync.js.map +7 -0
  234. package/dist/plugins/directives/teleport.d.ts +5 -0
  235. package/dist/plugins/directives/teleport.js +19 -0
  236. package/dist/plugins/directives/teleport.js.map +7 -0
  237. package/dist/plugins/directives/text-content.d.ts +1 -0
  238. package/dist/plugins/directives/text-content.js +13 -0
  239. package/dist/plugins/directives/text-content.js.map +7 -0
  240. package/dist/plugins/directives/timer.d.ts +2 -0
  241. package/dist/plugins/directives/timer.js +18 -0
  242. package/dist/plugins/directives/timer.js.map +7 -0
  243. package/dist/plugins/directives/transition-name.d.ts +1 -0
  244. package/dist/plugins/directives/transition-name.js +11 -0
  245. package/dist/plugins/directives/transition-name.js.map +7 -0
  246. package/dist/plugins/directives/transition.d.ts +5 -0
  247. package/dist/plugins/directives/transition.js +40 -0
  248. package/dist/plugins/directives/transition.js.map +7 -0
  249. package/dist/plugins/directives/trap.d.ts +5 -0
  250. package/dist/plugins/directives/trap.js +48 -0
  251. package/dist/plugins/directives/trap.js.map +7 -0
  252. package/dist/plugins/directives/tween.d.ts +6 -0
  253. package/dist/plugins/directives/tween.js +58 -0
  254. package/dist/plugins/directives/tween.js.map +7 -0
  255. package/dist/plugins/directives/two-way-bind.d.ts +6 -0
  256. package/dist/plugins/directives/two-way-bind.js +82 -0
  257. package/dist/plugins/directives/two-way-bind.js.map +7 -0
  258. package/dist/plugins/directives/url-params.d.ts +13 -0
  259. package/dist/plugins/directives/url-params.js +76 -0
  260. package/dist/plugins/directives/url-params.js.map +7 -0
  261. package/dist/plugins/directives/url-replace.d.ts +1 -0
  262. package/dist/plugins/directives/url-replace.js +11 -0
  263. package/dist/plugins/directives/url-replace.js.map +7 -0
  264. package/dist/plugins/directives/validity.d.ts +2 -0
  265. package/dist/plugins/directives/validity.js +14 -0
  266. package/dist/plugins/directives/validity.js.map +7 -0
  267. package/dist/plugins/directives/viewport.d.ts +2 -0
  268. package/dist/plugins/directives/viewport.js +28 -0
  269. package/dist/plugins/directives/viewport.js.map +7 -0
  270. package/dist/plugins/directives/visibility.d.ts +2 -0
  271. package/dist/plugins/directives/visibility.js +19 -0
  272. package/dist/plugins/directives/visibility.js.map +7 -0
  273. package/dist/plugins/directives/watch.d.ts +2 -0
  274. package/dist/plugins/directives/watch.js +12 -0
  275. package/dist/plugins/directives/watch.js.map +7 -0
  276. package/dist/plugins/functions/bulk-set.d.ts +2 -0
  277. package/dist/plugins/functions/bulk-set.js +11 -0
  278. package/dist/plugins/functions/bulk-set.js.map +7 -0
  279. package/dist/plugins/functions/bulk-toggle.d.ts +2 -0
  280. package/dist/plugins/functions/bulk-toggle.js +11 -0
  281. package/dist/plugins/functions/bulk-toggle.js.map +7 -0
  282. package/dist/plugins/functions/confirm.d.ts +2 -0
  283. package/dist/plugins/functions/confirm.js +6 -0
  284. package/dist/plugins/functions/confirm.js.map +7 -0
  285. package/dist/plugins/functions/copy-text.d.ts +2 -0
  286. package/dist/plugins/functions/copy-text.js +11 -0
  287. package/dist/plugins/functions/copy-text.js.map +7 -0
  288. package/dist/plugins/functions/dispatch.d.ts +2 -0
  289. package/dist/plugins/functions/dispatch.js +9 -0
  290. package/dist/plugins/functions/dispatch.js.map +7 -0
  291. package/dist/plugins/functions/locale-format.d.ts +2 -0
  292. package/dist/plugins/functions/locale-format.js +21 -0
  293. package/dist/plugins/functions/locale-format.js.map +7 -0
  294. package/dist/plugins/functions/range-map.d.ts +2 -0
  295. package/dist/plugins/functions/range-map.js +14 -0
  296. package/dist/plugins/functions/range-map.js.map +7 -0
  297. package/dist/plugins/functions/request.d.ts +30 -0
  298. package/dist/plugins/functions/request.js +152 -0
  299. package/dist/plugins/functions/request.js.map +7 -0
  300. package/dist/plugins/functions/untracked-read.d.ts +2 -0
  301. package/dist/plugins/functions/untracked-read.js +6 -0
  302. package/dist/plugins/functions/untracked-read.js.map +7 -0
  303. package/dist/plugins/functions/websocket.d.ts +11 -0
  304. package/dist/plugins/functions/websocket.js +35 -0
  305. package/dist/plugins/functions/websocket.js.map +7 -0
  306. package/dist/plugins/index.d.ts +52 -0
  307. package/dist/plugins/index.js +108 -0
  308. package/dist/plugins/index.js.map +7 -0
  309. package/dist/plugins/server-events/apply-elements.d.ts +2 -0
  310. package/dist/plugins/server-events/apply-elements.js +62 -0
  311. package/dist/plugins/server-events/apply-elements.js.map +7 -0
  312. package/dist/plugins/server-events/apply-state.d.ts +2 -0
  313. package/dist/plugins/server-events/apply-state.js +18 -0
  314. package/dist/plugins/server-events/apply-state.js.map +7 -0
  315. package/dist/plugins/server-events/morph.d.ts +12 -0
  316. package/dist/plugins/server-events/morph.js +124 -0
  317. package/dist/plugins/server-events/morph.js.map +7 -0
  318. package/dist/presets/all.d.ts +3 -0
  319. package/dist/presets/all.js +112 -0
  320. package/dist/presets/all.js.map +7 -0
  321. package/dist/presets/essentials.d.ts +3 -0
  322. package/dist/presets/essentials.js +18 -0
  323. package/dist/presets/essentials.js.map +7 -0
  324. package/dist/presets/minimal.d.ts +3 -0
  325. package/dist/presets/minimal.js +9 -0
  326. package/dist/presets/minimal.js.map +7 -0
  327. package/dist/sigmx.auto.js +5 -0
  328. package/dist/sigmx.standalone.js +1 -0
  329. package/dist/standalone.d.ts +1 -0
  330. package/dist/standalone.js +8 -0
  331. package/dist/standalone.js.map +7 -0
  332. package/dist/utils/object.d.ts +9 -0
  333. package/dist/utils/object.js +26 -0
  334. package/dist/utils/object.js.map +7 -0
  335. package/dist/utils/text.d.ts +7 -0
  336. package/dist/utils/text.js +15 -0
  337. package/dist/utils/text.js.map +7 -0
  338. package/dist/utils/timing.d.ts +14 -0
  339. package/dist/utils/timing.js +58 -0
  340. package/dist/utils/timing.js.map +7 -0
  341. package/dist/vite.d.ts +42 -0
  342. package/dist/vite.js +79 -0
  343. package/dist/vite.js.map +7 -0
  344. package/package.json +111 -0
@@ -0,0 +1,76 @@
1
+ import { attribute, expand, toPredicate } from "../../kernel/index.js";
2
+ const parse = (s) => {
3
+ try {
4
+ return JSON.parse(s);
5
+ } catch {
6
+ return s;
7
+ }
8
+ };
9
+ const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
10
+ const queryString = attribute({
11
+ name: "query-string",
12
+ mount({ key, value, mods, evaluate, cased, store, listen, effect }) {
13
+ const history = mods.has("history");
14
+ const push = (url) => {
15
+ if (url !== location.pathname + location.search + location.hash) window.history[history ? "pushState" : "replaceState"](null, "", url);
16
+ };
17
+ const urlWith = (q) => `${location.pathname}${q.size ? `?${q}` : ""}${location.hash}`;
18
+ let restoring = false;
19
+ const restore = (fn) => {
20
+ restoring = true;
21
+ try {
22
+ fn();
23
+ } finally {
24
+ restoring = false;
25
+ }
26
+ };
27
+ if (key) {
28
+ const path = cased();
29
+ const fallback = value ? evaluate() : "";
30
+ const fromUrl2 = () => {
31
+ const raw = new URLSearchParams(location.search).get(key);
32
+ store.set(path, raw === null ? fallback : parse(raw));
33
+ };
34
+ if (!store.has(path) || new URLSearchParams(location.search).has(key)) fromUrl2();
35
+ effect(() => {
36
+ const v = store.get(path);
37
+ if (restoring) return;
38
+ const q = new URLSearchParams(location.search);
39
+ if (v === void 0 || same(v, fallback)) q.delete(key);
40
+ else q.set(key, typeof v === "string" ? v : JSON.stringify(v));
41
+ push(urlWith(q));
42
+ });
43
+ if (history) listen(window, "popstate", () => restore(fromUrl2));
44
+ return;
45
+ }
46
+ const filter = value ? evaluate() : void 0;
47
+ const ok = toPredicate(filter);
48
+ const fromUrl = () => {
49
+ const patch = {};
50
+ for (const [k, v] of new URLSearchParams(location.search)) if (ok(k)) expand(patch, k, parse(v));
51
+ store.merge(patch);
52
+ };
53
+ fromUrl();
54
+ effect(() => {
55
+ const snap = store.snapshot(filter, { computed: false });
56
+ if (restoring) return;
57
+ const q = new URLSearchParams(location.search);
58
+ const walk = (obj, prefix) => {
59
+ for (const k in obj) {
60
+ const p = prefix ? `${prefix}.${k}` : k;
61
+ const v = obj[k];
62
+ if (v && typeof v === "object" && !Array.isArray(v)) walk(v, p);
63
+ else if (mods.has("filter") && (v === "" || v == null)) q.delete(p);
64
+ else q.set(p, typeof v === "string" ? v : JSON.stringify(v));
65
+ }
66
+ };
67
+ walk(snap, "");
68
+ push(urlWith(q));
69
+ });
70
+ if (history) listen(window, "popstate", () => restore(fromUrl));
71
+ }
72
+ });
73
+ export {
74
+ queryString
75
+ };
76
+ //# sourceMappingURL=url-params.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/url-params.ts"],
4
+ "sourcesContent": ["import { attribute, expand, toPredicate } from '../../kernel/index.js'\n\nconst parse = (s: string): unknown => {\n try {\n return JSON.parse(s)\n } catch {\n return s\n }\n}\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)\n\n/**\n * Keeps signals and the URL query string in step.\n *\n * Keyed form declares one signal with a default: `query-string:page=\"1\"` creates `page`, reads\n * `?page=` on load when present (otherwise uses the default), writes it whenever it changes, and\n * drops the parameter again when the value is back at the default. The parameter name is the key\n * as written; the signal name is recased as usual.\n *\n * Bare form syncs existing signals: `query-string=\"{ include: /^(q|sort)$/ }\"` mirrors matching\n * paths both ways. `__history` pushes an entry per change and restores on back/forward;\n * `__filter` drops empty values from the URL.\n */\nexport const queryString = attribute({\n name: 'query-string',\n mount({ key, value, mods, evaluate, cased, store, listen, effect }) {\n const history = mods.has('history')\n const push = (url: string) => {\n if (url !== location.pathname + location.search + location.hash) window.history[history ? 'pushState' : 'replaceState'](null, '', url)\n }\n const urlWith = (q: URLSearchParams) => `${location.pathname}${q.size ? `?${q}` : ''}${location.hash}`\n let restoring = false\n const restore = (fn: () => void) => {\n restoring = true\n try {\n fn()\n } finally {\n restoring = false\n }\n }\n\n if (key) {\n const path = cased()\n const fallback = value ? evaluate() : ''\n const fromUrl = () => {\n const raw = new URLSearchParams(location.search).get(key)\n store.set(path, raw === null ? fallback : parse(raw))\n }\n if (!store.has(path) || new URLSearchParams(location.search).has(key)) fromUrl()\n effect(() => {\n const v = store.get(path)\n if (restoring) return\n const q = new URLSearchParams(location.search)\n if (v === undefined || same(v, fallback)) q.delete(key)\n else q.set(key, typeof v === 'string' ? v : JSON.stringify(v))\n push(urlWith(q))\n })\n if (history) listen(window, 'popstate', () => restore(fromUrl))\n return\n }\n\n const filter = value ? evaluate() : undefined\n const ok = toPredicate(filter)\n const fromUrl = () => {\n const patch = {}\n for (const [k, v] of new URLSearchParams(location.search)) if (ok(k)) expand(patch, k, parse(v))\n store.merge(patch)\n }\n fromUrl()\n effect(() => {\n const snap = store.snapshot(filter, { computed: false })\n if (restoring) return\n const q = new URLSearchParams(location.search)\n const walk = (obj: Record<string, any>, prefix: string) => {\n for (const k in obj) {\n const p = prefix ? `${prefix}.${k}` : k\n const v = obj[k]\n if (v && typeof v === 'object' && !Array.isArray(v)) walk(v, p)\n else if (mods.has('filter') && (v === '' || v == null)) q.delete(p)\n else q.set(p, typeof v === 'string' ? v : JSON.stringify(v))\n }\n }\n walk(snap, '')\n push(urlWith(q))\n })\n if (history) listen(window, 'popstate', () => restore(fromUrl))\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,WAAW,QAAQ,mBAAmB;AAE/C,MAAM,QAAQ,CAAC,MAAuB;AACpC,MAAI;AACF,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AACA,MAAM,OAAO,CAAC,GAAY,MAAe,KAAK,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAcxE,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,MAAM,EAAE,KAAK,OAAO,MAAM,UAAU,OAAO,OAAO,QAAQ,OAAO,GAAG;AAClE,UAAM,UAAU,KAAK,IAAI,SAAS;AAClC,UAAM,OAAO,CAAC,QAAgB;AAC5B,UAAI,QAAQ,SAAS,WAAW,SAAS,SAAS,SAAS,KAAM,QAAO,QAAQ,UAAU,cAAc,cAAc,EAAE,MAAM,IAAI,GAAG;AAAA,IACvI;AACA,UAAM,UAAU,CAAC,MAAuB,GAAG,SAAS,QAAQ,GAAG,EAAE,OAAO,IAAI,CAAC,KAAK,EAAE,GAAG,SAAS,IAAI;AACpG,QAAI,YAAY;AAChB,UAAM,UAAU,CAAC,OAAmB;AAClC,kBAAY;AACZ,UAAI;AACF,WAAG;AAAA,MACL,UAAE;AACA,oBAAY;AAAA,MACd;AAAA,IACF;AAEA,QAAI,KAAK;AACP,YAAM,OAAO,MAAM;AACnB,YAAM,WAAW,QAAQ,SAAS,IAAI;AACtC,YAAMA,WAAU,MAAM;AACpB,cAAM,MAAM,IAAI,gBAAgB,SAAS,MAAM,EAAE,IAAI,GAAG;AACxD,cAAM,IAAI,MAAM,QAAQ,OAAO,WAAW,MAAM,GAAG,CAAC;AAAA,MACtD;AACA,UAAI,CAAC,MAAM,IAAI,IAAI,KAAK,IAAI,gBAAgB,SAAS,MAAM,EAAE,IAAI,GAAG,EAAG,CAAAA,SAAQ;AAC/E,aAAO,MAAM;AACX,cAAM,IAAI,MAAM,IAAI,IAAI;AACxB,YAAI,UAAW;AACf,cAAM,IAAI,IAAI,gBAAgB,SAAS,MAAM;AAC7C,YAAI,MAAM,UAAa,KAAK,GAAG,QAAQ,EAAG,GAAE,OAAO,GAAG;AAAA,YACjD,GAAE,IAAI,KAAK,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC,CAAC;AAC7D,aAAK,QAAQ,CAAC,CAAC;AAAA,MACjB,CAAC;AACD,UAAI,QAAS,QAAO,QAAQ,YAAY,MAAM,QAAQA,QAAO,CAAC;AAC9D;AAAA,IACF;AAEA,UAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,UAAM,KAAK,YAAY,MAAM;AAC7B,UAAM,UAAU,MAAM;AACpB,YAAM,QAAQ,CAAC;AACf,iBAAW,CAAC,GAAG,CAAC,KAAK,IAAI,gBAAgB,SAAS,MAAM,EAAG,KAAI,GAAG,CAAC,EAAG,QAAO,OAAO,GAAG,MAAM,CAAC,CAAC;AAC/F,YAAM,MAAM,KAAK;AAAA,IACnB;AACA,YAAQ;AACR,WAAO,MAAM;AACX,YAAM,OAAO,MAAM,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;AACvD,UAAI,UAAW;AACf,YAAM,IAAI,IAAI,gBAAgB,SAAS,MAAM;AAC7C,YAAM,OAAO,CAAC,KAA0B,WAAmB;AACzD,mBAAW,KAAK,KAAK;AACnB,gBAAM,IAAI,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK;AACtC,gBAAM,IAAI,IAAI,CAAC;AACf,cAAI,KAAK,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,CAAC,EAAG,MAAK,GAAG,CAAC;AAAA,mBACrD,KAAK,IAAI,QAAQ,MAAM,MAAM,MAAM,KAAK,MAAO,GAAE,OAAO,CAAC;AAAA,cAC7D,GAAE,IAAI,GAAG,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC,CAAC;AAAA,QAC7D;AAAA,MACF;AACA,WAAK,MAAM,EAAE;AACb,WAAK,QAAQ,CAAC,CAAC;AAAA,IACjB,CAAC;AACD,QAAI,QAAS,QAAO,QAAQ,YAAY,MAAM,QAAQ,OAAO,CAAC;AAAA,EAChE;AACF,CAAC;",
6
+ "names": ["fromUrl"]
7
+ }
@@ -0,0 +1 @@
1
+ export declare const replaceUrl: import("../../kernel/contracts.js").AttributePlugin;
@@ -0,0 +1,11 @@
1
+ import { attribute } from "../../kernel/index.js";
2
+ const replaceUrl = attribute({
3
+ name: "replace-url",
4
+ key: "forbidden",
5
+ value: "required",
6
+ mount: ({ evaluate, effect }) => effect(() => history.replaceState(history.state, "", new URL(String(evaluate()), location.href)))
7
+ });
8
+ export {
9
+ replaceUrl
10
+ };
11
+ //# sourceMappingURL=url-replace.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/url-replace.ts"],
4
+ "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\nexport const replaceUrl = attribute({\n name: 'replace-url',\n key: 'forbidden',\n value: 'required',\n mount: ({ evaluate, effect }) =>\n effect(() => history.replaceState(history.state, '', new URL(String(evaluate()), location.href))),\n})\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,CAAC,EAAE,UAAU,OAAO,MACzB,OAAO,MAAM,QAAQ,aAAa,QAAQ,OAAO,IAAI,IAAI,IAAI,OAAO,SAAS,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;AACpG,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** The expression's string becomes the field's validity message; '' means valid. */
2
+ export declare const customValidity: import("../../kernel/contracts.js").AttributePlugin;
@@ -0,0 +1,14 @@
1
+ import { attribute } from "../../kernel/index.js";
2
+ const customValidity = attribute({
3
+ name: "custom-validity",
4
+ key: "forbidden",
5
+ value: "required",
6
+ mount({ el, evaluate, effect, error }) {
7
+ if (!("setCustomValidity" in el)) throw error("only works on form fields");
8
+ effect(() => el.setCustomValidity(String(evaluate() ?? "")));
9
+ }
10
+ });
11
+ export {
12
+ customValidity
13
+ };
14
+ //# sourceMappingURL=validity.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/validity.ts"],
4
+ "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** The expression's string becomes the field's validity message; '' means valid. */\nexport const customValidity = attribute({\n name: 'custom-validity',\n key: 'forbidden',\n value: 'required',\n mount({ el, evaluate, effect, error }) {\n if (!('setCustomValidity' in el)) throw error('only works on form fields')\n effect(() => (el as HTMLInputElement).setCustomValidity(String(evaluate() ?? '')))\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,iBAAiB,UAAU;AAAA,EACtC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,UAAU,QAAQ,MAAM,GAAG;AACrC,QAAI,EAAE,uBAAuB,IAAK,OAAM,MAAM,2BAA2B;AACzE,WAAO,MAAO,GAAwB,kBAAkB,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC;AAAA,EACnF;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Runs when the element enters the viewport. Modifiers: once, exit, full, half, threshold.N. */
2
+ export declare const onIntersect: import("../../kernel/contracts.js").AttributePlugin;
@@ -0,0 +1,28 @@
1
+ import { attribute, withTiming, withViewTransition } from "../../kernel/index.js";
2
+ const onIntersect = attribute({
3
+ name: "on-intersect",
4
+ key: "forbidden",
5
+ value: "required",
6
+ returns: false,
7
+ mount({ el, mods, evaluate }) {
8
+ const t = mods.get("threshold")?.[0];
9
+ const threshold = mods.has("full") ? 1 : mods.has("half") ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0;
10
+ const run = withTiming(withViewTransition(() => evaluate(), mods), mods);
11
+ const io = new IntersectionObserver(
12
+ (entries) => {
13
+ for (const e of entries) {
14
+ if (e.isIntersecting === mods.has("exit")) continue;
15
+ run();
16
+ if (mods.has("once")) io.disconnect();
17
+ }
18
+ },
19
+ { threshold }
20
+ );
21
+ io.observe(el);
22
+ return () => io.disconnect();
23
+ }
24
+ });
25
+ export {
26
+ onIntersect
27
+ };
28
+ //# sourceMappingURL=viewport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/viewport.ts"],
4
+ "sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js'\n\n/** Runs when the element enters the viewport. Modifiers: once, exit, full, half, threshold.N. */\nexport const onIntersect = attribute({\n name: 'on-intersect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ el, mods, evaluate }) {\n const t = mods.get('threshold')?.[0]\n const threshold = mods.has('full') ? 1 : mods.has('half') ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0\n const run = withTiming(withViewTransition(() => evaluate(), mods), mods)\n const io = new IntersectionObserver(\n (entries) => {\n for (const e of entries) {\n if (e.isIntersecting === mods.has('exit')) continue\n run()\n if (mods.has('once')) io.disconnect()\n }\n },\n { threshold },\n )\n io.observe(el)\n return () => io.disconnect()\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,SAAS,GAAG;AAC5B,UAAM,IAAI,KAAK,IAAI,WAAW,IAAI,CAAC;AACnC,UAAM,YAAY,KAAK,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM;AAC7G,UAAM,MAAM,WAAW,mBAAmB,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI;AACvE,UAAM,KAAK,IAAI;AAAA,MACb,CAAC,YAAY;AACX,mBAAW,KAAK,SAAS;AACvB,cAAI,EAAE,mBAAmB,KAAK,IAAI,MAAM,EAAG;AAC3C,cAAI;AACJ,cAAI,KAAK,IAAI,MAAM,EAAG,IAAG,WAAW;AAAA,QACtC;AAAA,MACF;AAAA,MACA,EAAE,UAAU;AAAA,IACd;AACA,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Toggles `display: none`, restoring whatever inline display the element had. */
2
+ export declare const show: import("../../kernel/contracts.js").AttributePlugin;
@@ -0,0 +1,19 @@
1
+ import { attribute } from "../../kernel/index.js";
2
+ const show = attribute({
3
+ name: "show",
4
+ key: "forbidden",
5
+ value: "required",
6
+ mount({ el, evaluate, effect }) {
7
+ const initial = el.style.display === "none" ? "" : el.style.display;
8
+ effect(() => {
9
+ el.style.display = evaluate() ? initial : "none";
10
+ });
11
+ return () => {
12
+ el.style.display = initial;
13
+ };
14
+ }
15
+ });
16
+ export {
17
+ show
18
+ };
19
+ //# sourceMappingURL=visibility.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/visibility.ts"],
4
+ "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Toggles `display: none`, restoring whatever inline display the element had. */\nexport const show = attribute({\n name: 'show',\n key: 'forbidden',\n value: 'required',\n mount({ el, evaluate, effect }) {\n const initial = el.style.display === 'none' ? '' : el.style.display\n effect(() => {\n el.style.display = evaluate() ? initial : 'none'\n })\n return () => {\n el.style.display = initial\n }\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,UAAU,OAAO,GAAG;AAC9B,UAAM,UAAU,GAAG,MAAM,YAAY,SAAS,KAAK,GAAG,MAAM;AAC5D,WAAO,MAAM;AACX,SAAG,MAAM,UAAU,SAAS,IAAI,UAAU;AAAA,IAC5C,CAAC;AACD,WAAO,MAAM;AACX,SAAG,MAAM,UAAU;AAAA,IACrB;AAAA,EACF;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Runs the expression now and whenever a signal it read changes. */
2
+ export declare const effect: import("../../kernel/contracts.js").AttributePlugin;
@@ -0,0 +1,12 @@
1
+ import { attribute } from "../../kernel/index.js";
2
+ const effect = attribute({
3
+ name: "effect",
4
+ key: "forbidden",
5
+ value: "required",
6
+ returns: false,
7
+ mount: (ctx) => ctx.effect(() => ctx.evaluate())
8
+ });
9
+ export {
10
+ effect
11
+ };
12
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/directives/watch.ts"],
4
+ "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Runs the expression now and whenever a signal it read changes. */\nexport const effect = attribute({\n name: 'effect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount: (ctx) => ctx.effect(() => ctx.evaluate()),\n})\n"],
5
+ "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,SAAS,UAAU;AAAA,EAC9B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ,IAAI,OAAO,MAAM,IAAI,SAAS,CAAC;AACjD,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@setAll(value, { include: /^form\./ })` assigns every matching signal. */
2
+ export declare const setAll: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,11 @@
1
+ import { action, batch, untracked } from "../../kernel/index.js";
2
+ const setAll = action({
3
+ name: "setAll",
4
+ call: ({ store }, value, filter) => batch(() => untracked(() => {
5
+ for (const p of store.paths(filter)) store.set(p, value);
6
+ }))
7
+ });
8
+ export {
9
+ setAll
10
+ };
11
+ //# sourceMappingURL=bulk-set.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/bulk-set.ts"],
4
+ "sourcesContent": ["import { action, batch, untracked, type Filter } from '../../kernel/index.js'\n\n/** `@setAll(value, { include: /^form\\./ })` assigns every matching signal. */\nexport const setAll = action({\n name: 'setAll',\n call: ({ store }, value: unknown, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, value) })),\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,SAAS,OAAO;AAAA,EAC3B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,OAAgB,WAChC,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,KAAK;AAAA,EAAE,CAAC,CAAC;AAC7F,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@toggleAll({ include: /^flags\./ })` negates every matching boolean signal. */
2
+ export declare const toggleAll: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,11 @@
1
+ import { action, batch, untracked } from "../../kernel/index.js";
2
+ const toggleAll = action({
3
+ name: "toggleAll",
4
+ call: ({ store }, filter) => batch(() => untracked(() => {
5
+ for (const p of store.paths(filter)) store.set(p, !store.get(p));
6
+ }))
7
+ });
8
+ export {
9
+ toggleAll
10
+ };
11
+ //# sourceMappingURL=bulk-toggle.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/bulk-toggle.ts"],
4
+ "sourcesContent": ["import { action, batch, untracked, type Filter } from '../../kernel/index.js'\n\n/** `@toggleAll({ include: /^flags\\./ })` negates every matching boolean signal. */\nexport const toggleAll = action({\n name: 'toggleAll',\n call: ({ store }, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, !store.get(p)) })),\n})\n"],
5
+ "mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,WAChB,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAAA,EAAE,CAAC,CAAC;AACrG,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@confirm('Delete?') && @delete('/x')` asks before continuing. */
2
+ export declare const confirm: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,6 @@
1
+ import { action } from "../../kernel/index.js";
2
+ const confirm = action({ name: "confirm", call: (_, message) => window.confirm(message) });
3
+ export {
4
+ confirm
5
+ };
6
+ //# sourceMappingURL=confirm.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/confirm.ts"],
4
+ "sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@confirm('Delete?') && @delete('/x')` asks before continuing. */\nexport const confirm = action({ name: 'confirm', call: (_, message: string) => window.confirm(message) })\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,UAAU,OAAO,EAAE,MAAM,WAAW,MAAM,CAAC,GAAG,YAAoB,OAAO,QAAQ,OAAO,EAAE,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@clipboard(text, isBase64?)` copies text; base64 input is decoded first. */
2
+ export declare const clipboard: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,11 @@
1
+ import { action } from "../../kernel/index.js";
2
+ const clipboard = action({
3
+ name: "clipboard",
4
+ call: (_, text, base64 = false) => navigator.clipboard.writeText(
5
+ base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text
6
+ )
7
+ });
8
+ export {
9
+ clipboard
10
+ };
11
+ //# sourceMappingURL=copy-text.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/copy-text.ts"],
4
+ "sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@clipboard(text, isBase64?)` copies text; base64 input is decoded first. */\nexport const clipboard = action({\n name: 'clipboard',\n call: (_, text: string, base64 = false) =>\n navigator.clipboard.writeText(\n base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text,\n ),\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,MAAc,SAAS,UAC/B,UAAU,UAAU;AAAA,IAClB,SAAS,IAAI,YAAY,EAAE,OAAO,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI;AAAA,EAC3F;AACJ,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@dispatch('name', detail)` fires a bubbling CustomEvent from the element. */
2
+ export declare const dispatch: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,9 @@
1
+ import { action } from "../../kernel/index.js";
2
+ const dispatch = action({
3
+ name: "dispatch",
4
+ call: ({ el }, name, detail) => el.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }))
5
+ });
6
+ export {
7
+ dispatch
8
+ };
9
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/dispatch.ts"],
4
+ "sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@dispatch('name', detail)` fires a bubbling CustomEvent from the element. */\nexport const dispatch = action({\n name: 'dispatch',\n call: ({ el }, name: string, detail?: unknown) => el.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true })),\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,WAAW,OAAO;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,GAAG,GAAG,MAAc,WAAqB,GAAG,cAAc,IAAI,YAAY,MAAM,EAAE,QAAQ,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AACrI,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@intl('number', 1234.5, { style: 'currency', currency: 'USD' }, 'en-US')`. */
2
+ export declare const intl: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,21 @@
1
+ import { action } from "../../kernel/index.js";
2
+ const formats = {
3
+ number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),
4
+ datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),
5
+ pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),
6
+ relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),
7
+ list: (l, v, o) => new Intl.ListFormat(l, o).format(v),
8
+ displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? ""
9
+ };
10
+ const intl = action({
11
+ name: "intl",
12
+ call: ({ error }, type, value, options, locale) => {
13
+ const f = formats[type];
14
+ if (!f) throw error(`unknown @intl type "${type}"`);
15
+ return f(locale, value, options);
16
+ }
17
+ });
18
+ export {
19
+ intl
20
+ };
21
+ //# sourceMappingURL=locale-format.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/locale-format.ts"],
4
+ "sourcesContent": ["import { action } from '../../kernel/index.js'\n\ntype Fmt = (locale: string | string[] | undefined, value: any, options: any) => string\nconst formats: Record<string, Fmt> = {\n number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),\n datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),\n pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),\n relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),\n list: (l, v, o) => new Intl.ListFormat(l, o).format(v),\n displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? '',\n}\n\n/** `@intl('number', 1234.5, { style: 'currency', currency: 'USD' }, 'en-US')`. */\nexport const intl = action({\n name: 'intl',\n call: ({ error }, type: string, value: unknown, options?: Record<string, unknown>, locale?: string | string[]) => {\n const f = formats[type]\n if (!f) throw error(`unknown @intl type \"${type}\"`)\n return f(locale, value, options)\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGvB,MAAM,UAA+B;AAAA,EACnC,QAAQ,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACzD,UAAU,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,eAAe,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,aAAa,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,YAAY,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAA,EAC9E,MAAM,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,WAAW,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACrD,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK;AAClE;AAGO,MAAM,OAAO,OAAO;AAAA,EACzB,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,MAAc,OAAgB,SAAmC,WAA+B;AAChH,UAAM,IAAI,QAAQ,IAAI;AACtB,QAAI,CAAC,EAAG,OAAM,MAAM,uBAAuB,IAAI,GAAG;AAClD,WAAO,EAAE,QAAQ,OAAO,OAAO;AAAA,EACjC;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Map `v` from [inMin, inMax] onto [outMin, outMax]; optionally clamp and round. */
2
+ export declare const fit: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,14 @@
1
+ import { action } from "../../kernel/index.js";
2
+ const fit = action({
3
+ name: "fit",
4
+ call: (_, v, inMin, inMax, outMin, outMax, clamp = false, round = false) => {
5
+ let t = (v - inMin) / (inMax - inMin);
6
+ if (clamp) t = Math.min(1, Math.max(0, t));
7
+ const out = outMin + t * (outMax - outMin);
8
+ return round ? Math.round(out) : out;
9
+ }
10
+ });
11
+ export {
12
+ fit
13
+ };
14
+ //# sourceMappingURL=range-map.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/functions/range-map.ts"],
4
+ "sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** Map `v` from [inMin, inMax] onto [outMin, outMax]; optionally clamp and round. */\nexport const fit = action({\n name: 'fit',\n call: (_, v: number, inMin: number, inMax: number, outMin: number, outMax: number, clamp = false, round = false) => {\n let t = (v - inMin) / (inMax - inMin)\n if (clamp) t = Math.min(1, Math.max(0, t))\n const out = outMin + t * (outMax - outMin)\n return round ? Math.round(out) : out\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,MAAM,OAAO;AAAA,EACxB,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,GAAW,OAAe,OAAe,QAAgB,QAAgB,QAAQ,OAAO,QAAQ,UAAU;AAClH,QAAI,KAAK,IAAI,UAAU,QAAQ;AAC/B,QAAI,MAAO,KAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACzC,UAAM,MAAM,SAAS,KAAK,SAAS;AACnC,WAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;AAAA,EACnC;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ import { type Filter } from '../../kernel/index.js';
2
+ export type RequestOptions = {
3
+ headers?: Record<string, string>;
4
+ /** 'json' (default) sends filtered signals; 'form' serialises the closest (or `selector`) form. */
5
+ contentType?: 'json' | 'form';
6
+ selector?: string;
7
+ /** Which signals to send. Default: everything except paths starting with `_`. */
8
+ filter?: Filter;
9
+ /** Explicit body instead of signals. */
10
+ payload?: unknown;
11
+ /** 'replace' (default) aborts an earlier request with the same method and URL; 'none' lets them overlap. */
12
+ abort?: 'replace' | 'none' | AbortController;
13
+ /** Keep the connection open while the tab is hidden. Default: true except for GET streams. */
14
+ openWhenHidden?: boolean;
15
+ /** Reconnect after a stream closes normally (long-lived event streams). */
16
+ reconnect?: boolean;
17
+ retry?: {
18
+ attempts?: number;
19
+ interval?: number;
20
+ factor?: number;
21
+ max?: number;
22
+ onStatusError?: boolean;
23
+ };
24
+ };
25
+ /** `@get(url, options)`: signals travel in the `sigmx` query parameter. */
26
+ export declare const httpGet: import("../../kernel/contracts.js").ActionPlugin;
27
+ export declare const httpPost: import("../../kernel/contracts.js").ActionPlugin;
28
+ export declare const httpPut: import("../../kernel/contracts.js").ActionPlugin;
29
+ export declare const httpPatch: import("../../kernel/contracts.js").ActionPlugin;
30
+ export declare const httpDelete: import("../../kernel/contracts.js").ActionPlugin;
@@ -0,0 +1,152 @@
1
+ import { action, untracked } from "../../kernel/index.js";
2
+ import { camel } from "../../lib/casing.js";
3
+ import { parseFields, readEvents } from "../../lib/sse.js";
4
+ const inflight = /* @__PURE__ */ new Map();
5
+ let seq = 0;
6
+ const sleep = (ms, signal) => new Promise((resolve) => {
7
+ const t = setTimeout(resolve, ms);
8
+ signal.addEventListener("abort", () => (clearTimeout(t), resolve()), { once: true });
9
+ });
10
+ const untilVisible = () => new Promise((resolve) => document.addEventListener("visibilitychange", () => !document.hidden && resolve(), { once: true }));
11
+ const headerArgs = (res, names, data) => {
12
+ for (const n of names) {
13
+ const v = res.headers.get(`sigmx-${n}`);
14
+ if (v) data[camel(n)] = v;
15
+ }
16
+ return data;
17
+ };
18
+ const runScript = (text) => {
19
+ const s = document.createElement("script");
20
+ s.text = text;
21
+ document.head.append(s);
22
+ s.remove();
23
+ };
24
+ const send = async (method, ctx, url, o = {}) => {
25
+ const { el, evt, store, runtime, error } = ctx;
26
+ if (!url) throw error(`@${method.toLowerCase()} needs a URL`);
27
+ const key = `${method} ${url}`;
28
+ const ac = o.abort instanceof AbortController ? o.abort : new AbortController();
29
+ if (o.abort !== "none") {
30
+ inflight.get(key)?.abort();
31
+ inflight.set(key, ac);
32
+ }
33
+ ctx.cleanup(() => ac.abort());
34
+ const rid = ++seq;
35
+ const emit = (type, extra = {}) => runtime.emit("fetch", { el, type, method, url, rid, ...extra });
36
+ const retry = { attempts: 5, interval: 1e3, factor: 2, max: 3e4, onStatusError: false, ...o.retry };
37
+ const pauseWhenHidden = !(o.openWhenHidden ?? method !== "GET");
38
+ const bodyAllowed = method !== "GET" && method !== "DELETE";
39
+ const build = () => {
40
+ const u = new URL(url, location.href);
41
+ const headers = {
42
+ Accept: "text/event-stream, text/html, application/json",
43
+ "Sigmx-Request": "true",
44
+ ...o.headers
45
+ };
46
+ let body;
47
+ if ((o.contentType ?? "json") === "json") {
48
+ const payload = o.payload ?? untracked(() => store.snapshot(o.filter ?? { exclude: /(^|\.)_/ }));
49
+ const json = JSON.stringify(payload);
50
+ if (bodyAllowed) {
51
+ body = json;
52
+ headers["Content-Type"] ??= "application/json";
53
+ } else u.searchParams.set("sigmx", json);
54
+ } else {
55
+ const form = o.selector ? document.querySelector(o.selector) : el.closest("form");
56
+ if (!form) throw error("no form found", { selector: o.selector });
57
+ if (!form.noValidate && !form.checkValidity()) {
58
+ form.reportValidity();
59
+ return;
60
+ }
61
+ const submitter = evt instanceof SubmitEvent ? evt.submitter : el instanceof HTMLButtonElement ? el : null;
62
+ const fd = new FormData(form, submitter);
63
+ const multipart = form.enctype === "multipart/form-data";
64
+ if (bodyAllowed) {
65
+ body = multipart ? fd : new URLSearchParams(fd);
66
+ if (!multipart) headers["Content-Type"] = "application/x-www-form-urlencoded";
67
+ } else {
68
+ for (const [k, v] of new URLSearchParams(fd)) u.searchParams.append(k, v);
69
+ }
70
+ }
71
+ return { url: u.toString(), init: { method, headers, body } };
72
+ };
73
+ const route = (event, data) => {
74
+ const fields = parseFields(data);
75
+ runtime.emit("server-event", { el, event, data: fields });
76
+ runtime.handle(event, fields);
77
+ };
78
+ let attempt = 0;
79
+ let wait = retry.interval;
80
+ let lastId;
81
+ const backoff = async () => {
82
+ if (attempt++ >= retry.attempts) throw new Error("retries exhausted");
83
+ emit("retrying", { attempt });
84
+ await sleep(wait, ac.signal);
85
+ wait = Math.min(wait * retry.factor, retry.max);
86
+ };
87
+ emit("started");
88
+ try {
89
+ while (!ac.signal.aborted) {
90
+ const req = build();
91
+ if (!req) return;
92
+ if (lastId) req.init.headers["Last-Event-ID"] = lastId;
93
+ const hide = new AbortController();
94
+ const onHide = () => document.hidden && hide.abort();
95
+ if (pauseWhenHidden) document.addEventListener("visibilitychange", onHide);
96
+ try {
97
+ const res = await fetch(req.url, { ...req.init, signal: AbortSignal.any([ac.signal, hide.signal]) });
98
+ const ct = res.headers.get("content-type") ?? "";
99
+ if (res.status >= 400) {
100
+ emit("error", { status: res.status });
101
+ if (!retry.onStatusError) return;
102
+ await backoff();
103
+ continue;
104
+ }
105
+ if (res.status === 204 || res.status === 304 || !res.body) return;
106
+ if (ct.includes("text/event-stream")) {
107
+ attempt = 0;
108
+ wait = retry.interval;
109
+ await readEvents(res.body, (e) => {
110
+ if (e.id !== void 0) lastId = e.id;
111
+ if (e.retry) wait = retry.interval = e.retry;
112
+ route(e.event, e.data);
113
+ });
114
+ if (!o.reconnect) return;
115
+ await backoff();
116
+ continue;
117
+ }
118
+ const text = await res.text();
119
+ if (ct.includes("text/html")) runtime.handle("patch-elements", headerArgs(res, ["selector", "mode", "use-view-transition"], { elements: text }));
120
+ else if (ct.includes("application/json")) runtime.handle("patch-signals", headerArgs(res, ["only-if-missing"], { signals: text }));
121
+ else if (ct.includes("javascript")) runScript(text);
122
+ return;
123
+ } catch {
124
+ if (ac.signal.aborted) return;
125
+ if (hide.signal.aborted) await untilVisible();
126
+ else await backoff();
127
+ } finally {
128
+ document.removeEventListener("visibilitychange", onHide);
129
+ }
130
+ }
131
+ } catch (e) {
132
+ emit("error", { message: e?.message });
133
+ throw error(`${method} ${url}: ${e?.message ?? e}`);
134
+ } finally {
135
+ emit("finished");
136
+ if (inflight.get(key) === ac) inflight.delete(key);
137
+ }
138
+ };
139
+ const make = (name, method) => action({ name, call: (ctx, url, o) => send(method, ctx, url, o) });
140
+ const httpGet = make("get", "GET");
141
+ const httpPost = make("post", "POST");
142
+ const httpPut = make("put", "PUT");
143
+ const httpPatch = make("patch", "PATCH");
144
+ const httpDelete = make("delete", "DELETE");
145
+ export {
146
+ httpDelete,
147
+ httpGet,
148
+ httpPatch,
149
+ httpPost,
150
+ httpPut
151
+ };
152
+ //# sourceMappingURL=request.js.map