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,20 +1,19 @@
1
- export { createRuntime, parseAttr } from './runtime.js';
2
- export { compile, functionCompiler, rewriteActions, runtimeExpressions, splitStatements } from './compile.js';
3
- export { expressionKey, precompiled } from './precompiled.js';
4
- export type { ExpressionTable } from './precompiled.js';
1
+ export { camel, kebab, pascal, recase, snake } from '../lib/casing.js';
2
+ export type { Filter } from '../lib/objects.js';
3
+ export { expand, isPlain, toPredicate } from '../lib/objects.js';
4
+ export { debounce, delay, throttle, toMs, withTiming } from '../lib/schedule.js';
5
5
  export type { Compiler } from './compile.js';
6
- export { Computed, Signal, batch, computed, effect, flush, onSettled, signal, untracked } from './reactive.js';
7
- export { createStore } from './state.js';
8
- export type { Patch, Store } from './state.js';
6
+ export { compile, compileBody, functionCompiler, runtimeExpressions, transform } from './compile.js';
9
7
  export type * from './contracts.js';
10
- export { expand, isPlain, toPredicate } from '../lib/objects.js';
11
- export type { Filter } from '../lib/objects.js';
12
- export { camel, kebab, pascal, recase, snake } from '../lib/casing.js';
13
- export { debounce, delay, throttle, toMs, withTiming, withViewTransition } from '../lib/schedule.js';
8
+ export type { ExpressionTable } from './precompiled.js';
9
+ export { expressionKey, precompiled } from './precompiled.js';
10
+ export { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from './reactive.js';
11
+ export { createRuntime, parseAttr } from './runtime.js';
12
+ export type { Patch, Store } from './state.js';
13
+ export { createStore } from './state.js';
14
14
  import type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js';
15
15
  /** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */
16
16
  export declare const createSigmx: (options?: SigmxOptions) => Sigmx;
17
- /** Type a plugin definition. Pure: registration is `createSigmx({ plugins })` or `sigmx.use()`. */
18
17
  export declare const attribute: (p: Omit<AttributePlugin, "type">) => AttributePlugin;
19
18
  export declare const action: (p: Omit<ActionPlugin, "type">) => ActionPlugin;
20
19
  export declare const handler: (p: Omit<HandlerPlugin, "type">) => HandlerPlugin;
@@ -1,14 +1,17 @@
1
- import { createRuntime, parseAttr } from "./runtime.js";
2
- import { compile, functionCompiler, rewriteActions, runtimeExpressions, splitStatements } from "./compile.js";
1
+ import { camel, kebab, pascal, recase, snake } from "../lib/casing.js";
2
+ import { expand, isPlain, toPredicate } from "../lib/objects.js";
3
+ import { debounce, delay, throttle, toMs, withTiming } from "../lib/schedule.js";
4
+ import { compile, compileBody, functionCompiler, runtimeExpressions, transform } from "./compile.js";
3
5
  import { expressionKey, precompiled } from "./precompiled.js";
4
- import { Computed, Signal, batch, computed, effect, flush, onSettled, signal, untracked } from "./reactive.js";
6
+ import { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from "./reactive.js";
7
+ import { createRuntime, parseAttr } from "./runtime.js";
5
8
  import { createStore } from "./state.js";
6
- import { expand, isPlain, toPredicate } from "../lib/objects.js";
7
- import { camel, kebab, pascal, recase, snake } from "../lib/casing.js";
8
- import { debounce, delay, throttle, toMs, withTiming, withViewTransition } from "../lib/schedule.js";
9
- import { createRuntime as createRuntime2 } from "./runtime.js";
10
9
  import { functionCompiler as functionCompiler2, runtimeExpressions as runtimeExpressions2 } from "./compile.js";
11
- const createSigmx = (options = {}) => createRuntime2({ ...options, expressions: options.expressions ?? runtimeExpressions2(options.compile ?? functionCompiler2) });
10
+ import { createRuntime as createRuntime2 } from "./runtime.js";
11
+ const createSigmx = (options = {}) => createRuntime2({
12
+ ...options,
13
+ expressions: options.expressions ?? runtimeExpressions2(options.compile ?? functionCompiler2)
14
+ });
12
15
  const attribute = (p) => ({ type: "attribute", ...p });
13
16
  const action = (p) => ({ type: "action", ...p });
14
17
  const handler = (p) => ({ type: "handler", ...p });
@@ -20,6 +23,7 @@ export {
20
23
  batch,
21
24
  camel,
22
25
  compile,
26
+ compileBody,
23
27
  computed,
24
28
  createRuntime,
25
29
  createSigmx,
@@ -39,16 +43,14 @@ export {
39
43
  pascal,
40
44
  precompiled,
41
45
  recase,
42
- rewriteActions,
43
46
  runtimeExpressions,
44
47
  signal,
45
48
  snake,
46
- splitStatements,
47
49
  throttle,
48
50
  toMs,
49
51
  toPredicate,
52
+ transform,
50
53
  untracked,
51
- withTiming,
52
- withViewTransition
54
+ withTiming
53
55
  };
54
56
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/kernel/index.ts"],
4
- "sourcesContent": ["export { createRuntime, parseAttr } from './runtime.js'\nexport { compile, functionCompiler, rewriteActions, runtimeExpressions, splitStatements } from './compile.js'\nexport { expressionKey, precompiled } from './precompiled.js'\nexport type { ExpressionTable } from './precompiled.js'\nexport type { Compiler } from './compile.js'\nexport { Computed, Signal, batch, computed, effect, flush, onSettled, signal, untracked } from './reactive.js'\nexport { createStore } from './state.js'\nexport type { Patch, Store } from './state.js'\nexport type * from './contracts.js'\nexport { expand, isPlain, toPredicate } from '../lib/objects.js'\nexport type { Filter } from '../lib/objects.js'\nexport { camel, kebab, pascal, recase, snake } from '../lib/casing.js'\nexport { debounce, delay, throttle, toMs, withTiming, withViewTransition } from '../lib/schedule.js'\n\nimport type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js'\nimport { createRuntime } from './runtime.js'\nimport { functionCompiler, runtimeExpressions } from './compile.js'\n\n/** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */\nexport const createSigmx = (options: SigmxOptions = {}): Sigmx =>\n createRuntime({ ...options, expressions: options.expressions ?? runtimeExpressions(options.compile ?? functionCompiler) })\n\n/** Type a plugin definition. Pure: registration is `createSigmx({ plugins })` or `sigmx.use()`. */\nexport const attribute = (p: Omit<AttributePlugin, 'type'>): AttributePlugin => ({ type: 'attribute', ...p })\nexport const action = (p: Omit<ActionPlugin, 'type'>): ActionPlugin => ({ type: 'action', ...p })\nexport const handler = (p: Omit<HandlerPlugin, 'type'>): HandlerPlugin => ({ type: 'handler', ...p })\n"],
5
- "mappings": "AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,SAAS,kBAAkB,gBAAgB,oBAAoB,uBAAuB;AAC/F,SAAS,eAAe,mBAAmB;AAG3C,SAAS,UAAU,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,QAAQ,iBAAiB;AAC/F,SAAS,mBAAmB;AAG5B,SAAS,QAAQ,SAAS,mBAAmB;AAE7C,SAAS,OAAO,OAAO,QAAQ,QAAQ,aAAa;AACpD,SAAS,UAAU,OAAO,UAAU,MAAM,YAAY,0BAA0B;AAGhF,SAAS,iBAAAA,sBAAqB;AAC9B,SAAS,oBAAAC,mBAAkB,sBAAAC,2BAA0B;AAG9C,MAAM,cAAc,CAAC,UAAwB,CAAC,MACnDF,eAAc,EAAE,GAAG,SAAS,aAAa,QAAQ,eAAeE,oBAAmB,QAAQ,WAAWD,iBAAgB,EAAE,CAAC;AAGpH,MAAM,YAAY,CAAC,OAAuD,EAAE,MAAM,aAAa,GAAG,EAAE;AACpG,MAAM,SAAS,CAAC,OAAiD,EAAE,MAAM,UAAU,GAAG,EAAE;AACxF,MAAM,UAAU,CAAC,OAAmD,EAAE,MAAM,WAAW,GAAG,EAAE;",
6
- "names": ["createRuntime", "functionCompiler", "runtimeExpressions"]
4
+ "sourcesContent": ["export { camel, kebab, pascal, recase, snake } from '../lib/casing.js';\nexport type { Filter } from '../lib/objects.js';\nexport { expand, isPlain, toPredicate } from '../lib/objects.js';\nexport { debounce, delay, throttle, toMs, withTiming } from '../lib/schedule.js';\nexport type { Compiler } from './compile.js';\nexport { compile, compileBody, functionCompiler, runtimeExpressions, transform } from './compile.js';\nexport type * from './contracts.js';\nexport type { ExpressionTable } from './precompiled.js';\nexport { expressionKey, precompiled } from './precompiled.js';\nexport { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from './reactive.js';\nexport { createRuntime, parseAttr } from './runtime.js';\nexport type { Patch, Store } from './state.js';\nexport { createStore } from './state.js';\n\nimport { functionCompiler, runtimeExpressions } from './compile.js';\nimport type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js';\nimport { createRuntime } from './runtime.js';\n\n/** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */\nexport const createSigmx = (options: SigmxOptions = {}): Sigmx =>\n createRuntime({\n ...options,\n expressions: options.expressions ?? runtimeExpressions(options.compile ?? functionCompiler),\n });\n\nexport const attribute = (p: Omit<AttributePlugin, 'type'>): AttributePlugin => ({ type: 'attribute', ...p });\nexport const action = (p: Omit<ActionPlugin, 'type'>): ActionPlugin => ({ type: 'action', ...p });\nexport const handler = (p: Omit<HandlerPlugin, 'type'>): HandlerPlugin => ({ type: 'handler', ...p });\n"],
5
+ "mappings": "AAAA,SAAS,OAAO,OAAO,QAAQ,QAAQ,aAAa;AAEpD,SAAS,QAAQ,SAAS,mBAAmB;AAC7C,SAAS,UAAU,OAAO,UAAU,MAAM,kBAAkB;AAE5D,SAAS,SAAS,aAAa,kBAAkB,oBAAoB,iBAAiB;AAGtF,SAAS,eAAe,mBAAmB;AAC3C,SAAS,OAAO,UAAU,UAAU,QAAQ,OAAO,WAAW,QAAQ,QAAQ,iBAAiB;AAC/F,SAAS,eAAe,iBAAiB;AAEzC,SAAS,mBAAmB;AAE5B,SAAS,oBAAAA,mBAAkB,sBAAAC,2BAA0B;AAErD,SAAS,iBAAAC,sBAAqB;AAGvB,MAAM,cAAc,CAAC,UAAwB,CAAC,MACnDA,eAAc;AAAA,EACZ,GAAG;AAAA,EACH,aAAa,QAAQ,eAAeD,oBAAmB,QAAQ,WAAWD,iBAAgB;AAC5F,CAAC;AAEI,MAAM,YAAY,CAAC,OAAuD,EAAE,MAAM,aAAa,GAAG,EAAE;AACpG,MAAM,SAAS,CAAC,OAAiD,EAAE,MAAM,UAAU,GAAG,EAAE;AACxF,MAAM,UAAU,CAAC,OAAmD,EAAE,MAAM,WAAW,GAAG,EAAE;",
6
+ "names": ["functionCompiler", "runtimeExpressions", "createRuntime"]
7
7
  }
@@ -1,25 +1,21 @@
1
- /**
2
- * Rewrite `$name` and `$a.b` into `$.name` / `$.a.b` so the expression runs in strict mode without
3
- * `with`. Skips strings and comments, recurses into template-literal interpolations, and leaves
4
- * `$` alone, `$[...]` alone, and `obj.$prop` alone.
5
- */
6
- export declare const rewriteSignals: (src: string) => string;
7
- /** The strict-mode function body for one expression: same semantics as the runtime compiler. */
8
- export declare const compileBody: (src: string, returns: boolean) => string;
9
1
  export type Extracted = {
10
2
  src: string;
11
3
  params: string[];
12
- returns: boolean;
13
4
  };
14
- /** JavaScript source for a module exporting `table`, from a list of extracted expressions. */
15
5
  export declare const generateTable: (items: Extracted[]) => string;
16
6
  export type PluginMeta = {
17
7
  name: string;
18
- returns?: boolean;
19
8
  args?: string[];
9
+ literal?: boolean;
20
10
  };
21
11
  /**
22
12
  * Find directive attributes with literal values in template source. Values must be plain quoted
23
- * strings; anything interpolated at render time is left to the runtime fallback.
13
+ * strings; anything interpolated at render time is left to the runtime fallback. Plugins whose value
14
+ * is a literal (mask, teleport, …) are skipped unless the attribute carries `__dynamic`.
24
15
  */
25
16
  export declare const extractExpressions: (source: string, plugins: PluginMeta[], prefixes?: string[]) => Extracted[];
17
+ /**
18
+ * Keyed directive attributes whose key contains an uppercase letter. HTML lowercases attribute names,
19
+ * so `data-bind:firstName` reaches the runtime as `firstname`: write `data-bind:first-name`.
20
+ */
21
+ export declare const lintSource: (source: string, prefixes?: string[]) => string[];
@@ -1,80 +1,15 @@
1
- import { rewriteActions, splitStatements } from "./compile.js";
1
+ import { compileBody, functionCompiler } from "./compile.js";
2
2
  import { expressionKey } from "./precompiled.js";
3
- const ident = /[A-Za-z0-9_$]/;
4
- const rewriteSignals = (src) => {
5
- let out = "";
6
- let i = 0;
7
- const n = src.length;
8
- const prevCode = () => {
9
- for (let j = out.length - 1; j >= 0; j--) if (!/\s/.test(out[j])) return out[j];
10
- return "";
11
- };
12
- while (i < n) {
13
- const c = src[i];
14
- const next = src[i + 1];
15
- if (c === '"' || c === "'") {
16
- let j = i + 1;
17
- while (j < n && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
18
- out += src.slice(i, j + 1);
19
- i = j + 1;
20
- } else if (c === "`") {
21
- out += c;
22
- i++;
23
- while (i < n && src[i] !== "`") {
24
- if (src[i] === "\\") {
25
- out += src.slice(i, i + 2);
26
- i += 2;
27
- } else if (src[i] === "$" && src[i + 1] === "{") {
28
- let depth = 1;
29
- let j = i + 2;
30
- while (j < n && depth) {
31
- if (src[j] === "{") depth++;
32
- else if (src[j] === "}") depth--;
33
- if (depth) j++;
34
- }
35
- out += "${" + rewriteSignals(src.slice(i + 2, j)) + "}";
36
- i = j + 1;
37
- } else out += src[i++];
38
- }
39
- out += "`";
40
- i++;
41
- } else if (c === "/" && next === "/") {
42
- const j = src.indexOf("\n", i);
43
- i = j < 0 ? n : j;
44
- } else if (c === "/" && next === "*") {
45
- const j = src.indexOf("*/", i + 2);
46
- i = j < 0 ? n : j + 2;
47
- } else if (c === "$" && next !== void 0 && ident.test(next) && next !== "$" && prevCode() !== "." && !ident.test(out[out.length - 1] ?? "")) {
48
- let j = i + 1;
49
- while (j < n && ident.test(src[j])) j++;
50
- out += "$." + src.slice(i + 1, j);
51
- i = j;
52
- } else {
53
- out += c;
54
- i++;
55
- }
56
- }
57
- return out;
58
- };
59
- const compileBody = (src, returns) => {
60
- const code = rewriteSignals(rewriteActions(src.trim()));
61
- if (!returns) return code;
62
- const parts = splitStatements(code);
63
- const last = parts.pop() ?? "";
64
- return `${parts.length ? parts.join(";") + ";" : ""}return (${last}
65
- )`;
66
- };
67
3
  const generateTable = (items) => {
68
4
  const seen = /* @__PURE__ */ new Set();
69
5
  const lines = [];
70
- for (const { src, params, returns } of items) {
71
- const key = expressionKey(src, params, returns);
6
+ for (const { src, params } of items) {
7
+ const key = expressionKey(src);
72
8
  if (seen.has(key)) continue;
73
9
  seen.add(key);
74
10
  let body;
75
11
  try {
76
- body = compileBody(src, returns);
77
- Function("$", "__a", ...params, body);
12
+ [body] = compileBody(functionCompiler, src, params);
78
13
  } catch {
79
14
  continue;
80
15
  }
@@ -85,8 +20,23 @@ ${lines.join("\n")}
85
20
  }
86
21
  `;
87
22
  };
88
- const entities = { "&quot;": '"', "&#39;": "'", "&apos;": "'", "&lt;": "<", "&gt;": ">", "&amp;": "&" };
89
- const decode = (s) => s.replace(/&(quot|#39|apos|lt|gt|amp);/g, (m) => entities[m]);
23
+ const entities = {
24
+ "&quot;": '"',
25
+ "&#39;": "'",
26
+ "&apos;": "'",
27
+ "&lt;": "<",
28
+ "&gt;": ">",
29
+ "&amp;": "&"
30
+ };
31
+ const decode = (s) => s.replace(
32
+ /&(?:quot|apos|lt|gt|amp|#\d+|#x[\da-f]+);/gi,
33
+ (m) => m[1] === "#" ? String.fromCodePoint(
34
+ Number.parseInt(
35
+ m[2] === "x" || m[2] === "X" ? m.slice(3, -1) : m.slice(2, -1),
36
+ m[2] === "x" || m[2] === "X" ? 16 : 10
37
+ )
38
+ ) : entities[m.toLowerCase()] ?? m
39
+ );
90
40
  const extractExpressions = (source, plugins, prefixes = ["data-"]) => {
91
41
  const byName = new Map(plugins.map((p) => [p.name, p]));
92
42
  const out = [];
@@ -96,16 +46,23 @@ const extractExpressions = (source, plugins, prefixes = ["data-"]) => {
96
46
  const value = decode(m[2] ?? m[3] ?? "");
97
47
  const prefix = prefixes.find((p) => attr.startsWith(p));
98
48
  if (!prefix || !value.trim()) continue;
99
- const plugin = byName.get(attr.slice(prefix.length).split("__")[0].split(":")[0]);
100
- if (!plugin) continue;
101
- out.push({ src: value, params: ["el", "evt", ...plugin.args ?? []], returns: plugin.returns ?? true });
49
+ const [head, ...mods] = attr.slice(prefix.length).split("__");
50
+ const plugin = byName.get(head.split(":")[0]);
51
+ if (!plugin || plugin.literal && !mods.some((x) => x.split(".")[0] === "dynamic")) continue;
52
+ out.push({ src: value, params: ["el", "evt", ...plugin.args ?? []] });
102
53
  }
103
54
  return out;
104
55
  };
56
+ const lintSource = (source, prefixes = ["data-"]) => {
57
+ const out = [];
58
+ for (const p of prefixes)
59
+ for (const m of source.matchAll(new RegExp(`(?<![\\w-])(${p}[a-z-]+:[^\\s="'<>]*[A-Z][^\\s="'<>]*)`, "g")))
60
+ out.push(`${m[1]}: attribute names are lowercased by HTML; write the key in kebab-case`);
61
+ return out;
62
+ };
105
63
  export {
106
- compileBody,
107
64
  extractExpressions,
108
65
  generateTable,
109
- rewriteSignals
66
+ lintSource
110
67
  };
111
68
  //# sourceMappingURL=precompile.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/kernel/precompile.ts"],
4
- "sourcesContent": ["// Build-time expression compiler. Not for the browser: import it from a Vite/Astro plugin.\nimport { rewriteActions, splitStatements } from './compile.js'\nimport { expressionKey } from './precompiled.js'\n\nconst ident = /[A-Za-z0-9_$]/\n\n/**\n * Rewrite `$name` and `$a.b` into `$.name` / `$.a.b` so the expression runs in strict mode without\n * `with`. Skips strings and comments, recurses into template-literal interpolations, and leaves\n * `$` alone, `$[...]` alone, and `obj.$prop` alone.\n */\nexport const rewriteSignals = (src: string): string => {\n let out = ''\n let i = 0\n const n = src.length\n const prevCode = () => {\n for (let j = out.length - 1; j >= 0; j--) if (!/\\s/.test(out[j])) return out[j]\n return ''\n }\n while (i < n) {\n const c = src[i]\n const next = src[i + 1]\n if (c === '\"' || c === \"'\") {\n let j = i + 1\n while (j < n && src[j] !== c) j += src[j] === '\\\\' ? 2 : 1\n out += src.slice(i, j + 1)\n i = j + 1\n } else if (c === '`') {\n out += c\n i++\n while (i < n && src[i] !== '`') {\n if (src[i] === '\\\\') {\n out += src.slice(i, i + 2)\n i += 2\n } else if (src[i] === '$' && src[i + 1] === '{') {\n let depth = 1\n let j = i + 2\n while (j < n && depth) {\n if (src[j] === '{') depth++\n else if (src[j] === '}') depth--\n if (depth) j++\n }\n out += '${' + rewriteSignals(src.slice(i + 2, j)) + '}'\n i = j + 1\n } else out += src[i++]\n }\n out += '`'\n i++\n } else if (c === '/' && next === '/') {\n const j = src.indexOf('\\n', i)\n i = j < 0 ? n : j\n } else if (c === '/' && next === '*') {\n const j = src.indexOf('*/', i + 2)\n i = j < 0 ? n : j + 2\n } else if (c === '$' && next !== undefined && ident.test(next) && next !== '$' && prevCode() !== '.' && !ident.test(out[out.length - 1] ?? '')) {\n let j = i + 1\n while (j < n && ident.test(src[j])) j++\n out += '$.' + src.slice(i + 1, j)\n i = j\n } else {\n out += c\n i++\n }\n }\n return out\n}\n\n/** The strict-mode function body for one expression: same semantics as the runtime compiler. */\nexport const compileBody = (src: string, returns: boolean): string => {\n const code = rewriteSignals(rewriteActions(src.trim()))\n if (!returns) return code\n const parts = splitStatements(code)\n const last = parts.pop() ?? ''\n return `${parts.length ? parts.join(';') + ';' : ''}return (${last}\\n)`\n}\n\nexport type Extracted = { src: string; params: string[]; returns: boolean }\n\n/** JavaScript source for a module exporting `table`, from a list of extracted expressions. */\nexport const generateTable = (items: Extracted[]): string => {\n const seen = new Set<string>()\n const lines: string[] = []\n for (const { src, params, returns } of items) {\n const key = expressionKey(src, params, returns)\n if (seen.has(key)) continue\n seen.add(key)\n let body: string\n try {\n body = compileBody(src, returns)\n Function('$', '__a', ...params, body) // syntax check at build time\n } catch {\n continue // leave it to the runtime fallback (or fail there)\n }\n lines.push(` ${JSON.stringify(key)}: function($, __a, ${params.join(', ')}) { ${body} },`)\n }\n return `export const table = {\\n${lines.join('\\n')}\\n}\\n`\n}\n\nconst entities: Record<string, string> = { '&quot;': '\"', '&#39;': \"'\", '&apos;': \"'\", '&lt;': '<', '&gt;': '>', '&amp;': '&' }\nconst decode = (s: string) => s.replace(/&(quot|#39|apos|lt|gt|amp);/g, (m) => entities[m])\n\nexport type PluginMeta = { name: string; returns?: boolean; args?: string[] }\n\n/**\n * Find directive attributes with literal values in template source. Values must be plain quoted\n * strings; anything interpolated at render time is left to the runtime fallback.\n */\nexport const extractExpressions = (source: string, plugins: PluginMeta[], prefixes: string[] = ['data-']): Extracted[] => {\n const byName = new Map(plugins.map((p) => [p.name, p]))\n const out: Extracted[] = []\n const re = /([a-z][\\w-]*(?::[^\\s=\"'<>]+)?(?:__[^\\s=\"'<>]+)*)=(?:\"([^\"]*)\"|'([^']*)')/g\n for (const m of source.matchAll(re)) {\n const attr = m[1]\n const value = decode(m[2] ?? m[3] ?? '')\n const prefix = prefixes.find((p) => attr.startsWith(p))\n if (!prefix || !value.trim()) continue\n const plugin = byName.get(attr.slice(prefix.length).split('__')[0].split(':')[0])\n if (!plugin) continue\n out.push({ src: value, params: ['el', 'evt', ...(plugin.args ?? [])], returns: plugin.returns ?? true })\n }\n return out\n}\n"],
5
- "mappings": "AACA,SAAS,gBAAgB,uBAAuB;AAChD,SAAS,qBAAqB;AAE9B,MAAM,QAAQ;AAOP,MAAM,iBAAiB,CAAC,QAAwB;AACrD,MAAI,MAAM;AACV,MAAI,IAAI;AACR,QAAM,IAAI,IAAI;AACd,QAAM,WAAW,MAAM;AACrB,aAAS,IAAI,IAAI,SAAS,GAAG,KAAK,GAAG,IAAK,KAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,EAAG,QAAO,IAAI,CAAC;AAC9E,WAAO;AAAA,EACT;AACA,SAAO,IAAI,GAAG;AACZ,UAAM,IAAI,IAAI,CAAC;AACf,UAAM,OAAO,IAAI,IAAI,CAAC;AACtB,QAAI,MAAM,OAAO,MAAM,KAAK;AAC1B,UAAI,IAAI,IAAI;AACZ,aAAO,IAAI,KAAK,IAAI,CAAC,MAAM,EAAG,MAAK,IAAI,CAAC,MAAM,OAAO,IAAI;AACzD,aAAO,IAAI,MAAM,GAAG,IAAI,CAAC;AACzB,UAAI,IAAI;AAAA,IACV,WAAW,MAAM,KAAK;AACpB,aAAO;AACP;AACA,aAAO,IAAI,KAAK,IAAI,CAAC,MAAM,KAAK;AAC9B,YAAI,IAAI,CAAC,MAAM,MAAM;AACnB,iBAAO,IAAI,MAAM,GAAG,IAAI,CAAC;AACzB,eAAK;AAAA,QACP,WAAW,IAAI,CAAC,MAAM,OAAO,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,SAAS,OAAO,IAAI,KAAK,MAAM,OAAO,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC;AAChF,QAAI,CAAC,OAAQ;AACb,QAAI,KAAK,EAAE,KAAK,OAAO,QAAQ,CAAC,MAAM,OAAO,GAAI,OAAO,QAAQ,CAAC,CAAE,GAAG,SAAS,OAAO,WAAW,KAAK,CAAC;AAAA,EACzG;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["// Build-time expression compiler. Not for the browser: import it from a Vite/Astro plugin.\n// It emits the very same strict-mode bodies the runtime compiles, keyed by source text.\nimport { compileBody, functionCompiler } from './compile.js';\nimport { expressionKey } from './precompiled.js';\n\nexport type Extracted = { src: string; params: string[] };\n\nexport const generateTable = (items: Extracted[]): string => {\n const seen = new Set<string>();\n const lines: string[] = [];\n for (const { src, params } of items) {\n const key = expressionKey(src);\n if (seen.has(key)) continue;\n seen.add(key);\n let body: string;\n try {\n [body] = compileBody(functionCompiler, src, params); // also the syntax check\n } catch {\n continue; // leave it to the runtime fallback (or fail there)\n }\n lines.push(` ${JSON.stringify(key)}: function($, __a, ${params.join(', ')}) { ${body} },`);\n }\n return `export const table = {\\n${lines.join('\\n')}\\n}\\n`;\n};\n\nconst entities: Record<string, string> = {\n '&quot;': '\"',\n '&#39;': \"'\",\n '&apos;': \"'\",\n '&lt;': '<',\n '&gt;': '>',\n '&amp;': '&',\n};\nconst decode = (s: string) =>\n s.replace(/&(?:quot|apos|lt|gt|amp|#\\d+|#x[\\da-f]+);/gi, (m) =>\n m[1] === '#'\n ? String.fromCodePoint(\n Number.parseInt(\n m[2] === 'x' || m[2] === 'X' ? m.slice(3, -1) : m.slice(2, -1),\n m[2] === 'x' || m[2] === 'X' ? 16 : 10,\n ),\n )\n : (entities[m.toLowerCase()] ?? m),\n );\n\nexport type PluginMeta = { name: string; args?: string[]; literal?: boolean };\n\n/**\n * Find directive attributes with literal values in template source. Values must be plain quoted\n * strings; anything interpolated at render time is left to the runtime fallback. Plugins whose value\n * is a literal (mask, teleport, \u2026) are skipped unless the attribute carries `__dynamic`.\n */\nexport const extractExpressions = (\n source: string,\n plugins: PluginMeta[],\n prefixes: string[] = ['data-'],\n): Extracted[] => {\n const byName = new Map(plugins.map((p) => [p.name, p]));\n const out: Extracted[] = [];\n const re = /([a-z][\\w-]*(?::[^\\s=\"'<>]+)?(?:__[^\\s=\"'<>]+)*)=(?:\"([^\"]*)\"|'([^']*)')/g;\n for (const m of source.matchAll(re)) {\n const attr = m[1];\n const value = decode(m[2] ?? m[3] ?? '');\n const prefix = prefixes.find((p) => attr.startsWith(p));\n if (!prefix || !value.trim()) continue;\n const [head, ...mods] = attr.slice(prefix.length).split('__');\n const plugin = byName.get(head.split(':')[0]);\n if (!plugin || (plugin.literal && !mods.some((x) => x.split('.')[0] === 'dynamic'))) continue;\n out.push({ src: value, params: ['el', 'evt', ...(plugin.args ?? [])] });\n }\n return out;\n};\n\n/**\n * Keyed directive attributes whose key contains an uppercase letter. HTML lowercases attribute names,\n * so `data-bind:firstName` reaches the runtime as `firstname`: write `data-bind:first-name`.\n */\nexport const lintSource = (source: string, prefixes: string[] = ['data-']): string[] => {\n const out: string[] = [];\n for (const p of prefixes)\n for (const m of source.matchAll(new RegExp(`(?<![\\\\w-])(${p}[a-z-]+:[^\\\\s=\"'<>]*[A-Z][^\\\\s=\"'<>]*)`, 'g')))\n out.push(`${m[1]}: attribute names are lowercased by HTML; write the key in kebab-case`);\n return out;\n};\n"],
5
+ "mappings": "AAEA,SAAS,aAAa,wBAAwB;AAC9C,SAAS,qBAAqB;AAIvB,MAAM,gBAAgB,CAAC,UAA+B;AAC3D,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAkB,CAAC;AACzB,aAAW,EAAE,KAAK,OAAO,KAAK,OAAO;AACnC,UAAM,MAAM,cAAc,GAAG;AAC7B,QAAI,KAAK,IAAI,GAAG,EAAG;AACnB,SAAK,IAAI,GAAG;AACZ,QAAI;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AAM,GAAG,IAAI,IAAI,KAAK,MAAM,OAAO,MAAM,EAAE,MAAM,IAAI;AAC5D,UAAM,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;AAC5C,QAAI,CAAC,UAAW,OAAO,WAAW,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,SAAS,EAAI;AACrF,QAAI,KAAK,EAAE,KAAK,OAAO,QAAQ,CAAC,MAAM,OAAO,GAAI,OAAO,QAAQ,CAAC,CAAE,EAAE,CAAC;AAAA,EACxE;AACA,SAAO;AACT;AAMO,MAAM,aAAa,CAAC,QAAgB,WAAqB,CAAC,OAAO,MAAgB;AACtF,QAAM,MAAgB,CAAC;AACvB,aAAW,KAAK;AACd,eAAW,KAAK,OAAO,SAAS,IAAI,OAAO,eAAe,CAAC,0CAA0C,GAAG,CAAC;AACvG,UAAI,KAAK,GAAG,EAAE,CAAC,CAAC,uEAAuE;AAC3F,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,13 @@
1
1
  import type { ExpressionCompiler } from './contracts.js';
2
2
  export type ExpressionTable = Record<string, (root: any, actions: any, el: any, evt: any, ...args: any[]) => any>;
3
- /** Key used by the build plugin and the lookup: returns flag, parameter names, trimmed source. */
4
- export declare const expressionKey: (src: string, params: string[], returns: boolean) => string;
5
3
  /**
6
- * Look expressions up in a table generated at build time (see `sigmx/precompile`). Precompiled functions
7
- * receive the root store proxy as `$` instead of a `with` scope. Pass a `fallback` (for example
4
+ * Key used by the build plugin and the lookup: the trimmed source text. Parameter names are not part
5
+ * of it, so a plugin gaining an argument (arguments are only ever appended) keeps old tables valid.
6
+ */
7
+ export declare const expressionKey: (src: string) => string;
8
+ /**
9
+ * Look expressions up in a table generated at build time (see `sigmx/precompile`). Table functions
10
+ * take the root store proxy as `$`, exactly like runtime-compiled ones. Pass a `fallback` (for example
8
11
  * `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime
9
12
  * compiler is not bundled at all.
10
13
  */
@@ -1,10 +1,10 @@
1
- const expressionKey = (src, params, returns) => `${+returns}|${params.join()}|${src.trim()}`;
2
- const precompiled = (table, fallback, onMiss) => (src, params, returns) => {
3
- const fn = table[expressionKey(src, params, returns)];
4
- if (fn) return ((store, actions, el, evt, ...args) => fn(store.$, actions, el, evt, ...args));
1
+ const expressionKey = (src) => src.trim();
2
+ const precompiled = (table, fallback, onMiss) => (src, params) => {
3
+ const fn = table[expressionKey(src)];
4
+ if (fn) return ((store, actions, ...rest) => fn(store.$, actions, ...rest));
5
5
  onMiss?.(src);
6
6
  if (!fallback) throw new Error(`expression not precompiled: ${src}`);
7
- return fallback(src, params, returns);
7
+ return fallback(src, params);
8
8
  };
9
9
  export {
10
10
  expressionKey,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/kernel/precompiled.ts"],
4
- "sourcesContent": ["import type { Evaluator, ExpressionCompiler } from './contracts.js'\n\nexport type ExpressionTable = Record<string, (root: any, actions: any, el: any, evt: any, ...args: any[]) => any>\n\n/** Key used by the build plugin and the lookup: returns flag, parameter names, trimmed source. */\nexport const expressionKey = (src: string, params: string[], returns: boolean): string => `${+returns}|${params.join()}|${src.trim()}`\n\n/**\n * Look expressions up in a table generated at build time (see `sigmx/precompile`). Precompiled functions\n * receive the root store proxy as `$` instead of a `with` scope. Pass a `fallback` (for example\n * `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime\n * compiler is not bundled at all.\n */\nexport const precompiled =\n (table: ExpressionTable, fallback?: ExpressionCompiler, onMiss?: (src: string) => void): ExpressionCompiler =>\n (src, params, returns) => {\n const fn = table[expressionKey(src, params, returns)]\n if (fn) return ((store, actions, el, evt, ...args) => fn(store.$, actions, el, evt, ...args)) as Evaluator\n onMiss?.(src)\n if (!fallback) throw new Error(`expression not precompiled: ${src}`)\n return fallback(src, params, returns)\n }\n"],
5
- "mappings": "AAKO,MAAM,gBAAgB,CAAC,KAAa,QAAkB,YAA6B,GAAG,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;AAQ7H,MAAM,cACX,CAAC,OAAwB,UAA+B,WACxD,CAAC,KAAK,QAAQ,YAAY;AACxB,QAAM,KAAK,MAAM,cAAc,KAAK,QAAQ,OAAO,CAAC;AACpD,MAAI,GAAI,SAAQ,CAAC,OAAO,SAAS,IAAI,QAAQ,SAAS,GAAG,MAAM,GAAG,SAAS,IAAI,KAAK,GAAG,IAAI;AAC3F,WAAS,GAAG;AACZ,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,+BAA+B,GAAG,EAAE;AACnE,SAAO,SAAS,KAAK,QAAQ,OAAO;AACtC;",
4
+ "sourcesContent": ["import type { Evaluator, ExpressionCompiler } from './contracts.js';\n\nexport type ExpressionTable = Record<string, (root: any, actions: any, el: any, evt: any, ...args: any[]) => any>;\n\n/**\n * Key used by the build plugin and the lookup: the trimmed source text. Parameter names are not part\n * of it, so a plugin gaining an argument (arguments are only ever appended) keeps old tables valid.\n */\nexport const expressionKey = (src: string): string => src.trim();\n\n/**\n * Look expressions up in a table generated at build time (see `sigmx/precompile`). Table functions\n * take the root store proxy as `$`, exactly like runtime-compiled ones. Pass a `fallback` (for example\n * `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime\n * compiler is not bundled at all.\n */\nexport const precompiled =\n (table: ExpressionTable, fallback?: ExpressionCompiler, onMiss?: (src: string) => void): ExpressionCompiler =>\n (src, params) => {\n const fn = table[expressionKey(src)];\n if (fn) return ((store, actions, ...rest) => fn(store.$, actions, ...rest)) as Evaluator;\n onMiss?.(src);\n if (!fallback) throw new Error(`expression not precompiled: ${src}`);\n return fallback(src, params);\n };\n"],
5
+ "mappings": "AAQO,MAAM,gBAAgB,CAAC,QAAwB,IAAI,KAAK;AAQxD,MAAM,cACX,CAAC,OAAwB,UAA+B,WACxD,CAAC,KAAK,WAAW;AACf,QAAM,KAAK,MAAM,cAAc,GAAG,CAAC;AACnC,MAAI,GAAI,SAAQ,CAAC,OAAO,YAAY,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;AACzE,WAAS,GAAG;AACZ,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,+BAA+B,GAAG,EAAE;AACnE,SAAO,SAAS,KAAK,MAAM;AAC7B;",
6
6
  "names": []
7
7
  }
@@ -3,27 +3,27 @@ interface Tracker {
3
3
  _invalidate(): void;
4
4
  }
5
5
  export declare class Signal<T> {
6
- /** @internal */ _v: T;
7
- /** @internal */ _ver: number;
8
- /** @internal */ _subs: Set<Tracker>;
6
+ _v: T;
7
+ _ver: number;
8
+ _subs: Set<Tracker>;
9
9
  constructor(v: T);
10
10
  get value(): T;
11
11
  set value(x: T);
12
- /** Read without subscribing. */
13
12
  peek(): T;
14
13
  /** Notify subscribers without replacing the value (after mutating an array or object in place). */
15
14
  bump(): void;
16
15
  }
17
16
  export declare class Computed<T> extends Signal<T> implements Tracker {
17
+ _fn: () => T;
18
18
  _deps: Map<Signal<any>, number>;
19
- /** @internal */ _dirty: boolean;
20
- /** @internal */ _fn: () => T;
19
+ _dirty: boolean;
21
20
  constructor(fn: () => T);
22
- /** @internal */ _refresh(): void;
21
+ _refresh(): void;
23
22
  get value(): T;
24
23
  set value(_: T);
25
- peek(): T;
26
24
  _invalidate(): void;
25
+ /** Unsubscribe from every dependency; the computed is no longer recalculated. Public: the store calls it. */
26
+ dispose(): void;
27
27
  }
28
28
  export declare const signal: <T>(value: T) => Signal<T>;
29
29
  export declare const computed: <T>(fn: () => T) => Computed<T>;
@@ -32,11 +32,13 @@ export declare const computed: <T>(fn: () => T) => Computed<T>;
32
32
  * effect are disposed when the parent re-runs. Returns a disposer.
33
33
  */
34
34
  export declare const effect: (fn: () => void, onError?: (e: unknown) => void) => (() => void);
35
- /** Coalesce many writes into one round of effect runs. */
35
+ /**
36
+ * Like `effect`, but never owned by the effect that happens to be running: for long-lived effects
37
+ * such as mounted attributes, which must not die when an unrelated parent effect re-runs.
38
+ */
39
+ export declare const rootEffect: (fn: () => void, onError?: (e: unknown) => void) => (() => void);
36
40
  export declare const batch: <R>(fn: () => R) => R;
37
- /** Read signals inside `fn` without subscribing the current effect to them. */
38
41
  export declare const untracked: <R>(fn: () => R) => R;
39
- /** Called after each flush once every queued effect has run. */
40
42
  export declare const onSettled: (fn: () => void) => (() => void);
41
43
  export declare const flush: () => void;
42
44
  export {};