mattebox 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/dist/cdn/mattebox.dash-drm.min.js +3 -3
  2. package/dist/cdn/mattebox.dash.min.js +3 -3
  3. package/dist/cdn/mattebox.dual-drm.min.js +3 -3
  4. package/dist/cdn/mattebox.dual-ts-drm.min.js +3 -3
  5. package/dist/cdn/mattebox.dual-ts.min.js +3 -3
  6. package/dist/cdn/mattebox.dual.min.js +3 -3
  7. package/dist/cdn/mattebox.hls-drm.min.js +3 -3
  8. package/dist/cdn/mattebox.hls-ts-drm.min.js +3 -3
  9. package/dist/cdn/mattebox.hls-ts.min.js +3 -3
  10. package/dist/cdn/mattebox.hls.min.js +3 -3
  11. package/dist/cdn/mattebox.kernel.min.js +1 -1
  12. package/dist/cdn/mattebox.min.js +3 -6
  13. package/dist/containers/adts.d.ts +10 -0
  14. package/dist/containers/adts.d.ts.map +1 -1
  15. package/dist/containers/adts.js +27 -7
  16. package/dist/containers/adts.js.map +1 -1
  17. package/dist/containers/codec-probe/index.d.ts +0 -6
  18. package/dist/containers/codec-probe/index.d.ts.map +1 -1
  19. package/dist/containers/codec-probe/index.js +14 -23
  20. package/dist/containers/codec-probe/index.js.map +1 -1
  21. package/dist/containers/fmp4/fit.d.ts +26 -0
  22. package/dist/containers/fmp4/fit.d.ts.map +1 -0
  23. package/dist/containers/fmp4/fit.js +49 -0
  24. package/dist/containers/fmp4/fit.js.map +1 -0
  25. package/dist/containers/fmp4/writer.d.ts +7 -0
  26. package/dist/containers/fmp4/writer.d.ts.map +1 -1
  27. package/dist/containers/fmp4/writer.js +9 -1
  28. package/dist/containers/fmp4/writer.js.map +1 -1
  29. package/dist/containers/id3.d.ts.map +1 -1
  30. package/dist/containers/id3.js +2 -1
  31. package/dist/containers/id3.js.map +1 -1
  32. package/dist/containers/mp4-box/index.d.ts +75 -7
  33. package/dist/containers/mp4-box/index.d.ts.map +1 -1
  34. package/dist/containers/mp4-box/index.js +225 -49
  35. package/dist/containers/mp4-box/index.js.map +1 -1
  36. package/dist/containers/packed-audio/index.d.ts.map +1 -1
  37. package/dist/containers/packed-audio/index.js +9 -27
  38. package/dist/containers/packed-audio/index.js.map +1 -1
  39. package/dist/containers/sei.d.ts +5 -0
  40. package/dist/containers/sei.d.ts.map +1 -1
  41. package/dist/containers/sei.js +5 -2
  42. package/dist/containers/sei.js.map +1 -1
  43. package/dist/containers/ts-transmux/demux.d.ts +7 -1
  44. package/dist/containers/ts-transmux/demux.d.ts.map +1 -1
  45. package/dist/containers/ts-transmux/demux.js +38 -17
  46. package/dist/containers/ts-transmux/demux.js.map +1 -1
  47. package/dist/containers/ts-transmux/h264.d.ts.map +1 -1
  48. package/dist/containers/ts-transmux/h264.js +1 -17
  49. package/dist/containers/ts-transmux/h264.js.map +1 -1
  50. package/dist/containers/ts-transmux/index.d.ts.map +1 -1
  51. package/dist/containers/ts-transmux/index.js +11 -2
  52. package/dist/containers/ts-transmux/index.js.map +1 -1
  53. package/dist/containers/ts-transmux/transmux.d.ts.map +1 -1
  54. package/dist/containers/ts-transmux/transmux.js +6 -36
  55. package/dist/containers/ts-transmux/transmux.js.map +1 -1
  56. package/dist/{stages/text-webvtt/parse.d.ts → containers/webvtt.d.ts} +4 -3
  57. package/dist/containers/webvtt.d.ts.map +1 -0
  58. package/dist/{stages/text-webvtt/parse.js → containers/webvtt.js} +1 -1
  59. package/dist/containers/webvtt.js.map +1 -0
  60. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/asyncToGenerator.js +1 -1
  61. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/defineProperty.js +1 -1
  62. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectSpread2.js +1 -1
  63. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutProperties.js +1 -1
  64. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/objectWithoutPropertiesLoose.js +1 -1
  65. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPrimitive.js +1 -1
  66. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/toPropertyKey.js +1 -1
  67. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.149.0 → _@oxc-project_runtime@0.150.0}/helpers/esm/typeof.js +1 -1
  68. package/dist/es2015/containers/adts.js +28 -8
  69. package/dist/es2015/containers/codec-probe/index.js +17 -26
  70. package/dist/es2015/containers/fmp4/fit.js +46 -0
  71. package/dist/es2015/containers/fmp4/writer.js +9 -1
  72. package/dist/es2015/containers/id3.js +3 -3
  73. package/dist/es2015/containers/mp4-box/index.js +224 -39
  74. package/dist/es2015/containers/packed-audio/index.js +6 -33
  75. package/dist/es2015/containers/sei.js +6 -3
  76. package/dist/es2015/containers/ts-transmux/demux.js +41 -22
  77. package/dist/es2015/containers/ts-transmux/h264.js +2 -18
  78. package/dist/es2015/containers/ts-transmux/index.js +9 -9
  79. package/dist/es2015/containers/ts-transmux/transmux.js +8 -39
  80. package/dist/es2015/{stages/text-webvtt/parse.js → containers/webvtt.js} +2 -2
  81. package/dist/es2015/index.js +40 -42
  82. package/dist/es2015/kernel/append-queue.js +1 -1
  83. package/dist/es2015/kernel/base64.js +25 -0
  84. package/dist/es2015/kernel/context.js +7 -0
  85. package/dist/es2015/kernel/effects.js +21 -1
  86. package/dist/es2015/kernel/loader.js +5 -4
  87. package/dist/es2015/kernel/mime.js +5 -1
  88. package/dist/es2015/kernel/mse.js +27 -71
  89. package/dist/es2015/kernel/prepare.js +77 -0
  90. package/dist/es2015/kernel/presentation.js +24 -0
  91. package/dist/es2015/kernel/reducer.js +279 -124
  92. package/dist/es2015/kernel/refresh.js +35 -0
  93. package/dist/es2015/kernel/rendition-select.js +109 -4
  94. package/dist/es2015/kernel/scheduler.js +23 -5
  95. package/dist/es2015/kernel/sinks/text-track-sink.js +27 -26
  96. package/dist/es2015/kernel/timeline.js +22 -1
  97. package/dist/es2015/kernel/trace.js +1 -1
  98. package/dist/es2015/kernel/track-registry.js +10 -2
  99. package/dist/es2015/kernel/transport.js +4 -4
  100. package/dist/es2015/kernel/url.js +12 -0
  101. package/dist/es2015/presets/define.js +2 -2
  102. package/dist/es2015/presets/full/index.js +9 -3
  103. package/dist/es2015/presets/tiers.js +7 -6
  104. package/dist/es2015/protocols/adapter-shared.js +28 -0
  105. package/dist/es2015/protocols/dash-cmaf/index.js +132 -88
  106. package/dist/es2015/protocols/dash-cmaf/parse.js +62 -64
  107. package/dist/es2015/protocols/dash-live/index.js +62 -37
  108. package/dist/es2015/protocols/dimensions.js +15 -0
  109. package/dist/es2015/protocols/hls-cmaf/index.js +108 -95
  110. package/dist/es2015/protocols/hls-cmaf/lexer.js +3 -0
  111. package/dist/es2015/protocols/hls-cmaf/parse.js +167 -56
  112. package/dist/es2015/protocols/hls-cmaf/unavailable.js +43 -0
  113. package/dist/es2015/protocols/hls-live/index.js +187 -109
  114. package/dist/es2015/stages/abr/index.js +8 -11
  115. package/dist/es2015/stages/abr-persist/index.js +18 -11
  116. package/dist/es2015/stages/aes-128/index.js +15 -8
  117. package/dist/es2015/stages/alt-audio/index.js +25 -13
  118. package/dist/es2015/stages/chapters/index.js +151 -0
  119. package/dist/es2015/stages/chapters/parse.js +149 -0
  120. package/dist/es2015/stages/cmaf-timing/index.js +24 -39
  121. package/dist/es2015/stages/cmcd/index.js +29 -6
  122. package/dist/es2015/stages/codec-switch/index.js +2 -5
  123. package/dist/es2015/stages/content-steering/index.js +13 -16
  124. package/dist/es2015/stages/eme-cenc/index.js +10 -4
  125. package/dist/es2015/stages/eme-core/index.js +31 -13
  126. package/dist/es2015/stages/eme-fairplay/index.js +12 -8
  127. package/dist/es2015/stages/nal-scan/index.js +30 -140
  128. package/dist/es2015/stages/recovery/index.js +47 -54
  129. package/dist/es2015/stages/text-cea608/decode.js +1 -1
  130. package/dist/es2015/stages/text-cea608/index.js +3 -17
  131. package/dist/es2015/stages/text-webvtt/index.js +1 -1
  132. package/dist/es2015/stages/text-webvtt-segmented/index.js +15 -8
  133. package/dist/es2015/stages/thumbnails/index.js +213 -43
  134. package/dist/es2015/stages/trick-play/index.js +463 -0
  135. package/dist/index.d.ts +6 -0
  136. package/dist/index.d.ts.map +1 -1
  137. package/dist/index.js +36 -53
  138. package/dist/index.js.map +1 -1
  139. package/dist/kernel/base64.d.ts +9 -0
  140. package/dist/kernel/base64.d.ts.map +1 -0
  141. package/dist/kernel/base64.js +26 -0
  142. package/dist/kernel/base64.js.map +1 -0
  143. package/dist/kernel/context.d.ts +5 -1
  144. package/dist/kernel/context.d.ts.map +1 -1
  145. package/dist/kernel/context.js +10 -0
  146. package/dist/kernel/context.js.map +1 -1
  147. package/dist/kernel/effects.d.ts +9 -1
  148. package/dist/kernel/effects.d.ts.map +1 -1
  149. package/dist/kernel/effects.js +12 -0
  150. package/dist/kernel/effects.js.map +1 -1
  151. package/dist/kernel/lifecycle.js +1 -1
  152. package/dist/kernel/lifecycle.js.map +1 -1
  153. package/dist/kernel/loader.d.ts.map +1 -1
  154. package/dist/kernel/loader.js +5 -7
  155. package/dist/kernel/loader.js.map +1 -1
  156. package/dist/kernel/mime.d.ts +2 -0
  157. package/dist/kernel/mime.d.ts.map +1 -1
  158. package/dist/kernel/mime.js +4 -0
  159. package/dist/kernel/mime.js.map +1 -1
  160. package/dist/kernel/mse.d.ts +6 -10
  161. package/dist/kernel/mse.d.ts.map +1 -1
  162. package/dist/kernel/mse.js +20 -73
  163. package/dist/kernel/mse.js.map +1 -1
  164. package/dist/kernel/prepare.d.ts +28 -0
  165. package/dist/kernel/prepare.d.ts.map +1 -0
  166. package/dist/kernel/prepare.js +89 -0
  167. package/dist/kernel/prepare.js.map +1 -0
  168. package/dist/kernel/presentation.d.ts +20 -0
  169. package/dist/kernel/presentation.d.ts.map +1 -0
  170. package/dist/kernel/presentation.js +25 -0
  171. package/dist/kernel/presentation.js.map +1 -0
  172. package/dist/kernel/reducer.d.ts +24 -0
  173. package/dist/kernel/reducer.d.ts.map +1 -1
  174. package/dist/kernel/reducer.js +375 -152
  175. package/dist/kernel/reducer.js.map +1 -1
  176. package/dist/kernel/refresh.d.ts +14 -0
  177. package/dist/kernel/refresh.d.ts.map +1 -0
  178. package/dist/kernel/refresh.js +51 -0
  179. package/dist/kernel/refresh.js.map +1 -0
  180. package/dist/kernel/rendition-select.d.ts +38 -5
  181. package/dist/kernel/rendition-select.d.ts.map +1 -1
  182. package/dist/kernel/rendition-select.js +134 -2
  183. package/dist/kernel/rendition-select.js.map +1 -1
  184. package/dist/kernel/scheduler.d.ts +18 -3
  185. package/dist/kernel/scheduler.d.ts.map +1 -1
  186. package/dist/kernel/scheduler.js +32 -7
  187. package/dist/kernel/scheduler.js.map +1 -1
  188. package/dist/kernel/sinks/text-track-sink.d.ts +9 -0
  189. package/dist/kernel/sinks/text-track-sink.d.ts.map +1 -1
  190. package/dist/kernel/sinks/text-track-sink.js +29 -29
  191. package/dist/kernel/sinks/text-track-sink.js.map +1 -1
  192. package/dist/kernel/timeline.d.ts +26 -7
  193. package/dist/kernel/timeline.d.ts.map +1 -1
  194. package/dist/kernel/timeline.js +21 -7
  195. package/dist/kernel/timeline.js.map +1 -1
  196. package/dist/kernel/track-registry.d.ts.map +1 -1
  197. package/dist/kernel/track-registry.js +17 -1
  198. package/dist/kernel/track-registry.js.map +1 -1
  199. package/dist/kernel/transport.d.ts.map +1 -1
  200. package/dist/kernel/transport.js +1 -0
  201. package/dist/kernel/transport.js.map +1 -1
  202. package/dist/kernel/url.d.ts +4 -0
  203. package/dist/kernel/url.d.ts.map +1 -0
  204. package/dist/kernel/url.js +11 -0
  205. package/dist/kernel/url.js.map +1 -0
  206. package/dist/presets/full/index.d.ts.map +1 -1
  207. package/dist/presets/full/index.js +8 -2
  208. package/dist/presets/full/index.js.map +1 -1
  209. package/dist/presets/tiers.d.ts +7 -6
  210. package/dist/presets/tiers.d.ts.map +1 -1
  211. package/dist/presets/tiers.js +7 -6
  212. package/dist/presets/tiers.js.map +1 -1
  213. package/dist/protocols/adapter-shared.d.ts +23 -0
  214. package/dist/protocols/adapter-shared.d.ts.map +1 -0
  215. package/dist/protocols/adapter-shared.js +23 -0
  216. package/dist/protocols/adapter-shared.js.map +1 -0
  217. package/dist/protocols/dash-cmaf/index.d.ts +2 -2
  218. package/dist/protocols/dash-cmaf/index.d.ts.map +1 -1
  219. package/dist/protocols/dash-cmaf/index.js +150 -97
  220. package/dist/protocols/dash-cmaf/index.js.map +1 -1
  221. package/dist/protocols/dash-cmaf/parse.d.ts +2 -5
  222. package/dist/protocols/dash-cmaf/parse.d.ts.map +1 -1
  223. package/dist/protocols/dash-cmaf/parse.js +46 -39
  224. package/dist/protocols/dash-cmaf/parse.js.map +1 -1
  225. package/dist/protocols/dash-live/index.d.ts.map +1 -1
  226. package/dist/protocols/dash-live/index.js +67 -25
  227. package/dist/protocols/dash-live/index.js.map +1 -1
  228. package/dist/protocols/dimensions.d.ts +8 -0
  229. package/dist/protocols/dimensions.d.ts.map +1 -0
  230. package/dist/protocols/dimensions.js +13 -0
  231. package/dist/protocols/dimensions.js.map +1 -0
  232. package/dist/protocols/hls-cmaf/index.d.ts +3 -2
  233. package/dist/protocols/hls-cmaf/index.d.ts.map +1 -1
  234. package/dist/protocols/hls-cmaf/index.js +127 -114
  235. package/dist/protocols/hls-cmaf/index.js.map +1 -1
  236. package/dist/protocols/hls-cmaf/lexer.d.ts.map +1 -1
  237. package/dist/protocols/hls-cmaf/lexer.js +3 -0
  238. package/dist/protocols/hls-cmaf/lexer.js.map +1 -1
  239. package/dist/protocols/hls-cmaf/parse.d.ts +22 -14
  240. package/dist/protocols/hls-cmaf/parse.d.ts.map +1 -1
  241. package/dist/protocols/hls-cmaf/parse.js +196 -69
  242. package/dist/protocols/hls-cmaf/parse.js.map +1 -1
  243. package/dist/protocols/hls-cmaf/unavailable.d.ts +17 -0
  244. package/dist/protocols/hls-cmaf/unavailable.d.ts.map +1 -0
  245. package/dist/protocols/hls-cmaf/unavailable.js +38 -0
  246. package/dist/protocols/hls-cmaf/unavailable.js.map +1 -0
  247. package/dist/protocols/hls-live/index.d.ts +17 -0
  248. package/dist/protocols/hls-live/index.d.ts.map +1 -1
  249. package/dist/protocols/hls-live/index.js +202 -106
  250. package/dist/protocols/hls-live/index.js.map +1 -1
  251. package/dist/stages/abr/index.d.ts.map +1 -1
  252. package/dist/stages/abr/index.js +8 -14
  253. package/dist/stages/abr/index.js.map +1 -1
  254. package/dist/stages/abr-cap-size/index.d.ts +1 -1
  255. package/dist/stages/abr-persist/index.d.ts.map +1 -1
  256. package/dist/stages/abr-persist/index.js +17 -7
  257. package/dist/stages/abr-persist/index.js.map +1 -1
  258. package/dist/stages/aes-128/index.d.ts +0 -9
  259. package/dist/stages/aes-128/index.d.ts.map +1 -1
  260. package/dist/stages/aes-128/index.js +15 -13
  261. package/dist/stages/aes-128/index.js.map +1 -1
  262. package/dist/stages/alt-audio/index.d.ts +16 -0
  263. package/dist/stages/alt-audio/index.d.ts.map +1 -1
  264. package/dist/stages/alt-audio/index.js +28 -15
  265. package/dist/stages/alt-audio/index.js.map +1 -1
  266. package/dist/stages/chapters/index.d.ts +20 -0
  267. package/dist/stages/chapters/index.d.ts.map +1 -0
  268. package/dist/stages/chapters/index.js +141 -0
  269. package/dist/stages/chapters/index.js.map +1 -0
  270. package/dist/stages/chapters/parse.d.ts +47 -0
  271. package/dist/stages/chapters/parse.d.ts.map +1 -0
  272. package/dist/stages/chapters/parse.js +168 -0
  273. package/dist/stages/chapters/parse.js.map +1 -0
  274. package/dist/stages/cmaf-timing/index.d.ts.map +1 -1
  275. package/dist/stages/cmaf-timing/index.js +33 -42
  276. package/dist/stages/cmaf-timing/index.js.map +1 -1
  277. package/dist/stages/cmcd/index.d.ts +0 -11
  278. package/dist/stages/cmcd/index.d.ts.map +1 -1
  279. package/dist/stages/cmcd/index.js +30 -12
  280. package/dist/stages/cmcd/index.js.map +1 -1
  281. package/dist/stages/codec-switch/index.d.ts.map +1 -1
  282. package/dist/stages/codec-switch/index.js +3 -8
  283. package/dist/stages/codec-switch/index.js.map +1 -1
  284. package/dist/stages/content-steering/index.d.ts.map +1 -1
  285. package/dist/stages/content-steering/index.js +12 -9
  286. package/dist/stages/content-steering/index.js.map +1 -1
  287. package/dist/stages/eme-cenc/index.d.ts +0 -7
  288. package/dist/stages/eme-cenc/index.d.ts.map +1 -1
  289. package/dist/stages/eme-cenc/index.js +9 -5
  290. package/dist/stages/eme-cenc/index.js.map +1 -1
  291. package/dist/stages/eme-core/index.d.ts.map +1 -1
  292. package/dist/stages/eme-core/index.js +31 -15
  293. package/dist/stages/eme-core/index.js.map +1 -1
  294. package/dist/stages/eme-fairplay/index.d.ts +0 -7
  295. package/dist/stages/eme-fairplay/index.d.ts.map +1 -1
  296. package/dist/stages/eme-fairplay/index.js +11 -9
  297. package/dist/stages/eme-fairplay/index.js.map +1 -1
  298. package/dist/stages/nal-scan/index.d.ts.map +1 -1
  299. package/dist/stages/nal-scan/index.js +32 -145
  300. package/dist/stages/nal-scan/index.js.map +1 -1
  301. package/dist/stages/recovery/index.d.ts.map +1 -1
  302. package/dist/stages/recovery/index.js +42 -56
  303. package/dist/stages/recovery/index.js.map +1 -1
  304. package/dist/stages/text-cea608/index.d.ts +11 -0
  305. package/dist/stages/text-cea608/index.d.ts.map +1 -1
  306. package/dist/stages/text-cea608/index.js +3 -23
  307. package/dist/stages/text-cea608/index.js.map +1 -1
  308. package/dist/stages/text-webvtt/index.d.ts +12 -0
  309. package/dist/stages/text-webvtt/index.d.ts.map +1 -1
  310. package/dist/stages/text-webvtt/index.js +1 -1
  311. package/dist/stages/text-webvtt/index.js.map +1 -1
  312. package/dist/stages/text-webvtt-segmented/index.d.ts.map +1 -1
  313. package/dist/stages/text-webvtt-segmented/index.js +11 -8
  314. package/dist/stages/text-webvtt-segmented/index.js.map +1 -1
  315. package/dist/stages/thumbnails/index.d.ts +39 -10
  316. package/dist/stages/thumbnails/index.d.ts.map +1 -1
  317. package/dist/stages/thumbnails/index.js +220 -30
  318. package/dist/stages/thumbnails/index.js.map +1 -1
  319. package/dist/stages/trick-play/index.d.ts +51 -0
  320. package/dist/stages/trick-play/index.d.ts.map +1 -0
  321. package/dist/stages/trick-play/index.js +480 -0
  322. package/dist/stages/trick-play/index.js.map +1 -0
  323. package/dist/types/ir.d.ts +40 -1
  324. package/dist/types/ir.d.ts.map +1 -1
  325. package/dist/types/kernel.d.ts +41 -13
  326. package/dist/types/kernel.d.ts.map +1 -1
  327. package/dist/types/kernel.js +2 -1
  328. package/dist/types/kernel.js.map +1 -1
  329. package/dist/types/messages.d.ts +61 -10
  330. package/dist/types/messages.d.ts.map +1 -1
  331. package/dist/types/stage.d.ts +18 -0
  332. package/dist/types/stage.d.ts.map +1 -1
  333. package/package.json +1 -1
  334. package/dist/stages/text-webvtt/parse.d.ts.map +0 -1
  335. package/dist/stages/text-webvtt/parse.js.map +0 -1
@@ -0,0 +1,151 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { findTrackSite } from "../../kernel/presentation.js";
3
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
4
+ import { parseAppleChapters, parseChapterTrack } from "./parse.js";
5
+ //#region src/stages/chapters/index.ts
6
+ /**
7
+ * Chapters: named spans of the presentation, answered through
8
+ * `engine.chapters`. Two sources fill it:
9
+ *
10
+ * - The manifest. An HLS EXT-X-SESSION-DATA entry with DATA-ID
11
+ * `com.apple.hls.chapters` names Apple's JSON chapters document. The
12
+ * stage's reducer fetches it once per load and parses it; the list lives
13
+ * in the stage's slice.
14
+ * - A file the app loads: a WebVTT chapters track, the metadata track this
15
+ * engine defines (JSON cue payloads with an image and data), or Apple's
16
+ * JSON. It wins over the manifest until the next LOAD, UNLOAD, or DETACH.
17
+ *
18
+ * Both fetches go through the transport, so request hooks (auth, cmcd,
19
+ * steering) apply. A load counter in the slice ties the app's list, which
20
+ * lives outside kernel state, to the source loaded when it arrived.
21
+ */
22
+ /** The session-data id Apple's players read chapters from. */
23
+ const APPLE_CHAPTERS = "com.apple.hls.chapters";
24
+ const FETCH_TOKEN = "chapters:manifest";
25
+ const INITIAL = {
26
+ loads: 0,
27
+ manifestUri: null,
28
+ manifest: null
29
+ };
30
+ /** The active subtitle language picks among a document's titles. */
31
+ function preferredLanguage(kernel) {
32
+ var _findTrackSite$track$, _findTrackSite;
33
+ const textId = kernel.tracks.active.get("text");
34
+ if (textId === void 0) return null;
35
+ return (_findTrackSite$track$ = (_findTrackSite = findTrackSite(kernel.presentation, textId)) === null || _findTrackSite === void 0 ? void 0 : _findTrackSite.track.lang) !== null && _findTrackSite$track$ !== void 0 ? _findTrackSite$track$ : null;
36
+ }
37
+ /** A parse's warnings and the list-changed event, as emit effects. */
38
+ function report(url, result, source) {
39
+ return [...result.warnings.map((warning) => ({
40
+ kind: "emit",
41
+ event: "chapters:warning",
42
+ payload: _objectSpread2({ url }, warning)
43
+ })), {
44
+ kind: "emit",
45
+ event: "chapters:changed",
46
+ payload: {
47
+ count: result.chapters.length,
48
+ source
49
+ }
50
+ }];
51
+ }
52
+ /** Counts source changes, and finds, fetches, and parses the manifest's chapters. */
53
+ const reduceChapters = (slice, msg, kernel) => {
54
+ const state = slice !== null && slice !== void 0 ? slice : INITIAL;
55
+ if (msg.type === "LOAD" || msg.type === "UNLOAD" || msg.type === "DETACH") return [_objectSpread2(_objectSpread2({}, INITIAL), {}, { loads: state.loads + 1 }), [{
56
+ kind: "emit",
57
+ event: "chapters:changed",
58
+ payload: {
59
+ count: 0,
60
+ source: "none"
61
+ }
62
+ }]];
63
+ if (msg.type === "MANIFEST_LOADED") {
64
+ var _msg$presentation$ses;
65
+ const uri = (_msg$presentation$ses = msg.presentation.sessionData) === null || _msg$presentation$ses === void 0 || (_msg$presentation$ses = _msg$presentation$ses.find((d) => d.id === APPLE_CHAPTERS)) === null || _msg$presentation$ses === void 0 ? void 0 : _msg$presentation$ses.uri;
66
+ if (uri === void 0 || uri === state.manifestUri) return [state, []];
67
+ return [_objectSpread2(_objectSpread2({}, state), {}, { manifestUri: uri }), [{
68
+ kind: "fetch",
69
+ token: FETCH_TOKEN,
70
+ url: uri
71
+ }]];
72
+ }
73
+ if (msg.type === "SEGMENT_LOADED" && msg.trackId === FETCH_TOKEN && state.manifestUri !== null) {
74
+ const text = new TextDecoder().decode(msg.bytes);
75
+ const result = parseAppleChapters(text, state.manifestUri, preferredLanguage(kernel));
76
+ return [_objectSpread2(_objectSpread2({}, state), {}, { manifest: result.chapters }), report(state.manifestUri, result, "manifest")];
77
+ }
78
+ if (msg.type === "SEGMENT_FAILED" && msg.trackId === FETCH_TOKEN) return [state, [{
79
+ kind: "emit",
80
+ event: "chapters:warning",
81
+ payload: {
82
+ url: state.manifestUri,
83
+ reason: "fetch-failed"
84
+ }
85
+ }]];
86
+ return [state, []];
87
+ };
88
+ function chapters() {
89
+ return {
90
+ name: "chapters",
91
+ provides: ["chapters"],
92
+ requires: ["transport"],
93
+ install(ctx) {
94
+ ctx.reduce("chapters", reduceChapters);
95
+ let list = null;
96
+ const slice = () => {
97
+ var _ref;
98
+ return (_ref = ctx.getState().chapters) !== null && _ref !== void 0 ? _ref : INITIAL;
99
+ };
100
+ /** The app's list, when it belongs to the source loaded now. */
101
+ const app = () => list !== null && list.loads === slice().loads ? list.chapters : null;
102
+ /**
103
+ * The list in force. A last chapter with no end runs to the end of the
104
+ * presentation, known once a media playlist has loaded.
105
+ */
106
+ const current = () => {
107
+ var _ref2, _app, _ctx$getState$present;
108
+ const chosen = (_ref2 = (_app = app()) !== null && _app !== void 0 ? _app : slice().manifest) !== null && _ref2 !== void 0 ? _ref2 : [];
109
+ const duration = (_ctx$getState$present = ctx.getState().presentation) === null || _ctx$getState$present === void 0 ? void 0 : _ctx$getState$present.duration;
110
+ if (duration === void 0) return chosen;
111
+ return chosen.map((c) => c.end === Number.POSITIVE_INFINITY ? _objectSpread2(_objectSpread2({}, c), {}, { end: duration }) : c);
112
+ };
113
+ ctx.registerNamespace("chapters", {
114
+ load(url) {
115
+ return _asyncToGenerator(function* () {
116
+ const at = slice().loads;
117
+ const response = yield ctx.request(url, { method: "GET" });
118
+ if (!response.ok) throw new TypeError(`chapters ${url}: HTTP ${response.status}`);
119
+ const text = yield response.text();
120
+ const base = response.url || url;
121
+ let result;
122
+ if (/^?WEBVTT/.test(text)) result = parseChapterTrack(text, base);
123
+ else if (text.trimStart().startsWith("[")) result = parseAppleChapters(text, base, preferredLanguage(ctx.getState()));
124
+ else throw new TypeError(`chapters ${url}: neither WebVTT nor a JSON chapters array`);
125
+ const effects = report(url, result, "app");
126
+ if (at !== slice().loads) return result.chapters.length;
127
+ list = {
128
+ loads: at,
129
+ chapters: result.chapters
130
+ };
131
+ for (const effect of effects) if (effect.kind === "emit") ctx.emit(effect.event, effect.payload);
132
+ return result.chapters.length;
133
+ })();
134
+ },
135
+ at(time) {
136
+ var _current$find;
137
+ return (_current$find = current().find((c) => time >= c.start && time < c.end)) !== null && _current$find !== void 0 ? _current$find : null;
138
+ },
139
+ get all() {
140
+ return current();
141
+ },
142
+ get source() {
143
+ if (app() !== null) return "app";
144
+ return slice().manifest === null ? "none" : "manifest";
145
+ }
146
+ });
147
+ }
148
+ };
149
+ }
150
+ //#endregion
151
+ export { chapters as default };
@@ -0,0 +1,149 @@
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import _objectWithoutProperties from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectWithoutProperties.js";
3
+ import { parseVtt } from "../../containers/webvtt.js";
4
+ import { resolveUrl } from "../../kernel/url.js";
5
+ //#region src/stages/chapters/parse.ts
6
+ /**
7
+ * Chapter files into one record shape. Pure. A WebVTT file serves two
8
+ * sources: a chapters track, whose cue payload is the title, and the
9
+ * metadata track this engine defines, whose cue payload may be a JSON object
10
+ * with a title, an image, and free data. Detection is per cue, so the two
11
+ * mix in one file.
12
+ */
13
+ const _excluded = [
14
+ "title",
15
+ "lang",
16
+ "image"
17
+ ];
18
+ const _excluded2 = [
19
+ "start-time",
20
+ "duration",
21
+ "titles",
22
+ "images"
23
+ ];
24
+ function imageOf(value, baseUrl) {
25
+ if (typeof value === "string") return { url: resolveUrl(value, baseUrl) };
26
+ if (typeof value !== "object" || value === null) return void 0;
27
+ const { url, width, height } = value;
28
+ if (typeof url !== "string") return void 0;
29
+ return _objectSpread2(_objectSpread2({ url: resolveUrl(url, baseUrl) }, typeof width === "number" ? { width } : {}), typeof height === "number" ? { height } : {});
30
+ }
31
+ /** A JSON cue payload into the record's fields; every other field goes to `data`. */
32
+ function fromJson(object, baseUrl) {
33
+ const { title, lang, image } = object, rest = _objectWithoutProperties(object, _excluded);
34
+ const resolvedImage = imageOf(image, baseUrl);
35
+ return _objectSpread2(_objectSpread2(_objectSpread2({ title: typeof title === "string" ? title : "" }, typeof lang === "string" ? { lang } : {}), resolvedImage !== void 0 ? { image: resolvedImage } : {}), Object.keys(rest).length > 0 ? { data: rest } : {});
36
+ }
37
+ /**
38
+ * Sorts by start and truncates an earlier chapter that runs into the next,
39
+ * so chapters partition the timeline. An authored gap stays a gap.
40
+ */
41
+ function orderChapters(chapters, warnings) {
42
+ const sorted = [...chapters].sort((a, b) => a.start - b.start);
43
+ return sorted.map((chapter, i) => {
44
+ const next = sorted[i + 1];
45
+ if (next === void 0 || chapter.end <= next.start) return chapter;
46
+ warnings.push({
47
+ reason: "overlap",
48
+ id: chapter.id
49
+ });
50
+ return _objectSpread2(_objectSpread2({}, chapter), {}, { end: next.start });
51
+ });
52
+ }
53
+ /** A WebVTT chapters or metadata track. URLs resolve against `baseUrl`, the file's own URL. */
54
+ function parseChapterTrack(text, baseUrl) {
55
+ const { cues, skipped } = parseVtt(text);
56
+ const warnings = [];
57
+ for (let i = 0; i < skipped; i += 1) warnings.push({ reason: "malformed-cue" });
58
+ const chapters = [];
59
+ for (const cue of cues) {
60
+ var _cue$text, _cue$id;
61
+ const payload = ((_cue$text = cue.text) !== null && _cue$text !== void 0 ? _cue$text : "").trim();
62
+ const id = (_cue$id = cue.id) !== null && _cue$id !== void 0 ? _cue$id : String(Math.round(cue.start * 1e3));
63
+ let fields = { title: payload };
64
+ if (payload.startsWith("{")) try {
65
+ const parsed = JSON.parse(payload);
66
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new TypeError("not an object");
67
+ fields = fromJson(parsed, baseUrl);
68
+ } catch (_unused) {
69
+ warnings.push({
70
+ reason: "bad-json",
71
+ id
72
+ });
73
+ }
74
+ chapters.push(_objectSpread2({
75
+ id,
76
+ start: cue.start,
77
+ end: cue.end
78
+ }, fields));
79
+ }
80
+ return {
81
+ chapters: orderChapters(chapters, warnings),
82
+ warnings
83
+ };
84
+ }
85
+ /**
86
+ * The title in `preferred`, else the language-neutral `und` one, else the
87
+ * first. Apple's JSON gives one title per BCP 47 tag.
88
+ */
89
+ function pickTitle(titles, preferred) {
90
+ var _ref, _ref2, _titles$find;
91
+ const base = (tag) => tag.toLowerCase().split("-")[0];
92
+ return (_ref = (_ref2 = preferred === null ? void 0 : (_titles$find = titles.find((t) => t.language.toLowerCase() === preferred.toLowerCase())) !== null && _titles$find !== void 0 ? _titles$find : titles.find((t) => base(t.language) === base(preferred))) !== null && _ref2 !== void 0 ? _ref2 : titles.find((t) => t.language === "und")) !== null && _ref !== void 0 ? _ref : titles[0];
93
+ }
94
+ /**
95
+ * Apple's JSON chapters document (HTTP Live Streaming, "Providing
96
+ * JavaScript Object Notation (JSON) chapters"): an array of entries with a
97
+ * required `start-time` and optional `duration`, `chapter`, `titles`,
98
+ * `images`, and `metadata`. Without `duration` a chapter ends at the next
99
+ * one's start; the last one runs to the end of the presentation (Infinity
100
+ * here). The first image becomes `image`; every title, image, and metadata
101
+ * item stays under `data`. Image URLs resolve against the document.
102
+ */
103
+ function parseAppleChapters(text, baseUrl, preferredLanguage = null) {
104
+ const warnings = [];
105
+ let parsed;
106
+ try {
107
+ parsed = JSON.parse(text);
108
+ } catch (_unused2) {
109
+ return {
110
+ chapters: [],
111
+ warnings: [{ reason: "bad-json" }]
112
+ };
113
+ }
114
+ if (!Array.isArray(parsed)) return {
115
+ chapters: [],
116
+ warnings: [{ reason: "bad-json" }]
117
+ };
118
+ const entries = parsed.filter((entry) => {
119
+ const ok = typeof entry === "object" && entry !== null && typeof entry["start-time"] === "number";
120
+ if (!ok) warnings.push({ reason: "malformed-cue" });
121
+ return ok;
122
+ });
123
+ const starts = entries.map((entry) => entry["start-time"]).sort((a, b) => a - b);
124
+ return {
125
+ chapters: orderChapters(entries.map((entry, index) => {
126
+ var _starts$find, _title$title;
127
+ const start = entry["start-time"];
128
+ const duration = typeof entry.duration === "number" ? entry.duration : null;
129
+ const end = duration !== null ? start + duration : (_starts$find = starts.find((s) => s > start)) !== null && _starts$find !== void 0 ? _starts$find : Number.POSITIVE_INFINITY;
130
+ const titles = Array.isArray(entry.titles) ? entry.titles.filter((t) => typeof t === "object" && t !== null && typeof t.language === "string" && typeof t.title === "string") : [];
131
+ const title = pickTitle(titles, preferredLanguage);
132
+ const images = Array.isArray(entry.images) ? entry.images.filter((i) => typeof i === "object" && i !== null).filter((i) => typeof i.url === "string").map((i) => _objectSpread2(_objectSpread2({}, i), {}, { url: resolveUrl(i.url, baseUrl) })) : [];
133
+ const first = images[0];
134
+ const { "start-time": _start, duration: _duration, titles: _titles, images: _images } = entry, rest = _objectWithoutProperties(entry, _excluded2);
135
+ const data = _objectSpread2(_objectSpread2(_objectSpread2({}, rest), titles.length > 0 ? { titles } : {}), images.length > 0 ? { images } : {});
136
+ const width = first === null || first === void 0 ? void 0 : first["pixel-width"];
137
+ const height = first === null || first === void 0 ? void 0 : first["pixel-height"];
138
+ return _objectSpread2(_objectSpread2(_objectSpread2({
139
+ id: typeof entry.chapter === "number" ? String(entry.chapter) : String(index + 1),
140
+ start,
141
+ end,
142
+ title: (_title$title = title === null || title === void 0 ? void 0 : title.title) !== null && _title$title !== void 0 ? _title$title : ""
143
+ }, title !== void 0 ? { lang: title.language } : {}), first !== void 0 ? { image: _objectSpread2(_objectSpread2({ url: first.url }, typeof width === "number" ? { width } : {}), typeof height === "number" ? { height } : {}) } : {}), Object.keys(data).length > 0 ? { data } : {});
144
+ }), warnings),
145
+ warnings
146
+ };
147
+ }
148
+ //#endregion
149
+ export { orderChapters, parseAppleChapters, parseChapterTrack };
@@ -1,52 +1,37 @@
1
- import { findBox, normalizeTfdt, trackTimescales } from "../../containers/mp4-box/index.js";
1
+ import { earliestDecodeTime, findBox, trackTimescales } from "../../containers/mp4-box/index.js";
2
2
  //#region src/stages/cmaf-timing/index.ts
3
3
  /**
4
- * cmaf-timing normalizes the decode timeline of native fMP4 segments so a live
5
- * CMAF stream plays. A CMAF live segment's tfdt carries the real broadcast
6
- * clock (often a value in the billions of seconds); appended with the zero
7
- * timestampOffset the kernel derives for fMP4, its frames land far past the
8
- * playhead and nothing ever renders. This stage rewrites each segment's tfdt to
9
- * the presentation start the manifest assigns it, which is the same alignment a
10
- * TS transmux produces for free, so VOD (already near zero) is untouched and
11
- * live is corrected.
4
+ * cmaf-timing reads where a native fMP4 segment's media clock starts, so
5
+ * the kernel can land the segment at the presentation time the manifest
6
+ * gives it. Packagers write whatever clock they like into tfdt: a live
7
+ * broadcast clock in the billions of seconds, an encoder offset of ten
8
+ * seconds into a VOD title, or zero. The bytes are never touched. The
9
+ * kernel settles one timestampOffset per timeline epoch from the first
10
+ * reading, the segment's playlist start minus this decode time, and every
11
+ * buffer applies it, the way videojs-http-streaming derives the offset
12
+ * from its main loader's first segment.
12
13
  *
13
- * It contributes a transform step and the `media-transform` capability, so the
14
- * append path routes through the transform pipeline for a CMAF composition too.
15
- * Timescales come from the init segment's moov; the transform runs after any
16
- * transmux, and a decrypt step never touches the moof header, so an encrypted
17
- * segment is normalized the same way.
14
+ * The probe runs after the transform pipeline, so a decrypted or
15
+ * transmuxed segment is read in its final form. Timescales come from each
16
+ * rendition's init segment moov, or from a self-contained segment that
17
+ * carries its own.
18
18
  */
19
- /** After ts-transmux (100) and any decrypt-class step, before the append. */
20
- const ORDER = 150;
21
19
  function cmafTiming() {
22
20
  return {
23
21
  name: "cmaf-timing",
24
- provides: [
25
- "cmaf-timing",
26
- "media-transform",
27
- "media-time-normalized"
28
- ],
22
+ provides: ["cmaf-timing", "media-time-probe"],
29
23
  install(ctx) {
30
24
  const timescales = /* @__PURE__ */ new Map();
31
- ctx.registerTransform({
32
- name: "cmaf-timing",
33
- order: ORDER,
34
- transform(data, meta) {
35
- if (meta.contentType !== "video" && meta.contentType !== "audio") return data;
36
- if (findBox(data, "moov") !== null) {
37
- const scales = trackTimescales(data);
38
- if (scales.size > 0) timescales.set(meta.contentType, scales);
39
- }
40
- if (findBox(data, "moof") !== null) {
41
- const scales = timescales.get(meta.contentType);
42
- if (scales !== void 0 && scales.size > 0) {
43
- var _;
44
- const fallback = (_ = [...scales.values()][0]) !== null && _ !== void 0 ? _ : 0;
45
- normalizeTfdt(data, meta.start, scales, fallback);
46
- }
47
- }
48
- return data;
25
+ ctx.registerTimeProbe((data, meta) => {
26
+ if (meta.contentType !== "video" && meta.contentType !== "audio") return null;
27
+ if (findBox(data, "moov") !== null) {
28
+ const scales = trackTimescales(data);
29
+ if (scales.size > 0) timescales.set(meta.renditionId, scales);
49
30
  }
31
+ if (findBox(data, "moof") === null) return null;
32
+ const scales = timescales.get(meta.renditionId);
33
+ if (scales === void 0) return null;
34
+ return earliestDecodeTime(data, scales);
50
35
  });
51
36
  }
52
37
  };
@@ -1,4 +1,16 @@
1
+ import { findRendition } from "../../kernel/presentation.js";
1
2
  //#region src/stages/cmcd/index.ts
3
+ /**
4
+ * Common Media Client Data (CTA-5004). The engine already exposes the seam
5
+ * this needs: a request hook that sees every outgoing segment and manifest
6
+ * URL. This stage reads playback state through the stage context and appends
7
+ * the CMCD keys a CDN reads to understand the session, as either a query
8
+ * argument or request headers.
9
+ *
10
+ * It computes nothing the kernel does not already track: the active rendition
11
+ * bitrate, the measured throughput EWMA, and the buffer ahead of the playhead
12
+ * from the media element. No new kernel state, no new effect.
13
+ */
2
14
  /** The CMCD object type, inferred from the URL the request is fetching. */
3
15
  function objectType(url) {
4
16
  if (/\.(m3u8|mpd)(\?|$)/i.test(url)) return "m";
@@ -24,9 +36,22 @@ function serialize(keys) {
24
36
  return `${key}=${value}`;
25
37
  }).join(",");
26
38
  }
39
+ /**
40
+ * A version 4 UUID for `sid` (CTA-5004 recommends a UUID). randomUUID
41
+ * exists only in secure contexts, so plain-HTTP pages build one from
42
+ * getRandomValues, which every context has (RFC 9562 §5.4).
43
+ */
44
+ function sessionUuid() {
45
+ if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
46
+ const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
47
+ bytes[6] = bytes[6] & 15 | 64;
48
+ bytes[8] = bytes[8] & 63 | 128;
49
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
50
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
51
+ }
27
52
  function cmcd(options = {}) {
28
- var _ref, _options$sessionId, _globalThis$crypto, _globalThis$crypto$ra, _options$mode;
29
- const sessionId = (_ref = (_options$sessionId = options.sessionId) !== null && _options$sessionId !== void 0 ? _options$sessionId : (_globalThis$crypto = globalThis.crypto) === null || _globalThis$crypto === void 0 || (_globalThis$crypto$ra = _globalThis$crypto.randomUUID) === null || _globalThis$crypto$ra === void 0 ? void 0 : _globalThis$crypto$ra.call(_globalThis$crypto)) !== null && _ref !== void 0 ? _ref : `mb-${Math.random().toString(36).slice(2)}`;
53
+ var _options$sessionId, _options$mode;
54
+ const sessionId = (_options$sessionId = options.sessionId) !== null && _options$sessionId !== void 0 ? _options$sessionId : sessionUuid();
30
55
  const mode = (_options$mode = options.mode) !== null && _options$mode !== void 0 ? _options$mode : "query";
31
56
  return {
32
57
  name: "cmcd",
@@ -41,10 +66,8 @@ function cmcd(options = {}) {
41
66
  };
42
67
  if (options.contentId !== void 0) keys.cid = options.contentId;
43
68
  const activeId = state.quality.active;
44
- if (activeId !== null && state.presentation !== null) for (const period of state.presentation.periods) for (const track of period.tracks) {
45
- const rendition = track.renditions.find((r) => r.id === activeId);
46
- if (rendition !== void 0) keys.br = Math.round(rendition.bitrate / 1e3);
47
- }
69
+ const active = activeId === null ? null : findRendition(state.presentation, activeId);
70
+ if (active !== null) keys.br = Math.round(active.rendition.bitrate / 1e3);
48
71
  const mtp = state.stats.throughputEwma;
49
72
  if (mtp > 0) keys.mtp = Math.round(mtp / 1e3 / 100) * 100;
50
73
  const el = ctx.element;
@@ -1,3 +1,4 @@
1
+ import { typeString } from "../../kernel/mime.js";
1
2
  import { canSwitchTo } from "../../kernel/rendition-select.js";
2
3
  //#region src/stages/codec-switch/index.ts
3
4
  /**
@@ -15,17 +16,13 @@ import { canSwitchTo } from "../../kernel/rendition-select.js";
15
16
  * lies; until a runtime call site exists this policy reasons over the IR's
16
17
  * declared strings, which is already a real improvement.
17
18
  */
18
- /** A full MSE type string for a rendition, mime plus codecs. */
19
- function typeString(rendition) {
20
- return rendition.codecs === null ? rendition.mimeType : `${rendition.mimeType}; codecs="${rendition.codecs}"`;
21
- }
22
19
  /** Whether the runtime can bridge two types without tearing the buffer down. */
23
20
  function changeTypeSupported(target) {
24
21
  var _globalThis$SourceBuf;
25
22
  const MediaSourceCtor = typeof MediaSource !== "undefined" ? MediaSource : globalThis.ManagedMediaSource;
26
23
  if (MediaSourceCtor === void 0) return false;
27
24
  if (typeof ((_globalThis$SourceBuf = globalThis.SourceBuffer) === null || _globalThis$SourceBuf === void 0 || (_globalThis$SourceBuf = _globalThis$SourceBuf.prototype) === null || _globalThis$SourceBuf === void 0 ? void 0 : _globalThis$SourceBuf.changeType) !== "function") return false;
28
- return MediaSourceCtor.isTypeSupported(typeString(target));
25
+ return MediaSourceCtor.isTypeSupported(typeString(target.mimeType, target.codecs));
29
26
  }
30
27
  function createPolicy() {
31
28
  return (current, target) => {
@@ -1,5 +1,15 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import { scheduled, tickAfter } from "../../kernel/effects.js";
2
3
  //#region src/stages/content-steering/index.ts
4
+ /**
5
+ * Content steering: pathway switching from a steering manifest, plus
6
+ * failover when the active pathway starts failing. The two manifest
7
+ * families normalize into one model at parse time — HLS pathways are
8
+ * variant clones (renditions carry a pathway id), DASH pathways are
9
+ * BaseURL choices (the steering bases map) — so one stage serves both:
10
+ * rendition pathways apply through a 'steering' constraint, base pathways
11
+ * through a transport request hook rewriting URL prefixes.
12
+ */
3
13
  const MANIFEST_TOKEN = "steering:manifest";
4
14
  const RELOAD_TOKEN = "steering:reload";
5
15
  const PATHWAY_EVENT = "steering:pathway";
@@ -19,12 +29,7 @@ const INITIAL = {
19
29
  };
20
30
  /** Loops a message back into the bus through a zero-delay schedule effect. */
21
31
  function feed(message) {
22
- return {
23
- kind: "schedule",
24
- token: "steering:loopback",
25
- delayMs: 0,
26
- then: message
27
- };
32
+ return scheduled("steering:loopback", message);
28
33
  }
29
34
  function pathwaysOf(kernel) {
30
35
  var _kernel$presentation$, _kernel$presentation, _kernel$presentation$2, _kernel$presentation2;
@@ -131,15 +136,7 @@ const reduceSteering = (slice, msg, kernel) => {
131
136
  }
132
137
  if (!next.tickPending) {
133
138
  var _parsed$TTL;
134
- effects.push({
135
- kind: "schedule",
136
- token: RELOAD_TOKEN,
137
- delayMs: ((_parsed$TTL = parsed.TTL) !== null && _parsed$TTL !== void 0 ? _parsed$TTL : DEFAULT_TTL) * 1e3,
138
- then: {
139
- type: "TICK",
140
- token: RELOAD_TOKEN
141
- }
142
- });
139
+ effects.push(tickAfter(RELOAD_TOKEN, ((_parsed$TTL = parsed.TTL) !== null && _parsed$TTL !== void 0 ? _parsed$TTL : DEFAULT_TTL) * 1e3));
143
140
  next = _objectSpread2(_objectSpread2({}, next), {}, { tickPending: true });
144
141
  }
145
142
  return [next, effects];
@@ -1,17 +1,23 @@
1
+ import { base64ToBytes } from "../../kernel/base64.js";
1
2
  import { registerKeySystem } from "../drm-shared.js";
2
3
  //#region src/stages/eme-cenc/index.ts
4
+ /**
5
+ * Widevine and PlayReady over Common Encryption. Neither drives EME
6
+ * itself: each registers a key-system handler that eme-core negotiates and
7
+ * runs. The system-id UUIDs the dash parser already extracts, and the
8
+ * skd/pssh the hls parser stores, select the branch; the shaping here is
9
+ * the request body and the response unwrap each server expects.
10
+ */
3
11
  const WIDEVINE_SYSTEM_ID = "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";
4
12
  const PLAYREADY_SYSTEM_ID = "9a04f079-9840-4286-ab92-e65be0885f95";
5
13
  /** Pulls the license blob out of a PlayReady SOAP response, or passes bytes through. */
6
14
  function unwrapPlayReadyResponse(response) {
15
+ var _base64ToBytes;
7
16
  const text = new TextDecoder().decode(response);
8
17
  if (!text.includes("<License>")) return response;
9
18
  const match = /<License>([\s\S]*?)<\/License>/.exec(text);
10
19
  if (match === null) return response;
11
- const binary = atob(match[1].trim());
12
- const bytes = new Uint8Array(binary.length);
13
- for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);
14
- return bytes;
20
+ return (_base64ToBytes = base64ToBytes(match[1])) !== null && _base64ToBytes !== void 0 ? _base64ToBytes : response;
15
21
  }
16
22
  function emeCenc() {
17
23
  return {
@@ -1,13 +1,26 @@
1
- import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/objectSpread2.js";
2
- import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/asyncToGenerator.js";
1
+ import _objectSpread2 from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/objectSpread2.js";
2
+ import _asyncToGenerator from "../../_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/asyncToGenerator.js";
3
+ import { bytesToBase64 } from "../../kernel/base64.js";
3
4
  import { keySystemHandlers, normalizeSystemId } from "../drm-shared.js";
4
5
  //#region src/stages/eme-core/index.ts
6
+ /**
7
+ * The generic EME handshake, entanglement #3 resolved: DRM lands without
8
+ * touching a protocol adapter. Init data arrives by two routes — the
9
+ * manifest (protection descriptors already in the IR since Stage 08) and
10
+ * the media (the element's `encrypted` event) — and eme-core dedupes them
11
+ * by key id so the same key never opens two sessions.
12
+ *
13
+ * Everything here is the impure edge: MediaKeys and MediaKeySession are
14
+ * un-serializable and cannot enter the reducer, so this is an install-time
15
+ * controller. It reports through ctx.emit (drm:* events, and a fatal
16
+ * 'error' event that reaches engine.error) and exposes engine.drm; the
17
+ * trace stays complete for everything the reducer can see.
18
+ *
19
+ * ClearKey is built in — it is the only key system testable headlessly.
20
+ * Widevine, PlayReady, and FairPlay arrive as handlers eme-cenc and
21
+ * eme-fairplay register through drm-shared.
22
+ */
5
23
  const CLEARKEY = "org.w3.clearkey";
6
- function bytesToBase64Url(bytes) {
7
- let binary = "";
8
- for (const b of bytes) binary += String.fromCharCode(b);
9
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
10
- }
11
24
  /** A ClearKey handler: the license is a JSON the app answers from its keys. */
12
25
  function clearKeyHandler(clearKeys) {
13
26
  return {
@@ -106,13 +119,16 @@ function emeCore(options = {}) {
106
119
  const handlers = allHandlers();
107
120
  const ordered = options.preferredKeySystems ? [...handlers].sort((a, b) => options.preferredKeySystems.indexOf(a.keySystem) - options.preferredKeySystems.indexOf(b.keySystem)) : handlers;
108
121
  const candidates = preferredSystemIds.length > 0 ? ordered.filter((h) => h.systemIds.some((id) => preferredSystemIds.includes(id))) : ordered;
122
+ let lastError;
109
123
  for (const candidate of candidates.length > 0 ? candidates : ordered) try {
110
124
  var _candidate$fairplay;
111
125
  const keys = yield (yield navigator.requestMediaKeySystemAccess(candidate.keySystem, accessConfig(candidate))).createMediaKeys();
112
126
  if (disposed) return false;
113
127
  if (((_candidate$fairplay = candidate.fairplay) === null || _candidate$fairplay === void 0 ? void 0 : _candidate$fairplay.certificateUrl) !== void 0) {
114
- const cert = yield ctx.request(candidate.fairplay.certificateUrl, {}).then((r) => r.arrayBuffer());
115
- yield keys.setServerCertificate(cert);
128
+ const url = candidate.fairplay.certificateUrl;
129
+ const response = yield ctx.request(url, {});
130
+ if (!response.ok) throw new Error(`certificate ${url}: HTTP ${response.status}`);
131
+ yield keys.setServerCertificate(yield response.arrayBuffer());
116
132
  }
117
133
  yield element.setMediaKeys(keys);
118
134
  mediaKeys = keys;
@@ -120,8 +136,10 @@ function emeCore(options = {}) {
120
136
  handler = candidate;
121
137
  ctx.emit("drm:keysystem", { keySystem });
122
138
  return true;
123
- } catch (_unused) {}
124
- fail("DRM_KEY_SYSTEM_UNAVAILABLE", false);
139
+ } catch (err) {
140
+ lastError = err;
141
+ }
142
+ fail("DRM_KEY_SYSTEM_UNAVAILABLE", false, lastError);
125
143
  return false;
126
144
  });
127
145
  return _ensureKeys.apply(this, arguments);
@@ -133,7 +151,7 @@ function emeCore(options = {}) {
133
151
  function _openSession() {
134
152
  _openSession = _asyncToGenerator(function* (initDataType, initData) {
135
153
  if (mediaKeys === null || handler === null || disposed) return;
136
- const fingerprint = `${initDataType}:${bytesToBase64Url(new Uint8Array(initData))}`;
154
+ const fingerprint = `${initDataType}:${bytesToBase64(new Uint8Array(initData), true)}`;
137
155
  if (initDataSeen.has(fingerprint)) return;
138
156
  initDataSeen.add(fingerprint);
139
157
  let session;
@@ -196,7 +214,7 @@ function emeCore(options = {}) {
196
214
  }
197
215
  function onKeyStatus(session) {
198
216
  session.keyStatuses.forEach((status, keyIdBuffer) => {
199
- const keyId = bytesToBase64Url(new Uint8Array(keyIdBuffer));
217
+ const keyId = bytesToBase64(new Uint8Array(keyIdBuffer), true);
200
218
  statuses.set(keyId, status);
201
219
  sessionsByKey.set(keyId, session);
202
220
  ctx.emit("drm:keystatus", {