sygnal 5.3.7 → 6.0.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 (438) hide show
  1. package/CHANGELOG.md +646 -0
  2. package/README.md +77 -47
  3. package/dist/astro/client.cjs.js +33 -8114
  4. package/dist/astro/client.cjs.js.map +1 -0
  5. package/dist/astro/client.mjs +33 -8114
  6. package/dist/astro/client.mjs.map +1 -0
  7. package/dist/astro/index.cjs.js +1039 -9
  8. package/dist/astro/index.cjs.js.map +1 -0
  9. package/dist/astro/index.mjs +1038 -9
  10. package/dist/astro/index.mjs.map +1 -0
  11. package/dist/astro/server.cjs.js +3400 -166
  12. package/dist/astro/server.cjs.js.map +1 -0
  13. package/dist/astro/server.mjs +3400 -166
  14. package/dist/astro/server.mjs.map +1 -0
  15. package/dist/devtools.cjs.js +1431 -0
  16. package/dist/devtools.cjs.js.map +1 -0
  17. package/dist/devtools.esm.js +1419 -0
  18. package/dist/devtools.esm.js.map +1 -0
  19. package/dist/diagnostics.cjs.js +4033 -0
  20. package/dist/diagnostics.cjs.js.map +1 -0
  21. package/dist/diagnostics.esm.js +4003 -0
  22. package/dist/diagnostics.esm.js.map +1 -0
  23. package/dist/element.cjs.js +230 -0
  24. package/dist/element.cjs.js.map +1 -0
  25. package/dist/element.esm.js +228 -0
  26. package/dist/element.esm.js.map +1 -0
  27. package/dist/guide/accessibility.md +257 -0
  28. package/dist/guide/adapters.md +221 -0
  29. package/dist/guide/behaviors.md +312 -0
  30. package/dist/guide/browser-sources.md +203 -0
  31. package/dist/guide/drag-and-drop.md +342 -0
  32. package/dist/guide/element-commands.md +306 -0
  33. package/dist/guide/error-boundaries.md +169 -0
  34. package/dist/guide/forms-reference.md +381 -0
  35. package/dist/guide/forms.md +250 -0
  36. package/dist/guide/http.md +299 -0
  37. package/dist/guide/inputs.md +173 -0
  38. package/dist/guide/persistence.md +245 -0
  39. package/dist/guide/recipes/carousel.md +155 -0
  40. package/dist/guide/recipes/charts.md +177 -0
  41. package/dist/guide/recipes/code-editor.md +135 -0
  42. package/dist/guide/recipes/data-grid.md +155 -0
  43. package/dist/guide/recipes/data-table.md +196 -0
  44. package/dist/guide/recipes/i18n.md +222 -0
  45. package/dist/guide/recipes/icons.md +115 -0
  46. package/dist/guide/recipes/overview.md +33 -0
  47. package/dist/guide/recipes/rich-text.md +154 -0
  48. package/dist/guide/resources.md +471 -0
  49. package/dist/guide/ssr.md +255 -0
  50. package/dist/guide/timers.md +178 -0
  51. package/dist/guide/ui/accordion.md +93 -0
  52. package/dist/guide/ui/combobox.md +144 -0
  53. package/dist/guide/ui/dialog.md +124 -0
  54. package/dist/guide/ui/disclosure.md +60 -0
  55. package/dist/guide/ui/menu.md +125 -0
  56. package/dist/guide/ui/overview.md +166 -0
  57. package/dist/guide/ui/popover.md +101 -0
  58. package/dist/guide/ui/select.md +114 -0
  59. package/dist/guide/ui/tabs.md +161 -0
  60. package/dist/guide/ui/toaster.md +152 -0
  61. package/dist/guide/ui/tooltip.md +103 -0
  62. package/dist/guide/undo.md +178 -0
  63. package/dist/guide/virtual-collections.md +183 -0
  64. package/dist/guide/web-components.md +179 -0
  65. package/dist/guide/widgets.md +217 -0
  66. package/dist/index.cjs.js +15283 -6279
  67. package/dist/index.cjs.js.map +1 -0
  68. package/dist/index.d.ts +3739 -370
  69. package/dist/index.esm.js +15230 -6274
  70. package/dist/index.esm.js.map +1 -0
  71. package/dist/jsx-dev-runtime.cjs.js +27 -329
  72. package/dist/jsx-dev-runtime.cjs.js.map +1 -0
  73. package/dist/jsx-dev-runtime.esm.js +20 -322
  74. package/dist/jsx-dev-runtime.esm.js.map +1 -0
  75. package/dist/jsx-runtime.cjs.js +27 -329
  76. package/dist/jsx-runtime.cjs.js.map +1 -0
  77. package/dist/jsx-runtime.esm.js +20 -322
  78. package/dist/jsx-runtime.esm.js.map +1 -0
  79. package/dist/jsx.cjs.js +11 -309
  80. package/dist/jsx.cjs.js.map +1 -0
  81. package/dist/jsx.esm.js +9 -310
  82. package/dist/jsx.esm.js.map +1 -0
  83. package/dist/react.cjs.js +117 -0
  84. package/dist/react.cjs.js.map +1 -0
  85. package/dist/react.esm.js +115 -0
  86. package/dist/react.esm.js.map +1 -0
  87. package/dist/shims/globalthis.cjs +20 -0
  88. package/dist/sygnal.min.js +2 -1
  89. package/dist/sygnal.min.js.map +1 -0
  90. package/dist/ui-combobox.cjs.js +169 -0
  91. package/dist/ui-combobox.cjs.js.map +1 -0
  92. package/dist/ui-combobox.esm.js +148 -0
  93. package/dist/ui-combobox.esm.js.map +1 -0
  94. package/dist/ui-menu.cjs.js +87 -0
  95. package/dist/ui-menu.cjs.js.map +1 -0
  96. package/dist/ui-menu.esm.js +66 -0
  97. package/dist/ui-menu.esm.js.map +1 -0
  98. package/dist/ui-select.cjs.js +104 -0
  99. package/dist/ui-select.cjs.js.map +1 -0
  100. package/dist/ui-select.esm.js +83 -0
  101. package/dist/ui-select.esm.js.map +1 -0
  102. package/dist/ui.cjs.js +738 -0
  103. package/dist/ui.cjs.js.map +1 -0
  104. package/dist/ui.esm.js +727 -0
  105. package/dist/ui.esm.js.map +1 -0
  106. package/dist/vike/ClientOnly.cjs.js +5 -14
  107. package/dist/vike/ClientOnly.cjs.js.map +1 -0
  108. package/dist/vike/ClientOnly.mjs +5 -14
  109. package/dist/vike/ClientOnly.mjs.map +1 -0
  110. package/dist/vike/{+config.js → config/+config.js} +10 -1
  111. package/dist/vike/config/+config.js.map +1 -0
  112. package/dist/vike/config/package.json +6 -0
  113. package/dist/vike/onRenderClient.cjs.js +166 -95
  114. package/dist/vike/onRenderClient.cjs.js.map +1 -0
  115. package/dist/vike/onRenderClient.mjs +166 -95
  116. package/dist/vike/onRenderClient.mjs.map +1 -0
  117. package/dist/vike/onRenderHtml.cjs.js +60 -24
  118. package/dist/vike/onRenderHtml.cjs.js.map +1 -0
  119. package/dist/vike/onRenderHtml.mjs +61 -25
  120. package/dist/vike/onRenderHtml.mjs.map +1 -0
  121. package/dist/vite/plugin.cjs.js +926 -65
  122. package/dist/vite/plugin.cjs.js.map +1 -0
  123. package/dist/vite/plugin.mjs +925 -65
  124. package/dist/vite/plugin.mjs.map +1 -0
  125. package/dist/zag.cjs.js +408 -0
  126. package/dist/zag.cjs.js.map +1 -0
  127. package/dist/zag.esm.js +405 -0
  128. package/dist/zag.esm.js.map +1 -0
  129. package/llms.txt +313 -0
  130. package/package.json +109 -16
  131. package/src/astro/client.ts +40 -18
  132. package/src/astro/index.d.ts +48 -1
  133. package/src/astro/index.ts +106 -9
  134. package/src/astro/server.ts +11 -3
  135. package/src/collection.ts +6 -90
  136. package/src/core/actions.ts +134 -0
  137. package/src/core/cell.ts +202 -0
  138. package/src/core/debug.ts +23 -0
  139. package/src/core/define.ts +242 -0
  140. package/src/core/hooks.ts +314 -0
  141. package/src/core/hosts/collection.ts +325 -0
  142. package/src/core/hosts/switchable.ts +146 -0
  143. package/src/core/instance.ts +592 -0
  144. package/src/core/markers/clientonly.ts +13 -0
  145. package/src/core/markers/lazy.ts +40 -0
  146. package/src/core/markers/portal.ts +96 -0
  147. package/src/core/markers/suspense.ts +41 -0
  148. package/src/core/markers/transition.ts +70 -0
  149. package/src/core/registry.ts +25 -0
  150. package/src/core/runtime.ts +573 -0
  151. package/src/core/statics.ts +104 -0
  152. package/src/core/teardown.ts +60 -0
  153. package/src/core/view.ts +37 -0
  154. package/src/cycle/dom/DocumentDOMSource.ts +13 -8
  155. package/src/cycle/dom/ElementFinder.ts +7 -9
  156. package/src/cycle/dom/EventDelegator.ts +174 -223
  157. package/src/cycle/dom/IsolateModule.ts +65 -35
  158. package/src/cycle/dom/MainDOMSource.ts +13 -2
  159. package/src/cycle/dom/PriorityQueue.ts +4 -2
  160. package/src/cycle/dom/SymbolTree.ts +18 -47
  161. package/src/cycle/dom/classNameModule.ts +76 -0
  162. package/src/cycle/dom/controlledInputModule.ts +50 -0
  163. package/src/cycle/dom/enrichEventStream.ts +29 -45
  164. package/src/cycle/dom/fragment.ts +7 -0
  165. package/src/cycle/dom/isolate.ts +30 -27
  166. package/src/cycle/dom/makeDOMDriver.ts +115 -57
  167. package/src/cycle/dom/mockDOMSource.ts +83 -9
  168. package/src/cycle/dom/modules.ts +21 -4
  169. package/src/cycle/dom/propsModule.ts +65 -0
  170. package/src/cycle/dom/selectModule.ts +22 -17
  171. package/src/cycle/dom/snabbdom.ts +1 -6
  172. package/src/cycle/dom/thunk.ts +3 -0
  173. package/src/cycle/dom/utils.ts +98 -0
  174. package/src/cycle/dom/viewTransition.ts +43 -0
  175. package/src/cycle/state/StateSource.ts +20 -4
  176. package/src/cycle/state/objIsEqual.ts +50 -0
  177. package/src/cycle/state/types.ts +0 -10
  178. package/src/defineComponent.ts +34 -0
  179. package/src/devtools.d.ts +151 -0
  180. package/src/devtools.ts +34 -0
  181. package/src/element.d.ts +59 -0
  182. package/src/element.ts +235 -0
  183. package/src/extra/backoff.ts +9 -0
  184. package/src/extra/behaviors.ts +169 -0
  185. package/src/extra/browserSignals.ts +23 -0
  186. package/src/extra/browserSources.ts +326 -0
  187. package/src/extra/command.ts +3 -3
  188. package/src/extra/controls.ts +47 -0
  189. package/src/extra/copyAsTest.ts +286 -0
  190. package/src/extra/devtools.ts +109 -31
  191. package/src/extra/devtoolsActions.ts +379 -0
  192. package/src/extra/devtoolsHook.ts +9 -0
  193. package/src/extra/devtoolsNext.ts +83 -0
  194. package/src/extra/diagnostics/checks/actionLog.ts +108 -0
  195. package/src/extra/diagnostics/checks/behaviors.ts +49 -0
  196. package/src/extra/diagnostics/checks/browserSources.ts +96 -0
  197. package/src/extra/diagnostics/checks/collections.ts +67 -0
  198. package/src/extra/diagnostics/checks/controls.ts +148 -0
  199. package/src/extra/diagnostics/checks/dataset.ts +57 -0
  200. package/src/extra/diagnostics/checks/dom.ts +250 -0
  201. package/src/extra/diagnostics/checks/elementCommands.ts +175 -0
  202. package/src/extra/diagnostics/checks/events.ts +83 -0
  203. package/src/extra/diagnostics/checks/fetch.ts +135 -0
  204. package/src/extra/diagnostics/checks/forms.ts +163 -0
  205. package/src/extra/diagnostics/checks/index.ts +202 -0
  206. package/src/extra/diagnostics/checks/inspect.ts +427 -0
  207. package/src/extra/diagnostics/checks/next.ts +417 -0
  208. package/src/extra/diagnostics/checks/persist.ts +54 -0
  209. package/src/extra/diagnostics/checks/props.ts +56 -0
  210. package/src/extra/diagnostics/checks/public.d.ts +302 -0
  211. package/src/extra/diagnostics/checks/replies.ts +128 -0
  212. package/src/extra/diagnostics/checks/router.ts +100 -0
  213. package/src/extra/diagnostics/checks/rxjsHints.ts +88 -0
  214. package/src/extra/diagnostics/checks/shared.ts +203 -0
  215. package/src/extra/diagnostics/checks/shorthand.ts +115 -0
  216. package/src/extra/diagnostics/checks/sortable.ts +129 -0
  217. package/src/extra/diagnostics/checks/state.ts +148 -0
  218. package/src/extra/diagnostics/checks/statics.ts +48 -0
  219. package/src/extra/diagnostics/checks/strict.ts +55 -0
  220. package/src/extra/diagnostics/checks/timers.ts +80 -0
  221. package/src/extra/diagnostics/checks/viewTransitions.ts +47 -0
  222. package/src/extra/diagnostics/checks/virtual.ts +73 -0
  223. package/src/extra/diagnostics/checks/widgets.ts +109 -0
  224. package/src/extra/diagnostics/checks/wiring.ts +121 -0
  225. package/src/extra/diagnostics/codes.ts +477 -0
  226. package/src/extra/diagnostics/index.ts +353 -0
  227. package/src/extra/diagnostics/legacy.ts +76 -0
  228. package/src/extra/driverFactories.ts +172 -60
  229. package/src/extra/elementCommands.ts +53 -0
  230. package/src/extra/eventDriver.ts +4 -0
  231. package/src/extra/fetchDriver.ts +519 -0
  232. package/src/extra/flatten.ts +75 -0
  233. package/src/extra/focusWithin.ts +27 -0
  234. package/src/extra/form.ts +268 -0
  235. package/src/extra/formHelpers.ts +139 -0
  236. package/src/extra/head.ts +106 -0
  237. package/src/extra/hmr.ts +2 -3
  238. package/src/extra/owned.ts +24 -0
  239. package/src/extra/pager.ts +50 -0
  240. package/src/extra/persist.ts +133 -0
  241. package/src/extra/pwa.ts +1 -1
  242. package/src/extra/queryCache.ts +107 -0
  243. package/src/extra/reducers.ts +13 -6
  244. package/src/extra/reduxDevtools.ts +92 -0
  245. package/src/extra/replies.ts +54 -0
  246. package/src/extra/router.ts +323 -0
  247. package/src/extra/run.ts +94 -210
  248. package/src/extra/selection.ts +76 -0
  249. package/src/extra/socketDriver.ts +265 -0
  250. package/src/extra/sortable.ts +377 -0
  251. package/src/extra/ssr.ts +427 -160
  252. package/src/extra/standardSchema.ts +27 -0
  253. package/src/extra/testing.ts +3158 -190
  254. package/src/extra/timers.ts +95 -0
  255. package/src/extra/undo.ts +261 -0
  256. package/src/extra/viewTransitions.ts +38 -0
  257. package/src/extra/virtual.ts +513 -0
  258. package/src/extra/widget.ts +201 -0
  259. package/src/extra/xstreamExtras.ts +269 -0
  260. package/src/index.d.ts +3012 -87
  261. package/src/index.ts +32 -10
  262. package/src/jsx-runtime.ts +15 -1
  263. package/src/jsx.ts +2 -1
  264. package/src/lazy.ts +50 -7
  265. package/src/portal.ts +3 -1
  266. package/src/pragma/index.ts +262 -134
  267. package/src/react-peers.d.ts +5 -0
  268. package/src/react.d.ts +43 -0
  269. package/src/react.ts +110 -0
  270. package/src/shared.ts +48 -0
  271. package/src/slot.ts +1 -1
  272. package/src/suspense.ts +3 -1
  273. package/src/switchable.ts +6 -119
  274. package/src/transition.ts +3 -1
  275. package/src/ui/accordion.ts +64 -0
  276. package/src/ui/dialog.ts +129 -0
  277. package/src/ui/disclosure.ts +35 -0
  278. package/src/ui/popover.ts +45 -0
  279. package/src/ui/shared.ts +94 -0
  280. package/src/ui/tabs.ts +82 -0
  281. package/src/ui/toaster.ts +198 -0
  282. package/src/ui/tooltip.ts +70 -0
  283. package/src/ui/zag/combobox.ts +115 -0
  284. package/src/ui/zag/menu.ts +40 -0
  285. package/src/ui/zag/select.ts +54 -0
  286. package/src/ui/zag/shared.ts +43 -0
  287. package/src/ui-combobox.d.ts +20 -0
  288. package/src/ui-combobox.ts +6 -0
  289. package/src/ui-menu.d.ts +30 -0
  290. package/src/ui-menu.ts +6 -0
  291. package/src/ui-select.d.ts +17 -0
  292. package/src/ui-select.ts +6 -0
  293. package/src/ui-zag-types.d.ts +42 -0
  294. package/src/ui.d.ts +208 -0
  295. package/src/ui.ts +15 -0
  296. package/src/vike/+config.ts +9 -1
  297. package/src/vike/ClientOnly.ts +1 -1
  298. package/src/vike/onRenderClient.ts +144 -96
  299. package/src/vike/onRenderHtml.ts +69 -26
  300. package/src/vike/types.ts +27 -4
  301. package/src/vite/globalthis-shim.ts +18 -0
  302. package/src/vite/globalthis.ts +56 -0
  303. package/src/vite/plugin.d.ts +114 -2
  304. package/src/vite/plugin.ts +920 -56
  305. package/src/zag.d.ts +64 -0
  306. package/src/zag.ts +238 -0
  307. package/dist/astro/astro/client.d.ts +0 -5
  308. package/dist/astro/astro/index.d.ts +0 -16
  309. package/dist/astro/astro/server.d.ts +0 -12
  310. package/dist/astro/client.d.ts +0 -5
  311. package/dist/astro/client.esm.js +0 -4665
  312. package/dist/astro/collection.d.ts +0 -12
  313. package/dist/astro/component.d.ts +0 -22
  314. package/dist/astro/cycle/dom/BodyDOMSource.d.ts +0 -10
  315. package/dist/astro/cycle/dom/DOMSource.d.ts +0 -11
  316. package/dist/astro/cycle/dom/DocumentDOMSource.d.ts +0 -12
  317. package/dist/astro/cycle/dom/ElementFinder.d.ts +0 -8
  318. package/dist/astro/cycle/dom/EventDelegator.d.ts +0 -34
  319. package/dist/astro/cycle/dom/IsolateModule.d.ts +0 -23
  320. package/dist/astro/cycle/dom/MainDOMSource.d.ts +0 -32
  321. package/dist/astro/cycle/dom/PriorityQueue.d.ts +0 -7
  322. package/dist/astro/cycle/dom/ScopeChecker.d.ts +0 -9
  323. package/dist/astro/cycle/dom/SymbolTree.d.ts +0 -9
  324. package/dist/astro/cycle/dom/VNodeWrapper.d.ts +0 -8
  325. package/dist/astro/cycle/dom/enrichEventStream.d.ts +0 -24
  326. package/dist/astro/cycle/dom/fromEvent.d.ts +0 -6
  327. package/dist/astro/cycle/dom/index.d.ts +0 -8
  328. package/dist/astro/cycle/dom/isolate.d.ts +0 -9
  329. package/dist/astro/cycle/dom/makeDOMDriver.d.ts +0 -11
  330. package/dist/astro/cycle/dom/mockDOMSource.d.ts +0 -17
  331. package/dist/astro/cycle/dom/modules.d.ts +0 -5
  332. package/dist/astro/cycle/dom/snabbdom.d.ts +0 -22
  333. package/dist/astro/cycle/dom/styleModule.d.ts +0 -13
  334. package/dist/astro/cycle/dom/thunk.d.ts +0 -11
  335. package/dist/astro/cycle/dom/utils.d.ts +0 -8
  336. package/dist/astro/cycle/isolate/index.d.ts +0 -42
  337. package/dist/astro/cycle/run/adapt.d.ts +0 -6
  338. package/dist/astro/cycle/run/index.d.ts +0 -36
  339. package/dist/astro/cycle/run/internals.d.ts +0 -8
  340. package/dist/astro/cycle/run/types.d.ts +0 -49
  341. package/dist/astro/cycle/state/Collection.d.ts +0 -29
  342. package/dist/astro/cycle/state/StateSource.d.ts +0 -20
  343. package/dist/astro/cycle/state/index.d.ts +0 -5
  344. package/dist/astro/cycle/state/pickCombine.d.ts +0 -3
  345. package/dist/astro/cycle/state/pickMerge.d.ts +0 -3
  346. package/dist/astro/cycle/state/types.d.ts +0 -18
  347. package/dist/astro/cycle/state/withState.d.ts +0 -17
  348. package/dist/astro/extra/classes.d.ts +0 -7
  349. package/dist/astro/extra/devtools.d.ts +0 -78
  350. package/dist/astro/extra/dragDriver.d.ts +0 -20
  351. package/dist/astro/extra/driverFactories.d.ts +0 -12
  352. package/dist/astro/extra/eventDriver.d.ts +0 -9
  353. package/dist/astro/extra/exactState.d.ts +0 -1
  354. package/dist/astro/extra/hmr.d.ts +0 -17
  355. package/dist/astro/extra/logDriver.d.ts +0 -2
  356. package/dist/astro/extra/processDrag.d.ts +0 -19
  357. package/dist/astro/extra/processForm.d.ts +0 -15
  358. package/dist/astro/extra/run.d.ts +0 -13
  359. package/dist/astro/extra/xstreamCompat.d.ts +0 -5
  360. package/dist/astro/index.d.ts +0 -19
  361. package/dist/astro/index.esm.js +0 -27
  362. package/dist/astro/jsx-dev-runtime.d.ts +0 -1
  363. package/dist/astro/jsx-runtime.d.ts +0 -4
  364. package/dist/astro/jsx.d.ts +0 -2
  365. package/dist/astro/pragma/fn.d.ts +0 -7
  366. package/dist/astro/pragma/index.d.ts +0 -7
  367. package/dist/astro/pragma/is.d.ts +0 -10
  368. package/dist/astro/server.d.ts +0 -12
  369. package/dist/astro/server.esm.js +0 -25
  370. package/dist/astro/switchable.d.ts +0 -7
  371. package/dist/collection.d.ts +0 -12
  372. package/dist/component.d.ts +0 -22
  373. package/dist/cycle/dom/BodyDOMSource.d.ts +0 -10
  374. package/dist/cycle/dom/DOMSource.d.ts +0 -11
  375. package/dist/cycle/dom/DocumentDOMSource.d.ts +0 -12
  376. package/dist/cycle/dom/ElementFinder.d.ts +0 -8
  377. package/dist/cycle/dom/EventDelegator.d.ts +0 -34
  378. package/dist/cycle/dom/IsolateModule.d.ts +0 -23
  379. package/dist/cycle/dom/MainDOMSource.d.ts +0 -32
  380. package/dist/cycle/dom/PriorityQueue.d.ts +0 -7
  381. package/dist/cycle/dom/ScopeChecker.d.ts +0 -9
  382. package/dist/cycle/dom/SymbolTree.d.ts +0 -9
  383. package/dist/cycle/dom/VNodeWrapper.d.ts +0 -8
  384. package/dist/cycle/dom/enrichEventStream.d.ts +0 -24
  385. package/dist/cycle/dom/fromEvent.d.ts +0 -6
  386. package/dist/cycle/dom/index.d.ts +0 -8
  387. package/dist/cycle/dom/isolate.d.ts +0 -9
  388. package/dist/cycle/dom/makeDOMDriver.d.ts +0 -11
  389. package/dist/cycle/dom/mockDOMSource.d.ts +0 -17
  390. package/dist/cycle/dom/modules.d.ts +0 -5
  391. package/dist/cycle/dom/snabbdom.d.ts +0 -22
  392. package/dist/cycle/dom/styleModule.d.ts +0 -13
  393. package/dist/cycle/dom/thunk.d.ts +0 -11
  394. package/dist/cycle/dom/utils.d.ts +0 -8
  395. package/dist/cycle/isolate/index.d.ts +0 -42
  396. package/dist/cycle/run/adapt.d.ts +0 -6
  397. package/dist/cycle/run/index.d.ts +0 -36
  398. package/dist/cycle/run/internals.d.ts +0 -8
  399. package/dist/cycle/run/types.d.ts +0 -49
  400. package/dist/cycle/state/Collection.d.ts +0 -29
  401. package/dist/cycle/state/StateSource.d.ts +0 -20
  402. package/dist/cycle/state/index.d.ts +0 -5
  403. package/dist/cycle/state/pickCombine.d.ts +0 -3
  404. package/dist/cycle/state/pickMerge.d.ts +0 -3
  405. package/dist/cycle/state/types.d.ts +0 -18
  406. package/dist/cycle/state/withState.d.ts +0 -17
  407. package/dist/extra/classes.d.ts +0 -7
  408. package/dist/extra/devtools.d.ts +0 -78
  409. package/dist/extra/dragDriver.d.ts +0 -20
  410. package/dist/extra/driverFactories.d.ts +0 -12
  411. package/dist/extra/eventDriver.d.ts +0 -9
  412. package/dist/extra/exactState.d.ts +0 -1
  413. package/dist/extra/hmr.d.ts +0 -17
  414. package/dist/extra/logDriver.d.ts +0 -2
  415. package/dist/extra/processDrag.d.ts +0 -19
  416. package/dist/extra/processForm.d.ts +0 -15
  417. package/dist/extra/run.d.ts +0 -13
  418. package/dist/extra/xstreamCompat.d.ts +0 -5
  419. package/dist/jsx-dev-runtime.d.ts +0 -1
  420. package/dist/jsx-dev-runtime.js +0 -224
  421. package/dist/jsx-runtime.d.ts +0 -4
  422. package/dist/jsx-runtime.js +0 -224
  423. package/dist/jsx.d.ts +0 -2
  424. package/dist/pragma/fn.d.ts +0 -7
  425. package/dist/pragma/index.d.ts +0 -7
  426. package/dist/pragma/is.d.ts +0 -10
  427. package/dist/switchable.d.ts +0 -7
  428. package/dist/vike/+config.cjs.js +0 -65
  429. package/src/component.ts +0 -2256
  430. package/src/cycle/isolate/index.ts +0 -196
  431. package/src/cycle/run/index.ts +0 -151
  432. package/src/cycle/run/internals.ts +0 -143
  433. package/src/cycle/state/Collection.ts +0 -174
  434. package/src/cycle/state/index.ts +0 -5
  435. package/src/cycle/state/pickCombine.ts +0 -167
  436. package/src/cycle/state/pickMerge.ts +0 -122
  437. package/src/cycle/state/withState.ts +0 -47
  438. package/src/pragma/fn.ts +0 -55
@@ -1,19 +1,26 @@
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'
4
+ // PLAN-4 GS-11 / D120: the app-level error hook, the default export of the module the
5
+ // integration's `onError` option names (undefined without it); served by sygnal/astro's Vite plugin
6
+ // @ts-ignore — a virtual module
7
+ import onError from 'virtual:sygnal/astro-on-error'
2
8
 
3
9
  interface SygnalComponent {
4
10
  (args: any): any;
5
- isSygnalComponent?: boolean;
6
11
  model?: any;
7
12
  intent?: any;
8
- hmrActions?: any;
13
+ connections?: any;
14
+ resources?: any;
15
+ route?: any;
16
+ head?: any;
17
+ persist?: any;
18
+ uses?: any;
19
+ timers?: any;
20
+ viewTransitions?: any;
9
21
  context?: any;
10
- peers?: any;
11
- components?: any;
12
22
  initialState?: any;
13
23
  calculated?: any;
14
- storeCalculatedInState?: any;
15
- DOMSourceName?: string;
16
- stateSourceName?: string;
17
24
  onError?: (error: Error, info: { componentName: string }) => any;
18
25
  debug?: boolean;
19
26
  componentName?: string;
@@ -27,8 +34,7 @@ interface AstroMetadata {
27
34
  function looksLikeSygnalComponent(Component: any): Component is SygnalComponent {
28
35
  if (typeof Component !== 'function') return false
29
36
  return Boolean(
30
- Component.isSygnalComponent ||
31
- Component.model ||
37
+ Component.model ||
32
38
  Component.intent ||
33
39
  Component.initialState ||
34
40
  Component.componentName
@@ -50,23 +56,39 @@ export default (element: any) => {
50
56
  previous.dispose()
51
57
  }
52
58
 
53
- const Wrapped: any = (args: any) => Component({ ...args, props: { ...(props || {}) } })
59
+ // Island props reach the view like any component's props, spread
60
+ // top-level (`{ state, title }`), the same as on the server
61
+ // (renderToString). The view args (state, context, ...) win over a prop
62
+ // with the same name; `props` is kept for older `({ state, props })`
63
+ // views (B-026).
64
+ const islandProps = { ...(props || {}) }
65
+ const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })
54
66
  Wrapped.model = Component.model
55
67
  Wrapped.intent = Component.intent
56
- Wrapped.hmrActions = Component.hmrActions
57
68
  Wrapped.context = Component.context
58
- Wrapped.peers = Component.peers
59
- Wrapped.components = Component.components
60
69
  Wrapped.initialState = Component.initialState
61
70
  Wrapped.calculated = Component.calculated
62
- Wrapped.storeCalculatedInState = Component.storeCalculatedInState
63
- Wrapped.DOMSourceName = Component.DOMSourceName
64
- Wrapped.stateSourceName = Component.stateSourceName
65
71
  Wrapped.onError = Component.onError
66
72
  Wrapped.debug = Component.debug
73
+ Wrapped.connections = Component.connections
74
+ Wrapped.resources = Component.resources
75
+ Wrapped.route = Component.route
76
+ Wrapped.head = Component.head
77
+ // PLAN-4 3-B2: more statics the core reads off the root view: persist (root only: the island
78
+ // is its app's root), uses, timers (they run only with a timer driver) and viewTransitions
79
+ Wrapped.persist = Component.persist
80
+ Wrapped.uses = Component.uses
81
+ Wrapped.timers = Component.timers
82
+ Wrapped.viewTransitions = Component.viewTransitions
67
83
  Wrapped.componentName = Component.componentName || Component.name
84
+ // run() names the root by `name` first: diagnostics and devtools should
85
+ // say 'Counter', not 'Wrapped'
86
+ try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}
68
87
 
69
- const app = run(Wrapped, {}, { mountPoint })
88
+ // G-206: a `uid` island prop is the island's uid root (as on the server); the view's own
89
+ // uid() function wins over the prop (args are spread last)
90
+ // 3-B2: `__hydrate` tells persist() whether the island starts over the server's markup
91
+ const app = run(Wrapped, { __hydrate: () => client !== 'only' && canHydrate }, { mountPoint, onError, uid: islandProps.uid })
70
92
  element.__sygnal = app
71
93
  }
72
94
  }
@@ -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,53 @@ 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 };
15
+ config?: { root?: URL | string; vite?: any };
11
16
  }) => void;
12
17
  };
13
18
  };
14
19
 
15
- export default function sygnalAstroIntegration(): SygnalAstroIntegration;
20
+ export interface SygnalAstroOptions {
21
+ /**
22
+ * Runtime diagnostics for islands in `astro dev`: a mode ('warn',
23
+ * 'collect', 'error' or 'off') or { mode, strict, ignore }, the same as
24
+ * the sygnal/vite `diagnostics` option.
25
+ * @default 'warn'
26
+ */
27
+ diagnostics?: DiagnosticsMode | DiagnosticsPluginOptions;
28
+ /**
29
+ * Run sygnal-check in `astro dev` (see the sygnal/vite `check` option).
30
+ * @default true
31
+ */
32
+ check?: boolean | CheckPluginOptions;
33
+ /**
34
+ * Resolve xstream's `globalthis` dependency to a stub returning the native
35
+ * `globalThis` (see the sygnal/vite `nativeGlobalThis` option), in
36
+ * `astro dev` and `astro build`. false: keep the polyfill package.
37
+ * @default true
38
+ */
39
+ nativeGlobalThis?: boolean;
40
+ /**
41
+ * Install the DevTools bridge for islands in `astro dev` (see the sygnal/vite
42
+ * `devtools` option). Never in `astro build`.
43
+ * @default true
44
+ */
45
+ devtools?: boolean;
46
+ /**
47
+ * The islands' app-level error hook (PLAN-4 GS-11): the path of a module, relative to the
48
+ * Astro project root, whose default export is called as run()'s and renderToString's
49
+ * `onError`, in the browser and during SSR. Reporting only, after a component's onError
50
+ * boundary chose the fallback.
51
+ * @example sygnal({ onError: './src/onError.js' })
52
+ * // src/onError.js
53
+ * export default (error, { componentName, action, phase }) => report(error)
54
+ */
55
+ onError?: string;
56
+ }
57
+
58
+ /**
59
+ * Sygnal Astro integration. In `astro dev` it also adds the sygnal Vite
60
+ * plugin, which turns on runtime diagnostics for islands and runs sygnal-check.
61
+ */
62
+ export default function sygnalAstroIntegration(options?: SygnalAstroOptions): SygnalAstroIntegration;
@@ -1,5 +1,38 @@
1
+ import sygnalVite from '../vite/plugin'
2
+ import { globalThisAlias } from '../vite/globalthis'
3
+ import type { DiagnosticsMode, DiagnosticsPluginOptions, CheckPluginOptions } from '../vite/plugin'
4
+ // Node built-ins (the integration runs in Node). The package has no @types/node.
5
+ // @ts-ignore
6
+ import path from 'node:path'
7
+ // @ts-ignore
8
+ import { fileURLToPath } from 'node:url'
9
+
1
10
  const SYGNAL_RENDERER_NAME = '@sygnal/astro'
2
11
 
12
+ // PLAN-4 GS-11 / D120: both island entries import this; it re-exports the default export of the
13
+ // module the `onError` option names (undefined without it)
14
+ const ON_ERROR_ID = 'virtual:sygnal/astro-on-error'
15
+
16
+ /** The Vite plugin serving ON_ERROR_ID; `file` is absolute (undefined: no hook) */
17
+ function onErrorPlugin(file?: string) {
18
+ return {
19
+ name: 'sygnal:astro-on-error',
20
+ resolveId: (id: string) => id === ON_ERROR_ID ? '\0' + ON_ERROR_ID : undefined,
21
+ load: (id: string) => id === '\0' + ON_ERROR_ID
22
+ ? (file ? `export { default } from ${JSON.stringify(file)}` : 'export default undefined')
23
+ : undefined,
24
+ // Vite 6+ (Astro 6 renders in its own 'prerender' / 'ssr' environments): the island server
25
+ // entry imports the virtual module, so Vite must load it (not Node). `ssr.noExternal`
26
+ // below covers the 'ssr' environment and older Vite
27
+ configEnvironment: (name: string) => name === 'client' ? undefined : { resolve: { noExternal: ['sygnal'] } },
28
+ }
29
+ }
30
+
31
+ /** The project root as a directory path (Astro gives a file: URL) */
32
+ const rootDir = (root: any): string =>
33
+ // @ts-ignore — Node's process
34
+ !root ? process.cwd() : typeof root === 'string' ? root : fileURLToPath(root)
35
+
3
36
  interface AstroRenderer {
4
37
  name: string;
5
38
  clientEntrypoint: string;
@@ -9,27 +42,91 @@ interface AstroRenderer {
9
42
  interface AstroConfigSetupArgs {
10
43
  addRenderer: (renderer: AstroRenderer) => void;
11
44
  updateConfig: (config: any) => void;
45
+ command?: 'dev' | 'build' | 'preview' | 'sync';
46
+ logger?: { warn: (message: string) => void };
47
+ config?: { root?: URL | string; vite?: { resolve?: { alias?: any } } };
12
48
  }
13
49
 
14
- export default function sygnalAstroIntegration() {
50
+ export interface SygnalAstroOptions {
51
+ /**
52
+ * Runtime diagnostics for islands in `astro dev`: a mode or
53
+ * { mode, strict, ignore }, the same as the sygnal/vite `diagnostics`
54
+ * option (the island client shares the app's core, B-019).
55
+ * @default 'warn'
56
+ */
57
+ diagnostics?: DiagnosticsMode | DiagnosticsPluginOptions;
58
+ /** Run sygnal-check in `astro dev` (see the sygnal/vite `check` option). @default true */
59
+ check?: boolean | CheckPluginOptions;
60
+ /**
61
+ * Resolve xstream's `globalthis` dependency to a stub returning the native
62
+ * `globalThis` (see the sygnal/vite `nativeGlobalThis` option), in
63
+ * `astro dev` and `astro build`. false: keep the polyfill package.
64
+ * @default true
65
+ */
66
+ nativeGlobalThis?: boolean;
67
+ /**
68
+ * Install the DevTools bridge for islands in `astro dev` (see the sygnal/vite
69
+ * `devtools` option). Never in `astro build`.
70
+ * @default true
71
+ */
72
+ devtools?: boolean;
73
+ /**
74
+ * PLAN-4 GS-11: the islands' app-level error hook: the path of a module (relative to the Astro
75
+ * project root) whose default export is called as run()'s / renderToString's `onError`
76
+ * (error, { componentName, action, phase }), in the browser and during SSR. Reporting only,
77
+ * after a component's onError boundary chose the fallback.
78
+ * @example sygnal({ onError: './src/onError.js' })
79
+ */
80
+ onError?: string;
81
+ }
82
+
83
+ export default function sygnalAstroIntegration(options: SygnalAstroOptions = {}) {
15
84
  return {
16
85
  name: SYGNAL_RENDERER_NAME,
17
86
  hooks: {
18
- 'astro:config:setup': ({ addRenderer, updateConfig }: AstroConfigSetupArgs) => {
87
+ 'astro:config:setup': ({ addRenderer, updateConfig, command, config }: AstroConfigSetupArgs) => {
19
88
  addRenderer({
20
89
  name: SYGNAL_RENDERER_NAME,
21
90
  clientEntrypoint: 'sygnal/astro/client',
22
91
  serverEntrypoint: 'sygnal/astro/server',
23
92
  })
24
93
 
25
- updateConfig({
26
- vite: {
27
- esbuild: {
28
- jsx: 'automatic',
29
- jsxImportSource: 'sygnal',
30
- },
94
+ const vite: any = {
95
+ esbuild: {
96
+ jsx: 'automatic',
97
+ jsxImportSource: 'sygnal',
31
98
  },
32
- })
99
+ // D120: the island entries import the virtual onError module, so they stay on Vite:
100
+ // not pre-bundled with it, and not externalized (loaded by Node) during SSR
101
+ optimizeDeps: { exclude: [ON_ERROR_ID] },
102
+ ssr: { noExternal: ['sygnal'] },
103
+ }
104
+ const hook = options.onError ? path.resolve(rootDir(config?.root), options.onError) : undefined
105
+
106
+ // Dev mode (G-014): islands are started by sygnal/astro/client, which
107
+ // user code never imports, so the sygnal Vite plugin wraps that entry
108
+ // in dev to install DevTools, set the dev flag and load the runtime checks first. It
109
+ // also runs sygnal-check. `astro build` only gets the `globalthis` alias.
110
+ if (command === 'dev') {
111
+ vite.plugins = [sygnalVite({
112
+ disableJsx: true,
113
+ disableHmr: true,
114
+ vitestSetup: false,
115
+ diagnostics: options.diagnostics,
116
+ check: options.check,
117
+ nativeGlobalThis: options.nativeGlobalThis,
118
+ devtools: options.devtools,
119
+ })]
120
+ } else if (options.nativeGlobalThis !== false) {
121
+ // G-099: the same `globalthis` alias the plugin adds in dev (R2-7: unless the
122
+ // user's vite config already aliases `globalthis`)
123
+ const alias = globalThisAlias(config?.vite?.resolve?.alias)
124
+ if (alias.length) vite.resolve = { alias }
125
+ }
126
+
127
+ vite.plugins = [...(vite.plugins || []), onErrorPlugin(hook)]
128
+
129
+ updateConfig({ vite })
33
130
  },
34
131
  },
35
132
  }
@@ -1,10 +1,12 @@
1
1
  import {renderToString} from '../extra/ssr'
2
+ // PLAN-4 GS-11 / D120: the integration's `onError` module (see client.ts)
3
+ // @ts-ignore — a virtual module
4
+ import onError from 'virtual:sygnal/astro-on-error'
2
5
 
3
6
  function looksLikeSygnalComponent(Component: any): boolean {
4
7
  if (typeof Component !== 'function') return false
5
8
  return Boolean(
6
- Component.isSygnalComponent ||
7
- Component.model ||
9
+ Component.model ||
8
10
  Component.intent ||
9
11
  Component.initialState ||
10
12
  Component.componentName
@@ -22,9 +24,15 @@ export function renderToStaticMarkup(
22
24
  _metadata?: any
23
25
  ): { html: string; attrs: Record<string, any> } {
24
26
  try {
27
+ // Props are spread top-level by renderToString (`{ state, ...props }`);
28
+ // `props` is also passed, as on the client, for `({ state, props })` views.
25
29
  const html = renderToString(Component, {
26
30
  state: props.initialState || Component.initialState,
27
- props,
31
+ props: {...props, props},
32
+ // PLAN-4 GS-11: the app-level error hook (as the client's run() gets)
33
+ onError,
34
+ // G-206: a `uid` island prop is its uid root (as on the client), for two islands on a page
35
+ uid: props.uid,
28
36
  })
29
37
  return {html, attrs: {}}
30
38
  } catch (err: any) {
package/src/collection.ts CHANGED
@@ -1,98 +1,14 @@
1
- import isolate from './cycle/isolate/index';
2
- import {makeCollection} from './cycle/state/index';
3
- import {h} from './cycle/dom/index';
4
- import type {Lens} from './cycle/state/types';
5
-
6
- let COLLECTION_COUNT = 0;
7
-
8
- interface CollectionOptions {
9
- combineList?: string[];
10
- globalList?: string[];
11
- stateSourceName?: string;
12
- domSourceName?: string;
13
- container?: string;
14
- containerClass?: string;
15
- }
16
-
17
- export default function collection(
18
- component: (...args: any[]) => any,
19
- stateLense: string | Lens<any, any>,
20
- opts: CollectionOptions = {}
21
- ): (sources: any) => any {
22
- if (typeof component !== 'function') {
23
- throw new Error('collection: first argument (component) must be a function');
24
- }
25
- const {
26
- combineList = ['DOM'],
27
- globalList = ['EVENTS'],
28
- stateSourceName = 'STATE',
29
- domSourceName = 'DOM',
30
- container = 'div',
31
- containerClass,
32
- } = opts;
33
-
34
- return (sources: any) => {
35
- const key = `sygnal-collection-${COLLECTION_COUNT++}`;
36
- const collectionOpts = {
37
- item: component,
38
- itemKey: (state: any, ind: number) =>
39
- typeof state.id !== 'undefined' ? state.id : ind,
40
- itemScope: (key: any) => key,
41
- channel: stateSourceName,
42
- collectSinks: (instances: any) => {
43
- return Object.entries(sources).reduce<Record<string, any>>(
44
- (acc, [name]) => {
45
- if (combineList.includes(name)) {
46
- const combined = instances.pickCombine(name);
47
- if (name === domSourceName && container) {
48
- acc[domSourceName] = combined.map((children: any) => {
49
- const data = containerClass
50
- ? {props: {className: containerClass}}
51
- : {};
52
- return {
53
- sel: container,
54
- data,
55
- children,
56
- key,
57
- text: undefined,
58
- elm: undefined,
59
- };
60
- });
61
- } else {
62
- acc[name] = combined;
63
- }
64
- } else {
65
- acc[name] = instances.pickMerge(name);
66
- }
67
- return acc;
68
- },
69
- {}
70
- );
71
- },
72
- };
73
-
74
- const isolateOpts: Record<string, any> = {[stateSourceName]: stateLense};
75
-
76
- globalList.forEach((global) => (isolateOpts[global] = null));
77
- combineList.forEach((combine) => (isolateOpts[combine] = null));
78
-
79
- return makeIsolatedCollection(collectionOpts, isolateOpts, sources);
80
- };
81
- }
82
-
83
- function makeIsolatedCollection(
84
- collectionOpts: any,
85
- isolateOpts: any,
86
- sources: any
87
- ): any {
88
- return isolate(makeCollection(collectionOpts), isolateOpts)(sources);
89
- }
1
+ import {h} from './cycle/dom/snabbdom';
2
+ // the core's handler for this marker, registered on import (D157)
3
+ import './core/hosts/collection';
90
4
 
5
+ /** `<Collection of={Item} from="items" />`: a marker vnode the core's Collection host renders */
91
6
  const Collection = (props: any) => {
92
7
  const {children, ...sanitizedProps} = props;
93
8
  return h('collection', {props: sanitizedProps}, children);
94
9
  };
95
- (Collection as any).label = 'collection';
10
+ (Collection as any).componentName = 'collection';
96
11
  (Collection as any).preventInstantiation = true;
97
12
 
98
13
  export {Collection};
14
+ export default Collection;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * PLAN-4.6 core: running one action (03-proposal §3, 04 §2.4.1).
3
+ *
4
+ * The action's handlers run in model order with (pre, data, next, props), where `pre` is the
5
+ * state (calculated fields included) from before the action, for every sink:
6
+ * - STATE: applied at once (D165). ABORT, or the object it was given (GS-4), is no change.
7
+ * D205: during an input / change event (an action triggered by typing in a field), no change
8
+ * still re-renders the instance, so a controlled field shows the model's value again
9
+ * - EFFECT: run synchronously (preventDefault on the live event still works); `props.signal`
10
+ * aborts on dispose; a returned value is SYG219, a rejected promise SYG214.
11
+ * - PARENT: straight to the parent's CHILD.select listeners as { name, component, value }.
12
+ * - READY: the instance's ready flag (the parent re-renders it with data-sygnal-ready).
13
+ * - ELEMENT: element commands, run after the next patch (extra/elementCommands).
14
+ * - any other sink (EVENTS, LOG, drivers): stamped and scoped (send), then the app's bus.
15
+ * A dispatch from a handler (a driver answering synchronously, an EFFECT) is queued (FIFO).
16
+ */
17
+ import type {Inst} from './instance'
18
+ import {isAbort} from '../shared'
19
+ import {isObj} from './define'
20
+ import {warn, error as logError, fail} from '../extra/diagnostics/legacy'
21
+ import {runElementCommands} from '../extra/elementCommands'
22
+ import {viewOf} from './view'
23
+ import {checkStatics} from './statics'
24
+ import {objIsEqual} from '../cycle/state/objIsEqual'
25
+ import {dbg} from './debug'
26
+
27
+ export function handle(inst: Inst, type: string, data: any, cause: any, src?: string) {
28
+ const hs = inst.def.handlers.get(type), app = inst.app, H = app.hooks
29
+ // (an action with no model entry is seen too: the action log lists it with no sinks)
30
+ if (H.onAction) H.onAction(viewOf(inst), {type, data, cause, target: viewOf(inst), source: src})
31
+ dbg(inst, () => `<${type}> Action triggered`)
32
+ if (!hs) return
33
+ const def = inst.def
34
+ const pre = inst.cell.get()
35
+ let props: any, outs: any[] | undefined
36
+ const next = (t: string, d?: any, ms: any = 10, effect?: boolean) => {
37
+ if (typeof ms !== 'number') fail('SYG215', inst, `next() delay in '${type}' must be a number`, "Use next('ACTION', data, ms)")
38
+ // G-300: none for an instance being disposed; dispose() clears the pending ones
39
+ if (inst.disposed || inst.dying) return dbg(inst, () => `next(${t}) ignored: disposed`)
40
+ H.onNext?.(viewOf(inst), t, d, ms)
41
+ dbg(inst, () => `<${type}> ${effect ? 'EFFECT triggered' : 'Triggered'} a next() action: <${t}> ${ms}ms delay`)
42
+ const ts = inst.timers ||= new Set()
43
+ const id = setTimeout(() => { ts.delete(id); inst.disposed || app.dispatch(inst, t, d, 'next') }, ms)
44
+ ts.add(id)
45
+ }
46
+ for (const [sink, h0] of hs) {
47
+ const h = H.wrapHandler ? H.wrapHandler(viewOf(inst), type, sink, h0) || h0 : h0
48
+ if (sink == 'EFFECT') {
49
+ if (typeof h != 'function') continue
50
+ const failed = (e: any) => app.caught(inst, 'SYG214', `EFFECT handler '${type}' threw`, e, 'effect', type)
51
+ try {
52
+ const p = {...(props ||= inst_props(inst, pre)), signal: (inst.ac ||= globalThis.AbortController && new AbortController())?.signal}
53
+ const r = h(pre, data, (t: string, d?: any, ms?: any) => next(t, d, ms, true), p)
54
+ if (r?.then) r.then(null, failed)
55
+ else if (r !== undefined && !isAbort(r)) warn('SYG219', inst, `EFFECT handler '${type}' returned a value, which is ignored`, 'Use a STATE or driver sink')
56
+ } catch (e) { failed(e) }
57
+ continue
58
+ }
59
+ let v: any
60
+ if (typeof h == 'function') {
61
+ try { v = h(pre, data, next, props ||= inst_props(inst, pre)) } catch (e) {
62
+ app.caught(inst, 'SYG216', `Reducer for '${type}' threw; ${sink == 'STATE' ? 'state unchanged' : 'nothing sent'}`, e, 'reducer', type)
63
+ continue
64
+ }
65
+ } else v = h === undefined || h === true ? data : h
66
+ if (sink == 'STATE' && (isAbort(v) || v === pre)) {
67
+ // D205: the DOM event being dispatched (window.event) is the one this action came from
68
+ if (/^(input|change)$/.test((globalThis as any).event?.type)) inst.refresh()
69
+ continue
70
+ }
71
+ if (isAbort(v)) continue
72
+ if (sink == 'STATE') {
73
+ H.onReducer?.(viewOf(inst), type, pre, v)
74
+ dbg(inst, () => `<${type}> State reducer added`)
75
+ inst.cell.set(v)
76
+ // GS-12: this app's DOM driver patches inside a View Transition (makeViewTransitionDOMDriver
77
+ // reads the flag on its IsolateModule); includes?.: a non-array static lists nothing (G-228).
78
+ // Only for a state that changed structurally: today an equal one renders nothing (its
79
+ // request expires unused); here it would re-render the same view, so it asks for nothing
80
+ if (def.view.viewTransitions?.includes?.(type) && (v === undefined || !objIsEqual(pre, inst.cell.get()))) { const m = inst.dom?._isolateModule; if (m) m.vt = 1 }
81
+ continue
82
+ }
83
+ if (typeof v == 'symbol') { logError('SYG218', inst, `Reducer for '${type}' returned a symbol; nothing sent`, 'Return a value, or ABORT to send nothing'); continue }
84
+ if (v === undefined) warn('SYG217', inst, `Reducer for '${type}' sent undefined to the driver`, 'Return a value, or ABORT to send nothing')
85
+ if (H.onSink) H.onSink(viewOf(inst), type, sink, v)
86
+ dbg(inst, () => `<${type}> Data sent to [${sink}]: ${JSON.stringify(v)}`)
87
+ if (sink == 'PARENT') {
88
+ const e = {name: def.name, component: def.view, value: v}
89
+ if (inst.parent) inst.parent.toChild(e)
90
+ else app.out('PARENT', e)
91
+ } else if (sink == 'READY') inst.setReady(!!v)
92
+ else if (sink == 'ELEMENT') {
93
+ // onElementCommand returning false: recorded, not run (renderComponent's mock DOM)
94
+ if (H.onElementCommand?.(viewOf(inst), v) !== false) runElementCommands(inst.el ||= {name: def.name, DOMSourceName: 'DOM', sources: {DOM: inst.dom}, get _disposed() { return inst.disposed }}, v)
95
+ } else if (inst.st) (outs ||= []).push(sink, v)
96
+ else send(inst, sink, v)
97
+ }
98
+ // G-158 (D170/Q21): a static this action changed reaches its driver before the action's own
99
+ // driver values (a connection the action opens exists before its first message)
100
+ if (inst.st) {
101
+ checkStatics(inst)
102
+ if (outs) for (let i = 0; i < outs.length; i += 2) send(inst, outs[i], outs[i + 1])
103
+ }
104
+ }
105
+
106
+ /** the handlers' 4th argument: the props, children, slots, context, uid and the pre-action state */
107
+ function inst_props(inst: Inst, pre: any) {
108
+ return {...inst.props, children: inst.children, slots: inst.slots, context: inst.context(), uid: inst.uid, state: pre}
109
+ }
110
+
111
+ /**
112
+ * A sink value of an instance: stamped with its sender (EVENTS; object values for a reply-capable
113
+ * source), scoped through every ancestor's isolation (a driver's value-level isolateValue, else
114
+ * one stream per instance and sink through isolateSink), then onto the app's bus for that sink.
115
+ */
116
+ export function send(inst: Inst, n: string, v: any) {
117
+ const app = inst.app, src = app.sources[n]
118
+ if (n == 'EVENTS' || (src?.__sygnalReplies && isObj(v))) {
119
+ v = Object.defineProperties({...v}, {__emitterId: {value: inst.id, configurable: true}, __emitterName: {value: inst.def.name, configurable: true}})
120
+ }
121
+ if (inst.parent && src && typeof src.isolateSink == 'function') {
122
+ let w = v
123
+ for (let i: Inst = inst; i.parent; i = i.parent) {
124
+ const o = i.parent.src(n)
125
+ if (typeof o?.isolateValue != 'function') return app.pipe(inst, n, v, (s$: any) => {
126
+ for (let j: Inst = inst; j.parent; j = j.parent) { const p = j.parent.src(n); if (typeof p?.isolateSink == 'function') s$ = p.isolateSink(s$, j.scope) }
127
+ return s$
128
+ }, (x: any) => app.out(n, x))
129
+ w = o.isolateValue(w, i.scope)
130
+ }
131
+ v = w
132
+ }
133
+ app.out(n, v)
134
+ }