@videojs/spf 10.0.0-beta.30 → 10.0.0-beta.32

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 (520) hide show
  1. package/dist/default/core/actors/create-machine-actor.js +23 -25
  2. package/dist/default/core/actors/create-machine-actor.js.map +1 -1
  3. package/dist/default/core/actors/create-transition-actor.js +7 -9
  4. package/dist/default/core/actors/create-transition-actor.js.map +1 -1
  5. package/dist/default/core/composition/create-composition.js +26 -29
  6. package/dist/default/core/composition/create-composition.js.map +1 -1
  7. package/dist/default/core/composition/share-signals.js +12 -17
  8. package/dist/default/core/composition/share-signals.js.map +1 -1
  9. package/dist/default/core/machine.js +3 -4
  10. package/dist/default/core/machine.js.map +1 -1
  11. package/dist/default/core/reactors/create-machine-reactor.js +20 -19
  12. package/dist/default/core/reactors/create-machine-reactor.js.map +1 -1
  13. package/dist/default/core/signals/effect.js +24 -4
  14. package/dist/default/core/signals/effect.js.map +1 -1
  15. package/dist/default/core/signals/primitives.js +10 -14
  16. package/dist/default/core/signals/primitives.js.map +1 -1
  17. package/dist/default/core/signals/when.js +6 -8
  18. package/dist/default/core/signals/when.js.map +1 -1
  19. package/dist/default/core/tasks/delayed-reschedule.js +7 -11
  20. package/dist/default/core/tasks/delayed-reschedule.js.map +1 -1
  21. package/dist/default/core/tasks/task.js +59 -82
  22. package/dist/default/core/tasks/task.js.map +1 -1
  23. package/dist/default/hls.js +3 -1
  24. package/dist/default/index.js +2 -3
  25. package/dist/default/index.js.map +1 -1
  26. package/dist/default/media/abr/quality-selection.js +3 -7
  27. package/dist/default/media/abr/quality-selection.js.map +1 -1
  28. package/dist/default/media/buffer/back-buffer.js +15 -19
  29. package/dist/default/media/buffer/back-buffer.js.map +1 -1
  30. package/dist/default/media/buffer/forward-buffer.js +32 -41
  31. package/dist/default/media/buffer/forward-buffer.js.map +1 -1
  32. package/dist/default/media/dom/capabilities.js +26 -37
  33. package/dist/default/media/dom/capabilities.js.map +1 -1
  34. package/dist/default/media/dom/mse/append-segment.js +3 -5
  35. package/dist/default/media/dom/mse/append-segment.js.map +1 -1
  36. package/dist/default/media/dom/mse/buffer-flusher.js +5 -5
  37. package/dist/default/media/dom/mse/buffer-flusher.js.map +1 -1
  38. package/dist/default/media/dom/mse/duration.js +23 -31
  39. package/dist/default/media/dom/mse/duration.js.map +1 -1
  40. package/dist/default/media/dom/mse/end-of-stream.js +3 -6
  41. package/dist/default/media/dom/mse/end-of-stream.js.map +1 -1
  42. package/dist/default/media/dom/mse/mediasource-setup.js +65 -81
  43. package/dist/default/media/dom/mse/mediasource-setup.js.map +1 -1
  44. package/dist/default/media/dom/screen.js +37 -54
  45. package/dist/default/media/dom/screen.js.map +1 -1
  46. package/dist/default/media/dom/text/resolve-vtt-segment.js.map +1 -1
  47. package/dist/default/media/dom/text/text-track-slots.js +15 -23
  48. package/dist/default/media/dom/text/text-track-slots.js.map +1 -1
  49. package/dist/default/media/errors.js +25 -34
  50. package/dist/default/media/errors.js.map +1 -1
  51. package/dist/default/media/hls/parse-attributes.js +9 -26
  52. package/dist/default/media/hls/parse-attributes.js.map +1 -1
  53. package/dist/default/media/hls/parse-media-playlist.js +25 -33
  54. package/dist/default/media/hls/parse-media-playlist.js.map +1 -1
  55. package/dist/default/media/hls/parse-multivariant.js +3 -3
  56. package/dist/default/media/hls/parse-multivariant.js.map +1 -1
  57. package/dist/default/media/hls/reload-policy.js +19 -27
  58. package/dist/default/media/hls/reload-policy.js.map +1 -1
  59. package/dist/default/media/hls/resolve-url.js +1 -3
  60. package/dist/default/media/hls/resolve-url.js.map +1 -1
  61. package/dist/default/media/live-window.js +9 -13
  62. package/dist/default/media/live-window.js.map +1 -1
  63. package/dist/default/media/media-tracks/media-tracks.js +12 -17
  64. package/dist/default/media/media-tracks/media-tracks.js.map +1 -1
  65. package/dist/default/media/mp4/box.js +4 -5
  66. package/dist/default/media/mp4/box.js.map +1 -1
  67. package/dist/default/media/mp4/timestamp-origin.js +30 -42
  68. package/dist/default/media/mp4/timestamp-origin.js.map +1 -1
  69. package/dist/default/media/primitives/resolution.js +5 -8
  70. package/dist/default/media/primitives/resolution.js.map +1 -1
  71. package/dist/default/media/primitives/select-tracks.js +24 -34
  72. package/dist/default/media/primitives/select-tracks.js.map +1 -1
  73. package/dist/default/media/text/parse-vtt-timestamp-map.js +6 -8
  74. package/dist/default/media/text/parse-vtt-timestamp-map.js.map +1 -1
  75. package/dist/default/media/text/resolve-vtt-metadata.js +8 -9
  76. package/dist/default/media/text/resolve-vtt-metadata.js.map +1 -1
  77. package/dist/default/media/types/index.js +10 -18
  78. package/dist/default/media/types/index.js.map +1 -1
  79. package/dist/default/media/utils/cdn.js +10 -16
  80. package/dist/default/media/utils/cdn.js.map +1 -1
  81. package/dist/default/media/utils/preload.js +4 -6
  82. package/dist/default/media/utils/preload.js.map +1 -1
  83. package/dist/default/media/utils/track-selection.js +10 -14
  84. package/dist/default/media/utils/track-selection.js.map +1 -1
  85. package/dist/default/media/utils/tracks.js +56 -54
  86. package/dist/default/media/utils/tracks.js.map +1 -1
  87. package/dist/default/network/bandwidth-estimator.js +18 -19
  88. package/dist/default/network/bandwidth-estimator.js.map +1 -1
  89. package/dist/default/network/chunked-stream-iterable.js +4 -6
  90. package/dist/default/network/chunked-stream-iterable.js.map +1 -1
  91. package/dist/default/network/ewma.js +22 -25
  92. package/dist/default/network/ewma.js.map +1 -1
  93. package/dist/default/network/fetch.js +30 -37
  94. package/dist/default/network/fetch.js.map +1 -1
  95. package/dist/default/playback/actors/dom/segment-loader.js +28 -44
  96. package/dist/default/playback/actors/dom/segment-loader.js.map +1 -1
  97. package/dist/default/playback/actors/dom/source-buffer.js.map +1 -1
  98. package/dist/default/playback/actors/dom/text-tracks.js.map +1 -1
  99. package/dist/default/playback/actors/text-track-segment-loader.js +24 -35
  100. package/dist/default/playback/actors/text-track-segment-loader.js.map +1 -1
  101. package/dist/default/playback/adapters/hls-audio/adapter.js +23 -31
  102. package/dist/default/playback/adapters/hls-audio/adapter.js.map +1 -1
  103. package/dist/default/playback/adapters/hls-audio/media.js.map +1 -1
  104. package/dist/default/playback/adapters/hls-background-video/adapter.js +50 -70
  105. package/dist/default/playback/adapters/hls-background-video/adapter.js.map +1 -1
  106. package/dist/default/playback/adapters/hls-background-video/host.js +12 -16
  107. package/dist/default/playback/adapters/hls-background-video/host.js.map +1 -1
  108. package/dist/default/playback/adapters/hls-background-video/media.js +5 -8
  109. package/dist/default/playback/adapters/hls-background-video/media.js.map +1 -1
  110. package/dist/default/playback/adapters/hls-video/adapter.js +43 -60
  111. package/dist/default/playback/adapters/hls-video/adapter.js.map +1 -1
  112. package/dist/default/playback/adapters/hls-video/error-surface.js +13 -18
  113. package/dist/default/playback/adapters/hls-video/error-surface.js.map +1 -1
  114. package/dist/default/playback/adapters/hls-video/media-tracks.js +4 -5
  115. package/dist/default/playback/adapters/hls-video/media-tracks.js.map +1 -1
  116. package/dist/default/playback/adapters/hls-video/media.js.map +1 -1
  117. package/dist/default/playback/adapters/mux-audio/media.js +8 -12
  118. package/dist/default/playback/adapters/mux-audio/media.js.map +1 -1
  119. package/dist/default/playback/adapters/mux-video/adapter.js +25 -33
  120. package/dist/default/playback/adapters/mux-video/adapter.js.map +1 -1
  121. package/dist/default/playback/adapters/mux-video/media.js +7 -9
  122. package/dist/default/playback/adapters/mux-video/media.js.map +1 -1
  123. package/dist/default/playback/behaviors/calculate-presentation-duration.js +5 -8
  124. package/dist/default/playback/behaviors/calculate-presentation-duration.js.map +1 -1
  125. package/dist/default/playback/behaviors/collect-errors.js +39 -52
  126. package/dist/default/playback/behaviors/collect-errors.js.map +1 -1
  127. package/dist/default/playback/behaviors/derive-cdn-priority.js +16 -23
  128. package/dist/default/playback/behaviors/derive-cdn-priority.js.map +1 -1
  129. package/dist/default/playback/behaviors/dom/airplay.js +38 -61
  130. package/dist/default/playback/behaviors/dom/airplay.js.map +1 -1
  131. package/dist/default/playback/behaviors/dom/apply-start-position.js +23 -35
  132. package/dist/default/playback/behaviors/dom/apply-start-position.js.map +1 -1
  133. package/dist/default/playback/behaviors/dom/end-of-stream.js +11 -16
  134. package/dist/default/playback/behaviors/dom/end-of-stream.js.map +1 -1
  135. package/dist/default/playback/behaviors/dom/load-segments.js +27 -39
  136. package/dist/default/playback/behaviors/dom/load-segments.js.map +1 -1
  137. package/dist/default/playback/behaviors/dom/recover-end-stall.js +21 -26
  138. package/dist/default/playback/behaviors/dom/recover-end-stall.js.map +1 -1
  139. package/dist/default/playback/behaviors/dom/seek-to-live-edge.js +41 -60
  140. package/dist/default/playback/behaviors/dom/seek-to-live-edge.js.map +1 -1
  141. package/dist/default/playback/behaviors/dom/setup-buffer-actors.js +50 -74
  142. package/dist/default/playback/behaviors/dom/setup-buffer-actors.js.map +1 -1
  143. package/dist/default/playback/behaviors/dom/setup-mediasource.js +29 -43
  144. package/dist/default/playback/behaviors/dom/setup-mediasource.js.map +1 -1
  145. package/dist/default/playback/behaviors/dom/setup-text-track-actors.js.map +1 -1
  146. package/dist/default/playback/behaviors/dom/sync-live-seekable-range.js +3 -4
  147. package/dist/default/playback/behaviors/dom/sync-live-seekable-range.js.map +1 -1
  148. package/dist/default/playback/behaviors/dom/sync-text-tracks.js +30 -45
  149. package/dist/default/playback/behaviors/dom/sync-text-tracks.js.map +1 -1
  150. package/dist/default/playback/behaviors/dom/track-current-time.js +9 -11
  151. package/dist/default/playback/behaviors/dom/track-current-time.js.map +1 -1
  152. package/dist/default/playback/behaviors/dom/track-load-triggers.js +24 -32
  153. package/dist/default/playback/behaviors/dom/track-load-triggers.js.map +1 -1
  154. package/dist/default/playback/behaviors/dom/track-playback-rate.js +6 -8
  155. package/dist/default/playback/behaviors/dom/track-playback-rate.js.map +1 -1
  156. package/dist/default/playback/behaviors/dom/track-player-resolution.js +10 -14
  157. package/dist/default/playback/behaviors/dom/track-player-resolution.js.map +1 -1
  158. package/dist/default/playback/behaviors/dom/track-screen-resolution.js +8 -9
  159. package/dist/default/playback/behaviors/dom/track-screen-resolution.js.map +1 -1
  160. package/dist/default/playback/behaviors/dom/update-mediasource-duration.js +28 -43
  161. package/dist/default/playback/behaviors/dom/update-mediasource-duration.js.map +1 -1
  162. package/dist/default/playback/behaviors/establish-start-media-time.js +32 -42
  163. package/dist/default/playback/behaviors/establish-start-media-time.js.map +1 -1
  164. package/dist/default/playback/behaviors/resolve-presentation.js +13 -22
  165. package/dist/default/playback/behaviors/resolve-presentation.js.map +1 -1
  166. package/dist/default/playback/behaviors/resolve-track.js +5 -12
  167. package/dist/default/playback/behaviors/resolve-track.js.map +1 -1
  168. package/dist/default/playback/behaviors/select-tracks.js +77 -104
  169. package/dist/default/playback/behaviors/select-tracks.js.map +1 -1
  170. package/dist/default/playback/behaviors/setup-failover-monitor.js +11 -16
  171. package/dist/default/playback/behaviors/setup-failover-monitor.js.map +1 -1
  172. package/dist/default/playback/behaviors/sync-preload.js +9 -13
  173. package/dist/default/playback/behaviors/sync-preload.js.map +1 -1
  174. package/dist/default/playback/behaviors/track-switching.js +189 -173
  175. package/dist/default/playback/behaviors/track-switching.js.map +1 -1
  176. package/dist/default/playback/engines/hls/engine-audio-only.js +20 -24
  177. package/dist/default/playback/engines/hls/engine-audio-only.js.map +1 -1
  178. package/dist/default/playback/engines/hls/engine-background-video.js +22 -27
  179. package/dist/default/playback/engines/hls/engine-background-video.js.map +1 -1
  180. package/dist/default/playback/engines/hls/engine.js +22 -25
  181. package/dist/default/playback/engines/hls/engine.js.map +1 -1
  182. package/dist/default/playback/primitives/error-messages.js +16 -25
  183. package/dist/default/playback/primitives/error-messages.js.map +1 -1
  184. package/dist/default/playback/primitives/failover-fetch.js +9 -14
  185. package/dist/default/playback/primitives/failover-fetch.js.map +1 -1
  186. package/dist/default/playback/primitives/head-peek.js +7 -10
  187. package/dist/default/playback/primitives/head-peek.js.map +1 -1
  188. package/dist/default/playback/primitives/live-window.js +12 -15
  189. package/dist/default/playback/primitives/live-window.js.map +1 -1
  190. package/dist/default/playback/primitives/relocation-pipelines.js +34 -46
  191. package/dist/default/playback/primitives/relocation-pipelines.js.map +1 -1
  192. package/dist/default/playback/primitives/report-track-conditions.js +26 -38
  193. package/dist/default/playback/primitives/report-track-conditions.js.map +1 -1
  194. package/dist/default/playback/primitives/segment-load-pipeline.js +15 -15
  195. package/dist/default/playback/primitives/segment-load-pipeline.js.map +1 -1
  196. package/dist/default/playback/primitives/selection-rules.js +65 -36
  197. package/dist/default/playback/primitives/selection-rules.js.map +1 -1
  198. package/dist/default/playback/primitives/text-segment-load-pipeline.js +4 -5
  199. package/dist/default/playback/primitives/text-segment-load-pipeline.js.map +1 -1
  200. package/dist/default/playback/primitives/track-types.js +10 -18
  201. package/dist/default/playback/primitives/track-types.js.map +1 -1
  202. package/dist/dev/core/actors/actor.d.ts +4 -4
  203. package/dist/dev/core/actors/actor.d.ts.map +1 -1
  204. package/dist/dev/core/actors/create-machine-actor.d.ts +38 -47
  205. package/dist/dev/core/actors/create-machine-actor.d.ts.map +1 -1
  206. package/dist/dev/core/actors/create-machine-actor.js +23 -25
  207. package/dist/dev/core/actors/create-machine-actor.js.map +1 -1
  208. package/dist/dev/core/actors/create-transition-actor.d.ts +11 -15
  209. package/dist/dev/core/actors/create-transition-actor.d.ts.map +1 -1
  210. package/dist/dev/core/actors/create-transition-actor.js +7 -9
  211. package/dist/dev/core/actors/create-transition-actor.js.map +1 -1
  212. package/dist/dev/core/composition/create-composition.d.ts +70 -102
  213. package/dist/dev/core/composition/create-composition.d.ts.map +1 -1
  214. package/dist/dev/core/composition/create-composition.js +26 -29
  215. package/dist/dev/core/composition/create-composition.js.map +1 -1
  216. package/dist/dev/core/composition/share-signals.d.ts +17 -24
  217. package/dist/dev/core/composition/share-signals.d.ts.map +1 -1
  218. package/dist/dev/core/composition/share-signals.js +12 -17
  219. package/dist/dev/core/composition/share-signals.js.map +1 -1
  220. package/dist/dev/core/machine.d.ts +4 -4
  221. package/dist/dev/core/machine.js +3 -4
  222. package/dist/dev/core/machine.js.map +1 -1
  223. package/dist/dev/core/reactors/create-machine-reactor.d.ts +33 -39
  224. package/dist/dev/core/reactors/create-machine-reactor.d.ts.map +1 -1
  225. package/dist/dev/core/reactors/create-machine-reactor.js +20 -19
  226. package/dist/dev/core/reactors/create-machine-reactor.js.map +1 -1
  227. package/dist/dev/core/signals/effect.d.ts +3 -4
  228. package/dist/dev/core/signals/effect.d.ts.map +1 -1
  229. package/dist/dev/core/signals/effect.js +24 -4
  230. package/dist/dev/core/signals/effect.js.map +1 -1
  231. package/dist/dev/core/signals/primitives.d.ts +10 -12
  232. package/dist/dev/core/signals/primitives.d.ts.map +1 -1
  233. package/dist/dev/core/signals/primitives.js +10 -14
  234. package/dist/dev/core/signals/primitives.js.map +1 -1
  235. package/dist/dev/core/signals/when.js +6 -8
  236. package/dist/dev/core/signals/when.js.map +1 -1
  237. package/dist/dev/core/tasks/delayed-reschedule.js +7 -11
  238. package/dist/dev/core/tasks/delayed-reschedule.js.map +1 -1
  239. package/dist/dev/core/tasks/task.d.ts +51 -73
  240. package/dist/dev/core/tasks/task.d.ts.map +1 -1
  241. package/dist/dev/core/tasks/task.js +59 -82
  242. package/dist/dev/core/tasks/task.js.map +1 -1
  243. package/dist/dev/hls.d.ts +3 -1
  244. package/dist/dev/hls.js +3 -1
  245. package/dist/dev/index.d.ts +2 -3
  246. package/dist/dev/index.d.ts.map +1 -1
  247. package/dist/dev/index.js +2 -3
  248. package/dist/dev/index.js.map +1 -1
  249. package/dist/dev/media/abr/quality-selection.d.ts +7 -10
  250. package/dist/dev/media/abr/quality-selection.d.ts.map +1 -1
  251. package/dist/dev/media/abr/quality-selection.js +3 -7
  252. package/dist/dev/media/abr/quality-selection.js.map +1 -1
  253. package/dist/dev/media/buffer/back-buffer.d.ts +2 -7
  254. package/dist/dev/media/buffer/back-buffer.d.ts.map +1 -1
  255. package/dist/dev/media/buffer/back-buffer.js +15 -19
  256. package/dist/dev/media/buffer/back-buffer.js.map +1 -1
  257. package/dist/dev/media/buffer/forward-buffer.d.ts +2 -7
  258. package/dist/dev/media/buffer/forward-buffer.d.ts.map +1 -1
  259. package/dist/dev/media/buffer/forward-buffer.js +32 -41
  260. package/dist/dev/media/buffer/forward-buffer.js.map +1 -1
  261. package/dist/dev/media/dom/capabilities.js +26 -37
  262. package/dist/dev/media/dom/capabilities.js.map +1 -1
  263. package/dist/dev/media/dom/mse/append-segment.d.ts +3 -5
  264. package/dist/dev/media/dom/mse/append-segment.d.ts.map +1 -1
  265. package/dist/dev/media/dom/mse/append-segment.js +3 -5
  266. package/dist/dev/media/dom/mse/append-segment.js.map +1 -1
  267. package/dist/dev/media/dom/mse/buffer-flusher.d.ts +5 -5
  268. package/dist/dev/media/dom/mse/buffer-flusher.js +5 -5
  269. package/dist/dev/media/dom/mse/buffer-flusher.js.map +1 -1
  270. package/dist/dev/media/dom/mse/duration.js +23 -31
  271. package/dist/dev/media/dom/mse/duration.js.map +1 -1
  272. package/dist/dev/media/dom/mse/end-of-stream.js +3 -6
  273. package/dist/dev/media/dom/mse/end-of-stream.js.map +1 -1
  274. package/dist/dev/media/dom/mse/mediasource-setup.js +65 -81
  275. package/dist/dev/media/dom/mse/mediasource-setup.js.map +1 -1
  276. package/dist/dev/media/dom/screen.d.ts.map +1 -1
  277. package/dist/dev/media/dom/screen.js +37 -54
  278. package/dist/dev/media/dom/screen.js.map +1 -1
  279. package/dist/dev/media/dom/text/resolve-vtt-segment.d.ts.map +1 -1
  280. package/dist/dev/media/dom/text/resolve-vtt-segment.js.map +1 -1
  281. package/dist/dev/media/dom/text/text-track-slots.d.ts +10 -16
  282. package/dist/dev/media/dom/text/text-track-slots.d.ts.map +1 -1
  283. package/dist/dev/media/dom/text/text-track-slots.js +15 -23
  284. package/dist/dev/media/dom/text/text-track-slots.js.map +1 -1
  285. package/dist/dev/media/errors.d.ts +32 -46
  286. package/dist/dev/media/errors.d.ts.map +1 -1
  287. package/dist/dev/media/errors.js +25 -34
  288. package/dist/dev/media/errors.js.map +1 -1
  289. package/dist/dev/media/hls/parse-attributes.js +9 -26
  290. package/dist/dev/media/hls/parse-attributes.js.map +1 -1
  291. package/dist/dev/media/hls/parse-media-playlist.js +25 -33
  292. package/dist/dev/media/hls/parse-media-playlist.js.map +1 -1
  293. package/dist/dev/media/hls/parse-multivariant.js +3 -3
  294. package/dist/dev/media/hls/parse-multivariant.js.map +1 -1
  295. package/dist/dev/media/hls/reload-policy.js +19 -27
  296. package/dist/dev/media/hls/reload-policy.js.map +1 -1
  297. package/dist/dev/media/hls/resolve-url.js +1 -3
  298. package/dist/dev/media/hls/resolve-url.js.map +1 -1
  299. package/dist/dev/media/live-window.js +9 -13
  300. package/dist/dev/media/live-window.js.map +1 -1
  301. package/dist/dev/media/media-tracks/media-tracks.d.ts +8 -13
  302. package/dist/dev/media/media-tracks/media-tracks.d.ts.map +1 -1
  303. package/dist/dev/media/media-tracks/media-tracks.js +12 -17
  304. package/dist/dev/media/media-tracks/media-tracks.js.map +1 -1
  305. package/dist/dev/media/mp4/box.js +4 -5
  306. package/dist/dev/media/mp4/box.js.map +1 -1
  307. package/dist/dev/media/mp4/timestamp-origin.js +30 -42
  308. package/dist/dev/media/mp4/timestamp-origin.js.map +1 -1
  309. package/dist/dev/media/primitives/resolution.d.ts +6 -8
  310. package/dist/dev/media/primitives/resolution.d.ts.map +1 -1
  311. package/dist/dev/media/primitives/resolution.js +5 -8
  312. package/dist/dev/media/primitives/resolution.js.map +1 -1
  313. package/dist/dev/media/primitives/select-tracks.js +24 -34
  314. package/dist/dev/media/primitives/select-tracks.js.map +1 -1
  315. package/dist/dev/media/text/parse-vtt-timestamp-map.js +6 -8
  316. package/dist/dev/media/text/parse-vtt-timestamp-map.js.map +1 -1
  317. package/dist/dev/media/text/resolve-vtt-metadata.js +8 -9
  318. package/dist/dev/media/text/resolve-vtt-metadata.js.map +1 -1
  319. package/dist/dev/media/types/index.d.ts +106 -177
  320. package/dist/dev/media/types/index.d.ts.map +1 -1
  321. package/dist/dev/media/types/index.js +10 -18
  322. package/dist/dev/media/types/index.js.map +1 -1
  323. package/dist/dev/media/utils/cdn.d.ts +4 -6
  324. package/dist/dev/media/utils/cdn.d.ts.map +1 -1
  325. package/dist/dev/media/utils/cdn.js +10 -16
  326. package/dist/dev/media/utils/cdn.js.map +1 -1
  327. package/dist/dev/media/utils/preload.js +4 -6
  328. package/dist/dev/media/utils/preload.js.map +1 -1
  329. package/dist/dev/media/utils/track-selection.js +10 -14
  330. package/dist/dev/media/utils/track-selection.js.map +1 -1
  331. package/dist/dev/media/utils/tracks.js +56 -54
  332. package/dist/dev/media/utils/tracks.js.map +1 -1
  333. package/dist/dev/network/bandwidth-estimator.d.ts +7 -9
  334. package/dist/dev/network/bandwidth-estimator.d.ts.map +1 -1
  335. package/dist/dev/network/bandwidth-estimator.js +18 -19
  336. package/dist/dev/network/bandwidth-estimator.js.map +1 -1
  337. package/dist/dev/network/chunked-stream-iterable.js +4 -6
  338. package/dist/dev/network/chunked-stream-iterable.js.map +1 -1
  339. package/dist/dev/network/ewma.js +22 -25
  340. package/dist/dev/network/ewma.js.map +1 -1
  341. package/dist/dev/network/fetch.js +30 -37
  342. package/dist/dev/network/fetch.js.map +1 -1
  343. package/dist/dev/playback/actors/dom/segment-loader.d.ts +7 -11
  344. package/dist/dev/playback/actors/dom/segment-loader.d.ts.map +1 -1
  345. package/dist/dev/playback/actors/dom/segment-loader.js +28 -44
  346. package/dist/dev/playback/actors/dom/segment-loader.js.map +1 -1
  347. package/dist/dev/playback/actors/dom/source-buffer.d.ts +5 -7
  348. package/dist/dev/playback/actors/dom/source-buffer.d.ts.map +1 -1
  349. package/dist/dev/playback/actors/dom/source-buffer.js.map +1 -1
  350. package/dist/dev/playback/actors/dom/text-tracks.js.map +1 -1
  351. package/dist/dev/playback/actors/text-track-segment-loader.d.ts +10 -16
  352. package/dist/dev/playback/actors/text-track-segment-loader.d.ts.map +1 -1
  353. package/dist/dev/playback/actors/text-track-segment-loader.js +24 -35
  354. package/dist/dev/playback/actors/text-track-segment-loader.js.map +1 -1
  355. package/dist/dev/playback/actors/text-tracks.d.ts +5 -8
  356. package/dist/dev/playback/actors/text-tracks.d.ts.map +1 -1
  357. package/dist/dev/playback/adapters/hls-audio/adapter.d.ts +11 -14
  358. package/dist/dev/playback/adapters/hls-audio/adapter.d.ts.map +1 -1
  359. package/dist/dev/playback/adapters/hls-audio/adapter.js +23 -31
  360. package/dist/dev/playback/adapters/hls-audio/adapter.js.map +1 -1
  361. package/dist/dev/playback/adapters/hls-audio/media.d.ts.map +1 -1
  362. package/dist/dev/playback/adapters/hls-audio/media.js.map +1 -1
  363. package/dist/dev/playback/adapters/hls-background-video/adapter.d.ts +28 -39
  364. package/dist/dev/playback/adapters/hls-background-video/adapter.d.ts.map +1 -1
  365. package/dist/dev/playback/adapters/hls-background-video/adapter.js +50 -70
  366. package/dist/dev/playback/adapters/hls-background-video/adapter.js.map +1 -1
  367. package/dist/dev/playback/adapters/hls-background-video/host.d.ts +12 -16
  368. package/dist/dev/playback/adapters/hls-background-video/host.d.ts.map +1 -1
  369. package/dist/dev/playback/adapters/hls-background-video/host.js +12 -16
  370. package/dist/dev/playback/adapters/hls-background-video/host.js.map +1 -1
  371. package/dist/dev/playback/adapters/hls-background-video/media.d.ts +5 -8
  372. package/dist/dev/playback/adapters/hls-background-video/media.d.ts.map +1 -1
  373. package/dist/dev/playback/adapters/hls-background-video/media.js +5 -8
  374. package/dist/dev/playback/adapters/hls-background-video/media.js.map +1 -1
  375. package/dist/dev/playback/adapters/hls-video/adapter.d.ts +12 -14
  376. package/dist/dev/playback/adapters/hls-video/adapter.d.ts.map +1 -1
  377. package/dist/dev/playback/adapters/hls-video/adapter.js +43 -60
  378. package/dist/dev/playback/adapters/hls-video/adapter.js.map +1 -1
  379. package/dist/dev/playback/adapters/hls-video/error-surface.d.ts +4 -5
  380. package/dist/dev/playback/adapters/hls-video/error-surface.d.ts.map +1 -1
  381. package/dist/dev/playback/adapters/hls-video/error-surface.js +13 -18
  382. package/dist/dev/playback/adapters/hls-video/error-surface.js.map +1 -1
  383. package/dist/dev/playback/adapters/hls-video/media-tracks.d.ts +4 -5
  384. package/dist/dev/playback/adapters/hls-video/media-tracks.d.ts.map +1 -1
  385. package/dist/dev/playback/adapters/hls-video/media-tracks.js +4 -5
  386. package/dist/dev/playback/adapters/hls-video/media-tracks.js.map +1 -1
  387. package/dist/dev/playback/adapters/hls-video/media.d.ts.map +1 -1
  388. package/dist/dev/playback/adapters/hls-video/media.js.map +1 -1
  389. package/dist/dev/playback/adapters/mux-audio/media.d.ts +8 -12
  390. package/dist/dev/playback/adapters/mux-audio/media.d.ts.map +1 -1
  391. package/dist/dev/playback/adapters/mux-audio/media.js +8 -12
  392. package/dist/dev/playback/adapters/mux-audio/media.js.map +1 -1
  393. package/dist/dev/playback/adapters/mux-video/adapter.d.ts +9 -11
  394. package/dist/dev/playback/adapters/mux-video/adapter.d.ts.map +1 -1
  395. package/dist/dev/playback/adapters/mux-video/adapter.js +25 -33
  396. package/dist/dev/playback/adapters/mux-video/adapter.js.map +1 -1
  397. package/dist/dev/playback/adapters/mux-video/media.d.ts +7 -9
  398. package/dist/dev/playback/adapters/mux-video/media.d.ts.map +1 -1
  399. package/dist/dev/playback/adapters/mux-video/media.js +7 -9
  400. package/dist/dev/playback/adapters/mux-video/media.js.map +1 -1
  401. package/dist/dev/playback/behaviors/calculate-presentation-duration.d.ts +5 -8
  402. package/dist/dev/playback/behaviors/calculate-presentation-duration.d.ts.map +1 -1
  403. package/dist/dev/playback/behaviors/calculate-presentation-duration.js +5 -8
  404. package/dist/dev/playback/behaviors/calculate-presentation-duration.js.map +1 -1
  405. package/dist/dev/playback/behaviors/collect-errors.d.ts +2 -0
  406. package/dist/dev/playback/behaviors/collect-errors.js +39 -52
  407. package/dist/dev/playback/behaviors/collect-errors.js.map +1 -1
  408. package/dist/dev/playback/behaviors/derive-cdn-priority.js +16 -23
  409. package/dist/dev/playback/behaviors/derive-cdn-priority.js.map +1 -1
  410. package/dist/dev/playback/behaviors/dom/airplay.js +38 -61
  411. package/dist/dev/playback/behaviors/dom/airplay.js.map +1 -1
  412. package/dist/dev/playback/behaviors/dom/apply-start-position.js +23 -35
  413. package/dist/dev/playback/behaviors/dom/apply-start-position.js.map +1 -1
  414. package/dist/dev/playback/behaviors/dom/end-of-stream.js +11 -16
  415. package/dist/dev/playback/behaviors/dom/end-of-stream.js.map +1 -1
  416. package/dist/dev/playback/behaviors/dom/load-segments.d.ts +5 -8
  417. package/dist/dev/playback/behaviors/dom/load-segments.d.ts.map +1 -1
  418. package/dist/dev/playback/behaviors/dom/load-segments.js +27 -39
  419. package/dist/dev/playback/behaviors/dom/load-segments.js.map +1 -1
  420. package/dist/dev/playback/behaviors/dom/recover-end-stall.js +21 -26
  421. package/dist/dev/playback/behaviors/dom/recover-end-stall.js.map +1 -1
  422. package/dist/dev/playback/behaviors/dom/seek-to-live-edge.js +41 -60
  423. package/dist/dev/playback/behaviors/dom/seek-to-live-edge.js.map +1 -1
  424. package/dist/dev/playback/behaviors/dom/setup-buffer-actors.js +50 -74
  425. package/dist/dev/playback/behaviors/dom/setup-buffer-actors.js.map +1 -1
  426. package/dist/dev/playback/behaviors/dom/setup-mediasource.js +29 -43
  427. package/dist/dev/playback/behaviors/dom/setup-mediasource.js.map +1 -1
  428. package/dist/dev/playback/behaviors/dom/setup-text-track-actors.d.ts +3 -3
  429. package/dist/dev/playback/behaviors/dom/setup-text-track-actors.d.ts.map +1 -1
  430. package/dist/dev/playback/behaviors/dom/setup-text-track-actors.js.map +1 -1
  431. package/dist/dev/playback/behaviors/dom/sync-live-seekable-range.js +3 -4
  432. package/dist/dev/playback/behaviors/dom/sync-live-seekable-range.js.map +1 -1
  433. package/dist/dev/playback/behaviors/dom/sync-text-tracks.js +30 -45
  434. package/dist/dev/playback/behaviors/dom/sync-text-tracks.js.map +1 -1
  435. package/dist/dev/playback/behaviors/dom/track-current-time.d.ts +2 -2
  436. package/dist/dev/playback/behaviors/dom/track-current-time.d.ts.map +1 -1
  437. package/dist/dev/playback/behaviors/dom/track-current-time.js +9 -11
  438. package/dist/dev/playback/behaviors/dom/track-current-time.js.map +1 -1
  439. package/dist/dev/playback/behaviors/dom/track-load-triggers.d.ts +6 -12
  440. package/dist/dev/playback/behaviors/dom/track-load-triggers.d.ts.map +1 -1
  441. package/dist/dev/playback/behaviors/dom/track-load-triggers.js +24 -32
  442. package/dist/dev/playback/behaviors/dom/track-load-triggers.js.map +1 -1
  443. package/dist/dev/playback/behaviors/dom/track-playback-rate.d.ts +2 -2
  444. package/dist/dev/playback/behaviors/dom/track-playback-rate.d.ts.map +1 -1
  445. package/dist/dev/playback/behaviors/dom/track-playback-rate.js +6 -8
  446. package/dist/dev/playback/behaviors/dom/track-playback-rate.js.map +1 -1
  447. package/dist/dev/playback/behaviors/dom/track-player-resolution.d.ts.map +1 -1
  448. package/dist/dev/playback/behaviors/dom/track-player-resolution.js +10 -14
  449. package/dist/dev/playback/behaviors/dom/track-player-resolution.js.map +1 -1
  450. package/dist/dev/playback/behaviors/dom/track-screen-resolution.js +8 -9
  451. package/dist/dev/playback/behaviors/dom/track-screen-resolution.js.map +1 -1
  452. package/dist/dev/playback/behaviors/dom/update-mediasource-duration.js +28 -43
  453. package/dist/dev/playback/behaviors/dom/update-mediasource-duration.js.map +1 -1
  454. package/dist/dev/playback/behaviors/establish-start-media-time.d.ts +15 -19
  455. package/dist/dev/playback/behaviors/establish-start-media-time.d.ts.map +1 -1
  456. package/dist/dev/playback/behaviors/establish-start-media-time.js +32 -42
  457. package/dist/dev/playback/behaviors/establish-start-media-time.js.map +1 -1
  458. package/dist/dev/playback/behaviors/resolve-presentation.d.ts.map +1 -1
  459. package/dist/dev/playback/behaviors/resolve-presentation.js +13 -22
  460. package/dist/dev/playback/behaviors/resolve-presentation.js.map +1 -1
  461. package/dist/dev/playback/behaviors/resolve-track.js +5 -12
  462. package/dist/dev/playback/behaviors/resolve-track.js.map +1 -1
  463. package/dist/dev/playback/behaviors/select-tracks.d.ts +28 -39
  464. package/dist/dev/playback/behaviors/select-tracks.d.ts.map +1 -1
  465. package/dist/dev/playback/behaviors/select-tracks.js +77 -104
  466. package/dist/dev/playback/behaviors/select-tracks.js.map +1 -1
  467. package/dist/dev/playback/behaviors/setup-failover-monitor.d.ts +1 -4
  468. package/dist/dev/playback/behaviors/setup-failover-monitor.d.ts.map +1 -1
  469. package/dist/dev/playback/behaviors/setup-failover-monitor.js +11 -16
  470. package/dist/dev/playback/behaviors/setup-failover-monitor.js.map +1 -1
  471. package/dist/dev/playback/behaviors/sync-preload.js +9 -13
  472. package/dist/dev/playback/behaviors/sync-preload.js.map +1 -1
  473. package/dist/dev/playback/behaviors/track-switching.d.ts +110 -0
  474. package/dist/dev/playback/behaviors/track-switching.d.ts.map +1 -0
  475. package/dist/dev/playback/behaviors/track-switching.js +189 -173
  476. package/dist/dev/playback/behaviors/track-switching.js.map +1 -1
  477. package/dist/dev/playback/engines/hls/engine-audio-only.d.ts +59 -72
  478. package/dist/dev/playback/engines/hls/engine-audio-only.d.ts.map +1 -1
  479. package/dist/dev/playback/engines/hls/engine-audio-only.js +20 -24
  480. package/dist/dev/playback/engines/hls/engine-audio-only.js.map +1 -1
  481. package/dist/dev/playback/engines/hls/engine-background-video.d.ts +51 -78
  482. package/dist/dev/playback/engines/hls/engine-background-video.d.ts.map +1 -1
  483. package/dist/dev/playback/engines/hls/engine-background-video.js +22 -27
  484. package/dist/dev/playback/engines/hls/engine-background-video.js.map +1 -1
  485. package/dist/dev/playback/engines/hls/engine.d.ts +115 -155
  486. package/dist/dev/playback/engines/hls/engine.d.ts.map +1 -1
  487. package/dist/dev/playback/engines/hls/engine.js +22 -25
  488. package/dist/dev/playback/engines/hls/engine.js.map +1 -1
  489. package/dist/dev/playback/primitives/derive-start-media-time.d.ts +3 -3
  490. package/dist/dev/playback/primitives/derive-start-media-time.d.ts.map +1 -1
  491. package/dist/dev/playback/primitives/error-messages.js +16 -25
  492. package/dist/dev/playback/primitives/error-messages.js.map +1 -1
  493. package/dist/dev/playback/primitives/failover-fetch.js +9 -14
  494. package/dist/dev/playback/primitives/failover-fetch.js.map +1 -1
  495. package/dist/dev/playback/primitives/head-peek.js +7 -10
  496. package/dist/dev/playback/primitives/head-peek.js.map +1 -1
  497. package/dist/dev/playback/primitives/live-window.js +12 -15
  498. package/dist/dev/playback/primitives/live-window.js.map +1 -1
  499. package/dist/dev/playback/primitives/relocation-pipelines.js +34 -46
  500. package/dist/dev/playback/primitives/relocation-pipelines.js.map +1 -1
  501. package/dist/dev/playback/primitives/report-track-conditions.d.ts +1 -4
  502. package/dist/dev/playback/primitives/report-track-conditions.d.ts.map +1 -1
  503. package/dist/dev/playback/primitives/report-track-conditions.js +26 -38
  504. package/dist/dev/playback/primitives/report-track-conditions.js.map +1 -1
  505. package/dist/dev/playback/primitives/segment-load-pipeline.js +15 -15
  506. package/dist/dev/playback/primitives/segment-load-pipeline.js.map +1 -1
  507. package/dist/dev/playback/primitives/selection-rules.d.ts +45 -17
  508. package/dist/dev/playback/primitives/selection-rules.d.ts.map +1 -1
  509. package/dist/dev/playback/primitives/selection-rules.js +65 -36
  510. package/dist/dev/playback/primitives/selection-rules.js.map +1 -1
  511. package/dist/dev/playback/primitives/source-buffer-messages.d.ts +6 -9
  512. package/dist/dev/playback/primitives/source-buffer-messages.d.ts.map +1 -1
  513. package/dist/dev/playback/primitives/text-segment-load-pipeline.d.ts +20 -29
  514. package/dist/dev/playback/primitives/text-segment-load-pipeline.d.ts.map +1 -1
  515. package/dist/dev/playback/primitives/text-segment-load-pipeline.js +4 -5
  516. package/dist/dev/playback/primitives/text-segment-load-pipeline.js.map +1 -1
  517. package/dist/dev/playback/primitives/text-track-messages.d.ts.map +1 -1
  518. package/dist/dev/playback/primitives/track-types.js +10 -18
  519. package/dist/dev/playback/primitives/track-types.js.map +1 -1
  520. package/package.json +25 -28
@@ -1 +1 @@
1
- {"version":3,"file":"selection-rules.js","names":[],"sources":["../../../../src/playback/primitives/selection-rules.ts"],"sourcesContent":["/**\n * The selection-rule substrate: the shape of a rule, and the two composers that\n * turn a list of them into a pick.\n *\n * Lives here rather than beside `switchVideoTrack` so both track-selection\n * behaviors can share rules. The simple `selectVideoTrack` variant exists\n * specifically to tree-shake the ABR path out, so importing a composer from\n * `behaviors/track-switching.ts` would drag the bandwidth estimator and quality\n * selection back in with it. These four have no dependencies at all — pure\n * generics over a candidate list — so either side can reach them freely.\n *\n * See `internal/design/spf/track-switching-model.md` for the model these\n * implement: a hard constraints pre-pass, then an ordered chain of soft\n * narrowing rules and rankers, with the pick as the first survivor.\n */\n\nimport type { CanPlayTrack } from '../../media/types';\n\n/**\n * Deps handed to each rule and to `applyRules`, mirroring a behavior's setup\n * deps so a rule reads from the same surfaces a behavior does. `context` is\n * optional — it's threaded through but absent on direct setup calls (and\n * unread by today's rules), so the whole deps object can pass straight through.\n */\nexport interface SelectionRuleDeps<State = unknown, Context = unknown, Config = unknown> {\n state: State;\n context?: Context;\n config: Config;\n}\n\n/**\n * A selection rule narrows or reorders the candidate list. It reads the state,\n * context, and config it needs at apply time (tightly-coupled reads), so a\n * rule's `.get()`s subscribe the running effect to exactly what it consulted.\n * Returning an empty list means \"no match\" — the composer skips it, so a soft\n * filter never narrows the set to nothing. A ranker returns the list with its\n * pick at the head.\n */\nexport type SelectionRule<T, State = unknown, Context = unknown, Config = unknown> = (\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n) => readonly T[];\n\n/**\n * Apply rules to a candidate list in order; the pick is the first survivor.\n * Two responsibilities the rules don't carry: a rule that returns nothing is\n * skipped (fall-through — a preference never empties the set), and once one\n * survivor remains the chain stops (early-bail — later rules, including the\n * bandwidth ranker, never run, so the effect doesn't subscribe to their\n * signals while the choice is fixed).\n *\n * @param rules - Rules to apply, most authoritative first\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed through to each rule\n * @returns The surviving candidates, pick first\n */\nexport function applyRules<T, State, Context, Config>(\n rules: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n for (const rule of rules) {\n const remaining = rule(current, deps);\n if (remaining.length === 0) continue;\n current = remaining;\n if (current.length === 1) break;\n }\n return current;\n}\n\n/**\n * Apply hard constraints to a candidate list — the pre-pass that runs before the\n * rule chain. A constraint shares a rule's signature but its exclusion is\n * *hard*: it removes the unplayable (a codec the environment can't decode, a CDN\n * in failover cooldown) and a removed track is never attempted. Unlike\n * `applyRules`, this never skips an empty result and never early-bails — every\n * constraint always applies, and an empty survivor set is a real outcome\n * (\"nothing playable here\"), not a fall-through. Because each constraint only\n * removes, the order they run in can't change which tracks survive — though one\n * that also *reports* reads the list at its own position, so placement matters.\n *\n * @param constraints - Constraints to apply, in order\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed to each constraint\n * @returns The playable survivors (possibly empty)\n */\nexport function applyConstraints<T, State, Context, Config>(\n constraints: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n for (const constraint of constraints) current = constraint(current, deps);\n return current;\n}\n\n/**\n * Whether two candidate sets hold the same tracks, by id.\n *\n * The `equals` both selection behaviors give their candidate-set `computed`. A\n * live playlist refresh swaps in a new presentation object carrying the same\n * variants, and a constraint's own inputs can churn without changing which\n * tracks survive; in both cases the set is unchanged and the reaction must not\n * re-fire. Compares by id rather than array identity for exactly that.\n */\nexport function sameCandidateSet<T extends { id: string }>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((track) => b.some((other) => other.id === track.id));\n}\n\n/**\n * What {@link excludeUnplayableTracks} reads off the config it is handed.\n *\n * Read through a cast rather than constraining the rule's `Config` generic, the\n * same way `screenResolutionCap` reads `screenResolution` off its state: a rule\n * composes into chains whose config types have nothing else in common, and\n * constraining the generic would make every one of those a weak-type mismatch.\n * Each engine defaults `canPlayTrack` to the DOM-bound probe; unwired means \"no\n * capability filtering\" and the constraint passes everything through.\n */\nexport interface CapabilityConstraintConfig {\n canPlayTrack?: CanPlayTrack;\n}\n\n/**\n * Capability constraint — a *hard* filter for the {@link applyConstraints}\n * pre-pass. Removes renditions this environment can't decode, probed via the\n * injected `canPlayTrack` (codec → `MediaSource.isTypeSupported`, plus the\n * container and encryption assertions that probe can't make). Constraining here\n * — before selection — means an unplayable variant is pruned upstream and never\n * picked, instead of surviving into the pipeline to fail late at\n * `createSourceBuffer`. That late throw stays as a defensive structural\n * guarantee; with this constraint it should rarely fire.\n *\n * Lives here rather than beside `switchVideoTrack` for the reason this module\n * exists: both the re-evaluating variant and the pinned `selectVideoTrack` apply\n * it, and reaching it through `behaviors/track-switching.ts` would drag the ABR\n * path into a composition that deliberately omits it.\n *\n * Passes everything through when there's no probe (a composition that didn't\n * wire one, or DOM-free tests). When it prunes *every* track, the empty result is\n * preserved (per `applyConstraints`) — \"nothing playable\" — which each consuming\n * behavior answers by clearing its selection; reporting the verdict is separate.\n */\nexport function excludeUnplayableTracks<T, State, Context, Config>(\n tracks: readonly T[],\n { config }: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n const canPlay = (config as CapabilityConstraintConfig | undefined)?.canPlayTrack;\n if (!canPlay) return tracks;\n return tracks.filter((track) => canPlay(track as Parameters<CanPlayTrack>[0]));\n}\n"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAgB,WACd,OACA,QACA,MACc;CACd,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,YAAY,KAAK,SAAS,IAAI;EACpC,IAAI,UAAU,WAAW,GAAG;EAC5B,UAAU;EACV,IAAI,QAAQ,WAAW,GAAG;CAC5B;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,SAAgB,iBACd,aACA,QACA,MACc;CACd,IAAI,UAAU;CACd,KAAK,MAAM,cAAc,aAAa,UAAU,WAAW,SAAS,IAAI;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,iBAA2C,GAAiB,GAA0B;CACpG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM,EAAE,CAAC;AAC7F;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,wBACd,QACA,EAAE,UACY;CACd,MAAM,UAAW,QAAmD;CACpE,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,OAAO,QAAQ,UAAU,QAAQ,KAAoC,CAAC;AAC/E"}
1
+ {"version":3,"file":"selection-rules.js","names":[],"sources":["../../../../src/playback/primitives/selection-rules.ts"],"sourcesContent":["/**\n * The selection-rule substrate: the shape of a rule, and the two composers that turn a list of them into a pick.\n *\n * Lives here rather than beside `switchVideoTrack` so both track-selection behaviors can share rules. The simple\n * `selectVideoTrack` variant exists specifically to tree-shake the ABR path out, so importing a composer from\n * `behaviors/track-switching.ts` would drag the bandwidth estimator and quality selection back in with it. Nothing here\n * reaches past pure generics over a candidate list and small media-layer helpers, so either side can reach them\n * freely.\n *\n * See `internal/design/spf/track-switching-model.md` for the model these implement: a hard constraints pre-pass, then\n * an ordered chain of soft narrowing rules and rankers, with the pick as the first survivor.\n */\n\nimport type { CanPlayTrack } from '../../media/types';\nimport { getCodecFamilies, getCodecFamily } from '../../media/utils/tracks';\n\n/**\n * Deps handed to each rule and to `applyRules`, mirroring a behavior's setup deps so a rule reads from the same\n * surfaces a behavior does. `context` is optional — it's threaded through but absent on direct setup calls (and unread\n * by today's rules), so the whole deps object can pass straight through.\n */\nexport interface SelectionRuleDeps<State = unknown, Context = unknown, Config = unknown> {\n state: State;\n context?: Context;\n config: Config;\n}\n\n/**\n * A selection rule narrows or reorders the candidate list. It reads the state, context, and config it needs at apply\n * time (tightly-coupled reads), so a rule's `.get()`s subscribe the running effect to exactly what it consulted.\n * Returning an empty list means \"no match\" — the composer skips it, so a soft filter never narrows the set to nothing.\n * A ranker returns the list with its pick at the head.\n */\nexport type SelectionRule<T, State = unknown, Context = unknown, Config = unknown> = (\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n) => readonly T[];\n\n/**\n * Apply rules to a candidate list in order; the pick is the first survivor. Two responsibilities the rules don't carry:\n * a rule that returns nothing is skipped (fall-through — a preference never empties the set), and once one survivor\n * remains the chain stops (early-bail — later rules, including the bandwidth ranker, never run, so the effect doesn't\n * subscribe to their signals while the choice is fixed).\n *\n * @param rules - Rules to apply, most authoritative first\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed through to each rule\n * @returns The surviving candidates, pick first\n */\nexport function applyRules<T, State, Context, Config>(\n rules: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n\n for (const rule of rules) {\n const remaining = rule(current, deps);\n if (remaining.length === 0) continue;\n\n current = remaining;\n\n if (current.length === 1) break;\n }\n\n return current;\n}\n\n/**\n * Apply hard constraints to a candidate list — the pre-pass that runs before the rule chain. A constraint shares a\n * rule's signature but its exclusion is _hard_: it removes the unplayable (a codec the environment can't decode, a CDN\n * in failover cooldown) and a removed track is never attempted. Unlike `applyRules`, this never skips an empty result\n * and never early-bails — every constraint always applies, and an empty survivor set is a real outcome (\"nothing\n * playable here\"), not a fall-through. Because each constraint only removes, the order they run in can't change which\n * tracks survive — though one that also _reports_ reads the list at its own position, so placement matters.\n *\n * @param constraints - Constraints to apply, in order\n * @param tracks - Candidate tracks\n * @param deps - The behavior's `{ state, context, config }`, passed to each constraint\n * @returns The playable survivors (possibly empty)\n */\nexport function applyConstraints<T, State, Context, Config>(\n constraints: readonly SelectionRule<T, State, Context, Config>[],\n tracks: readonly T[],\n deps: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n let current = tracks;\n\n for (const constraint of constraints) current = constraint(current, deps);\n\n return current;\n}\n\n/**\n * Whether two candidate sets hold the same tracks, by id.\n *\n * The `equals` both selection behaviors give their candidate-set `computed`. A live playlist refresh swaps in a new\n * presentation object carrying the same variants, and a constraint's own inputs can churn without changing which tracks\n * survive; in both cases the set is unchanged and the reaction must not re-fire. Compares by id rather than array\n * identity for exactly that.\n */\nexport function sameCandidateSet<T extends { id: string }>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((track) => b.some((other) => other.id === track.id));\n}\n\n/**\n * What {@link excludeUnplayableTracks} reads off the config it is handed.\n *\n * Read through a cast rather than constraining the rule's `Config` generic, the same way `screenResolutionCap` reads\n * `screenResolution` off its state: a rule composes into chains whose config types have nothing else in common, and\n * constraining the generic would make every one of those a weak-type mismatch. Each engine defaults `canPlayTrack` to\n * the DOM-bound probe; unwired means \"no capability filtering\" and the constraint passes everything through.\n */\nexport interface CapabilityConstraintConfig {\n canPlayTrack?: CanPlayTrack;\n}\n\n/**\n * Capability constraint — a _hard_ filter for the {@link applyConstraints} pre-pass. Removes renditions this\n * environment can't decode, probed via the injected `canPlayTrack` (codec → `MediaSource.isTypeSupported`, plus the\n * container and encryption assertions that probe can't make). Constraining here — before selection — means an\n * unplayable variant is pruned upstream and never picked, instead of surviving into the pipeline to fail late at\n * `createSourceBuffer`. That late throw stays as a defensive structural guarantee; with this constraint it should\n * rarely fire.\n *\n * Lives here rather than beside `switchVideoTrack` for the reason this module exists: both the re-evaluating variant\n * and the pinned `selectVideoTrack` apply it, and reaching it through `behaviors/track-switching.ts` would drag the ABR\n * path into a composition that deliberately omits it.\n *\n * Passes everything through when there's no probe (a composition that didn't wire one, or DOM-free tests). When it\n * prunes _every_ track, the empty result is preserved (per `applyConstraints`) — \"nothing playable\" — which each\n * consuming behavior answers by clearing its selection; reporting the verdict is separate.\n */\nexport function excludeUnplayableTracks<T, State, Context, Config>(\n tracks: readonly T[],\n { config }: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n const canPlay = (config as CapabilityConstraintConfig | undefined)?.canPlayTrack;\n if (!canPlay) return tracks;\n\n return tracks.filter((track) => canPlay(track as Parameters<CanPlayTrack>[0]));\n}\n\n/**\n * What {@link preferCodecFamilies} reads off the config it is handed — a cast view, for the same reason as\n * {@link CapabilityConstraintConfig}.\n */\nexport interface CodecPreferenceConfig {\n preferredCodecs?: string[];\n}\n\n/**\n * The codec families {@link preferCodecFamilies} narrows to when the config carries no `preferredCodecs`: AVC (both its\n * 4CCs) and AAC. The default is deliberate rather than neutral — SPF implements no `SourceBuffer.changeType()`, so on a\n * mixed-codec source the _initial_ family choice is the one ABR lives inside for the whole source (see\n * `stickToSelectedCodecs` in `behaviors/track-switching.ts`), and AVC/AAC is the family pair with the broadest decode\n * support. The cost, equally deliberate: on a ladder whose higher rungs are HEVC-only (a common 4K shape), the default\n * caps quality at the top AVC rung — configure `preferredCodecs` (or pass `[]`) to trade the other way.\n */\nexport const DEFAULT_PREFERRED_CODECS: readonly string[] = ['avc1', 'avc3', 'mp4a'];\n\n/**\n * Codec-family preference — a _soft_ filter (scope) for a selection-rule chain; the `hevc-variant-selection` concern\n * from `internal/design/spf/track-switching-model.md`. Narrows to the tracks whose codec families are all in\n * `preferredCodecs` (family-compared, so entries may be 4CCs or full codec strings). Soft-filter semantics: a source\n * with no preferred-family rendition (an HEVC-only ladder under the AVC default) is left unnarrowed, and a track\n * without codecs never matches — on a ladder with no codecs anywhere (DOM-free tests) the rule is inert.\n *\n * `preferredCodecs` defaults to {@link DEFAULT_PREFERRED_CODECS}; explicitly pass `[]` to disable the preference while\n * keeping the rule composed.\n *\n * \"All families\" rather than \"any\" so a muxed rendition is judged as the unit it is: `hvc1,mp4a` must not count as\n * preferred just because its audio half matches.\n *\n * Lives here rather than beside `switchVideoTrack` for the module's usual reason: the pinned `selectVideoTrack` variant\n * can compose it without dragging the ABR path in.\n */\nexport function preferCodecFamilies<T, State, Context, Config>(\n tracks: readonly T[],\n { config }: SelectionRuleDeps<State, Context, Config>\n): readonly T[] {\n const preferred = (config as CodecPreferenceConfig | undefined)?.preferredCodecs ?? DEFAULT_PREFERRED_CODECS;\n if (!preferred.length) return tracks;\n\n const preferredFamilies = new Set(preferred.map(getCodecFamily));\n\n return tracks.filter((track) => {\n const families = getCodecFamilies(track as { codecs?: string[] });\n\n return !!families && families.every((family) => preferredFamilies.has(family));\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAiDA,SAAgB,WACd,OACA,QACA,MACc;CACd,IAAI,UAAU;CAEd,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,YAAY,KAAK,SAAS,IAAI;EACpC,IAAI,UAAU,WAAW,GAAG;EAE5B,UAAU;EAEV,IAAI,QAAQ,WAAW,GAAG;CAC5B;CAEA,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,iBACd,aACA,QACA,MACc;CACd,IAAI,UAAU;CAEd,KAAK,MAAM,cAAc,aAAa,UAAU,WAAW,SAAS,IAAI;CAExE,OAAO;AACT;;;;;;;;;AAUA,SAAgB,iBAA2C,GAAiB,GAA0B;CACpG,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,UAAU,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM,EAAE,CAAC;AAC7F;;;;;;;;;;;;;;;;;AA8BA,SAAgB,wBACd,QACA,EAAE,UACY;CACd,MAAM,UAAW,QAAmD;CACpE,IAAI,CAAC,SAAS,OAAO;CAErB,OAAO,OAAO,QAAQ,UAAU,QAAQ,KAAoC,CAAC;AAC/E;;;;;;;;;AAkBA,MAAa,2BAA8C;CAAC;CAAQ;CAAQ;AAAM;;;;;;;;;;;;;;;;;AAkBlF,SAAgB,oBACd,QACA,EAAE,UACY;CACd,MAAM,YAAa,QAA8C,mBAAmB;CACpF,IAAI,CAAC,UAAU,QAAQ,OAAO;CAE9B,MAAM,oBAAoB,IAAI,IAAI,UAAU,IAAI,cAAc,CAAC;CAE/D,OAAO,OAAO,QAAQ,UAAU;EAC9B,MAAM,WAAW,iBAAiB,KAA8B;EAEhE,OAAO,CAAC,CAAC,YAAY,SAAS,OAAO,WAAW,kBAAkB,IAAI,MAAM,CAAC;CAC/E,CAAC;AACH"}
@@ -1,10 +1,9 @@
1
1
  //#region src/playback/primitives/text-segment-load-pipeline.ts
2
2
  /**
3
- * Base-step view of the loader's wiring, folded into `config` by
4
- * `createTextTrackSegmentLoaderActor` so base steps read it from the uniform passthrough
5
- * present in both composition and standalone use. `config` is loose (`object`), so
6
- * assert the shape here (mirrors the v/a loader's `stepWiring`). The sink is the
7
- * structural {@link CueSink}, not the concrete actor.
3
+ * Base-step view of the loader's wiring, folded into `config` by `createTextTrackSegmentLoaderActor` so base steps read
4
+ * it from the uniform passthrough present in both composition and standalone use. `config` is loose (`object`), so
5
+ * assert the shape here (mirrors the v/a loader's `stepWiring`). The sink is the structural {@link CueSink}, not the
6
+ * concrete actor.
8
7
  */
9
8
  function textStepWiring(deps) {
10
9
  return deps.config;
@@ -1 +1 @@
1
- {"version":3,"file":"text-segment-load-pipeline.js","names":[],"sources":["../../../../src/playback/primitives/text-segment-load-pipeline.ts"],"sourcesContent":["/**\n * The text-track **load pipeline** — the step vocabulary and base steps a text-segment\n * loader runs, the text mirror of `segment-load-pipeline`. Extracted from the loader\n * actor so the \"what\" (the composable steps) is separable from the \"how\" (scheduling).\n * A pipeline is a flat, ordered list of {@link TextLoadStep}s (text has a single op\n * type, so no per-type `Record`); the default is `resolveCues → dispatchCues`, and a\n * composition can insert its own steps (e.g. non-zero-PTS cue rebase) without the\n * loader knowing.\n *\n * The dispatch step reaches its cue sink through the structural {@link CueSink} seam\n * rather than the concrete `TextTracksActor` type — the loader folds the real actor\n * into `config`, and it satisfies the seam by structure — so this module names no\n * actor and stays DOM-free (generic over the cue type `C`).\n */\nimport type { AnySlotMap } from '../../core/composition/create-composition';\nimport type { Cue, Segment } from '../../media/types';\nimport type { AddCuesMessage } from './text-track-messages';\n\n// ============================================================================\n// SINK SEAM\n// ============================================================================\n\n/**\n * The structural view of a cue sink the base steps use — just the `send`\n * {@link dispatchCuesStep} needs. The concrete `TextTracksActor` satisfies it by\n * structure, so the pipeline names no actor.\n */\nexport interface CueSink<C extends Cue = Cue> {\n send(message: AddCuesMessage<C>): void;\n}\n\n// ============================================================================\n// STEP MODEL\n// ============================================================================\n\n/**\n * Resolves a text-track segment URL into the array of cues it contains.\n *\n * \"Resolve\" because the fn covers both network fetch and parse into the\n * domain model. Host-agnostic — the concrete resolver (e.g. the\n * browser's native VTT resolver) is supplied at engine-assembly time,\n * so this stays DOM-free. A pure `url → cues` primitive (the text\n * analog of the v/a loader's `fetchBytes`); composition-awareness lives in\n * the injected {@link TextLoadStep}s, not here.\n */\nexport type TextTrackSegmentResolver<C extends Cue = Cue> = (url: string) => Promise<C[]>;\n\n/** Internal load-task descriptor — one segment fetch + dispatch unit. */\nexport interface TextLoadTask {\n segment: Segment;\n trackId: string;\n}\n\n/**\n * A text load in mid-pipeline — the text analog of the v/a loader's `Frame`.\n * `resolveCuesStep` fills `cues`; `dispatchCuesStep` sends them. `metadata` is\n * opaque header metadata a resolve step may attach for a later step to read\n * (e.g. relocation stashes the `X-TIMESTAMP-MAP` correlation here for its rebase\n * step). Typed `unknown` so the generic loader stays host-agnostic — the step\n * that reads it knows its concrete shape (mirrors `StepDeps.state`).\n */\nexport interface TextFrame<C extends Cue = Cue> {\n readonly op: TextLoadTask;\n cues?: C[];\n metadata?: unknown;\n}\n\n/**\n * One stage of a text message pipeline — the text analog of the v/a loader's\n * `LoadStep`. Mutates the {@link TextFrame} in place and may be async; the runner\n * checks `signal.aborted` before each step and passes the actor's\n * {@link TextStepDeps} on every call, so a stateless step (`resolveCuesStep`) is a\n * plain value and a step that needs composition signals (relocation's cue rebase)\n * reads them from `deps` at call time.\n */\nexport type TextLoadStep<C extends Cue = Cue> = (\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n) => void | Promise<void>;\n\n/**\n * The uniform passthrough handed to each {@link TextLoadStep} — the composition triple,\n * the text analog of `StepDeps`. `state`/`context` are the composition signal maps;\n * `config` is the threaded config with the loader's wiring folded in (see\n * {@link textStepWiring} + `createTextTrackSegmentLoaderActor`). Typed loose: composition\n * steps read `state`; base steps read the folded wiring off `config`.\n */\nexport interface TextStepDeps {\n state: AnySlotMap;\n context: AnySlotMap;\n config: object;\n}\n\n/**\n * Base-step view of the loader's wiring, folded into `config` by\n * `createTextTrackSegmentLoaderActor` so base steps read it from the uniform passthrough\n * — present in both composition and standalone use. `config` is loose (`object`), so\n * assert the shape here (mirrors the v/a loader's `stepWiring`). The sink is the\n * structural {@link CueSink}, not the concrete actor.\n */\nexport function textStepWiring<C extends Cue>(\n deps: TextStepDeps\n): { textTracksActor: CueSink<C>; resolveSegment: TextTrackSegmentResolver<C> } {\n return deps.config as { textTracksActor: CueSink<C>; resolveSegment: TextTrackSegmentResolver<C> };\n}\n\n/**\n * Builds the ordered step list, called **once per actor** (mirrors the v/a loader's\n * `MessagePipelines`, but text has a single op type so it's a flat array, not a\n * `Record`). The default ({@link DEFAULT_TEXT_MESSAGE_PIPELINES}) is\n * `resolveCues → dispatchCues`; a non-zero-PTS composition returns a list that\n * inserts a cue-rebase step (see `relocatingTextPipelines`), so the loader stays\n * oblivious to relocation.\n */\nexport type TextMessagePipelines<C extends Cue = Cue> = () => TextLoadStep<C>[];\n\n// ============================================================================\n// BASE STEPS\n// ============================================================================\n\n// Base steps are generic over the cue type `C` (generic arrow consts, not\n// `TextLoadStep<Cue>` values): each touches `C` — `frame.cues: C[]` and the\n// `C`-typed `textStepWiring<C>` — so a `Cue`-typed const wouldn't slot into a\n// `VTTCue` pipeline. A generic function assigns to any `TextLoadStep<C>`.\n\n/** Resolve the op's cues (via the injected host primitive) into the frame. The text analog of `fetchStep`. */\nexport const resolveCuesStep = async <C extends Cue>(\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n): Promise<void> => {\n const cues = await textStepWiring<C>(deps).resolveSegment(frame.op.segment.url);\n if (signal.aborted) return;\n frame.cues = cues;\n};\n\n/** Dispatch the frame's cues to the TextTracksActor as `add-cues`. The text analog of `dispatchStep`. */\nexport const dispatchCuesStep = <C extends Cue>(\n frame: TextFrame<C>,\n _signal: AbortSignal,\n deps: TextStepDeps\n): void => {\n const { op } = frame;\n textStepWiring<C>(deps).textTracksActor.send({\n type: 'add-cues',\n meta: {\n trackId: op.trackId,\n id: op.segment.id,\n startTime: op.segment.startTime,\n duration: op.segment.duration,\n },\n cues: frame.cues ?? [],\n });\n};\n\n/** Tier 0 default: resolve then dispatch. No relocation vocabulary. */\nexport const DEFAULT_TEXT_MESSAGE_PIPELINES = <C extends Cue>(): TextLoadStep<C>[] => [\n resolveCuesStep,\n dispatchCuesStep,\n];\n"],"mappings":";;;;;;;;AAqGA,SAAgB,eACd,MAC8E;CAC9E,OAAO,KAAK;AACd;;AAsBA,MAAa,kBAAkB,OAC7B,OACA,QACA,SACkB;CAClB,MAAM,OAAO,MAAM,eAAkB,IAAI,CAAC,CAAC,eAAe,MAAM,GAAG,QAAQ,GAAG;CAC9E,IAAI,OAAO,SAAS;CACpB,MAAM,OAAO;AACf;;AAGA,MAAa,oBACX,OACA,SACA,SACS;CACT,MAAM,EAAE,OAAO;CACf,eAAkB,IAAI,CAAC,CAAC,gBAAgB,KAAK;EAC3C,MAAM;EACN,MAAM;GACJ,SAAS,GAAG;GACZ,IAAI,GAAG,QAAQ;GACf,WAAW,GAAG,QAAQ;GACtB,UAAU,GAAG,QAAQ;EACvB;EACA,MAAM,MAAM,QAAQ,CAAC;CACvB,CAAC;AACH;;AAGA,MAAa,uCAAyE,CACpF,iBACA,gBACF"}
1
+ {"version":3,"file":"text-segment-load-pipeline.js","names":[],"sources":["../../../../src/playback/primitives/text-segment-load-pipeline.ts"],"sourcesContent":["/**\n * The text-track **load pipeline** — the step vocabulary and base steps a text-segment loader runs, the text mirror of\n * `segment-load-pipeline`. Extracted from the loader actor so the \"what\" (the composable steps) is separable from the\n * \"how\" (scheduling). A pipeline is a flat, ordered list of {@link TextLoadStep}s (text has a single op type, so no\n * per-type `Record`); the default is `resolveCues → dispatchCues`, and a composition can insert its own steps (e.g.\n * non-zero-PTS cue rebase) without the loader knowing.\n *\n * The dispatch step reaches its cue sink through the structural {@link CueSink} seam rather than the concrete\n * `TextTracksActor` type — the loader folds the real actor into `config`, and it satisfies the seam by structure — so\n * this module names no actor and stays DOM-free (generic over the cue type `C`).\n */\nimport type { AnySlotMap } from '../../core/composition/create-composition';\nimport type { Cue, Segment } from '../../media/types';\nimport type { AddCuesMessage } from './text-track-messages';\n\n// ============================================================================\n// SINK SEAM\n// ============================================================================\n\n/**\n * The structural view of a cue sink the base steps use — just the `send` {@link dispatchCuesStep} needs. The concrete\n * `TextTracksActor` satisfies it by structure, so the pipeline names no actor.\n */\nexport interface CueSink<C extends Cue = Cue> {\n send(message: AddCuesMessage<C>): void;\n}\n\n// ============================================================================\n// STEP MODEL\n// ============================================================================\n\n/**\n * Resolves a text-track segment URL into the array of cues it contains.\n *\n * \"Resolve\" because the fn covers both network fetch and parse into the domain model. Host-agnostic — the concrete\n * resolver (e.g. the browser's native VTT resolver) is supplied at engine-assembly time, so this stays DOM-free. A pure\n * `url → cues` primitive (the text analog of the v/a loader's `fetchBytes`); composition-awareness lives in the\n * injected {@link TextLoadStep}s, not here.\n */\nexport type TextTrackSegmentResolver<C extends Cue = Cue> = (url: string) => Promise<C[]>;\n\n/** Internal load-task descriptor — one segment fetch + dispatch unit. */\nexport interface TextLoadTask {\n segment: Segment;\n trackId: string;\n}\n\n/**\n * A text load in mid-pipeline — the text analog of the v/a loader's `Frame`. `resolveCuesStep` fills `cues`;\n * `dispatchCuesStep` sends them. `metadata` is opaque header metadata a resolve step may attach for a later step to\n * read (e.g. relocation stashes the `X-TIMESTAMP-MAP` correlation here for its rebase step). Typed `unknown` so the\n * generic loader stays host-agnostic — the step that reads it knows its concrete shape (mirrors `StepDeps.state`).\n */\nexport interface TextFrame<C extends Cue = Cue> {\n readonly op: TextLoadTask;\n cues?: C[];\n metadata?: unknown;\n}\n\n/**\n * One stage of a text message pipeline — the text analog of the v/a loader's `LoadStep`. Mutates the {@link TextFrame}\n * in place and may be async; the runner checks `signal.aborted` before each step and passes the actor's\n * {@link TextStepDeps} on every call, so a stateless step (`resolveCuesStep`) is a plain value and a step that needs\n * composition signals (relocation's cue rebase) reads them from `deps` at call time.\n */\nexport type TextLoadStep<C extends Cue = Cue> = (\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n) => void | Promise<void>;\n\n/**\n * The uniform passthrough handed to each {@link TextLoadStep} — the composition triple, the text analog of `StepDeps`.\n * `state`/`context` are the composition signal maps; `config` is the threaded config with the loader's wiring folded in\n * (see {@link textStepWiring} + `createTextTrackSegmentLoaderActor`). Typed loose: composition steps read `state`; base\n * steps read the folded wiring off `config`.\n */\nexport interface TextStepDeps {\n state: AnySlotMap;\n context: AnySlotMap;\n config: object;\n}\n\n/**\n * Base-step view of the loader's wiring, folded into `config` by `createTextTrackSegmentLoaderActor` so base steps read\n * it from the uniform passthrough — present in both composition and standalone use. `config` is loose (`object`), so\n * assert the shape here (mirrors the v/a loader's `stepWiring`). The sink is the structural {@link CueSink}, not the\n * concrete actor.\n */\nexport function textStepWiring<C extends Cue>(\n deps: TextStepDeps\n): { textTracksActor: CueSink<C>; resolveSegment: TextTrackSegmentResolver<C> } {\n return deps.config as { textTracksActor: CueSink<C>; resolveSegment: TextTrackSegmentResolver<C> };\n}\n\n/**\n * Builds the ordered step list, called **once per actor** (mirrors the v/a loader's `MessagePipelines`, but text has a\n * single op type so it's a flat array, not a `Record`). The default ({@link DEFAULT_TEXT_MESSAGE_PIPELINES}) is\n * `resolveCues → dispatchCues`; a non-zero-PTS composition returns a list that inserts a cue-rebase step (see\n * `relocatingTextPipelines`), so the loader stays oblivious to relocation.\n */\nexport type TextMessagePipelines<C extends Cue = Cue> = () => TextLoadStep<C>[];\n\n// ============================================================================\n// BASE STEPS\n// ============================================================================\n\n// Base steps are generic over the cue type `C` (generic arrow consts, not\n// `TextLoadStep<Cue>` values): each touches `C` — `frame.cues: C[]` and the\n// `C`-typed `textStepWiring<C>` — so a `Cue`-typed const wouldn't slot into a\n// `VTTCue` pipeline. A generic function assigns to any `TextLoadStep<C>`.\n\n/** Resolve the op's cues (via the injected host primitive) into the frame. The text analog of `fetchStep`. */\nexport const resolveCuesStep = async <C extends Cue>(\n frame: TextFrame<C>,\n signal: AbortSignal,\n deps: TextStepDeps\n): Promise<void> => {\n const cues = await textStepWiring<C>(deps).resolveSegment(frame.op.segment.url);\n\n if (signal.aborted) return;\n\n frame.cues = cues;\n};\n\n/** Dispatch the frame's cues to the TextTracksActor as `add-cues`. The text analog of `dispatchStep`. */\nexport const dispatchCuesStep = <C extends Cue>(\n frame: TextFrame<C>,\n _signal: AbortSignal,\n deps: TextStepDeps\n): void => {\n const { op } = frame;\n\n textStepWiring<C>(deps).textTracksActor.send({\n type: 'add-cues',\n meta: {\n trackId: op.trackId,\n id: op.segment.id,\n startTime: op.segment.startTime,\n duration: op.segment.duration,\n },\n cues: frame.cues ?? [],\n });\n};\n\n/** Tier 0 default: resolve then dispatch. No relocation vocabulary. */\nexport const DEFAULT_TEXT_MESSAGE_PIPELINES = <C extends Cue>(): TextLoadStep<C>[] => [\n resolveCuesStep,\n dispatchCuesStep,\n];\n"],"mappings":";;;;;;;AAyFA,SAAgB,eACd,MAC8E;CAC9E,OAAO,KAAK;AACd;;AAoBA,MAAa,kBAAkB,OAC7B,OACA,QACA,SACkB;CAClB,MAAM,OAAO,MAAM,eAAkB,IAAI,CAAC,CAAC,eAAe,MAAM,GAAG,QAAQ,GAAG;CAE9E,IAAI,OAAO,SAAS;CAEpB,MAAM,OAAO;AACf;;AAGA,MAAa,oBACX,OACA,SACA,SACS;CACT,MAAM,EAAE,OAAO;CAEf,eAAkB,IAAI,CAAC,CAAC,gBAAgB,KAAK;EAC3C,MAAM;EACN,MAAM;GACJ,SAAS,GAAG;GACZ,IAAI,GAAG,QAAQ;GACf,WAAW,GAAG,QAAQ;GACtB,UAAU,GAAG,QAAQ;EACvB;EACA,MAAM,MAAM,QAAQ,CAAC;CACvB,CAAC;AACH;;AAGA,MAAa,uCAAyE,CACpF,iBACA,gBACF"}
@@ -2,22 +2,16 @@
2
2
  /**
3
3
  * **Per-type config bundles for per-type behavior variants.**
4
4
  *
5
- * Each `*_TYPE_CONFIG` constant names the per-type slot keys that
6
- * per-type-variant setup-shape helpers consume. Variants reference the
7
- * shared constant at their `defineBehavior` setup body rather than
8
- * constructing the config inline, so the per-type identity (which state
9
- * slot, which context slot, which discriminant) lives in one place per
5
+ * Each `*_TYPE_CONFIG` constant names the per-type slot keys that per-type-variant setup-shape helpers consume.
6
+ * Variants reference the shared constant at their `defineBehavior` setup body rather than constructing the config
7
+ * inline, so the per-type identity (which state slot, which context slot, which discriminant) lives in one place per
10
8
  * type.
11
9
  *
12
- * Variants spread their composition-time `config` over the defaults so
13
- * engines can layer composition-supplied additions on top (e.g. a
14
- * custom fetch closure, a non-default segment resolver). Defaults
15
- * first, engine config second.
10
+ * Variants spread their composition-time `config` over the defaults so engines can layer composition-supplied additions
11
+ * on top (e.g. a custom fetch closure, a non-default segment resolver). Defaults first, engine config second.
16
12
  *
17
- * Helpers continue to consume their slice via the existing typed-key
18
- * generics (`<K extends SelectedTrackKey>` etc.); the extra fields on
19
- * the config object (carrying facets other helpers care about) are fine
20
- * under structural typing.
13
+ * Helpers continue to consume their slice via the existing typed-key generics (`<K extends SelectedTrackKey>` etc.);
14
+ * the extra fields on the config object (carrying facets other helpers care about) are fine under structural typing.
21
15
  */
22
16
  /**
23
17
  * Type-identity bundle for video-track-typed behaviors.
@@ -42,11 +36,9 @@ const AUDIO_TYPE_CONFIG = {
42
36
  loaderKey: "audioSegmentLoaderActor"
43
37
  };
44
38
  /**
45
- * Type-identity bundle for text-track-typed behaviors. Text tracks have
46
- * no `SourceBufferActor` (MSE doesn't apply), so this bundle omits
47
- * `actorKey`. The `loaderKey` points at the text-track-segment-loader
48
- * actor (a `MessageActor` with continue-vs-preempt semantics, parallel
49
- * to v/a's `SegmentLoaderActor`).
39
+ * Type-identity bundle for text-track-typed behaviors. Text tracks have no `SourceBufferActor` (MSE doesn't apply), so
40
+ * this bundle omits `actorKey`. The `loaderKey` points at the text-track-segment-loader actor (a `MessageActor` with
41
+ * continue-vs-preempt semantics, parallel to v/a's `SegmentLoaderActor`).
50
42
  *
51
43
  * @see loadTextTrackSegments, setupTextTrackActors
52
44
  */
@@ -1 +1 @@
1
- {"version":3,"file":"track-types.js","names":[],"sources":["../../../../src/playback/primitives/track-types.ts"],"sourcesContent":["/**\n * **Per-type config bundles for per-type behavior variants.**\n *\n * Each `*_TYPE_CONFIG` constant names the per-type slot keys that\n * per-type-variant setup-shape helpers consume. Variants reference the\n * shared constant at their `defineBehavior` setup body rather than\n * constructing the config inline, so the per-type identity (which state\n * slot, which context slot, which discriminant) lives in one place per\n * type.\n *\n * Variants spread their composition-time `config` over the defaults so\n * engines can layer composition-supplied additions on top (e.g. a\n * custom fetch closure, a non-default segment resolver). Defaults\n * first, engine config second.\n *\n * Helpers continue to consume their slice via the existing typed-key\n * generics (`<K extends SelectedTrackKey>` etc.); the extra fields on\n * the config object (carrying facets other helpers care about) are fine\n * under structural typing.\n */\n\n/**\n * Type-identity bundle for video-track-typed behaviors.\n *\n * @see setupVideoBufferActors, loadVideoSegments\n */\nexport const VIDEO_TYPE_CONFIG = {\n type: 'video',\n selectedKey: 'selectedVideoTrackId',\n actorKey: 'videoBufferActor',\n loaderKey: 'videoSegmentLoaderActor',\n} as const;\n\n/**\n * Type-identity bundle for audio-track-typed behaviors.\n *\n * @see setupAudioBufferActors, loadAudioSegments\n */\nexport const AUDIO_TYPE_CONFIG = {\n type: 'audio',\n selectedKey: 'selectedAudioTrackId',\n actorKey: 'audioBufferActor',\n loaderKey: 'audioSegmentLoaderActor',\n} as const;\n\n/**\n * Type-identity bundle for text-track-typed behaviors. Text tracks have\n * no `SourceBufferActor` (MSE doesn't apply), so this bundle omits\n * `actorKey`. The `loaderKey` points at the text-track-segment-loader\n * actor (a `MessageActor` with continue-vs-preempt semantics, parallel\n * to v/a's `SegmentLoaderActor`).\n *\n * @see loadTextTrackSegments, setupTextTrackActors\n */\nexport const TEXT_TYPE_CONFIG = {\n type: 'text',\n selectedKey: 'selectedTextTrackId',\n loaderKey: 'textTrackSegmentLoaderActor',\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aAAa;CACb,UAAU;CACV,WAAW;AACb;;;;;;AAOA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aAAa;CACb,UAAU;CACV,WAAW;AACb;;;;;;;;;;AAWA,MAAa,mBAAmB;CAC9B,MAAM;CACN,aAAa;CACb,WAAW;AACb"}
1
+ {"version":3,"file":"track-types.js","names":[],"sources":["../../../../src/playback/primitives/track-types.ts"],"sourcesContent":["/**\n * **Per-type config bundles for per-type behavior variants.**\n *\n * Each `*_TYPE_CONFIG` constant names the per-type slot keys that per-type-variant setup-shape helpers consume.\n * Variants reference the shared constant at their `defineBehavior` setup body rather than constructing the config\n * inline, so the per-type identity (which state slot, which context slot, which discriminant) lives in one place per\n * type.\n *\n * Variants spread their composition-time `config` over the defaults so engines can layer composition-supplied additions\n * on top (e.g. a custom fetch closure, a non-default segment resolver). Defaults first, engine config second.\n *\n * Helpers continue to consume their slice via the existing typed-key generics (`<K extends SelectedTrackKey>` etc.);\n * the extra fields on the config object (carrying facets other helpers care about) are fine under structural typing.\n */\n\n/**\n * Type-identity bundle for video-track-typed behaviors.\n *\n * @see setupVideoBufferActors, loadVideoSegments\n */\nexport const VIDEO_TYPE_CONFIG = {\n type: 'video',\n selectedKey: 'selectedVideoTrackId',\n actorKey: 'videoBufferActor',\n loaderKey: 'videoSegmentLoaderActor',\n} as const;\n\n/**\n * Type-identity bundle for audio-track-typed behaviors.\n *\n * @see setupAudioBufferActors, loadAudioSegments\n */\nexport const AUDIO_TYPE_CONFIG = {\n type: 'audio',\n selectedKey: 'selectedAudioTrackId',\n actorKey: 'audioBufferActor',\n loaderKey: 'audioSegmentLoaderActor',\n} as const;\n\n/**\n * Type-identity bundle for text-track-typed behaviors. Text tracks have no `SourceBufferActor` (MSE doesn't apply), so\n * this bundle omits `actorKey`. The `loaderKey` points at the text-track-segment-loader actor (a `MessageActor` with\n * continue-vs-preempt semantics, parallel to v/a's `SegmentLoaderActor`).\n *\n * @see loadTextTrackSegments, setupTextTrackActors\n */\nexport const TEXT_TYPE_CONFIG = {\n type: 'text',\n selectedKey: 'selectedTextTrackId',\n loaderKey: 'textTrackSegmentLoaderActor',\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aAAa;CACb,UAAU;CACV,WAAW;AACb;;;;;;AAOA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aAAa;CACb,UAAU;CACV,WAAW;AACb;;;;;;;;AASA,MAAa,mBAAmB;CAC9B,MAAM;CACN,aAAa;CACb,WAAW;AACb"}
@@ -1,8 +1,8 @@
1
1
  import { Machine, MachineSnapshot } from "../machine.js";
2
2
  //#region src/core/actors/actor.d.ts
3
3
  /**
4
- * Complete actor snapshot: finite state + non-finite context.
5
- * Extends `MachineSnapshot` with context — the non-finite data managed by the actor.
4
+ * Complete actor snapshot: finite state + non-finite context. Extends `MachineSnapshot` with context — the non-finite
5
+ * data managed by the actor.
6
6
  */
7
7
  interface ActorSnapshot<State extends string, Context extends object> extends MachineSnapshot<State> {
8
8
  context: Context;
@@ -12,8 +12,8 @@ interface SignalActor<State extends string, Context extends object> extends Mach
12
12
  /**
13
13
  * A message-driven actor with no reactive snapshot.
14
14
  *
15
- * Use for actors that coordinate async work but have no state that external
16
- * consumers need to observe. Analogous to XState's `fromCallback`.
15
+ * Use for actors that coordinate async work but have no state that external consumers need to observe. Analogous to
16
+ * XState's `fromCallback`.
17
17
  */
18
18
  interface CallbackActor<Message extends {
19
19
  type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"actor.d.ts","names":[],"sources":["../../../../src/core/actors/actor.ts"],"mappings":";;;;;;UAeiB,cAAc,sBAAsB,gCAAgC,gBAAgB;EACnG,SAAS;;;UAIM,YAAY,sBAAsB,gCACzC,QAAQ,cAAc,OAAO;;;;;;;UAQtB,cAAc;EAAkB;;EAC/C,KAAK,SAAS;EACd"}
1
+ {"version":3,"file":"actor.d.ts","names":[],"sources":["../../../../src/core/actors/actor.ts"],"mappings":";;;;;;UAciB,cAAc,sBAAsB,gCAAgC,gBAAgB;EACnG,SAAS;;;UAIM,YAAY,sBAAsB,gCAAgC,QACjF,cAAc,OAAO;;;;;;;UASN,cAAc;EAAkB;;EAC/C,KAAK,SAAS;EACd"}
@@ -1,9 +1,7 @@
1
1
  import { TaskLike } from "../tasks/task.js";
2
2
  import { SignalActor } from "./actor.js";
3
3
  //#region src/core/actors/create-machine-actor.d.ts
4
- /**
5
- * Minimal interface for any runner that can be used with createMachineActor.
6
- */
4
+ /** Minimal interface for any runner that can be used with createMachineActor. */
7
5
  interface RunnerLike {
8
6
  schedule<Value = void, Err = unknown>(task: TaskLike<Value, Err>): Promise<Value>;
9
7
  abortAll(): void;
@@ -11,8 +9,7 @@ interface RunnerLike {
11
9
  whenSettled(callback: () => void): void;
12
10
  }
13
11
  /**
14
- * Context passed to message handlers.
15
- * `runner` is present and typed as the exact runner instance only when the
12
+ * Context passed to message handlers. `runner` is present and typed as the exact runner instance only when the
16
13
  * definition includes a runner factory.
17
14
  */
18
15
  type HandlerContext<UserState extends string, Context extends object, RunnerFactory extends (() => RunnerLike) | undefined> = {
@@ -20,9 +17,8 @@ type HandlerContext<UserState extends string, Context extends object, RunnerFact
20
17
  /** Context snapshot captured at dispatch time. Stale after any `setContext` call. */
21
18
  context: Context;
22
19
  /**
23
- * Live untracked read of the current context. Use in async task closures that
24
- * execute after the handler returns — e.g. `getCtx: getContext` passed to tasks
25
- * scheduled on the runner, so each task reads the context committed by the
20
+ * Live untracked read of the current context. Use in async task closures that execute after the handler returns —
21
+ * e.g. `getCtx: getContext` passed to tasks scheduled on the runner, so each task reads the context committed by the
26
22
  * previous task rather than the stale snapshot from dispatch time.
27
23
  */
28
24
  getContext: () => Context;
@@ -30,17 +26,14 @@ type HandlerContext<UserState extends string, Context extends object, RunnerFact
30
26
  } & (RunnerFactory extends (() => infer R) ? {
31
27
  runner: R;
32
28
  } : object);
33
- /**
34
- * Definition for a single user-defined state.
35
- */
29
+ /** Definition for a single user-defined state. */
36
30
  type ActorStateDefinition<UserState extends string, Context extends object, Message extends {
37
31
  type: string;
38
32
  }, RunnerFactory extends (() => RunnerLike) | undefined> = {
39
33
  /**
40
- * When the actor's runner settles while in this state, automatically
41
- * transition to this state. The framework owns the generation-token logic —
42
- * re-registering after each `runner.schedule()` call so that
43
- * `abortAll()` + reschedule correctly supersedes stale callbacks.
34
+ * When the actor's runner settles while in this state, automatically transition to this state. The framework owns the
35
+ * generation-token logic re-registering after each `runner.schedule()` call so that `abortAll()` + reschedule
36
+ * correctly supersedes stale callbacks.
44
37
  */
45
38
  onSettled?: UserState;
46
39
  /** Message handlers active in this state. Messages with no handler are silently dropped. */
@@ -51,18 +44,18 @@ type ActorStateDefinition<UserState extends string, Context extends object, Mess
51
44
  /**
52
45
  * Full actor definition passed to `createMachineActor`.
53
46
  *
54
- * `UserState` is the set of domain-meaningful states. `'destroyed'` is always
55
- * added by the framework as the implicit terminal state — do not include it here.
47
+ * `UserState` is the set of domain-meaningful states. `'destroyed'` is always added by the framework as the implicit
48
+ * terminal state — do not include it here.
56
49
  */
57
50
  type ActorDefinition<UserState extends string, Context extends object, Message extends {
58
51
  type: string;
59
52
  }, RunnerFactory extends (() => RunnerLike) | undefined = undefined> = {
60
53
  /**
61
- * Runner factory — called once at `createMachineActor()` time.
62
- * The runner lives for the full actor lifetime and is destroyed with it.
54
+ * Runner factory — called once at `createMachineActor()` time. The runner lives for the full actor lifetime and is
55
+ * destroyed with it.
63
56
  *
64
57
  * @example
65
- * runner: () => new SerialRunner()
58
+ * runner: () => new SerialRunner();
66
59
  */
67
60
  runner?: RunnerFactory;
68
61
  /** Initial state. */
@@ -70,8 +63,8 @@ type ActorDefinition<UserState extends string, Context extends object, Message e
70
63
  /** Initial context. */
71
64
  context: Context;
72
65
  /**
73
- * Per-state definitions. States with no definition silently drop all messages.
74
- * All user-defined states must appear as keys in the `UserState` union.
66
+ * Per-state definitions. States with no definition silently drop all messages. All user-defined states must appear as
67
+ * keys in the `UserState` union.
75
68
  */
76
69
  states: Partial<Record<UserState, ActorStateDefinition<UserState, Context, Message, RunnerFactory>>>;
77
70
  };
@@ -84,41 +77,39 @@ interface MessageActor<State extends string, Context extends object, Message ext
84
77
  /**
85
78
  * Creates a message-driven actor from a declarative definition.
86
79
  *
87
- * The actor owns a reactive snapshot signal (state + context), an optional
88
- * runner, and dispatches incoming messages to per-state handlers. `'destroyed'`
89
- * is always the implicit terminal state — `destroy()` transitions there
80
+ * The actor owns a reactive snapshot signal (state + context), an optional runner, and dispatches incoming messages to
81
+ * per-state handlers. `'destroyed'` is always the implicit terminal state — `destroy()` transitions there
90
82
  * unconditionally and all subsequent `send()` calls are no-ops.
91
83
  *
92
- * When a state declares `onSettled`, the framework calls `runner.whenSettled()`
93
- * after the handler returns. The runner owns the generation-token logic if
94
- * new tasks are scheduled before the current batch settles, the callback is
84
+ * When a state declares `onSettled`, the framework calls `runner.whenSettled()` after the handler returns. The runner
85
+ * owns the generation-token logic if new tasks are scheduled before the current batch settles, the callback is
95
86
  * automatically superseded.
96
87
  *
97
88
  * @example
98
- * const actor = createMachineActor({
89
+ * const actor = createMachineActor({
99
90
  * runner: () => new SerialRunner(),
100
91
  * initial: 'idle',
101
92
  * context: {},
102
93
  * states: {
103
- * idle: {
104
- * on: {
105
- * load: (msg, { transition, runner }) => {
106
- * segments.forEach(s => runner.schedule(new Task(...)));
107
- * transition('loading');
108
- * }
109
- * }
110
- * },
111
- * loading: {
112
- * onSettled: 'idle',
113
- * on: {
114
- * load: (msg, { runner }) => {
115
- * runner.abortAll();
116
- * segments.forEach(s => runner.schedule(new Task(...)));
117
- * }
118
- * }
119
- * }
94
+ * idle: {
95
+ * on: {
96
+ * load: (msg, { transition, runner }) => {
97
+ * segments.forEach(s => runner.schedule(new Task(...)));
98
+ * transition('loading');
99
+ * }
100
+ * }
101
+ * },
102
+ * loading: {
103
+ * onSettled: 'idle',
104
+ * on: {
105
+ * load: (msg, { runner }) => {
106
+ * runner.abortAll();
107
+ * segments.forEach(s => runner.schedule(new Task(...)));
108
+ * }
109
+ * }
110
+ * }
120
111
  * }
121
- * });
112
+ * });
122
113
  */
123
114
  declare function createMachineActor<UserState extends string, Context extends object, Message extends {
124
115
  type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-machine-actor.d.ts","names":[],"sources":["../../../../src/core/actors/create-machine-actor.ts"],"mappings":";;;;;;UAYiB;EACf,SAAS,cAAc,eAAe,MAAM,SAAS,OAAO,OAAO,QAAQ;EAC3E;EACA;EACA,YAAY;;;;;;;KAYF,eACV,0BACA,wBACA,6BAA6B;EAE7B,aAAa,IAAI;;EAEjB,SAAS;;;;;;;EAOT,kBAAkB;EAClB,aAAa,MAAM;KAChB,mCAAkC;EAAM,QAAQ;;;;;KAKzC,qBACV,0BACA,wBACA;EAAkB;GAClB,6BAA6B;;;;;;;EAQ7B,YAAY;;EAEZ,QACG,KAAK,WAAW,cACf,SAAS,QAAQ;IAAW,MAAM;MAClC,KAAK,eAAe,WAAW,SAAS;;;;;;;;KAWlC,gBACV,0BACA,wBACA;EAAkB;GAClB,6BAA6B;;;;;;;;EAS7B,SAAS;;EAET,SAAS;;EAET,SAAS;;;;;EAKT,QAAQ,QAAQ,OAAO,WAAW,qBAAqB,WAAW,SAAS,SAAS;;;UAQrE,aAAa,sBAAsB,wBAAwB;EAAkB;WACpF,YAAY,OAAO;EAC3B,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8CA,mBACd,0BACA,wBACA;EAAkB;GAClB,6BAA6B,qCAE7B,KAAK,gBAAgB,WAAW,SAAS,SAAS,iBACjD,aAAa,yBAAyB,SAAS"}
1
+ {"version":3,"file":"create-machine-actor.d.ts","names":[],"sources":["../../../../src/core/actors/create-machine-actor.ts"],"mappings":";;;;UAUiB;EACf,SAAS,cAAc,eAAe,MAAM,SAAS,OAAO,OAAO,QAAQ;EAC3E;EACA;EACA,YAAY;;;;;;KAWF,eACV,0BACA,wBACA,6BAA6B;EAE7B,aAAa,IAAI;;EAEjB,SAAS;;;;;;EAMT,kBAAkB;EAClB,aAAa,MAAM;KAChB,mCAAkC;EAAM,QAAQ;;;KAGzC,qBACV,0BACA,wBACA;EAAkB;GAClB,6BAA6B;;;;;;EAO7B,YAAY;;EAEZ,QACG,KAAK,WAAW,cACf,SAAS,QAAQ;IAAW,MAAM;MAClC,KAAK,eAAe,WAAW,SAAS;;;;;;;;KAWlC,gBACV,0BACA,wBACA;EAAkB;GAClB,6BAA6B;;;;;;;;EAS7B,SAAS;;EAET,SAAS;;EAET,SAAS;;;;;EAKT,QAAQ,QAAQ,OAAO,WAAW,qBAAqB,WAAW,SAAS,SAAS;;;UAQrE,aACf,sBACA,wBACA;EAAkB;WACV,YAAY,OAAO;EAC3B,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4CA,mBACd,0BACA,wBACA;EAAkB;GAClB,6BAA6B,qCAE7B,KAAK,gBAAgB,WAAW,SAAS,SAAS,iBACjD,aAAa,yBAAyB,SAAS"}
@@ -4,41 +4,39 @@ import { createMachineCore } from "../machine.js";
4
4
  /**
5
5
  * Creates a message-driven actor from a declarative definition.
6
6
  *
7
- * The actor owns a reactive snapshot signal (state + context), an optional
8
- * runner, and dispatches incoming messages to per-state handlers. `'destroyed'`
9
- * is always the implicit terminal state — `destroy()` transitions there
7
+ * The actor owns a reactive snapshot signal (state + context), an optional runner, and dispatches incoming messages to
8
+ * per-state handlers. `'destroyed'` is always the implicit terminal state — `destroy()` transitions there
10
9
  * unconditionally and all subsequent `send()` calls are no-ops.
11
10
  *
12
- * When a state declares `onSettled`, the framework calls `runner.whenSettled()`
13
- * after the handler returns. The runner owns the generation-token logic if
14
- * new tasks are scheduled before the current batch settles, the callback is
11
+ * When a state declares `onSettled`, the framework calls `runner.whenSettled()` after the handler returns. The runner
12
+ * owns the generation-token logic if new tasks are scheduled before the current batch settles, the callback is
15
13
  * automatically superseded.
16
14
  *
17
15
  * @example
18
- * const actor = createMachineActor({
16
+ * const actor = createMachineActor({
19
17
  * runner: () => new SerialRunner(),
20
18
  * initial: 'idle',
21
19
  * context: {},
22
20
  * states: {
23
- * idle: {
24
- * on: {
25
- * load: (msg, { transition, runner }) => {
26
- * segments.forEach(s => runner.schedule(new Task(...)));
27
- * transition('loading');
28
- * }
29
- * }
30
- * },
31
- * loading: {
32
- * onSettled: 'idle',
33
- * on: {
34
- * load: (msg, { runner }) => {
35
- * runner.abortAll();
36
- * segments.forEach(s => runner.schedule(new Task(...)));
37
- * }
38
- * }
39
- * }
21
+ * idle: {
22
+ * on: {
23
+ * load: (msg, { transition, runner }) => {
24
+ * segments.forEach(s => runner.schedule(new Task(...)));
25
+ * transition('loading');
40
26
  * }
41
- * });
27
+ * }
28
+ * },
29
+ * loading: {
30
+ * onSettled: 'idle',
31
+ * on: {
32
+ * load: (msg, { runner }) => {
33
+ * runner.abortAll();
34
+ * segments.forEach(s => runner.schedule(new Task(...)));
35
+ * }
36
+ * }
37
+ * }
38
+ * }
39
+ * });
42
40
  */
43
41
  function createMachineActor(def) {
44
42
  const runner = def.runner?.();
@@ -1 +1 @@
1
- {"version":3,"file":"create-machine-actor.js","names":[],"sources":["../../../../src/core/actors/create-machine-actor.ts"],"sourcesContent":["import { createMachineCore } from '../machine';\nimport { untrack, update } from '../signals/primitives';\nimport type { TaskLike } from '../tasks/task';\nimport type { ActorSnapshot, SignalActor } from './actor';\n\n// =============================================================================\n// Runner interfaces\n// =============================================================================\n\n/**\n * Minimal interface for any runner that can be used with createMachineActor.\n */\nexport interface RunnerLike {\n schedule<Value = void, Err = unknown>(task: TaskLike<Value, Err>): Promise<Value>;\n abortAll(): void;\n destroy(): void;\n whenSettled(callback: () => void): void;\n}\n\n// =============================================================================\n// Definition types\n// =============================================================================\n\n/**\n * Context passed to message handlers.\n * `runner` is present and typed as the exact runner instance only when the\n * definition includes a runner factory.\n */\nexport type HandlerContext<\n UserState extends string,\n Context extends object,\n RunnerFactory extends (() => RunnerLike) | undefined,\n> = {\n transition: (to: UserState) => void;\n /** Context snapshot captured at dispatch time. Stale after any `setContext` call. */\n context: Context;\n /**\n * Live untracked read of the current context. Use in async task closures that\n * execute after the handler returns e.g. `getCtx: getContext` passed to tasks\n * scheduled on the runner, so each task reads the context committed by the\n * previous task rather than the stale snapshot from dispatch time.\n */\n getContext: () => Context;\n setContext: (next: Context) => void;\n} & (RunnerFactory extends () => infer R ? { runner: R } : object);\n\n/**\n * Definition for a single user-defined state.\n */\nexport type ActorStateDefinition<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined,\n> = {\n /**\n * When the actor's runner settles while in this state, automatically\n * transition to this state. The framework owns the generation-token logic —\n * re-registering after each `runner.schedule()` call so that\n * `abortAll()` + reschedule correctly supersedes stale callbacks.\n */\n onSettled?: UserState;\n /** Message handlers active in this state. Messages with no handler are silently dropped. */\n on?: {\n [M in Message as M['type']]?: (\n message: Extract<Message, { type: M['type'] }>,\n ctx: HandlerContext<UserState, Context, RunnerFactory>\n ) => void;\n };\n};\n\n/**\n * Full actor definition passed to `createMachineActor`.\n *\n * `UserState` is the set of domain-meaningful states. `'destroyed'` is always\n * added by the framework as the implicit terminal state — do not include it here.\n */\nexport type ActorDefinition<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined = undefined,\n> = {\n /**\n * Runner factory — called once at `createMachineActor()` time.\n * The runner lives for the full actor lifetime and is destroyed with it.\n *\n * @example\n * runner: () => new SerialRunner()\n */\n runner?: RunnerFactory;\n /** Initial state. */\n initial: UserState;\n /** Initial context. */\n context: Context;\n /**\n * Per-state definitions. States with no definition silently drop all messages.\n * All user-defined states must appear as keys in the `UserState` union.\n */\n states: Partial<Record<UserState, ActorStateDefinition<UserState, Context, Message, RunnerFactory>>>;\n};\n\n// =============================================================================\n// Live actor interface\n// =============================================================================\n\n/** Live actor instance returned by `createMachineActor`. */\nexport interface MessageActor<State extends string, Context extends object, Message extends { type: string }>\n extends SignalActor<State, Context> {\n send(message: Message): void;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Creates a message-driven actor from a declarative definition.\n *\n * The actor owns a reactive snapshot signal (state + context), an optional\n * runner, and dispatches incoming messages to per-state handlers. `'destroyed'`\n * is always the implicit terminal state — `destroy()` transitions there\n * unconditionally and all subsequent `send()` calls are no-ops.\n *\n * When a state declares `onSettled`, the framework calls `runner.whenSettled()`\n * after the handler returns. The runner owns the generation-token logic — if\n * new tasks are scheduled before the current batch settles, the callback is\n * automatically superseded.\n *\n * @example\n * const actor = createMachineActor({\n * runner: () => new SerialRunner(),\n * initial: 'idle',\n * context: {},\n * states: {\n * idle: {\n * on: {\n * load: (msg, { transition, runner }) => {\n * segments.forEach(s => runner.schedule(new Task(...)));\n * transition('loading');\n * }\n * }\n * },\n * loading: {\n * onSettled: 'idle',\n * on: {\n * load: (msg, { runner }) => {\n * runner.abortAll();\n * segments.forEach(s => runner.schedule(new Task(...)));\n * }\n * }\n * }\n * }\n * });\n */\nexport function createMachineActor<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined = undefined,\n>(\n def: ActorDefinition<UserState, Context, Message, RunnerFactory>\n): MessageActor<UserState | 'destroyed', Context, Message> {\n type FullState = UserState | 'destroyed';\n\n const runner = def.runner?.() as RunnerLike | undefined;\n const { snapshotSignal, getState, transition } = createMachineCore<FullState, ActorSnapshot<FullState, Context>>({\n value: def.initial as FullState,\n context: def.context,\n });\n\n const getContext = (): Context => untrack(() => snapshotSignal.get().context);\n\n const setContext = (context: Context): void => {\n update(snapshotSignal, { context });\n };\n\n return {\n get snapshot() {\n return snapshotSignal;\n },\n\n send(message: Message): void {\n const state = getState();\n if (state === 'destroyed') return;\n const stateDef = def.states[state as UserState];\n const handler = stateDef?.on?.[message.type as keyof typeof stateDef.on] as\n | ((msg: Message, ctx: HandlerContext<UserState, Context, RunnerFactory>) => void)\n | undefined;\n if (!handler) return;\n handler(message, {\n context: getContext(),\n getContext,\n transition: (to: UserState) => transition(to as FullState),\n setContext,\n ...(runner ? { runner } : {}),\n } as HandlerContext<UserState, Context, RunnerFactory>);\n // Register onSettled after the handler so we read the post-transition state.\n const newState = getState();\n if (newState !== 'destroyed') {\n const newStateDef = def.states[newState as UserState];\n if (newStateDef?.onSettled && runner) {\n const targetState = newStateDef.onSettled as FullState;\n runner.whenSettled(() => {\n if (getState() !== newState) return;\n transition(targetState);\n });\n }\n }\n },\n\n destroy(): void {\n if (getState() === 'destroyed') return;\n runner?.destroy();\n transition('destroyed');\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,SAAgB,mBAMd,KACyD;CAGzD,MAAM,SAAS,IAAI,SAAS;CAC5B,MAAM,EAAE,gBAAgB,UAAU,eAAe,kBAAgE;EAC/G,OAAO,IAAI;EACX,SAAS,IAAI;CACf,CAAC;CAED,MAAM,mBAA4B,cAAc,eAAe,IAAI,CAAC,CAAC,OAAO;CAE5E,MAAM,cAAc,YAA2B;EAC7C,OAAO,gBAAgB,EAAE,QAAQ,CAAC;CACpC;CAEA,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EAEA,KAAK,SAAwB;GAC3B,MAAM,QAAQ,SAAS;GACvB,IAAI,UAAU,aAAa;GAE3B,MAAM,UADW,IAAI,OAAO,MACJ,EAAE,KAAK,QAAQ;GAGvC,IAAI,CAAC,SAAS;GACd,QAAQ,SAAS;IACf,SAAS,WAAW;IACpB;IACA,aAAa,OAAkB,WAAW,EAAe;IACzD;IACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;GAC7B,CAAsD;GAEtD,MAAM,WAAW,SAAS;GAC1B,IAAI,aAAa,aAAa;IAC5B,MAAM,cAAc,IAAI,OAAO;IAC/B,IAAI,aAAa,aAAa,QAAQ;KACpC,MAAM,cAAc,YAAY;KAChC,OAAO,kBAAkB;MACvB,IAAI,SAAS,MAAM,UAAU;MAC7B,WAAW,WAAW;KACxB,CAAC;IACH;GACF;EACF;EAEA,UAAgB;GACd,IAAI,SAAS,MAAM,aAAa;GAChC,QAAQ,QAAQ;GAChB,WAAW,WAAW;EACxB;CACF;AACF"}
1
+ {"version":3,"file":"create-machine-actor.js","names":[],"sources":["../../../../src/core/actors/create-machine-actor.ts"],"sourcesContent":["import { createMachineCore } from '../machine';\nimport { untrack, update } from '../signals/primitives';\nimport type { TaskLike } from '../tasks/task';\nimport type { ActorSnapshot, SignalActor } from './actor';\n\n// =============================================================================\n// Runner interfaces\n// =============================================================================\n\n/** Minimal interface for any runner that can be used with createMachineActor. */\nexport interface RunnerLike {\n schedule<Value = void, Err = unknown>(task: TaskLike<Value, Err>): Promise<Value>;\n abortAll(): void;\n destroy(): void;\n whenSettled(callback: () => void): void;\n}\n\n// =============================================================================\n// Definition types\n// =============================================================================\n\n/**\n * Context passed to message handlers. `runner` is present and typed as the exact runner instance only when the\n * definition includes a runner factory.\n */\nexport type HandlerContext<\n UserState extends string,\n Context extends object,\n RunnerFactory extends (() => RunnerLike) | undefined,\n> = {\n transition: (to: UserState) => void;\n /** Context snapshot captured at dispatch time. Stale after any `setContext` call. */\n context: Context;\n /**\n * Live untracked read of the current context. Use in async task closures that execute after the handler returns —\n * e.g. `getCtx: getContext` passed to tasks scheduled on the runner, so each task reads the context committed by the\n * previous task rather than the stale snapshot from dispatch time.\n */\n getContext: () => Context;\n setContext: (next: Context) => void;\n} & (RunnerFactory extends () => infer R ? { runner: R } : object);\n\n/** Definition for a single user-defined state. */\nexport type ActorStateDefinition<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined,\n> = {\n /**\n * When the actor's runner settles while in this state, automatically transition to this state. The framework owns the\n * generation-token logic re-registering after each `runner.schedule()` call so that `abortAll()` + reschedule\n * correctly supersedes stale callbacks.\n */\n onSettled?: UserState;\n /** Message handlers active in this state. Messages with no handler are silently dropped. */\n on?: {\n [M in Message as M['type']]?: (\n message: Extract<Message, { type: M['type'] }>,\n ctx: HandlerContext<UserState, Context, RunnerFactory>\n ) => void;\n };\n};\n\n/**\n * Full actor definition passed to `createMachineActor`.\n *\n * `UserState` is the set of domain-meaningful states. `'destroyed'` is always added by the framework as the implicit\n * terminal state — do not include it here.\n */\nexport type ActorDefinition<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined = undefined,\n> = {\n /**\n * Runner factory — called once at `createMachineActor()` time. The runner lives for the full actor lifetime and is\n * destroyed with it.\n *\n * @example\n * runner: () => new SerialRunner();\n */\n runner?: RunnerFactory;\n /** Initial state. */\n initial: UserState;\n /** Initial context. */\n context: Context;\n /**\n * Per-state definitions. States with no definition silently drop all messages. All user-defined states must appear as\n * keys in the `UserState` union.\n */\n states: Partial<Record<UserState, ActorStateDefinition<UserState, Context, Message, RunnerFactory>>>;\n};\n\n// =============================================================================\n// Live actor interface\n// =============================================================================\n\n/** Live actor instance returned by `createMachineActor`. */\nexport interface MessageActor<\n State extends string,\n Context extends object,\n Message extends { type: string },\n> extends SignalActor<State, Context> {\n send(message: Message): void;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Creates a message-driven actor from a declarative definition.\n *\n * The actor owns a reactive snapshot signal (state + context), an optional runner, and dispatches incoming messages to\n * per-state handlers. `'destroyed'` is always the implicit terminal state — `destroy()` transitions there\n * unconditionally and all subsequent `send()` calls are no-ops.\n *\n * When a state declares `onSettled`, the framework calls `runner.whenSettled()` after the handler returns. The runner\n * owns the generation-token logic — if new tasks are scheduled before the current batch settles, the callback is\n * automatically superseded.\n *\n * @example\n * const actor = createMachineActor({\n * runner: () => new SerialRunner(),\n * initial: 'idle',\n * context: {},\n * states: {\n * idle: {\n * on: {\n * load: (msg, { transition, runner }) => {\n * segments.forEach(s => runner.schedule(new Task(...)));\n * transition('loading');\n * }\n * }\n * },\n * loading: {\n * onSettled: 'idle',\n * on: {\n * load: (msg, { runner }) => {\n * runner.abortAll();\n * segments.forEach(s => runner.schedule(new Task(...)));\n * }\n * }\n * }\n * }\n * });\n */\nexport function createMachineActor<\n UserState extends string,\n Context extends object,\n Message extends { type: string },\n RunnerFactory extends (() => RunnerLike) | undefined = undefined,\n>(\n def: ActorDefinition<UserState, Context, Message, RunnerFactory>\n): MessageActor<UserState | 'destroyed', Context, Message> {\n type FullState = UserState | 'destroyed';\n\n const runner = def.runner?.() as RunnerLike | undefined;\n const { snapshotSignal, getState, transition } = createMachineCore<FullState, ActorSnapshot<FullState, Context>>({\n value: def.initial as FullState,\n context: def.context,\n });\n\n const getContext = (): Context => untrack(() => snapshotSignal.get().context);\n\n const setContext = (context: Context): void => {\n update(snapshotSignal, { context });\n };\n\n return {\n get snapshot() {\n return snapshotSignal;\n },\n\n send(message: Message): void {\n const state = getState();\n if (state === 'destroyed') return;\n\n const stateDef = def.states[state as UserState];\n const handler = stateDef?.on?.[message.type as keyof typeof stateDef.on] as\n | ((msg: Message, ctx: HandlerContext<UserState, Context, RunnerFactory>) => void)\n | undefined;\n if (!handler) return;\n\n handler(message, {\n context: getContext(),\n getContext,\n transition: (to: UserState) => transition(to as FullState),\n setContext,\n ...(runner ? { runner } : {}),\n } as HandlerContext<UserState, Context, RunnerFactory>);\n // Register onSettled after the handler so we read the post-transition state.\n const newState = getState();\n\n if (newState !== 'destroyed') {\n const newStateDef = def.states[newState as UserState];\n\n if (newStateDef?.onSettled && runner) {\n const targetState = newStateDef.onSettled as FullState;\n\n runner.whenSettled(() => {\n if (getState() !== newState) return;\n\n transition(targetState);\n });\n }\n }\n },\n\n destroy(): void {\n if (getState() === 'destroyed') return;\n\n runner?.destroy();\n transition('destroyed');\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJA,SAAgB,mBAMd,KACyD;CAGzD,MAAM,SAAS,IAAI,SAAS;CAC5B,MAAM,EAAE,gBAAgB,UAAU,eAAe,kBAAgE;EAC/G,OAAO,IAAI;EACX,SAAS,IAAI;CACf,CAAC;CAED,MAAM,mBAA4B,cAAc,eAAe,IAAI,CAAC,CAAC,OAAO;CAE5E,MAAM,cAAc,YAA2B;EAC7C,OAAO,gBAAgB,EAAE,QAAQ,CAAC;CACpC;CAEA,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EAEA,KAAK,SAAwB;GAC3B,MAAM,QAAQ,SAAS;GACvB,IAAI,UAAU,aAAa;GAG3B,MAAM,UADW,IAAI,OAAO,MACJ,EAAE,KAAK,QAAQ;GAGvC,IAAI,CAAC,SAAS;GAEd,QAAQ,SAAS;IACf,SAAS,WAAW;IACpB;IACA,aAAa,OAAkB,WAAW,EAAe;IACzD;IACA,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;GAC7B,CAAsD;GAEtD,MAAM,WAAW,SAAS;GAE1B,IAAI,aAAa,aAAa;IAC5B,MAAM,cAAc,IAAI,OAAO;IAE/B,IAAI,aAAa,aAAa,QAAQ;KACpC,MAAM,cAAc,YAAY;KAEhC,OAAO,kBAAkB;MACvB,IAAI,SAAS,MAAM,UAAU;MAE7B,WAAW,WAAW;KACxB,CAAC;IACH;GACF;EACF;EAEA,UAAgB;GACd,IAAI,SAAS,MAAM,aAAa;GAEhC,QAAQ,QAAQ;GAChB,WAAW,WAAW;EACxB;CACF;AACF"}
@@ -4,13 +4,11 @@ import { Machine } from "../machine.js";
4
4
  /**
5
5
  * A reducer-shaped actor: `(context, message) => context`.
6
6
  *
7
- * No finite states — the snapshot carries `value: 'active' | 'destroyed'`
8
- * as a universal lifecycle marker rather than domain state. The interesting
9
- * state is entirely in the context, which is reactive via `snapshot`.
7
+ * No finite states — the snapshot carries `value: 'active' | 'destroyed'` as a universal lifecycle marker rather than
8
+ * domain state. The interesting state is entirely in the context, which is reactive via `snapshot`.
10
9
  *
11
- * Use this when the actor has context that needs to be reactive but no
12
- * meaningful state machine (e.g., a message-driven model with DOM side
13
- * effects). For actors that need per-state behavior, use `createMachineActor`.
10
+ * Use this when the actor has context that needs to be reactive but no meaningful state machine (e.g., a message-driven
11
+ * model with DOM side effects). For actors that need per-state behavior, use `createMachineActor`.
14
12
  */
15
13
  interface TransitionActor<Context extends object, Message extends {
16
14
  type: string;
@@ -20,18 +18,16 @@ interface TransitionActor<Context extends object, Message extends {
20
18
  /**
21
19
  * Creates a reducer-shaped actor from an initial context and a reducer function.
22
20
  *
23
- * The reducer receives the current context and a message and returns the next
24
- * context. Returning the same reference (by identity) skips the signal update
25
- * so early-returning `context` unchanged is both the no-op and the optimization.
21
+ * The reducer receives the current context and a message and returns the next context. Returning the same reference (by
22
+ * identity) skips the signal update so early-returning `context` unchanged is both the no-op and the optimization.
26
23
  *
27
- * Side effects (e.g. DOM mutations) may be performed inside the reducer.
28
- * They run synchronously before the signal is updated.
24
+ * Side effects (e.g. DOM mutations) may be performed inside the reducer. They run synchronously before the signal is
25
+ * updated.
29
26
  *
30
27
  * @example
31
- * const actor = createTransitionActor(
32
- * { count: 0 },
33
- * (context, message: { type: 'increment' }) => ({ count: context.count + 1 })
34
- * );
28
+ * const actor = createTransitionActor({ count: 0 }, (context, message: { type: 'increment' }) => ({
29
+ * count: context.count + 1,
30
+ * }));
35
31
  */
36
32
  declare function createTransitionActor<Context extends object, Message extends {
37
33
  type: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-transition-actor.d.ts","names":[],"sources":["../../../../src/core/actors/create-transition-actor.ts"],"mappings":";;;;;;;;;;;;;;UAoBiB,gBAAgB,wBAAwB;EAAkB;WACjE,QAAQ,sCAAsC;EACtD,KAAK,SAAS;;;;;;;;;;;;;;;;;;iBAuBA,sBAAsB,wBAAwB;EAAkB;GAC9E,gBAAgB,SAChB,UAAU,SAAS,SAAS,SAAS,YAAY,UAChD,gBAAgB,SAAS"}
1
+ {"version":3,"file":"create-transition-actor.d.ts","names":[],"sources":["../../../../src/core/actors/create-transition-actor.ts"],"mappings":";;;;;;;;;;;;UAkBiB,gBAAgB,wBAAwB;EAAkB;WAAwB,QACjG,sCAAsC;EAEtC,KAAK,SAAS;;;;;;;;;;;;;;;;iBAqBA,sBAAsB,wBAAwB;EAAkB;GAC9E,gBAAgB,SAChB,UAAU,SAAS,SAAS,SAAS,YAAY,UAChD,gBAAgB,SAAS"}
@@ -4,18 +4,16 @@ import { createMachineCore } from "../machine.js";
4
4
  /**
5
5
  * Creates a reducer-shaped actor from an initial context and a reducer function.
6
6
  *
7
- * The reducer receives the current context and a message and returns the next
8
- * context. Returning the same reference (by identity) skips the signal update
9
- * so early-returning `context` unchanged is both the no-op and the optimization.
7
+ * The reducer receives the current context and a message and returns the next context. Returning the same reference (by
8
+ * identity) skips the signal update so early-returning `context` unchanged is both the no-op and the optimization.
10
9
  *
11
- * Side effects (e.g. DOM mutations) may be performed inside the reducer.
12
- * They run synchronously before the signal is updated.
10
+ * Side effects (e.g. DOM mutations) may be performed inside the reducer. They run synchronously before the signal is
11
+ * updated.
13
12
  *
14
13
  * @example
15
- * const actor = createTransitionActor(
16
- * { count: 0 },
17
- * (context, message: { type: 'increment' }) => ({ count: context.count + 1 })
18
- * );
14
+ * const actor = createTransitionActor({ count: 0 }, (context, message: { type: 'increment' }) => ({
15
+ * count: context.count + 1,
16
+ * }));
19
17
  */
20
18
  function createTransitionActor(initialContext, reducer) {
21
19
  const { snapshotSignal, getState, transition } = createMachineCore({
@@ -1 +1 @@
1
- {"version":3,"file":"create-transition-actor.js","names":[],"sources":["../../../../src/core/actors/create-transition-actor.ts"],"sourcesContent":["import type { Machine } from '../machine';\nimport { createMachineCore } from '../machine';\nimport { untrack, update } from '../signals/primitives';\nimport type { ActorSnapshot } from './actor';\n\n// =============================================================================\n// Definition types\n// =============================================================================\n\n/**\n * A reducer-shaped actor: `(context, message) => context`.\n *\n * No finite states — the snapshot carries `value: 'active' | 'destroyed'`\n * as a universal lifecycle marker rather than domain state. The interesting\n * state is entirely in the context, which is reactive via `snapshot`.\n *\n * Use this when the actor has context that needs to be reactive but no\n * meaningful state machine (e.g., a message-driven model with DOM side\n * effects). For actors that need per-state behavior, use `createMachineActor`.\n */\nexport interface TransitionActor<Context extends object, Message extends { type: string }>\n extends Machine<ActorSnapshot<'active' | 'destroyed', Context>> {\n send(message: Message): void;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Creates a reducer-shaped actor from an initial context and a reducer function.\n *\n * The reducer receives the current context and a message and returns the next\n * context. Returning the same reference (by identity) skips the signal update —\n * so early-returning `context` unchanged is both the no-op and the optimization.\n *\n * Side effects (e.g. DOM mutations) may be performed inside the reducer.\n * They run synchronously before the signal is updated.\n *\n * @example\n * const actor = createTransitionActor(\n * { count: 0 },\n * (context, message: { type: 'increment' }) => ({ count: context.count + 1 })\n * );\n */\nexport function createTransitionActor<Context extends object, Message extends { type: string }>(\n initialContext: Context,\n reducer: (context: Context, message: Message) => Context\n): TransitionActor<Context, Message> {\n const { snapshotSignal, getState, transition } = createMachineCore<\n 'active' | 'destroyed',\n ActorSnapshot<'active' | 'destroyed', Context>\n >({ value: 'active', context: initialContext });\n\n const getContext = (): Context => untrack(() => snapshotSignal.get().context);\n const setContext = (context: Context): void => update(snapshotSignal, { context });\n\n return {\n get snapshot() {\n return snapshotSignal;\n },\n\n send(message: Message): void {\n if (getState() === 'destroyed') return;\n const context = getContext();\n const newContext = reducer(context, message);\n if (newContext !== context) setContext(newContext);\n },\n\n destroy(): void {\n if (getState() === 'destroyed') return;\n transition('destroyed');\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,sBACd,gBACA,SACmC;CACnC,MAAM,EAAE,gBAAgB,UAAU,eAAe,kBAG/C;EAAE,OAAO;EAAU,SAAS;CAAe,CAAC;CAE9C,MAAM,mBAA4B,cAAc,eAAe,IAAI,CAAC,CAAC,OAAO;CAC5E,MAAM,cAAc,YAA2B,OAAO,gBAAgB,EAAE,QAAQ,CAAC;CAEjF,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EAEA,KAAK,SAAwB;GAC3B,IAAI,SAAS,MAAM,aAAa;GAChC,MAAM,UAAU,WAAW;GAC3B,MAAM,aAAa,QAAQ,SAAS,OAAO;GAC3C,IAAI,eAAe,SAAS,WAAW,UAAU;EACnD;EAEA,UAAgB;GACd,IAAI,SAAS,MAAM,aAAa;GAChC,WAAW,WAAW;EACxB;CACF;AACF"}
1
+ {"version":3,"file":"create-transition-actor.js","names":[],"sources":["../../../../src/core/actors/create-transition-actor.ts"],"sourcesContent":["import type { Machine } from '../machine';\nimport { createMachineCore } from '../machine';\nimport { untrack, update } from '../signals/primitives';\nimport type { ActorSnapshot } from './actor';\n\n// =============================================================================\n// Definition types\n// =============================================================================\n\n/**\n * A reducer-shaped actor: `(context, message) => context`.\n *\n * No finite states — the snapshot carries `value: 'active' | 'destroyed'` as a universal lifecycle marker rather than\n * domain state. The interesting state is entirely in the context, which is reactive via `snapshot`.\n *\n * Use this when the actor has context that needs to be reactive but no meaningful state machine (e.g., a message-driven\n * model with DOM side effects). For actors that need per-state behavior, use `createMachineActor`.\n */\nexport interface TransitionActor<Context extends object, Message extends { type: string }> extends Machine<\n ActorSnapshot<'active' | 'destroyed', Context>\n> {\n send(message: Message): void;\n}\n\n// =============================================================================\n// Implementation\n// =============================================================================\n\n/**\n * Creates a reducer-shaped actor from an initial context and a reducer function.\n *\n * The reducer receives the current context and a message and returns the next context. Returning the same reference (by\n * identity) skips the signal update so early-returning `context` unchanged is both the no-op and the optimization.\n *\n * Side effects (e.g. DOM mutations) may be performed inside the reducer. They run synchronously before the signal is\n * updated.\n *\n * @example\n * const actor = createTransitionActor({ count: 0 }, (context, message: { type: 'increment' }) => ({\n * count: context.count + 1,\n * }));\n */\nexport function createTransitionActor<Context extends object, Message extends { type: string }>(\n initialContext: Context,\n reducer: (context: Context, message: Message) => Context\n): TransitionActor<Context, Message> {\n const { snapshotSignal, getState, transition } = createMachineCore<\n 'active' | 'destroyed',\n ActorSnapshot<'active' | 'destroyed', Context>\n >({ value: 'active', context: initialContext });\n\n const getContext = (): Context => untrack(() => snapshotSignal.get().context);\n const setContext = (context: Context): void => update(snapshotSignal, { context });\n\n return {\n get snapshot() {\n return snapshotSignal;\n },\n\n send(message: Message): void {\n if (getState() === 'destroyed') return;\n\n const context = getContext();\n const newContext = reducer(context, message);\n\n if (newContext !== context) setContext(newContext);\n },\n\n destroy(): void {\n if (getState() === 'destroyed') return;\n\n transition('destroyed');\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,SAAgB,sBACd,gBACA,SACmC;CACnC,MAAM,EAAE,gBAAgB,UAAU,eAAe,kBAG/C;EAAE,OAAO;EAAU,SAAS;CAAe,CAAC;CAE9C,MAAM,mBAA4B,cAAc,eAAe,IAAI,CAAC,CAAC,OAAO;CAC5E,MAAM,cAAc,YAA2B,OAAO,gBAAgB,EAAE,QAAQ,CAAC;CAEjF,OAAO;EACL,IAAI,WAAW;GACb,OAAO;EACT;EAEA,KAAK,SAAwB;GAC3B,IAAI,SAAS,MAAM,aAAa;GAEhC,MAAM,UAAU,WAAW;GAC3B,MAAM,aAAa,QAAQ,SAAS,OAAO;GAE3C,IAAI,eAAe,SAAS,WAAW,UAAU;EACnD;EAEA,UAAgB;GACd,IAAI,SAAS,MAAM,aAAa;GAEhC,WAAW,WAAW;EACxB;CACF;AACF"}