sigmx 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -0
  3. package/dist/auto.d.ts +1 -0
  4. package/dist/auto.js +7 -0
  5. package/dist/auto.js.map +7 -0
  6. package/dist/cli.d.ts +2 -0
  7. package/dist/cli.js +26 -0
  8. package/dist/cli.js.map +7 -0
  9. package/dist/core/csp.d.ts +7 -0
  10. package/dist/core/csp.js +20 -0
  11. package/dist/core/csp.js.map +7 -0
  12. package/dist/core/engine.d.ts +10 -0
  13. package/dist/core/engine.js +200 -0
  14. package/dist/core/engine.js.map +7 -0
  15. package/dist/core/expr.d.ts +12 -0
  16. package/dist/core/expr.js +94 -0
  17. package/dist/core/expr.js.map +7 -0
  18. package/dist/core/index.d.ts +16 -0
  19. package/dist/core/index.js +46 -0
  20. package/dist/core/index.js.map +7 -0
  21. package/dist/core/signals.d.ts +42 -0
  22. package/dist/core/signals.js +195 -0
  23. package/dist/core/signals.js.map +7 -0
  24. package/dist/core/store.d.ts +32 -0
  25. package/dist/core/store.js +185 -0
  26. package/dist/core/store.js.map +7 -0
  27. package/dist/core/types.d.ts +101 -0
  28. package/dist/core/types.js +1 -0
  29. package/dist/core/types.js.map +7 -0
  30. package/dist/kernel/compile.d.ts +16 -0
  31. package/dist/kernel/compile.js +96 -0
  32. package/dist/kernel/compile.js.map +7 -0
  33. package/dist/kernel/contracts.d.ts +121 -0
  34. package/dist/kernel/contracts.js +1 -0
  35. package/dist/kernel/contracts.js.map +7 -0
  36. package/dist/kernel/index.d.ts +20 -0
  37. package/dist/kernel/index.js +54 -0
  38. package/dist/kernel/index.js.map +7 -0
  39. package/dist/kernel/precompile.d.ts +25 -0
  40. package/dist/kernel/precompile.js +111 -0
  41. package/dist/kernel/precompile.js.map +7 -0
  42. package/dist/kernel/precompiled.d.ts +11 -0
  43. package/dist/kernel/precompiled.js +13 -0
  44. package/dist/kernel/precompiled.js.map +7 -0
  45. package/dist/kernel/reactive.d.ts +42 -0
  46. package/dist/kernel/reactive.js +201 -0
  47. package/dist/kernel/reactive.js.map +7 -0
  48. package/dist/kernel/runtime.d.ts +11 -0
  49. package/dist/kernel/runtime.js +210 -0
  50. package/dist/kernel/runtime.js.map +7 -0
  51. package/dist/kernel/scan.d.ts +42 -0
  52. package/dist/kernel/scan.js +68 -0
  53. package/dist/kernel/scan.js.map +7 -0
  54. package/dist/kernel/state.d.ts +32 -0
  55. package/dist/kernel/state.js +186 -0
  56. package/dist/kernel/state.js.map +7 -0
  57. package/dist/kernel/strict-csp.d.ts +7 -0
  58. package/dist/kernel/strict-csp.js +20 -0
  59. package/dist/kernel/strict-csp.js.map +7 -0
  60. package/dist/lib/casing.d.ts +7 -0
  61. package/dist/lib/casing.js +16 -0
  62. package/dist/lib/casing.js.map +7 -0
  63. package/dist/lib/objects.d.ts +9 -0
  64. package/dist/lib/objects.js +26 -0
  65. package/dist/lib/objects.js.map +7 -0
  66. package/dist/lib/schedule.d.ts +14 -0
  67. package/dist/lib/schedule.js +51 -0
  68. package/dist/lib/schedule.js.map +7 -0
  69. package/dist/lib/sse.d.ts +10 -0
  70. package/dist/lib/sse.js +55 -0
  71. package/dist/lib/sse.js.map +7 -0
  72. package/dist/plugins/actions/clipboard.d.ts +2 -0
  73. package/dist/plugins/actions/clipboard.js +11 -0
  74. package/dist/plugins/actions/clipboard.js.map +7 -0
  75. package/dist/plugins/actions/fit.d.ts +2 -0
  76. package/dist/plugins/actions/fit.js +14 -0
  77. package/dist/plugins/actions/fit.js.map +7 -0
  78. package/dist/plugins/actions/intl.d.ts +2 -0
  79. package/dist/plugins/actions/intl.js +21 -0
  80. package/dist/plugins/actions/intl.js.map +7 -0
  81. package/dist/plugins/actions/peek.d.ts +2 -0
  82. package/dist/plugins/actions/peek.js +6 -0
  83. package/dist/plugins/actions/peek.js.map +7 -0
  84. package/dist/plugins/actions/setAll.d.ts +2 -0
  85. package/dist/plugins/actions/setAll.js +11 -0
  86. package/dist/plugins/actions/setAll.js.map +7 -0
  87. package/dist/plugins/actions/toggleAll.d.ts +2 -0
  88. package/dist/plugins/actions/toggleAll.js +11 -0
  89. package/dist/plugins/actions/toggleAll.js.map +7 -0
  90. package/dist/plugins/attributes/attr.d.ts +2 -0
  91. package/dist/plugins/attributes/attr.js +20 -0
  92. package/dist/plugins/attributes/attr.js.map +7 -0
  93. package/dist/plugins/attributes/bind.d.ts +6 -0
  94. package/dist/plugins/attributes/bind.js +81 -0
  95. package/dist/plugins/attributes/bind.js.map +7 -0
  96. package/dist/plugins/attributes/class.d.ts +2 -0
  97. package/dist/plugins/attributes/class.js +22 -0
  98. package/dist/plugins/attributes/class.js.map +7 -0
  99. package/dist/plugins/attributes/computed.d.ts +2 -0
  100. package/dist/plugins/attributes/computed.js +20 -0
  101. package/dist/plugins/attributes/computed.js.map +7 -0
  102. package/dist/plugins/attributes/customValidity.d.ts +2 -0
  103. package/dist/plugins/attributes/customValidity.js +14 -0
  104. package/dist/plugins/attributes/customValidity.js.map +7 -0
  105. package/dist/plugins/attributes/effect.d.ts +2 -0
  106. package/dist/plugins/attributes/effect.js +12 -0
  107. package/dist/plugins/attributes/effect.js.map +7 -0
  108. package/dist/plugins/attributes/indicator.d.ts +2 -0
  109. package/dist/plugins/attributes/indicator.js +20 -0
  110. package/dist/plugins/attributes/indicator.js.map +7 -0
  111. package/dist/plugins/attributes/init.d.ts +2 -0
  112. package/dist/plugins/attributes/init.js +14 -0
  113. package/dist/plugins/attributes/init.js.map +7 -0
  114. package/dist/plugins/attributes/jsonSignals.d.ts +2 -0
  115. package/dist/plugins/attributes/jsonSignals.js +15 -0
  116. package/dist/plugins/attributes/jsonSignals.js.map +7 -0
  117. package/dist/plugins/attributes/matchMedia.d.ts +2 -0
  118. package/dist/plugins/attributes/matchMedia.js +19 -0
  119. package/dist/plugins/attributes/matchMedia.js.map +7 -0
  120. package/dist/plugins/attributes/on.d.ts +5 -0
  121. package/dist/plugins/attributes/on.js +28 -0
  122. package/dist/plugins/attributes/on.js.map +7 -0
  123. package/dist/plugins/attributes/onIntersect.d.ts +2 -0
  124. package/dist/plugins/attributes/onIntersect.js +28 -0
  125. package/dist/plugins/attributes/onIntersect.js.map +7 -0
  126. package/dist/plugins/attributes/onInterval.d.ts +2 -0
  127. package/dist/plugins/attributes/onInterval.js +18 -0
  128. package/dist/plugins/attributes/onInterval.js.map +7 -0
  129. package/dist/plugins/attributes/onRaf.d.ts +1 -0
  130. package/dist/plugins/attributes/onRaf.js +19 -0
  131. package/dist/plugins/attributes/onRaf.js.map +7 -0
  132. package/dist/plugins/attributes/onResize.d.ts +1 -0
  133. package/dist/plugins/attributes/onResize.js +17 -0
  134. package/dist/plugins/attributes/onResize.js.map +7 -0
  135. package/dist/plugins/attributes/onSignalPatch.d.ts +5 -0
  136. package/dist/plugins/attributes/onSignalPatch.js +35 -0
  137. package/dist/plugins/attributes/onSignalPatch.js.map +7 -0
  138. package/dist/plugins/attributes/persist.d.ts +6 -0
  139. package/dist/plugins/attributes/persist.js +16 -0
  140. package/dist/plugins/attributes/persist.js.map +7 -0
  141. package/dist/plugins/attributes/queryString.d.ts +5 -0
  142. package/dist/plugins/attributes/queryString.js +54 -0
  143. package/dist/plugins/attributes/queryString.js.map +7 -0
  144. package/dist/plugins/attributes/ref.d.ts +2 -0
  145. package/dist/plugins/attributes/ref.js +13 -0
  146. package/dist/plugins/attributes/ref.js.map +7 -0
  147. package/dist/plugins/attributes/replaceUrl.d.ts +1 -0
  148. package/dist/plugins/attributes/replaceUrl.js +11 -0
  149. package/dist/plugins/attributes/replaceUrl.js.map +7 -0
  150. package/dist/plugins/attributes/scrollIntoView.d.ts +2 -0
  151. package/dist/plugins/attributes/scrollIntoView.js +19 -0
  152. package/dist/plugins/attributes/scrollIntoView.js.map +7 -0
  153. package/dist/plugins/attributes/show.d.ts +2 -0
  154. package/dist/plugins/attributes/show.js +19 -0
  155. package/dist/plugins/attributes/show.js.map +7 -0
  156. package/dist/plugins/attributes/signals.d.ts +2 -0
  157. package/dist/plugins/attributes/signals.js +13 -0
  158. package/dist/plugins/attributes/signals.js.map +7 -0
  159. package/dist/plugins/attributes/style.d.ts +2 -0
  160. package/dist/plugins/attributes/style.js +25 -0
  161. package/dist/plugins/attributes/style.js.map +7 -0
  162. package/dist/plugins/attributes/text.d.ts +1 -0
  163. package/dist/plugins/attributes/text.js +13 -0
  164. package/dist/plugins/attributes/text.js.map +7 -0
  165. package/dist/plugins/attributes/viewTransition.d.ts +1 -0
  166. package/dist/plugins/attributes/viewTransition.js +11 -0
  167. package/dist/plugins/attributes/viewTransition.js.map +7 -0
  168. package/dist/plugins/directives/attribute-sync.d.ts +2 -0
  169. package/dist/plugins/directives/attribute-sync.js +20 -0
  170. package/dist/plugins/directives/attribute-sync.js.map +7 -0
  171. package/dist/plugins/directives/boost.d.ts +6 -0
  172. package/dist/plugins/directives/boost.js +35 -0
  173. package/dist/plugins/directives/boost.js.map +7 -0
  174. package/dist/plugins/directives/busy-flag.d.ts +2 -0
  175. package/dist/plugins/directives/busy-flag.js +21 -0
  176. package/dist/plugins/directives/busy-flag.js.map +7 -0
  177. package/dist/plugins/directives/class-toggle.d.ts +2 -0
  178. package/dist/plugins/directives/class-toggle.js +22 -0
  179. package/dist/plugins/directives/class-toggle.js.map +7 -0
  180. package/dist/plugins/directives/cloak.d.ts +5 -0
  181. package/dist/plugins/directives/cloak.js +11 -0
  182. package/dist/plugins/directives/cloak.js.map +7 -0
  183. package/dist/plugins/directives/collapse.d.ts +5 -0
  184. package/dist/plugins/directives/collapse.js +42 -0
  185. package/dist/plugins/directives/collapse.js.map +7 -0
  186. package/dist/plugins/directives/declare.d.ts +2 -0
  187. package/dist/plugins/directives/declare.js +13 -0
  188. package/dist/plugins/directives/declare.js.map +7 -0
  189. package/dist/plugins/directives/derive.d.ts +2 -0
  190. package/dist/plugins/directives/derive.js +20 -0
  191. package/dist/plugins/directives/derive.js.map +7 -0
  192. package/dist/plugins/directives/element-ref.d.ts +2 -0
  193. package/dist/plugins/directives/element-ref.js +13 -0
  194. package/dist/plugins/directives/element-ref.js.map +7 -0
  195. package/dist/plugins/directives/event-listener.d.ts +5 -0
  196. package/dist/plugins/directives/event-listener.js +28 -0
  197. package/dist/plugins/directives/event-listener.js.map +7 -0
  198. package/dist/plugins/directives/frame-loop.d.ts +1 -0
  199. package/dist/plugins/directives/frame-loop.js +19 -0
  200. package/dist/plugins/directives/frame-loop.js.map +7 -0
  201. package/dist/plugins/directives/html.d.ts +2 -0
  202. package/dist/plugins/directives/html.js +13 -0
  203. package/dist/plugins/directives/html.js.map +7 -0
  204. package/dist/plugins/directives/inline-style.d.ts +2 -0
  205. package/dist/plugins/directives/inline-style.js +25 -0
  206. package/dist/plugins/directives/inline-style.js.map +7 -0
  207. package/dist/plugins/directives/mask.d.ts +7 -0
  208. package/dist/plugins/directives/mask.js +47 -0
  209. package/dist/plugins/directives/mask.js.map +7 -0
  210. package/dist/plugins/directives/media-query.d.ts +2 -0
  211. package/dist/plugins/directives/media-query.js +19 -0
  212. package/dist/plugins/directives/media-query.js.map +7 -0
  213. package/dist/plugins/directives/on-mount.d.ts +2 -0
  214. package/dist/plugins/directives/on-mount.js +14 -0
  215. package/dist/plugins/directives/on-mount.js.map +7 -0
  216. package/dist/plugins/directives/patch-listener.d.ts +5 -0
  217. package/dist/plugins/directives/patch-listener.js +35 -0
  218. package/dist/plugins/directives/patch-listener.js.map +7 -0
  219. package/dist/plugins/directives/remove-me.d.ts +2 -0
  220. package/dist/plugins/directives/remove-me.js +13 -0
  221. package/dist/plugins/directives/remove-me.js.map +7 -0
  222. package/dist/plugins/directives/scroll-to.d.ts +2 -0
  223. package/dist/plugins/directives/scroll-to.js +19 -0
  224. package/dist/plugins/directives/scroll-to.js.map +7 -0
  225. package/dist/plugins/directives/size-watch.d.ts +1 -0
  226. package/dist/plugins/directives/size-watch.js +17 -0
  227. package/dist/plugins/directives/size-watch.js.map +7 -0
  228. package/dist/plugins/directives/state-dump.d.ts +2 -0
  229. package/dist/plugins/directives/state-dump.js +15 -0
  230. package/dist/plugins/directives/state-dump.js.map +7 -0
  231. package/dist/plugins/directives/storage-sync.d.ts +6 -0
  232. package/dist/plugins/directives/storage-sync.js +16 -0
  233. package/dist/plugins/directives/storage-sync.js.map +7 -0
  234. package/dist/plugins/directives/teleport.d.ts +5 -0
  235. package/dist/plugins/directives/teleport.js +19 -0
  236. package/dist/plugins/directives/teleport.js.map +7 -0
  237. package/dist/plugins/directives/text-content.d.ts +1 -0
  238. package/dist/plugins/directives/text-content.js +13 -0
  239. package/dist/plugins/directives/text-content.js.map +7 -0
  240. package/dist/plugins/directives/timer.d.ts +2 -0
  241. package/dist/plugins/directives/timer.js +18 -0
  242. package/dist/plugins/directives/timer.js.map +7 -0
  243. package/dist/plugins/directives/transition-name.d.ts +1 -0
  244. package/dist/plugins/directives/transition-name.js +11 -0
  245. package/dist/plugins/directives/transition-name.js.map +7 -0
  246. package/dist/plugins/directives/transition.d.ts +5 -0
  247. package/dist/plugins/directives/transition.js +40 -0
  248. package/dist/plugins/directives/transition.js.map +7 -0
  249. package/dist/plugins/directives/trap.d.ts +5 -0
  250. package/dist/plugins/directives/trap.js +48 -0
  251. package/dist/plugins/directives/trap.js.map +7 -0
  252. package/dist/plugins/directives/tween.d.ts +6 -0
  253. package/dist/plugins/directives/tween.js +58 -0
  254. package/dist/plugins/directives/tween.js.map +7 -0
  255. package/dist/plugins/directives/two-way-bind.d.ts +6 -0
  256. package/dist/plugins/directives/two-way-bind.js +82 -0
  257. package/dist/plugins/directives/two-way-bind.js.map +7 -0
  258. package/dist/plugins/directives/url-params.d.ts +13 -0
  259. package/dist/plugins/directives/url-params.js +76 -0
  260. package/dist/plugins/directives/url-params.js.map +7 -0
  261. package/dist/plugins/directives/url-replace.d.ts +1 -0
  262. package/dist/plugins/directives/url-replace.js +11 -0
  263. package/dist/plugins/directives/url-replace.js.map +7 -0
  264. package/dist/plugins/directives/validity.d.ts +2 -0
  265. package/dist/plugins/directives/validity.js +14 -0
  266. package/dist/plugins/directives/validity.js.map +7 -0
  267. package/dist/plugins/directives/viewport.d.ts +2 -0
  268. package/dist/plugins/directives/viewport.js +28 -0
  269. package/dist/plugins/directives/viewport.js.map +7 -0
  270. package/dist/plugins/directives/visibility.d.ts +2 -0
  271. package/dist/plugins/directives/visibility.js +19 -0
  272. package/dist/plugins/directives/visibility.js.map +7 -0
  273. package/dist/plugins/directives/watch.d.ts +2 -0
  274. package/dist/plugins/directives/watch.js +12 -0
  275. package/dist/plugins/directives/watch.js.map +7 -0
  276. package/dist/plugins/functions/bulk-set.d.ts +2 -0
  277. package/dist/plugins/functions/bulk-set.js +11 -0
  278. package/dist/plugins/functions/bulk-set.js.map +7 -0
  279. package/dist/plugins/functions/bulk-toggle.d.ts +2 -0
  280. package/dist/plugins/functions/bulk-toggle.js +11 -0
  281. package/dist/plugins/functions/bulk-toggle.js.map +7 -0
  282. package/dist/plugins/functions/confirm.d.ts +2 -0
  283. package/dist/plugins/functions/confirm.js +6 -0
  284. package/dist/plugins/functions/confirm.js.map +7 -0
  285. package/dist/plugins/functions/copy-text.d.ts +2 -0
  286. package/dist/plugins/functions/copy-text.js +11 -0
  287. package/dist/plugins/functions/copy-text.js.map +7 -0
  288. package/dist/plugins/functions/dispatch.d.ts +2 -0
  289. package/dist/plugins/functions/dispatch.js +9 -0
  290. package/dist/plugins/functions/dispatch.js.map +7 -0
  291. package/dist/plugins/functions/locale-format.d.ts +2 -0
  292. package/dist/plugins/functions/locale-format.js +21 -0
  293. package/dist/plugins/functions/locale-format.js.map +7 -0
  294. package/dist/plugins/functions/range-map.d.ts +2 -0
  295. package/dist/plugins/functions/range-map.js +14 -0
  296. package/dist/plugins/functions/range-map.js.map +7 -0
  297. package/dist/plugins/functions/request.d.ts +30 -0
  298. package/dist/plugins/functions/request.js +152 -0
  299. package/dist/plugins/functions/request.js.map +7 -0
  300. package/dist/plugins/functions/untracked-read.d.ts +2 -0
  301. package/dist/plugins/functions/untracked-read.js +6 -0
  302. package/dist/plugins/functions/untracked-read.js.map +7 -0
  303. package/dist/plugins/functions/websocket.d.ts +11 -0
  304. package/dist/plugins/functions/websocket.js +35 -0
  305. package/dist/plugins/functions/websocket.js.map +7 -0
  306. package/dist/plugins/index.d.ts +52 -0
  307. package/dist/plugins/index.js +108 -0
  308. package/dist/plugins/index.js.map +7 -0
  309. package/dist/plugins/server-events/apply-elements.d.ts +2 -0
  310. package/dist/plugins/server-events/apply-elements.js +62 -0
  311. package/dist/plugins/server-events/apply-elements.js.map +7 -0
  312. package/dist/plugins/server-events/apply-state.d.ts +2 -0
  313. package/dist/plugins/server-events/apply-state.js +18 -0
  314. package/dist/plugins/server-events/apply-state.js.map +7 -0
  315. package/dist/plugins/server-events/morph.d.ts +12 -0
  316. package/dist/plugins/server-events/morph.js +124 -0
  317. package/dist/plugins/server-events/morph.js.map +7 -0
  318. package/dist/presets/all.d.ts +3 -0
  319. package/dist/presets/all.js +112 -0
  320. package/dist/presets/all.js.map +7 -0
  321. package/dist/presets/essentials.d.ts +3 -0
  322. package/dist/presets/essentials.js +18 -0
  323. package/dist/presets/essentials.js.map +7 -0
  324. package/dist/presets/minimal.d.ts +3 -0
  325. package/dist/presets/minimal.js +9 -0
  326. package/dist/presets/minimal.js.map +7 -0
  327. package/dist/sigmx.auto.js +5 -0
  328. package/dist/sigmx.standalone.js +1 -0
  329. package/dist/standalone.d.ts +1 -0
  330. package/dist/standalone.js +8 -0
  331. package/dist/standalone.js.map +7 -0
  332. package/dist/utils/object.d.ts +9 -0
  333. package/dist/utils/object.js +26 -0
  334. package/dist/utils/object.js.map +7 -0
  335. package/dist/utils/text.d.ts +7 -0
  336. package/dist/utils/text.js +15 -0
  337. package/dist/utils/text.js.map +7 -0
  338. package/dist/utils/timing.d.ts +14 -0
  339. package/dist/utils/timing.js +58 -0
  340. package/dist/utils/timing.js.map +7 -0
  341. package/dist/vite.d.ts +42 -0
  342. package/dist/vite.js +79 -0
  343. package/dist/vite.js.map +7 -0
  344. package/package.json +111 -0
@@ -0,0 +1,101 @@
1
+ import type { Compiler } from './expr.js';
2
+ import type { Store } from './store.js';
3
+ import type { CaseStyle } from '../utils/text.js';
4
+ export type El = HTMLElement | SVGElement | MathMLElement;
5
+ export type Mods = Map<string, string[]>;
6
+ export interface Runtime {
7
+ /** Attribute prefixes being scanned; the first is primary. */
8
+ readonly prefixes: readonly string[];
9
+ /** Full attribute name under the primary prefix: attr('on') → 'data-on'. */
10
+ attr(name: string): string;
11
+ readonly store: Store;
12
+ readonly compiler: Compiler;
13
+ /** Dispatch a `sigmx-<type>` CustomEvent on `document`. */
14
+ emit(type: string, detail?: unknown): void;
15
+ /** Call a registered action by name. */
16
+ call(name: string, ctx: ActionCtx, args: any[]): any;
17
+ readonly attributes: Record<string, AttributePlugin>;
18
+ readonly actions: Record<string, ActionPlugin>;
19
+ readonly handlers: Record<string, HandlerPlugin>;
20
+ }
21
+ export interface Ctx {
22
+ el: El;
23
+ /** Plugin name, e.g. 'on'. */
24
+ plugin: string;
25
+ /** Full attribute name as written, e.g. 'data-on:click__debounce.300ms'. */
26
+ attr: string;
27
+ /** The `:key` part, if any. */
28
+ key: string | undefined;
29
+ /** Attribute value (the expression source). */
30
+ value: string;
31
+ mods: Mods;
32
+ /** The key recased per `__case.<style>`, defaulting to `style`. */
33
+ cased(style?: CaseStyle): string;
34
+ /** Evaluate the attribute expression. `evt` and any `args` are exposed to it by name. */
35
+ evaluate(evt?: Event, ...args: any[]): any;
36
+ /** Reactive effect disposed with the attribute. Errors are reported, not thrown. */
37
+ effect(fn: () => void): void;
38
+ /** addEventListener with automatic removal on cleanup. */
39
+ listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void;
40
+ cleanup(fn: () => void): void;
41
+ error(message: string, extra?: Record<string, unknown>): Error;
42
+ store: Store;
43
+ runtime: Runtime;
44
+ }
45
+ export interface ActionCtx {
46
+ el: El;
47
+ evt?: Event;
48
+ store: Store;
49
+ runtime: Runtime;
50
+ error(message: string, extra?: Record<string, unknown>): Error;
51
+ }
52
+ export interface AttributePlugin {
53
+ type: 'attribute';
54
+ name: string;
55
+ key?: 'required' | 'forbidden';
56
+ value?: 'required' | 'forbidden';
57
+ /** Whether the expression yields a value (default) or is a statement body. */
58
+ returns?: boolean;
59
+ /** Extra parameter names the expression can reference, in the order passed to `evaluate`. */
60
+ args?: string[];
61
+ mount(ctx: Ctx): void | (() => void);
62
+ }
63
+ export interface ActionPlugin {
64
+ type: 'action';
65
+ name: string;
66
+ call(ctx: ActionCtx, ...args: any[]): any;
67
+ }
68
+ /** Handles a named server event (for example a streamed patch). */
69
+ export interface HandlerPlugin {
70
+ type: 'handler';
71
+ name: string;
72
+ handle(runtime: Runtime, data: Record<string, string>): void;
73
+ }
74
+ export type Plugin = AttributePlugin | ActionPlugin | HandlerPlugin;
75
+ export interface SigmxOptions {
76
+ plugins?: Plugin[];
77
+ /** Attribute prefix or prefixes to scan. Default 'data-'. */
78
+ prefix?: string | string[];
79
+ compile?: Compiler;
80
+ /** Share a store between instances. */
81
+ store?: Store;
82
+ /** Called for any plugin or expression error. Default: console.error. */
83
+ onError?: (error: unknown, info: {
84
+ plugin?: string;
85
+ el?: Element;
86
+ attr?: string;
87
+ }) => void;
88
+ /** Scan `document.documentElement` on creation (after DOM ready). Default true. */
89
+ autoStart?: boolean;
90
+ }
91
+ export interface Sigmx {
92
+ runtime: Runtime;
93
+ store: Store;
94
+ /** Root namespace proxy for use from JavaScript: `sigmx.$.count++`. */
95
+ $: any;
96
+ /** Mount plugins under `root` and observe it for changes. */
97
+ apply(root?: El | ShadowRoot, observe?: boolean): void;
98
+ /** Register more plugins; attribute plugins are applied to observed roots immediately. */
99
+ use(...plugins: Plugin[]): void;
100
+ destroy(): void;
101
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import type { ExpressionCompiler } from './contracts.js';
2
+ export type Compiler = (params: string[], body: string) => (...args: any[]) => any;
3
+ /** Default compiler: `new Function`. Not usable under a strict CSP; see `cspCompiler`. */
4
+ export declare const functionCompiler: Compiler;
5
+ /** Replace `@name(` with `__a.name(` outside strings and comments. */
6
+ export declare const rewriteActions: (src: string) => string;
7
+ /** Split on top-level semicolons. */
8
+ export declare const splitStatements: (src: string) => string[];
9
+ /**
10
+ * Compile an expression to `(store, actions, ...params) => any`: the body runs inside
11
+ * `with (store.scope)`, so `$name` resolves through the store. With `returns`, the value of the
12
+ * last statement is returned, so `$a = 1; $a * 2` works. Compiled functions are cached by source.
13
+ */
14
+ export declare const compile: (compiler: Compiler, src: string, params: string[], returns: boolean) => ((...args: any[]) => any);
15
+ /** The default pipeline: compile at runtime inside `with (scope)` using `compiler` (`new Function` or CSP). */
16
+ export declare const runtimeExpressions: (compiler: Compiler) => ExpressionCompiler;
@@ -0,0 +1,96 @@
1
+ const functionCompiler = (params, body) => Function(...params, body);
2
+ const cache = /* @__PURE__ */ new Map();
3
+ const isIdent = (c) => /[A-Za-z0-9_$]/.test(c);
4
+ const scan = (src, onCode) => {
5
+ let i = 0;
6
+ const n = src.length;
7
+ while (i < n) {
8
+ const c = src[i];
9
+ const next = src[i + 1];
10
+ if (c === '"' || c === "'" || c === "`") {
11
+ let j = i + 1;
12
+ while (j < n && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
13
+ onCode(src.slice(i, j + 1), i);
14
+ i = j + 1;
15
+ } else if (c === "/" && next === "/") {
16
+ const j = src.indexOf("\n", i);
17
+ i = j < 0 ? n : j;
18
+ } else if (c === "/" && next === "*") {
19
+ const j = src.indexOf("*/", i + 2);
20
+ i = j < 0 ? n : j + 2;
21
+ } else {
22
+ const skip = onCode(c, i);
23
+ i += skip || 1;
24
+ }
25
+ }
26
+ };
27
+ const rewriteActions = (src) => {
28
+ let out = "";
29
+ scan(src, (c, i) => {
30
+ if (c === "@") {
31
+ let j = i + 1;
32
+ while (j < src.length && isIdent(src[j])) j++;
33
+ let k = j;
34
+ while (k < src.length && /\s/.test(src[k])) k++;
35
+ if (j > i + 1 && src[k] === "(") {
36
+ out += `__a.${src.slice(i + 1, j)}(`;
37
+ return k + 1 - i;
38
+ }
39
+ }
40
+ out += c;
41
+ });
42
+ return out;
43
+ };
44
+ const splitStatements = (src) => {
45
+ const parts = [];
46
+ let depth = 0;
47
+ let start = 0;
48
+ scan(src, (c, i) => {
49
+ if (c.length > 1) return;
50
+ if ("([{".includes(c)) depth++;
51
+ else if (")]}".includes(c)) depth--;
52
+ else if (c === ";" && !depth) {
53
+ parts.push(src.slice(start, i));
54
+ start = i + 1;
55
+ }
56
+ });
57
+ parts.push(src.slice(start));
58
+ return parts.filter((p) => p.trim());
59
+ };
60
+ const compile = (compiler, src, params, returns) => {
61
+ const key = `${+returns}|${params.join()}|${src}`;
62
+ const hit = cache.get(key);
63
+ if (hit) return hit;
64
+ const code = rewriteActions(src.trim());
65
+ const make = (body) => compiler(["$", "__a", ...params], `with($.scope){${body}
66
+ }`);
67
+ let fn;
68
+ if (!returns) {
69
+ fn = make(code);
70
+ } else {
71
+ try {
72
+ fn = make(`return(${code}
73
+ )`);
74
+ } catch {
75
+ const parts = splitStatements(code);
76
+ const last = parts.pop() ?? "";
77
+ try {
78
+ fn = make(`${parts.join(";")};return(${last}
79
+ )`);
80
+ } catch {
81
+ fn = make(code);
82
+ }
83
+ }
84
+ }
85
+ cache.set(key, fn);
86
+ return fn;
87
+ };
88
+ const runtimeExpressions = (compiler) => (src, params, returns) => compile(compiler, src, params, returns);
89
+ export {
90
+ compile,
91
+ functionCompiler,
92
+ rewriteActions,
93
+ runtimeExpressions,
94
+ splitStatements
95
+ };
96
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/kernel/compile.ts"],
4
+ "sourcesContent": ["// Expression compiler. Signals need no rewriting: the body runs inside `with (scope)`, where\n// `$count`, `$user.name` and `$` resolve through the store's scope proxy. Only `@action(` is\n// rewritten, into a call on the per-evaluation actions object.\n\nimport type { ExpressionCompiler } from './contracts.js'\n\nexport type Compiler = (params: string[], body: string) => (...args: any[]) => any\n\n/** Default compiler: `new Function`. Not usable under a strict CSP; see `cspCompiler`. */\nexport const functionCompiler: Compiler = (params, body) => Function(...params, body) as (...args: any[]) => any\n\nconst cache = new Map<string, (...args: any[]) => any>()\n\nconst isIdent = (c: string): boolean => /[A-Za-z0-9_$]/.test(c)\n\n/** Walk source text, skipping string, template and comment contents; `emit` receives code chars. */\nconst scan = (src: string, onCode: (c: string, i: number) => number | void): void => {\n let i = 0\n const n = src.length\n while (i < n) {\n const c = src[i]\n const next = src[i + 1]\n if (c === '\"' || c === \"'\" || c === '`') {\n let j = i + 1\n while (j < n && src[j] !== c) j += src[j] === '\\\\' ? 2 : 1\n onCode(src.slice(i, j + 1), i)\n i = j + 1\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 {\n const skip = onCode(c, i)\n i += skip || 1\n }\n }\n}\n\n/** Replace `@name(` with `__a.name(` outside strings and comments. */\nexport const rewriteActions = (src: string): string => {\n let out = ''\n scan(src, (c, i) => {\n if (c === '@') {\n let j = i + 1\n while (j < src.length && isIdent(src[j])) j++\n let k = j\n while (k < src.length && /\\s/.test(src[k])) k++\n if (j > i + 1 && src[k] === '(') {\n out += `__a.${src.slice(i + 1, j)}(`\n return k + 1 - i\n }\n }\n out += c\n })\n return out\n}\n\n/** Split on top-level semicolons. */\nexport const splitStatements = (src: string): string[] => {\n const parts: string[] = []\n let depth = 0\n let start = 0\n scan(src, (c, i) => {\n if (c.length > 1) return\n if ('([{'.includes(c)) depth++\n else if (')]}'.includes(c)) depth--\n else if (c === ';' && !depth) {\n parts.push(src.slice(start, i))\n start = i + 1\n }\n })\n parts.push(src.slice(start))\n return parts.filter((p) => p.trim())\n}\n\n/**\n * Compile an expression to `(store, actions, ...params) => any`: the body runs inside\n * `with (store.scope)`, so `$name` resolves through the store. With `returns`, the value of the\n * last statement is returned, so `$a = 1; $a * 2` works. Compiled functions are cached by source.\n */\nexport const compile = (\n compiler: Compiler,\n src: string,\n params: string[],\n returns: boolean,\n): ((...args: any[]) => any) => {\n const key = `${+returns}|${params.join()}|${src}`\n const hit = cache.get(key)\n if (hit) return hit\n const code = rewriteActions(src.trim())\n const make = (body: string) => compiler(['$', '__a', ...params], `with($.scope){${body}\\n}`)\n let fn: (...args: any[]) => any\n if (!returns) {\n fn = make(code)\n } else {\n try {\n fn = make(`return(${code}\\n)`)\n } catch {\n const parts = splitStatements(code)\n const last = parts.pop() ?? ''\n try {\n fn = make(`${parts.join(';')};return(${last}\\n)`)\n } catch {\n fn = make(code)\n }\n }\n }\n cache.set(key, fn)\n return fn\n}\n\n/** The default pipeline: compile at runtime inside `with (scope)` using `compiler` (`new Function` or CSP). */\nexport const runtimeExpressions =\n (compiler: Compiler): ExpressionCompiler =>\n (src, params, returns) =>\n compile(compiler, src, params, returns)\n"],
5
+ "mappings": "AASO,MAAM,mBAA6B,CAAC,QAAQ,SAAS,SAAS,GAAG,QAAQ,IAAI;AAEpF,MAAM,QAAQ,oBAAI,IAAqC;AAEvD,MAAM,UAAU,CAAC,MAAuB,gBAAgB,KAAK,CAAC;AAG9D,MAAM,OAAO,CAAC,KAAa,WAA0D;AACnF,MAAI,IAAI;AACR,QAAM,IAAI,IAAI;AACd,SAAO,IAAI,GAAG;AACZ,UAAM,IAAI,IAAI,CAAC;AACf,UAAM,OAAO,IAAI,IAAI,CAAC;AACtB,QAAI,MAAM,OAAO,MAAM,OAAO,MAAM,KAAK;AACvC,UAAI,IAAI,IAAI;AACZ,aAAO,IAAI,KAAK,IAAI,CAAC,MAAM,EAAG,MAAK,IAAI,CAAC,MAAM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9B,cAAQ,IAAI;AAAA,IACd;AAAA,EACF,CAAC;AACD,QAAM,KAAK,IAAI,MAAM,KAAK,CAAC;AAC3B,SAAO,MAAM,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;AACrC;AAOO,MAAM,UAAU,CACrB,UACA,KACA,QACA,YAC8B;AAC9B,QAAM,MAAM,GAAG,CAAC,OAAO,IAAI,OAAO,KAAK,CAAC,IAAI,GAAG;AAC/C,QAAM,MAAM,MAAM,IAAI,GAAG;AACzB,MAAI,IAAK,QAAO;AAChB,QAAM,OAAO,eAAe,IAAI,KAAK,CAAC;AACtC,QAAM,OAAO,CAAC,SAAiB,SAAS,CAAC,KAAK,OAAO,GAAG,MAAM,GAAG,iBAAiB,IAAI;AAAA,EAAK;AAC3F,MAAI;AACJ,MAAI,CAAC,SAAS;AACZ,SAAK,KAAK,IAAI;AAAA,EAChB,OAAO;AACL,QAAI;AACF,WAAK,KAAK,UAAU,IAAI;AAAA,EAAK;AAAA,IAC/B,QAAQ;AACN,YAAM,QAAQ,gBAAgB,IAAI;AAClC,YAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAI;AACF,aAAK,KAAK,GAAG,MAAM,KAAK,GAAG,CAAC,WAAW,IAAI;AAAA,EAAK;AAAA,MAClD,QAAQ;AACN,aAAK,KAAK,IAAI;AAAA,MAChB;AAAA,IACF;AAAA,EACF;AACA,QAAM,IAAI,KAAK,EAAE;AACjB,SAAO;AACT;AAGO,MAAM,qBACX,CAAC,aACD,CAAC,KAAK,QAAQ,YACZ,QAAQ,UAAU,KAAK,QAAQ,OAAO;",
6
+ "names": []
7
+ }
@@ -0,0 +1,121 @@
1
+ import type { Compiler } from './compile.js';
2
+ import type { Store } from './state.js';
3
+ import type { CaseStyle } from '../lib/casing.js';
4
+ export type El = HTMLElement | SVGElement | MathMLElement;
5
+ export type Mods = Map<string, string[]>;
6
+ /** A compiled attribute expression. `store` is the instance store; `actions` resolves `@name(...)`. */
7
+ export type Evaluator = (store: Store, actions: any, el: El, evt: Event | undefined, ...args: any[]) => any;
8
+ /** Turns expression source into an evaluator. The runtime compiler and the precompiled table both implement this. */
9
+ export type ExpressionCompiler = (src: string, params: string[], returns: boolean) => Evaluator;
10
+ export interface Runtime {
11
+ /** Attribute prefixes being scanned; the first is primary. */
12
+ readonly prefixes: readonly string[];
13
+ /** Full attribute name under the primary prefix: attr('on') → 'data-on'. */
14
+ attr(name: string): string;
15
+ readonly store: Store;
16
+ /** The low-level function compiler (`new Function` or the CSP compiler), for plugins that build code. */
17
+ readonly compiler: Compiler;
18
+ /** Dispatch a `sigmx-<type>` CustomEvent on `document`. */
19
+ emit(type: string, detail?: unknown): void;
20
+ /** Call a registered action by name. */
21
+ call(name: string, ctx: ActionCtx, args: any[]): any;
22
+ /** Event-name prefixes accepted from servers; the first is what sigmx itself uses. */
23
+ readonly eventPrefixes: readonly string[];
24
+ /** Route a named server event (with any accepted prefix) to its handler. Returns false if none. */
25
+ handle(event: string, data: Record<string, string>): boolean;
26
+ readonly attributes: Record<string, AttributePlugin>;
27
+ readonly actions: Record<string, ActionPlugin>;
28
+ readonly handlers: Record<string, HandlerPlugin>;
29
+ }
30
+ export interface Ctx {
31
+ el: El;
32
+ /** Plugin name, e.g. 'on'. */
33
+ plugin: string;
34
+ /** Full attribute name as written, e.g. 'data-on:click__debounce.300ms'. */
35
+ attr: string;
36
+ /** The `:key` part, if any. */
37
+ key: string | undefined;
38
+ /** Attribute value (the expression source). */
39
+ value: string;
40
+ mods: Mods;
41
+ /** The key recased per `__case.<style>`, defaulting to `style`. */
42
+ cased(style?: CaseStyle): string;
43
+ /** Evaluate the attribute expression. `evt` and any `args` are exposed to it by name. */
44
+ evaluate(evt?: Event, ...args: any[]): any;
45
+ /** Reactive effect disposed with the attribute. Errors are reported, not thrown. */
46
+ effect(fn: () => void): void;
47
+ /** addEventListener with automatic removal on cleanup. */
48
+ listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void;
49
+ cleanup(fn: () => void): void;
50
+ error(message: string, extra?: Record<string, unknown>): Error;
51
+ store: Store;
52
+ runtime: Runtime;
53
+ }
54
+ export interface ActionCtx {
55
+ el: El;
56
+ evt?: Event;
57
+ store: Store;
58
+ runtime: Runtime;
59
+ error(message: string, extra?: Record<string, unknown>): Error;
60
+ /** Run when the attribute that invoked the action is torn down. */
61
+ cleanup(fn: () => void): void;
62
+ }
63
+ export interface AttributePlugin {
64
+ type: 'attribute';
65
+ name: string;
66
+ key?: 'required' | 'forbidden';
67
+ value?: 'required' | 'forbidden';
68
+ /** Whether the expression yields a value (default) or is a statement body. */
69
+ returns?: boolean;
70
+ /** Extra parameter names the expression can reference, in the order passed to `evaluate`. */
71
+ args?: string[];
72
+ mount(ctx: Ctx): void | (() => void);
73
+ }
74
+ export interface ActionPlugin {
75
+ type: 'action';
76
+ name: string;
77
+ call(ctx: ActionCtx, ...args: any[]): any;
78
+ }
79
+ /** Handles a named server event (for example a streamed patch). */
80
+ export interface HandlerPlugin {
81
+ type: 'handler';
82
+ name: string;
83
+ handle(runtime: Runtime, data: Record<string, string>): void;
84
+ }
85
+ export type Plugin = AttributePlugin | ActionPlugin | HandlerPlugin;
86
+ export interface RuntimeOptions {
87
+ plugins?: Plugin[];
88
+ /** How attribute expressions become functions: `runtimeExpressions(compiler)` or `precompiled(table)`. */
89
+ expressions: ExpressionCompiler;
90
+ /** Low-level function compiler exposed to plugins (default `new Function`). */
91
+ compile?: Compiler;
92
+ /** Attribute prefix or prefixes to scan. Default 'data-'. */
93
+ prefix?: string | string[];
94
+ /** Server event-name prefixes to accept, add a second prefix while migrating from another library. Default 'sigmx-'. */
95
+ eventPrefix?: string | string[];
96
+ /** Share a store between instances. */
97
+ store?: Store;
98
+ /** Called for any plugin or expression error. Default: console.error. */
99
+ onError?: (error: unknown, info: {
100
+ plugin?: string;
101
+ el?: Element;
102
+ attr?: string;
103
+ }) => void;
104
+ /** Scan `document.documentElement` on creation (after DOM ready). Default true. */
105
+ autoStart?: boolean;
106
+ }
107
+ /** `createSigmx` options: `expressions` is optional and defaults to the runtime compiler. */
108
+ export interface SigmxOptions extends Omit<RuntimeOptions, 'expressions'> {
109
+ expressions?: ExpressionCompiler;
110
+ }
111
+ export interface Sigmx {
112
+ runtime: Runtime;
113
+ store: Store;
114
+ /** Root namespace proxy for use from JavaScript: `sigmx.$.count++`. */
115
+ $: any;
116
+ /** Mount plugins under `root` and observe it for changes. */
117
+ apply(root?: El | ShadowRoot, observe?: boolean): void;
118
+ /** Register more plugins; attribute plugins are applied to observed roots immediately. */
119
+ use(...plugins: Plugin[]): void;
120
+ destroy(): void;
121
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,20 @@
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';
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';
9
+ 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';
14
+ import type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js';
15
+ /** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */
16
+ export declare const createSigmx: (options?: SigmxOptions) => Sigmx;
17
+ /** Type a plugin definition. Pure: registration is `createSigmx({ plugins })` or `sigmx.use()`. */
18
+ export declare const attribute: (p: Omit<AttributePlugin, "type">) => AttributePlugin;
19
+ export declare const action: (p: Omit<ActionPlugin, "type">) => ActionPlugin;
20
+ export declare const handler: (p: Omit<HandlerPlugin, "type">) => HandlerPlugin;
@@ -0,0 +1,54 @@
1
+ import { createRuntime, parseAttr } from "./runtime.js";
2
+ import { compile, functionCompiler, rewriteActions, runtimeExpressions, splitStatements } from "./compile.js";
3
+ import { expressionKey, precompiled } from "./precompiled.js";
4
+ import { Computed, Signal, batch, computed, effect, flush, onSettled, signal, untracked } from "./reactive.js";
5
+ 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
+ import { functionCompiler as functionCompiler2, runtimeExpressions as runtimeExpressions2 } from "./compile.js";
11
+ const createSigmx = (options = {}) => createRuntime2({ ...options, expressions: options.expressions ?? runtimeExpressions2(options.compile ?? functionCompiler2) });
12
+ const attribute = (p) => ({ type: "attribute", ...p });
13
+ const action = (p) => ({ type: "action", ...p });
14
+ const handler = (p) => ({ type: "handler", ...p });
15
+ export {
16
+ Computed,
17
+ Signal,
18
+ action,
19
+ attribute,
20
+ batch,
21
+ camel,
22
+ compile,
23
+ computed,
24
+ createRuntime,
25
+ createSigmx,
26
+ createStore,
27
+ debounce,
28
+ delay,
29
+ effect,
30
+ expand,
31
+ expressionKey,
32
+ flush,
33
+ functionCompiler,
34
+ handler,
35
+ isPlain,
36
+ kebab,
37
+ onSettled,
38
+ parseAttr,
39
+ pascal,
40
+ precompiled,
41
+ recase,
42
+ rewriteActions,
43
+ runtimeExpressions,
44
+ signal,
45
+ snake,
46
+ splitStatements,
47
+ throttle,
48
+ toMs,
49
+ toPredicate,
50
+ untracked,
51
+ withTiming,
52
+ withViewTransition
53
+ };
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"]
7
+ }
@@ -0,0 +1,25 @@
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
+ export type Extracted = {
10
+ src: string;
11
+ params: string[];
12
+ returns: boolean;
13
+ };
14
+ /** JavaScript source for a module exporting `table`, from a list of extracted expressions. */
15
+ export declare const generateTable: (items: Extracted[]) => string;
16
+ export type PluginMeta = {
17
+ name: string;
18
+ returns?: boolean;
19
+ args?: string[];
20
+ };
21
+ /**
22
+ * 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.
24
+ */
25
+ export declare const extractExpressions: (source: string, plugins: PluginMeta[], prefixes?: string[]) => Extracted[];
@@ -0,0 +1,111 @@
1
+ import { rewriteActions, splitStatements } from "./compile.js";
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
+ const generateTable = (items) => {
68
+ const seen = /* @__PURE__ */ new Set();
69
+ const lines = [];
70
+ for (const { src, params, returns } of items) {
71
+ const key = expressionKey(src, params, returns);
72
+ if (seen.has(key)) continue;
73
+ seen.add(key);
74
+ let body;
75
+ try {
76
+ body = compileBody(src, returns);
77
+ Function("$", "__a", ...params, body);
78
+ } catch {
79
+ continue;
80
+ }
81
+ lines.push(` ${JSON.stringify(key)}: function($, __a, ${params.join(", ")}) { ${body} },`);
82
+ }
83
+ return `export const table = {
84
+ ${lines.join("\n")}
85
+ }
86
+ `;
87
+ };
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]);
90
+ const extractExpressions = (source, plugins, prefixes = ["data-"]) => {
91
+ const byName = new Map(plugins.map((p) => [p.name, p]));
92
+ const out = [];
93
+ const re = /([a-z][\w-]*(?::[^\s="'<>]+)?(?:__[^\s="'<>]+)*)=(?:"([^"]*)"|'([^']*)')/g;
94
+ for (const m of source.matchAll(re)) {
95
+ const attr = m[1];
96
+ const value = decode(m[2] ?? m[3] ?? "");
97
+ const prefix = prefixes.find((p) => attr.startsWith(p));
98
+ 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 });
102
+ }
103
+ return out;
104
+ };
105
+ export {
106
+ compileBody,
107
+ extractExpressions,
108
+ generateTable,
109
+ rewriteSignals
110
+ };
111
+ //# sourceMappingURL=precompile.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 ?? [])], retur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ExpressionCompiler } from './contracts.js';
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
+ /**
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
8
+ * `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime
9
+ * compiler is not bundled at all.
10
+ */
11
+ export declare const precompiled: (table: ExpressionTable, fallback?: ExpressionCompiler, onMiss?: (src: string) => void) => ExpressionCompiler;
@@ -0,0 +1,13 @@
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));
5
+ onMiss?.(src);
6
+ if (!fallback) throw new Error(`expression not precompiled: ${src}`);
7
+ return fallback(src, params, returns);
8
+ };
9
+ export {
10
+ expressionKey,
11
+ precompiled
12
+ };
13
+ //# sourceMappingURL=precompiled.js.map