@mattebox/player 0.6.0 → 0.8.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 (290) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -435
  2. package/dist/controls/airplay.js +28 -44
  3. package/dist/controls/airplay.js.map +1 -1
  4. package/dist/controls/chapters.d.ts +22 -11
  5. package/dist/controls/chapters.d.ts.map +1 -1
  6. package/dist/controls/chapters.js +87 -73
  7. package/dist/controls/chapters.js.map +1 -1
  8. package/dist/controls/cues.d.ts +0 -22
  9. package/dist/controls/cues.d.ts.map +1 -1
  10. package/dist/controls/cues.js +161 -191
  11. package/dist/controls/cues.js.map +1 -1
  12. package/dist/controls/fullscreen.js +52 -70
  13. package/dist/controls/fullscreen.js.map +1 -1
  14. package/dist/controls/icons.d.ts +4 -2
  15. package/dist/controls/icons.d.ts.map +1 -1
  16. package/dist/controls/icons.js +46 -70
  17. package/dist/controls/icons.js.map +1 -1
  18. package/dist/controls/markers.d.ts +39 -0
  19. package/dist/controls/markers.d.ts.map +1 -0
  20. package/dist/controls/markers.js +38 -0
  21. package/dist/controls/markers.js.map +1 -0
  22. package/dist/controls/menu.d.ts +8 -4
  23. package/dist/controls/menu.d.ts.map +1 -1
  24. package/dist/controls/menu.js +261 -223
  25. package/dist/controls/menu.js.map +1 -1
  26. package/dist/controls/native-tracks.d.ts +28 -0
  27. package/dist/controls/native-tracks.d.ts.map +1 -0
  28. package/dist/controls/native-tracks.js +30 -0
  29. package/dist/controls/native-tracks.js.map +1 -0
  30. package/dist/controls/pip.js +35 -49
  31. package/dist/controls/pip.js.map +1 -1
  32. package/dist/controls/quality-names.d.ts +15 -0
  33. package/dist/controls/quality-names.d.ts.map +1 -0
  34. package/dist/controls/quality-names.js +62 -0
  35. package/dist/controls/quality-names.js.map +1 -0
  36. package/dist/controls/ranges.js +42 -37
  37. package/dist/controls/ranges.js.map +1 -1
  38. package/dist/controls/session.d.ts +6 -1
  39. package/dist/controls/session.d.ts.map +1 -1
  40. package/dist/controls/session.js +41 -26
  41. package/dist/controls/session.js.map +1 -1
  42. package/dist/controls/slider.d.ts +2 -2
  43. package/dist/controls/slider.d.ts.map +1 -1
  44. package/dist/controls/slider.js +151 -159
  45. package/dist/controls/slider.js.map +1 -1
  46. package/dist/controls/time.js +17 -17
  47. package/dist/controls/time.js.map +1 -1
  48. package/dist/controls/track-names.d.ts +40 -0
  49. package/dist/controls/track-names.d.ts.map +1 -0
  50. package/dist/controls/track-names.js +59 -0
  51. package/dist/controls/track-names.js.map +1 -0
  52. package/dist/dom.d.ts +6 -0
  53. package/dist/dom.d.ts.map +1 -1
  54. package/dist/dom.js +28 -19
  55. package/dist/dom.js.map +1 -1
  56. package/dist/element-entry.js +9 -6
  57. package/dist/element-entry.js.map +1 -1
  58. package/dist/element.d.ts +28 -2
  59. package/dist/element.d.ts.map +1 -1
  60. package/dist/element.js +426 -442
  61. package/dist/element.js.map +1 -1
  62. package/dist/elements/airplay-button.js +51 -53
  63. package/dist/elements/airplay-button.js.map +1 -1
  64. package/dist/elements/audio-menu.d.ts +19 -8
  65. package/dist/elements/audio-menu.d.ts.map +1 -1
  66. package/dist/elements/audio-menu.js +103 -65
  67. package/dist/elements/audio-menu.js.map +1 -1
  68. package/dist/elements/chapters-menu.d.ts.map +1 -1
  69. package/dist/elements/chapters-menu.js +75 -65
  70. package/dist/elements/chapters-menu.js.map +1 -1
  71. package/dist/elements/component.d.ts +1 -1
  72. package/dist/elements/component.d.ts.map +1 -1
  73. package/dist/elements/component.js +86 -89
  74. package/dist/elements/component.js.map +1 -1
  75. package/dist/elements/control-bar.d.ts +18 -5
  76. package/dist/elements/control-bar.d.ts.map +1 -1
  77. package/dist/elements/control-bar.js +282 -319
  78. package/dist/elements/control-bar.js.map +1 -1
  79. package/dist/elements/current-time.js +26 -25
  80. package/dist/elements/current-time.js.map +1 -1
  81. package/dist/elements/drm-badge.d.ts +3 -2
  82. package/dist/elements/drm-badge.d.ts.map +1 -1
  83. package/dist/elements/drm-badge.js +109 -141
  84. package/dist/elements/drm-badge.js.map +1 -1
  85. package/dist/elements/duration.d.ts.map +1 -1
  86. package/dist/elements/duration.js +24 -21
  87. package/dist/elements/duration.js.map +1 -1
  88. package/dist/elements/error-screen.d.ts.map +1 -1
  89. package/dist/elements/error-screen.js +68 -102
  90. package/dist/elements/error-screen.js.map +1 -1
  91. package/dist/elements/fullscreen-button.js +48 -54
  92. package/dist/elements/fullscreen-button.js.map +1 -1
  93. package/dist/elements/live-button.d.ts.map +1 -1
  94. package/dist/elements/live-button.js +67 -94
  95. package/dist/elements/live-button.js.map +1 -1
  96. package/dist/elements/marker-button.d.ts +22 -0
  97. package/dist/elements/marker-button.d.ts.map +1 -0
  98. package/dist/elements/marker-button.js +99 -0
  99. package/dist/elements/marker-button.js.map +1 -0
  100. package/dist/elements/menu-element.js +31 -28
  101. package/dist/elements/menu-element.js.map +1 -1
  102. package/dist/elements/mute-button.js +58 -59
  103. package/dist/elements/mute-button.js.map +1 -1
  104. package/dist/elements/pip-button.js +54 -54
  105. package/dist/elements/pip-button.js.map +1 -1
  106. package/dist/elements/play-button.d.ts.map +1 -1
  107. package/dist/elements/play-button.js +73 -58
  108. package/dist/elements/play-button.js.map +1 -1
  109. package/dist/elements/quality-menu.d.ts +4 -0
  110. package/dist/elements/quality-menu.d.ts.map +1 -1
  111. package/dist/elements/quality-menu.js +82 -71
  112. package/dist/elements/quality-menu.js.map +1 -1
  113. package/dist/elements/remaining-time.d.ts.map +1 -1
  114. package/dist/elements/remaining-time.js +27 -24
  115. package/dist/elements/remaining-time.js.map +1 -1
  116. package/dist/elements/scan-button.d.ts +17 -0
  117. package/dist/elements/scan-button.d.ts.map +1 -0
  118. package/dist/elements/scan-button.js +117 -0
  119. package/dist/elements/scan-button.js.map +1 -0
  120. package/dist/elements/seek-bar.d.ts +99 -15
  121. package/dist/elements/seek-bar.d.ts.map +1 -1
  122. package/dist/elements/seek-bar.js +487 -336
  123. package/dist/elements/seek-bar.js.map +1 -1
  124. package/dist/elements/shared.d.ts +3 -11
  125. package/dist/elements/shared.d.ts.map +1 -1
  126. package/dist/elements/shared.js +44 -144
  127. package/dist/elements/shared.js.map +1 -1
  128. package/dist/elements/skip-button.d.ts.map +1 -1
  129. package/dist/elements/skip-button.js +54 -55
  130. package/dist/elements/skip-button.js.map +1 -1
  131. package/dist/elements/spacer.d.ts.map +1 -1
  132. package/dist/elements/spacer.js +12 -7
  133. package/dist/elements/spacer.js.map +1 -1
  134. package/dist/elements/speed-menu.js +60 -55
  135. package/dist/elements/speed-menu.js.map +1 -1
  136. package/dist/elements/spinner.d.ts.map +1 -1
  137. package/dist/elements/spinner.js +52 -78
  138. package/dist/elements/spinner.js.map +1 -1
  139. package/dist/elements/start-button.d.ts.map +1 -1
  140. package/dist/elements/start-button.js +107 -120
  141. package/dist/elements/start-button.js.map +1 -1
  142. package/dist/elements/subtitles-menu.d.ts +2 -0
  143. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  144. package/dist/elements/subtitles-menu.js +119 -103
  145. package/dist/elements/subtitles-menu.js.map +1 -1
  146. package/dist/elements/time-element.d.ts.map +1 -1
  147. package/dist/elements/time-element.js +36 -28
  148. package/dist/elements/time-element.js.map +1 -1
  149. package/dist/elements/title.d.ts.map +1 -1
  150. package/dist/elements/title.js +105 -137
  151. package/dist/elements/title.js.map +1 -1
  152. package/dist/elements/volume-slider.d.ts.map +1 -1
  153. package/dist/elements/volume-slider.js +47 -45
  154. package/dist/elements/volume-slider.js.map +1 -1
  155. package/dist/elements/volume.d.ts.map +1 -1
  156. package/dist/elements/volume.js +42 -50
  157. package/dist/elements/volume.js.map +1 -1
  158. package/dist/entries/airplay-button.js +7 -7
  159. package/dist/entries/airplay-button.js.map +1 -1
  160. package/dist/entries/audio-menu.js +7 -6
  161. package/dist/entries/audio-menu.js.map +1 -1
  162. package/dist/entries/chapters-menu.js +7 -7
  163. package/dist/entries/chapters-menu.js.map +1 -1
  164. package/dist/entries/control-bar.js +7 -6
  165. package/dist/entries/control-bar.js.map +1 -1
  166. package/dist/entries/current-time.js +7 -6
  167. package/dist/entries/current-time.js.map +1 -1
  168. package/dist/entries/drm-badge.js +7 -6
  169. package/dist/entries/drm-badge.js.map +1 -1
  170. package/dist/entries/duration.js +7 -6
  171. package/dist/entries/duration.js.map +1 -1
  172. package/dist/entries/error-screen.js +7 -6
  173. package/dist/entries/error-screen.js.map +1 -1
  174. package/dist/entries/fullscreen-button.js +7 -6
  175. package/dist/entries/fullscreen-button.js.map +1 -1
  176. package/dist/entries/live-button.js +7 -6
  177. package/dist/entries/live-button.js.map +1 -1
  178. package/dist/entries/marker-button.d.ts +5 -0
  179. package/dist/entries/marker-button.d.ts.map +1 -0
  180. package/dist/entries/marker-button.js +9 -0
  181. package/dist/entries/marker-button.js.map +1 -0
  182. package/dist/entries/mute-button.js +7 -6
  183. package/dist/entries/mute-button.js.map +1 -1
  184. package/dist/entries/pip-button.js +7 -6
  185. package/dist/entries/pip-button.js.map +1 -1
  186. package/dist/entries/play-button.js +7 -6
  187. package/dist/entries/play-button.js.map +1 -1
  188. package/dist/entries/quality-menu.js +7 -6
  189. package/dist/entries/quality-menu.js.map +1 -1
  190. package/dist/entries/remaining-time.js +7 -7
  191. package/dist/entries/remaining-time.js.map +1 -1
  192. package/dist/entries/scan-button.d.ts +5 -0
  193. package/dist/entries/scan-button.d.ts.map +1 -0
  194. package/dist/entries/scan-button.js +9 -0
  195. package/dist/entries/scan-button.js.map +1 -0
  196. package/dist/entries/seek-bar.js +7 -6
  197. package/dist/entries/seek-bar.js.map +1 -1
  198. package/dist/entries/skip-button.js +7 -6
  199. package/dist/entries/skip-button.js.map +1 -1
  200. package/dist/entries/spacer.js +7 -6
  201. package/dist/entries/spacer.js.map +1 -1
  202. package/dist/entries/speed-menu.js +7 -6
  203. package/dist/entries/speed-menu.js.map +1 -1
  204. package/dist/entries/spinner.js +7 -7
  205. package/dist/entries/spinner.js.map +1 -1
  206. package/dist/entries/start-button.js +7 -6
  207. package/dist/entries/start-button.js.map +1 -1
  208. package/dist/entries/subtitles-menu.js +7 -6
  209. package/dist/entries/subtitles-menu.js.map +1 -1
  210. package/dist/entries/title.js +7 -7
  211. package/dist/entries/title.js.map +1 -1
  212. package/dist/entries/volume-slider.js +7 -6
  213. package/dist/entries/volume-slider.js.map +1 -1
  214. package/dist/entries/volume.js +9 -8
  215. package/dist/entries/volume.js.map +1 -1
  216. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  217. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  218. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  219. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  220. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  221. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  222. package/dist/es2015/controls/chapters.js +40 -7
  223. package/dist/es2015/controls/cues.js +1 -8
  224. package/dist/es2015/controls/icons.js +27 -25
  225. package/dist/es2015/controls/markers.js +36 -0
  226. package/dist/es2015/controls/menu.js +49 -10
  227. package/dist/es2015/controls/native-tracks.js +29 -0
  228. package/dist/es2015/controls/quality-names.js +67 -0
  229. package/dist/es2015/controls/session.js +16 -4
  230. package/dist/es2015/controls/slider.js +5 -4
  231. package/dist/es2015/controls/track-names.js +57 -0
  232. package/dist/es2015/dom.js +10 -1
  233. package/dist/es2015/element.js +71 -13
  234. package/dist/es2015/elements/audio-menu.js +62 -19
  235. package/dist/es2015/elements/chapters-menu.js +18 -10
  236. package/dist/es2015/elements/control-bar.js +41 -35
  237. package/dist/es2015/elements/drm-badge.js +12 -33
  238. package/dist/es2015/elements/duration.js +2 -1
  239. package/dist/es2015/elements/error-screen.js +1 -30
  240. package/dist/es2015/elements/live-button.js +1 -29
  241. package/dist/es2015/elements/marker-button.js +100 -0
  242. package/dist/es2015/elements/menu-element.js +2 -2
  243. package/dist/es2015/elements/play-button.js +10 -3
  244. package/dist/es2015/elements/quality-menu.js +22 -7
  245. package/dist/es2015/elements/remaining-time.js +2 -1
  246. package/dist/es2015/elements/scan-button.js +118 -0
  247. package/dist/es2015/elements/seek-bar.js +295 -90
  248. package/dist/es2015/elements/shared.js +5 -106
  249. package/dist/es2015/elements/skip-button.js +2 -1
  250. package/dist/es2015/elements/spacer.js +2 -1
  251. package/dist/es2015/elements/spinner.js +1 -32
  252. package/dist/es2015/elements/start-button.js +8 -26
  253. package/dist/es2015/elements/subtitles-menu.js +39 -11
  254. package/dist/es2015/elements/time-element.js +1 -4
  255. package/dist/es2015/elements/title.js +1 -45
  256. package/dist/es2015/elements/volume-slider.js +2 -1
  257. package/dist/es2015/elements/volume.js +1 -11
  258. package/dist/es2015/entries/marker-button.js +7 -0
  259. package/dist/es2015/entries/scan-button.js +7 -0
  260. package/dist/es2015/index.js +5 -1
  261. package/dist/es2015/presets.js +1 -1
  262. package/dist/es2015/style.js +1 -101
  263. package/dist/es2015/tags.js +3 -1
  264. package/dist/host.d.ts +3 -0
  265. package/dist/host.d.ts.map +1 -1
  266. package/dist/host.js +19 -17
  267. package/dist/host.js.map +1 -1
  268. package/dist/index.d.ts +7 -0
  269. package/dist/index.d.ts.map +1 -1
  270. package/dist/index.js +57 -27
  271. package/dist/labels.js +13 -9
  272. package/dist/labels.js.map +1 -1
  273. package/dist/namespaces.d.ts +9 -26
  274. package/dist/namespaces.d.ts.map +1 -1
  275. package/dist/namespaces.js +6 -2
  276. package/dist/namespaces.js.map +1 -1
  277. package/dist/presets.js +33 -28
  278. package/dist/presets.js.map +1 -1
  279. package/dist/style.d.ts +1 -20
  280. package/dist/style.d.ts.map +1 -1
  281. package/dist/style.js +4 -100
  282. package/dist/style.js.map +1 -1
  283. package/dist/surface.js +25 -21
  284. package/dist/surface.js.map +1 -1
  285. package/dist/tags.d.ts +2 -0
  286. package/dist/tags.d.ts.map +1 -1
  287. package/dist/tags.js +32 -26
  288. package/dist/tags.js.map +1 -1
  289. package/package.json +4 -4
  290. package/dist/index.js.map +0 -1
package/dist/element.js CHANGED
@@ -1,456 +1,440 @@
1
+ import { createMarkers } from "./controls/markers.js";
2
+ import { namespaces } from "./namespaces.js";
3
+ import { drmGuard, resolvePreset } from "./presets.js";
4
+ import { STYLE } from "./style.js";
5
+ import { errorSurface } from "./surface.js";
6
+ import { PLAYER } from "./tags.js";
7
+ import { createPlayer, inferType, matteboxHandler, nativeHandler, preferNativeHls } from "@mattebox/player-core";
8
+ //#region src/element.ts
1
9
  /**
2
- * <mattebox-player>: a real <video> as a light-DOM child, so the integrator
3
- * can reach it, and the error surface in shadow DOM. The element never
4
- * forwards or wraps a media element member: play, pause, seek, volume and
5
- * the rest live on the video, where the browser, Picture-in-Picture and the
6
- * OS media session already find them.
7
- *
8
- * The controls are elements the page places inside, beside the video, and
9
- * the stage slots them over the picture. The element appends none of its
10
- * own: the composition is the page's in every mode, and `none` hides every
11
- * child but the video. The element reflects the video's state as
12
- * attributes on itself, `paused`, `playing`, `ended`, `muted`, `audio`,
13
- * `started` and `waiting`, for the page's stylesheet and the controls
14
- * alike.
15
- *
16
- * No class fields, `#private` or otherwise: the ES2015 build would lower
17
- * them into runtime helpers, and the emit check bans helpers. Statics are
18
- * getters and instance state is declared, then assigned in the constructor.
19
- */
20
- import { createPlayer, inferType, matteboxHandler, nativeHandler } from '@mattebox/player-core';
21
- import { namespaces } from './namespaces.js';
22
- import { drmGuard, resolvePreset } from './presets.js';
23
- import { STYLE } from './style.js';
24
- import { errorSurface } from './surface.js';
25
- import { PLAYER } from './tags.js';
10
+ * `off` keeps HLS on the engine in Safari. Anything else lets Safari play
11
+ * HLS itself: FairPlay, AirPlay, Low-Latency HLS and the platform's
12
+ * fullscreen then work as Apple built them. Changing it reloads.
13
+ */
14
+ const NATIVE_HLS = "native-hls";
26
15
  /** Attributes forwarded onto the video as attributes, never as properties. */
27
- const FORWARDED = ['autoplay', 'muted', 'poster', 'crossorigin'];
16
+ const FORWARDED = [
17
+ "autoplay",
18
+ "muted",
19
+ "poster",
20
+ "crossorigin"
21
+ ];
28
22
  /** Everything else the element watches. Changing any of them reloads. */
29
- const OWN = ['src', 'type', 'preset', 'license-url', 'thumbnails'];
23
+ const OWN = [
24
+ "src",
25
+ "type",
26
+ "preset",
27
+ "license-url",
28
+ "certificate-url",
29
+ "thumbnails",
30
+ NATIVE_HLS
31
+ ];
30
32
  /**
31
- * The chapters track URL. A `<track kind="chapters">` on the video, hidden
32
- * so its cues load and nothing is drawn: chapters are the browser's own
33
- * text track, which the seek bar and the chapters menu read, and which a
34
- * page can also put there itself. Changing it swaps the track and never
35
- * reloads the source.
36
- */
37
- const CHAPTERS = 'chapters';
33
+ * The chapters file URL. A session with the engine's `chapters` namespace
34
+ * loads it there: through the engine's transport, so request hooks apply,
35
+ * and in every format the engine reads. Any other session gets a
36
+ * `<track kind="chapters">` on the video, hidden so its cues load and
37
+ * nothing is drawn. The seek bar and the chapters menu read either.
38
+ * Changing it never reloads the source.
39
+ */
40
+ const CHAPTERS = "chapters";
38
41
  /**
39
- * The one attribute whose meaning the element owns: `native` keeps the
40
- * browser's controls on the video, `custom` swaps them for the controls the
41
- * page placed inside, `none` takes the browser's off and hides every child
42
- * but the video. Anything else is `native`. Changing it never touches the
43
- * session.
44
- */
45
- const CONTROLS = 'controls';
42
+ * The one attribute whose meaning the element owns: `native` keeps the
43
+ * browser's controls on the video, `custom` swaps them for the controls the
44
+ * page placed inside, `none` takes the browser's off and hides every child
45
+ * but the video. Anything else is `native`. Changing it never touches the
46
+ * session.
47
+ */
48
+ const CONTROLS = "controls";
46
49
  /**
47
- * Inline playback, on until the page writes `playsinline="false"`, the way
48
- * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes
49
- * a video without `playsinline` to its own fullscreen on play, where no
50
- * control the page placed shows. Changing it never reloads.
51
- */
52
- const PLAYSINLINE = 'playsinline';
50
+ * Inline playback, on until the page writes `playsinline="false"`, the way
51
+ * `spellcheck` and `draggable` are on until told otherwise. An iPhone takes
52
+ * a video without `playsinline` to its own fullscreen on play, where no
53
+ * control the page placed shows. Changing it never reloads.
54
+ */
55
+ const PLAYSINLINE = "playsinline";
53
56
  /** The video's state, as attributes on the element, read on the events the video fires for it. */
54
57
  const STATE_EVENTS = [
55
- 'play',
56
- 'pause',
57
- 'ended',
58
- 'emptied',
59
- 'volumechange',
60
- 'loadedmetadata',
61
- 'resize',
62
- 'playing',
63
- 'waiting',
64
- 'stalled',
65
- 'canplay',
58
+ "play",
59
+ "pause",
60
+ "ended",
61
+ "seeked",
62
+ "emptied",
63
+ "volumechange",
64
+ "loadedmetadata",
65
+ "resize",
66
+ "playing",
67
+ "waiting",
68
+ "stalled",
69
+ "canplay"
66
70
  ];
71
+ /** The stages that register a key system, which a native session's DRM offers. */
72
+ const KEY_SYSTEMS = ["eme-fairplay", "eme-cenc"];
67
73
  /** Every stage the engine ships. A narrower preset is optimization. */
68
- const DEFAULT_PRESET = 'full';
74
+ const DEFAULT_PRESET = "full";
69
75
  /**
70
- * What `define()` recorded, for the elements the parser creates. It is the
71
- * one value shared across elements, because a page that writes only markup
72
- * still has to be able to say what the engine carries.
73
- */
76
+ * What `define()` recorded, for the elements the parser creates. It is the
77
+ * one value shared across elements, because a page that writes only markup
78
+ * still has to be able to say what the engine carries.
79
+ */
74
80
  let defaults = {};
75
81
  /**
76
- * The interface above merges only `addEventListener` and `removeEventListener`
77
- * overloads, which the class inherits from HTMLElement. The rule it suppresses
78
- * guards against properties an interface declares and a constructor never
79
- * assigns, and there are none.
80
- */
81
- // biome-ignore lint/suspicious/noUnsafeDeclarationMerging: method overloads only, no properties
82
- export class MatteboxPlayerElement extends HTMLElement {
83
- static get observedAttributes() {
84
- return [...FORWARDED, ...OWN, CONTROLS, CHAPTERS, PLAYSINLINE];
85
- }
86
- /**
87
- * Registers the element once, and records the stages markup-only pages
88
- * get. The controls register through their own entries, the package's
89
- * root entry importing every one; a control connected before its player
90
- * is defined waits for the definition.
91
- */
92
- static define(options) {
93
- if (options !== undefined)
94
- defaults = options;
95
- if (customElements.get(PLAYER) === undefined) {
96
- customElements.define(PLAYER, MatteboxPlayerElement);
97
- }
98
- }
99
- constructor(options) {
100
- super();
101
- this.options = options ?? defaults;
102
- this.focusable = false;
103
- this.track = null;
104
- this.core = null;
105
- this.current = null;
106
- this.failure = null;
107
- this.reflecting = false;
108
- this.started = false;
109
- this.waiting = false;
110
- this.offs = [];
111
- this.queue = Promise.resolve();
112
- this.pending = false;
113
- this.media = document.createElement('video');
114
- // Native until the `controls` attribute says otherwise, which arrives
115
- // through attributeChangedCallback: a constructor must not read attributes.
116
- this.media.controls = true;
117
- // Inline is the default, and the player's own attribute has not arrived
118
- // yet. Set as an attribute: not every browser has the `playsInline`
119
- // property. The fullscreen button still reaches the iPhone's fullscreen,
120
- // through `webkitEnterFullscreen`.
121
- this.media.setAttribute(PLAYSINLINE, '');
122
- for (const name of STATE_EVENTS) {
123
- this.media.addEventListener(name, () => {
124
- this.note(name);
125
- this.reflect();
126
- });
127
- }
128
- // An error over a picture that then plays is wrong by definition.
129
- this.media.addEventListener('playing', () => {
130
- this.failure = null;
131
- });
132
- this.stage = document.createElement('div');
133
- this.stage.setAttribute('part', 'stage');
134
- this.stage.append(document.createElement('slot'));
135
- this.surface = errorSurface(() => {
136
- this.reload();
137
- });
138
- const root = this.attachShadow({ mode: 'open' });
139
- const style = document.createElement('style');
140
- style.textContent = STYLE;
141
- root.append(style, this.stage, this.surface.root);
142
- }
143
- /** The media element. Everything the browser already does is here. */
144
- get video() {
145
- return this.media;
146
- }
147
- /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
148
- get player() {
149
- return this.core;
150
- }
151
- /** The engine feeding the video, or null for a native session and before the first load. */
152
- get engine() {
153
- return this.current?.engine ?? null;
154
- }
155
- /**
156
- * The fatal error of the current load, or null once a load starts or
157
- * playback resumes. The `error` event says when; this says what, for a
158
- * control that attaches after the event, such as an error screen parsed
159
- * after a source that failed while the page was still loading.
160
- */
161
- get error() {
162
- return this.failure;
163
- }
164
- connectedCallback() {
165
- if (this.media.parentNode !== this)
166
- this.append(this.media);
167
- for (const name of FORWARDED)
168
- this.forward(name);
169
- this.reflect();
170
- this.reload();
171
- }
172
- /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
173
- note(event) {
174
- if (event === 'playing') {
175
- this.started = true;
176
- this.waiting = false;
177
- }
178
- else if (event === 'waiting' || event === 'stalled') {
179
- this.waiting = true;
180
- }
181
- else if (event === 'canplay') {
182
- this.waiting = false;
183
- }
184
- else if (event === 'emptied') {
185
- // A new source starts over: the title shows again before its first play.
186
- this.started = false;
187
- this.waiting = false;
188
- }
189
- }
190
- /** The video's state on the element, for `mattebox-player[paused]` and the like. */
191
- reflect() {
192
- const video = this.media;
193
- this.reflecting = true;
194
- this.toggleAttribute('paused', video.paused);
195
- this.toggleAttribute('playing', !video.paused);
196
- this.toggleAttribute('ended', video.ended);
197
- // `muted` is also forwarded: the page's attribute sets the video, and
198
- // the video's state sets the attribute. Reflection never forwards, so
199
- // a read can only ever change the attribute, never the video.
200
- this.toggleAttribute('muted', video.muted);
201
- this.toggleAttribute('audio', this.audio());
202
- this.toggleAttribute('started', this.started);
203
- this.toggleAttribute('waiting', this.waiting);
204
- this.reflecting = false;
205
- }
206
- /**
207
- * Whether the source has no picture. Once the metadata is in, the video's
208
- * size decides: zero by zero is sound alone, and `resize` catches a stream
209
- * that moves to or from an audio-only rendition. Before that, the type the
210
- * page wrote or the URL implies is the hint, so an mp3 is `audio` from
211
- * the start rather than from its metadata.
212
- */
213
- audio() {
214
- const video = this.media;
215
- if (video.readyState >= HTMLMediaElement.HAVE_METADATA) {
216
- return video.videoWidth === 0 && video.videoHeight === 0;
217
- }
218
- const src = this.getAttribute('src');
219
- const type = this.getAttribute('type') ?? (src === null ? undefined : inferType(src));
220
- return type?.startsWith('audio/') === true;
221
- }
222
- disconnectedCallback() {
223
- // A single-page app must not leave a pipeline attached to a video it
224
- // navigated away from. Reconnecting loads the `src` again.
225
- this.enqueue(() => this.teardown());
226
- }
227
- attributeChangedCallback(name) {
228
- if (FORWARDED.includes(name)) {
229
- if (!this.reflecting)
230
- this.forward(name);
231
- return;
232
- }
233
- if (name === CONTROLS) {
234
- this.mode();
235
- return;
236
- }
237
- if (name === CHAPTERS) {
238
- this.chapters();
239
- return;
240
- }
241
- if (name === PLAYSINLINE) {
242
- // On the video it is a boolean attribute, so off is absent.
243
- this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== 'false');
244
- return;
245
- }
246
- // The preset decides the chain, so it is the one attribute that rebuilds it.
247
- if (name === 'preset')
248
- this.enqueue(() => this.discard());
249
- // The source's type is the hint for `audio` until its metadata arrives.
250
- // Only `audio`: a full reflection here would drop a `muted` the page
251
- // wrote before its own callback forwards it.
252
- if (name === 'src' || name === 'type')
253
- this.toggleAttribute('audio', this.audio());
254
- this.reload();
255
- }
256
- /**
257
- * Applies the `controls` attribute: the video's own controls and the
258
- * tabindex. The controls themselves are elements the page placed, and
259
- * they attach on their own; the element appends none.
260
- */
261
- mode() {
262
- const value = this.getAttribute(CONTROLS);
263
- const custom = value === 'custom';
264
- this.media.controls = !custom && value !== 'none';
265
- // Under custom controls the error screen element carries a fatal error.
266
- if (custom)
267
- this.surface.clear();
268
- if (!custom) {
269
- if (this.focusable)
270
- this.removeAttribute('tabindex');
271
- this.focusable = false;
272
- }
273
- else if (!this.hasAttribute('tabindex')) {
274
- // A bare video is not focusable, so without this a click on it would
275
- // leave the shortcuts nowhere to listen. A page that set its own
276
- // tabindex keeps it.
277
- this.tabIndex = 0;
278
- this.focusable = true;
279
- }
280
- }
281
- /** Keeps a hidden chapters track on the video for the `chapters` attribute, or none. */
282
- chapters() {
283
- const url = this.getAttribute(CHAPTERS);
284
- if (url === null) {
285
- this.track?.remove();
286
- this.track = null;
287
- return;
288
- }
289
- const held = this.track;
290
- if (held !== null && held.parentNode === this.media && held.getAttribute('src') === url)
291
- return;
292
- // A new element each time: one removed mid-load, as the engine's attach
293
- // does, stays in its error state, and neither a new `src` nor a second
294
- // insertion starts it loading again.
295
- held?.remove();
296
- const track = document.createElement('track');
297
- track.kind = 'chapters';
298
- track.src = url;
299
- this.track = track;
300
- this.media.append(track);
301
- // Set after the insertion: a track element's mode exists once it is in
302
- // a media element, and `hidden` is what makes its cues load unseen.
303
- track.track.mode = 'hidden';
304
- }
305
- forward(name) {
306
- const value = this.getAttribute(name);
307
- if (value === null)
308
- this.media.removeAttribute(name);
309
- else
310
- this.media.setAttribute(name, value);
311
- // A video reads `muted` into its state only when it is created, and this
312
- // one was created before any attribute reached it. Muted autoplay and
313
- // the autoplay policy read the state, so the attribute alone would not do.
314
- if (name === 'muted')
315
- this.media.muted = value !== null;
316
- }
317
- enqueue(task) {
318
- this.queue = this.queue.then(task, task).catch(() => undefined);
319
- }
320
- /**
321
- * One run per burst. The parser sets every attribute and then connects the
322
- * element before any queued task starts, and each of those would load on
323
- * its own; the flag folds them into the one run that sees the final state.
324
- */
325
- reload() {
326
- if (this.pending)
327
- return;
328
- this.pending = true;
329
- this.enqueue(() => {
330
- this.pending = false;
331
- return this.run();
332
- });
333
- }
334
- emit(name, detail) {
335
- this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
336
- }
337
- report(error) {
338
- if (error.fatal) {
339
- this.failure = error;
340
- // Under custom controls the error screen element is the surface, and
341
- // the element's own row under the video stays quiet.
342
- if (this.getAttribute(CONTROLS) !== 'custom')
343
- this.surface.show(error);
344
- }
345
- this.emit('error', error);
346
- }
347
- async run() {
348
- this.unmount();
349
- if (!this.isConnected)
350
- return;
351
- const url = this.getAttribute('src');
352
- if (url === null)
353
- return;
354
- const core = await this.ensure();
355
- const type = this.getAttribute('type');
356
- const source = type === null ? { url } : { url, type };
357
- this.failure = null;
358
- this.surface.clear();
359
- let session;
360
- try {
361
- session = await core.load(source);
362
- }
363
- catch {
364
- // The core already reported it on the error event, which the surface
365
- // and the element's own event both carry. Nothing to add here.
366
- return;
367
- }
368
- if (!this.isConnected) {
369
- await core.unload();
370
- return;
371
- }
372
- this.current = session;
373
- this.configure(session);
374
- // The engine's attach empties the media element to reset its resource
375
- // selection (`kernel/mse.ts`), and the chapters track goes with the
376
- // `<source>` children it means. Wanted: the track to survive attach.
377
- // Had to: put it back once the session is in. The surface that would
378
- // make it one call: an attach that removes `<source>` children alone.
379
- this.chapters();
380
- }
381
- async ensure() {
382
- if (this.core !== null)
383
- return this.core;
384
- const core = createPlayer(this.media, { handlers: await this.chain() });
385
- this.offs.push(core.on('sourcechange', (session) => {
386
- // Before the event goes out, so a control that reads `engine` on
387
- // `sourcechange` sees the session the event is about.
388
- this.current = session;
389
- this.emit('sourcechange', session);
390
- }), core.on('error', (error) => {
391
- this.report(error);
392
- }));
393
- this.core = core;
394
- return core;
395
- }
396
- async chain() {
397
- if (this.options.handlers !== undefined)
398
- return this.options.handlers;
399
- const config = this.options.config === undefined ? {} : { config: this.options.config };
400
- if (this.options.stages !== undefined) {
401
- return [matteboxHandler({ stages: this.options.stages, ...config }), nativeHandler()];
402
- }
403
- const name = this.getAttribute('preset') ?? DEFAULT_PRESET;
404
- const preset = await resolvePreset(name);
405
- if (preset === null) {
406
- this.report({
407
- category: 'config',
408
- code: 'CONFIG_INVALID',
409
- fatal: true,
410
- recoverable: false,
411
- handler: null,
412
- context: { preset: name },
413
- });
414
- return [nativeHandler()];
415
- }
416
- return [matteboxHandler({ preset, ...config, ...drmGuard() }), nativeHandler()];
417
- }
418
- /** What the attributes ask of the session's namespaces, once there is one. */
419
- configure(session) {
420
- const engine = session.engine;
421
- if (engine === null)
422
- return;
423
- const optional = namespaces(engine);
424
- const license = this.getAttribute('license-url');
425
- // After the session exists, not before: passing a license URL up front
426
- // means constructing eme-core, and importing a stage to configure it
427
- // would bundle it.
428
- if (license !== null && optional.drm !== undefined)
429
- optional.drm.setLicenseUrl(license);
430
- const track = this.getAttribute('thumbnails');
431
- if (track !== null && optional.thumbnails !== undefined) {
432
- // Loaded here; drawn by the seek bar's preview under `controls="custom"`.
433
- // Native controls expose no scrub position to anchor a preview to, so
434
- // under `native` the track only answers `engine.thumbnails.at(time)` for
435
- // the app. See docs/guide/03-the-element.md.
436
- void optional.thumbnails.load(track).catch(() => undefined);
437
- }
438
- }
439
- unmount() {
440
- this.current = null;
441
- }
442
- async teardown() {
443
- this.unmount();
444
- if (this.core !== null)
445
- await this.core.unload();
446
- }
447
- /** Drops the player itself, so the next run builds a chain from the new preset. */
448
- async discard() {
449
- await this.teardown();
450
- for (const off of this.offs)
451
- off();
452
- this.offs = [];
453
- this.core = null;
454
- }
455
- }
82
+ * The interface above merges only `addEventListener` and `removeEventListener`
83
+ * overloads, which the class inherits from HTMLElement. The rule it suppresses
84
+ * guards against properties an interface declares and a constructor never
85
+ * assigns, and there are none.
86
+ */
87
+ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
88
+ static get observedAttributes() {
89
+ return [
90
+ ...FORWARDED,
91
+ ...OWN,
92
+ CONTROLS,
93
+ CHAPTERS,
94
+ PLAYSINLINE
95
+ ];
96
+ }
97
+ /**
98
+ * Registers the element once, and records the stages markup-only pages
99
+ * get. The controls register through their own entries, the package's
100
+ * root entry importing every one; a control connected before its player
101
+ * is defined waits for the definition.
102
+ */
103
+ static define(options) {
104
+ if (options !== void 0) defaults = options;
105
+ if (customElements.get("mattebox-player") === void 0) customElements.define(PLAYER, MatteboxPlayerElement);
106
+ }
107
+ constructor(options) {
108
+ super();
109
+ this.options = options ?? defaults;
110
+ this.focusable = false;
111
+ this.track = null;
112
+ this.given = null;
113
+ this.core = null;
114
+ this.current = null;
115
+ this.failure = null;
116
+ this.reflecting = false;
117
+ this.started = false;
118
+ this.waiting = false;
119
+ this.offs = [];
120
+ this.queue = Promise.resolve();
121
+ this.pending = false;
122
+ this.media = document.createElement("video");
123
+ this.media.controls = true;
124
+ this.media.setAttribute(PLAYSINLINE, "");
125
+ for (const name of STATE_EVENTS) this.media.addEventListener(name, () => {
126
+ this.note(name);
127
+ this.reflect();
128
+ });
129
+ this.media.addEventListener("playing", () => {
130
+ this.failure = null;
131
+ });
132
+ this.marks = createMarkers(this.media, (name, detail) => this.emit(name, detail));
133
+ this.stage = document.createElement("div");
134
+ this.stage.setAttribute("part", "stage");
135
+ this.stage.append(document.createElement("slot"));
136
+ this.surface = errorSurface(() => {
137
+ this.reload();
138
+ });
139
+ const root = this.attachShadow({ mode: "open" });
140
+ const style = document.createElement("style");
141
+ style.textContent = STYLE;
142
+ root.append(style, this.stage, this.surface.root);
143
+ }
144
+ /** The media element. Everything the browser already does is here. */
145
+ get video() {
146
+ return this.media;
147
+ }
148
+ /** The ranges the page named in this source: credits to skip, parts that must not play. */
149
+ get markers() {
150
+ return this.marks;
151
+ }
152
+ /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
153
+ get player() {
154
+ return this.core;
155
+ }
156
+ /** The engine feeding the video, or null for a native session and before the first load. */
157
+ get engine() {
158
+ return this.current?.engine ?? null;
159
+ }
160
+ /**
161
+ * The fatal error of the current load, or null once a load starts or
162
+ * playback resumes. The `error` event says when; this says what, for a
163
+ * control that attaches after the event, such as an error screen parsed
164
+ * after a source that failed while the page was still loading.
165
+ */
166
+ get error() {
167
+ return this.failure;
168
+ }
169
+ connectedCallback() {
170
+ if (this.media.parentNode !== this) this.append(this.media);
171
+ for (const name of FORWARDED) this.forward(name);
172
+ this.reflect();
173
+ this.reload();
174
+ }
175
+ /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
176
+ note(event) {
177
+ if (event === "playing") {
178
+ this.started = true;
179
+ this.waiting = false;
180
+ } else if (event === "waiting" || event === "stalled") this.waiting = true;
181
+ else if (event === "canplay") this.waiting = false;
182
+ else if (event === "emptied") {
183
+ this.started = false;
184
+ this.waiting = false;
185
+ }
186
+ }
187
+ /** The video's state on the element, for `mattebox-player[paused]` and the like. */
188
+ reflect() {
189
+ const video = this.media;
190
+ this.reflecting = true;
191
+ this.toggleAttribute("paused", video.paused);
192
+ this.toggleAttribute("playing", !video.paused);
193
+ this.toggleAttribute("ended", video.ended);
194
+ this.toggleAttribute("muted", video.muted);
195
+ this.toggleAttribute("audio", this.audio());
196
+ this.toggleAttribute("started", this.started);
197
+ this.toggleAttribute("waiting", this.waiting);
198
+ this.reflecting = false;
199
+ }
200
+ /**
201
+ * Whether the source has no picture. Once the metadata is in, the video's
202
+ * size decides: zero by zero is sound alone, and `resize` catches a stream
203
+ * that moves to or from an audio-only rendition. Before that, the type the
204
+ * page wrote or the URL implies is the hint, so an mp3 is `audio` from
205
+ * the start rather than from its metadata.
206
+ */
207
+ audio() {
208
+ const video = this.media;
209
+ if (video.readyState >= HTMLMediaElement.HAVE_METADATA) return video.videoWidth === 0 && video.videoHeight === 0;
210
+ const src = this.getAttribute("src");
211
+ return (this.getAttribute("type") ?? (src === null ? void 0 : inferType(src)))?.startsWith("audio/") === true;
212
+ }
213
+ disconnectedCallback() {
214
+ this.enqueue(() => this.teardown());
215
+ }
216
+ attributeChangedCallback(name) {
217
+ if (FORWARDED.includes(name)) {
218
+ if (!this.reflecting) this.forward(name);
219
+ return;
220
+ }
221
+ if (name === CONTROLS) {
222
+ this.mode();
223
+ return;
224
+ }
225
+ if (name === CHAPTERS) {
226
+ this.chapters();
227
+ return;
228
+ }
229
+ if (name === PLAYSINLINE) {
230
+ this.media.toggleAttribute(PLAYSINLINE, this.getAttribute(PLAYSINLINE) !== "false");
231
+ return;
232
+ }
233
+ if (name === "preset") this.enqueue(() => this.discard());
234
+ if (name === "src" || name === "type") this.toggleAttribute("audio", this.audio());
235
+ if (name === "src" && this.marks.list.length > 0) this.marks.set([]);
236
+ this.reload();
237
+ }
238
+ /**
239
+ * Applies the `controls` attribute: the video's own controls and the
240
+ * tabindex. The controls themselves are elements the page placed, and
241
+ * they attach on their own; the element appends none.
242
+ */
243
+ mode() {
244
+ const value = this.getAttribute(CONTROLS);
245
+ const custom = value === "custom";
246
+ this.media.controls = !custom && value !== "none";
247
+ if (custom) this.surface.clear();
248
+ if (!custom) {
249
+ if (this.focusable) this.removeAttribute("tabindex");
250
+ this.focusable = false;
251
+ } else if (!this.hasAttribute("tabindex")) {
252
+ this.tabIndex = 0;
253
+ this.focusable = true;
254
+ }
255
+ }
256
+ /** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
257
+ chapters() {
258
+ const url = this.getAttribute(CHAPTERS);
259
+ const engine = this.current?.engine ?? null;
260
+ const api = engine === null ? void 0 : namespaces(engine).chapters;
261
+ if (api !== void 0) {
262
+ this.track?.remove();
263
+ this.track = null;
264
+ if (url === this.given) return;
265
+ this.given = url;
266
+ if (url === null) api.set([]);
267
+ else api.load(url).catch(() => void 0);
268
+ return;
269
+ }
270
+ if (url === null) {
271
+ this.track?.remove();
272
+ this.track = null;
273
+ return;
274
+ }
275
+ const held = this.track;
276
+ if (held !== null && held.parentNode === this.media && held.getAttribute("src") === url) return;
277
+ held?.remove();
278
+ const track = document.createElement("track");
279
+ track.kind = "chapters";
280
+ track.src = url;
281
+ this.track = track;
282
+ this.media.append(track);
283
+ track.track.mode = "hidden";
284
+ }
285
+ forward(name) {
286
+ const value = this.getAttribute(name);
287
+ if (value === null) this.media.removeAttribute(name);
288
+ else this.media.setAttribute(name, value);
289
+ if (name === "muted") this.media.muted = value !== null;
290
+ }
291
+ enqueue(task) {
292
+ this.queue = this.queue.then(task, task).catch(() => void 0);
293
+ }
294
+ /**
295
+ * One run per burst. The parser sets every attribute and then connects the
296
+ * element before any queued task starts, and each of those would load on
297
+ * its own; the flag folds them into the one run that sees the final state.
298
+ */
299
+ reload() {
300
+ if (this.pending) return;
301
+ this.pending = true;
302
+ this.enqueue(() => {
303
+ this.pending = false;
304
+ return this.run();
305
+ });
306
+ }
307
+ emit(name, detail) {
308
+ this.dispatchEvent(new CustomEvent(name, {
309
+ detail,
310
+ bubbles: true,
311
+ composed: true
312
+ }));
313
+ }
314
+ report(error) {
315
+ if (error.fatal) {
316
+ this.failure = error;
317
+ if (this.getAttribute(CONTROLS) !== "custom") this.surface.show(error);
318
+ }
319
+ this.emit("error", error);
320
+ }
321
+ async run() {
322
+ this.unmount();
323
+ if (!this.isConnected) return;
324
+ const url = this.getAttribute("src");
325
+ if (url === null) return;
326
+ const core = await this.ensure();
327
+ const type = this.getAttribute("type");
328
+ const source = type === null ? { url } : {
329
+ url,
330
+ type
331
+ };
332
+ this.failure = null;
333
+ this.surface.clear();
334
+ let session;
335
+ try {
336
+ session = await core.load(source);
337
+ } catch {
338
+ return;
339
+ }
340
+ if (!this.isConnected) {
341
+ await core.unload();
342
+ return;
343
+ }
344
+ this.current = session;
345
+ this.given = null;
346
+ this.configure(session);
347
+ this.chapters();
348
+ }
349
+ async ensure() {
350
+ if (this.core !== null) return this.core;
351
+ const core = createPlayer(this.media, { handlers: await this.chain() });
352
+ this.offs.push(core.on("sourcechange", (session) => {
353
+ this.current = session;
354
+ this.emit("sourcechange", session);
355
+ }), core.on("error", (error) => {
356
+ this.report(error);
357
+ }));
358
+ this.core = core;
359
+ return core;
360
+ }
361
+ async chain() {
362
+ if (this.options.handlers !== void 0) return this.options.handlers;
363
+ const config = this.options.config === void 0 ? {} : { config: this.options.config };
364
+ const native = (stages) => nativeHandler({
365
+ prefer: (source, env) => this.getAttribute(NATIVE_HLS) !== "off" && preferNativeHls(source, env),
366
+ drm: () => this.drm(stages)
367
+ });
368
+ if (this.options.stages !== void 0) return [matteboxHandler({
369
+ stages: this.options.stages,
370
+ ...config
371
+ }), native(() => this.options.stages ?? [])];
372
+ const name = this.getAttribute("preset") ?? DEFAULT_PRESET;
373
+ const preset = await resolvePreset(name);
374
+ if (preset === null) {
375
+ this.report({
376
+ category: "config",
377
+ code: "CONFIG_INVALID",
378
+ fatal: true,
379
+ recoverable: false,
380
+ handler: null,
381
+ context: { preset: name }
382
+ });
383
+ return [nativeHandler()];
384
+ }
385
+ return [matteboxHandler({
386
+ preset,
387
+ ...config,
388
+ ...drmGuard()
389
+ }), native(() => preset.stages())];
390
+ }
391
+ /**
392
+ * The DRM a native session attaches: the page's `drm` option, the
393
+ * key-system stages of the engine's stack, and the `license-url`
394
+ * attribute. None on a browser without EME, as for the engine.
395
+ */
396
+ drm(stages) {
397
+ if (drmGuard().without !== void 0) return void 0;
398
+ const keySystems = stages().filter((stage) => KEY_SYSTEMS.includes(stage.name));
399
+ const license = this.getAttribute("license-url");
400
+ const certificate = this.getAttribute("certificate-url");
401
+ const page = this.options.drm;
402
+ if (keySystems.length === 0 && license === null && page === void 0) return void 0;
403
+ return {
404
+ keySystems,
405
+ ...page,
406
+ ...license === null ? {} : { licenseUrl: license },
407
+ ...certificate === null ? {} : { certificateUrl: certificate }
408
+ };
409
+ }
410
+ /** What the attributes ask of the session's namespaces, once there is one. */
411
+ configure(session) {
412
+ const engine = session.engine;
413
+ if (engine === null) return;
414
+ const optional = namespaces(engine);
415
+ const license = this.getAttribute("license-url");
416
+ if (license !== null && optional.drm !== void 0) optional.drm.setLicenseUrl(license);
417
+ const certificate = this.getAttribute("certificate-url");
418
+ if (certificate !== null) optional.drm?.setCertificateUrl(certificate);
419
+ const track = this.getAttribute("thumbnails");
420
+ if (track !== null && optional.thumbnails !== void 0) optional.thumbnails.load(track).catch(() => void 0);
421
+ }
422
+ unmount() {
423
+ this.current = null;
424
+ }
425
+ async teardown() {
426
+ this.unmount();
427
+ if (this.core !== null) await this.core.unload();
428
+ }
429
+ /** Drops the player itself, so the next run builds a chain from the new preset. */
430
+ async discard() {
431
+ await this.teardown();
432
+ for (const off of this.offs) off();
433
+ this.offs = [];
434
+ this.core = null;
435
+ }
436
+ };
437
+ //#endregion
438
+ export { MatteboxPlayerElement };
439
+
456
440
  //# sourceMappingURL=element.js.map