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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/kernel/scan.ts"],
4
+ "sourcesContent": ["// Auto mode: work out which plugins a codebase uses by scanning its source, the way a CSS\n// framework scans templates for class names. Node only; never bundled for the browser.\nimport * as builtins from '../plugins/index.js'\nimport type { Plugin } from './contracts.js'\n\nexport type PluginMeta = {\n /** Export name, e.g. `httpGet`; what the generated module imports. */\n export: string\n /** Registered name, e.g. `get`; what markup refers to. */\n name: string\n type: Plugin['type']\n /** Module to import from; built-ins come from `sigmx/plugins`. */\n from: string\n returns?: boolean\n args?: string[]\n}\n\nconst NETWORK = ['httpGet', 'httpPost', 'httpPut', 'httpPatch', 'httpDelete', 'websocket', 'boost']\n\n/** Plugins that only make sense together. */\nexport const implied: Record<string, string[]> = {\n ...Object.fromEntries(NETWORK.map((n) => [n, ['applyElements', 'applyState']])),\n boost: ['httpGet', 'httpPost', 'applyElements', 'applyState'],\n}\n\n/** Metadata for every built-in plugin. */\nexport const builtinPlugins = (): PluginMeta[] =>\n Object.entries(builtins)\n .filter(([, v]) => v && typeof v === 'object' && 'type' in (v as object))\n .map(([key, v]) => {\n const p = v as Plugin\n return { export: key, name: p.name, type: p.type, from: 'sigmx/plugins', returns: (p as any).returns, args: (p as any).args }\n })\n\n/**\n * Read a custom plugin's metadata from its source without executing it: finds\n * `attribute({ name: 'x', ... })`, `action({...})` or `handler({...})` near `export const <exportName>`.\n */\nexport const customPluginMeta = (exportName: string, source: string, from: string): PluginMeta | undefined => {\n const re = new RegExp(`export\\\\s+const\\\\s+${exportName}\\\\s*(?::[^=]+)?=\\\\s*(attribute|action|handler)\\\\s*\\\\(\\\\s*\\\\{([\\\\s\\\\S]*?)\\\\}\\\\s*\\\\)`, 'm')\n const m = re.exec(source)\n if (!m) return\n const body = m[2]\n const name = /\\bname\\s*:\\s*['\"`]([^'\"`]+)['\"`]/.exec(body)?.[1]\n if (!name) return\n const returns = /\\breturns\\s*:\\s*(true|false)/.exec(body)?.[1]\n const args = /\\bargs\\s*:\\s*\\[([^\\]]*)\\]/.exec(body)?.[1]\n return {\n export: exportName,\n name,\n type: m[1] as Plugin['type'],\n from,\n returns: returns === undefined ? undefined : returns === 'true',\n args: args?.split(',').map((s) => s.trim().replace(/^['\"`]|['\"`]$/g, '')).filter(Boolean),\n }\n}\n\nconst escape = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/** True if `source` refers to the plugin: `data-<name>` for directives, `@name(` for functions, the name as a string for handlers. */\nexport const mentions = (source: string, p: PluginMeta, prefixes: string[]): boolean => {\n const n = escape(p.name)\n if (p.type === 'attribute') return prefixes.some((pre) => new RegExp(`(^|[\\\\s\"'\\`<])${escape(pre)}${n}(?=[\\\\s=:_>\"'\\`/]|$)`, 'm').test(source))\n if (p.type === 'action') return new RegExp(`@${n}\\\\s*\\\\(`).test(source)\n return new RegExp(`['\"\\`](?:[\\\\w-]+-)?${n}['\"\\`]`).test(source)\n}\n\nexport type Selection = {\n /** Selected plugins in a stable order. */\n plugins: PluginMeta[]\n /** Why each one is in: 'used', 'always', or the plugin that implied it. */\n reasons: Record<string, string>\n /** Known plugins that were left out. */\n unused: string[]\n}\n\n/**\n * Decide which plugins to ship. `sources` are file contents; `custom` are extra plugins (from\n * `customPluginMeta`); `always` are export names that ship regardless.\n */\nexport const selectPlugins = (\n sources: string[],\n { prefixes = ['data-'], always = [], custom = [] }: { prefixes?: string[]; always?: string[]; custom?: PluginMeta[] } = {},\n): Selection => {\n const known = [...builtinPlugins(), ...custom]\n const byExport = new Map(known.map((p) => [p.export, p]))\n const reasons: Record<string, string> = {}\n const add = (exp: string, why: string) => {\n if (!byExport.has(exp) || reasons[exp]) return\n reasons[exp] = why\n for (const dep of implied[exp] ?? []) add(dep, exp)\n }\n for (const exp of always) add(exp, 'always')\n const text = sources.join('\\n')\n for (const p of known) if (!reasons[p.export] && (p.type !== 'handler' || custom.includes(p)) && mentions(text, p, prefixes)) add(p.export, 'used')\n const plugins = known.filter((p) => reasons[p.export])\n return { plugins, reasons, unused: known.filter((p) => !reasons[p.export]).map((p) => p.export) }\n}\n\n/** JavaScript source for a module exporting `plugins` (and the selection report). */\nexport const generatePluginsModule = (sel: Selection): string => {\n const groups = new Map<string, string[]>()\n for (const p of sel.plugins) groups.set(p.from, [...(groups.get(p.from) ?? []), p.export])\n const imports = [...groups].map(([from, names]) => `import { ${names.join(', ')} } from ${JSON.stringify(from)}`).join('\\n')\n return `${imports}\\nexport const plugins = [${sel.plugins.map((p) => p.export).join(', ')}]\\nexport const report = ${JSON.stringify({ reasons: sel.reasons, unused: sel.unused }, null, 2)}\\n`\n}\n"],
5
+ "mappings": "AAEA,YAAY,cAAc;AAe1B,MAAM,UAAU,CAAC,WAAW,YAAY,WAAW,aAAa,cAAc,aAAa,OAAO;AAG3F,MAAM,UAAoC;AAAA,EAC/C,GAAG,OAAO,YAAY,QAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,YAAY,CAAC,CAAC,CAAC;AAAA,EAC9E,OAAO,CAAC,WAAW,YAAY,iBAAiB,YAAY;AAC9D;AAGO,MAAM,iBAAiB,MAC5B,OAAO,QAAQ,QAAQ,EACpB,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,KAAK,OAAO,MAAM,YAAY,UAAW,CAAY,EACvE,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM;AACjB,QAAM,IAAI;AACV,SAAO,EAAE,QAAQ,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,iBAAiB,SAAU,EAAU,SAAS,MAAO,EAAU,KAAK;AAC9H,CAAC;AAME,MAAM,mBAAmB,CAAC,YAAoB,QAAgB,SAAyC;AAC5G,QAAM,KAAK,IAAI,OAAO,sBAAsB,UAAU,sFAAsF,GAAG;AAC/I,QAAM,IAAI,GAAG,KAAK,MAAM;AACxB,MAAI,CAAC,EAAG;AACR,QAAM,OAAO,EAAE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active.js';
2
+ import { type Filter } from '../lib/objects.js';
3
+ export type Patch = Record<string, any>;
4
+ export interface Store {
5
+ /** Value at a dotted path: a leaf value, a namespace proxy, or undefined. Reads subscribe. */
6
+ get(path: string): any;
7
+ /** Replace the value at a path. Plain objects become namespaces; null/undefined removes. */
8
+ set(path: string, value: any): void;
9
+ /** JSON merge-patch (RFC 7396): objects merge, null removes, everything else replaces. */
10
+ merge(patch: Patch, options?: {
11
+ at?: string;
12
+ ifMissing?: boolean;
13
+ }): void;
14
+ remove(path: string): void;
15
+ has(path: string): boolean;
16
+ /** Install a computed (or any signal) as the leaf at a path. */
17
+ define(path: string, node: Signal<any>): void;
18
+ /** Leaf paths, optionally filtered. */
19
+ paths(filter?: Filter): string[];
20
+ /** Plain-object copy of the store or a namespace. */
21
+ snapshot(filter?: Filter, options?: {
22
+ at?: string;
23
+ computed?: boolean;
24
+ }): Patch;
25
+ /** Called after each settled batch with the nested object of changed paths (null = removed). */
26
+ onPatch(fn: (patch: Patch) => void): () => void;
27
+ /** Root namespace proxy: `$.count`, `$.user.name = 'x'`, `JSON.stringify($)`. */
28
+ readonly $: any;
29
+ /** Identifier scope for compiled expressions: resolves `$count`, `$user`, and `$`. */
30
+ readonly scope: object;
31
+ }
32
+ export declare const createStore: () => Store;
@@ -0,0 +1,186 @@
1
+ import { Computed, Signal, batch, onSettled } from "./reactive.js";
2
+ import { expand, isPlain, toPredicate } from "../lib/objects.js";
3
+ const parentOf = (p) => p.slice(0, Math.max(0, p.lastIndexOf(".")));
4
+ const nameOf = (p) => p.slice(p.lastIndexOf(".") + 1);
5
+ const join = (a, b) => a ? `${a}.${b}` : b;
6
+ const under = (p, at) => !at || p === at || p.startsWith(`${at}.`);
7
+ const str = (k) => typeof k === "string";
8
+ const createStore = () => {
9
+ const leaves = /* @__PURE__ */ new Map();
10
+ const kids = /* @__PURE__ */ new Map([["", /* @__PURE__ */ new Set()]]);
11
+ const shape = new Signal(0);
12
+ const pending = /* @__PURE__ */ new Map();
13
+ const listeners = /* @__PURE__ */ new Set();
14
+ const nsCache = /* @__PURE__ */ new Map();
15
+ const arrCache = /* @__PURE__ */ new WeakMap();
16
+ const ensureNs = (p) => {
17
+ let set2 = kids.get(p);
18
+ if (!set2) {
19
+ if (leaves.has(p)) dropLeaf(p);
20
+ kids.set(p, set2 = /* @__PURE__ */ new Set());
21
+ ensureNs(parentOf(p)).add(nameOf(p));
22
+ shape.bump();
23
+ }
24
+ return set2;
25
+ };
26
+ const dropLeaf = (p) => {
27
+ const s = leaves.get(p);
28
+ if (!s) return;
29
+ leaves.delete(p);
30
+ kids.get(parentOf(p))?.delete(nameOf(p));
31
+ pending.set(p, null);
32
+ s.bump();
33
+ shape.bump();
34
+ };
35
+ const dropNs = (p) => {
36
+ const set2 = kids.get(p);
37
+ if (!set2) return;
38
+ for (const k of [...set2]) remove(join(p, k));
39
+ if (p) {
40
+ kids.delete(p);
41
+ kids.get(parentOf(p))?.delete(nameOf(p));
42
+ nsCache.delete(p);
43
+ }
44
+ shape.bump();
45
+ };
46
+ const remove = (p) => batch(() => {
47
+ dropLeaf(p);
48
+ dropNs(p);
49
+ });
50
+ const define = (p, node) => batch(() => {
51
+ if (kids.has(p)) dropNs(p);
52
+ const old = leaves.get(p);
53
+ leaves.set(p, node);
54
+ ensureNs(parentOf(p)).add(nameOf(p));
55
+ old?.bump();
56
+ shape.bump();
57
+ });
58
+ const set = (p, v) => batch(() => {
59
+ if (v == null) return remove(p);
60
+ if (isPlain(v)) {
61
+ const names = ensureNs(p);
62
+ for (const k of [...names]) if (!(k in v)) remove(join(p, k));
63
+ for (const k in v) set(join(p, k), v[k]);
64
+ return;
65
+ }
66
+ if (kids.has(p)) dropNs(p);
67
+ const s = leaves.get(p);
68
+ if (s instanceof Computed) throw new Error(`"${p}" is a computed signal and cannot be assigned`);
69
+ if (s) {
70
+ if (Object.is(s.peek(), v)) return;
71
+ s.value = v;
72
+ } else {
73
+ define(p, new Signal(v));
74
+ }
75
+ pending.set(p, v);
76
+ });
77
+ const merge = (patch, { at = "", ifMissing = false } = {}) => batch(() => {
78
+ if (!isPlain(patch)) return;
79
+ ensureNs(at);
80
+ for (const k in patch) {
81
+ const p = join(at, k);
82
+ const v = patch[k];
83
+ if (v === null) {
84
+ if (!ifMissing) remove(p);
85
+ } else if (isPlain(v)) {
86
+ merge(v, { at: p, ifMissing });
87
+ } else if (!(ifMissing && (leaves.has(p) || kids.has(p))) && !(leaves.get(p) instanceof Computed)) {
88
+ set(p, v);
89
+ }
90
+ }
91
+ });
92
+ const wrapArray = (raw, s, p) => {
93
+ let px = arrCache.get(raw);
94
+ if (!px) {
95
+ const touch = () => {
96
+ pending.set(p, raw);
97
+ s.bump();
98
+ };
99
+ px = new Proxy(raw, {
100
+ set: (t, k, v) => (t[k] = v, touch(), true),
101
+ deleteProperty: (t, k) => (delete t[k], touch(), true)
102
+ });
103
+ arrCache.set(raw, px);
104
+ }
105
+ return px;
106
+ };
107
+ const get = (p) => {
108
+ const s = leaves.get(p);
109
+ if (s) {
110
+ const v = s.value;
111
+ return Array.isArray(v) ? wrapArray(v, s, p) : v;
112
+ }
113
+ if (kids.has(p)) return ns(p);
114
+ shape.value;
115
+ return void 0;
116
+ };
117
+ const ns = (p) => {
118
+ let px = nsCache.get(p);
119
+ if (!px) {
120
+ const names = () => (shape.value, kids.get(p));
121
+ px = new Proxy({}, {
122
+ get: (_, k) => !str(k) ? void 0 : k === "toJSON" ? () => snapshot(void 0, { at: p }) : get(join(p, k)),
123
+ set: (_, k, v) => (str(k) && set(join(p, k), v), true),
124
+ deleteProperty: (_, k) => (str(k) && remove(join(p, k)), true),
125
+ has: (_, k) => str(k) && !!names()?.has(k),
126
+ ownKeys: () => [...names() ?? []],
127
+ getOwnPropertyDescriptor: (_, k) => str(k) && names()?.has(k) ? { enumerable: true, configurable: true, writable: true, value: get(join(p, k)) } : void 0
128
+ });
129
+ nsCache.set(p, px);
130
+ }
131
+ return px;
132
+ };
133
+ const scope = new Proxy({}, {
134
+ has: (_, k) => str(k) && k[0] === "$",
135
+ get: (_, k) => !str(k) ? void 0 : k === "$" ? ns("") : get(k.slice(1)),
136
+ set: (_, k, v) => {
137
+ if (str(k)) k === "$" ? merge(v) : set(k.slice(1), v);
138
+ return true;
139
+ }
140
+ });
141
+ const paths = (filter) => {
142
+ shape.value;
143
+ const ok = toPredicate(filter);
144
+ return [...leaves.keys()].filter(ok);
145
+ };
146
+ const snapshot = (filter, { at = "", computed = true } = {}) => {
147
+ shape.value;
148
+ const ok = toPredicate(filter);
149
+ const out = {};
150
+ const rel = (p) => at ? p.slice(at.length + 1) : p;
151
+ for (const [p, s] of leaves) {
152
+ if (!under(p, at) || !ok(p) || !computed && s instanceof Computed) continue;
153
+ expand(out, rel(p), s.value);
154
+ }
155
+ for (const p of kids.keys()) {
156
+ if (p && p !== at && under(p, at) && ok(p) && !kids.get(p).size) expand(out, rel(p), {});
157
+ }
158
+ return out;
159
+ };
160
+ onSettled(() => {
161
+ if (!pending.size) return;
162
+ const patch = {};
163
+ for (const [p, v] of pending) expand(patch, p, v);
164
+ pending.clear();
165
+ for (const fn of listeners) fn(patch);
166
+ });
167
+ return {
168
+ get,
169
+ set,
170
+ merge,
171
+ remove,
172
+ has: (p) => leaves.has(p) || kids.has(p),
173
+ define,
174
+ paths,
175
+ snapshot,
176
+ onPatch: (fn) => (listeners.add(fn), () => listeners.delete(fn)),
177
+ get $() {
178
+ return ns("");
179
+ },
180
+ scope
181
+ };
182
+ };
183
+ export {
184
+ createStore
185
+ };
186
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/kernel/state.ts"],
4
+ "sourcesContent": ["// Path-keyed signal store with JSON merge-patch semantics. No DOM dependency.\nimport { Computed, Signal, batch, onSettled } from './reactive.js'\nimport { expand, isPlain, toPredicate, type Filter } from '../lib/objects.js'\n\nexport type Patch = Record<string, any>\n\nexport interface Store {\n /** Value at a dotted path: a leaf value, a namespace proxy, or undefined. Reads subscribe. */\n get(path: string): any\n /** Replace the value at a path. Plain objects become namespaces; null/undefined removes. */\n set(path: string, value: any): void\n /** JSON merge-patch (RFC 7396): objects merge, null removes, everything else replaces. */\n merge(patch: Patch, options?: { at?: string; ifMissing?: boolean }): void\n remove(path: string): void\n has(path: string): boolean\n /** Install a computed (or any signal) as the leaf at a path. */\n define(path: string, node: Signal<any>): void\n /** Leaf paths, optionally filtered. */\n paths(filter?: Filter): string[]\n /** Plain-object copy of the store or a namespace. */\n snapshot(filter?: Filter, options?: { at?: string; computed?: boolean }): Patch\n /** Called after each settled batch with the nested object of changed paths (null = removed). */\n onPatch(fn: (patch: Patch) => void): () => void\n /** Root namespace proxy: `$.count`, `$.user.name = 'x'`, `JSON.stringify($)`. */\n readonly $: any\n /** Identifier scope for compiled expressions: resolves `$count`, `$user`, and `$`. */\n readonly scope: object\n}\n\nconst parentOf = (p: string): string => p.slice(0, Math.max(0, p.lastIndexOf('.')))\nconst nameOf = (p: string): string => p.slice(p.lastIndexOf('.') + 1)\nconst join = (a: string, b: string): string => (a ? `${a}.${b}` : b)\nconst under = (p: string, at: string): boolean => !at || p === at || p.startsWith(`${at}.`)\nconst str = (k: unknown): k is string => typeof k === 'string'\n\nexport const createStore = (): Store => {\n const leaves = new Map<string, Signal<any>>()\n const kids = new Map<string, Set<string>>([['', new Set()]])\n const shape = new Signal(0) // bumped on any structural change; enumerations subscribe to it\n const pending = new Map<string, any>()\n const listeners = new Set<(p: Patch) => void>()\n const nsCache = new Map<string, any>()\n const arrCache = new WeakMap<object, any>()\n\n const ensureNs = (p: string): Set<string> => {\n let set = kids.get(p)\n if (!set) {\n if (leaves.has(p)) dropLeaf(p)\n kids.set(p, (set = new Set()))\n ensureNs(parentOf(p)).add(nameOf(p))\n shape.bump()\n }\n return set\n }\n\n const dropLeaf = (p: string): void => {\n const s = leaves.get(p)\n if (!s) return\n leaves.delete(p)\n kids.get(parentOf(p))?.delete(nameOf(p))\n pending.set(p, null)\n s.bump()\n shape.bump()\n }\n\n const dropNs = (p: string): void => {\n const set = kids.get(p)\n if (!set) return\n for (const k of [...set]) remove(join(p, k))\n if (p) {\n kids.delete(p)\n kids.get(parentOf(p))?.delete(nameOf(p))\n nsCache.delete(p)\n }\n shape.bump()\n }\n\n const remove = (p: string): void =>\n batch(() => {\n dropLeaf(p)\n dropNs(p)\n })\n\n const define = (p: string, node: Signal<any>): void =>\n batch(() => {\n if (kids.has(p)) dropNs(p)\n const old = leaves.get(p)\n leaves.set(p, node)\n ensureNs(parentOf(p)).add(nameOf(p))\n old?.bump()\n shape.bump()\n })\n\n const set = (p: string, v: any): void =>\n batch(() => {\n if (v == null) return remove(p)\n if (isPlain(v)) {\n const names = ensureNs(p)\n for (const k of [...names]) if (!(k in v)) remove(join(p, k))\n for (const k in v) set(join(p, k), v[k])\n return\n }\n if (kids.has(p)) dropNs(p)\n const s = leaves.get(p)\n if (s instanceof Computed) throw new Error(`\"${p}\" is a computed signal and cannot be assigned`)\n if (s) {\n if (Object.is(s.peek(), v)) return\n s.value = v\n } else {\n define(p, new Signal(v))\n }\n pending.set(p, v)\n })\n\n const merge = (patch: Patch, { at = '', ifMissing = false } = {}): void =>\n batch(() => {\n if (!isPlain(patch)) return\n ensureNs(at)\n for (const k in patch) {\n const p = join(at, k)\n const v = patch[k]\n if (v === null) {\n if (!ifMissing) remove(p)\n } else if (isPlain(v)) {\n merge(v, { at: p, ifMissing })\n } else if (!(ifMissing && (leaves.has(p) || kids.has(p))) && !(leaves.get(p) instanceof Computed)) {\n set(p, v) // computed leaves are skipped: patches from storage or a server cannot overwrite them\n }\n }\n })\n\n /** Arrays are returned through a proxy so in-place mutation notifies the leaf. */\n const wrapArray = (raw: any[], s: Signal<any>, p: string): any => {\n let px = arrCache.get(raw)\n if (!px) {\n const touch = () => {\n pending.set(p, raw)\n s.bump()\n }\n px = new Proxy(raw, {\n set: (t, k, v) => ((t as any)[k] = v, touch(), true),\n deleteProperty: (t, k) => (delete (t as any)[k], touch(), true),\n })\n arrCache.set(raw, px)\n }\n return px\n }\n\n const get = (p: string): any => {\n const s = leaves.get(p)\n if (s) {\n const v = s.value\n return Array.isArray(v) ? wrapArray(v, s, p) : v\n }\n if (kids.has(p)) return ns(p)\n shape.value // subscribe, so creating this path later re-runs the reader\n return undefined\n }\n\n const ns = (p: string): any => {\n let px = nsCache.get(p)\n if (!px) {\n const names = () => (shape.value, kids.get(p))\n px = new Proxy({}, {\n get: (_, k) => (!str(k) ? undefined : k === 'toJSON' ? () => snapshot(undefined, { at: p }) : get(join(p, k))),\n set: (_, k, v) => (str(k) && set(join(p, k), v), true),\n deleteProperty: (_, k) => (str(k) && remove(join(p, k)), true),\n has: (_, k) => str(k) && !!names()?.has(k),\n ownKeys: () => [...(names() ?? [])],\n getOwnPropertyDescriptor: (_, k) =>\n str(k) && names()?.has(k)\n ? { enumerable: true, configurable: true, writable: true, value: get(join(p, k)) }\n : undefined,\n })\n nsCache.set(p, px)\n }\n return px\n }\n\n const scope = new Proxy({}, {\n has: (_, k) => str(k) && k[0] === '$',\n get: (_, k) => (!str(k) ? undefined : k === '$' ? ns('') : get(k.slice(1))),\n set: (_, k, v) => {\n if (str(k)) k === '$' ? merge(v) : set(k.slice(1), v)\n return true\n },\n })\n\n const paths = (filter?: Filter): string[] => {\n shape.value\n const ok = toPredicate(filter)\n return [...leaves.keys()].filter(ok)\n }\n\n const snapshot = (filter?: Filter, { at = '', computed = true } = {}): Patch => {\n shape.value\n const ok = toPredicate(filter)\n const out: Patch = {}\n const rel = (p: string) => (at ? p.slice(at.length + 1) : p)\n for (const [p, s] of leaves) {\n if (!under(p, at) || !ok(p) || (!computed && s instanceof Computed)) continue\n expand(out, rel(p), s.value)\n }\n // Empty namespaces still appear as `{}`.\n for (const p of kids.keys()) {\n if (p && p !== at && under(p, at) && ok(p) && !kids.get(p)!.size) expand(out, rel(p), {})\n }\n return out\n }\n\n onSettled(() => {\n if (!pending.size) return\n const patch: Patch = {}\n for (const [p, v] of pending) expand(patch, p, v)\n pending.clear()\n for (const fn of listeners) fn(patch)\n })\n\n return {\n get,\n set,\n merge,\n remove,\n has: (p) => leaves.has(p) || kids.has(p),\n define,\n paths,\n snapshot,\n onPatch: (fn) => (listeners.add(fn), () => listeners.delete(fn)),\n get $() {\n return ns('')\n },\n scope,\n }\n}\n"],
5
+ "mappings": "AACA,SAAS,UAAU,QAAQ,OAAO,iBAAiB;AACnD,SAAS,QAAQ,SAAS,mBAAgC;AA2B1D,MAAM,WAAW,CAAC,MAAsB,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG,EAAE,YAAY,GAAG,CAAC,CAAC;AAClF,MAAM,SAAS,CAAC,MAAsB,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;AACpE,MAAM,OAAO,CAAC,GAAW,MAAuB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK;AAClE,MAAM,QAAQ,CAAC,GAAW,OAAwB,CAAC,MAAM,MAAM,MAAM,EAAE,WAAW,GAAG,EAAE,GAAG;AAC1F,MAAM,MAAM,CAAC,MAA4B,OAAO,MAAM;AAE/C,MAAM,cAAc,MAAa;AACtC,QAAM,SAAS,oBAAI,IAAyB;AAC5C,QAAM,OAAO,oBAAI,IAAyB,CAAC,CAAC,IAAI,oBAAI,IAAI,CAAC,CAAC,CAAC;AAC3D,QAAM,QAAQ,IAAI,OAAO,CAAC;AAC1B,QAAM,UAAU,oBAAI,IAAiB;AACrC,QAAM,YAAY,oBAAI,IAAwB;AAC9C,QAAM,UAAU,oBAAI,IAAiB;AACrC,QAAM,WAAW,oBAAI,QAAqB;AAE1C,QAAM,WAAW,CAAC,MAA2B;AAC3C,QAAIA,OAAM,KAAK,IAAI,CAAC;AACpB,QAAI,CAACA,MAAK;AACR,UAAI,OAAO,IAAI,CAAC,EAAG,UAAS,CAAC;AAC7B,WAAK,IAAI,GAAIA,OAAM,oBAAI,IAAI,CAAE;AAC7B,eAAS,SAAS,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC;AACnC,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AEA,eAAW,KAAK,KAAK,KAAK,GAAG;AAC3B,UAAI,KAAK,MAAM,MAAM,MAAM,GAAG,EAAE,KAAK,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,EAAG,KAAM,QAAO,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC;AAAA,IAC1F;AACA,WAAO;AAAA,EACT;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,QAAQ,KAAM;AACnB,UAAM,QAAe,CAAC;AACtB,eAAW,CAAC,GAAG,CAAC,KAAK,QAAS,QAAO,OAAO,GAAG,CAAC;AAChD,YAAQ,MAAM;AACd,eAAW,MAAM,UAAW,IAAG,KAAK;AAAA,EACtC,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,CAAC,MAAM,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS,CAAC,QAAQ,UAAU,IAAI,EAAE,GAAG,MAAM,UAAU,OAAO,EAAE;AAAA,IAC9D,IAAI,IAAI;AACN,aAAO,GAAG,EAAE;AAAA,IACd;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": ["set"]
7
+ }
@@ -0,0 +1,7 @@
1
+ import type { Compiler } from './compile.js';
2
+ /**
3
+ * Compiler for pages with a strict Content-Security-Policy: compiles through a nonce-bearing
4
+ * inline `<script>` (and a Trusted Types policy when present) instead of `new Function`.
5
+ * Pass as `createSigmx({ compile: cspCompiler(nonce) })`.
6
+ */
7
+ export declare const cspCompiler: (nonce: string) => Compiler;
@@ -0,0 +1,20 @@
1
+ const cspCompiler = (nonce) => {
2
+ if (!nonce) throw new Error("cspCompiler needs the page nonce");
3
+ const tt = window.trustedTypes;
4
+ const policy = tt?.createPolicy("sigmx", { createScript: (s) => s });
5
+ return (params, body) => {
6
+ const script = document.createElement("script");
7
+ script.nonce = nonce;
8
+ const text = `document.currentScript.f=function(${params.join(",")}){${body}}`;
9
+ script.text = policy ? policy.createScript(text) : text;
10
+ document.head.append(script);
11
+ script.remove();
12
+ const fn = script.f;
13
+ if (!fn) throw new Error("the Content-Security-Policy blocked expression compilation");
14
+ return fn;
15
+ };
16
+ };
17
+ export {
18
+ cspCompiler
19
+ };
20
+ //# sourceMappingURL=strict-csp.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/kernel/strict-csp.ts"],
4
+ "sourcesContent": ["import type { Compiler } from './compile.js'\n\n/**\n * Compiler for pages with a strict Content-Security-Policy: compiles through a nonce-bearing\n * inline `<script>` (and a Trusted Types policy when present) instead of `new Function`.\n * Pass as `createSigmx({ compile: cspCompiler(nonce) })`.\n */\nexport const cspCompiler = (nonce: string): Compiler => {\n if (!nonce) throw new Error('cspCompiler needs the page nonce')\n const tt = (window as any).trustedTypes\n const policy = tt?.createPolicy('sigmx', { createScript: (s: string) => s })\n return (params, body) => {\n const script = document.createElement('script')\n script.nonce = nonce\n const text = `document.currentScript.f=function(${params.join(',')}){${body}}`\n script.text = policy ? policy.createScript(text) : text\n document.head.append(script)\n script.remove()\n const fn = (script as any).f\n if (!fn) throw new Error('the Content-Security-Policy blocked expression compilation')\n return fn\n }\n}\n"],
5
+ "mappings": "AAOO,MAAM,cAAc,CAAC,UAA4B;AACtD,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,kCAAkC;AAC9D,QAAM,KAAM,OAAe;AAC3B,QAAM,SAAS,IAAI,aAAa,SAAS,EAAE,cAAc,CAAC,MAAc,EAAE,CAAC;AAC3E,SAAO,CAAC,QAAQ,SAAS;AACvB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ;AACf,UAAM,OAAO,qCAAqC,OAAO,KAAK,GAAG,CAAC,KAAK,IAAI;AAC3E,WAAO,OAAO,SAAS,OAAO,aAAa,IAAI,IAAI;AACnD,aAAS,KAAK,OAAO,MAAM;AAC3B,WAAO,OAAO;AACd,UAAM,KAAM,OAAe;AAC3B,QAAI,CAAC,GAAI,OAAM,IAAI,MAAM,4DAA4D;AACrF,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ export type CaseStyle = 'camel' | 'kebab' | 'snake' | 'pascal';
2
+ export declare const kebab: (s: string) => string;
3
+ export declare const snake: (s: string) => string;
4
+ export declare const camel: (s: string) => string;
5
+ export declare const pascal: (s: string) => string;
6
+ /** Recase a dotted path segment by segment so `user.first-name` becomes `user.firstName`. */
7
+ export declare const recase: (path: string, style: CaseStyle) => string;
@@ -0,0 +1,16 @@
1
+ const words = (s) => s.replace(/([a-z0-9])([A-Z])|([A-Z]+)([A-Z][a-z])/g, "$1$3 $2$4").split(/[^A-Za-z0-9]+/).filter(Boolean).map((w) => w.toLowerCase());
2
+ const cap = (w) => w[0].toUpperCase() + w.slice(1);
3
+ const kebab = (s) => words(s).join("-");
4
+ const snake = (s) => words(s).join("_");
5
+ const camel = (s) => words(s).map((w, i) => i ? cap(w) : w).join("");
6
+ const pascal = (s) => words(s).map(cap).join("");
7
+ const styles = { camel, kebab, snake, pascal };
8
+ const recase = (path, style) => path.split(".").map(styles[style]).join(".");
9
+ export {
10
+ camel,
11
+ kebab,
12
+ pascal,
13
+ recase,
14
+ snake
15
+ };
16
+ //# sourceMappingURL=casing.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/casing.ts"],
4
+ "sourcesContent": ["export type CaseStyle = 'camel' | 'kebab' | 'snake' | 'pascal'\n\n/** Split an identifier in any common casing into lowercase words. */\nconst words = (s: string): string[] =>\n s\n .replace(/([a-z0-9])([A-Z])|([A-Z]+)([A-Z][a-z])/g, '$1$3 $2$4')\n .split(/[^A-Za-z0-9]+/)\n .filter(Boolean)\n .map((w) => w.toLowerCase())\n\nconst cap = (w: string): string => w[0].toUpperCase() + w.slice(1)\n\nexport const kebab = (s: string): string => words(s).join('-')\nexport const snake = (s: string): string => words(s).join('_')\nexport const camel = (s: string): string => words(s).map((w, i) => (i ? cap(w) : w)).join('')\nexport const pascal = (s: string): string => words(s).map(cap).join('')\n\nconst styles = { camel, kebab, snake, pascal }\n\n/** Recase a dotted path segment by segment so `user.first-name` becomes `user.firstName`. */\nexport const recase = (path: string, style: CaseStyle): string => path.split('.').map(styles[style]).join('.')\n"],
5
+ "mappings": "AAGA,MAAM,QAAQ,CAAC,MACb,EACG,QAAQ,2CAA2C,WAAW,EAC9D,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAE/B,MAAM,MAAM,CAAC,MAAsB,EAAE,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC;AAE1D,MAAM,QAAQ,CAAC,MAAsB,MAAM,CAAC,EAAE,KAAK,GAAG;AACtD,MAAM,QAAQ,CAAC,MAAsB,MAAM,CAAC,EAAE,KAAK,GAAG;AACtD,MAAM,QAAQ,CAAC,MAAsB,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAO,IAAI,IAAI,CAAC,IAAI,CAAE,EAAE,KAAK,EAAE;AACrF,MAAM,SAAS,CAAC,MAAsB,MAAM,CAAC,EAAE,IAAI,GAAG,EAAE,KAAK,EAAE;AAEtE,MAAM,SAAS,EAAE,OAAO,OAAO,OAAO,OAAO;AAGtC,MAAM,SAAS,CAAC,MAAc,UAA6B,KAAK,MAAM,GAAG,EAAE,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,GAAG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,9 @@
1
+ export declare const isPlain: (v: unknown) => v is Record<string, any>;
2
+ /** Write `value` at a dotted path inside `out`, creating intermediate objects. */
3
+ export declare const expand: (out: Record<string, any>, path: string, value: any) => Record<string, any>;
4
+ export type Filter = {
5
+ include?: RegExp | string;
6
+ exclude?: RegExp | string;
7
+ } | ((path: string) => boolean);
8
+ /** Turn `{ include, exclude }` (regex or string) or a predicate into a path predicate. */
9
+ export declare const toPredicate: (f?: Filter) => ((path: string) => boolean);
@@ -0,0 +1,26 @@
1
+ const isPlain = (v) => {
2
+ if (v === null || typeof v !== "object") return false;
3
+ const proto = Object.getPrototypeOf(v);
4
+ return proto === Object.prototype || proto === null;
5
+ };
6
+ const expand = (out, path, value) => {
7
+ const keys = path.split(".");
8
+ const last = keys.pop();
9
+ let cur = out;
10
+ for (const k of keys) cur = isPlain(cur[k]) ? cur[k] : cur[k] = {};
11
+ cur[last] = value;
12
+ return out;
13
+ };
14
+ const re = (v, fallback) => v === void 0 ? fallback : typeof v === "string" ? new RegExp(v.replace(/^\/|\/$/g, "")) : v;
15
+ const toPredicate = (f) => {
16
+ if (typeof f === "function") return f;
17
+ const inc = re(f?.include, /(?:)/);
18
+ const exc = re(f?.exclude, /(?!)/);
19
+ return (p) => inc.test(p) && !exc.test(p);
20
+ };
21
+ export {
22
+ expand,
23
+ isPlain,
24
+ toPredicate
25
+ };
26
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/objects.ts"],
4
+ "sourcesContent": ["export const isPlain = (v: unknown): v is Record<string, any> => {\n if (v === null || typeof v !== 'object') return false\n const proto = Object.getPrototypeOf(v)\n return proto === Object.prototype || proto === null\n}\n\n/** Write `value` at a dotted path inside `out`, creating intermediate objects. */\nexport const expand = (out: Record<string, any>, path: string, value: any): Record<string, any> => {\n const keys = path.split('.')\n const last = keys.pop()!\n let cur = out\n for (const k of keys) cur = isPlain(cur[k]) ? cur[k] : (cur[k] = {})\n cur[last] = value\n return out\n}\n\nexport type Filter = { include?: RegExp | string; exclude?: RegExp | string } | ((path: string) => boolean)\n\nconst re = (v: RegExp | string | undefined, fallback: RegExp): RegExp =>\n v === undefined ? fallback : typeof v === 'string' ? new RegExp(v.replace(/^\\/|\\/$/g, '')) : v\n\n/** Turn `{ include, exclude }` (regex or string) or a predicate into a path predicate. */\nexport const toPredicate = (f?: Filter): ((path: string) => boolean) => {\n if (typeof f === 'function') return f\n const inc = re(f?.include, /(?:)/)\n const exc = re(f?.exclude, /(?!)/)\n return (p) => inc.test(p) && !exc.test(p)\n}\n"],
5
+ "mappings": "AAAO,MAAM,UAAU,CAAC,MAAyC;AAC/D,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAU,QAAO;AAChD,QAAM,QAAQ,OAAO,eAAe,CAAC;AACrC,SAAO,UAAU,OAAO,aAAa,UAAU;AACjD;AAGO,MAAM,SAAS,CAAC,KAA0B,MAAc,UAAoC;AACjG,QAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,QAAM,OAAO,KAAK,IAAI;AACtB,MAAI,MAAM;AACV,aAAW,KAAK,KAAM,OAAM,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAK,IAAI,CAAC,IAAI,CAAC;AAClE,MAAI,IAAI,IAAI;AACZ,SAAO;AACT;AAIA,MAAM,KAAK,CAAC,GAAgC,aAC1C,MAAM,SAAY,WAAW,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE,QAAQ,YAAY,EAAE,CAAC,IAAI;AAGxF,MAAM,cAAc,CAAC,MAA4C;AACtE,MAAI,OAAO,MAAM,WAAY,QAAO;AACpC,QAAM,MAAM,GAAG,GAAG,SAAS,MAAM;AACjC,QAAM,MAAM,GAAG,GAAG,SAAS,MAAM;AACjC,SAAO,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AAC1C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,14 @@
1
+ export type Mods = Map<string, string[]>;
2
+ type Fn = (...args: any[]) => void;
3
+ /** '300ms' → 300, '2s' → 2000, '150' → 150. */
4
+ export declare const toMs: (args: string[] | undefined, fallback?: number) => number;
5
+ export declare const delay: (fn: Fn, ms: number) => Fn;
6
+ /** Debounce: wait for a quiet period. `leading` fires on the first call, `trailing` on the last. */
7
+ export declare const debounce: (fn: Fn, ms: number, leading?: boolean, trailing?: boolean) => Fn;
8
+ /** Throttle: at most one call per window. `leading` fires immediately, `trailing` fires once at the end. */
9
+ export declare const throttle: (fn: Fn, ms: number, leading?: boolean, trailing?: boolean) => Fn;
10
+ /** Apply `__delay`, `__debounce` and `__throttle` modifiers to a callback. */
11
+ export declare const withTiming: (fn: Fn, mods: Mods) => Fn;
12
+ /** Wrap a callback in `document.startViewTransition` when `__viewtransition` is present and supported. */
13
+ export declare const withViewTransition: (fn: Fn, mods: Mods) => Fn;
14
+ export {};
@@ -0,0 +1,51 @@
1
+ const toMs = (args, fallback = 0) => {
2
+ for (const a of args ?? []) {
3
+ const m = /^(\d+(?:\.\d+)?)(ms|s)?$/.exec(a);
4
+ if (m) return +m[1] * (m[2] === "s" ? 1e3 : 1);
5
+ }
6
+ return fallback;
7
+ };
8
+ const delay = (fn, ms) => (...args) => void setTimeout(fn, ms, ...args);
9
+ const limit = (fn, ms, leading, trailing, restart) => {
10
+ let timer;
11
+ let last;
12
+ const fire = () => {
13
+ timer = void 0;
14
+ if (trailing && last) fn(...last);
15
+ last = void 0;
16
+ };
17
+ return (...args) => {
18
+ if (timer) {
19
+ last = args;
20
+ if (restart) {
21
+ clearTimeout(timer);
22
+ timer = setTimeout(fire, ms);
23
+ }
24
+ return;
25
+ }
26
+ if (leading) fn(...args);
27
+ else last = args;
28
+ timer = setTimeout(fire, ms);
29
+ };
30
+ };
31
+ const debounce = (fn, ms, leading = false, trailing = true) => limit(fn, ms, leading, trailing, true);
32
+ const throttle = (fn, ms, leading = true, trailing = false) => limit(fn, ms, leading, trailing, false);
33
+ const withTiming = (fn, mods) => {
34
+ const d = mods.get("delay");
35
+ if (d) fn = delay(fn, toMs(d));
36
+ const db = mods.get("debounce");
37
+ if (db) fn = debounce(fn, toMs(db, 300), db.includes("leading"), !db.includes("notrailing"));
38
+ const th = mods.get("throttle");
39
+ if (th) fn = throttle(fn, toMs(th, 300), !th.includes("noleading"), th.includes("trailing"));
40
+ return fn;
41
+ };
42
+ const withViewTransition = (fn, mods) => mods.has("viewtransition") && "startViewTransition" in document ? (...args) => void document.startViewTransition(() => fn(...args)) : fn;
43
+ export {
44
+ debounce,
45
+ delay,
46
+ throttle,
47
+ toMs,
48
+ withTiming,
49
+ withViewTransition
50
+ };
51
+ //# sourceMappingURL=schedule.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/schedule.ts"],
4
+ "sourcesContent": ["export type Mods = Map<string, string[]>\ntype Fn = (...args: any[]) => void\n\n/** '300ms' \u2192 300, '2s' \u2192 2000, '150' \u2192 150. */\nexport const toMs = (args: string[] | undefined, fallback = 0): number => {\n for (const a of args ?? []) {\n const m = /^(\\d+(?:\\.\\d+)?)(ms|s)?$/.exec(a)\n if (m) return +m[1] * (m[2] === 's' ? 1000 : 1)\n }\n return fallback\n}\n\nexport const delay = (fn: Fn, ms: number): Fn => (...args) => void setTimeout(fn, ms, ...args)\n\n/** Shared rate limiter. `restart` makes it a debounce (the window restarts on every call). */\nconst limit = (fn: Fn, ms: number, leading: boolean, trailing: boolean, restart: boolean): Fn => {\n let timer: ReturnType<typeof setTimeout> | undefined\n let last: any[] | undefined\n const fire = () => {\n timer = undefined\n if (trailing && last) fn(...last)\n last = undefined\n }\n return (...args) => {\n if (timer) {\n last = args\n if (restart) {\n clearTimeout(timer)\n timer = setTimeout(fire, ms)\n }\n return\n }\n if (leading) fn(...args)\n else last = args\n timer = setTimeout(fire, ms)\n }\n}\n\n/** Debounce: wait for a quiet period. `leading` fires on the first call, `trailing` on the last. */\nexport const debounce = (fn: Fn, ms: number, leading = false, trailing = true): Fn => limit(fn, ms, leading, trailing, true)\n\n/** Throttle: at most one call per window. `leading` fires immediately, `trailing` fires once at the end. */\nexport const throttle = (fn: Fn, ms: number, leading = true, trailing = false): Fn => limit(fn, ms, leading, trailing, false)\n\n/** Apply `__delay`, `__debounce` and `__throttle` modifiers to a callback. */\nexport const withTiming = (fn: Fn, mods: Mods): Fn => {\n const d = mods.get('delay')\n if (d) fn = delay(fn, toMs(d))\n const db = mods.get('debounce')\n if (db) fn = debounce(fn, toMs(db, 300), db.includes('leading'), !db.includes('notrailing'))\n const th = mods.get('throttle')\n if (th) fn = throttle(fn, toMs(th, 300), !th.includes('noleading'), th.includes('trailing'))\n return fn\n}\n\n/** Wrap a callback in `document.startViewTransition` when `__viewtransition` is present and supported. */\nexport const withViewTransition = (fn: Fn, mods: Mods): Fn =>\n mods.has('viewtransition') && 'startViewTransition' in document\n ? (...args) => void document.startViewTransition(() => fn(...args))\n : fn\n"],
5
+ "mappings": "AAIO,MAAM,OAAO,CAAC,MAA4B,WAAW,MAAc;AACxE,aAAW,KAAK,QAAQ,CAAC,GAAG;AAC1B,UAAM,IAAI,2BAA2B,KAAK,CAAC;AAC3C,QAAI,EAAG,QAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,MAAM,MAAO;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,QAAQ,CAAC,IAAQ,OAAmB,IAAI,SAAS,KAAK,WAAW,IAAI,IAAI,GAAG,IAAI;AAG7F,MAAM,QAAQ,CAAC,IAAQ,IAAY,SAAkB,UAAmB,YAAyB;AAC/F,MAAI;AACJ,MAAI;AACJ,QAAM,OAAO,MAAM;AACjB,YAAQ;AACR,QAAI,YAAY,KAAM,IAAG,GAAG,IAAI;AAChC,WAAO;AAAA,EACT;AACA,SAAO,IAAI,SAAS;AAClB,QAAI,OAAO;AACT,aAAO;AACP,UAAI,SAAS;AACX,qBAAa,KAAK;AAClB,gBAAQ,WAAW,MAAM,EAAE;AAAA,MAC7B;AACA;AAAA,IACF;AACA,QAAI,QAAS,IAAG,GAAG,IAAI;AAAA,QAClB,QAAO;AACZ,YAAQ,WAAW,MAAM,EAAE;AAAA,EAC7B;AACF;AAGO,MAAM,WAAW,CAAC,IAAQ,IAAY,UAAU,OAAO,WAAW,SAAa,MAAM,IAAI,IAAI,SAAS,UAAU,IAAI;AAGpH,MAAM,WAAW,CAAC,IAAQ,IAAY,UAAU,MAAM,WAAW,UAAc,MAAM,IAAI,IAAI,SAAS,UAAU,KAAK;AAGrH,MAAM,aAAa,CAAC,IAAQ,SAAmB;AACpD,QAAM,IAAI,KAAK,IAAI,OAAO;AAC1B,MAAI,EAAG,MAAK,MAAM,IAAI,KAAK,CAAC,CAAC;AAC7B,QAAM,KAAK,KAAK,IAAI,UAAU;AAC9B,MAAI,GAAI,MAAK,SAAS,IAAI,KAAK,IAAI,GAAG,GAAG,GAAG,SAAS,SAAS,GAAG,CAAC,GAAG,SAAS,YAAY,CAAC;AAC3F,QAAM,KAAK,KAAK,IAAI,UAAU;AAC9B,MAAI,GAAI,MAAK,SAAS,IAAI,KAAK,IAAI,GAAG,GAAG,CAAC,GAAG,SAAS,WAAW,GAAG,GAAG,SAAS,UAAU,CAAC;AAC3F,SAAO;AACT;AAGO,MAAM,qBAAqB,CAAC,IAAQ,SACzC,KAAK,IAAI,gBAAgB,KAAK,yBAAyB,WACnD,IAAI,SAAS,KAAK,SAAS,oBAAoB,MAAM,GAAG,GAAG,IAAI,CAAC,IAChE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ export type ServerEvent = {
2
+ event: string;
3
+ data: string;
4
+ id?: string;
5
+ retry?: number;
6
+ };
7
+ /** Read a `text/event-stream` body, calling `onEvent` for each complete event. Resolves when the stream ends. */
8
+ export declare const readEvents: (body: ReadableStream<Uint8Array>, onEvent: (e: ServerEvent) => void) => Promise<void>;
9
+ /** Event payloads: each data line is `key value`; repeated keys join with newlines. */
10
+ export declare const parseFields: (data: string) => Record<string, string>;
@@ -0,0 +1,55 @@
1
+ const readEvents = async (body, onEvent) => {
2
+ const reader = body.getReader();
3
+ const decoder = new TextDecoder();
4
+ let buffer = "";
5
+ let event = "";
6
+ let data = [];
7
+ let id;
8
+ let retry;
9
+ const flush = () => {
10
+ if (data.length) onEvent({ event: event || "message", data: data.join("\n"), id, retry });
11
+ event = "";
12
+ data = [];
13
+ };
14
+ const line = (l) => {
15
+ if (!l) return flush();
16
+ if (l[0] === ":") return;
17
+ const c = l.indexOf(":");
18
+ const field = c < 0 ? l : l.slice(0, c);
19
+ let v = c < 0 ? "" : l.slice(c + 1);
20
+ if (v[0] === " ") v = v.slice(1);
21
+ if (field === "event") event = v;
22
+ else if (field === "data") data.push(v);
23
+ else if (field === "id") id = v;
24
+ else if (field === "retry" && /^\d+$/.test(v)) retry = +v;
25
+ };
26
+ for (; ; ) {
27
+ const { value, done } = await reader.read();
28
+ if (done) break;
29
+ buffer += decoder.decode(value, { stream: true });
30
+ let i;
31
+ while ((i = buffer.search(/\r\n|\r|\n/)) >= 0) {
32
+ const l = buffer.slice(0, i);
33
+ buffer = buffer.slice(i + (buffer[i] === "\r" && buffer[i + 1] === "\n" ? 2 : 1));
34
+ line(l);
35
+ }
36
+ }
37
+ if (buffer) line(buffer);
38
+ flush();
39
+ };
40
+ const parseFields = (data) => {
41
+ const out = {};
42
+ for (const l of data.split("\n")) {
43
+ const i = l.indexOf(" ");
44
+ const k = i < 0 ? l : l.slice(0, i);
45
+ const v = i < 0 ? "" : l.slice(i + 1);
46
+ out[k] = k in out ? `${out[k]}
47
+ ${v}` : v;
48
+ }
49
+ return out;
50
+ };
51
+ export {
52
+ parseFields,
53
+ readEvents
54
+ };
55
+ //# sourceMappingURL=sse.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/lib/sse.ts"],
4
+ "sourcesContent": ["export type ServerEvent = { event: string; data: string; id?: string; retry?: number }\n\n/** Read a `text/event-stream` body, calling `onEvent` for each complete event. Resolves when the stream ends. */\nexport const readEvents = async (body: ReadableStream<Uint8Array>, onEvent: (e: ServerEvent) => void): Promise<void> => {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let event = ''\n let data: string[] = []\n let id: string | undefined\n let retry: number | undefined\n const flush = () => {\n if (data.length) onEvent({ event: event || 'message', data: data.join('\\n'), id, retry })\n event = ''\n data = []\n }\n const line = (l: string) => {\n if (!l) return flush()\n if (l[0] === ':') return\n const c = l.indexOf(':')\n const field = c < 0 ? l : l.slice(0, c)\n let v = c < 0 ? '' : l.slice(c + 1)\n if (v[0] === ' ') v = v.slice(1)\n if (field === 'event') event = v\n else if (field === 'data') data.push(v)\n else if (field === 'id') id = v\n else if (field === 'retry' && /^\\d+$/.test(v)) retry = +v\n }\n for (;;) {\n const { value, done } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let i: number\n while ((i = buffer.search(/\\r\\n|\\r|\\n/)) >= 0) {\n const l = buffer.slice(0, i)\n buffer = buffer.slice(i + (buffer[i] === '\\r' && buffer[i + 1] === '\\n' ? 2 : 1))\n line(l)\n }\n }\n if (buffer) line(buffer)\n flush()\n}\n\n/** Event payloads: each data line is `key value`; repeated keys join with newlines. */\nexport const parseFields = (data: string): Record<string, string> => {\n const out: Record<string, string> = {}\n for (const l of data.split('\\n')) {\n const i = l.indexOf(' ')\n const k = i < 0 ? l : l.slice(0, i)\n const v = i < 0 ? '' : l.slice(i + 1)\n out[k] = k in out ? `${out[k]}\\n${v}` : v\n }\n return out\n}\n"],
5
+ "mappings": "AAGO,MAAM,aAAa,OAAO,MAAkC,YAAqD;AACtH,QAAM,SAAS,KAAK,UAAU;AAC9B,QAAM,UAAU,IAAI,YAAY;AAChC,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,MAAI,OAAiB,CAAC;AACtB,MAAI;AACJ,MAAI;AACJ,QAAM,QAAQ,MAAM;AAClB,QAAI,KAAK,OAAQ,SAAQ,EAAE,OAAO,SAAS,WAAW,MAAM,KAAK,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC;AACxF,YAAQ;AACR,WAAO,CAAC;AAAA,EACV;AACA,QAAM,OAAO,CAAC,MAAc;AAC1B,QAAI,CAAC,EAAG,QAAO,MAAM;AACrB,QAAI,EAAE,CAAC,MAAM,IAAK;AAClB,UAAM,IAAI,EAAE,QAAQ,GAAG;AACvB,UAAM,QAAQ,IAAI,IAAI,IAAI,EAAE,MAAM,GAAG,CAAC;AACtC,QAAI,IAAI,IAAI,IAAI,KAAK,EAAE,MAAM,IAAI,CAAC;AAClC,QAAI,EAAE,CAAC,MAAM,IAAK,KAAI,EAAE,MAAM,CAAC;AAC/B,QAAI,UAAU,QAAS,SAAQ;AAAA,aACtB,UAAU,OAAQ,MAAK,KAAK,CAAC;AAAA,aAC7B,UAAU,KAAM,MAAK;AAAA,aACrB,UAAU,WAAW,QAAQ,KAAK,CAAC,EAAG,SAAQ,CAAC;AAAA,EAC1D;AACA,aAAS;AACP,UAAM,EAAE,OAAO,KAAK,IAAI,MAAM,OAAO,KAAK;AAC1C,QAAI,KAAM;AACV,cAAU,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;AAChD,QAAI;AACJ,YAAQ,IAAI,OAAO,OAAO,YAAY,MAAM,GAAG;AAC7C,YAAM,IAAI,OAAO,MAAM,GAAG,CAAC;AAC3B,eAAS,OAAO,MAAM,KAAK,OAAO,CAAC,MAAM,QAAQ,OAAO,IAAI,CAAC,MAAM,OAAO,IAAI,EAAE;AAChF,WAAK,CAAC;AAAA,IACR;AAAA,EACF;AACA,MAAI,OAAQ,MAAK,MAAM;AACvB,QAAM;AACR;AAGO,MAAM,cAAc,CAAC,SAAyC;AACnE,QAAM,MAA8B,CAAC;AACrC,aAAW,KAAK,KAAK,MAAM,IAAI,GAAG;AAChC,UAAM,IAAI,EAAE,QAAQ,GAAG;AACvB,UAAM,IAAI,IAAI,IAAI,IAAI,EAAE,MAAM,GAAG,CAAC;AAClC,UAAM,IAAI,IAAI,IAAI,KAAK,EAAE,MAAM,IAAI,CAAC;AACpC,QAAI,CAAC,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC;AAAA,EAAK,CAAC,KAAK;AAAA,EAC1C;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@clipboard(text, isBase64?)` copies text; base64 input is decoded first. */
2
+ export declare const clipboard: import("../../core/types.js").ActionPlugin;
@@ -0,0 +1,11 @@
1
+ import { action } from "../../core/index.js";
2
+ const clipboard = action({
3
+ name: "clipboard",
4
+ call: (_, text, base64 = false) => navigator.clipboard.writeText(
5
+ base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text
6
+ )
7
+ });
8
+ export {
9
+ clipboard
10
+ };
11
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/actions/clipboard.ts"],
4
+ "sourcesContent": ["import { action } from '../../core/index.js'\n\n/** `@clipboard(text, isBase64?)` copies text; base64 input is decoded first. */\nexport const clipboard = action({\n name: 'clipboard',\n call: (_, text: string, base64 = false) =>\n navigator.clipboard.writeText(\n base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text,\n ),\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,MAAc,SAAS,UAC/B,UAAU,UAAU;AAAA,IAClB,SAAS,IAAI,YAAY,EAAE,OAAO,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI;AAAA,EAC3F;AACJ,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** Map `v` from [inMin, inMax] onto [outMin, outMax]; optionally clamp and round. */
2
+ export declare const fit: import("../../core/types.js").ActionPlugin;
@@ -0,0 +1,14 @@
1
+ import { action } from "../../core/index.js";
2
+ const fit = action({
3
+ name: "fit",
4
+ call: (_, v, inMin, inMax, outMin, outMax, clamp = false, round = false) => {
5
+ let t = (v - inMin) / (inMax - inMin);
6
+ if (clamp) t = Math.min(1, Math.max(0, t));
7
+ const out = outMin + t * (outMax - outMin);
8
+ return round ? Math.round(out) : out;
9
+ }
10
+ });
11
+ export {
12
+ fit
13
+ };
14
+ //# sourceMappingURL=fit.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/plugins/actions/fit.ts"],
4
+ "sourcesContent": ["import { action } from '../../core/index.js'\n\n/** Map `v` from [inMin, inMax] onto [outMin, outMax]; optionally clamp and round. */\nexport const fit = action({\n name: 'fit',\n call: (_, v: number, inMin: number, inMax: number, outMin: number, outMax: number, clamp = false, round = false) => {\n let t = (v - inMin) / (inMax - inMin)\n if (clamp) t = Math.min(1, Math.max(0, t))\n const out = outMin + t * (outMax - outMin)\n return round ? Math.round(out) : out\n },\n})\n"],
5
+ "mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,MAAM,OAAO;AAAA,EACxB,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,GAAW,OAAe,OAAe,QAAgB,QAAgB,QAAQ,OAAO,QAAQ,UAAU;AAClH,QAAI,KAAK,IAAI,UAAU,QAAQ;AAC/B,QAAI,MAAO,KAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACzC,UAAM,MAAM,SAAS,KAAK,SAAS;AACnC,WAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;AAAA,EACnC;AACF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ /** `@intl('number', 1234.5, { style: 'currency', currency: 'USD' }, 'en-US')`. */
2
+ export declare const intl: import("../../core/types.js").ActionPlugin;