sygnal 5.4.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/CHANGELOG.md +716 -0
  2. package/README.md +24 -9
  3. package/dist/ai.cjs.js +115 -0
  4. package/dist/ai.cjs.js.map +1 -0
  5. package/dist/ai.esm.js +2 -0
  6. package/dist/ai.esm.js.map +1 -0
  7. package/dist/astro/client.cjs.js +16 -9
  8. package/dist/astro/client.cjs.js.map +1 -1
  9. package/dist/astro/client.mjs +16 -9
  10. package/dist/astro/client.mjs.map +1 -1
  11. package/dist/astro/index.cjs.js +958 -92
  12. package/dist/astro/index.cjs.js.map +1 -1
  13. package/dist/astro/index.mjs +958 -93
  14. package/dist/astro/index.mjs.map +1 -1
  15. package/dist/astro/server.cjs.js +3396 -165
  16. package/dist/astro/server.cjs.js.map +1 -1
  17. package/dist/astro/server.mjs +3396 -165
  18. package/dist/astro/server.mjs.map +1 -1
  19. package/dist/devtools.cjs.js +1840 -0
  20. package/dist/devtools.cjs.js.map +1 -0
  21. package/dist/devtools.esm.js +1827 -0
  22. package/dist/devtools.esm.js.map +1 -0
  23. package/dist/diagnostics.cjs.js +3190 -296
  24. package/dist/diagnostics.cjs.js.map +1 -1
  25. package/dist/diagnostics.esm.js +3190 -296
  26. package/dist/diagnostics.esm.js.map +1 -1
  27. package/dist/element.cjs.js +230 -0
  28. package/dist/element.cjs.js.map +1 -0
  29. package/dist/element.esm.js +228 -0
  30. package/dist/element.esm.js.map +1 -0
  31. package/dist/guide/accessibility.md +310 -0
  32. package/dist/guide/adapters.md +221 -0
  33. package/dist/guide/agent.md +588 -0
  34. package/dist/guide/ai-chat.md +693 -0
  35. package/dist/guide/ai-decisions.md +330 -0
  36. package/dist/guide/behaviors.md +312 -0
  37. package/dist/guide/browser-sources.md +203 -0
  38. package/dist/guide/drag-and-drop.md +342 -0
  39. package/dist/guide/element-commands.md +306 -0
  40. package/dist/guide/error-boundaries.md +169 -0
  41. package/dist/guide/forms-reference.md +409 -0
  42. package/dist/guide/forms.md +251 -0
  43. package/dist/guide/http.md +301 -0
  44. package/dist/guide/inputs.md +173 -0
  45. package/dist/guide/mcp-apps.md +272 -0
  46. package/dist/guide/persistence.md +245 -0
  47. package/dist/guide/recipes/ai-form-fill.md +163 -0
  48. package/dist/guide/recipes/ai-summarize.md +155 -0
  49. package/dist/guide/recipes/ai-support-inbox.md +190 -0
  50. package/dist/guide/recipes/carousel.md +155 -0
  51. package/dist/guide/recipes/charts.md +177 -0
  52. package/dist/guide/recipes/code-editor.md +135 -0
  53. package/dist/guide/recipes/data-grid.md +155 -0
  54. package/dist/guide/recipes/data-table.md +196 -0
  55. package/dist/guide/recipes/i18n.md +222 -0
  56. package/dist/guide/recipes/icons.md +115 -0
  57. package/dist/guide/recipes/overview.md +43 -0
  58. package/dist/guide/recipes/rich-text.md +154 -0
  59. package/dist/guide/resources.md +471 -0
  60. package/dist/guide/ssr.md +255 -0
  61. package/dist/guide/timers.md +178 -0
  62. package/dist/guide/ui/accordion.md +93 -0
  63. package/dist/guide/ui/combobox.md +144 -0
  64. package/dist/guide/ui/dialog.md +124 -0
  65. package/dist/guide/ui/disclosure.md +60 -0
  66. package/dist/guide/ui/menu.md +125 -0
  67. package/dist/guide/ui/overview.md +166 -0
  68. package/dist/guide/ui/popover.md +101 -0
  69. package/dist/guide/ui/select.md +114 -0
  70. package/dist/guide/ui/tabs.md +161 -0
  71. package/dist/guide/ui/toaster.md +152 -0
  72. package/dist/guide/ui/tooltip.md +103 -0
  73. package/dist/guide/undo.md +178 -0
  74. package/dist/guide/virtual-collections.md +183 -0
  75. package/dist/guide/web-components.md +179 -0
  76. package/dist/guide/webmcp.md +226 -0
  77. package/dist/guide/widgets.md +217 -0
  78. package/dist/index.cjs.js +19288 -7408
  79. package/dist/index.cjs.js.map +1 -1
  80. package/dist/index.d.ts +4466 -552
  81. package/dist/index.esm.js +19274 -7461
  82. package/dist/index.esm.js.map +1 -1
  83. package/dist/jsx-dev-runtime.cjs.js +26 -334
  84. package/dist/jsx-dev-runtime.cjs.js.map +1 -1
  85. package/dist/jsx-dev-runtime.esm.js +19 -327
  86. package/dist/jsx-dev-runtime.esm.js.map +1 -1
  87. package/dist/jsx-runtime.cjs.js +26 -334
  88. package/dist/jsx-runtime.cjs.js.map +1 -1
  89. package/dist/jsx-runtime.esm.js +19 -327
  90. package/dist/jsx-runtime.esm.js.map +1 -1
  91. package/dist/jsx.cjs.js +10 -314
  92. package/dist/jsx.cjs.js.map +1 -1
  93. package/dist/jsx.esm.js +8 -315
  94. package/dist/jsx.esm.js.map +1 -1
  95. package/dist/react.cjs.js +117 -0
  96. package/dist/react.cjs.js.map +1 -0
  97. package/dist/react.esm.js +115 -0
  98. package/dist/react.esm.js.map +1 -0
  99. package/dist/shims/globalthis.cjs +20 -0
  100. package/dist/sygnal.min.js +1 -1
  101. package/dist/sygnal.min.js.map +1 -1
  102. package/dist/ui-combobox.cjs.js +169 -0
  103. package/dist/ui-combobox.cjs.js.map +1 -0
  104. package/dist/ui-combobox.esm.js +148 -0
  105. package/dist/ui-combobox.esm.js.map +1 -0
  106. package/dist/ui-menu.cjs.js +87 -0
  107. package/dist/ui-menu.cjs.js.map +1 -0
  108. package/dist/ui-menu.esm.js +66 -0
  109. package/dist/ui-menu.esm.js.map +1 -0
  110. package/dist/ui-select.cjs.js +104 -0
  111. package/dist/ui-select.cjs.js.map +1 -0
  112. package/dist/ui-select.esm.js +83 -0
  113. package/dist/ui-select.esm.js.map +1 -0
  114. package/dist/ui.cjs.js +738 -0
  115. package/dist/ui.cjs.js.map +1 -0
  116. package/dist/ui.esm.js +727 -0
  117. package/dist/ui.esm.js.map +1 -0
  118. package/dist/vike/ClientOnly.cjs.js +4 -14
  119. package/dist/vike/ClientOnly.cjs.js.map +1 -1
  120. package/dist/vike/ClientOnly.mjs +4 -14
  121. package/dist/vike/ClientOnly.mjs.map +1 -1
  122. package/dist/vike/{+config.js → config/+config.js} +9 -1
  123. package/dist/vike/config/+config.js.map +1 -0
  124. package/dist/vike/config/package.json +6 -0
  125. package/dist/vike/onRenderClient.cjs.js +165 -95
  126. package/dist/vike/onRenderClient.cjs.js.map +1 -1
  127. package/dist/vike/onRenderClient.mjs +165 -95
  128. package/dist/vike/onRenderClient.mjs.map +1 -1
  129. package/dist/vike/onRenderHtml.cjs.js +59 -24
  130. package/dist/vike/onRenderHtml.cjs.js.map +1 -1
  131. package/dist/vike/onRenderHtml.mjs +60 -25
  132. package/dist/vike/onRenderHtml.mjs.map +1 -1
  133. package/dist/vite/plugin.cjs.js +919 -89
  134. package/dist/vite/plugin.cjs.js.map +1 -1
  135. package/dist/vite/plugin.mjs +919 -90
  136. package/dist/vite/plugin.mjs.map +1 -1
  137. package/dist/zag.cjs.js +408 -0
  138. package/dist/zag.cjs.js.map +1 -0
  139. package/dist/zag.esm.js +405 -0
  140. package/dist/zag.esm.js.map +1 -0
  141. package/llms.txt +172 -103
  142. package/package.json +112 -14
  143. package/src/ai.d.ts +1186 -0
  144. package/src/ai.ts +23 -0
  145. package/src/astro/client.ts +27 -16
  146. package/src/astro/index.d.ts +24 -0
  147. package/src/astro/index.ts +69 -3
  148. package/src/astro/server.ts +8 -2
  149. package/src/collection.ts +6 -93
  150. package/src/core/actions.ts +134 -0
  151. package/src/core/cell.ts +202 -0
  152. package/src/core/debug.ts +23 -0
  153. package/src/core/define.ts +242 -0
  154. package/src/core/hooks.ts +314 -0
  155. package/src/core/hosts/collection.ts +325 -0
  156. package/src/core/hosts/switchable.ts +146 -0
  157. package/src/core/instance.ts +592 -0
  158. package/src/core/markers/clientonly.ts +13 -0
  159. package/src/core/markers/lazy.ts +40 -0
  160. package/src/core/markers/portal.ts +96 -0
  161. package/src/core/markers/suspense.ts +41 -0
  162. package/src/core/markers/transition.ts +70 -0
  163. package/src/core/registry.ts +25 -0
  164. package/src/core/runtime.ts +573 -0
  165. package/src/core/statics.ts +104 -0
  166. package/src/core/teardown.ts +60 -0
  167. package/src/core/view.ts +37 -0
  168. package/src/cycle/dom/DocumentDOMSource.ts +13 -8
  169. package/src/cycle/dom/ElementFinder.ts +7 -9
  170. package/src/cycle/dom/EventDelegator.ts +174 -223
  171. package/src/cycle/dom/IsolateModule.ts +65 -35
  172. package/src/cycle/dom/MainDOMSource.ts +9 -2
  173. package/src/cycle/dom/PriorityQueue.ts +4 -2
  174. package/src/cycle/dom/SymbolTree.ts +18 -47
  175. package/src/cycle/dom/classNameModule.ts +9 -7
  176. package/src/cycle/dom/controlledInputModule.ts +23 -6
  177. package/src/cycle/dom/enrichEventStream.ts +25 -47
  178. package/src/cycle/dom/fragment.ts +7 -0
  179. package/src/cycle/dom/isolate.ts +30 -27
  180. package/src/cycle/dom/makeDOMDriver.ts +115 -56
  181. package/src/cycle/dom/mockDOMSource.ts +21 -1
  182. package/src/cycle/dom/modules.ts +16 -3
  183. package/src/cycle/dom/propsModule.ts +65 -0
  184. package/src/cycle/dom/selectModule.ts +22 -17
  185. package/src/cycle/dom/snabbdom.ts +1 -6
  186. package/src/cycle/dom/thunk.ts +3 -0
  187. package/src/cycle/dom/utils.ts +98 -0
  188. package/src/cycle/dom/viewTransition.ts +43 -0
  189. package/src/cycle/state/StateSource.ts +19 -3
  190. package/src/cycle/state/objIsEqual.ts +50 -0
  191. package/src/cycle/state/types.ts +0 -10
  192. package/src/defineComponent.ts +34 -0
  193. package/src/devtools.d.ts +170 -0
  194. package/src/devtools.ts +37 -0
  195. package/src/element.d.ts +59 -0
  196. package/src/element.ts +235 -0
  197. package/src/extra/ai/agent/index.ts +484 -0
  198. package/src/extra/ai/answers.ts +115 -0
  199. package/src/extra/ai/chat/behavior.ts +336 -0
  200. package/src/extra/ai/chat/driver.ts +271 -0
  201. package/src/extra/ai/chat/memoryTransport.ts +61 -0
  202. package/src/extra/ai/chat/output.ts +37 -0
  203. package/src/extra/ai/commandBar.ts +281 -0
  204. package/src/extra/ai/decide.ts +104 -0
  205. package/src/extra/ai/index.ts +42 -0
  206. package/src/extra/ai/link.ts +90 -0
  207. package/src/extra/ai/mcpApp.ts +314 -0
  208. package/src/extra/ai/messages.ts +51 -0
  209. package/src/extra/ai/schema/index.ts +166 -0
  210. package/src/extra/ai/schema/jsonSchema.ts +72 -0
  211. package/src/extra/ai/schema/strict.ts +152 -0
  212. package/src/extra/ai/transports/agui.ts +177 -0
  213. package/src/extra/ai/transports/anthropicMessages.ts +175 -0
  214. package/src/extra/ai/transports/chatCompletions.ts +105 -0
  215. package/src/extra/ai/transports/chromePrompt.ts +77 -0
  216. package/src/extra/ai/transports/encodeOpenResponses.ts +87 -0
  217. package/src/extra/ai/transports/fromAISDK.ts +126 -0
  218. package/src/extra/ai/transports/openResponses.ts +105 -0
  219. package/src/extra/ai/transports/shared.ts +125 -0
  220. package/src/extra/ai/transports/tools.ts +59 -0
  221. package/src/extra/ai/transports/uiMessageStream.ts +107 -0
  222. package/src/extra/ai/webmcp.ts +260 -0
  223. package/src/extra/backoff.ts +9 -0
  224. package/src/extra/behaviors.ts +169 -0
  225. package/src/extra/browserSignals.ts +23 -0
  226. package/src/extra/browserSources.ts +326 -0
  227. package/src/extra/command.ts +3 -3
  228. package/src/extra/controls.ts +47 -0
  229. package/src/extra/copyAsTest.ts +286 -0
  230. package/src/extra/devMcp.ts +386 -0
  231. package/src/extra/devtools.ts +101 -31
  232. package/src/extra/devtoolsActions.ts +379 -0
  233. package/src/extra/devtoolsHook.ts +9 -0
  234. package/src/extra/devtoolsNext.ts +83 -0
  235. package/src/extra/diagnostics/checks/actionLog.ts +108 -0
  236. package/src/extra/diagnostics/checks/behaviors.ts +49 -0
  237. package/src/extra/diagnostics/checks/browserSources.ts +96 -0
  238. package/src/extra/diagnostics/checks/chat.ts +71 -0
  239. package/src/extra/diagnostics/checks/collections.ts +1 -1
  240. package/src/extra/diagnostics/checks/controls.ts +148 -0
  241. package/src/extra/diagnostics/checks/dataset.ts +57 -0
  242. package/src/extra/diagnostics/checks/dom.ts +20 -11
  243. package/src/extra/diagnostics/checks/elementCommands.ts +175 -0
  244. package/src/extra/diagnostics/checks/events.ts +17 -2
  245. package/src/extra/diagnostics/checks/fetch.ts +135 -0
  246. package/src/extra/diagnostics/checks/forms.ts +171 -0
  247. package/src/extra/diagnostics/checks/index.ts +103 -4
  248. package/src/extra/diagnostics/checks/inspect.ts +140 -32
  249. package/src/extra/diagnostics/checks/next.ts +417 -0
  250. package/src/extra/diagnostics/checks/persist.ts +54 -0
  251. package/src/extra/diagnostics/checks/props.ts +10 -5
  252. package/src/extra/diagnostics/checks/public.d.ts +115 -7
  253. package/src/extra/diagnostics/checks/replies.ts +128 -0
  254. package/src/extra/diagnostics/checks/router.ts +100 -0
  255. package/src/extra/diagnostics/checks/rxjsHints.ts +1 -1
  256. package/src/extra/diagnostics/checks/shared.ts +86 -2
  257. package/src/extra/diagnostics/checks/shorthand.ts +115 -0
  258. package/src/extra/diagnostics/checks/sortable.ts +129 -0
  259. package/src/extra/diagnostics/checks/state.ts +100 -7
  260. package/src/extra/diagnostics/checks/statics.ts +48 -0
  261. package/src/extra/diagnostics/checks/strict.ts +10 -67
  262. package/src/extra/diagnostics/checks/timers.ts +80 -0
  263. package/src/extra/diagnostics/checks/viewTransitions.ts +47 -0
  264. package/src/extra/diagnostics/checks/virtual.ts +73 -0
  265. package/src/extra/diagnostics/checks/widgets.ts +109 -0
  266. package/src/extra/diagnostics/checks/wiring.ts +69 -10
  267. package/src/extra/diagnostics/codes.ts +335 -23
  268. package/src/extra/diagnostics/index.ts +34 -9
  269. package/src/extra/diagnostics/legacy.ts +17 -0
  270. package/src/extra/driverFactories.ts +83 -19
  271. package/src/extra/elementCommands.ts +53 -0
  272. package/src/extra/fetchDriver.ts +519 -0
  273. package/src/extra/focusWithin.ts +27 -0
  274. package/src/extra/form.ts +284 -0
  275. package/src/extra/formHelpers.ts +139 -0
  276. package/src/extra/formTool.ts +150 -0
  277. package/src/extra/head.ts +106 -0
  278. package/src/extra/hmr.ts +2 -3
  279. package/src/extra/owned.ts +24 -0
  280. package/src/extra/pager.ts +50 -0
  281. package/src/extra/persist.ts +133 -0
  282. package/src/extra/pwa.ts +1 -1
  283. package/src/extra/queryCache.ts +107 -0
  284. package/src/extra/reducers.ts +1 -1
  285. package/src/extra/reduxDevtools.ts +92 -0
  286. package/src/extra/replies.ts +54 -0
  287. package/src/extra/router.ts +323 -0
  288. package/src/extra/run.ts +90 -217
  289. package/src/extra/selection.ts +76 -0
  290. package/src/extra/socketDriver.ts +265 -0
  291. package/src/extra/sortable.ts +377 -0
  292. package/src/extra/ssr.ts +427 -160
  293. package/src/extra/standardSchema.ts +27 -0
  294. package/src/extra/testing.ts +2550 -175
  295. package/src/extra/timers.ts +95 -0
  296. package/src/extra/undo.ts +261 -0
  297. package/src/extra/viewTransitions.ts +38 -0
  298. package/src/extra/virtual.ts +513 -0
  299. package/src/extra/widget.ts +201 -0
  300. package/src/index.d.ts +2754 -127
  301. package/src/index.ts +45 -4
  302. package/src/jsx-runtime.ts +15 -1
  303. package/src/jsx.ts +2 -1
  304. package/src/lazy.ts +50 -7
  305. package/src/portal.ts +3 -1
  306. package/src/pragma/index.ts +256 -133
  307. package/src/react-peers.d.ts +5 -0
  308. package/src/react.d.ts +43 -0
  309. package/src/react.ts +110 -0
  310. package/src/shared.ts +57 -0
  311. package/src/slot.ts +1 -1
  312. package/src/suspense.ts +3 -1
  313. package/src/switchable.ts +6 -121
  314. package/src/transition.ts +3 -1
  315. package/src/ui/accordion.ts +64 -0
  316. package/src/ui/dialog.ts +129 -0
  317. package/src/ui/disclosure.ts +35 -0
  318. package/src/ui/popover.ts +45 -0
  319. package/src/ui/shared.ts +94 -0
  320. package/src/ui/tabs.ts +82 -0
  321. package/src/ui/toaster.ts +198 -0
  322. package/src/ui/tooltip.ts +70 -0
  323. package/src/ui/zag/combobox.ts +115 -0
  324. package/src/ui/zag/menu.ts +40 -0
  325. package/src/ui/zag/select.ts +54 -0
  326. package/src/ui/zag/shared.ts +43 -0
  327. package/src/ui-combobox.d.ts +20 -0
  328. package/src/ui-combobox.ts +6 -0
  329. package/src/ui-menu.d.ts +30 -0
  330. package/src/ui-menu.ts +6 -0
  331. package/src/ui-select.d.ts +17 -0
  332. package/src/ui-select.ts +6 -0
  333. package/src/ui-zag-types.d.ts +42 -0
  334. package/src/ui.d.ts +208 -0
  335. package/src/ui.ts +15 -0
  336. package/src/vike/+config.ts +9 -1
  337. package/src/vike/ClientOnly.ts +1 -1
  338. package/src/vike/onRenderClient.ts +144 -96
  339. package/src/vike/onRenderHtml.ts +69 -26
  340. package/src/vike/types.ts +7 -1
  341. package/src/vite/globalthis-shim.ts +18 -0
  342. package/src/vite/globalthis.ts +56 -0
  343. package/src/vite/mcp.ts +568 -0
  344. package/src/vite/plugin.d.ts +47 -3
  345. package/src/vite/plugin.ts +262 -25
  346. package/src/zag.d.ts +64 -0
  347. package/src/zag.ts +238 -0
  348. package/dist/vike/+config.cjs.js +0 -66
  349. package/dist/vike/+config.cjs.js.map +0 -1
  350. package/dist/vike/+config.js.map +0 -1
  351. package/src/component.ts +0 -2301
  352. package/src/cycle/isolate/index.ts +0 -196
  353. package/src/cycle/run/index.ts +0 -151
  354. package/src/cycle/run/internals.ts +0 -143
  355. package/src/cycle/state/Collection.ts +0 -184
  356. package/src/cycle/state/index.ts +0 -5
  357. package/src/cycle/state/pickCombine.ts +0 -201
  358. package/src/cycle/state/pickMerge.ts +0 -122
  359. package/src/cycle/state/withState.ts +0 -47
  360. package/src/pragma/fn.ts +0 -55
package/README.md CHANGED
@@ -14,7 +14,7 @@ A reactive component framework with pure functions, zero side effects, and autom
14
14
  - **Pure components** — Views are plain functions. All side effects are handled by drivers, outside your code.
15
15
  - **Automatic state management** — Monolithic state tree with no store setup, no providers, no hooks. Trivial undo/redo and time-travel debugging.
16
16
  - **Model-View-Intent** — Cleanly separate *what* happens (Model), *when* it happens (Intent), and *how* it looks (View).
17
- - **Tiny footprint** — Three runtime dependencies: [snabbdom](https://github.com/snabbdom/snabbdom), [xstream](https://github.com/staltz/xstream), and [extend](https://github.com/nicjohnson145/extend).
17
+ - **Tiny footprint** — Two runtime dependencies: [snabbdom](https://github.com/snabbdom/snabbdom) and [xstream](https://github.com/staltz/xstream).
18
18
 
19
19
  ## Quick Start
20
20
 
@@ -186,19 +186,34 @@ import { makeDragDriver } from 'sygnal'
186
186
  run(RootComponent, { DND: makeDragDriver() })
187
187
  ```
188
188
 
189
+ ### HTTP and Sockets
190
+
191
+ Requests name the actions that receive their reply; connections are declared from state:
192
+
193
+ ```jsx
194
+ import { run, makeFetchDriver, makeSocketDriver } from 'sygnal'
195
+
196
+ Quote.model = {
197
+ LOAD: { HTTP: (state, id) => ({ url: `/api/quotes/${id}`, ok: 'LOADED', error: 'FAILED', latest: true }) },
198
+ LOADED: (state, quote) => ({ ...state, quote }), // the parsed body
199
+ FAILED: (state, { status }) => ({ ...state, error: status }),
200
+ }
201
+
202
+ Chat.connections = (state) => ({
203
+ room: state.room && { socket: `/ws/rooms/${state.room}`, message: 'RECEIVED' },
204
+ })
205
+
206
+ run(App, { HTTP: makeFetchDriver(), WS: makeSocketDriver() })
207
+ ```
208
+
189
209
  ### Custom Drivers
190
210
 
191
- Wrap any async operation as a driver:
211
+ Wrap any other async operation as a driver; requests take the same reply actions (`{ value, ok: 'DONE', error: 'FAILED' }`):
192
212
 
193
213
  ```javascript
194
214
  import { driverFromAsync } from 'sygnal'
195
215
 
196
- const apiDriver = driverFromAsync(async (url) => {
197
- const res = await fetch(url)
198
- return res.json()
199
- }, { selector: 'endpoint', args: 'url', return: 'data' })
200
-
201
- run(RootComponent, { API: apiDriver })
216
+ run(RootComponent, { GEO: driverFromAsync(geocode) })
202
217
  ```
203
218
 
204
219
  ### Error Boundaries
@@ -508,7 +523,7 @@ h('div', [h('h1', 'Hello'), h('button.btn', 'Click')])
508
523
 
509
524
  ## Acknowledgments
510
525
 
511
- Sygnal's reactive architecture is built on patterns from [Cycle.js](https://cycle.js.org/) by [André Staltz](https://github.com/staltz). The Cycle.js runtime, DOM driver, state management, and isolation modules have been absorbed into the library — snabbdom, xstream, and extend are the only external dependencies.
526
+ Sygnal's reactive architecture is built on patterns from [Cycle.js](https://cycle.js.org/) by [André Staltz](https://github.com/staltz). The Cycle.js runtime, DOM driver, state management, and isolation modules have been absorbed into the library — snabbdom and xstream are the only external dependencies.
512
527
 
513
528
  ## License
514
529
 
package/dist/ai.cjs.js ADDED
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ var sygnal = require('sygnal');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, 'agentTools', {
8
+ enumerable: true,
9
+ get: function () { return sygnal.agentTools; }
10
+ });
11
+ Object.defineProperty(exports, 'agui', {
12
+ enumerable: true,
13
+ get: function () { return sygnal.agui; }
14
+ });
15
+ Object.defineProperty(exports, 'answers', {
16
+ enumerable: true,
17
+ get: function () { return sygnal.answers; }
18
+ });
19
+ Object.defineProperty(exports, 'anthropicMessages', {
20
+ enumerable: true,
21
+ get: function () { return sygnal.anthropicMessages; }
22
+ });
23
+ Object.defineProperty(exports, 'chat', {
24
+ enumerable: true,
25
+ get: function () { return sygnal.chat; }
26
+ });
27
+ Object.defineProperty(exports, 'chatCompletions', {
28
+ enumerable: true,
29
+ get: function () { return sygnal.chatCompletions; }
30
+ });
31
+ Object.defineProperty(exports, 'choice', {
32
+ enumerable: true,
33
+ get: function () { return sygnal.choice; }
34
+ });
35
+ Object.defineProperty(exports, 'chromePrompt', {
36
+ enumerable: true,
37
+ get: function () { return sygnal.chromePrompt; }
38
+ });
39
+ Object.defineProperty(exports, 'commandBar', {
40
+ enumerable: true,
41
+ get: function () { return sygnal.commandBar; }
42
+ });
43
+ Object.defineProperty(exports, 'decide', {
44
+ enumerable: true,
45
+ get: function () { return sygnal.decide; }
46
+ });
47
+ Object.defineProperty(exports, 'encodeOpenResponses', {
48
+ enumerable: true,
49
+ get: function () { return sygnal.encodeOpenResponses; }
50
+ });
51
+ Object.defineProperty(exports, 'experimentalExposeWebMcp', {
52
+ enumerable: true,
53
+ get: function () { return sygnal.experimentalExposeWebMcp; }
54
+ });
55
+ Object.defineProperty(exports, 'formTool', {
56
+ enumerable: true,
57
+ get: function () { return sygnal.formTool; }
58
+ });
59
+ Object.defineProperty(exports, 'fromAISDK', {
60
+ enumerable: true,
61
+ get: function () { return sygnal.fromAISDK; }
62
+ });
63
+ Object.defineProperty(exports, 'jsonSchema', {
64
+ enumerable: true,
65
+ get: function () { return sygnal.jsonSchema; }
66
+ });
67
+ Object.defineProperty(exports, 'makeChatDriver', {
68
+ enumerable: true,
69
+ get: function () { return sygnal.makeChatDriver; }
70
+ });
71
+ Object.defineProperty(exports, 'makeMcpAppDriver', {
72
+ enumerable: true,
73
+ get: function () { return sygnal.makeMcpAppDriver; }
74
+ });
75
+ Object.defineProperty(exports, 'messageText', {
76
+ enumerable: true,
77
+ get: function () { return sygnal.messageText; }
78
+ });
79
+ Object.defineProperty(exports, 'noul', {
80
+ enumerable: true,
81
+ get: function () { return sygnal.noul; }
82
+ });
83
+ Object.defineProperty(exports, 'openResponses', {
84
+ enumerable: true,
85
+ get: function () { return sygnal.openResponses; }
86
+ });
87
+ Object.defineProperty(exports, 'outputJsonSchema', {
88
+ enumerable: true,
89
+ get: function () { return sygnal.outputJsonSchema; }
90
+ });
91
+ Object.defineProperty(exports, 'parseInput', {
92
+ enumerable: true,
93
+ get: function () { return sygnal.parseInput; }
94
+ });
95
+ Object.defineProperty(exports, 'score', {
96
+ enumerable: true,
97
+ get: function () { return sygnal.score; }
98
+ });
99
+ Object.defineProperty(exports, 'strictSchemas', {
100
+ enumerable: true,
101
+ get: function () { return sygnal.strictSchemas; }
102
+ });
103
+ Object.defineProperty(exports, 'toJsonSchema', {
104
+ enumerable: true,
105
+ get: function () { return sygnal.toJsonSchema; }
106
+ });
107
+ Object.defineProperty(exports, 'uiMessageStream', {
108
+ enumerable: true,
109
+ get: function () { return sygnal.uiMessageStream; }
110
+ });
111
+ Object.defineProperty(exports, 'withToolResults', {
112
+ enumerable: true,
113
+ get: function () { return sygnal.withToolResults; }
114
+ });
115
+ //# sourceMappingURL=ai.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/ai.esm.js ADDED
@@ -0,0 +1,2 @@
1
+ export { agentTools, agui, answers, anthropicMessages, chat, chatCompletions, choice, chromePrompt, commandBar, decide, encodeOpenResponses, experimentalExposeWebMcp, formTool, fromAISDK, jsonSchema, makeChatDriver, makeMcpAppDriver, messageText, noul, openResponses, outputJsonSchema, parseInput, score, strictSchemas, toJsonSchema, uiMessageStream, withToolResults } from 'sygnal';
2
+ //# sourceMappingURL=ai.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var sygnal = require('sygnal');
4
+ var onError = require('virtual:sygnal/astro-on-error');
4
5
 
5
6
  // The public entry (external in the build), so islands share the app's
6
7
  // Sygnal core instead of a bundled copy (B-019).
7
8
  function looksLikeSygnalComponent(Component) {
8
9
  if (typeof Component !== 'function')
9
10
  return false;
10
- return Boolean(Component.isSygnalComponent ||
11
- Component.model ||
11
+ return Boolean(Component.model ||
12
12
  Component.intent ||
13
13
  Component.initialState ||
14
14
  Component.componentName);
@@ -35,17 +35,21 @@ var client = (element) => {
35
35
  const Wrapped = (args) => Component({ ...islandProps, ...args, props: islandProps });
36
36
  Wrapped.model = Component.model;
37
37
  Wrapped.intent = Component.intent;
38
- Wrapped.hmrActions = Component.hmrActions;
39
38
  Wrapped.context = Component.context;
40
- Wrapped.peers = Component.peers;
41
- Wrapped.components = Component.components;
42
39
  Wrapped.initialState = Component.initialState;
43
40
  Wrapped.calculated = Component.calculated;
44
- Wrapped.storeCalculatedInState = Component.storeCalculatedInState;
45
- Wrapped.DOMSourceName = Component.DOMSourceName;
46
- Wrapped.stateSourceName = Component.stateSourceName;
47
41
  Wrapped.onError = Component.onError;
48
42
  Wrapped.debug = Component.debug;
43
+ Wrapped.connections = Component.connections;
44
+ Wrapped.resources = Component.resources;
45
+ Wrapped.route = Component.route;
46
+ Wrapped.head = Component.head;
47
+ // PLAN-4 3-B2: more statics the core reads off the root view: persist (root only: the island
48
+ // is its app's root), uses, timers (they run only with a timer driver) and viewTransitions
49
+ Wrapped.persist = Component.persist;
50
+ Wrapped.uses = Component.uses;
51
+ Wrapped.timers = Component.timers;
52
+ Wrapped.viewTransitions = Component.viewTransitions;
49
53
  Wrapped.componentName = Component.componentName || Component.name;
50
54
  // run() names the root by `name` first: diagnostics and devtools should
51
55
  // say 'Counter', not 'Wrapped'
@@ -53,7 +57,10 @@ var client = (element) => {
53
57
  Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true });
54
58
  }
55
59
  catch (_) { }
56
- const app = sygnal.run(Wrapped, {}, { mountPoint });
60
+ // G-206: a `uid` island prop is the island's uid root (as on the server); the view's own
61
+ // uid() function wins over the prop (args are spread last)
62
+ // 3-B2: `__hydrate` tells persist() whether the island starts over the server's markup
63
+ const app = sygnal.run(Wrapped, { __hydrate: () => client !== 'only' && canHydrate }, { mountPoint, onError, uid: islandProps.uid });
57
64
  element.__sygnal = app;
58
65
  };
59
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"client.cjs.js","sources":["../../src/astro/client.ts"],"sourcesContent":["// The public entry (external in the build), so islands share the app's\n// Sygnal core instead of a bundled copy (B-019).\nimport { run } from 'sygnal'\n\ninterface SygnalComponent {\n (args: any): any;\n isSygnalComponent?: boolean;\n model?: any;\n intent?: any;\n hmrActions?: any;\n context?: any;\n peers?: any;\n components?: any;\n initialState?: any;\n calculated?: any;\n storeCalculatedInState?: any;\n DOMSourceName?: string;\n stateSourceName?: string;\n onError?: (error: Error, info: { componentName: string }) => any;\n debug?: boolean;\n componentName?: string;\n name?: string;\n}\n\ninterface AstroMetadata {\n client?: string;\n}\n\nfunction looksLikeSygnalComponent(Component: any): Component is SygnalComponent {\n if (typeof Component !== 'function') return false\n return Boolean(\n Component.isSygnalComponent ||\n Component.model ||\n Component.intent ||\n Component.initialState ||\n Component.componentName\n )\n}\n\nexport default (element: any) => {\n return async (Component: any, props: any, _slotted: any, metadata: AstroMetadata) => {\n if (!looksLikeSygnalComponent(Component)) return\n\n const mountPoint = element\n const { client } = metadata || {}\n const canHydrate = element.hasAttribute('ssr')\n\n if (client !== 'only' && !canHydrate) return\n\n const previous = element.__sygnal\n if (previous && typeof previous.dispose === 'function') {\n previous.dispose()\n }\n\n // Island props reach the view like any component's props, spread\n // top-level (`{ state, title }`), the same as on the server\n // (renderToString). The view args (state, context, ...) win over a prop\n // with the same name; `props` is kept for older `({ state, props })`\n // views (B-026).\n const islandProps = { ...(props || {}) }\n const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })\n Wrapped.model = Component.model\n Wrapped.intent = Component.intent\n Wrapped.hmrActions = Component.hmrActions\n Wrapped.context = Component.context\n Wrapped.peers = Component.peers\n Wrapped.components = Component.components\n Wrapped.initialState = Component.initialState\n Wrapped.calculated = Component.calculated\n Wrapped.storeCalculatedInState = Component.storeCalculatedInState\n Wrapped.DOMSourceName = Component.DOMSourceName\n Wrapped.stateSourceName = Component.stateSourceName\n Wrapped.onError = Component.onError\n Wrapped.debug = Component.debug\n Wrapped.componentName = Component.componentName || Component.name\n // run() names the root by `name` first: diagnostics and devtools should\n // say 'Counter', not 'Wrapped'\n try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}\n\n const app = run(Wrapped, {}, { mountPoint })\n element.__sygnal = app\n }\n}\n"],"names":["run"],"mappings":";;;;AAAA;AACA;AA2BA,SAAS,wBAAwB,CAAC,SAAc,EAAA;IAC9C,IAAI,O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O,GAAG,SAAS,CAAC,OAAO,CAAA;AACnC,QAAA,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAA;AAC/B,QAAA,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAA;AACzC,QAAA,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,YAAY,CAAA;AAC7C,QAAA,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAA;AACzC,QAAA,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,sBAAsB,CAAA;AACjE,QAAA,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAA;AAC/C,QAAA,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAA;AACnD,QAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AACnC,QAAA,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAA;QAC/B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,IAAI,CAAA;;;AAGjE,QAAA,IAAI;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;SAAE;AAAC,QAAA,OAAO,CAAC,EAAE,GAAE;AAEjH,QAAA,MAAM,GAAG,GAAGA,UAAG,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;AAC5C,QAAA,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAA;AACxB,KAAC,CAAA;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"client.cjs.js","sources":["../../src/astro/client.ts"],"sourcesContent":["// The public entry (external in the build), so islands share the app's\n// Sygnal core instead of a bundled copy (B-019).\nimport { run } from 'sygnal'\n// PLAN-4 GS-11 / D120: the app-level error hook, the default export of the module the\n// integration's `onError` option names (undefined without it); served by sygnal/astro's Vite plugin\n// @ts-ignore — a virtual module\nimport onError from 'virtual:sygnal/astro-on-error'\n\ninterface SygnalComponent {\n (args: any): any;\n model?: any;\n intent?: any;\n connections?: any;\n resources?: any;\n route?: any;\n head?: any;\n persist?: any;\n uses?: any;\n timers?: any;\n viewTransitions?: any;\n context?: any;\n initialState?: any;\n calculated?: any;\n onError?: (error: Error, info: { componentName: string }) => any;\n debug?: boolean;\n componentName?: string;\n name?: string;\n}\n\ninterface AstroMetadata {\n client?: string;\n}\n\nfunction looksLikeSygnalComponent(Component: any): Component is SygnalComponent {\n if (typeof Component !== 'function') return false\n return Boolean(\n Component.model ||\n Component.intent ||\n Component.initialState ||\n Component.componentName\n )\n}\n\nexport default (element: any) => {\n return async (Component: any, props: any, _slotted: any, metadata: AstroMetadata) => {\n if (!looksLikeSygnalComponent(Component)) return\n\n const mountPoint = element\n const { client } = metadata || {}\n const canHydrate = element.hasAttribute('ssr')\n\n if (client !== 'only' && !canHydrate) return\n\n const previous = element.__sygnal\n if (previous && typeof previous.dispose === 'function') {\n previous.dispose()\n }\n\n // Island props reach the view like any component's props, spread\n // top-level (`{ state, title }`), the same as on the server\n // (renderToString). The view args (state, context, ...) win over a prop\n // with the same name; `props` is kept for older `({ state, props })`\n // views (B-026).\n const islandProps = { ...(props || {}) }\n const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })\n Wrapped.model = Component.model\n Wrapped.intent = Component.intent\n Wrapped.context = Component.context\n Wrapped.initialState = Component.initialState\n Wrapped.calculated = Component.calculated\n Wrapped.onError = Component.onError\n Wrapped.debug = Component.debug\n Wrapped.connections = Component.connections\n Wrapped.resources = Component.resources\n Wrapped.route = Component.route\n Wrapped.head = Component.head\n // PLAN-4 3-B2: more statics the core reads off the root view: persist (root only: the island\n // is its app's root), uses, timers (they run only with a timer driver) and viewTransitions\n Wrapped.persist = Component.persist\n Wrapped.uses = Component.uses\n Wrapped.timers = Component.timers\n Wrapped.viewTransitions = Component.viewTransitions\n Wrapped.componentName = Component.componentName || Component.name\n // run() names the root by `name` first: diagnostics and devtools should\n // say 'Counter', not 'Wrapped'\n try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}\n\n // G-206: a `uid` island prop is the island's uid root (as on the server); the view's own\n // uid() function wins over the prop (args are spread last)\n // 3-B2: `__hydrate` tells persist() whether the island starts over the server's markup\n const app = run(Wrapped, { __hydrate: () => client !== 'only' && canHydrate }, { mountPoint, onError, uid: islandProps.uid })\n element.__sygnal = app\n }\n}\n"],"names":["run"],"mappings":";;;;;AAAA;AACA;AAgCA,SAAS,wBAAwB,CAAC,SAAc,EAAA;IAC9C,IAAI,OAAO,SAAS,KAAK,UAAU;AAAE,QAAA,OAAO,KAAK,CAAA;AACjD,IAAA,OAAO,OAAO,CACZ,SAAS,CAAC,KAAK;AACb,QAAA,SAAS,CAAC,MAAM;AAChB,QAAA,SAAS,CAAC,YAAY;QACtB,SAAS,CAAC,aAAa,CAC1B,CAAA;AACH,CAAC;AAED,aAAe,CAAC,OAAY,KAAI;IAC9B,OAAO,OAAO,SAAc,EAAE,KAAU,EAAE,QAAa,EAAE,QAAuB,KAAI;AAClF,QAAA,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC;YAAE,OAAM;QAEhD,MAAM,UAAU,GAAG,OAAO,CAAA;AAC1B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAA;QACjC,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAE9C,QAAA,IAAI,MAAM,KAAK,MAAM,IAAI,CAAC,UAAU;YAAE,OAAM;AAE5C,QAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QACjC,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE;YACtD,QAAQ,CAAC,OAAO,EAAE,CAAA;SACnB;;;;;;QAOD,MAAM,WA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Ac,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;SAAE;AAAC,QAAA,OAAO,CAAC,EAAE,GAAE;;;;AAKjH,QAAA,MAAM,GAAG,GAAGA,UAAG,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,MAAM,KAAK,MAAM,IAAI,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAA;AAC7H,QAAA,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAA;AACxB,KAAC,CAAA;AACH,CAAC;;;;"}
@@ -1,12 +1,12 @@
1
1
  import { run } from 'sygnal';
2
+ import onError from 'virtual:sygnal/astro-on-error';
2
3
 
3
4
  // The public entry (external in the build), so islands share the app's
4
5
  // Sygnal core instead of a bundled copy (B-019).
5
6
  function looksLikeSygnalComponent(Component) {
6
7
  if (typeof Component !== 'function')
7
8
  return false;
8
- return Boolean(Component.isSygnalComponent ||
9
- Component.model ||
9
+ return Boolean(Component.model ||
10
10
  Component.intent ||
11
11
  Component.initialState ||
12
12
  Component.componentName);
@@ -33,17 +33,21 @@ var client = (element) => {
33
33
  const Wrapped = (args) => Component({ ...islandProps, ...args, props: islandProps });
34
34
  Wrapped.model = Component.model;
35
35
  Wrapped.intent = Component.intent;
36
- Wrapped.hmrActions = Component.hmrActions;
37
36
  Wrapped.context = Component.context;
38
- Wrapped.peers = Component.peers;
39
- Wrapped.components = Component.components;
40
37
  Wrapped.initialState = Component.initialState;
41
38
  Wrapped.calculated = Component.calculated;
42
- Wrapped.storeCalculatedInState = Component.storeCalculatedInState;
43
- Wrapped.DOMSourceName = Component.DOMSourceName;
44
- Wrapped.stateSourceName = Component.stateSourceName;
45
39
  Wrapped.onError = Component.onError;
46
40
  Wrapped.debug = Component.debug;
41
+ Wrapped.connections = Component.connections;
42
+ Wrapped.resources = Component.resources;
43
+ Wrapped.route = Component.route;
44
+ Wrapped.head = Component.head;
45
+ // PLAN-4 3-B2: more statics the core reads off the root view: persist (root only: the island
46
+ // is its app's root), uses, timers (they run only with a timer driver) and viewTransitions
47
+ Wrapped.persist = Component.persist;
48
+ Wrapped.uses = Component.uses;
49
+ Wrapped.timers = Component.timers;
50
+ Wrapped.viewTransitions = Component.viewTransitions;
47
51
  Wrapped.componentName = Component.componentName || Component.name;
48
52
  // run() names the root by `name` first: diagnostics and devtools should
49
53
  // say 'Counter', not 'Wrapped'
@@ -51,7 +55,10 @@ var client = (element) => {
51
55
  Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true });
52
56
  }
53
57
  catch (_) { }
54
- const app = run(Wrapped, {}, { mountPoint });
58
+ // G-206: a `uid` island prop is the island's uid root (as on the server); the view's own
59
+ // uid() function wins over the prop (args are spread last)
60
+ // 3-B2: `__hydrate` tells persist() whether the island starts over the server's markup
61
+ const app = run(Wrapped, { __hydrate: () => client !== 'only' && canHydrate }, { mountPoint, onError, uid: islandProps.uid });
55
62
  element.__sygnal = app;
56
63
  };
57
64
  };
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","sources":["../../src/astro/client.ts"],"sourcesContent":["// The public entry (external in the build), so islands share the app's\n// Sygnal core instead of a bundled copy (B-019).\nimport { run } from 'sygnal'\n\ninterface SygnalComponent {\n (args: any): any;\n isSygnalComponent?: boolean;\n model?: any;\n intent?: any;\n hmrActions?: any;\n context?: any;\n peers?: any;\n components?: any;\n initialState?: any;\n calculated?: any;\n storeCalculatedInState?: any;\n DOMSourceName?: string;\n stateSourceName?: string;\n onError?: (error: Error, info: { componentName: string }) => any;\n debug?: boolean;\n componentName?: string;\n name?: string;\n}\n\ninterface AstroMetadata {\n client?: string;\n}\n\nfunction looksLikeSygnalComponent(Component: any): Component is SygnalComponent {\n if (typeof Component !== 'function') return false\n return Boolean(\n Component.isSygnalComponent ||\n Component.model ||\n Component.intent ||\n Component.initialState ||\n Component.componentName\n )\n}\n\nexport default (element: any) => {\n return async (Component: any, props: any, _slotted: any, metadata: AstroMetadata) => {\n if (!looksLikeSygnalComponent(Component)) return\n\n const mountPoint = element\n const { client } = metadata || {}\n const canHydrate = element.hasAttribute('ssr')\n\n if (client !== 'only' && !canHydrate) return\n\n const previous = element.__sygnal\n if (previous && typeof previous.dispose === 'function') {\n previous.dispose()\n }\n\n // Island props reach the view like any component's props, spread\n // top-level (`{ state, title }`), the same as on the server\n // (renderToString). The view args (state, context, ...) win over a prop\n // with the same name; `props` is kept for older `({ state, props })`\n // views (B-026).\n const islandProps = { ...(props || {}) }\n const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })\n Wrapped.model = Component.model\n Wrapped.intent = Component.intent\n Wrapped.hmrActions = Component.hmrActions\n Wrapped.context = Component.context\n Wrapped.peers = Component.peers\n Wrapped.components = Component.components\n Wrapped.initialState = Component.initialState\n Wrapped.calculated = Component.calculated\n Wrapped.storeCalculatedInState = Component.storeCalculatedInState\n Wrapped.DOMSourceName = Component.DOMSourceName\n Wrapped.stateSourceName = Component.stateSourceName\n Wrapped.onError = Component.onError\n Wrapped.debug = Component.debug\n Wrapped.componentName = Component.componentName || Component.name\n // run() names the root by `name` first: diagnostics and devtools should\n // say 'Counter', not 'Wrapped'\n try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}\n\n const app = run(Wrapped, {}, { mountPoint })\n element.__sygnal = app\n }\n}\n"],"names":[],"mappings":";;AAAA;AACA;AA2BA,SAAS,wBAAwB,CAAC,SAAc,EAAA;IAC9C,IAAI,OAAO,SAAS,KAAK,UAAU;AAAE,QAAA,OAAO,KAAK,CAAA;AACjD,IAAA,OAAO,OAAO,CACZ,SAAS,CAAC,iBAAiB;AACzB,QAAA,SAAS,CAAC,KAAK;AACf,QAAA,SAAS,CAAC,MAAM;AAChB,QAAA,SAAS,CAAC,YAAY;QACtB,SAAS,CAAC,aAAa,CAC1B,CAAA;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AO,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAA;AACzC,QAAA,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,sBAAsB,CAAA;AACjE,QAAA,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAA;AAC/C,QAAA,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAA;AACnD,QAAA,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;AACnC,QAAA,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAA;QAC/B,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,IAAI,CAAA;;;AAGjE,QAAA,IAAI;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAA;SAAE;AAAC,QAAA,OAAO,CAAC,EAAE,GAAE;AAEjH,QAAA,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;AAC5C,QAAA,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAA;AACxB,KAAC,CAAA;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"client.mjs","sources":["../../src/astro/client.ts"],"sourcesContent":["// The public entry (external in the build), so islands share the app's\n// Sygnal core instead of a bundled copy (B-019).\nimport { run } from 'sygnal'\n// PLAN-4 GS-11 / D120: the app-level error hook, the default export of the module the\n// integration's `onError` option names (undefined without it); served by sygnal/astro's Vite plugin\n// @ts-ignore — a virtual module\nimport onError from 'virtual:sygnal/astro-on-error'\n\ninterface SygnalComponent {\n (args: any): any;\n model?: any;\n intent?: any;\n connections?: any;\n resources?: any;\n route?: any;\n head?: any;\n persist?: any;\n uses?: any;\n timers?: any;\n viewTransitions?: any;\n context?: any;\n initialState?: any;\n calculated?: any;\n onError?: (error: Error, info: { componentName: string }) => any;\n debug?: boolean;\n componentName?: string;\n name?: string;\n}\n\ninterface AstroMetadata {\n client?: string;\n}\n\nfunction looksLikeSygnalComponent(Component: any): Component is SygnalComponent {\n if (typeof Component !== 'function') return false\n return Boolean(\n Component.model ||\n Component.intent ||\n Component.initialState ||\n Component.componentName\n )\n}\n\nexport default (element: any) => {\n return async (Component: any, props: any, _slotted: any, metadata: AstroMetadata) => {\n if (!looksLikeSygnalComponent(Component)) return\n\n const mountPoint = element\n const { client } = metadata || {}\n const canHydrate = element.hasAttribute('ssr')\n\n if (client !== 'only' && !canHydrate) return\n\n const previous = element.__sygnal\n if (previous && typeof previous.dispose === 'function') {\n previous.dispose()\n }\n\n // Island props reach the view like any component's props, spread\n // top-level (`{ state, title }`), the same as on the server\n // (renderToString). The view args (state, context, ...) win over a prop\n // with the same name; `props` is kept for older `({ state, props })`\n // views (B-026).\n const islandProps = { ...(props || {}) }\n const Wrapped: any = (args: any) => Component({ ...islandProps, ...args, props: islandProps })\n Wrapped.model = Component.model\n Wrapped.intent = Component.intent\n Wrapped.context = Component.context\n Wrapped.initialState = Component.initialState\n Wrapped.calculated = Component.calculated\n Wrapped.onError = Component.onError\n Wrapped.debug = Component.debug\n Wrapped.connections = Component.connections\n Wrapped.resources = Component.resources\n Wrapped.route = Component.route\n Wrapped.head = Component.head\n // PLAN-4 3-B2: more statics the core reads off the root view: persist (root only: the island\n // is its app's root), uses, timers (they run only with a timer driver) and viewTransitions\n Wrapped.persist = Component.persist\n Wrapped.uses = Component.uses\n Wrapped.timers = Component.timers\n Wrapped.viewTransitions = Component.viewTransitions\n Wrapped.componentName = Component.componentName || Component.name\n // run() names the root by `name` first: diagnostics and devtools should\n // say 'Counter', not 'Wrapped'\n try { Object.defineProperty(Wrapped, 'name', { value: Wrapped.componentName, configurable: true }) } catch (_) {}\n\n // G-206: a `uid` island prop is the island's uid root (as on the server); the view's own\n // uid() function wins over the prop (args are spread last)\n // 3-B2: `__hydrate` tells persist() whether the island starts over the server's markup\n const app = run(Wrapped, { __hydrate: () => client !== 'only' && canHydrate }, { mountPoint, onError, uid: islandProps.uid })\n element.__sygnal = app\n }\n}\n"],"names":[],"mappings":";;;AAAA;AACA;AAgCA,SAAS,wBAAwB,CAAC,SAAc,EAAA;IAC9C,IAAI,OAAO,SAAS,KAAK,UAAU;AAAE,QAAA,OAAO,KAAK,CAAA;AACjD,IAAA,OAAO,OAAO,CACZ,SAAS,CAAC,KAAK;AACb,QAAA,SAAS,CAAC,MAAM;AAChB,QAAA,SAAS,CAAC,YAAY;QACtB,SAAS,CAAC,aAAa,CAC1B,CAAA;AACH,CAAC;AAED,aAAe,CAAC,OAAY,KAAI;IAC9B,OAAO,OAAO,SAAc,EAAE,KAAU,EAAE,QAAa,EAAE,QAAuB,KAAI;AAClF,QAAA,IAAI,CAAC,wBAAwB,CAAC,SAAS,CAAC;YAAE,OAAM;QAEhD,MAAM,UAAU,GAAG,OAAO,CAAA;AAC1B,QAAA,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAA;QACjC,MAAM,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;AAE9C,QAAA,IAAI,MAAM,KAAK,MAAM,IAAI,CAAC,UAAU;YAAE,OAAM;AAE5C,QAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QACjC,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,UAAU,EAAE;YACtD,QAAQ,CAAC,OAAO,EAAE,CAAA;SACnB;;;;;;QAOD,MAAM,WAAW,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,CAAC,EAAE,CAAA;QACxC,MAAM,OAAO,GAAQ,CAAC,IAAS,KAAK,SAAS,CAAC,EAAE,GAAG,WAAW,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAA;AAC9F,QAAA,OAAO,CAAC,KAAK,GAAG,SAAS,CAA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