sigmx 0.1.0 → 0.2.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 (308) hide show
  1. package/README.md +54 -43
  2. package/dist/cli.js +3 -1
  3. package/dist/cli.js.map +2 -2
  4. package/dist/kernel/compile.d.ts +8 -9
  5. package/dist/kernel/compile.js +102 -67
  6. package/dist/kernel/compile.js.map +2 -2
  7. package/dist/kernel/contracts.d.ts +12 -13
  8. package/dist/kernel/index.d.ts +11 -12
  9. package/dist/kernel/index.js +14 -12
  10. package/dist/kernel/index.js.map +3 -3
  11. package/dist/kernel/precompile.d.ts +8 -12
  12. package/dist/kernel/precompile.js +33 -76
  13. package/dist/kernel/precompile.js.map +2 -2
  14. package/dist/kernel/precompiled.d.ts +7 -4
  15. package/dist/kernel/precompiled.js +5 -5
  16. package/dist/kernel/precompiled.js.map +2 -2
  17. package/dist/kernel/reactive.d.ts +13 -11
  18. package/dist/kernel/reactive.js +96 -71
  19. package/dist/kernel/reactive.js.map +3 -3
  20. package/dist/kernel/runtime.js +85 -63
  21. package/dist/kernel/runtime.js.map +3 -3
  22. package/dist/kernel/scan.d.ts +2 -11
  23. package/dist/kernel/scan.js +26 -9
  24. package/dist/kernel/scan.js.map +2 -2
  25. package/dist/kernel/state.d.ts +5 -8
  26. package/dist/kernel/state.js +114 -76
  27. package/dist/kernel/state.js.map +2 -2
  28. package/dist/kernel/strict-csp.d.ts +0 -5
  29. package/dist/kernel/strict-csp.js +2 -2
  30. package/dist/kernel/strict-csp.js.map +2 -2
  31. package/dist/lib/casing.d.ts +4 -1
  32. package/dist/lib/casing.js +8 -1
  33. package/dist/lib/casing.js.map +2 -2
  34. package/dist/lib/objects.d.ts +5 -4
  35. package/dist/lib/objects.js +13 -5
  36. package/dist/lib/objects.js.map +2 -2
  37. package/dist/lib/schedule.d.ts +3 -5
  38. package/dist/lib/schedule.js +12 -10
  39. package/dist/lib/schedule.js.map +2 -2
  40. package/dist/lib/sse.d.ts +10 -1
  41. package/dist/lib/sse.js +32 -28
  42. package/dist/lib/sse.js.map +2 -2
  43. package/dist/plugins/def.d.ts +5 -0
  44. package/dist/plugins/def.js +22 -0
  45. package/dist/plugins/def.js.map +7 -0
  46. package/dist/plugins/directives/attribute-sync.js +8 -12
  47. package/dist/plugins/directives/attribute-sync.js.map +2 -2
  48. package/dist/plugins/directives/boost.d.ts +1 -1
  49. package/dist/plugins/directives/boost.js +34 -30
  50. package/dist/plugins/directives/boost.js.map +2 -2
  51. package/dist/plugins/directives/busy-flag.js +13 -16
  52. package/dist/plugins/directives/busy-flag.js.map +2 -2
  53. package/dist/plugins/directives/class-toggle.js +17 -16
  54. package/dist/plugins/directives/class-toggle.js.map +2 -2
  55. package/dist/plugins/directives/cloak.js +2 -7
  56. package/dist/plugins/directives/cloak.js.map +2 -2
  57. package/dist/plugins/directives/collapse.js +36 -37
  58. package/dist/plugins/directives/collapse.js.map +2 -2
  59. package/dist/plugins/directives/declare.js +5 -8
  60. package/dist/plugins/directives/declare.js.map +2 -2
  61. package/dist/plugins/directives/derive.js +9 -15
  62. package/dist/plugins/directives/derive.js.map +2 -2
  63. package/dist/plugins/directives/element-ref.js +8 -8
  64. package/dist/plugins/directives/element-ref.js.map +2 -2
  65. package/dist/plugins/directives/event-listener.js +18 -23
  66. package/dist/plugins/directives/event-listener.js.map +2 -2
  67. package/dist/plugins/directives/frame-loop.js +9 -14
  68. package/dist/plugins/directives/frame-loop.js.map +2 -2
  69. package/dist/plugins/directives/html.js +6 -7
  70. package/dist/plugins/directives/html.js.map +2 -2
  71. package/dist/plugins/directives/inline-style.js +17 -20
  72. package/dist/plugins/directives/inline-style.js.map +2 -2
  73. package/dist/plugins/directives/mask.js +19 -23
  74. package/dist/plugins/directives/mask.js.map +2 -2
  75. package/dist/plugins/directives/media-query.d.ts +4 -1
  76. package/dist/plugins/directives/media-query.js +13 -12
  77. package/dist/plugins/directives/media-query.js.map +2 -2
  78. package/dist/plugins/directives/on-mount.js +4 -9
  79. package/dist/plugins/directives/on-mount.js.map +2 -2
  80. package/dist/plugins/directives/patch-listener.js +24 -19
  81. package/dist/plugins/directives/patch-listener.js.map +2 -2
  82. package/dist/plugins/directives/remove-me.js +7 -8
  83. package/dist/plugins/directives/remove-me.js.map +2 -2
  84. package/dist/plugins/directives/scroll-to.d.ts +4 -1
  85. package/dist/plugins/directives/scroll-to.js +8 -14
  86. package/dist/plugins/directives/scroll-to.js.map +2 -2
  87. package/dist/plugins/directives/size-watch.js +7 -12
  88. package/dist/plugins/directives/size-watch.js.map +2 -2
  89. package/dist/plugins/directives/state-dump.js +6 -10
  90. package/dist/plugins/directives/state-dump.js.map +2 -2
  91. package/dist/plugins/directives/storage-sync.js +13 -9
  92. package/dist/plugins/directives/storage-sync.js.map +2 -2
  93. package/dist/plugins/directives/teleport.js +8 -14
  94. package/dist/plugins/directives/teleport.js.map +2 -2
  95. package/dist/plugins/directives/text-content.js +6 -7
  96. package/dist/plugins/directives/text-content.js.map +2 -2
  97. package/dist/plugins/directives/timer.js +7 -13
  98. package/dist/plugins/directives/timer.js.map +2 -2
  99. package/dist/plugins/directives/transition.d.ts +1 -2
  100. package/dist/plugins/directives/transition.js +32 -34
  101. package/dist/plugins/directives/transition.js.map +2 -2
  102. package/dist/plugins/directives/tween.d.ts +2 -2
  103. package/dist/plugins/directives/tween.js +34 -50
  104. package/dist/plugins/directives/tween.js.map +2 -2
  105. package/dist/plugins/directives/two-way-bind.d.ts +1 -1
  106. package/dist/plugins/directives/two-way-bind.js +70 -67
  107. package/dist/plugins/directives/two-way-bind.js.map +2 -2
  108. package/dist/plugins/directives/url-params.js +36 -59
  109. package/dist/plugins/directives/url-params.js.map +3 -3
  110. package/dist/plugins/directives/url-replace.js +6 -7
  111. package/dist/plugins/directives/url-replace.js.map +2 -2
  112. package/dist/plugins/directives/validity.js +6 -9
  113. package/dist/plugins/directives/validity.js.map +2 -2
  114. package/dist/plugins/directives/viewport.js +18 -23
  115. package/dist/plugins/directives/viewport.js.map +2 -2
  116. package/dist/plugins/directives/visibility.js +9 -14
  117. package/dist/plugins/directives/visibility.js.map +2 -2
  118. package/dist/plugins/directives/watch.d.ts +0 -1
  119. package/dist/plugins/directives/watch.js +2 -8
  120. package/dist/plugins/directives/watch.js.map +2 -2
  121. package/dist/plugins/functions/bulk-set.js +10 -7
  122. package/dist/plugins/functions/bulk-set.js.map +2 -2
  123. package/dist/plugins/functions/bulk-toggle.js +10 -7
  124. package/dist/plugins/functions/bulk-toggle.js.map +2 -2
  125. package/dist/plugins/functions/confirm.js +2 -2
  126. package/dist/plugins/functions/confirm.js.map +2 -2
  127. package/dist/plugins/functions/copy-text.js +5 -5
  128. package/dist/plugins/functions/copy-text.js.map +2 -2
  129. package/dist/plugins/functions/dispatch.js +5 -5
  130. package/dist/plugins/functions/dispatch.js.map +2 -2
  131. package/dist/plugins/functions/locale-format.d.ts +4 -1
  132. package/dist/plugins/functions/locale-format.js +9 -16
  133. package/dist/plugins/functions/locale-format.js.map +2 -2
  134. package/dist/plugins/functions/range-map.js +6 -6
  135. package/dist/plugins/functions/range-map.js.map +2 -2
  136. package/dist/plugins/functions/request.d.ts +7 -3
  137. package/dist/plugins/functions/request.js +85 -80
  138. package/dist/plugins/functions/request.js.map +2 -2
  139. package/dist/plugins/functions/untracked-read.js +3 -2
  140. package/dist/plugins/functions/untracked-read.js.map +2 -2
  141. package/dist/plugins/functions/websocket.d.ts +3 -3
  142. package/dist/plugins/functions/websocket.js +18 -25
  143. package/dist/plugins/functions/websocket.js.map +2 -2
  144. package/dist/plugins/index.d.ts +34 -36
  145. package/dist/plugins/index.js +31 -35
  146. package/dist/plugins/index.js.map +2 -2
  147. package/dist/plugins/server-events/apply-elements.d.ts +1 -1
  148. package/dist/plugins/server-events/apply-elements.js +41 -40
  149. package/dist/plugins/server-events/apply-elements.js.map +2 -2
  150. package/dist/plugins/server-events/apply-state.js +9 -12
  151. package/dist/plugins/server-events/apply-state.js.map +2 -2
  152. package/dist/plugins/server-events/morph.d.ts +0 -2
  153. package/dist/plugins/server-events/morph.js +58 -55
  154. package/dist/plugins/server-events/morph.js.map +3 -3
  155. package/dist/presets/all.d.ts +0 -1
  156. package/dist/presets/all.js +22 -26
  157. package/dist/presets/all.js.map +2 -2
  158. package/dist/presets/essentials.d.ts +0 -1
  159. package/dist/presets/essentials.js +27 -9
  160. package/dist/presets/essentials.js.map +2 -2
  161. package/dist/presets/minimal.d.ts +0 -1
  162. package/dist/presets/minimal.js +2 -2
  163. package/dist/presets/minimal.js.map +2 -2
  164. package/dist/server.d.ts +108 -0
  165. package/dist/server.js +218 -0
  166. package/dist/server.js.map +7 -0
  167. package/dist/sigmx.standalone.js +1 -1
  168. package/dist/standalone.js.map +2 -2
  169. package/dist/vite.d.ts +2 -2
  170. package/dist/vite.js +48 -15
  171. package/dist/vite.js.map +2 -2
  172. package/package.json +21 -2
  173. package/dist/auto.d.ts +0 -1
  174. package/dist/auto.js +0 -7
  175. package/dist/auto.js.map +0 -7
  176. package/dist/core/csp.d.ts +0 -7
  177. package/dist/core/csp.js +0 -20
  178. package/dist/core/csp.js.map +0 -7
  179. package/dist/core/engine.d.ts +0 -10
  180. package/dist/core/engine.js +0 -200
  181. package/dist/core/engine.js.map +0 -7
  182. package/dist/core/expr.d.ts +0 -12
  183. package/dist/core/expr.js +0 -94
  184. package/dist/core/expr.js.map +0 -7
  185. package/dist/core/index.d.ts +0 -16
  186. package/dist/core/index.js +0 -46
  187. package/dist/core/index.js.map +0 -7
  188. package/dist/core/signals.d.ts +0 -42
  189. package/dist/core/signals.js +0 -195
  190. package/dist/core/signals.js.map +0 -7
  191. package/dist/core/store.d.ts +0 -32
  192. package/dist/core/store.js +0 -185
  193. package/dist/core/store.js.map +0 -7
  194. package/dist/core/types.d.ts +0 -101
  195. package/dist/core/types.js +0 -1
  196. package/dist/core/types.js.map +0 -7
  197. package/dist/plugins/actions/clipboard.d.ts +0 -2
  198. package/dist/plugins/actions/clipboard.js +0 -11
  199. package/dist/plugins/actions/clipboard.js.map +0 -7
  200. package/dist/plugins/actions/fit.d.ts +0 -2
  201. package/dist/plugins/actions/fit.js +0 -14
  202. package/dist/plugins/actions/fit.js.map +0 -7
  203. package/dist/plugins/actions/intl.d.ts +0 -2
  204. package/dist/plugins/actions/intl.js +0 -21
  205. package/dist/plugins/actions/intl.js.map +0 -7
  206. package/dist/plugins/actions/peek.d.ts +0 -2
  207. package/dist/plugins/actions/peek.js +0 -6
  208. package/dist/plugins/actions/peek.js.map +0 -7
  209. package/dist/plugins/actions/setAll.d.ts +0 -2
  210. package/dist/plugins/actions/setAll.js +0 -11
  211. package/dist/plugins/actions/setAll.js.map +0 -7
  212. package/dist/plugins/actions/toggleAll.d.ts +0 -2
  213. package/dist/plugins/actions/toggleAll.js +0 -11
  214. package/dist/plugins/actions/toggleAll.js.map +0 -7
  215. package/dist/plugins/attributes/attr.d.ts +0 -2
  216. package/dist/plugins/attributes/attr.js +0 -20
  217. package/dist/plugins/attributes/attr.js.map +0 -7
  218. package/dist/plugins/attributes/bind.d.ts +0 -6
  219. package/dist/plugins/attributes/bind.js +0 -81
  220. package/dist/plugins/attributes/bind.js.map +0 -7
  221. package/dist/plugins/attributes/class.d.ts +0 -2
  222. package/dist/plugins/attributes/class.js +0 -22
  223. package/dist/plugins/attributes/class.js.map +0 -7
  224. package/dist/plugins/attributes/computed.d.ts +0 -2
  225. package/dist/plugins/attributes/computed.js +0 -20
  226. package/dist/plugins/attributes/computed.js.map +0 -7
  227. package/dist/plugins/attributes/customValidity.d.ts +0 -2
  228. package/dist/plugins/attributes/customValidity.js +0 -14
  229. package/dist/plugins/attributes/customValidity.js.map +0 -7
  230. package/dist/plugins/attributes/effect.d.ts +0 -2
  231. package/dist/plugins/attributes/effect.js +0 -12
  232. package/dist/plugins/attributes/effect.js.map +0 -7
  233. package/dist/plugins/attributes/indicator.d.ts +0 -2
  234. package/dist/plugins/attributes/indicator.js +0 -20
  235. package/dist/plugins/attributes/indicator.js.map +0 -7
  236. package/dist/plugins/attributes/init.d.ts +0 -2
  237. package/dist/plugins/attributes/init.js +0 -14
  238. package/dist/plugins/attributes/init.js.map +0 -7
  239. package/dist/plugins/attributes/jsonSignals.d.ts +0 -2
  240. package/dist/plugins/attributes/jsonSignals.js +0 -15
  241. package/dist/plugins/attributes/jsonSignals.js.map +0 -7
  242. package/dist/plugins/attributes/matchMedia.d.ts +0 -2
  243. package/dist/plugins/attributes/matchMedia.js +0 -19
  244. package/dist/plugins/attributes/matchMedia.js.map +0 -7
  245. package/dist/plugins/attributes/on.d.ts +0 -5
  246. package/dist/plugins/attributes/on.js +0 -28
  247. package/dist/plugins/attributes/on.js.map +0 -7
  248. package/dist/plugins/attributes/onIntersect.d.ts +0 -2
  249. package/dist/plugins/attributes/onIntersect.js +0 -28
  250. package/dist/plugins/attributes/onIntersect.js.map +0 -7
  251. package/dist/plugins/attributes/onInterval.d.ts +0 -2
  252. package/dist/plugins/attributes/onInterval.js +0 -18
  253. package/dist/plugins/attributes/onInterval.js.map +0 -7
  254. package/dist/plugins/attributes/onRaf.d.ts +0 -1
  255. package/dist/plugins/attributes/onRaf.js +0 -19
  256. package/dist/plugins/attributes/onRaf.js.map +0 -7
  257. package/dist/plugins/attributes/onResize.d.ts +0 -1
  258. package/dist/plugins/attributes/onResize.js +0 -17
  259. package/dist/plugins/attributes/onResize.js.map +0 -7
  260. package/dist/plugins/attributes/onSignalPatch.d.ts +0 -5
  261. package/dist/plugins/attributes/onSignalPatch.js +0 -35
  262. package/dist/plugins/attributes/onSignalPatch.js.map +0 -7
  263. package/dist/plugins/attributes/persist.d.ts +0 -6
  264. package/dist/plugins/attributes/persist.js +0 -16
  265. package/dist/plugins/attributes/persist.js.map +0 -7
  266. package/dist/plugins/attributes/queryString.d.ts +0 -5
  267. package/dist/plugins/attributes/queryString.js +0 -54
  268. package/dist/plugins/attributes/queryString.js.map +0 -7
  269. package/dist/plugins/attributes/ref.d.ts +0 -2
  270. package/dist/plugins/attributes/ref.js +0 -13
  271. package/dist/plugins/attributes/ref.js.map +0 -7
  272. package/dist/plugins/attributes/replaceUrl.d.ts +0 -1
  273. package/dist/plugins/attributes/replaceUrl.js +0 -11
  274. package/dist/plugins/attributes/replaceUrl.js.map +0 -7
  275. package/dist/plugins/attributes/scrollIntoView.d.ts +0 -2
  276. package/dist/plugins/attributes/scrollIntoView.js +0 -19
  277. package/dist/plugins/attributes/scrollIntoView.js.map +0 -7
  278. package/dist/plugins/attributes/show.d.ts +0 -2
  279. package/dist/plugins/attributes/show.js +0 -19
  280. package/dist/plugins/attributes/show.js.map +0 -7
  281. package/dist/plugins/attributes/signals.d.ts +0 -2
  282. package/dist/plugins/attributes/signals.js +0 -13
  283. package/dist/plugins/attributes/signals.js.map +0 -7
  284. package/dist/plugins/attributes/style.d.ts +0 -2
  285. package/dist/plugins/attributes/style.js +0 -25
  286. package/dist/plugins/attributes/style.js.map +0 -7
  287. package/dist/plugins/attributes/text.d.ts +0 -1
  288. package/dist/plugins/attributes/text.js +0 -13
  289. package/dist/plugins/attributes/text.js.map +0 -7
  290. package/dist/plugins/attributes/viewTransition.d.ts +0 -1
  291. package/dist/plugins/attributes/viewTransition.js +0 -11
  292. package/dist/plugins/attributes/viewTransition.js.map +0 -7
  293. package/dist/plugins/directives/transition-name.d.ts +0 -1
  294. package/dist/plugins/directives/transition-name.js +0 -11
  295. package/dist/plugins/directives/transition-name.js.map +0 -7
  296. package/dist/plugins/directives/trap.d.ts +0 -5
  297. package/dist/plugins/directives/trap.js +0 -48
  298. package/dist/plugins/directives/trap.js.map +0 -7
  299. package/dist/sigmx.auto.js +0 -5
  300. package/dist/utils/object.d.ts +0 -9
  301. package/dist/utils/object.js +0 -26
  302. package/dist/utils/object.js.map +0 -7
  303. package/dist/utils/text.d.ts +0 -7
  304. package/dist/utils/text.js +0 -15
  305. package/dist/utils/text.js.map +0 -7
  306. package/dist/utils/timing.d.ts +0 -14
  307. package/dist/utils/timing.js +0 -58
  308. package/dist/utils/timing.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/html.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Sets `innerHTML` from an expression: `html=\"$markup\"`. Scripts inside are not executed. */\nexport const html = attribute({\n name: 'html',\n key: 'forbidden',\n value: 'required',\n mount: ({ el, evaluate, effect }) =>\n effect(() => {\n el.innerHTML = String(evaluate() ?? '')\n }),\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,CAAC,EAAE,IAAI,UAAU,OAAO,MAC7B,OAAO,MAAM;AACX,OAAG,YAAY,OAAO,SAAS,KAAK,EAAE;AAAA,EACxC,CAAC;AACL,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\n/** Sets `innerHTML` from an expression: `html=\"$markup\"`. Scripts inside are not executed. */\nexport const html = dir('html', 6, ({ el, evaluate, effect }) =>\n effect(() => {\n el.innerHTML = String(evaluate() ?? '');\n }),\n);\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAGb,MAAM,OAAO;AAAA,EAAI;AAAA,EAAQ;AAAA,EAAG,CAAC,EAAE,IAAI,UAAU,OAAO,MACzD,OAAO,MAAM;AACX,OAAG,YAAY,OAAO,SAAS,KAAK,EAAE;AAAA,EACxC,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,23 +1,20 @@
1
- import { attribute, kebab } from "../../kernel/index.js";
2
- const style = attribute({
3
- name: "style",
4
- value: "required",
5
- mount({ el, key, cased, evaluate, effect }) {
6
- const original = /* @__PURE__ */ new Map();
7
- const put = (prop, v) => {
8
- if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop));
9
- if (v || v === 0) el.style.setProperty(prop, String(v));
10
- else el.style.setProperty(prop, original.get(prop));
11
- };
12
- effect(() => {
13
- const map = key ? { [cased("kebab")]: evaluate() } : evaluate();
14
- for (const prop of original.keys()) if (!(prop in map)) put(prop, "");
15
- for (const prop in map) put(kebab(prop), map[prop]);
16
- });
17
- return () => {
18
- for (const [prop, v] of original) el.style.setProperty(prop, v);
19
- };
20
- }
1
+ import { kebab } from "../../kernel/index.js";
2
+ import { dir } from "../def.js";
3
+ const style = dir("style", 4, ({ el, key, cased, evaluate, effect }) => {
4
+ const original = /* @__PURE__ */ new Map();
5
+ const put = (prop, v) => {
6
+ if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop));
7
+ if (v || v === 0) el.style.setProperty(prop, String(v));
8
+ else el.style.setProperty(prop, original.get(prop) ?? "");
9
+ };
10
+ effect(() => {
11
+ const map = key ? { [cased("kebab")]: evaluate() } : evaluate();
12
+ for (const prop of original.keys()) if (!(prop in map)) put(prop, "");
13
+ for (const prop in map) put(prop.startsWith("--") ? prop : kebab(prop), map[prop]);
14
+ });
15
+ return () => {
16
+ for (const [prop, v] of original) el.style.setProperty(prop, v);
17
+ };
21
18
  });
22
19
  export {
23
20
  style
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/inline-style.ts"],
4
- "sourcesContent": ["import { attribute, kebab } from '../../kernel/index.js'\n\n/** `style:color=\"expr\"` or `style=\"{ color: expr }\"`. Falsy values (except 0) restore the original. */\nexport const style = attribute({\n name: 'style',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n const original = new Map<string, string>()\n const put = (prop: string, v: unknown) => {\n if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop))\n if (v || v === 0) el.style.setProperty(prop, String(v))\n else el.style.setProperty(prop, original.get(prop)!)\n }\n effect(() => {\n const map: Record<string, unknown> = key ? { [cased('kebab')]: evaluate() } : evaluate()\n for (const prop of original.keys()) if (!(prop in map)) put(prop, '')\n for (const prop in map) put(kebab(prop), map[prop])\n })\n return () => {\n for (const [prop, v] of original) el.style.setProperty(prop, v)\n }\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,WAAW,aAAa;AAG1B,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,UAAM,WAAW,oBAAI,IAAoB;AACzC,UAAM,MAAM,CAAC,MAAc,MAAe;AACxC,UAAI,CAAC,SAAS,IAAI,IAAI,EAAG,UAAS,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,CAAC;AAC3E,UAAI,KAAK,MAAM,EAAG,IAAG,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,UACjD,IAAG,MAAM,YAAY,MAAM,SAAS,IAAI,IAAI,CAAE;AAAA,IACrD;AACA,WAAO,MAAM;AACX,YAAM,MAA+B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,SAAS;AACvF,iBAAW,QAAQ,SAAS,KAAK,EAAG,KAAI,EAAE,QAAQ,KAAM,KAAI,MAAM,EAAE;AACpE,iBAAW,QAAQ,IAAK,KAAI,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,IACpD,CAAC;AACD,WAAO,MAAM;AACX,iBAAW,CAAC,MAAM,CAAC,KAAK,SAAU,IAAG,MAAM,YAAY,MAAM,CAAC;AAAA,IAChE;AAAA,EACF;AACF,CAAC;",
4
+ "sourcesContent": ["import { kebab } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/** `style:color=\"expr\"` or `style=\"{ color: expr }\"`. Falsy values (except 0) restore the original. */\nexport const style = dir('style', 4, ({ el, key, cased, evaluate, effect }) => {\n const original = new Map<string, string>();\n const put = (prop: string, v: unknown) => {\n if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop));\n if (v || v === 0) el.style.setProperty(prop, String(v));\n else el.style.setProperty(prop, original.get(prop) ?? '');\n };\n effect(() => {\n const map: Record<string, unknown> = key ? { [cased('kebab')]: evaluate() } : evaluate();\n for (const prop of original.keys()) if (!(prop in map)) put(prop, '');\n for (const prop in map) put(prop.startsWith('--') ? prop : kebab(prop), map[prop]);\n });\n return () => {\n for (const [prop, v] of original) el.style.setProperty(prop, v);\n };\n});\n"],
5
+ "mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,WAAW;AAGb,MAAM,QAAQ,IAAI,SAAS,GAAG,CAAC,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,MAAM;AAC7E,QAAM,WAAW,oBAAI,IAAoB;AACzC,QAAM,MAAM,CAAC,MAAc,MAAe;AACxC,QAAI,CAAC,SAAS,IAAI,IAAI,EAAG,UAAS,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,CAAC;AAC3E,QAAI,KAAK,MAAM,EAAG,IAAG,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,QACjD,IAAG,MAAM,YAAY,MAAM,SAAS,IAAI,IAAI,KAAK,EAAE;AAAA,EAC1D;AACA,SAAO,MAAM;AACX,UAAM,MAA+B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,SAAS;AACvF,eAAW,QAAQ,SAAS,KAAK,EAAG,KAAI,EAAE,QAAQ,KAAM,KAAI,MAAM,EAAE;AACpE,eAAW,QAAQ,IAAK,KAAI,KAAK,WAAW,IAAI,IAAI,OAAO,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,EACnF,CAAC;AACD,SAAO,MAAM;AACX,eAAW,CAAC,MAAM,CAAC,KAAK,SAAU,IAAG,MAAM,YAAY,MAAM,CAAC;AAAA,EAChE;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { attribute } from "../../kernel/index.js";
1
+ import { dir } from "../def.js";
2
2
  const slots = { "9": /\d/, a: /[a-zA-Z]/, "*": /[a-zA-Z0-9]/ };
3
3
  const applyMask = (mask2, raw) => {
4
4
  let out = "";
@@ -17,28 +17,24 @@ const applyMask = (mask2, raw) => {
17
17
  }
18
18
  return out;
19
19
  };
20
- const mask = attribute({
21
- name: "mask",
22
- key: "forbidden",
23
- value: "required",
24
- mount({ el, value, mods, evaluate, listen, effect }) {
25
- const input = el;
26
- let pattern = value;
27
- const format = () => {
28
- const next = applyMask(pattern, input.value);
29
- if (next !== input.value) {
30
- input.value = next;
31
- input.dispatchEvent(new Event("input", { bubbles: true }));
32
- }
33
- };
34
- listen(input, "input", format);
35
- if (mods.has("dynamic")) {
36
- effect(() => {
37
- pattern = String(evaluate() ?? "");
38
- format();
39
- });
40
- } else format();
41
- }
20
+ const mask = dir("mask", 38, ({ el, evaluate, listen, effect }) => {
21
+ const input = el;
22
+ let pattern = "";
23
+ const format = () => {
24
+ const next = applyMask(pattern, input.value);
25
+ if (next !== input.value) {
26
+ const pos = input.selectionStart;
27
+ const atEnd = pos === null || pos >= input.value.length;
28
+ input.value = next;
29
+ if (!atEnd) input.setSelectionRange(pos, pos);
30
+ input.dispatchEvent(new Event("input", { bubbles: true }));
31
+ }
32
+ };
33
+ listen(input, "input", format);
34
+ effect(() => {
35
+ pattern = String(evaluate() ?? "");
36
+ format();
37
+ });
42
38
  });
43
39
  export {
44
40
  applyMask,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/mask.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\nconst slots: Record<string, RegExp> = { '9': /\\d/, a: /[a-zA-Z]/, '*': /[a-zA-Z0-9]/ }\n\n/** Format raw input against a mask: `9` digit, `a` letter, `*` either, anything else literal. */\nexport const applyMask = (mask: string, raw: string): string => {\n let out = ''\n let i = 0\n for (const m of mask) {\n if (i >= raw.length) break\n const slot = slots[m]\n if (slot) {\n while (i < raw.length && !slot.test(raw[i])) i++\n if (i >= raw.length) break\n out += raw[i++]\n } else {\n out += m\n if (raw[i] === m) i++\n }\n }\n return out\n}\n\n/**\n * Formats the input as the user types: `mask=\"(999) 999-9999\"`. The value is the mask itself;\n * add `__dynamic` to evaluate it as an expression instead (`mask__dynamic=\"$isUS ? '999-999' : '9999'\"`).\n */\nexport const mask = attribute({\n name: 'mask',\n key: 'forbidden',\n value: 'required',\n mount({ el, value, mods, evaluate, listen, effect }) {\n const input = el as HTMLInputElement\n let pattern = value\n const format = () => {\n const next = applyMask(pattern, input.value)\n if (next !== input.value) {\n input.value = next\n input.dispatchEvent(new Event('input', { bubbles: true })) // let `bind` see the formatted value\n }\n }\n listen(input, 'input', format)\n if (mods.has('dynamic')) {\n effect(() => {\n pattern = String(evaluate() ?? '')\n format()\n })\n } else format()\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAE1B,MAAM,QAAgC,EAAE,KAAK,MAAM,GAAG,YAAY,KAAK,cAAc;AAG9E,MAAM,YAAY,CAACA,OAAc,QAAwB;AAC9D,MAAI,MAAM;AACV,MAAI,IAAI;AACR,aAAW,KAAKA,OAAM;AACpB,QAAI,KAAK,IAAI,OAAQ;AACrB,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,MAAM;AACR,aAAO,IAAI,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,EAAG;AAC7C,UAAI,KAAK,IAAI,OAAQ;AACrB,aAAO,IAAI,GAAG;AAAA,IAChB,OAAO;AACL,aAAO;AACP,UAAI,IAAI,CAAC,MAAM,EAAG;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMO,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,OAAO,MAAM,UAAU,QAAQ,OAAO,GAAG;AACnD,UAAM,QAAQ;AACd,QAAI,UAAU;AACd,UAAM,SAAS,MAAM;AACnB,YAAM,OAAO,UAAU,SAAS,MAAM,KAAK;AAC3C,UAAI,SAAS,MAAM,OAAO;AACxB,cAAM,QAAQ;AACd,cAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AACA,WAAO,OAAO,SAAS,MAAM;AAC7B,QAAI,KAAK,IAAI,SAAS,GAAG;AACvB,aAAO,MAAM;AACX,kBAAU,OAAO,SAAS,KAAK,EAAE;AACjC,eAAO;AAAA,MACT,CAAC;AAAA,IACH,MAAO,QAAO;AAAA,EAChB;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\nconst slots: Record<string, RegExp> = { '9': /\\d/, a: /[a-zA-Z]/, '*': /[a-zA-Z0-9]/ };\n\n/** Format raw input against a mask: `9` digit, `a` letter, `*` either, anything else literal. */\nexport const applyMask = (mask: string, raw: string): string => {\n let out = '';\n let i = 0;\n for (const m of mask) {\n if (i >= raw.length) break;\n const slot = slots[m];\n if (slot) {\n while (i < raw.length && !slot.test(raw[i])) i++;\n if (i >= raw.length) break;\n out += raw[i++];\n } else {\n out += m;\n if (raw[i] === m) i++;\n }\n }\n return out;\n};\n\n/**\n * Formats the input as the user types: `mask=\"(999) 999-9999\"`. The value is the mask itself;\n * add `__dynamic` to evaluate it as an expression instead (`mask__dynamic=\"$isUS ? '999-999' : '9999'\"`).\n */\nexport const mask = dir('mask', 38, ({ el, evaluate, listen, effect }) => {\n const input = el as HTMLInputElement;\n let pattern = '';\n const format = () => {\n const next = applyMask(pattern, input.value);\n if (next !== input.value) {\n const pos = input.selectionStart;\n const atEnd = pos === null || pos >= input.value.length;\n input.value = next;\n if (!atEnd) input.setSelectionRange(pos, pos);\n input.dispatchEvent(new Event('input', { bubbles: true })); // let `bind` see the formatted value\n }\n };\n listen(input, 'input', format);\n // Literal by default; with `__dynamic` the value is an expression and the mask follows its signals.\n effect(() => {\n pattern = String(evaluate() ?? '');\n format();\n });\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAEpB,MAAM,QAAgC,EAAE,KAAK,MAAM,GAAG,YAAY,KAAK,cAAc;AAG9E,MAAM,YAAY,CAACA,OAAc,QAAwB;AAC9D,MAAI,MAAM;AACV,MAAI,IAAI;AACR,aAAW,KAAKA,OAAM;AACpB,QAAI,KAAK,IAAI,OAAQ;AACrB,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,MAAM;AACR,aAAO,IAAI,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,EAAG;AAC7C,UAAI,KAAK,IAAI,OAAQ;AACrB,aAAO,IAAI,GAAG;AAAA,IAChB,OAAO;AACL,aAAO;AACP,UAAI,IAAI,CAAC,MAAM,EAAG;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMO,MAAM,OAAO,IAAI,QAAQ,IAAI,CAAC,EAAE,IAAI,UAAU,QAAQ,OAAO,MAAM;AACxE,QAAM,QAAQ;AACd,MAAI,UAAU;AACd,QAAM,SAAS,MAAM;AACnB,UAAM,OAAO,UAAU,SAAS,MAAM,KAAK;AAC3C,QAAI,SAAS,MAAM,OAAO;AACxB,YAAM,MAAM,MAAM;AAClB,YAAM,QAAQ,QAAQ,QAAQ,OAAO,MAAM,MAAM;AACjD,YAAM,QAAQ;AACd,UAAI,CAAC,MAAO,OAAM,kBAAkB,KAAK,GAAG;AAC5C,YAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAAA,IAC3D;AAAA,EACF;AACA,SAAO,OAAO,SAAS,MAAM;AAE7B,SAAO,MAAM;AACX,cAAU,OAAO,SAAS,KAAK,EAAE;AACjC,WAAO;AAAA,EACT,CAAC;AACH,CAAC;",
6
6
  "names": ["mask"]
7
7
  }
@@ -1,2 +1,5 @@
1
- /** `match-media:is-dark="'prefers-color-scheme: dark'"` keeps a boolean signal in sync. */
1
+ /**
2
+ * Keeps a boolean signal in step with a media query: `match-media:dark="(prefers-color-scheme: dark)"`.
3
+ * The value is a literal; `__dynamic` makes it an expression that can read signals.
4
+ */
2
5
  export declare const matchMedia: import("../../kernel/contracts.js").AttributePlugin;
@@ -1,17 +1,18 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const matchMedia = attribute({
3
- name: "match-media",
4
- key: "required",
5
- value: "required",
6
- mount({ cased, evaluate, store, listen }) {
1
+ import { dir } from "../def.js";
2
+ const matchMedia = dir("match-media", 37, ({ cased, evaluate, store, effect, cleanup }) => {
3
+ const path = cased();
4
+ let mql;
5
+ const sync = () => store.set(path, !!mql?.matches);
6
+ const stop = () => mql?.removeEventListener("change", sync);
7
+ effect(() => {
7
8
  let q = String(evaluate()).trim();
8
- if (!/^[(a-z]/.test(q) || !q.startsWith("(") && q.includes(":") && !/^(not|only|all|screen|print)\b/.test(q)) q = `(${q})`;
9
- const mql = window.matchMedia(q);
10
- const path = cased();
11
- const sync = () => store.set(path, mql.matches);
9
+ if (/^[\w-]+\s*:/.test(q)) q = `(${q})`;
10
+ stop();
11
+ mql = window.matchMedia(q);
12
12
  sync();
13
- listen(mql, "change", sync);
14
- }
13
+ mql.addEventListener("change", sync);
14
+ });
15
+ cleanup(stop);
15
16
  });
16
17
  export {
17
18
  matchMedia
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/media-query.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** `match-media:is-dark=\"'prefers-color-scheme: dark'\"` keeps a boolean signal in sync. */\nexport const matchMedia = attribute({\n name: 'match-media',\n key: 'required',\n value: 'required',\n mount({ cased, evaluate, store, listen }) {\n let q = String(evaluate()).trim()\n if (!/^[(a-z]/.test(q) || (!q.startsWith('(') && q.includes(':') && !/^(not|only|all|screen|print)\\b/.test(q))) q = `(${q})`\n const mql = window.matchMedia(q)\n const path = cased()\n const sync = () => store.set(path, mql.matches)\n sync()\n listen(mql, 'change', sync)\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,GAAG;AACxC,QAAI,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK;AAChC,QAAI,CAAC,UAAU,KAAK,CAAC,KAAM,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,iCAAiC,KAAK,CAAC,EAAI,KAAI,IAAI,CAAC;AACzH,UAAM,MAAM,OAAO,WAAW,CAAC;AAC/B,UAAM,OAAO,MAAM;AACnB,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,IAAI,OAAO;AAC9C,SAAK;AACL,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\n/**\n * Keeps a boolean signal in step with a media query: `match-media:dark=\"(prefers-color-scheme: dark)\"`.\n * The value is a literal; `__dynamic` makes it an expression that can read signals.\n */\nexport const matchMedia = dir('match-media', 37, ({ cased, evaluate, store, effect, cleanup }) => {\n const path = cased();\n let mql: MediaQueryList | undefined;\n const sync = () => store.set(path, !!mql?.matches);\n const stop = () => mql?.removeEventListener('change', sync);\n effect(() => {\n let q = String(evaluate()).trim();\n if (/^[\\w-]+\\s*:/.test(q)) q = `(${q})`; // a bare `feature: value` pair gets its parentheses\n stop();\n mql = window.matchMedia(q);\n sync();\n mql.addEventListener('change', sync);\n });\n cleanup(stop);\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAMb,MAAM,aAAa,IAAI,eAAe,IAAI,CAAC,EAAE,OAAO,UAAU,OAAO,QAAQ,QAAQ,MAAM;AAChG,QAAM,OAAO,MAAM;AACnB,MAAI;AACJ,QAAM,OAAO,MAAM,MAAM,IAAI,MAAM,CAAC,CAAC,KAAK,OAAO;AACjD,QAAM,OAAO,MAAM,KAAK,oBAAoB,UAAU,IAAI;AAC1D,SAAO,MAAM;AACX,QAAI,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK;AAChC,QAAI,cAAc,KAAK,CAAC,EAAG,KAAI,IAAI,CAAC;AACpC,SAAK;AACL,UAAM,OAAO,WAAW,CAAC;AACzB,SAAK;AACL,QAAI,iBAAiB,UAAU,IAAI;AAAA,EACrC,CAAC;AACD,UAAQ,IAAI;AACd,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,12 +1,7 @@
1
- import { attribute, withTiming, withViewTransition } from "../../kernel/index.js";
2
- const init = attribute({
3
- name: "init",
4
- key: "forbidden",
5
- value: "required",
6
- returns: false,
7
- mount({ mods, evaluate }) {
8
- withTiming(withViewTransition(() => evaluate(), mods), mods)();
9
- }
1
+ import { withTiming } from "../../kernel/index.js";
2
+ import { dir } from "../def.js";
3
+ const init = dir("init", 22, ({ mods, evaluate, cleanup }) => {
4
+ withTiming(() => evaluate(), mods, cleanup)();
10
5
  });
11
6
  export {
12
7
  init
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/on-mount.ts"],
4
- "sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js'\n\n/** Runs once when the element is mounted. Supports `__delay.500ms` and `__viewtransition`. */\nexport const init = attribute({\n name: 'init',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ mods, evaluate }) {\n withTiming(withViewTransition(() => evaluate(), mods), mods)()\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,MAAM,SAAS,GAAG;AACxB,eAAW,mBAAmB,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE;AAAA,EAC/D;AACF,CAAC;",
4
+ "sourcesContent": ["import { withTiming } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/** Runs once when the element is mounted. Supports `__delay.500ms` and `__viewtransition`. */\nexport const init = dir('init', 22, ({ mods, evaluate, cleanup }) => {\n withTiming(() => evaluate(), mods, cleanup)();\n});\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AAGb,MAAM,OAAO,IAAI,QAAQ,IAAI,CAAC,EAAE,MAAM,UAAU,QAAQ,MAAM;AACnE,aAAW,MAAM,SAAS,GAAG,MAAM,OAAO,EAAE;AAC9C,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,34 +1,39 @@
1
- import { attribute, withTiming } from "../../kernel/index.js";
1
+ import { withTiming } from "../../kernel/index.js";
2
+ import { dir } from "../def.js";
2
3
  const touches = (patch, path) => {
3
4
  let cur = patch;
4
5
  for (const k of path.split(".")) {
5
- if (cur == null || typeof cur !== "object" || !(k in cur)) return false;
6
+ if (cur === null) return true;
7
+ if (typeof cur !== "object" || !(k in cur)) return false;
6
8
  cur = cur[k];
7
9
  }
8
10
  return true;
9
11
  };
10
- const onSignalPatch = attribute({
11
- name: "on-signal-patch",
12
- value: "required",
13
- returns: false,
14
- args: ["patch"],
15
- mount({ key, cased, mods, evaluate, listen }) {
12
+ const onSignalPatch = dir(
13
+ "on-signal-patch",
14
+ 20,
15
+ ({ key, cased, mods, evaluate, listen, cleanup }) => {
16
16
  const path = key ? cased() : "";
17
17
  let running = false;
18
- const run = withTiming((patch) => {
19
- if (running) return;
20
- running = true;
21
- try {
22
- evaluate(void 0, patch);
23
- } finally {
24
- running = false;
25
- }
26
- }, mods);
18
+ const run = withTiming(
19
+ (patch) => {
20
+ if (running) return;
21
+ running = true;
22
+ try {
23
+ evaluate(void 0, patch);
24
+ } finally {
25
+ running = false;
26
+ }
27
+ },
28
+ mods,
29
+ cleanup
30
+ );
27
31
  listen(document, "sigmx-signal-patch", (e) => {
28
32
  if (!path || touches(e.detail, path)) run(e.detail);
29
33
  });
30
- }
31
- });
34
+ },
35
+ ["patch"]
36
+ );
32
37
  export {
33
38
  onSignalPatch
34
39
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/patch-listener.ts"],
4
- "sourcesContent": ["import { attribute, withTiming } from '../../kernel/index.js'\n\nconst touches = (patch: Record<string, any>, path: string): boolean => {\n let cur: any = patch\n for (const k of path.split('.')) {\n if (cur == null || typeof cur !== 'object' || !(k in cur)) return false\n cur = cur[k]\n }\n return true\n}\n\n/**\n * Runs after signals change, with the patch as `patch`. A key narrows it to one path:\n * `on-signal-patch:user.name=\"...\"`.\n */\nexport const onSignalPatch = attribute({\n name: 'on-signal-patch',\n value: 'required',\n returns: false,\n args: ['patch'],\n mount({ key, cased, mods, evaluate, listen }) {\n const path = key ? cased() : ''\n let running = false\n const run = withTiming((patch: Record<string, any>) => {\n if (running) return\n running = true\n try {\n evaluate(undefined, patch)\n } finally {\n running = false\n }\n }, mods)\n listen(document, 'sigmx-signal-patch', (e: CustomEvent) => {\n if (!path || touches(e.detail, path)) run(e.detail)\n })\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,WAAW,kBAAkB;AAEtC,MAAM,UAAU,CAAC,OAA4B,SAA0B;AACrE,MAAI,MAAW;AACf,aAAW,KAAK,KAAK,MAAM,GAAG,GAAG;AAC/B,QAAI,OAAO,QAAQ,OAAO,QAAQ,YAAY,EAAE,KAAK,KAAM,QAAO;AAClE,UAAM,IAAI,CAAC;AAAA,EACb;AACA,SAAO;AACT;AAMO,MAAM,gBAAgB,UAAU;AAAA,EACrC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,CAAC,OAAO;AAAA,EACd,MAAM,EAAE,KAAK,OAAO,MAAM,UAAU,OAAO,GAAG;AAC5C,UAAM,OAAO,MAAM,MAAM,IAAI;AAC7B,QAAI,UAAU;AACd,UAAM,MAAM,WAAW,CAAC,UAA+B;AACrD,UAAI,QAAS;AACb,gBAAU;AACV,UAAI;AACF,iBAAS,QAAW,KAAK;AAAA,MAC3B,UAAE;AACA,kBAAU;AAAA,MACZ;AAAA,IACF,GAAG,IAAI;AACP,WAAO,UAAU,sBAAsB,CAAC,MAAmB;AACzD,UAAI,CAAC,QAAQ,QAAQ,EAAE,QAAQ,IAAI,EAAG,KAAI,EAAE,MAAM;AAAA,IACpD,CAAC;AAAA,EACH;AACF,CAAC;",
4
+ "sourcesContent": ["import { withTiming } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\nconst touches = (patch: Record<string, any>, path: string): boolean => {\n let cur: any = patch;\n for (const k of path.split('.')) {\n if (cur === null) return true; // an ancestor was removed: everything under it changed\n if (typeof cur !== 'object' || !(k in cur)) return false;\n cur = cur[k];\n }\n return true;\n};\n\n/**\n * Runs after signals change, with the patch as `patch`. A key narrows it to one path:\n * `on-signal-patch:user.name=\"...\"`.\n */\nexport const onSignalPatch = dir(\n 'on-signal-patch',\n 20,\n ({ key, cased, mods, evaluate, listen, cleanup }) => {\n const path = key ? cased() : '';\n let running = false;\n const run = withTiming(\n (patch: Record<string, any>) => {\n if (running) return;\n running = true;\n try {\n evaluate(undefined, patch);\n } finally {\n running = false;\n }\n },\n mods,\n cleanup,\n );\n listen(document, 'sigmx-signal-patch', (e: CustomEvent) => {\n if (!path || touches(e.detail, path)) run(e.detail);\n });\n },\n ['patch'],\n);\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AAEpB,MAAM,UAAU,CAAC,OAA4B,SAA0B;AACrE,MAAI,MAAW;AACf,aAAW,KAAK,KAAK,MAAM,GAAG,GAAG;AAC/B,QAAI,QAAQ,KAAM,QAAO;AACzB,QAAI,OAAO,QAAQ,YAAY,EAAE,KAAK,KAAM,QAAO;AACnD,UAAM,IAAI,CAAC;AAAA,EACb;AACA,SAAO;AACT;AAMO,MAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA,CAAC,EAAE,KAAK,OAAO,MAAM,UAAU,QAAQ,QAAQ,MAAM;AACnD,UAAM,OAAO,MAAM,MAAM,IAAI;AAC7B,QAAI,UAAU;AACd,UAAM,MAAM;AAAA,MACV,CAAC,UAA+B;AAC9B,YAAI,QAAS;AACb,kBAAU;AACV,YAAI;AACF,mBAAS,QAAW,KAAK;AAAA,QAC3B,UAAE;AACA,oBAAU;AAAA,QACZ;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AACA,WAAO,UAAU,sBAAsB,CAAC,MAAmB;AACzD,UAAI,CAAC,QAAQ,QAAQ,EAAE,QAAQ,IAAI,EAAG,KAAI,EAAE,MAAM;AAAA,IACpD,CAAC;AAAA,EACH;AAAA,EACA,CAAC,OAAO;AACV;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,10 @@
1
- import { attribute, toMs } from "../../kernel/index.js";
2
- const removeMe = attribute({
3
- name: "remove-me",
4
- key: "forbidden",
5
- mount({ el, value, cleanup }) {
6
- const t = setTimeout(() => el.remove(), toMs([value], 0));
7
- cleanup(() => clearTimeout(t));
8
- }
1
+ import { toMs } from "../../kernel/index.js";
2
+ import { dir } from "../def.js";
3
+ const removeMe = dir("remove-me", 34, ({ el, evaluate, value, cleanup, error }) => {
4
+ const delay = value ? String(evaluate()) : "";
5
+ if (delay && toMs([delay], -1) < 0) throw error(`bad delay "${delay}"`);
6
+ const t = setTimeout(() => el.remove(), toMs([delay], 0));
7
+ cleanup(() => clearTimeout(t));
9
8
  });
10
9
  export {
11
10
  removeMe
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/remove-me.ts"],
4
- "sourcesContent": ["import { attribute, toMs } from '../../kernel/index.js'\n\n/** Removes the element after a delay: `remove-me=\"3s\"` (default immediately). Handy for toasts. */\nexport const removeMe = attribute({\n name: 'remove-me',\n key: 'forbidden',\n mount({ el, value, cleanup }) {\n const t = setTimeout(() => el.remove(), toMs([value], 0))\n cleanup(() => clearTimeout(t))\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,WAAW,YAAY;AAGzB,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM,EAAE,IAAI,OAAO,QAAQ,GAAG;AAC5B,UAAM,IAAI,WAAW,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;AACxD,YAAQ,MAAM,aAAa,CAAC,CAAC;AAAA,EAC/B;AACF,CAAC;",
4
+ "sourcesContent": ["import { toMs } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/** Removes the element after a delay: `remove-me=\"3s\"` (default immediately). Handy for toasts. */\nexport const removeMe = dir('remove-me', 34, ({ el, evaluate, value, cleanup, error }) => {\n const delay = value ? String(evaluate()) : ''; // a literal delay, or an expression with `__dynamic`\n if (delay && toMs([delay], -1) < 0) throw error(`bad delay \"${delay}\"`);\n const t = setTimeout(() => el.remove(), toMs([delay], 0));\n cleanup(() => clearTimeout(t));\n});\n"],
5
+ "mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,WAAW;AAGb,MAAM,WAAW,IAAI,aAAa,IAAI,CAAC,EAAE,IAAI,UAAU,OAAO,SAAS,MAAM,MAAM;AACxF,QAAM,QAAQ,QAAQ,OAAO,SAAS,CAAC,IAAI;AAC3C,MAAI,SAAS,KAAK,CAAC,KAAK,GAAG,EAAE,IAAI,EAAG,OAAM,MAAM,cAAc,KAAK,GAAG;AACtE,QAAM,IAAI,WAAW,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;AACxD,UAAQ,MAAM,aAAa,CAAC,CAAC;AAC/B,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,5 @@
1
- /** Scrolls the element into view on mount. Modifiers: smooth/instant/auto, vstart..vnearest, hstart..hnearest, focus. */
1
+ /**
2
+ * Scrolls the element into view when it mounts: `scroll-into-view__smooth__vcenter__focus`.
3
+ * Modifiers: `smooth|instant|auto`, `vstart|vcenter|vend|vnearest`, `focus`.
4
+ */
2
5
  export declare const scrollIntoView: import("../../kernel/contracts.js").AttributePlugin;
@@ -1,17 +1,11 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const pick = (mods, names, fallback) => names.find((n) => mods.has(n)) ?? fallback;
3
- const scrollIntoView = attribute({
4
- name: "scroll-into-view",
5
- key: "forbidden",
6
- value: "forbidden",
7
- mount({ el, mods }) {
8
- el.scrollIntoView({
9
- behavior: pick(mods, ["smooth", "instant", "auto"], "smooth"),
10
- block: pick(mods, ["vstart", "vcenter", "vend", "vnearest"], "vcenter").slice(1),
11
- inline: pick(mods, ["hstart", "hcenter", "hend", "hnearest"], "hcenter").slice(1)
12
- });
13
- if (mods.has("focus")) el.focus?.();
14
- }
1
+ import { dir } from "../def.js";
2
+ const pick = (mods, re, fallback) => [...mods.keys()].find((n) => re.test(n)) ?? fallback;
3
+ const scrollIntoView = dir("scroll-into-view", 10, ({ el, mods }) => {
4
+ el.scrollIntoView({
5
+ behavior: pick(mods, /^(smooth|instant|auto)$/, "smooth"),
6
+ block: pick(mods, /^v(start|center|end|nearest)$/, "vcenter").slice(1)
7
+ });
8
+ if (mods.has("focus")) el.focus?.();
15
9
  });
16
10
  export {
17
11
  scrollIntoView
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/scroll-to.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\nconst pick = (mods: Map<string, string[]>, names: string[], fallback: string) =>\n names.find((n) => mods.has(n)) ?? fallback\n\n/** Scrolls the element into view on mount. Modifiers: smooth/instant/auto, vstart..vnearest, hstart..hnearest, focus. */\nexport const scrollIntoView = attribute({\n name: 'scroll-into-view',\n key: 'forbidden',\n value: 'forbidden',\n mount({ el, mods }) {\n el.scrollIntoView({\n behavior: pick(mods, ['smooth', 'instant', 'auto'], 'smooth') as ScrollBehavior,\n block: pick(mods, ['vstart', 'vcenter', 'vend', 'vnearest'], 'vcenter').slice(1) as ScrollLogicalPosition,\n inline: pick(mods, ['hstart', 'hcenter', 'hend', 'hnearest'], 'hcenter').slice(1) as ScrollLogicalPosition,\n })\n if (mods.has('focus')) (el as HTMLElement).focus?.()\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAE1B,MAAM,OAAO,CAAC,MAA6B,OAAiB,aAC1D,MAAM,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK;AAG7B,MAAM,iBAAiB,UAAU;AAAA,EACtC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,GAAG;AAClB,OAAG,eAAe;AAAA,MAChB,UAAU,KAAK,MAAM,CAAC,UAAU,WAAW,MAAM,GAAG,QAAQ;AAAA,MAC5D,OAAO,KAAK,MAAM,CAAC,UAAU,WAAW,QAAQ,UAAU,GAAG,SAAS,EAAE,MAAM,CAAC;AAAA,MAC/E,QAAQ,KAAK,MAAM,CAAC,UAAU,WAAW,QAAQ,UAAU,GAAG,SAAS,EAAE,MAAM,CAAC;AAAA,IAClF,CAAC;AACD,QAAI,KAAK,IAAI,OAAO,EAAG,CAAC,GAAmB,QAAQ;AAAA,EACrD;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\nconst pick = (mods: Map<string, string[]>, re: RegExp, fallback: string) =>\n [...mods.keys()].find((n) => re.test(n)) ?? fallback;\n\n/**\n * Scrolls the element into view when it mounts: `scroll-into-view__smooth__vcenter__focus`.\n * Modifiers: `smooth|instant|auto`, `vstart|vcenter|vend|vnearest`, `focus`.\n */\nexport const scrollIntoView = dir('scroll-into-view', 10, ({ el, mods }) => {\n el.scrollIntoView({\n behavior: pick(mods, /^(smooth|instant|auto)$/, 'smooth') as ScrollBehavior,\n block: pick(mods, /^v(start|center|end|nearest)$/, 'vcenter').slice(1) as ScrollLogicalPosition,\n });\n if (mods.has('focus')) (el as HTMLElement).focus?.();\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAEpB,MAAM,OAAO,CAAC,MAA6B,IAAY,aACrD,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK;AAMvC,MAAM,iBAAiB,IAAI,oBAAoB,IAAI,CAAC,EAAE,IAAI,KAAK,MAAM;AAC1E,KAAG,eAAe;AAAA,IAChB,UAAU,KAAK,MAAM,2BAA2B,QAAQ;AAAA,IACxD,OAAO,KAAK,MAAM,iCAAiC,SAAS,EAAE,MAAM,CAAC;AAAA,EACvE,CAAC;AACD,MAAI,KAAK,IAAI,OAAO,EAAG,CAAC,GAAmB,QAAQ;AACrD,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,15 +1,10 @@
1
- import { attribute, withTiming } from "../../kernel/index.js";
2
- const onResize = attribute({
3
- name: "on-resize",
4
- key: "forbidden",
5
- value: "required",
6
- returns: false,
7
- mount({ el, mods, evaluate }) {
8
- const run = withTiming(() => evaluate(), mods);
9
- const ro = new ResizeObserver(() => run());
10
- ro.observe(el);
11
- return () => ro.disconnect();
12
- }
1
+ import { withTiming } from "../../kernel/index.js";
2
+ import { dir } from "../def.js";
3
+ const onResize = dir("on-resize", 22, ({ el, mods, evaluate, cleanup }) => {
4
+ const run = withTiming(() => evaluate(), mods, cleanup);
5
+ const ro = new ResizeObserver(() => run());
6
+ ro.observe(el);
7
+ return () => ro.disconnect();
13
8
  });
14
9
  export {
15
10
  onResize
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/size-watch.ts"],
4
- "sourcesContent": ["import { attribute, withTiming } from '../../kernel/index.js'\n\nexport const onResize = attribute({\n name: 'on-resize',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ el, mods, evaluate }) {\n const run = withTiming(() => evaluate(), mods)\n const ro = new ResizeObserver(() => run())\n ro.observe(el)\n return () => ro.disconnect()\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,WAAW,kBAAkB;AAE/B,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,SAAS,GAAG;AAC5B,UAAM,MAAM,WAAW,MAAM,SAAS,GAAG,IAAI;AAC7C,UAAM,KAAK,IAAI,eAAe,MAAM,IAAI,CAAC;AACzC,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AACF,CAAC;",
4
+ "sourcesContent": ["import { withTiming } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\nexport const onResize = dir('on-resize', 22, ({ el, mods, evaluate, cleanup }) => {\n const run = withTiming(() => evaluate(), mods, cleanup);\n const ro = new ResizeObserver(() => run());\n ro.observe(el);\n return () => ro.disconnect();\n});\n"],
5
+ "mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AAEb,MAAM,WAAW,IAAI,aAAa,IAAI,CAAC,EAAE,IAAI,MAAM,UAAU,QAAQ,MAAM;AAChF,QAAM,MAAM,WAAW,MAAM,SAAS,GAAG,MAAM,OAAO;AACtD,QAAM,KAAK,IAAI,eAAe,MAAM,IAAI,CAAC;AACzC,KAAG,QAAQ,EAAE;AACb,SAAO,MAAM,GAAG,WAAW;AAC7B,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,9 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const jsonSignals = attribute({
3
- name: "json-signals",
4
- key: "forbidden",
5
- mount({ el, value, mods, evaluate, effect, store }) {
6
- const filter = value ? evaluate() : void 0;
7
- effect(() => {
8
- el.textContent = JSON.stringify(store.snapshot(filter), null, mods.has("terse") ? 0 : 2);
9
- });
10
- }
1
+ import { dir } from "../def.js";
2
+ const jsonSignals = dir("json-signals", 2, ({ el, value, evaluate, effect, store }) => {
3
+ const filter = value ? evaluate() : void 0;
4
+ effect(() => {
5
+ el.textContent = JSON.stringify(store.snapshot(filter), null, 2);
6
+ });
11
7
  });
12
8
  export {
13
9
  jsonSignals
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/state-dump.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Renders the store (or a filtered part) as JSON. `__terse` for single-line output. */\nexport const jsonSignals = attribute({\n name: 'json-signals',\n key: 'forbidden',\n mount({ el, value, mods, evaluate, effect, store }) {\n const filter = value ? evaluate() : undefined\n effect(() => {\n el.textContent = JSON.stringify(store.snapshot(filter), null, mods.has('terse') ? 0 : 2)\n })\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM,EAAE,IAAI,OAAO,MAAM,UAAU,QAAQ,MAAM,GAAG;AAClD,UAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,WAAO,MAAM;AACX,SAAG,cAAc,KAAK,UAAU,MAAM,SAAS,MAAM,GAAG,MAAM,KAAK,IAAI,OAAO,IAAI,IAAI,CAAC;AAAA,IACzF,CAAC;AAAA,EACH;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\n/** Renders the store (or a filtered part) as JSON. `__terse` for single-line output. */\nexport const jsonSignals = dir('json-signals', 2, ({ el, value, evaluate, effect, store }) => {\n const filter = value ? evaluate() : undefined;\n effect(() => {\n el.textContent = JSON.stringify(store.snapshot(filter), null, 2);\n });\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAGb,MAAM,cAAc,IAAI,gBAAgB,GAAG,CAAC,EAAE,IAAI,OAAO,UAAU,QAAQ,MAAM,MAAM;AAC5F,QAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,SAAO,MAAM;AACX,OAAG,cAAc,KAAK,UAAU,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC;AAAA,EACjE,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,14 +1,18 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const persist = attribute({
3
- name: "persist",
4
- mount({ key, value, mods, evaluate, store, effect }) {
5
- const storage = mods.has("session") ? sessionStorage : localStorage;
6
- const name = key || "sigmx";
7
- const filter = value ? evaluate() : void 0;
8
- const saved = storage.getItem(name);
1
+ import { dir } from "../def.js";
2
+ const persist = dir("persist", 0, ({ key, value, evaluate, store, effect }) => {
3
+ const name = key || "sigmx";
4
+ const filter = value ? evaluate() : void 0;
5
+ try {
6
+ const saved = localStorage.getItem(name);
9
7
  if (saved) store.merge(JSON.parse(saved));
10
- effect(() => storage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false }))));
8
+ } catch {
11
9
  }
10
+ effect(() => {
11
+ try {
12
+ localStorage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false })));
13
+ } catch {
14
+ }
15
+ });
12
16
  });
13
17
  export {
14
18
  persist
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/storage-sync.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/**\n * Saves matching signals to localStorage (`__session` for sessionStorage) and restores them on\n * mount. `persist:key` sets the storage key; the value is an optional `{ include, exclude }` filter.\n * Declare defaults with `signals:x__ifmissing` so restored values are not overwritten.\n */\nexport const persist = attribute({\n name: 'persist',\n mount({ key, value, mods, evaluate, store, effect }) {\n const storage = mods.has('session') ? sessionStorage : localStorage\n const name = key || 'sigmx'\n const filter = value ? evaluate() : undefined\n const saved = storage.getItem(name)\n if (saved) store.merge(JSON.parse(saved))\n effect(() => storage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false }))))\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAOnB,MAAM,UAAU,UAAU;AAAA,EAC/B,MAAM;AAAA,EACN,MAAM,EAAE,KAAK,OAAO,MAAM,UAAU,OAAO,OAAO,GAAG;AACnD,UAAM,UAAU,KAAK,IAAI,SAAS,IAAI,iBAAiB;AACvD,UAAM,OAAO,OAAO;AACpB,UAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,UAAM,QAAQ,QAAQ,QAAQ,IAAI;AAClC,QAAI,MAAO,OAAM,MAAM,KAAK,MAAM,KAAK,CAAC;AACxC,WAAO,MAAM,QAAQ,QAAQ,MAAM,KAAK,UAAU,MAAM,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC,CAAC,CAAC,CAAC;AAAA,EACjG;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\n/**\n * Saves matching signals to localStorage (`__session` for sessionStorage) and restores them on\n * mount. `persist:key` sets the storage key; the value is an optional `{ include, exclude }` filter.\n * Declare defaults with `signals:x__ifmissing` so restored values are not overwritten.\n */\nexport const persist = dir('persist', 0, ({ key, value, evaluate, store, effect }) => {\n const name = key || 'sigmx';\n const filter = value ? evaluate() : undefined;\n try {\n const saved = localStorage.getItem(name);\n if (saved) store.merge(JSON.parse(saved));\n } catch {} // corrupted or blocked storage: start from the declared defaults\n effect(() => {\n try {\n localStorage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false })));\n } catch {} // quota exceeded or storage disabled: keep working in memory\n });\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAOb,MAAM,UAAU,IAAI,WAAW,GAAG,CAAC,EAAE,KAAK,OAAO,UAAU,OAAO,OAAO,MAAM;AACpF,QAAM,OAAO,OAAO;AACpB,QAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,MAAI;AACF,UAAM,QAAQ,aAAa,QAAQ,IAAI;AACvC,QAAI,MAAO,OAAM,MAAM,KAAK,MAAM,KAAK,CAAC;AAAA,EAC1C,QAAQ;AAAA,EAAC;AACT,SAAO,MAAM;AACX,QAAI;AACF,mBAAa,QAAQ,MAAM,KAAK,UAAU,MAAM,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC,CAAC,CAAC;AAAA,IACxF,QAAQ;AAAA,IAAC;AAAA,EACX,CAAC;AACH,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,17 +1,11 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const teleport = attribute({
3
- name: "teleport",
4
- key: "forbidden",
5
- value: "required",
6
- mount({ el, value, mods, error }) {
7
- const target = document.querySelector(value);
8
- if (!target) throw error(`no element matches "${value}"`);
9
- if (el.parentElement === target) return;
10
- const before = mods.has("prepend") ? target.firstChild : null;
11
- const t = target;
12
- if (t.moveBefore) t.moveBefore(el, before);
13
- else target.insertBefore(el, before);
14
- }
1
+ import { dir } from "../def.js";
2
+ const teleport = dir("teleport", 38, ({ el, evaluate, error }) => {
3
+ const selector = String(evaluate());
4
+ const target = document.querySelector(selector);
5
+ if (!target) throw error(`no element matches "${selector}"`);
6
+ if (el.parentElement === target) return;
7
+ const t = target;
8
+ (t.moveBefore ?? t.insertBefore).call(t, el, null);
15
9
  });
16
10
  export {
17
11
  teleport
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/plugins/directives/teleport.ts"],
4
- "sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/**\n * Moves the element to another place in the document: `teleport=\"body\"` (a selector).\n * `__prepend` inserts at the start. The element and its signals keep working where it lands.\n */\nexport const teleport = attribute({\n name: 'teleport',\n key: 'forbidden',\n value: 'required',\n mount({ el, value, mods, error }) {\n const target = document.querySelector(value)\n if (!target) throw error(`no element matches \"${value}\"`)\n if (el.parentElement === target) return\n const before = mods.has('prepend') ? target.firstChild : null\n const t = target as Node & { moveBefore?: (n: Node, b: Node | null) => void }\n // `moveBefore` keeps state and avoids an unmount/remount; fall back to a plain move.\n if (t.moveBefore) t.moveBefore(el, before)\n else target.insertBefore(el, before)\n },\n})\n"],
5
- "mappings": "AAAA,SAAS,iBAAiB;AAMnB,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,OAAO,MAAM,MAAM,GAAG;AAChC,UAAM,SAAS,SAAS,cAAc,KAAK;AAC3C,QAAI,CAAC,OAAQ,OAAM,MAAM,uBAAuB,KAAK,GAAG;AACxD,QAAI,GAAG,kBAAkB,OAAQ;AACjC,UAAM,SAAS,KAAK,IAAI,SAAS,IAAI,OAAO,aAAa;AACzD,UAAM,IAAI;AAEV,QAAI,EAAE,WAAY,GAAE,WAAW,IAAI,MAAM;AAAA,QACpC,QAAO,aAAa,IAAI,MAAM;AAAA,EACrC;AACF,CAAC;",
4
+ "sourcesContent": ["import { dir } from '../def.js';\n\n/**\n * Moves the element to another place in the document: `teleport=\"body\"` (a selector).\n * `__prepend` inserts at the start. The element and its signals keep working where it lands.\n */\nexport const teleport = dir('teleport', 38, ({ el, evaluate, error }) => {\n const selector = String(evaluate()); // a literal selector, or an expression with `__dynamic`\n const target = document.querySelector(selector);\n if (!target) throw error(`no element matches \"${selector}\"`);\n if (el.parentElement === target) return;\n const t = target as Node & { moveBefore?: (n: Node, b: Node | null) => void };\n // `moveBefore` keeps state and avoids an unmount/remount; fall back to a plain move.\n (t.moveBefore ?? t.insertBefore).call(t, el, null);\n});\n"],
5
+ "mappings": "AAAA,SAAS,WAAW;AAMb,MAAM,WAAW,IAAI,YAAY,IAAI,CAAC,EAAE,IAAI,UAAU,MAAM,MAAM;AACvE,QAAM,WAAW,OAAO,SAAS,CAAC;AAClC,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,MAAI,CAAC,OAAQ,OAAM,MAAM,uBAAuB,QAAQ,GAAG;AAC3D,MAAI,GAAG,kBAAkB,OAAQ;AACjC,QAAM,IAAI;AAEV,GAAC,EAAE,cAAc,EAAE,cAAc,KAAK,GAAG,IAAI,IAAI;AACnD,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1,12 +1,11 @@
1
- import { attribute } from "../../kernel/index.js";
2
- const text = attribute({
3
- name: "text",
4
- key: "forbidden",
5
- value: "required",
6
- mount: ({ el, evaluate, effect }) => effect(() => {
1
+ import { dir } from "../def.js";
2
+ const text = dir(
3
+ "text",
4
+ 6,
5
+ ({ el, evaluate, effect }) => effect(() => {
7
6
  el.textContent = String(evaluate() ?? "");
8
7
  })
9
- });
8
+ );
10
9
  export {
11
10
  text
12
11
  };