sygnal 5.3.7 → 5.4.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 (226) hide show
  1. package/README.md +53 -38
  2. package/dist/astro/client.cjs.js +18 -8106
  3. package/dist/astro/client.cjs.js.map +1 -0
  4. package/dist/astro/client.mjs +17 -8105
  5. package/dist/astro/client.mjs.map +1 -0
  6. package/dist/astro/index.cjs.js +768 -9
  7. package/dist/astro/index.cjs.js.map +1 -0
  8. package/dist/astro/index.mjs +768 -9
  9. package/dist/astro/index.mjs.map +1 -0
  10. package/dist/astro/server.cjs.js +4 -1
  11. package/dist/astro/server.cjs.js.map +1 -0
  12. package/dist/astro/server.mjs +4 -1
  13. package/dist/astro/server.mjs.map +1 -0
  14. package/dist/diagnostics.cjs.js +1297 -0
  15. package/dist/diagnostics.cjs.js.map +1 -0
  16. package/dist/diagnostics.esm.js +1267 -0
  17. package/dist/diagnostics.esm.js.map +1 -0
  18. package/dist/index.cjs.js +2981 -1386
  19. package/dist/index.cjs.js.map +1 -0
  20. package/dist/index.d.ts +848 -111
  21. package/dist/index.esm.js +2997 -1411
  22. package/dist/index.esm.js.map +1 -0
  23. package/dist/jsx-dev-runtime.cjs.js +15 -9
  24. package/dist/jsx-dev-runtime.cjs.js.map +1 -0
  25. package/dist/jsx-dev-runtime.esm.js +15 -9
  26. package/dist/jsx-dev-runtime.esm.js.map +1 -0
  27. package/dist/jsx-runtime.cjs.js +15 -9
  28. package/dist/jsx-runtime.cjs.js.map +1 -0
  29. package/dist/jsx-runtime.esm.js +15 -9
  30. package/dist/jsx-runtime.esm.js.map +1 -0
  31. package/dist/jsx.cjs.js +15 -9
  32. package/dist/jsx.cjs.js.map +1 -0
  33. package/dist/jsx.esm.js +15 -9
  34. package/dist/jsx.esm.js.map +1 -0
  35. package/dist/sygnal.min.js +2 -1
  36. package/dist/sygnal.min.js.map +1 -0
  37. package/dist/vike/+config.cjs.js +1 -0
  38. package/dist/vike/+config.cjs.js.map +1 -0
  39. package/dist/vike/+config.js +1 -0
  40. package/dist/vike/+config.js.map +1 -0
  41. package/dist/vike/ClientOnly.cjs.js +1 -0
  42. package/dist/vike/ClientOnly.cjs.js.map +1 -0
  43. package/dist/vike/ClientOnly.mjs +1 -0
  44. package/dist/vike/ClientOnly.mjs.map +1 -0
  45. package/dist/vike/onRenderClient.cjs.js +1 -0
  46. package/dist/vike/onRenderClient.cjs.js.map +1 -0
  47. package/dist/vike/onRenderClient.mjs +1 -0
  48. package/dist/vike/onRenderClient.mjs.map +1 -0
  49. package/dist/vike/onRenderHtml.cjs.js +1 -0
  50. package/dist/vike/onRenderHtml.cjs.js.map +1 -0
  51. package/dist/vike/onRenderHtml.mjs +1 -0
  52. package/dist/vike/onRenderHtml.mjs.map +1 -0
  53. package/dist/vite/plugin.cjs.js +670 -44
  54. package/dist/vite/plugin.cjs.js.map +1 -0
  55. package/dist/vite/plugin.mjs +670 -44
  56. package/dist/vite/plugin.mjs.map +1 -0
  57. package/llms.txt +250 -0
  58. package/package.json +15 -6
  59. package/src/astro/client.ts +13 -2
  60. package/src/astro/index.d.ts +24 -1
  61. package/src/astro/index.ts +40 -9
  62. package/src/astro/server.ts +3 -1
  63. package/src/collection.ts +5 -2
  64. package/src/component.ts +375 -330
  65. package/src/cycle/dom/MainDOMSource.ts +4 -0
  66. package/src/cycle/dom/classNameModule.ts +74 -0
  67. package/src/cycle/dom/controlledInputModule.ts +33 -0
  68. package/src/cycle/dom/enrichEventStream.ts +9 -3
  69. package/src/cycle/dom/makeDOMDriver.ts +1 -2
  70. package/src/cycle/dom/mockDOMSource.ts +62 -8
  71. package/src/cycle/dom/modules.ts +5 -1
  72. package/src/cycle/state/Collection.ts +13 -3
  73. package/src/cycle/state/StateSource.ts +1 -1
  74. package/src/cycle/state/pickCombine.ts +35 -1
  75. package/src/cycle/state/withState.ts +1 -1
  76. package/src/extra/devtools.ts +8 -0
  77. package/src/extra/diagnostics/checks/collections.ts +67 -0
  78. package/src/extra/diagnostics/checks/dom.ts +241 -0
  79. package/src/extra/diagnostics/checks/events.ts +68 -0
  80. package/src/extra/diagnostics/checks/index.ts +109 -0
  81. package/src/extra/diagnostics/checks/inspect.ts +319 -0
  82. package/src/extra/diagnostics/checks/props.ts +51 -0
  83. package/src/extra/diagnostics/checks/public.d.ts +211 -0
  84. package/src/extra/diagnostics/checks/rxjsHints.ts +88 -0
  85. package/src/extra/diagnostics/checks/shared.ts +119 -0
  86. package/src/extra/diagnostics/checks/state.ts +55 -0
  87. package/src/extra/diagnostics/checks/strict.ts +112 -0
  88. package/src/extra/diagnostics/checks/wiring.ts +65 -0
  89. package/src/extra/diagnostics/codes.ts +232 -0
  90. package/src/extra/diagnostics/index.ts +328 -0
  91. package/src/extra/diagnostics/legacy.ts +59 -0
  92. package/src/extra/driverFactories.ts +106 -58
  93. package/src/extra/eventDriver.ts +4 -0
  94. package/src/extra/flatten.ts +75 -0
  95. package/src/extra/reducers.ts +12 -5
  96. package/src/extra/run.ts +11 -0
  97. package/src/extra/testing.ts +890 -180
  98. package/src/extra/xstreamExtras.ts +269 -0
  99. package/src/index.d.ts +428 -17
  100. package/src/index.ts +7 -6
  101. package/src/pragma/index.ts +14 -9
  102. package/src/switchable.ts +10 -8
  103. package/src/vike/types.ts +21 -4
  104. package/src/vite/plugin.d.ts +95 -2
  105. package/src/vite/plugin.ts +720 -54
  106. package/dist/astro/astro/client.d.ts +0 -5
  107. package/dist/astro/astro/index.d.ts +0 -16
  108. package/dist/astro/astro/server.d.ts +0 -12
  109. package/dist/astro/client.d.ts +0 -5
  110. package/dist/astro/client.esm.js +0 -4665
  111. package/dist/astro/collection.d.ts +0 -12
  112. package/dist/astro/component.d.ts +0 -22
  113. package/dist/astro/cycle/dom/BodyDOMSource.d.ts +0 -10
  114. package/dist/astro/cycle/dom/DOMSource.d.ts +0 -11
  115. package/dist/astro/cycle/dom/DocumentDOMSource.d.ts +0 -12
  116. package/dist/astro/cycle/dom/ElementFinder.d.ts +0 -8
  117. package/dist/astro/cycle/dom/EventDelegator.d.ts +0 -34
  118. package/dist/astro/cycle/dom/IsolateModule.d.ts +0 -23
  119. package/dist/astro/cycle/dom/MainDOMSource.d.ts +0 -32
  120. package/dist/astro/cycle/dom/PriorityQueue.d.ts +0 -7
  121. package/dist/astro/cycle/dom/ScopeChecker.d.ts +0 -9
  122. package/dist/astro/cycle/dom/SymbolTree.d.ts +0 -9
  123. package/dist/astro/cycle/dom/VNodeWrapper.d.ts +0 -8
  124. package/dist/astro/cycle/dom/enrichEventStream.d.ts +0 -24
  125. package/dist/astro/cycle/dom/fromEvent.d.ts +0 -6
  126. package/dist/astro/cycle/dom/index.d.ts +0 -8
  127. package/dist/astro/cycle/dom/isolate.d.ts +0 -9
  128. package/dist/astro/cycle/dom/makeDOMDriver.d.ts +0 -11
  129. package/dist/astro/cycle/dom/mockDOMSource.d.ts +0 -17
  130. package/dist/astro/cycle/dom/modules.d.ts +0 -5
  131. package/dist/astro/cycle/dom/snabbdom.d.ts +0 -22
  132. package/dist/astro/cycle/dom/styleModule.d.ts +0 -13
  133. package/dist/astro/cycle/dom/thunk.d.ts +0 -11
  134. package/dist/astro/cycle/dom/utils.d.ts +0 -8
  135. package/dist/astro/cycle/isolate/index.d.ts +0 -42
  136. package/dist/astro/cycle/run/adapt.d.ts +0 -6
  137. package/dist/astro/cycle/run/index.d.ts +0 -36
  138. package/dist/astro/cycle/run/internals.d.ts +0 -8
  139. package/dist/astro/cycle/run/types.d.ts +0 -49
  140. package/dist/astro/cycle/state/Collection.d.ts +0 -29
  141. package/dist/astro/cycle/state/StateSource.d.ts +0 -20
  142. package/dist/astro/cycle/state/index.d.ts +0 -5
  143. package/dist/astro/cycle/state/pickCombine.d.ts +0 -3
  144. package/dist/astro/cycle/state/pickMerge.d.ts +0 -3
  145. package/dist/astro/cycle/state/types.d.ts +0 -18
  146. package/dist/astro/cycle/state/withState.d.ts +0 -17
  147. package/dist/astro/extra/classes.d.ts +0 -7
  148. package/dist/astro/extra/devtools.d.ts +0 -78
  149. package/dist/astro/extra/dragDriver.d.ts +0 -20
  150. package/dist/astro/extra/driverFactories.d.ts +0 -12
  151. package/dist/astro/extra/eventDriver.d.ts +0 -9
  152. package/dist/astro/extra/exactState.d.ts +0 -1
  153. package/dist/astro/extra/hmr.d.ts +0 -17
  154. package/dist/astro/extra/logDriver.d.ts +0 -2
  155. package/dist/astro/extra/processDrag.d.ts +0 -19
  156. package/dist/astro/extra/processForm.d.ts +0 -15
  157. package/dist/astro/extra/run.d.ts +0 -13
  158. package/dist/astro/extra/xstreamCompat.d.ts +0 -5
  159. package/dist/astro/index.d.ts +0 -19
  160. package/dist/astro/index.esm.js +0 -27
  161. package/dist/astro/jsx-dev-runtime.d.ts +0 -1
  162. package/dist/astro/jsx-runtime.d.ts +0 -4
  163. package/dist/astro/jsx.d.ts +0 -2
  164. package/dist/astro/pragma/fn.d.ts +0 -7
  165. package/dist/astro/pragma/index.d.ts +0 -7
  166. package/dist/astro/pragma/is.d.ts +0 -10
  167. package/dist/astro/server.d.ts +0 -12
  168. package/dist/astro/server.esm.js +0 -25
  169. package/dist/astro/switchable.d.ts +0 -7
  170. package/dist/collection.d.ts +0 -12
  171. package/dist/component.d.ts +0 -22
  172. package/dist/cycle/dom/BodyDOMSource.d.ts +0 -10
  173. package/dist/cycle/dom/DOMSource.d.ts +0 -11
  174. package/dist/cycle/dom/DocumentDOMSource.d.ts +0 -12
  175. package/dist/cycle/dom/ElementFinder.d.ts +0 -8
  176. package/dist/cycle/dom/EventDelegator.d.ts +0 -34
  177. package/dist/cycle/dom/IsolateModule.d.ts +0 -23
  178. package/dist/cycle/dom/MainDOMSource.d.ts +0 -32
  179. package/dist/cycle/dom/PriorityQueue.d.ts +0 -7
  180. package/dist/cycle/dom/ScopeChecker.d.ts +0 -9
  181. package/dist/cycle/dom/SymbolTree.d.ts +0 -9
  182. package/dist/cycle/dom/VNodeWrapper.d.ts +0 -8
  183. package/dist/cycle/dom/enrichEventStream.d.ts +0 -24
  184. package/dist/cycle/dom/fromEvent.d.ts +0 -6
  185. package/dist/cycle/dom/index.d.ts +0 -8
  186. package/dist/cycle/dom/isolate.d.ts +0 -9
  187. package/dist/cycle/dom/makeDOMDriver.d.ts +0 -11
  188. package/dist/cycle/dom/mockDOMSource.d.ts +0 -17
  189. package/dist/cycle/dom/modules.d.ts +0 -5
  190. package/dist/cycle/dom/snabbdom.d.ts +0 -22
  191. package/dist/cycle/dom/styleModule.d.ts +0 -13
  192. package/dist/cycle/dom/thunk.d.ts +0 -11
  193. package/dist/cycle/dom/utils.d.ts +0 -8
  194. package/dist/cycle/isolate/index.d.ts +0 -42
  195. package/dist/cycle/run/adapt.d.ts +0 -6
  196. package/dist/cycle/run/index.d.ts +0 -36
  197. package/dist/cycle/run/internals.d.ts +0 -8
  198. package/dist/cycle/run/types.d.ts +0 -49
  199. package/dist/cycle/state/Collection.d.ts +0 -29
  200. package/dist/cycle/state/StateSource.d.ts +0 -20
  201. package/dist/cycle/state/index.d.ts +0 -5
  202. package/dist/cycle/state/pickCombine.d.ts +0 -3
  203. package/dist/cycle/state/pickMerge.d.ts +0 -3
  204. package/dist/cycle/state/types.d.ts +0 -18
  205. package/dist/cycle/state/withState.d.ts +0 -17
  206. package/dist/extra/classes.d.ts +0 -7
  207. package/dist/extra/devtools.d.ts +0 -78
  208. package/dist/extra/dragDriver.d.ts +0 -20
  209. package/dist/extra/driverFactories.d.ts +0 -12
  210. package/dist/extra/eventDriver.d.ts +0 -9
  211. package/dist/extra/exactState.d.ts +0 -1
  212. package/dist/extra/hmr.d.ts +0 -17
  213. package/dist/extra/logDriver.d.ts +0 -2
  214. package/dist/extra/processDrag.d.ts +0 -19
  215. package/dist/extra/processForm.d.ts +0 -15
  216. package/dist/extra/run.d.ts +0 -13
  217. package/dist/extra/xstreamCompat.d.ts +0 -5
  218. package/dist/jsx-dev-runtime.d.ts +0 -1
  219. package/dist/jsx-dev-runtime.js +0 -224
  220. package/dist/jsx-runtime.d.ts +0 -4
  221. package/dist/jsx-runtime.js +0 -224
  222. package/dist/jsx.d.ts +0 -2
  223. package/dist/pragma/fn.d.ts +0 -7
  224. package/dist/pragma/index.d.ts +0 -7
  225. package/dist/pragma/is.d.ts +0 -10
  226. package/dist/switchable.d.ts +0 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","sources":["../../src/vite/plugin.ts"],"sourcesContent":["/**\n * Sygnal Vite Plugin\n *\n * Auto-configures JSX, wires up HMR with state preservation and, in dev,\n * turns on Sygnal's diagnostics (runtime checks and the static checker).\n * Nothing it adds in dev reaches a production build.\n *\n * Usage:\n * import sygnal from 'sygnal/vite'\n * export default defineConfig({ plugins: [sygnal()] })\n *\n * What it does:\n * 1. Configures the automatic JSX transform with sygnal as the import source:\n * `oxc` (Vite 8), plus `esbuild` under Vite 7 and older\n * 2. Detects files that call `run()` from sygnal and auto-injects HMR wiring\n * 3. Dev mode (`vite` / `vite dev` only; never `vite build`). Into every\n * file that imports `run` from sygnal (including entries with manual HMR\n * wiring or `disableHmr`) it inserts, on an existing line:\n *\n * if (globalThis.__SYGNAL_DEV__ === undefined) globalThis.__SYGNAL_DEV__ = true;\n * import 'sygnal/diagnostics';import 'virtual:sygnal/dev';\n *\n * The flag turns on runtime diagnostics in 'warn' mode; 'sygnal/diagnostics'\n * registers the runtime checks (SYG101-106, 201, 202, 301, 401, ...);\n * 'virtual:sygnal/dev' logs static-check results in the browser console\n * (see 5). With `diagnostics: { strict: true }` the snippet also sets\n * `globalThis.__SYGNAL_STRICT__ = true` (same guard), which turns on the\n * strict (SYG5xx) runtime checks of 'sygnal/diagnostics'. The snippet goes\n * after any shebang line and directive prologue ('use strict',\n * 'use client'); line numbers are unchanged and the transform returns a\n * sourcemap. Opt out per app with `run(App, drivers, { diagnostics: 'off' })`\n * or for the whole dev server with `sygnal({ diagnostics: 'off' })`.\n * 4. `diagnostics` option. The runtime core only understands\n * `__SYGNAL_DEV__ === true` ('warn'), so another mode or an ignore list\n * is passed as run()'s own `diagnostics` option: imports of 'sygnal'\n * from the entry files above resolve to a dev-only wrapper module\n * ('\\0sygnal-dev:runtime') that re-exports sygnal with a run() that adds\n * `diagnostics: { mode, ignore }` unless the call sets `diagnostics`\n * itself. With the default ('warn', no ignore list) there is no wrapper.\n * 5. `check` option: runs sygnal-check (an optional dependency, loaded\n * lazily from the project; `strict` defaults to `diagnostics.strict`)\n * over `include` (default: the existing ones of src/, pages/ and\n * renderer/, else the project root, with a notice) when the dev\n * server starts and again after every source file change. Results go to\n * the terminal in sygnal-check's format, and to the browser as a\n * 'sygnal:check' HMR event that the dev client ('virtual:sygnal/dev')\n * logs with console.warn (non-disruptive). The dev client asks for the\n * current findings when the page loads ('sygnal:check:request'), and only\n * that client is answered; after a source change the new findings go to\n * every connected client, and only when they changed. Error-severity\n * findings also open Vite's error overlay (`overlay: false`: never).\n * sygnal-check's codes are currently all warnings or info, so in practice\n * everything goes to the console. Warnings never use the overlay: while\n * one is open Vite's client reloads the page on the next HMR update\n * (`overlay: 'warn'` is treated as 'error', with a notice). The dev\n * client closes a sygnal-check overlay before each update, and the\n * server sends it again after the re-check, so it never causes a reload\n * and doesn't go stale. A missing sygnal-check is skipped silently; a\n * checker that throws only logs a warning.\n * 6. Vitest (process.env.VITEST): appends the package's 'sygnal/diagnostics'\n * ESM file to `test.setupFiles` (merged with a string or array value;\n * not added twice), so renderComponent tests get the runtime checks.\n * Its directory is added to the resolved `server.fs.allow` (G-050):\n * in jsdom / happy-dom environments Vitest loads setup files through\n * Vite's /@fs/ URLs, which a linked sygnal outside the workspace would\n * otherwise fail. Opt out with `vitestSetup: false`. Under Vitest the transform adds\n * nothing (no flags, HMR wiring, run() wrapper, dev client or checker):\n * a __SYGNAL_DEV__ / __SYGNAL_STRICT__ flag set by one test file would\n * leak into later test files of the same worker, and renderComponent()\n * manages the diagnostics modes itself.\n * 7. Vike and Astro (G-014): the app is started by sygnal's own client\n * entry, which user code doesn't import. Client-side imports of\n * 'sygnal/vike/onRenderClient' resolve to a dev wrapper that sets the\n * flag and loads the checks first. Astro resolves its renderer entry on\n * the server and the browser loads the file itself, so the same snippet\n * is added to sygnal's 'astro/client' file by the transform. That file\n * imports the public 'sygnal' entry (one shared core, B-019), so its\n * 'sygnal' import gets the run() wrapper too: every `diagnostics` mode\n * and ignore list works for islands. The sygnal/astro integration adds\n * this plugin in `astro dev`.\n *\n * Why not Vite's `define`? Vite's dependency optimizer does not apply user\n * `define` replacements to pre-bundled dependencies (only process.env.NODE_ENV),\n * so a `define` would never reach sygnal's own code when sygnal is pre-bundled.\n * Vite's client does copy `define` entries onto globalThis at runtime, but only\n * when `/@vite/client` is loaded (not under SSR or Vitest, where it would also\n * switch diagnostics on for every test run). Injecting the flag into the\n * entry file that calls run() is deterministic and scoped to the dev app; it\n * runs before run() is called, which is when the diagnostics mode is resolved.\n *\n * The HMR transform finds the pattern:\n * import { run } from 'sygnal'\n * import App from './App.jsx'\n * run(App)\n *\n * And appends:\n * if (import.meta.hot) {\n * import.meta.hot.accept('./App.jsx', __sygnal.hmr)\n * import.meta.hot.dispose(__sygnal.dispose)\n * }\n *\n * HMR wiring is only added for a recognized top-level (column 0) run()\n * statement whose result reference is actually defined (see RUN_CALL_RE). It\n * is skipped — the dev flag is still injected — for any other shape (e.g.\n * `app = run(App)`, nested or indented calls), for test files (*.test.*,\n * *.spec.*) and under Vitest (process.env.VITEST).\n */\n// Node built-ins (the plugin runs in Node). The package has no @types/node.\n// @ts-ignore\nimport fs from 'node:fs'\n// @ts-ignore\nimport path from 'node:path'\n// @ts-ignore\nimport { createRequire } from 'node:module'\n// @ts-ignore\nimport { pathToFileURL } from 'node:url'\n\nconst nodeProcess: any = (globalThis as any).process\n\nexport type DiagnosticsMode = 'off' | 'collect' | 'warn' | 'error'\n\nexport interface DiagnosticsPluginOptions {\n /** Runtime diagnostics mode in dev. @default 'warn' */\n mode?: DiagnosticsMode\n /** Strict (canonical-form, SYG5xx) runtime checks: sets globalThis.__SYGNAL_STRICT__. @default false */\n strict?: boolean\n /** Diagnostic codes to drop, e.g. ['SYG105'] */\n ignore?: string[]\n}\n\nexport interface CheckPluginOptions {\n /** Also run sygnal-check's strict (SYG5xx) rules. @default `diagnostics.strict` */\n strict?: boolean\n /**\n * Files, directories or globs to check, relative to the Vite root.\n * @default the existing ones of ['src', 'pages', 'renderer'], else the project root\n */\n include?: string[]\n /** Codes to drop. @default the `diagnostics` ignore list */\n ignore?: string[]\n /**\n * Error-severity findings also open Vite's error overlay ('error', the\n * default); false: never. All findings are logged in the terminal and the\n * browser console. Warnings never use the overlay (Vite reloads the page on\n * the next update while one is open): 'warn' is accepted but treated as\n * 'error'. sygnal-check currently reports no error-severity codes.\n * @default 'error'\n */\n overlay?: 'error' | 'warn' | false\n}\n\nexport interface SygnalPluginOptions {\n /**\n * Disable automatic JSX configuration.\n * Set to true if you want to configure JSX yourself.\n * @default false\n */\n disableJsx?: boolean\n\n /**\n * Disable automatic HMR wiring.\n * Set to true if you want to handle HMR manually.\n * @default false\n */\n disableHmr?: boolean\n\n /**\n * Runtime diagnostics in dev (`vite`, not `vite build`): a mode, or\n * { mode, strict, ignore }. 'off' injects nothing. A `diagnostics` option\n * passed to run() itself still wins.\n * @default 'warn'\n */\n diagnostics?: DiagnosticsMode | DiagnosticsPluginOptions\n\n /**\n * Run sygnal-check in dev on startup and on file changes. Skipped silently\n * when sygnal-check isn't installed.\n * @default true\n */\n check?: boolean | CheckPluginOptions\n\n /**\n * Under Vitest, add 'sygnal/diagnostics' to `test.setupFiles` so tests get\n * the runtime checks.\n * @default true\n */\n vitestSetup?: boolean\n}\n\n// Virtual modules (dev server only)\nconst DEV_CLIENT = 'virtual:sygnal/dev'\nconst DEV_CLIENT_ID = '\\0' + DEV_CLIENT\nconst RUNTIME_ID = '\\0sygnal-dev:runtime'\nconst VIKE_CLIENT = 'sygnal/vike/onRenderClient'\nconst VIKE_CLIENT_ID = '\\0sygnal-dev:vike-client'\nconst CHECK_EVENT = 'sygnal:check'\n// Sent by the dev client when it loads: the server answers that client only\nconst CHECK_REQUEST = 'sygnal:check:request'\nconst OVERLAY_PLUGIN = 'sygnal-check'\n// Register the runtime checks with the core that loaded last (see the Vike wrapper)\nconst REINSTALL_IMPORT = `import { installChecks as __sygnalInstallChecks } from 'sygnal/diagnostics';`\nconst REINSTALL_CALL = 'try { __sygnalInstallChecks() } catch (e) { console.warn(e) }\\n'\n\nexport default function sygnal(options: SygnalPluginOptions = {}) {\n const { disableJsx = false, disableHmr = false, vitestSetup = true } = options\n const diagnostics = normalizeDiagnostics(options.diagnostics)\n const devOn = diagnostics.mode !== 'off'\n // A mode other than the flag's 'warn', or an ignore list, needs run()'s option\n const wrapRun = devOn && (diagnostics.mode !== 'warn' || diagnostics.ignore.length > 0)\n let isServe = false\n let isVitest = false\n let root: string = nodeProcess.cwd()\n // Files whose `import ... from 'sygnal'` resolves to the run() wrapper\n const runtimeImporters = new Set<string>()\n // Statements run before the app starts: dev flag (+ strict flag)\n const flags = DEV_FLAG + (diagnostics.strict ? STRICT_FLAG : '')\n const devImports = `import 'sygnal/diagnostics';import '${DEV_CLIENT}';`\n let astroClient: Set<string> | undefined\n\n return {\n name: 'vite-plugin-sygnal',\n\n config(this: any, config: any, env: { command: string }) {\n isServe = env.command === 'serve'\n isVitest = !!nodeProcess?.env?.VITEST\n root = config?.root ? path.resolve(config.root) : nodeProcess.cwd()\n\n const result: any = {\n // Ensure sygnal is bundled for SSR rather than externalized.\n // Without this, Node fails to resolve sygnal's exports from\n // Vike's server chunks in production builds.\n ssr: {\n noExternal: ['sygnal'],\n },\n }\n\n if (!disableJsx) {\n result.oxc = {\n jsx: {\n runtime: 'automatic' as const,\n importSource: 'sygnal',\n },\n }\n // Vite 7 and older (Astro 6, Vitest on Vite 7) compile JSX with\n // esbuild and ignore `oxc` (B-027); Vite 8 warns about `esbuild`\n // from a plugin, so it is only set below Vite 8.\n if (viteMajor(this, root) < 8) {\n result.esbuild = { jsx: 'automatic', jsxImportSource: 'sygnal' }\n }\n // Vite 8's dependency scanner doesn't use the `oxc` options: without\n // this it compiles JSX for React, fails to resolve\n // react/jsx-dev-runtime and skips pre-bundling (a reload on first load).\n if (isServe && !isVitest) {\n result.optimizeDeps = { rolldownOptions: { transform: { jsx: { runtime: 'automatic', importSource: 'sygnal' } } } }\n }\n }\n\n if (isVitest) {\n if (vitestSetup) {\n const setup = diagnosticsSetupFile(root)\n const existing = ([] as string[]).concat(config?.test?.setupFiles || [])\n const loaded = existing.some(f => typeof f === 'string' &&\n (f === 'sygnal/diagnostics' || (!!setup && path.resolve(root, f) === setup)))\n // Vite merges arrays (and a string with an array) by concatenation\n if (setup && !loaded) result.test = { setupFiles: [setup] }\n }\n } else if (isServe && devOn && sygnalInNodeModules(root)) {\n // The dependency scan reads the original sources, which don't import\n // the checks entry: pre-bundle it with sygnal so the first page load\n // doesn't trigger a re-optimization. Only for an installed sygnal: a\n // linked one is served from source, and pre-bundling the checks alone\n // would give them their own copy of the core.\n result.optimizeDeps = { ...result.optimizeDeps, include: ['sygnal/diagnostics'] }\n }\n\n return result\n },\n\n configResolved(config: any) {\n if (config?.root) root = config.root\n // G-050: Vitest loads setup files by URL (/@fs/...) in browser-like\n // environments (jsdom, happy-dom), and Vite refuses files outside\n // server.fs.allow, which is the project's workspace by default. A linked\n // (or hoisted) sygnal lives outside it, so allow its setup file's\n // directory. The resolved list already holds Vite's defaults.\n if (isVitest) {\n const setup = diagnosticsSetupFile(root)\n const allow = config?.server?.fs?.allow\n if (setup && Array.isArray(allow)) {\n const dir = path.dirname(setup)\n const inside = (base: string) => {\n const rel = path.relative(path.resolve(base), dir)\n return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel))\n }\n if (!allow.some(inside)) allow.push(dir)\n }\n }\n },\n\n resolveId: {\n order: 'pre' as const,\n async handler(this: any, source: string, importer: string | undefined, opts: any) {\n if (!isServe || isVitest) return null\n if (source === DEV_CLIENT) return DEV_CLIENT_ID\n if (source === 'sygnal' && importer && wrapRun && runtimeImporters.has(cleanId(importer))) {\n return RUNTIME_ID\n }\n if (source === VIKE_CLIENT && devOn && !opts?.ssr) {\n if (importer !== VIKE_CLIENT_ID) return VIKE_CLIENT_ID\n // The wrapper's own import of the real entry: resolve it normally.\n // The real Vike client's run() then gets the run() wrapper too, when\n // it is served unbundled (a pre-bundled copy stays in 'warn' mode).\n const real = await this.resolve(source, importer, { ...opts, skipSelf: true })\n if (real && wrapRun) runtimeImporters.add(cleanId(real.id))\n return real\n }\n return null\n },\n },\n\n load(id: string) {\n if (id === DEV_CLIENT_ID) return devClientModule()\n if (id === RUNTIME_ID) return runtimeModule(diagnostics)\n // The checks register again once the real entry has loaded: a\n // pre-bundled copy of it can carry its own copy of the Sygnal core\n // (e.g. with a linked sygnal), which then holds the diagnostics bridge.\n if (id === VIKE_CLIENT_ID) {\n return `${devImports}${REINSTALL_IMPORT}\\nexport * from '${VIKE_CLIENT}';\\n${flags}\\n${REINSTALL_CALL}`\n }\n return null\n },\n\n configureServer(server: any) {\n if (isVitest || options.check === false) return\n const checkOptions = typeof options.check === 'object' && options.check ? options.check : {}\n // Deferred: the dev server doesn't wait for the first check\n const checkDefaults = { strict: diagnostics.strict, ignore: diagnostics.ignore }\n setTimeout(() => {\n startChecker(server, root, checkOptions, checkDefaults, options.check !== undefined)\n .catch(err => server?.config?.logger?.warn?.(`[sygnal] sygnal-check could not start: ${err?.message || err}`))\n }, 0)\n },\n\n transform(code: string, id: string, opts?: { ssr?: boolean }) {\n if (!isServe) return null\n\n // sygnal/astro/client (Astro islands): flags + checks first. It imports\n // the public 'sygnal' entry (the app's core, B-019), which resolves to\n // the run() wrapper when the diagnostics option needs it.\n if (devOn && !isVitest && !opts?.ssr) {\n astroClient = astroClient || astroClientFiles(root)\n if (astroClient.has(cleanId(id))) {\n if (wrapRun) runtimeImporters.add(cleanId(id))\n return withSourcemap(code, [[0, flags + devImports]], '', id)\n }\n }\n\n // Only transform JS/TS/JSX/TSX files\n if (!/\\.[jt]sx?$/.test(id)) return null\n // Skip node_modules\n if (id.includes('node_modules')) return null\n // Must import run from sygnal\n if (!code.includes('sygnal')) return null\n\n // Match against the code with comments blanked out (same offsets), so\n // e.g. `// run(App)` or a commented-out import is never matched.\n const noComments = blankOut(code, false)\n\n // Find: import { run, ... } from 'sygnal'\n const runImportRe = /import\\s+\\{[^}]*\\brun\\b[^}]*\\}\\s+from\\s+['\"]sygnal['\"]/\n if (!runImportRe.test(noComments)) return null\n\n // Dev snippet: injected into every file that imports run() — also when\n // HMR wiring below is skipped. Inserted after any shebang line and\n // directive prologue, without adding a line. Nothing under Vitest: a\n // global flag set by one test file would leak dev/strict mode into the\n // later test files of the same worker; there the checks come from\n // test.setupFiles and renderComponent() manages the modes.\n const inserts: Array<[number, string]> = []\n if (devOn && !isVitest) {\n inserts.push(flagInsertion(code, flags + devImports))\n if (wrapRun) runtimeImporters.add(cleanId(id))\n }\n const done = (tail = '') => (inserts.length || tail ? withSourcemap(code, inserts, tail, id) : null)\n\n // Skip HMR wiring if disabled, in tests, or already manually wired\n if (disableHmr || isVitest || /\\.(test|spec)\\.[jt]sx?$/.test(id)) return done()\n if (noComments.includes('import.meta.hot')) return done()\n\n // Strings and template literals blanked out too: a statement-level match only\n const runCall = RUN_CALL_RE.exec(blankOut(code, true))\n if (!runCall) return done()\n const [, binding, componentName] = runCall\n\n // Find the import path for this component\n // Handles: import App from './App.jsx'\n // import App from \"./App\"\n const componentImportRe = new RegExp(\n `import\\\\s+${componentName.replace(/\\$/g, '\\\\$')}\\\\s+from\\\\s+['\"]([^'\"]+)['\"]`\n )\n const componentImportMatch = noComments.match(componentImportRe)\n if (!componentImportMatch) return done()\n const componentPath = componentImportMatch[1]\n\n // Pattern 3: bare run(App, ...) — no result captured → const __sygnal = run(\n if (!binding) {\n inserts.push([runCall.index, 'const __sygnal = '])\n return done(hmrBlock(componentPath, '__sygnal.hmr', '__sygnal.dispose'))\n }\n\n // Pattern 2: const app = run(App, ...)\n if (binding[0] !== '{') {\n return done(hmrBlock(componentPath, `${binding}.hmr`, `${binding}.dispose`))\n }\n\n // Pattern 1: const { hmr, dispose, ... } = run(App, ...) — only when both\n // are bound under their own names (a rename would leave them undefined)\n const names = binding.slice(1, -1).split(',').map(s => s.trim())\n if (names.includes('hmr') && names.includes('dispose')) {\n return done(hmrBlock(componentPath, 'hmr', 'dispose'))\n }\n return done()\n },\n }\n}\n\n/**\n * Major version of the running Vite: from the plugin context (this.meta,\n * Vite 7+), else from the vite package the project resolves. Infinity when\n * unknown (treated as Vite 8+: no `esbuild` option).\n */\nfunction viteMajor(ctx: any, root: string): number {\n const fromMeta = ctx?.meta?.viteVersion\n if (typeof fromMeta === 'string') return parseInt(fromMeta, 10)\n if (ctx?.meta?.rolldownVersion) return 8\n try {\n const req = createRequire(path.join(root, 'package.json'))\n const v = JSON.parse(fs.readFileSync(req.resolve('vite/package.json'), 'utf8')).version\n const major = parseInt(v, 10)\n if (major > 0) return major\n } catch (_) {}\n return Infinity\n}\n\ninterface NormalizedDiagnostics { mode: DiagnosticsMode, strict: boolean, ignore: string[] }\n\nconst MODES: DiagnosticsMode[] = ['off', 'collect', 'warn', 'error']\n\nfunction normalizeDiagnostics(value: SygnalPluginOptions['diagnostics']): NormalizedDiagnostics {\n const o: DiagnosticsPluginOptions = typeof value === 'string' ? { mode: value } : value || {}\n const mode = o.mode === undefined ? 'warn' : o.mode\n if (!MODES.includes(mode)) {\n throw new Error(`[vite-plugin-sygnal] diagnostics mode must be one of ${MODES.map(m => `'${m}'`).join(', ')}; got ${JSON.stringify(mode)}`)\n }\n return { mode, strict: !!o.strict, ignore: Array.isArray(o.ignore) ? o.ignore.map(String) : [] }\n}\n\n/** Module id without a query or hash. */\nfunction cleanId(id: string): string {\n return id.replace(/[?#].*$/, '')\n}\n\n/** 'virtual:sygnal/dev': logs sygnal-check results in the browser console. */\nfunction devClientModule(): string {\n // Vite's client reloads the page on the first HMR update while an error\n // overlay is open. A sygnal-check overlay is closed before each update (the\n // server sends it again after the re-check), so it never causes a reload.\n return `if (import.meta.hot) {\n let shown = 0;\n let ours = false;\n const closeOurs = () => {\n if (!ours || typeof document === 'undefined') return;\n document.querySelectorAll('vite-error-overlay').forEach((n) => n.close ? n.close() : n.remove());\n ours = false;\n };\n import.meta.hot.on('vite:error', (payload) => {\n ours = !!(payload && payload.err && payload.err.plugin === '${OVERLAY_PLUGIN}');\n });\n import.meta.hot.on('vite:beforeUpdate', closeOurs);\n import.meta.hot.on('${CHECK_EVENT}', (payload) => {\n const list = (payload && payload.diagnostics) || [];\n if (!list.some((d) => d.severity === 'error')) closeOurs();\n if (!list.length) {\n if (shown) console.info('[sygnal-check] all findings resolved');\n shown = 0;\n return;\n }\n shown = list.length;\n for (const d of list) console[d.severity === 'error' ? 'error' : 'warn']('[sygnal-check] ' + d.text);\n console.info('[sygnal-check] ' + payload.summary);\n });\n import.meta.hot.send('${CHECK_REQUEST}');\n}\n`\n}\n\n/** '\\0sygnal-dev:runtime': sygnal with a run() that adds the plugin's diagnostics option. */\nfunction runtimeModule(d: NormalizedDiagnostics): string {\n const option = JSON.stringify({ mode: d.mode, ignore: d.ignore })\n return `import { run as __run } from 'sygnal';\nexport * from 'sygnal';\nexport function run(app, drivers, options) {\n if (options && options.diagnostics !== undefined) return __run(app, drivers, options);\n return __run(app, drivers, Object.assign({}, options, { diagnostics: ${option} }));\n}\n`\n}\n\n/** Directory of the 'sygnal' package the project resolves, or undefined. */\nfunction sygnalPackageDir(root: string): string | undefined {\n try {\n const req = createRequire(path.join(root, 'package.json'))\n let dir = path.dirname(req.resolve('sygnal'))\n while (dir !== path.dirname(dir)) {\n const pkgFile = path.join(dir, 'package.json')\n if (fs.existsSync(pkgFile) && JSON.parse(fs.readFileSync(pkgFile, 'utf8')).name === 'sygnal') return dir\n dir = path.dirname(dir)\n }\n } catch (_) {}\n return undefined\n}\n\n/** Real paths of sygnal's 'astro/client' ESM file. */\nfunction astroClientFiles(root: string): Set<string> {\n const files = new Set<string>()\n const dir = sygnalPackageDir(root)\n if (!dir) return files\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))\n const entry = pkg.exports?.['./astro/client']\n const rel = typeof entry === 'string' ? entry : entry?.import\n if (typeof rel !== 'string') return files\n const file = path.resolve(dir, rel)\n files.add(file.split(path.sep).join('/'))\n files.add(fs.realpathSync(file).split(path.sep).join('/'))\n } catch (_) {}\n return files\n}\n\nfunction sygnalInNodeModules(root: string): boolean {\n const dir = sygnalPackageDir(root)\n if (!dir) return false\n try {\n return fs.realpathSync(dir).split(path.sep).includes('node_modules')\n } catch (_) {\n return false\n }\n}\n\n/**\n * Absolute path of the ESM build of 'sygnal/diagnostics' (its \"import\"\n * condition), so the checks share the core instance the tests import.\n */\nfunction diagnosticsSetupFile(root: string): string | undefined {\n const dir = sygnalPackageDir(root)\n if (!dir) return undefined\n try {\n const pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'))\n const entry = pkg.exports?.['./diagnostics']\n const rel = typeof entry === 'string' ? entry : entry?.import?.default || entry?.import || entry?.default\n if (typeof rel !== 'string') return undefined\n const file = path.resolve(dir, rel)\n return fs.existsSync(file) ? file : undefined\n } catch (_) {\n return undefined\n }\n}\n\n/** Load sygnal-check from the project (optional dependency); undefined when it is missing. */\nasync function loadSygnalCheck(root: string): Promise<any> {\n try {\n const file = createRequire(path.join(root, 'package.json')).resolve('sygnal-check')\n return await import(/* @vite-ignore */ pathToFileURL(file).href)\n } catch (_) {}\n try {\n const name = 'sygnal-check'\n return await import(/* @vite-ignore */ name)\n } catch (_) {\n return undefined\n }\n}\n\nconst SOURCE_RE = /\\.[cm]?[jt]sx?$/\n\n/** sygnal-check's one-line format: `file:line:col CODE [severity] Component: message (fix)` */\nfunction formatLine(d: any): string {\n const where = d.file ? `${d.file}:${d.line}:${d.column}` : '<sygnal-check>'\n const sev = d.severity === 'warn' ? '' : ` [${d.severity}]`\n return `${where} ${d.code}${sev} ${d.component ? d.component + ': ' : ''}${d.message}${d.fix ? ` (${d.fix})` : ''}`\n}\n\n// Source directories checked by default, those that exist (Vike apps use\n// pages/ and renderer/, often without src/)\nconst DEFAULT_INCLUDE = ['src', 'pages', 'renderer']\n\n/**\n * What sygnal-check checks: `include` when given, else the existing default\n * directories, else the project root (sygnal-check skips node_modules, dist\n * and other build output). Logs one notice when the default finds no\n * directory, or when none of the given paths exists, so an empty check is\n * never a silent all-clear.\n */\nfunction checkInclude(root: string, include: string[] | undefined, notice: (m: string) => void): string[] {\n const exists = (p: string) => /[*?[{]/.test(p) || fs.existsSync(path.resolve(root, p))\n if (include && include.length) {\n if (!include.some(exists)) notice(`[sygnal] sygnal-check: none of check.include (${include.join(', ')}) exists under ${root}, so nothing is checked`)\n return include\n }\n const dirs = DEFAULT_INCLUDE.filter(exists)\n if (dirs.length) return dirs\n notice(`[sygnal] sygnal-check: no ${DEFAULT_INCLUDE.join('/, ')}/ directory under ${root}; checking the project root (set check.include to choose)`)\n return ['.']\n}\n\n/** Run sygnal-check now and after source changes; report to the terminal and the browser. */\nasync function startChecker(server: any, root: string, opts: CheckPluginOptions,\n defaults: { strict: boolean, ignore: string[] }, explicit: boolean) {\n const mod = await loadSygnalCheck(root)\n const logger = server?.config?.logger || console\n if (!mod || typeof mod.check !== 'function') {\n if (explicit) logger.info('[sygnal] sygnal-check is not installed, so static checks are off (npm i -D sygnal-check)')\n return\n }\n const include = checkInclude(root, opts.include, (m: string) => logger.info(m))\n const ignore = opts.ignore || defaults.ignore\n const strict = opts.strict === undefined ? defaults.strict : !!opts.strict\n // Only error-severity findings open Vite's overlay: while an overlay is open\n // Vite's client reloads the page on the first HMR update, so warnings stay\n // in the terminal and the browser console. overlay: 'warn' is treated as\n // 'error' (with a one-time notice).\n if (opts.overlay === 'warn') {\n logger.info(\"[sygnal] check.overlay: 'warn' is treated as 'error': warnings go to the browser console, not Vite's error overlay (an open overlay makes Vite reload the page on the next update)\")\n }\n const overlay = opts.overlay !== false\n let lastKey: string | undefined\n let payload: any = null\n let overlayErr: any = null\n\n const event = () => ({ type: 'custom', event: CHECK_EVENT, data: payload })\n const errorMessage = () => ({ type: 'error', err: overlayErr })\n // Every connected client (after a source change). An error with no client\n // connected would be buffered by Vite and shown on the next page load.\n const broadcast = (findingsChanged: boolean) => {\n const ws = server.ws\n if (!ws || typeof ws.send !== 'function') return\n try {\n if (findingsChanged && payload) ws.send(event())\n if (overlayErr && !(ws.clients && ws.clients.size === 0)) ws.send(errorMessage())\n } catch (_) {}\n }\n\n const run = (initial = false) => {\n let diags: any[]\n try {\n diags = mod.check(include, { cwd: root, strict, ignore })\n } catch (err: any) {\n logger.warn(`[sygnal] sygnal-check failed: ${err?.message || err}`, { timestamp: true })\n return\n }\n const shown = diags.filter(d => d.severity !== 'info')\n const lines = shown.map(formatLine)\n const key = lines.join('\\n')\n const changed = key !== lastKey\n if (changed) {\n lastKey = key\n const text: string = typeof mod.formatDiagnostics === 'function'\n ? mod.formatDiagnostics(diags)\n : lines.concat(`sygnal-check: ${shown.length} finding(s)`).join('\\n')\n const summary = text.split('\\n').pop() || ''\n if (shown.length) logger.warn(text, { timestamp: true })\n else logger.info(summary, { timestamp: true })\n payload = {\n summary,\n diagnostics: shown.map((d, i) => ({ code: d.code, severity: d.severity, file: d.file, line: d.line, column: d.column, text: lines[i] })),\n }\n const forOverlay = overlay ? shown.filter(d => d.severity === 'error') : []\n const first = forOverlay[0]\n overlayErr = first ? {\n plugin: OVERLAY_PLUGIN,\n message: forOverlay.map(formatLine).join('\\n'),\n stack: '',\n id: path.resolve(root, first.file || ''),\n loc: { file: path.resolve(root, first.file || ''), line: first.line, column: first.column },\n } : null\n }\n // The first check runs before any page is open; pages ask for the\n // findings when they load (CHECK_REQUEST). After a change the overlay is\n // sent again even when the findings are the same: the HMR update closed it.\n if (!initial) broadcast(changed)\n }\n\n run(true)\n // A page that loads (or reloads) asks for the current findings: answer\n // that client only, never every client.\n try {\n server.ws?.on?.(CHECK_REQUEST, (_data: any, client: any) => {\n try {\n if (payload) client?.send?.(event())\n if (overlayErr) client?.send?.(errorMessage())\n } catch (_) {}\n })\n } catch (_) {}\n\n let timer: any\n const onChange = (file: string) => {\n if (!SOURCE_RE.test(file) || file.split(/[\\\\/]/).includes('node_modules')) return\n clearTimeout(timer)\n timer = setTimeout(run, 100)\n }\n const watcher = server?.watcher\n if (watcher && typeof watcher.on === 'function') {\n watcher.on('change', onChange)\n watcher.on('add', onChange)\n watcher.on('unlink', onChange)\n }\n try { server.httpServer?.once?.('close', () => clearTimeout(timer)) } catch (_) {}\n}\n\nconst DEV_FLAG = 'if (globalThis.__SYGNAL_DEV__ === undefined) globalThis.__SYGNAL_DEV__ = true;'\nconst STRICT_FLAG = 'if (globalThis.__SYGNAL_STRICT__ === undefined) globalThis.__SYGNAL_STRICT__ = true;'\n\n// A top-level (column 0) run(Component, ...) statement: bare, or declaring a\n// new binding. Assignments to existing variables, nested calls and indented\n// calls (e.g. inside a function or test callback) do not match (B-007). It is\n// matched against the code with comments and strings blanked out.\nconst RUN_CALL_RE = /^(?:(?:const|let|var)\\s+(\\{[^}]*\\}|[\\w$]+)\\s*=\\s*)?run\\s*\\(\\s*([A-Z][\\w$]*)/m\n\n// Comments, string literals and template literals (a regex literal containing\n// a quote or `//` can over-blank; that only ever skips HMR wiring).\nconst COMMENT_OR_STRING_RE = /\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?(?:\\*\\/|$)|(['\"])(?:\\\\.|(?!\\1)[^\\\\\\n])*\\1?|`(?:\\\\[\\s\\S]|[^\\\\`])*`?/g\n\n/** Replace comments (and, with `strings`, string/template literals) by spaces, keeping offsets and newlines. */\nfunction blankOut(code: string, strings: boolean): string {\n return code.replace(COMMENT_OR_STRING_RE, m =>\n !strings && m[0] !== '/' ? m : m.replace(/[^\\n]/g, ' ')\n )\n}\n\n// One directive ('use strict', \"use client\", ...) with any leading whitespace\n// and comments. It must end with `;` (group 2) or at the end of its line.\nconst DIRECTIVE_RE = /(?:\\s|\\/\\/[^\\n]*|\\/\\*[\\s\\S]*?\\*\\/)*(['\"])(?:\\\\.|(?!\\1)[^\\\\\\n])*\\1(?:[ \\t]*(;)|(?=[ \\t]*(?:\\/\\/[^\\n]*|\\/\\*[^\\n]*?\\*\\/)?[ \\t]*(?:\\r?\\n|$)))/y\n\n/** Insert `text` (the dev snippet) after a shebang line and the directive prologue. */\nfunction flagInsertion(code: string, text: string): [number, string] {\n let at = code.startsWith('#!') ? (code.indexOf('\\n') + 1 || code.length) : 0\n let semicolon = true\n DIRECTIVE_RE.lastIndex = at\n let m\n while ((m = DIRECTIVE_RE.exec(code))) {\n at = DIRECTIVE_RE.lastIndex\n semicolon = !!m[2]\n }\n return [at, (semicolon ? '' : ';') + text]\n}\n\nconst B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\nfunction vlq(n: number): string {\n let v = n < 0 ? (-n << 1) | 1 : n << 1\n let out = ''\n do {\n let digit = v & 31\n v >>>= 5\n if (v) digit |= 32\n out += B64[digit]\n } while (v)\n return out\n}\n\n/**\n * Apply single-line insertions (at offsets in the original code) plus an\n * appended tail, and build a v3 sourcemap without extra dependencies. No line\n * is added before the tail, so every original line maps to itself; on a line\n * with an insertion, the text after it maps back to its original column.\n */\nfunction withSourcemap(code: string, inserts: Array<[number, string]>, tail: string, id: string) {\n inserts.sort((a, b) => a[0] - b[0])\n let out = ''\n let last = 0\n for (const [at, text] of inserts) {\n out += code.slice(last, at) + text\n last = at\n }\n out += code.slice(last) + tail\n\n let offset = 0\n let k = 0\n let prevLine = 0\n let prevCol = 0\n const mappings = code.split('\\n').map((line, i) => {\n const segments: Array<[number, number]> = [[0, 0]] // [generated column, original column]\n let shift = 0\n while (k < inserts.length && inserts[k][0] <= offset + line.length) {\n const col = inserts[k][0] - offset\n shift += inserts[k][1].length\n segments.push([col + shift, col])\n k++\n }\n offset += line.length + 1\n let genCol = 0\n return segments.map(([gen, col]) => {\n const seg = vlq(gen - genCol) + 'A' + vlq(i - prevLine) + vlq(col - prevCol)\n genCol = gen\n prevLine = i\n prevCol = col\n return seg\n }).join(',')\n }).join(';')\n\n return {\n code: out,\n map: { version: 3, sources: [id], sourcesContent: [code], names: [] as string[], mappings },\n }\n}\n\nfunction hmrBlock(componentPath: string, hmrRef: string, disposeRef: string): string {\n return `\nif (import.meta.hot) {\n import.meta.hot.accept('${componentPath}', ${hmrRef})\n import.meta.hot.dispose(${disposeRef})\n}\n`\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GG;AACH;AACA;AASA,MAAM,WAAW,GAAS,UAAkB,CAAC,OAAO,CAAA;AAwEpD;AACA,MAAM,UAAU,GAAG,oBAAoB,CAAA;AACvC,MAAM,aAAa,GAAG,IAAI,GAAG,UAAU,CAAA;AACvC,MAAM,UAAU,GAAG,sBAAsB,CAAA;AACzC,MAAM,WAAW,GAAG,4BAA4B,CAAA;AAChD,MAAM,cAAc,GAAG,0BAA0B,CAAA;AACjD,MAAM,WAAW,GAAG,cAAc,CAAA;AAClC;AACA,MAAM,aAAa,GAAG,sBAAsB,CAAA;AAC5C,MAAM,cAAc,GAAG,cAAc,CAAA;AACrC;AACA,MAAM,gBAAgB,GAAG,CAAA,4EAAA,CAA8E,CAAA;AACvG,MAAM,cAAc,GAAG,iEAAiE,CAAA;AAE1E,SAAU,MAAM,CAAC,UAA+B,EAAE,EAAA;AAC9D,IAAA,MAAM,EAAE,UAAU,GAAG,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,WAAW,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IAC9E,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;AAC7D,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,KAAK,KAAK,CAAA;;AAExC,IAAA,MAAM,OAAO,GAAG,KAAK,KAA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AAQ,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,CAAA;YAC5E,MAAM,GAAG,GAAG,CAAA;YACZ,QAAQ,GAAG,CAAC,CAAA;YACZ,OAAO,GAAG,GAAG,CAAA;AACb,YAAA,OAAO,GAAG,CAAA;AACZ,SAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACd,KAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEZ,OAAO;AACL,QAAA,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAc,EAAE,QAAQ,EAAE;KAC5F,CAAA;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,aAAqB,EAAE,MAAc,EAAE,UAAkB,EAAA;IACzE,OAAO,CAAA;;AAEmB,0BAAA,EAAA,aAAa,MAAM,MAAM,CAAA;4BACzB,UAAU,CAAA;;CAErC,CAAA;AACD;;;;"}
package/llms.txt ADDED
@@ -0,0 +1,250 @@
1
+ # Sygnal
2
+
3
+ > Reactive component framework (Cycle.js Model-View-Intent, JSX views, xstream streams). `npm i sygnal`; Vite: `import sygnal from 'sygnal/vite'`, `plugins: [sygnal()]`; entry: `run(App)`. This file shows only the canonical forms. Other forms still work, but strict mode (`sygnal-check --strict`, runtime `strict: true`) flags them as SYG5xx.
4
+
5
+ ## 1. Mental model
6
+ - A component is a pure view function plus static properties: `.intent` (WHEN: sources → named action streams), `.model` (WHAT: action → one reducer per sink), `.initialState`.
7
+ - There is one state tree. A child sees its parent's whole state, or a slice with `state="key"`. A Collection item sees one array element.
8
+ - Every side effect is a sink of a model entry (STATE, EVENTS, PARENT, EFFECT, custom drivers). JSX never has event handlers (`onClick`).
9
+ - Streams are xstream, not RxJS. An intent's DOM selectors only see the component's own JSX, never a child component's.
10
+
11
+ ## 2. Component anatomy
12
+ ```jsx
13
+ import { ABORT } from 'sygnal'
14
+
15
+ function Counter({ state, context, label }) { // 1st arg: parent props + state, context, children, slots
16
+ return (
17
+ <div className="counter">
18
+ <span>{label} {state.count} (x2 = {state.double})</span>
19
+ <button className="inc">+</button>
20
+ <button className="reset">reset</button>
21
+ </div>
22
+ )
23
+ }
24
+ Counter.initialState = { count: 0 } // root only: a child gets state from its parent (SYG405)
25
+ Counter.calculated = { double: state => state.count * 2 } // or [['count'], fn]; read as state.double
26
+ Counter.context = { total: state => state.count } // all descendants: ({ context }) => context.total
27
+ Counter.intent = ({ DOM }) => ({ // sources: DOM STATE EVENTS CHILD props$ commands$ dispose$ + drivers
28
+ INC: DOM.click('.inc'),
29
+ RESET: DOM.click('.reset'),
30
+ })
31
+ Counter.model = {
32
+ INC: (state, data, next, props) => ({ ...state, count: state.count + 1 }),
33
+ RESET: (state) => (state.count === 0 ? ABORT : { ...state, count: 0 }),
34
+ }
35
+ Counter.onError = (error, { componentName }) => <div className="error">{componentName} failed</div>
36
+ export default Counter
37
+ ```
38
+ - Reducer `(state, data, next, props)`. `data` is the action stream's value. `next('ACTION', data?, delayMs = 10)` dispatches another action. `props` holds the parent's props plus `state`, `context`, `children`, `slots`.
39
+ - Model entry: a function is the STATE reducer. An object `{ STATE, EVENTS, PARENT, EFFECT, LOG, <DRIVER>: fn }` maps each sink to a `(state, data, next, props)` function whose return value goes to that sink. `<SINK>: true` forwards `data` as-is.
40
+ - Built-in actions (model only): `BOOTSTRAP` (once, just after mount), `INITIALIZE` (automatic: sets initialState), `HYDRATE` (SSR data), `DISPOSE` (unmount).
41
+
42
+ ## 3. Canonical examples
43
+ ### State update, ABORT, set / toggle, controlled input
44
+ ```jsx
45
+ import { ABORT, set, toggle } from 'sygnal'
46
+
47
+ function AddTodo({ state }) {
48
+ return (
49
+ <div>
50
+ <input className="draft" value={state.draft} />
51
+ <button className="add">Add</button>
52
+ <button className="help">?</button>
53
+ {state.showHelp && <p className="hint">Type, then Add</p>}
54
+ </div>
55
+ )
56
+ }
57
+ AddTodo.initialState = { draft: '', todos: [], nextId: 1, showHelp: false }
58
+ AddTodo.intent = ({ DOM }) => ({
59
+ DRAFT: DOM.input('.draft').value(), // a bound value={...} needs an input listener (SYG111)
60
+ ADD: DOM.click('.add'),
61
+ HELP: DOM.click('.help'),
62
+ })
63
+ AddTodo.model = {
64
+ DRAFT: set((state, draft) => ({ draft })), // merges: ({ ...state, draft })
65
+ ADD: (state) => {
66
+ const text = state.draft.trim()
67
+ if (!text) return ABORT // "no change" is ABORT, never `return state`
68
+ return { ...state, draft: '', nextId: state.nextId + 1, todos: [...state.todos, { id: state.nextId, text }] }
69
+ },
70
+ HELP: toggle('showHelp'),
71
+ }
72
+ ```
73
+ ### Multi-sink entry + EVENTS between non-adjacent components
74
+ ```jsx
75
+ import { event } from 'sygnal'
76
+
77
+ function SaveButton({ state }) {
78
+ return <button className="save">{state.saving ? 'Saving' : 'Save'}</button>
79
+ }
80
+ SaveButton.intent = ({ DOM }) => ({ SAVE: DOM.click('.save') })
81
+ SaveButton.model = {
82
+ SAVE: {
83
+ STATE: (state) => ({ ...state, saving: true }),
84
+ EVENTS: event('DOC_SAVED', (state) => ({ id: state.id })), // or event('RESET'), event('MODE', 'dark')
85
+ },
86
+ }
87
+
88
+ function Toast({ state }) { // anywhere in the tree: EVENTS is a global bus
89
+ return <p className="toast">{state.lastSaved}</p>
90
+ }
91
+ Toast.intent = ({ EVENTS }) => ({ SAVED: EVENTS.select('DOC_SAVED') }) // emits the payload only
92
+ Toast.model = { SAVED: (state, payload) => ({ ...state, lastSaved: payload.id }) }
93
+ ```
94
+ ### Child → parent (PARENT + CHILD.select), Collection, item removal
95
+ ```jsx
96
+ import { Collection } from 'sygnal'
97
+
98
+ function TaskItem({ state }) {
99
+ return (
100
+ <li className="task" data={{ id: state.id }}>
101
+ {state.title} <button className="pick">pick</button> <button className="remove">x</button>
102
+ </li>
103
+ )
104
+ }
105
+ TaskItem.intent = ({ DOM }) => ({ PICK: DOM.click('.pick'), REMOVE: DOM.click('.remove') })
106
+ TaskItem.model = {
107
+ PICK: { PARENT: (state) => ({ taskId: state.id }) }, // the parent receives exactly this value
108
+ REMOVE: () => undefined, // a Collection item removes itself
109
+ }
110
+
111
+ function TaskList({ state }) {
112
+ return (
113
+ <div>
114
+ <p className="picked">{state.picked}</p>
115
+ <Collection of={TaskItem} from="tasks" className="tasks" />
116
+ </div>
117
+ )
118
+ }
119
+ TaskList.initialState = { picked: null, tasks: [{ id: 1, title: 'Write' }, { id: 2, title: 'Test' }] }
120
+ TaskList.intent = ({ CHILD }) => ({ PICKED: CHILD.select(TaskItem) }) // the function, not a string
121
+ TaskList.model = { PICKED: (state, { taskId }) => ({ ...state, picked: taskId }) }
122
+ ```
123
+ - `from` names an array field; items are keyed by `.id`. Also `filter={t => !t.done}`, `sort="title"`. An item edits its own element (`{ ...state, done: true }`).
124
+ - Switchable: `<Switchable of={{ home: Home, settings: Settings }} current={state.route} />` (optional `state="slice"`).
125
+ ### Commands (parent → child) + EFFECT
126
+ ```jsx
127
+ import { createCommand } from 'sygnal'
128
+
129
+ const player = createCommand()
130
+
131
+ function Player({ state }) {
132
+ return <div className="player">{state.playing ? 'playing' : 'paused'}</div>
133
+ }
134
+ Player.intent = ({ commands$ }) => ({ PLAY: commands$.select('play') }) // emits send()'s data
135
+ Player.model = { PLAY: (state) => ({ ...state, playing: true }) }
136
+
137
+ function Controls({ state }) {
138
+ return <div><button className="play">Play</button><Player commands={player} state="player" /></div>
139
+ }
140
+ Controls.initialState = { player: { playing: false } }
141
+ Controls.intent = ({ DOM }) => ({ PLAY: DOM.click('.play') })
142
+ Controls.model = { PLAY: { EFFECT: () => player.send('play') } } // EFFECT: side effect only, returns nothing
143
+ ```
144
+ ### Drivers (driverFromAsync + errors()), document-level events
145
+ ```jsx
146
+ import { xs } from 'sygnal'
147
+
148
+ function Quote({ state }) {
149
+ return <div><button className="load">Load</button><p className="text">{state.error || state.text}</p></div>
150
+ }
151
+ Quote.initialState = { id: 1, text: '', error: null }
152
+ Quote.intent = ({ DOM, QUOTE }) => ({
153
+ LOAD: xs.merge(DOM.click('.load'), DOM.select('document').events('keydown').key().filter(k => k === 'r')),
154
+ LOADED: QUOTE.select('quote'), // { category: 'quote', value }
155
+ FAILED: QUOTE.errors('quote'), // { error, category, request }; unheard errors are only console.error'd
156
+ })
157
+ Quote.model = {
158
+ LOAD: { QUOTE: (state) => ({ category: 'quote', value: state.id }) },
159
+ LOADED: (state, { value }) => ({ ...state, text: value.text, error: null }),
160
+ FAILED: (state, { error }) => ({ ...state, error: String(error) }),
161
+ }
162
+ ```
163
+ ```js
164
+ // main.js. A request { category, value } calls fn(value); the reply is { category, value: result }
165
+ import { run, driverFromAsync } from 'sygnal'
166
+ import Quote from './Quote.jsx'
167
+ run(Quote, { QUOTE: driverFromAsync(id => fetch(`/api/quotes/${id}`).then(r => r.json())) })
168
+ ```
169
+ A driver is any function `sink$ => source`. Page-wide events: `DOM.select('document' | 'body').events(type)`, CSS-filtered with `DOM.select('document').select('.overlay').events('click')`.
170
+
171
+ ## 4. API facts
172
+ - **Child props**: `<Rating name="food" value={state.food} />` → `function Rating({ state, name, value })`; reducers read `props.name` (4th arg); intent gets the `props$` stream. Reserved: `state` (lens: `"key"` or `{ get, set }`), `children`, `slots`, `context`, `peers` (SYG106). Without `state=` a child shares its parent's whole state.
173
+ - **CHILD.select(Comp)** emits exactly what the child's `PARENT` function returned, for every instance (Collection items too). Put an id in the payload.
174
+ - **run(App, drivers = {}, { mountPoint = '#root', diagnostics })** returns `{ sources, sinks, dispose, hmr }`. DOM, EVENTS, LOG and STATE are built in. `app.sources.STATE.stream` is the state stream; `app.dispose()` fires DISPOSE.
175
+ - **ABORT**: from a STATE reducer, the state is unchanged; from any other sink, nothing is sent.
176
+ - **Focus**: `blur`/`focus` don't bubble, but `DOM.blur('.field')` and `DOM.focus('.field')` work (listener on the element). For any field inside a container use the bubbling `DOM.focusout('.form')` / `DOM.focusin`.
177
+ - **Shorthands**: `DOM.<event>('.sel')` = `DOM.select('.sel').events('<event>')` for every event name.
178
+ - **Enriched streams** (chainable, optional mapper): `.value(fn?)` e.target.value; `.checked(fn?)` boolean; `.key(fn?)` e.key; `.target(fn?)`; `.data('id', Number)` reads `data-id` on the target or its nearest ancestor that has it (JSX: `data={{ id: 7 }}`). camelCase names map to kebab-case attributes: `.data('taskId')` reads `data-task-id` (`data={{ taskId }}`).
179
+ - **xstream**: `xs.merge/combine/of/periodic/never/fromPromise`; methods `map mapTo filter startWith fold take drop last endWhen flatten compose remember replaceError debug`. From `'sygnal'`, used with `.compose(...)`: `debounce(ms) throttle(ms) delay(ms) dropRepeats() sampleCombine(other$)`.
180
+
181
+ | RxJS | xstream | RxJS | xstream |
182
+ |---|---|---|---|
183
+ | `pipe(a, b)` | chain `.a().b()`, `.compose(op)` | `switchMap(f)` | `.map(f).flatten()` |
184
+ | `debounceTime(ms)` | `.compose(debounce(ms))` | `throttleTime(ms)` | `.compose(throttle(ms))` |
185
+ | `distinctUntilChanged()` | `.compose(dropRepeats())` | `withLatestFrom(b$)` | `.compose(sampleCombine(b$))` |
186
+ | `combineLatest(a$, b$)` | `xs.combine(a$, b$)` | `merge(a$, b$)` | `xs.merge(a$, b$)` |
187
+ | `scan(f, seed)` | `.fold(f, seed)` | `skip(n)` / `first()` | `.drop(n)` / `.take(1)` |
188
+ | `takeUntil(b$)` | `.endWhen(b$)` | `tap(f)` | `.debug(f)` |
189
+ | `catchError(f)` | `.replaceError(f)` | `shareReplay(1)` | `.remember()` |
190
+ | `mergeMap(f)` | `.map(f).compose(flattenConcurrently)` | `concatMap(f)` | `.map(f).compose(flattenSequentially)` |
191
+ (Last row: `import { flattenConcurrently, flattenSequentially, concat } from 'sygnal'`.)
192
+
193
+ ## 5. Wiring rules (silent failures, and what catches them)
194
+ - **Selectors are scoped to the component's own JSX.** A parent's `DOM.click('.remove')` never fires for `.remove` rendered by a child or a Collection item. Handle the event in the child and send it up with `PARENT` (read with `CHILD.select(Child)`) or `EVENTS`. Caught as SYG104; a selector the view never renders is SYG110.
195
+ - **Every intent action needs a model entry (SYG101), and every model entry needs a trigger (SYG102)**: an intent action, a built-in, or `next('X')`.
196
+ - **EVENTS types must match exactly** between `event('X')` and `EVENTS.select('X')` (SYG105).
197
+ - **Collection `from` must name an array field of the state** (SYG401).
198
+ - **A controlled input needs an input listener**: `value={state.x}` plus `DOM.input('.x').value()`, otherwise a re-render resets the text (SYG111).
199
+ - Also: reducers return the complete new state (`{ ...state, ... }`); never mutate; no side effects in views or STATE reducers (use EFFECT or a driver).
200
+
201
+ ## 6. Diagnostics
202
+ - Format: `[Sygnal SYG104] Lane: <what is wrong>. <how to fix> https://sygnal.js.org/reference/errors#syg104`. Severities error/warn/info. 1xx wiring, 2xx model/state, 3xx streams (SYG301: RxJS operator on an xstream stream), 4xx components (Collection, Switchable, context), 5xx strict, 6xx drivers and setup, 9xx internal.
203
+ - `npx --no-install sygnal-check` runs the locally installed checker, never a download (a `create-sygnal-app` project already has the `sygnal-check` dev dependency; elsewhere `npm i -D sygnal-check`; still not installed? skip it and rely on the runtime diagnostics in the tests). It checks `src` statically; pass other paths instead, e.g. `npx --no-install sygnal-check pages --strict` (Vike). Use `--strict` for canonical forms, `--fix` to apply the mechanical rewrites (implies `--strict`), and `--json` / `--verbose` for output. `npx --no-install sygnal-check explain SYG104` explains a code and its fix. Suppress one line with `// sygnal-ignore SYG110`.
204
+ - App graph: `npx --no-install sygnal-check --graph --json` (static), `t.inspect()` (test), `getDevTools().inspect()` (running dev app). All return the same `InspectGraph`: components, actions and their triggers, selectors (`matched`, `isolationHit`), EVENTS emitters/selectors, diagnostics.
205
+ - Vite plugin in dev (`vite`, never `vite build`): runtime checks print warnings to the console; when `sygnal-check` is installed, the plugin also runs it on start and on every save (terminal + browser console). Stricter: `sygnal({ diagnostics: { mode: 'error', strict: true }, check: { strict: true } })`.
206
+ - Without the plugin: `run(App, drivers, { diagnostics: 'warn' })` (`'collect'` → `getDiagnostics()`; `'error'` throws) and `import 'sygnal/diagnostics'` for the full checks. Runtime strict: `configureStrict(true)` from `'sygnal/diagnostics'`, or `renderComponent(C, { strict: true })`. `run()` has no strict option.
207
+ - MCP: `claude mcp add sygnal-check -- npx --no-install sygnal-check mcp` (tools `check`, `graph`, `explain`).
208
+
209
+ ## 7. Testing your change
210
+ ```js
211
+ import { it, expect, afterEach } from 'vitest'
212
+ import { renderComponent } from 'sygnal'
213
+ import TaskList from './TaskList.jsx'
214
+
215
+ let t
216
+ afterEach(() => t?.dispose())
217
+
218
+ it('picks, then removes a task', async () => {
219
+ t = renderComponent(TaskList, { strict: true }) // also: initialState, drivers, mockConfig, diagnostics
220
+ t.simulateEvent('.pick', 'click') // first match; bubbles; reaches child components too
221
+ await t.next(s => s.picked === 1) // a state emitted after this call
222
+ t.simulateEvent('.task[data-id="2"] .remove', 'click')
223
+ await t.next(s => s.tasks.length === 1)
224
+ await t.settle() // nothing pending anywhere in the tree
225
+ expect(t.html()).not.toContain('Test')
226
+ t.expectNoDiagnostics() // throws on any warn/error diagnostic
227
+ })
228
+ ```
229
+ - `simulateEvent(sel, type, init?)`: init `{ value }`, `{ checked }`, `{ key: 'Enter' }`, `{ data: { id: 2 } }`; `'document'` targets `DOM.select('document')` listeners. Calls made before the component is ready are buffered (`await t.ready()` is optional). `sel` matches the rendered tree like the real DOM: tag, `.class`, `#id`, `[attr="v"]`, `:first-child`, `:last-child`, `:nth-child(n)`, `:nth-of-type(n)`, `:not()`, descendant and `>` (e.g. `.list:nth-child(2) .card:first-child .next`). If it matches nothing (after waiting up to 300ms for a render), the test fails with an error naming the selector (check `t.html()`, or select by attribute: `[data-id="3"]`); `{ allowMissing: true }` drops the event instead. `:has()`, `+`, `~` throw "unsupported selector syntax".
230
+ - `t.next(pred)` matches only future states. `t.waitForState(pred)` also matches states already recorded (e.g. the initial one), so use it only for a state that can't already exist. Both resolve after the whole tree has rendered. `t.states`, `t.emitted` (EVENTS sent) and `t.sinkValues('PARENT')` are live arrays.
231
+ - `t.simulateAction('LOADED', data)` pushes an action straight into intent → model (all sinks run). Use it for actions without a DOM trigger; for drivers prefer `drivers: { QUOTE: driverFromAsync(async () => ({ text: 'hi' })) }`.
232
+ - With the Vite plugin, Vitest gets `sygnal/diagnostics` in its setupFiles automatically; otherwise `import 'sygnal/diagnostics'` in the test.
233
+ - Full app in jsdom (`npm i -D jsdom`):
234
+ ```js
235
+ // @vitest-environment jsdom
236
+ import { it, expect } from 'vitest'
237
+ import { run } from 'sygnal'
238
+ import Counter from './Counter.jsx'
239
+
240
+ it('counts in the real DOM', async () => {
241
+ document.body.innerHTML = '<div id="root"></div>'
242
+ const app = run(Counter, {}, { mountPoint: '#root' })
243
+ const tick = () => new Promise(r => setTimeout(r, 30))
244
+ await tick()
245
+ document.querySelector('.inc').click()
246
+ await tick()
247
+ expect(document.querySelector('.counter span').textContent).toContain('1')
248
+ app.dispose()
249
+ })
250
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sygnal",
3
- "version": "5.3.7",
3
+ "version": "5.4.0",
4
4
  "description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,6 +26,11 @@
26
26
  "import": "./dist/jsx-dev-runtime.esm.js",
27
27
  "require": "./dist/jsx-dev-runtime.cjs.js"
28
28
  },
29
+ "./diagnostics": {
30
+ "types": "./src/extra/diagnostics/checks/public.d.ts",
31
+ "import": "./dist/diagnostics.esm.js",
32
+ "require": "./dist/diagnostics.cjs.js"
33
+ },
29
34
  "./vite": {
30
35
  "types": "./src/vite/plugin.d.ts",
31
36
  "import": "./dist/vite/plugin.mjs",
@@ -80,18 +85,21 @@
80
85
  },
81
86
  "files": [
82
87
  "dist",
83
- "src"
88
+ "src",
89
+ "llms.txt"
84
90
  ],
85
91
  "scripts": {
86
- "test": "vitest run && npm run test:types && npm run test:browser",
92
+ "test": "vitest run && npm run test:examples && npm run test:types && npm run test:browser",
93
+ "test:examples": "node scripts/test-examples.mjs",
87
94
  "test:types": "npx tsc --project type-tests/tsconfig.json 2>&1 | grep '^type-tests/' && exit 1 || exit 0",
88
95
  "test:browser": "npm test --prefix browser-tests",
89
96
  "test:watch": "vitest",
90
- "build": "npx rollup -c && cp src/index.d.ts dist/index.d.ts",
97
+ "build": "npx rollup -c && npx rollup -c rollup.config.dts.mjs",
91
98
  "build:types": "npx rollup -c rollup.config.dts.mjs",
92
- "build:all": "npm run build && npm run build:types",
99
+ "build:all": "npm run build",
93
100
  "build:devtools": "node devtools/build.mjs",
94
- "start": "npx rollup -c -w"
101
+ "start": "npx rollup -c -w",
102
+ "prepublishOnly": "npm run build:all"
95
103
  },
96
104
  "repository": {
97
105
  "type": "git",
@@ -123,6 +131,7 @@
123
131
  "@rollup/plugin-node-resolve": "^15.2.1",
124
132
  "@rollup/plugin-terser": "^0.4.3",
125
133
  "@rollup/plugin-typescript": "^11.1.6",
134
+ "jsdom": "^29.1.1",
126
135
  "rollup": "^3.28.1",
127
136
  "rollup-plugin-dts": "^6.1.1",
128
137
  "tslib": "^2.6.2",
@@ -1,4 +1,6 @@
1
- import run from '../extra/run'
1
+ // The public entry (external in the build), so islands share the app's
2
+ // Sygnal core instead of a bundled copy (B-019).
3
+ import { run } from 'sygnal'
2
4
 
3
5
  interface SygnalComponent {
4
6
  (args: any): any;
@@ -50,7 +52,13 @@ export default (element: any) => {
50
52
  previous.dispose()
51
53
  }
52
54
 
53
- const Wrapped: any = (args: any) => Component({ ...args, props: { ...(props || {}) } })
55
+ // Island props reach the view like any component's props, spread
56
+ // top-level (`{ state, title }`), the same as on the server
57
+ // (renderToString). The view args (state, context, ...) win over a prop
58
+ // with the same name; `props` is kept for older `({ state, props })`
59
+ // views (B-026).
60
+ const islandProps = { ...(props || {}) }
61
+ const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })
54
62
  Wrapped.model = Component.model
55
63
  Wrapped.intent = Component.intent
56
64
  Wrapped.hmrActions = Component.hmrActions
@@ -65,6 +73,9 @@ export default (element: any) => {
65
73
  Wrapped.onError = Component.onError
66
74
  Wrapped.debug = Component.debug
67
75
  Wrapped.componentName = Component.componentName || Component.name
76
+ // run() names the root by `name` first: diagnostics and devtools should
77
+ // say 'Counter', not 'Wrapped'
78
+ try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}
68
79
 
69
80
  const app = run(Wrapped, {}, { mountPoint })
70
81
  element.__sygnal = app
@@ -1,3 +1,5 @@
1
+ import type { DiagnosticsMode, DiagnosticsPluginOptions, CheckPluginOptions } from '../vite/plugin.d'
2
+
1
3
  declare type SygnalAstroIntegration = {
2
4
  name: string;
3
5
  hooks: {
@@ -8,8 +10,29 @@ declare type SygnalAstroIntegration = {
8
10
  serverEntrypoint: string;
9
11
  }) => void;
10
12
  updateConfig: (config: any) => void;
13
+ command?: 'dev' | 'build' | 'preview' | 'sync';
14
+ logger?: { warn: (message: string) => void };
11
15
  }) => void;
12
16
  };
13
17
  };
14
18
 
15
- export default function sygnalAstroIntegration(): SygnalAstroIntegration;
19
+ export interface SygnalAstroOptions {
20
+ /**
21
+ * Runtime diagnostics for islands in `astro dev`: a mode ('warn',
22
+ * 'collect', 'error' or 'off') or { mode, strict, ignore }, the same as
23
+ * the sygnal/vite `diagnostics` option.
24
+ * @default 'warn'
25
+ */
26
+ diagnostics?: DiagnosticsMode | DiagnosticsPluginOptions;
27
+ /**
28
+ * Run sygnal-check in `astro dev` (see the sygnal/vite `check` option).
29
+ * @default true
30
+ */
31
+ check?: boolean | CheckPluginOptions;
32
+ }
33
+
34
+ /**
35
+ * Sygnal Astro integration. In `astro dev` it also adds the sygnal Vite
36
+ * plugin, which turns on runtime diagnostics for islands and runs sygnal-check.
37
+ */
38
+ export default function sygnalAstroIntegration(options?: SygnalAstroOptions): SygnalAstroIntegration;
@@ -1,3 +1,6 @@
1
+ import sygnalVite from '../vite/plugin'
2
+ import type { DiagnosticsMode, DiagnosticsPluginOptions, CheckPluginOptions } from '../vite/plugin'
3
+
1
4
  const SYGNAL_RENDERER_NAME = '@sygnal/astro'
2
5
 
3
6
  interface AstroRenderer {
@@ -9,27 +12,55 @@ interface AstroRenderer {
9
12
  interface AstroConfigSetupArgs {
10
13
  addRenderer: (renderer: AstroRenderer) => void;
11
14
  updateConfig: (config: any) => void;
15
+ command?: 'dev' | 'build' | 'preview' | 'sync';
16
+ logger?: { warn: (message: string) => void };
17
+ }
18
+
19
+ export interface SygnalAstroOptions {
20
+ /**
21
+ * Runtime diagnostics for islands in `astro dev`: a mode or
22
+ * { mode, strict, ignore }, the same as the sygnal/vite `diagnostics`
23
+ * option (the island client shares the app's core, B-019).
24
+ * @default 'warn'
25
+ */
26
+ diagnostics?: DiagnosticsMode | DiagnosticsPluginOptions;
27
+ /** Run sygnal-check in `astro dev` (see the sygnal/vite `check` option). @default true */
28
+ check?: boolean | CheckPluginOptions;
12
29
  }
13
30
 
14
- export default function sygnalAstroIntegration() {
31
+ export default function sygnalAstroIntegration(options: SygnalAstroOptions = {}) {
15
32
  return {
16
33
  name: SYGNAL_RENDERER_NAME,
17
34
  hooks: {
18
- 'astro:config:setup': ({ addRenderer, updateConfig }: AstroConfigSetupArgs) => {
35
+ 'astro:config:setup': ({ addRenderer, updateConfig, command }: AstroConfigSetupArgs) => {
19
36
  addRenderer({
20
37
  name: SYGNAL_RENDERER_NAME,
21
38
  clientEntrypoint: 'sygnal/astro/client',
22
39
  serverEntrypoint: 'sygnal/astro/server',
23
40
  })
24
41
 
25
- updateConfig({
26
- vite: {
27
- esbuild: {
28
- jsx: 'automatic',
29
- jsxImportSource: 'sygnal',
30
- },
42
+ const vite: any = {
43
+ esbuild: {
44
+ jsx: 'automatic',
45
+ jsxImportSource: 'sygnal',
31
46
  },
32
- })
47
+ }
48
+
49
+ // Dev mode (G-014): islands are started by sygnal/astro/client, which
50
+ // user code never imports, so the sygnal Vite plugin wraps that entry
51
+ // in dev to set the dev flag and load the runtime checks first. It
52
+ // also runs sygnal-check. Nothing is added to `astro build`.
53
+ if (command === 'dev') {
54
+ vite.plugins = [sygnalVite({
55
+ disableJsx: true,
56
+ disableHmr: true,
57
+ vitestSetup: false,
58
+ diagnostics: options.diagnostics,
59
+ check: options.check,
60
+ })]
61
+ }
62
+
63
+ updateConfig({ vite })
33
64
  },
34
65
  },
35
66
  }
@@ -22,9 +22,11 @@ export function renderToStaticMarkup(
22
22
  _metadata?: any
23
23
  ): { html: string; attrs: Record<string, any> } {
24
24
  try {
25
+ // Props are spread top-level by renderToString (`{ state, ...props }`);
26
+ // `props` is also passed, as on the client, for `({ state, props })` views.
25
27
  const html = renderToString(Component, {
26
28
  state: props.initialState || Component.initialState,
27
- props,
29
+ props: {...props, props},
28
30
  })
29
31
  return {html, attrs: {}}
30
32
  } catch (err: any) {
package/src/collection.ts CHANGED
@@ -2,6 +2,7 @@ import isolate from './cycle/isolate/index';
2
2
  import {makeCollection} from './cycle/state/index';
3
3
  import {h} from './cycle/dom/index';
4
4
  import type {Lens} from './cycle/state/types';
5
+ import {fail} from './extra/diagnostics/legacy';
5
6
 
6
7
  let COLLECTION_COUNT = 0;
7
8
 
@@ -20,7 +21,7 @@ export default function collection(
20
21
  opts: CollectionOptions = {}
21
22
  ): (sources: any) => any {
22
23
  if (typeof component !== 'function') {
23
- throw new Error('collection: first argument (component) must be a function');
24
+ fail('SYG411', 'collection', 'first argument (component) must be a function', 'Pass a component function');
24
25
  }
25
26
  const {
26
27
  combineList = ['DOM'],
@@ -37,7 +38,9 @@ export default function collection(
37
38
  item: component,
38
39
  itemKey: (state: any, ind: number) =>
39
40
  typeof state.id !== 'undefined' ? state.id : ind,
40
- itemScope: (key: any) => key,
41
+ // B-009: prefix with the collection instance so two Collections in one parent whose
42
+ // items share ids get different DOM isolation scopes
43
+ itemScope: (itemKey: any) => `${key}-${itemKey}`,
41
44
  channel: stateSourceName,
42
45
  collectSinks: (instances: any) => {
43
46
  return Object.entries(sources).reduce<Record<string, any>>(