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
@@ -0,0 +1,201 @@
1
+ /**
2
+ * PLAN-5 W-1 (D189/D190/D196): `defineWidget`, a framework-agnostic third-party widget (a date
3
+ * picker, a chart, an editor) as a JSX tag (canonical) that also works as a control spec.
4
+ *
5
+ * const DatePicker = defineWidget({
6
+ * tag: 'input',
7
+ * mount: (el, props, dispatch) => flatpickr(el, { defaultDate: props.value, onChange: ([d]) => dispatch('pick', d) }),
8
+ * update: (fp, props) => fp.setDate(props.value, false),
9
+ * unmount: (fp) => fp.destroy(),
10
+ * events: ['pick'],
11
+ * commands: { open: (fp) => fp.open() },
12
+ * })
13
+ * // view: <label>Due <DatePicker className="due" value={state.due} /></label>
14
+ * // intent: DUE: DOM.select('.due').events('pick').detail()
15
+ * // model: OPEN_DUE: { ELEMENT: { open: '.due' } }
16
+ * // alt: const { Due } = controls({ Due: DatePicker }); DOM.select(Due).events('pick'), { open: Due }
17
+ *
18
+ * 0 B in the core when unused: everything is in this module, and the marker handler is registered
19
+ * by the first defineWidget() call, not on import.
20
+ * - The tag is a function carrying the pragma's control render hook (`__sygnalControl`, CT-1), so
21
+ * `<DatePicker …/>` never becomes a component. It is also a control spec object (D101/D116:
22
+ * `kind`, `vnode(props, children, h)`, `commands`), so `controls({ Due: DatePicker })` works.
23
+ * - `vnode()` returns a `widget` marker; the owner's reconcile walk rewrites it through the marker
24
+ * registry (`pres.widget`, given the marker's path) into the host vnode, with the owner instance
25
+ * at hand (onError). The host has no children (opaque to snabbdom) and carries the newest props
26
+ * in `data.wp`; its hooks read the vnode they are given, so `update` always gets the props of
27
+ * the render being patched (no closure over mount-time props). Each host has its own hook
28
+ * object: the widget's, then a `ref`'s (the host element), then a `<Transition>`'s (G-363).
29
+ * - 1-R (G-360): the host's key names the widget and the instance (its key in the parent, or its
30
+ * place when unkeyed), so snabbdom never patches a host into another vnode (a plain element of
31
+ * the same tag, another widget, the error fallback) or the reverse: the host is destroyed and
32
+ * the widget unmounts.
33
+ * - The record `{ w (the tag), p (props), i (instance), e (dispatch) }` lives on the host element
34
+ * as the non-enumerable `__sw` (D200: short, the core reads it), so the instance survives re-renders and keyed moves
35
+ * (snabbdom moves the element). Mount runs on insert, or on the first patch of an element that
36
+ * has none (SSR hydration). `update` runs when the props change (shallow; an object host prop
37
+ * such as `style` one level deep, G-362); without `update`, a change remounts (G-367: a mount
38
+ * that throws then is SYG660 and leaves no record). `unmount` on destroy (a removed Portal
39
+ * destroys its content too, G-359).
40
+ * - `className` goes to the host as class-module tokens (G-364): a change toggles only those, not
41
+ * the classes the library added (flatpickr's `flatpickr-input`).
42
+ * - `dispatch(name, detail)` (mount's third parameter) dispatches a bubbling CustomEvent on the
43
+ * host: the intent reads it like any DOM event (`.detail()`); isolation (Collection items)
44
+ * applies as for any element.
45
+ * - Commands: D102's `spec.commands[name](hostElement, options)` resolves the instance from the
46
+ * host. For selector targets each command whose name the element doesn't already have is also
47
+ * a method of the host (D190); a declared command whose name is a native method (`focus`,
48
+ * `close`) is found by the core through `__sw` and wins over the native one, with the
49
+ * options object (D196, D200).
50
+ * - A widget tag is not a selector: `DOM.select(DatePicker)` matches nothing (SYG143 in dev).
51
+ * - G-413: `ownProps` names props that stay off the host although they'd go there (a part that
52
+ * puts `aria-label` on its own control).
53
+ * - G-409: mount's fourth parameter `error(e)` reports a later failure the widget caught itself
54
+ * (fromZag's machine-driven redraws): handled as a throwing `update` (SYG661 + fallback; G-580:
55
+ * the dev message says the widget reported it through error(e)).
56
+ * - A `mount`/`update` that throws (SYG660/661): reported to the app's onError with phase
57
+ * 'widget' (D105), and the owner's next render shows its `onError` fallback in that instance's
58
+ * place (G-361: per instance; a render with other props tries again, and the failure is
59
+ * forgotten when the fallback leaves the page). `unmount` (SYG662): reported, nothing to replace.
60
+ * - Inside `<Portal>`: the Portal's children are rewritten here too (Portal children are not
61
+ * walked by the core), so a widget works in a portal.
62
+ * - SSR (extra/ssr.ts): the host, with `fallback` inside it; the client patch replaces it with
63
+ * the keyed host and mounts.
64
+ *
65
+ * Dev text lives in the 'sygnal/diagnostics' entry (checks/widgets.ts), reached through the core
66
+ * bridge as `widget(code, widgetTag, owner, extra)`: SYG140 (dispatch of an undeclared event),
67
+ * SYG143, SYG144 (a declared event the host fires natively), SYG660–662. Without the entry, a
68
+ * thrown mount/update/unmount is logged as `[Sygnal SYG66x]` with the error.
69
+ */
70
+ import {pres} from '../core/registry'
71
+ import {chainHooks} from '../pragma/index'
72
+
73
+ const W = '__sw'
74
+
75
+ // props that also go to the host element (every prop but key goes to the widget; ref is the host's)
76
+ const HOST = /^(id|class(Name)?|style|title|name|placeholder|role|tab[iI]ndex|hidden|lang|dir|attrs)$|^(aria|data)-/
77
+
78
+ /** the dev entry's reporter (checks/widgets.ts); returns the diagnostic when one was reported
79
+ * (r: G-580, a 661 the widget reported through error(e), not a throwing update) */
80
+ const dev = (code: number, w: any, o?: any, x?: any, r?: any): any => (globalThis as any).__SYGNAL_DIAGNOSTICS__?.widget?.(code, w, o, x, r)
81
+
82
+ let ids = 0
83
+
84
+ // shallow; G-362: an object host prop (style, attrs, a class map) compares one level deep, so a
85
+ // new object with the same entries is no change (snabbdom patches the host from it anyway)
86
+ const same = (a: any, b: any, d?: any): any => {
87
+ const k = Object.keys(a)
88
+ return k.length == Object.keys(b).length && k.every(x => a[x] === b[x] ||
89
+ !d && HOST.test(x) && typeof a[x] == 'object' && typeof b[x] == 'object' && a[x] && b[x] && same(a[x], b[x], 1))
90
+ }
91
+
92
+ // k: the host's key, the failure's place; [error, the props of the fallback's last render]; r:
93
+ // reported through error(e)
94
+ function fail(o: any, w: any, k: any, code: number, e: any, r?: any) {
95
+ e = e instanceof Error ? e : Error(e)
96
+ dev(code, w, o, e, r) || console.error(`[Sygnal SYG${code}]`, e)
97
+ o.app.appError(o, e, 'widget')
98
+ if (code < 662 && !o.disposed) (o.$wf ||= new Map()).set(k, [e]), o.refresh()
99
+ }
100
+
101
+ function mount(v: any) {
102
+ const el = v.elm, {ww: w, wp: p, wo: o} = v.data
103
+ const d = (n: string, detail?: any) => { dev(140, w, o, n); el.dispatchEvent(new CustomEvent(n, {detail, bubbles: true})) }
104
+ let i: any
105
+ dev(144, w, o, el)
106
+ // G-409: mount's fourth parameter reports a later failure (an adapter's own redraw): SYG661,
107
+ // the owner's onError fallback in this instance's place, as for a throwing update (G-580: the
108
+ // dev text says error(e) reported it)
109
+ const err = (x: any) => { el[W] && fail(o, w, v.key, 661, x, 1) }
110
+ try { i = w.def.mount(el, p, d, err) } catch (x) { return fail(o, w, v.key, 660, x) }
111
+ Object.defineProperty(el, W, {value: {w, p, i, e: d}, configurable: true})
112
+ // the tag form's commands: a host method for each one the element doesn't have (D190)
113
+ for (const m in w.def.commands) m in el || (el[m] = (x: any) => el[W]?.w.commands[m]?.(el, x))
114
+ }
115
+
116
+ function destroy(v: any) {
117
+ const el = v.elm, s = el[W]
118
+ if (s) {
119
+ delete el[W]
120
+ try { s.w.def.unmount?.(s.i, el) } catch (x) { fail(v.data.wo, s.w, v.key, 662, x) }
121
+ }
122
+ }
123
+
124
+ const hooks: any = {
125
+ insert: mount,
126
+ postpatch(_: any, v: any) {
127
+ const el = v.elm, p = v.data.wp, s = el[W]
128
+ // SSR hydration (the element was patched in place, never inserted): mount now
129
+ if (!s) return mount(v)
130
+ const u = s.w.def.update
131
+ if (same(s.p, p)) return
132
+ // G-367: without update, a change remounts
133
+ if (!u) return destroy(v), mount(v)
134
+ try { u(s.i, p, el); s.p = p } catch (x) { fail(v.data.wo, s.w, v.key, 661, x) }
135
+ },
136
+ destroy,
137
+ }
138
+
139
+ /** the host vnode for a widget marker (client: the hooks, the owner and the key k; SSR adds the fallback) */
140
+ function host(n: any, o?: any, k?: any): any {
141
+ const {ww: w, wp: p, h, attrs, r} = n.data, def = w.def, hp: any = {ref: r}
142
+ for (const x in p) if ((HOST.test(x) || def.hostProps?.includes(x)) && !def.ownProps?.includes(x)) hp[x] = p[x]
143
+ if (hp.className) hp.class = [hp.class, hp.className], delete hp.className
144
+ const v = h(def.tag || 'div', hp), d = v.data
145
+ if (attrs) d.attrs = {...d.attrs, ...attrs}
146
+ if (o) {
147
+ v.key = k
148
+ d.ww = w; d.wp = p; d.wo = o; v.children = undefined
149
+ // a hook object per host: a ref's hooks (from h), the widget's, then a Transition's (marker)
150
+ chainHooks(d, hooks)
151
+ n.data.hook && chainHooks(d, n.data.hook)
152
+ }
153
+ return v
154
+ }
155
+
156
+ /** pres.widget: the host, or the owner's fallback where this instance failed */
157
+ function rewrite(n: any, o: any, path: string): any {
158
+ const w = n.data.ww, p = n.data.wp, wf = o.$wf
159
+ // the instance: the widget and its key, or its place when unkeyed
160
+ const k = 'w' + w.$i + (n.key == null ? path : '#' + n.key)
161
+ let f = wf?.get(k)
162
+ // a render with other props than the fallback's last one tries again
163
+ if (f && f[1] && !same(f[1], p)) wf.delete(k), f = 0
164
+ if (!f) return host(n, o, k)
165
+ f[1] = p
166
+ const def = o.def, x = n.data.h('div', {attrs: {'data-sygnal-error': def.name}})
167
+ let r: any = x
168
+ try { r = def.onError?.(f[0], {componentName: def.name}) || x } catch (_) {}
169
+ // its own key; the failure is forgotten when it leaves the page (a reopened panel tries again)
170
+ chainHooks((r = {...r, key: k + '!', data: {...r.data}}).data, {destroy: () => wf.delete(k)})
171
+ return r
172
+ }
173
+
174
+ /** widget markers among a Portal's children (the core doesn't walk them) */
175
+ const inPortal = (c: any[], o: any, x: string): any[] =>
176
+ c.map((n, i) => n?.sel == 'widget' ? rewrite(n, o, x + '.' + i) : n?.children ? {...n, children: inPortal(n.children, o, x + '.' + i)} : n)
177
+
178
+ export function defineWidget(def: any): any {
179
+ pres.widget ||= rewrite
180
+ const p: any = pres.portal
181
+ if (p && !p.$w) ((pres.portal = (n: any, o: any, x: string) => p({...n, children: inPortal(n.children || [], o, x)}, o, x)) as any).$w = 1
182
+ const w: any = () => {}, commands: any = {}
183
+ // D200: any name, `close` and `togglePopover` too (the core passes a widget command the options)
184
+ for (const m in def.commands) commands[m] = (el: any, o: any) => el[W] && def.commands[m](el[W].i, o || {}, el)
185
+ return Object.assign(w, {
186
+ kind: 'widget',
187
+ def,
188
+ $i: ++ids,
189
+ events: def.events || [],
190
+ commands,
191
+ // D101/D116: the control spec's vnode(props, children, h): one (marker) element vnode; also
192
+ // the tag form's pragma render hook (no data-control stamp)
193
+ vnode: w.__sygnalControl = (props: any, _: any, h: any) => {
194
+ const {key, ref, ...p} = props || {}
195
+ return {sel: 'widget', data: {ww: w, wp: p, h, r: ref}, children: undefined, text: undefined, key}
196
+ },
197
+ $ssr: host,
198
+ // D190/D199: a widget tag is not a selector (SYG143 in dev): select its className or a control
199
+ toString: () => (dev(143, w), ':not(*)'),
200
+ })
201
+ }
@@ -0,0 +1,269 @@
1
+ /**
2
+ * ESM ports of xstream's `concat`, `debounce`, `throttle`, `delay`, `dropRepeats` and
3
+ * `sampleCombine` extras (xstream, MIT, André Staltz), behaviour-identical.
4
+ *
5
+ * Why not import 'xstream/extra/*': those modules are CommonJS with `exports.default`. Under
6
+ * Vite/Vitest the default import resolves to the function, but in the rollup CJS build and in
7
+ * native Node ESM it resolves to the module object `{ default: fn }`, so the re-exports from
8
+ * 'sygnal' were not callable there (and neither were sygnal's own internal uses). ESM classes
9
+ * are also tree-shaken when an app does not use them. See also ./flatten.ts.
10
+ */
11
+ import {Stream} from 'xstream'
12
+
13
+ // ---------------------------------------------------------------- concat
14
+
15
+ class ConcatProducer {
16
+ type = 'concat'
17
+ out: any = null
18
+ i = 0
19
+ constructor(public streams: any[]) {}
20
+ _start(out: any) { this.out = out; this.streams[this.i]._add(this) }
21
+ _stop() {
22
+ const streams = this.streams
23
+ if (this.i < streams.length) streams[this.i]._remove(this)
24
+ this.i = 0
25
+ this.out = null
26
+ }
27
+ _n(t: any) { const u = this.out; if (u) u._n(t) }
28
+ _e(err: any) { const u = this.out; if (u) u._e(err) }
29
+ _c() {
30
+ const u = this.out
31
+ if (!u) return
32
+ const streams = this.streams
33
+ streams[this.i]._remove(this)
34
+ if (++this.i < streams.length) streams[this.i]._add(this)
35
+ else u._c()
36
+ }
37
+ }
38
+
39
+ /** Emits everything from the first stream, then (once it completes) the second, and so on. */
40
+ export function concat<T>(...streams: Stream<T>[]): Stream<T> {
41
+ return new Stream<T>(new ConcatProducer(streams) as any)
42
+ }
43
+
44
+ // ---------------------------------------------------------------- debounce
45
+
46
+ const NO_VALUE = {}
47
+
48
+ class DebounceOperator {
49
+ type = 'debounce'
50
+ out: any = null
51
+ id: any = null
52
+ t: any = NO_VALUE
53
+ constructor(public dt: number, public ins: any) {}
54
+ _start(out: any) { this.out = out; this.ins._add(this) }
55
+ _stop() { this.ins._remove(this); this.out = null; this.clearInterval() }
56
+ clearInterval() {
57
+ const id = this.id
58
+ if (id !== null) clearInterval(id)
59
+ this.id = null
60
+ }
61
+ _n(t: any) {
62
+ const u = this.out
63
+ if (!u) return
64
+ this.clearInterval()
65
+ this.t = t
66
+ this.id = setInterval(() => {
67
+ this.clearInterval()
68
+ u._n(t)
69
+ this.t = NO_VALUE
70
+ }, this.dt)
71
+ }
72
+ _e(err: any) {
73
+ const u = this.out
74
+ if (!u) return
75
+ this.clearInterval()
76
+ u._e(err)
77
+ }
78
+ _c() {
79
+ const u = this.out
80
+ if (!u) return
81
+ this.clearInterval()
82
+ if (this.t != NO_VALUE) u._n(this.t)
83
+ this.t = NO_VALUE
84
+ u._c()
85
+ }
86
+ }
87
+
88
+ /** Emits a value only after `period` ms have passed without another value. */
89
+ export function debounce(period: number): <T>(ins: Stream<T>) => Stream<T> {
90
+ return function debounceOperator<T>(ins: Stream<T>): Stream<T> {
91
+ return new Stream<T>(new DebounceOperator(period, ins) as any)
92
+ }
93
+ }
94
+
95
+ // ---------------------------------------------------------------- throttle
96
+
97
+ class ThrottleOperator {
98
+ type = 'throttle'
99
+ out: any = null
100
+ id: any = null
101
+ constructor(public dt: number, public ins: any) {}
102
+ _start(out: any) { this.out = out; this.ins._add(this) }
103
+ _stop() { this.ins._remove(this); this.out = null; this.id = null }
104
+ clearInterval() {
105
+ const id = this.id
106
+ if (id !== null) clearInterval(id)
107
+ this.id = null
108
+ }
109
+ _n(t: any) {
110
+ const u = this.out
111
+ if (!u) return
112
+ if (this.id) return
113
+ u._n(t)
114
+ this.id = setInterval(() => { this.clearInterval() }, this.dt)
115
+ }
116
+ _e(err: any) {
117
+ const u = this.out
118
+ if (!u) return
119
+ this.clearInterval()
120
+ u._e(err)
121
+ }
122
+ _c() {
123
+ const u = this.out
124
+ if (!u) return
125
+ this.clearInterval()
126
+ u._c()
127
+ }
128
+ }
129
+
130
+ /** Emits a value, then ignores further values for `period` ms. */
131
+ export function throttle(period: number): <T>(ins: Stream<T>) => Stream<T> {
132
+ return function throttleOperator<T>(ins: Stream<T>): Stream<T> {
133
+ return new Stream<T>(new ThrottleOperator(period, ins) as any)
134
+ }
135
+ }
136
+
137
+ // ---------------------------------------------------------------- delay
138
+
139
+ class DelayOperator {
140
+ type = 'delay'
141
+ out: any = null
142
+ constructor(public dt: number, public ins: any) {}
143
+ _start(out: any) { this.out = out; this.ins._add(this) }
144
+ _stop() { this.ins._remove(this); this.out = null }
145
+ _n(t: any) {
146
+ const u = this.out
147
+ if (!u) return
148
+ const id = setInterval(() => { u._n(t); clearInterval(id) }, this.dt)
149
+ }
150
+ _e(err: any) {
151
+ const u = this.out
152
+ if (!u) return
153
+ const id = setInterval(() => { u._e(err); clearInterval(id) }, this.dt)
154
+ }
155
+ _c() {
156
+ const u = this.out
157
+ if (!u) return
158
+ const id = setInterval(() => { u._c(); clearInterval(id) }, this.dt)
159
+ }
160
+ }
161
+
162
+ /** Delays every event (values, error, completion) by `period` ms. */
163
+ export function delay(period: number): <T>(ins: Stream<T>) => Stream<T> {
164
+ return function delayOperator<T>(ins: Stream<T>): Stream<T> {
165
+ return new Stream<T>(new DelayOperator(period, ins) as any)
166
+ }
167
+ }
168
+
169
+ // ---------------------------------------------------------------- dropRepeats
170
+
171
+ const EMPTY = {}
172
+
173
+ class DropRepeatsOperator {
174
+ type = 'dropRepeats'
175
+ out: any = null
176
+ v: any = EMPTY
177
+ isEq: (x: any, y: any) => boolean
178
+ constructor(public ins: any, fn?: (x: any, y: any) => boolean) {
179
+ this.isEq = fn ? fn : (x: any, y: any) => x === y
180
+ }
181
+ _start(out: any) { this.out = out; this.ins._add(this) }
182
+ _stop() { this.ins._remove(this); this.out = null; this.v = EMPTY }
183
+ _n(t: any) {
184
+ const u = this.out
185
+ if (!u) return
186
+ const v = this.v
187
+ if (v !== EMPTY && this.isEq(t, v)) return
188
+ this.v = t
189
+ u._n(t)
190
+ }
191
+ _e(err: any) { const u = this.out; if (u) u._e(err) }
192
+ _c() { const u = this.out; if (u) u._c() }
193
+ }
194
+
195
+ /** Drops consecutive duplicates (`===`, or the given equality function). */
196
+ export function dropRepeats<T>(isEqual?: (x: T, y: T) => boolean): (ins: Stream<T>) => Stream<T> {
197
+ return function dropRepeatsOperator(ins: Stream<T>): Stream<T> {
198
+ return new Stream<T>(new DropRepeatsOperator(ins, isEqual as any) as any)
199
+ }
200
+ }
201
+
202
+ // ---------------------------------------------------------------- sampleCombine
203
+
204
+ const NO = {}
205
+
206
+ class SampleCombineListener {
207
+ constructor(public i: number, public p: SampleCombineOperator) { p.ils[i] = this }
208
+ _n(t: any) {
209
+ const p = this.p
210
+ if (p.out === NO) return
211
+ p.up(t, this.i)
212
+ }
213
+ _e(err: any) { this.p._e(err) }
214
+ _c() { this.p.down(this.i, this) }
215
+ }
216
+
217
+ class SampleCombineOperator {
218
+ type = 'sampleCombine'
219
+ out: any = NO
220
+ ils: any[] = []
221
+ Nn = 0
222
+ vals: any[] = []
223
+ constructor(public ins: any, public others: any[]) {}
224
+ _start(out: any) {
225
+ this.out = out
226
+ const s = this.others
227
+ const n = this.Nn = s.length
228
+ const vals = this.vals = new Array(n)
229
+ for (let i = 0; i < n; i++) {
230
+ vals[i] = NO
231
+ s[i]._add(new SampleCombineListener(i, this))
232
+ }
233
+ this.ins._add(this)
234
+ }
235
+ _stop() {
236
+ const s = this.others
237
+ const n = s.length
238
+ const ils = this.ils
239
+ this.ins._remove(this)
240
+ for (let i = 0; i < n; i++) s[i]._remove(ils[i])
241
+ this.out = NO
242
+ this.vals = []
243
+ this.ils = []
244
+ }
245
+ _n(t: any) {
246
+ const out = this.out
247
+ if (out === NO) return
248
+ if (this.Nn > 0) return
249
+ out._n([t, ...this.vals])
250
+ }
251
+ _e(err: any) { const out = this.out; if (out !== NO) out._e(err) }
252
+ _c() { const out = this.out; if (out !== NO) out._c() }
253
+ up(t: any, i: number) {
254
+ const v = this.vals[i]
255
+ if (this.Nn > 0 && v === NO) this.Nn--
256
+ this.vals[i] = t
257
+ }
258
+ down(i: number, l: any) { this.others[i]._remove(l) }
259
+ }
260
+
261
+ /**
262
+ * Operator: whenever the source emits, emits `[source, latest(a), latest(b), ...]`
263
+ * (only once every other stream has emitted at least once).
264
+ */
265
+ export function sampleCombine(...streams: Stream<any>[]): (sampler: Stream<any>) => Stream<any[]> {
266
+ return function sampleCombineOperator(sampler: Stream<any>): Stream<any[]> {
267
+ return new Stream<any[]>(new SampleCombineOperator(sampler, streams) as any)
268
+ }
269
+ }