@mattebox/player 0.10.0 → 0.12.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 (355) hide show
  1. package/dist/announcer.d.ts +6 -3
  2. package/dist/announcer.d.ts.map +1 -1
  3. package/dist/announcer.js +17 -14
  4. package/dist/announcer.js.map +1 -1
  5. package/dist/cdn/mattebox-player.min.js +3 -3
  6. package/dist/controls/airplay.js +1 -2
  7. package/dist/controls/chapters.js +1 -2
  8. package/dist/controls/cues.js +1 -2
  9. package/dist/controls/fullscreen.js +1 -2
  10. package/dist/controls/icons.d.ts +1 -1
  11. package/dist/controls/icons.d.ts.map +1 -1
  12. package/dist/controls/icons.js +2 -2
  13. package/dist/controls/icons.js.map +1 -1
  14. package/dist/controls/markers.d.ts +2 -15
  15. package/dist/controls/markers.d.ts.map +1 -1
  16. package/dist/controls/markers.js +1 -2
  17. package/dist/controls/markers.js.map +1 -1
  18. package/dist/controls/menu.js +1 -2
  19. package/dist/controls/native-tracks.d.ts +8 -7
  20. package/dist/controls/native-tracks.d.ts.map +1 -1
  21. package/dist/controls/native-tracks.js +1 -2
  22. package/dist/controls/native-tracks.js.map +1 -1
  23. package/dist/controls/pip.js +1 -2
  24. package/dist/controls/quality-names.js +1 -2
  25. package/dist/controls/ranges.js +1 -2
  26. package/dist/controls/session.js +1 -2
  27. package/dist/controls/slider.js +1 -2
  28. package/dist/controls/time.js +1 -2
  29. package/dist/controls/track-names.d.ts +3 -2
  30. package/dist/controls/track-names.d.ts.map +1 -1
  31. package/dist/controls/track-names.js +5 -5
  32. package/dist/controls/track-names.js.map +1 -1
  33. package/dist/dom.js +1 -2
  34. package/dist/element-entry.d.ts +4 -1
  35. package/dist/element-entry.d.ts.map +1 -1
  36. package/dist/element-entry.js +1 -2
  37. package/dist/element-entry.js.map +1 -1
  38. package/dist/element.d.ts +134 -5
  39. package/dist/element.d.ts.map +1 -1
  40. package/dist/element.js +346 -35
  41. package/dist/element.js.map +1 -1
  42. package/dist/elements/airplay-button.js +2 -3
  43. package/dist/elements/airplay-button.js.map +1 -1
  44. package/dist/elements/audio-menu.d.ts +3 -2
  45. package/dist/elements/audio-menu.d.ts.map +1 -1
  46. package/dist/elements/audio-menu.js +18 -12
  47. package/dist/elements/audio-menu.js.map +1 -1
  48. package/dist/elements/chapters-menu.d.ts +2 -1
  49. package/dist/elements/chapters-menu.d.ts.map +1 -1
  50. package/dist/elements/chapters-menu.js +2 -3
  51. package/dist/elements/chapters-menu.js.map +1 -1
  52. package/dist/elements/component.d.ts +9 -0
  53. package/dist/elements/component.d.ts.map +1 -1
  54. package/dist/elements/component.js +16 -2
  55. package/dist/elements/component.js.map +1 -1
  56. package/dist/elements/control-bar.d.ts.map +1 -1
  57. package/dist/elements/control-bar.js +9 -8
  58. package/dist/elements/control-bar.js.map +1 -1
  59. package/dist/elements/current-time.js +1 -2
  60. package/dist/elements/drm-badge.js +4 -5
  61. package/dist/elements/drm-badge.js.map +1 -1
  62. package/dist/elements/duration.js +1 -2
  63. package/dist/elements/error-screen.d.ts +9 -0
  64. package/dist/elements/error-screen.d.ts.map +1 -1
  65. package/dist/elements/error-screen.js +55 -15
  66. package/dist/elements/error-screen.js.map +1 -1
  67. package/dist/elements/fullscreen-button.js +2 -3
  68. package/dist/elements/fullscreen-button.js.map +1 -1
  69. package/dist/elements/live-button.js +3 -4
  70. package/dist/elements/live-button.js.map +1 -1
  71. package/dist/elements/marker-button.d.ts.map +1 -1
  72. package/dist/elements/marker-button.js +7 -6
  73. package/dist/elements/marker-button.js.map +1 -1
  74. package/dist/elements/menu-element.d.ts +3 -2
  75. package/dist/elements/menu-element.d.ts.map +1 -1
  76. package/dist/elements/menu-element.js +3 -4
  77. package/dist/elements/menu-element.js.map +1 -1
  78. package/dist/elements/mute-button.js +2 -3
  79. package/dist/elements/mute-button.js.map +1 -1
  80. package/dist/elements/pip-button.js +2 -3
  81. package/dist/elements/pip-button.js.map +1 -1
  82. package/dist/elements/play-button.d.ts.map +1 -1
  83. package/dist/elements/play-button.js +9 -12
  84. package/dist/elements/play-button.js.map +1 -1
  85. package/dist/elements/quality-menu.d.ts +2 -1
  86. package/dist/elements/quality-menu.d.ts.map +1 -1
  87. package/dist/elements/quality-menu.js +3 -4
  88. package/dist/elements/quality-menu.js.map +1 -1
  89. package/dist/elements/remaining-time.js +1 -2
  90. package/dist/elements/scan-button.d.ts.map +1 -1
  91. package/dist/elements/scan-button.js +2 -3
  92. package/dist/elements/scan-button.js.map +1 -1
  93. package/dist/elements/seek-bar.d.ts +2 -0
  94. package/dist/elements/seek-bar.d.ts.map +1 -1
  95. package/dist/elements/seek-bar.js +10 -7
  96. package/dist/elements/seek-bar.js.map +1 -1
  97. package/dist/elements/shared.d.ts +18 -0
  98. package/dist/elements/shared.d.ts.map +1 -1
  99. package/dist/elements/shared.js +17 -11
  100. package/dist/elements/shared.js.map +1 -1
  101. package/dist/elements/skip-button.d.ts.map +1 -1
  102. package/dist/elements/skip-button.js +2 -3
  103. package/dist/elements/skip-button.js.map +1 -1
  104. package/dist/elements/spacer.js +1 -2
  105. package/dist/elements/speed-menu.d.ts +2 -1
  106. package/dist/elements/speed-menu.d.ts.map +1 -1
  107. package/dist/elements/speed-menu.js +3 -4
  108. package/dist/elements/speed-menu.js.map +1 -1
  109. package/dist/elements/spinner.d.ts +1 -1
  110. package/dist/elements/spinner.js +2 -4
  111. package/dist/elements/spinner.js.map +1 -1
  112. package/dist/elements/start-button.d.ts.map +1 -1
  113. package/dist/elements/start-button.js +5 -7
  114. package/dist/elements/start-button.js.map +1 -1
  115. package/dist/elements/subtitles-menu.d.ts +2 -1
  116. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  117. package/dist/elements/subtitles-menu.js +51 -22
  118. package/dist/elements/subtitles-menu.js.map +1 -1
  119. package/dist/elements/time-element.js +1 -2
  120. package/dist/elements/title.d.ts.map +1 -1
  121. package/dist/elements/title.js +16 -7
  122. package/dist/elements/title.js.map +1 -1
  123. package/dist/elements/video-menu.d.ts +24 -0
  124. package/dist/elements/video-menu.d.ts.map +1 -0
  125. package/dist/elements/video-menu.js +146 -0
  126. package/dist/elements/video-menu.js.map +1 -0
  127. package/dist/elements/volume-slider.js +2 -3
  128. package/dist/elements/volume-slider.js.map +1 -1
  129. package/dist/elements/volume.js +1 -2
  130. package/dist/entries/airplay-button.js +1 -2
  131. package/dist/entries/audio-menu.js +1 -2
  132. package/dist/entries/chapters-menu.js +1 -2
  133. package/dist/entries/control-bar.js +1 -2
  134. package/dist/entries/current-time.js +1 -2
  135. package/dist/entries/drm-badge.js +1 -2
  136. package/dist/entries/duration.js +1 -2
  137. package/dist/entries/error-screen.js +1 -2
  138. package/dist/entries/fullscreen-button.js +1 -2
  139. package/dist/entries/live-button.js +1 -2
  140. package/dist/entries/marker-button.js +1 -2
  141. package/dist/entries/mute-button.js +1 -2
  142. package/dist/entries/pip-button.js +1 -2
  143. package/dist/entries/play-button.js +1 -2
  144. package/dist/entries/quality-menu.js +1 -2
  145. package/dist/entries/remaining-time.js +1 -2
  146. package/dist/entries/scan-button.js +1 -2
  147. package/dist/entries/seek-bar.js +1 -2
  148. package/dist/entries/skip-button.js +1 -2
  149. package/dist/entries/spacer.js +1 -2
  150. package/dist/entries/speed-menu.js +1 -2
  151. package/dist/entries/spinner.js +1 -2
  152. package/dist/entries/start-button.js +1 -2
  153. package/dist/entries/subtitles-menu.js +1 -2
  154. package/dist/entries/title.js +1 -2
  155. package/dist/entries/video-menu.d.ts +5 -0
  156. package/dist/entries/video-menu.d.ts.map +1 -0
  157. package/dist/entries/video-menu.js +8 -0
  158. package/dist/entries/video-menu.js.map +1 -0
  159. package/dist/entries/volume-slider.js +1 -2
  160. package/dist/entries/volume.js +1 -2
  161. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/asyncToGenerator.js +1 -2
  162. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/defineProperty.js +1 -2
  163. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/objectSpread2.js +1 -2
  164. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPrimitive.js +1 -2
  165. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/toPropertyKey.js +1 -2
  166. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.154.0 → _@oxc-project_runtime@0.155.0}/helpers/esm/typeof.js +1 -2
  167. package/dist/es2015/announcer.js +18 -15
  168. package/dist/es2015/controls/airplay.js +1 -2
  169. package/dist/es2015/controls/chapters.js +2 -3
  170. package/dist/es2015/controls/cues.js +1 -2
  171. package/dist/es2015/controls/fullscreen.js +1 -2
  172. package/dist/es2015/controls/icons.js +2 -2
  173. package/dist/es2015/controls/markers.js +1 -2
  174. package/dist/es2015/controls/menu.js +2 -3
  175. package/dist/es2015/controls/native-tracks.js +1 -2
  176. package/dist/es2015/controls/pip.js +1 -2
  177. package/dist/es2015/controls/quality-names.js +1 -2
  178. package/dist/es2015/controls/ranges.js +1 -2
  179. package/dist/es2015/controls/session.js +1 -2
  180. package/dist/es2015/controls/slider.js +1 -2
  181. package/dist/es2015/controls/time.js +1 -2
  182. package/dist/es2015/controls/track-names.js +5 -5
  183. package/dist/es2015/dom.js +1 -2
  184. package/dist/es2015/element-entry.js +1 -2
  185. package/dist/es2015/element.js +402 -85
  186. package/dist/es2015/elements/airplay-button.js +2 -4
  187. package/dist/es2015/elements/audio-menu.js +18 -16
  188. package/dist/es2015/elements/chapters-menu.js +2 -3
  189. package/dist/es2015/elements/component.js +18 -2
  190. package/dist/es2015/elements/control-bar.js +9 -8
  191. package/dist/es2015/elements/current-time.js +1 -2
  192. package/dist/es2015/elements/drm-badge.js +5 -7
  193. package/dist/es2015/elements/duration.js +1 -2
  194. package/dist/es2015/elements/error-screen.js +58 -16
  195. package/dist/es2015/elements/fullscreen-button.js +2 -4
  196. package/dist/es2015/elements/live-button.js +3 -5
  197. package/dist/es2015/elements/marker-button.js +8 -7
  198. package/dist/es2015/elements/menu-element.js +3 -8
  199. package/dist/es2015/elements/mute-button.js +3 -4
  200. package/dist/es2015/elements/pip-button.js +2 -4
  201. package/dist/es2015/elements/play-button.js +9 -13
  202. package/dist/es2015/elements/quality-menu.js +4 -5
  203. package/dist/es2015/elements/remaining-time.js +1 -2
  204. package/dist/es2015/elements/scan-button.js +3 -4
  205. package/dist/es2015/elements/seek-bar.js +12 -11
  206. package/dist/es2015/elements/shared.js +17 -11
  207. package/dist/es2015/elements/skip-button.js +2 -4
  208. package/dist/es2015/elements/spacer.js +1 -2
  209. package/dist/es2015/elements/speed-menu.js +4 -5
  210. package/dist/es2015/elements/spinner.js +2 -5
  211. package/dist/es2015/elements/start-button.js +6 -8
  212. package/dist/es2015/elements/subtitles-menu.js +53 -31
  213. package/dist/es2015/elements/time-element.js +1 -2
  214. package/dist/es2015/elements/title.js +17 -8
  215. package/dist/es2015/elements/video-menu.js +152 -0
  216. package/dist/es2015/elements/volume-slider.js +3 -4
  217. package/dist/es2015/elements/volume.js +1 -2
  218. package/dist/es2015/entries/airplay-button.js +1 -2
  219. package/dist/es2015/entries/audio-menu.js +1 -2
  220. package/dist/es2015/entries/chapters-menu.js +1 -2
  221. package/dist/es2015/entries/control-bar.js +1 -2
  222. package/dist/es2015/entries/current-time.js +1 -2
  223. package/dist/es2015/entries/drm-badge.js +1 -2
  224. package/dist/es2015/entries/duration.js +1 -2
  225. package/dist/es2015/entries/error-screen.js +1 -2
  226. package/dist/es2015/entries/fullscreen-button.js +1 -2
  227. package/dist/es2015/entries/live-button.js +1 -2
  228. package/dist/es2015/entries/marker-button.js +1 -2
  229. package/dist/es2015/entries/mute-button.js +1 -2
  230. package/dist/es2015/entries/pip-button.js +1 -2
  231. package/dist/es2015/entries/play-button.js +1 -2
  232. package/dist/es2015/entries/quality-menu.js +1 -2
  233. package/dist/es2015/entries/remaining-time.js +1 -2
  234. package/dist/es2015/entries/scan-button.js +1 -2
  235. package/dist/es2015/entries/seek-bar.js +1 -2
  236. package/dist/es2015/entries/skip-button.js +1 -2
  237. package/dist/es2015/entries/spacer.js +1 -2
  238. package/dist/es2015/entries/speed-menu.js +1 -2
  239. package/dist/es2015/entries/spinner.js +1 -2
  240. package/dist/es2015/entries/start-button.js +1 -2
  241. package/dist/es2015/entries/subtitles-menu.js +1 -2
  242. package/dist/es2015/entries/title.js +1 -2
  243. package/dist/es2015/entries/video-menu.js +6 -0
  244. package/dist/es2015/entries/volume-slider.js +1 -2
  245. package/dist/es2015/entries/volume.js +1 -2
  246. package/dist/es2015/host.js +1 -2
  247. package/dist/es2015/ids.js +33 -0
  248. package/dist/es2015/index.js +4 -1
  249. package/dist/es2015/labels.js +1 -2
  250. package/dist/es2015/locales/ar.js +75 -0
  251. package/dist/es2015/locales/ca.js +75 -0
  252. package/dist/es2015/locales/de.js +75 -0
  253. package/dist/es2015/locales/es.js +75 -0
  254. package/dist/es2015/locales/fr.js +75 -0
  255. package/dist/es2015/locales/hi.js +75 -0
  256. package/dist/es2015/locales/it.js +75 -0
  257. package/dist/es2015/locales/ja.js +75 -0
  258. package/dist/es2015/locales/ko.js +75 -0
  259. package/dist/es2015/locales/pt.js +75 -0
  260. package/dist/es2015/locales/zh.js +75 -0
  261. package/dist/es2015/locales.js +61 -0
  262. package/dist/es2015/namespaces.js +1 -2
  263. package/dist/es2015/presets.js +2 -3
  264. package/dist/es2015/style.js +1 -2
  265. package/dist/es2015/surface.js +12 -4
  266. package/dist/es2015/tags.js +3 -3
  267. package/dist/es2015/text.js +15 -0
  268. package/dist/es2015/trackers.js +43 -0
  269. package/dist/es2015/video-sources.js +127 -0
  270. package/dist/host.d.ts +49 -1
  271. package/dist/host.d.ts.map +1 -1
  272. package/dist/host.js +1 -2
  273. package/dist/host.js.map +1 -1
  274. package/dist/ids.d.ts +19 -0
  275. package/dist/ids.d.ts.map +1 -0
  276. package/dist/ids.js +34 -0
  277. package/dist/ids.js.map +1 -0
  278. package/dist/index.d.ts +11 -1
  279. package/dist/index.d.ts.map +1 -1
  280. package/dist/index.js +4 -1
  281. package/dist/labels.js +1 -2
  282. package/dist/locales/ar.d.ts +75 -0
  283. package/dist/locales/ar.d.ts.map +1 -0
  284. package/dist/locales/ar.js +77 -0
  285. package/dist/locales/ar.js.map +1 -0
  286. package/dist/locales/ca.d.ts +75 -0
  287. package/dist/locales/ca.d.ts.map +1 -0
  288. package/dist/locales/ca.js +77 -0
  289. package/dist/locales/ca.js.map +1 -0
  290. package/dist/locales/de.d.ts +75 -0
  291. package/dist/locales/de.d.ts.map +1 -0
  292. package/dist/locales/de.js +77 -0
  293. package/dist/locales/de.js.map +1 -0
  294. package/dist/locales/es.d.ts +75 -0
  295. package/dist/locales/es.d.ts.map +1 -0
  296. package/dist/locales/es.js +77 -0
  297. package/dist/locales/es.js.map +1 -0
  298. package/dist/locales/fr.d.ts +75 -0
  299. package/dist/locales/fr.d.ts.map +1 -0
  300. package/dist/locales/fr.js +77 -0
  301. package/dist/locales/fr.js.map +1 -0
  302. package/dist/locales/hi.d.ts +75 -0
  303. package/dist/locales/hi.d.ts.map +1 -0
  304. package/dist/locales/hi.js +77 -0
  305. package/dist/locales/hi.js.map +1 -0
  306. package/dist/locales/it.d.ts +75 -0
  307. package/dist/locales/it.d.ts.map +1 -0
  308. package/dist/locales/it.js +77 -0
  309. package/dist/locales/it.js.map +1 -0
  310. package/dist/locales/ja.d.ts +75 -0
  311. package/dist/locales/ja.d.ts.map +1 -0
  312. package/dist/locales/ja.js +77 -0
  313. package/dist/locales/ja.js.map +1 -0
  314. package/dist/locales/ko.d.ts +75 -0
  315. package/dist/locales/ko.d.ts.map +1 -0
  316. package/dist/locales/ko.js +77 -0
  317. package/dist/locales/ko.js.map +1 -0
  318. package/dist/locales/pt.d.ts +75 -0
  319. package/dist/locales/pt.d.ts.map +1 -0
  320. package/dist/locales/pt.js +77 -0
  321. package/dist/locales/pt.js.map +1 -0
  322. package/dist/locales/zh.d.ts +75 -0
  323. package/dist/locales/zh.d.ts.map +1 -0
  324. package/dist/locales/zh.js +77 -0
  325. package/dist/locales/zh.js.map +1 -0
  326. package/dist/locales.d.ts +27 -0
  327. package/dist/locales.d.ts.map +1 -0
  328. package/dist/locales.js +48 -0
  329. package/dist/locales.js.map +1 -0
  330. package/dist/messages.d.ts +167 -0
  331. package/dist/messages.d.ts.map +1 -0
  332. package/dist/namespaces.js +1 -2
  333. package/dist/presets.js +1 -2
  334. package/dist/style.js +1 -2
  335. package/dist/surface.d.ts +4 -1
  336. package/dist/surface.d.ts.map +1 -1
  337. package/dist/surface.js +12 -4
  338. package/dist/surface.js.map +1 -1
  339. package/dist/tags.d.ts +1 -0
  340. package/dist/tags.d.ts.map +1 -1
  341. package/dist/tags.js +3 -3
  342. package/dist/tags.js.map +1 -1
  343. package/dist/text.d.ts +14 -0
  344. package/dist/text.d.ts.map +1 -0
  345. package/dist/text.js +16 -0
  346. package/dist/text.js.map +1 -0
  347. package/dist/trackers.d.ts +18 -0
  348. package/dist/trackers.d.ts.map +1 -0
  349. package/dist/trackers.js +45 -0
  350. package/dist/trackers.js.map +1 -0
  351. package/dist/video-sources.d.ts +48 -0
  352. package/dist/video-sources.d.ts.map +1 -0
  353. package/dist/video-sources.js +133 -0
  354. package/dist/video-sources.js.map +1 -0
  355. package/package.json +11 -3
@@ -14,6 +14,8 @@
14
14
  */
15
15
  import type { Mattebox } from 'mattebox';
16
16
  import type { PlayerHost } from '../host.js';
17
+ import type { Messages } from '../messages.js';
18
+ import type { Text } from '../text.js';
17
19
  export declare abstract class Component extends HTMLElement {
18
20
  protected player: PlayerHost | null;
19
21
  private offs;
@@ -25,6 +27,13 @@ export declare abstract class Component extends HTMLElement {
25
27
  attributeChangedCallback(): void;
26
28
  /** Adds `fn` for every name on `target`, to be removed on detach. */
27
29
  protected listen(target: EventTarget, names: readonly string[], fn: (event: Event) => void): void;
30
+ /**
31
+ * A word the control shows: its `attribute` when the page set one, else
32
+ * the player's language's `id`, else `english`.
33
+ */
34
+ protected word(attribute: string, id: keyof Messages, english: string): string;
35
+ /** Words the page gave, in the player's language. */
36
+ protected pageText(text: Text): string;
28
37
  /** Keeps `off` to run on detach. */
29
38
  protected keep(off: () => void): void;
30
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/elements/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C,8BAAsB,SAAU,SAAQ,WAAW;IACjD,UAAkB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC5C,QAAgB,IAAI,CAAoB;IACxC,yGAAyG;IACzG,QAAgB,KAAK,CAAS;;IAS9B,iBAAiB,IAAI,IAAI;IA8BzB,oBAAoB,IAAI,IAAI;IAU5B,wBAAwB,IAAI,IAAI;IAIhC,qEAAqE;IACrE,SAAS,CAAC,MAAM,CACd,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GACzB,IAAI;IAOP,oCAAoC;IACpC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;;;OAIG;IACH,SAAS,CAAC,MAAM,CACd,MAAM,EAAE,UAAU,EAClB,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GACxD,IAAI;IAcP,mGAAmG;IACnG,SAAS,CAAC,OAAO,CACf,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,EAAE,EAAE,MAAM,IAA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EAAE,MAAM,IAAI,GAAG,IAAI;IAIrC;;;;OAIG;IACH,SAAS,CAAC,MAAM,CACd,MAAM,EAAE,UAAU,EAClB,EAAE,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GACxD,IAAI;IAcP,mGAAmG;IACnG,SAAS,CAAC,OAAO,CACf,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,EAAE,EAAE,MAAM,IAAI,EACd,OAAO,UAAQ,GACd,IAAI;IAQP,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAEnD,mFAAmF;IACnF,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAE3C,yFAAyF;IACzF,SAAS,CAAC,MAAM,IAAI,IAAI;CACzB"}
@@ -1,6 +1,7 @@
1
1
  import { PLAYER } from "../tags.js";
2
+ import { textIn } from "../text.js";
2
3
  import { findPlayer } from "../host.js";
3
- //#region src/elements/component.ts
4
+ // src/elements/component.ts
4
5
  var Component = class extends HTMLElement {
5
6
  constructor() {
6
7
  super();
@@ -27,6 +28,9 @@ var Component = class extends HTMLElement {
27
28
  tier();
28
29
  this.render();
29
30
  });
31
+ this.listen(found, ["localechange"], () => {
32
+ this.render();
33
+ });
30
34
  tier();
31
35
  this.attach(this.player);
32
36
  };
@@ -52,6 +56,17 @@ var Component = class extends HTMLElement {
52
56
  for (const name of names) target.removeEventListener(name, fn);
53
57
  });
54
58
  }
59
+ /**
60
+ * A word the control shows: its `attribute` when the page set one, else
61
+ * the player's language's `id`, else `english`.
62
+ */
63
+ word(attribute, id, english) {
64
+ return this.getAttribute(attribute) ?? this.player?.message(id) ?? english;
65
+ }
66
+ /** Words the page gave, in the player's language. */
67
+ pageText(text) {
68
+ return textIn(text, this.player?.locale ?? "");
69
+ }
55
70
  /** Keeps `off` to run on detach. */
56
71
  keep(off) {
57
72
  this.offs.push(off);
@@ -91,7 +106,6 @@ var Component = class extends HTMLElement {
91
106
  /** Draws the current state. Called on every observed attribute change while attached. */
92
107
  render() {}
93
108
  };
94
- //#endregion
95
109
  export { Component };
96
110
 
97
111
  //# sourceMappingURL=component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.js","names":[],"sources":["../../src/elements/component.ts"],"sourcesContent":["/**\n * What every control shares: finding its player, and letting go of it.\n *\n * A control attaches when it is connected inside a player, once the player\n * is defined and upgraded, and detaches when it is removed. Every listener\n * a control adds goes through `listen`, so detaching drops them all. A\n * control connected outside a player is inert. Moving one to another\n * player detaches and attaches again, so a framework that reorders\n * children is safe.\n *\n * No class fields: the ES2015 build would lower them into helpers, and the\n * emit check bans helpers. State is declared, then assigned in the\n * constructor.\n */\nimport type { Mattebox } from 'mattebox';\nimport type { PlayerHost } from '../host.js';\nimport { findPlayer } from '../host.js';\nimport { PLAYER } from '../tags.js';\n\nexport abstract class Component extends HTMLElement {\n declare protected player: PlayerHost | null;\n declare private offs: Array<() => void>;\n /** Bumped on every connect and disconnect, so a late upgrade attaches only to the current connection. */\n declare private epoch: number;\n\n constructor() {\n super();\n this.player = null;\n this.offs = [];\n this.epoch = 0;\n }\n\n connectedCallback(): void {\n const found = findPlayer(this);\n if (found === null) return;\n this.epoch += 1;\n const epoch = this.epoch;\n const attach = (): void => {\n if (epoch !== this.epoch || !this.isConnected) return;\n // Defined, and this instance upgraded: `video` is on the prototype.\n customElements.upgrade(found);\n if (!('video' in found)) return;\n this.player = found as PlayerHost;\n // The player's size tier, on the control itself: a shadow tree cannot\n // match an attribute of an ancestor in every browser, and with it\n // here a control's stylesheet says `:host([layout=\"compact\"])`.\n const tier = (): void => {\n const layout = found.getAttribute('layout');\n if (layout === null) this.removeAttribute('layout');\n else this.setAttribute('layout', layout);\n };\n this.listen(found, ['layoutchange'], () => {\n tier();\n this.render();\n });\n tier();\n this.attach(this.player);\n };\n if ('video' in found) attach();\n else void customElements.whenDefined(PLAYER).then(attach);\n }\n\n disconnectedCallback(): void {\n this.epoch += 1;\n for (const off of this.offs) off();\n this.offs = [];\n const player = this.player;\n if (player === null) return;\n this.player = null;\n this.detach(player);\n }\n\n attributeChangedCallback(): void {\n if (this.player !== null) this.render();\n }\n\n /** Adds `fn` for every name on `target`, to be removed on detach. */\n protected listen(\n target: EventTarget,\n names: readonly string[],\n fn: (event: Event) => void,\n ): void {\n for (const name of names) target.addEventListener(name, fn);\n this.offs.push(() => {\n for (const name of names) target.removeEventListener(name, fn);\n });\n }\n\n /** Keeps `off` to run on detach. */\n protected keep(off: () => void): void {\n this.offs.push(off);\n }\n\n /**\n * Runs `fn` over the current engine now and on every session change,\n * running what the last call returned first, so a control's engine\n * subscriptions live exactly as long as the session. Detach runs it too.\n */\n protected follow(\n player: PlayerHost,\n fn: (engine: Mattebox | null) => (() => void) | undefined,\n ): void {\n let off: (() => void) | undefined;\n const run = (): void => {\n off?.();\n off = fn(player.engine);\n };\n this.listen(player, ['sourcechange'], run);\n this.offs.push(() => {\n off?.();\n off = undefined;\n });\n run();\n }\n\n /** Runs `fn` when any of `names` changes on `target`, or under it with `subtree`, until detach. */\n protected observe(\n target: Element,\n names: readonly string[],\n fn: () => void,\n subtree = false,\n ): void {\n const observer = new MutationObserver(fn);\n observer.observe(target, { attributes: true, attributeFilter: [...names], subtree });\n this.offs.push(() => {\n observer.disconnect();\n });\n }\n\n /** The control is connected inside an upgraded player. Subscribe and render. */\n protected abstract attach(player: PlayerHost): void;\n\n /** The control left its player. Listeners are already gone; undo anything else. */\n protected detach(_player: PlayerHost): void {}\n\n /** Draws the current state. Called on every observed attribute change while attached. */\n protected render(): void {}\n}\n"],"mappings":";;;AAmBA,IAAsB,YAAtB,cAAwC,YAAY;CAMlD,cAAc;EACZ,MAAM;EACN,KAAK,SAAS;EACd,KAAK,OAAO,CAAC;EACb,KAAK,QAAQ;CACf;CAEA,oBAA0B;EACxB,MAAM,QAAQ,WAAW,IA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,WAAW;GACnB,MAAM;GACN,MAAM,KAAA;EACR,CAAC;EACD,IAAI;CACN;;CAGA,QACE,QACA,OACA,IACA,UAAU,OACJ;EACN,MAAM,WAAW,IAAI,iBAAiB,EAAE;EACxC,SAAS,QAAQ,QAAQ;GAAE,YAAY;GAAM,iBAAiB,CAAC,GAAG,KAAK;GAAG;EAAQ,CAAC;EACnF,KAAK,KAAK,WAAW;GACnB,SAAS,WAAW;EACtB,CAAC;CACH;;CAMA,OAAiB,SAA2B,CAAC;;CAG7C,SAAyB,CAAC;AAC5B"}
1
+ {"version":3,"file":"component.js","names":[],"sources":["../../src/elements/component.ts"],"sourcesContent":["/**\n * What every control shares: finding its player, and letting go of it.\n *\n * A control attaches when it is connected inside a player, once the player\n * is defined and upgraded, and detaches when it is removed. Every listener\n * a control adds goes through `listen`, so detaching drops them all. A\n * control connected outside a player is inert. Moving one to another\n * player detaches and attaches again, so a framework that reorders\n * children is safe.\n *\n * No class fields: the ES2015 build would lower them into helpers, and the\n * emit check bans helpers. State is declared, then assigned in the\n * constructor.\n */\nimport type { Mattebox } from 'mattebox';\nimport type { PlayerHost } from '../host.js';\nimport { findPlayer } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { PLAYER } from '../tags.js';\nimport type { Text } from '../text.js';\nimport { textIn } from '../text.js';\n\nexport abstract class Component extends HTMLElement {\n declare protected player: PlayerHost | null;\n declare private offs: Array<() => void>;\n /** Bumped on every connect and disconnect, so a late upgrade attaches only to the current connection. */\n declare private epoch: number;\n\n constructor() {\n super();\n this.player = null;\n this.offs = [];\n this.epoch = 0;\n }\n\n connectedCallback(): void {\n const found = findPlayer(this);\n if (found === null) return;\n this.epoch += 1;\n const epoch = this.epoch;\n const attach = (): void => {\n if (epoch !== this.epoch || !this.isConnected) return;\n // Defined, and this instance upgraded: `video` is on the prototype.\n customElements.upgrade(found);\n if (!('video' in found)) return;\n this.player = found as PlayerHost;\n // The player's size tier, on the control itself: a shadow tree cannot\n // match an attribute of an ancestor in every browser, and with it\n // here a control's stylesheet says `:host([layout=\"compact\"])`.\n const tier = (): void => {\n const layout = found.getAttribute('layout');\n if (layout === null) this.removeAttribute('layout');\n else this.setAttribute('layout', layout);\n };\n this.listen(found, ['layoutchange'], () => {\n tier();\n this.render();\n });\n this.listen(found, ['localechange'], () => {\n this.render();\n });\n tier();\n this.attach(this.player);\n };\n if ('video' in found) attach();\n else void customElements.whenDefined(PLAYER).then(attach);\n }\n\n disconnectedCallback(): void {\n this.epoch += 1;\n for (const off of this.offs) off();\n this.offs = [];\n const player = this.player;\n if (player === null) return;\n this.player = null;\n this.detach(player);\n }\n\n attributeChangedCallback(): void {\n if (this.player !== null) this.render();\n }\n\n /** Adds `fn` for every name on `target`, to be removed on detach. */\n protected listen(\n target: EventTarget,\n names: readonly string[],\n fn: (event: Event) => void,\n ): void {\n for (const name of names) target.addEventListener(name, fn);\n this.offs.push(() => {\n for (const name of names) target.removeEventListener(name, fn);\n });\n }\n\n /**\n * A word the control shows: its `attribute` when the page set one, else\n * the player's language's `id`, else `english`.\n */\n protected word(attribute: string, id: keyof Messages, english: string): string {\n return this.getAttribute(attribute) ?? this.player?.message(id) ?? english;\n }\n\n /** Words the page gave, in the player's language. */\n protected pageText(text: Text): string {\n return textIn(text, this.player?.locale ?? '');\n }\n\n /** Keeps `off` to run on detach. */\n protected keep(off: () => void): void {\n this.offs.push(off);\n }\n\n /**\n * Runs `fn` over the current engine now and on every session change,\n * running what the last call returned first, so a control's engine\n * subscriptions live exactly as long as the session. Detach runs it too.\n */\n protected follow(\n player: PlayerHost,\n fn: (engine: Mattebox | null) => (() => void) | undefined,\n ): void {\n let off: (() => void) | undefined;\n const run = (): void => {\n off?.();\n off = fn(player.engine);\n };\n this.listen(player, ['sourcechange'], run);\n this.offs.push(() => {\n off?.();\n off = undefined;\n });\n run();\n }\n\n /** Runs `fn` when any of `names` changes on `target`, or under it with `subtree`, until detach. */\n protected observe(\n target: Element,\n names: readonly string[],\n fn: () => void,\n subtree = false,\n ): void {\n const observer = new MutationObserver(fn);\n observer.observe(target, { attributes: true, attributeFilter: [...names], subtree });\n this.offs.push(() => {\n observer.disconnect();\n });\n }\n\n /** The control is connected inside an upgraded player. Subscribe and render. */\n protected abstract attach(player: PlayerHost): void;\n\n /** The control left its player. Listeners are already gone; undo anything else. */\n protected detach(_player: PlayerHost): void {}\n\n /** Draws the current state. Called on every observed attribute change while attached. */\n protected render(): void {}\n}\n"],"mappings":";;;;AAsBA,IAAsB,YAAtB,cAAwC,YAAY;CAMlD,cAAc;EACZ,MAAM;EACN,KAAK,SAAS;EACd,KAAK,OAAO,CAAC;EACb,KAAK,QAAQ;CACf;CAEA,oBAA0B;EACxB,MAAM,QAAQ,WAAW,IAAI;EAC7B,IAAI,UAAU,MAAM;EACpB,KAAK,SAAS;EACd,MAAM,QAAQ,KAAK;EACnB,MAAM,eAAqB;GACzB,IAAI,UAAU,KAAK,SAAS,CAAC,KAAK,aAAa;GAE/C,eAAe,QAAQ,KAAK;GAC5B,IAAI,EAAE,WAAW,QAAQ;GACzB,KAAK,SAAS;GAId,MAAM,aAAmB;IACvB,MAAM,SAAS,MAAM,aAAa,QAAQ;IAC1C,IAAI,WAAW,MAAM,KAAK,gBAAgB,QAAQ;SAC7C,KAAK,aAAa,UAAU,MAAM;GACzC;GACA,KAAK,OAAO,OAAO,CAAC,cAAc,SAAS;IACzC,KAAK;IACL,KAAK,OAAO;GACd,CAAC;GACD,KAAK,OAAO,OAAO,CAAC,cAAc,SAAS;IACzC,KAAK,OAAO;GACd,CAAC;GACD,KAAK;GACL,KAAK,OAAO,KAAK,MAAM;EACzB;EACA,IAAI,WAAW,OAAO,OAAO;OACxB,eAAoB,YAAY,MAAM,CAAC,CAAC,KAAK,MAAM;CAC1D;CAEA,uBAA6B;EAC3B,KAAK,SAAS;EACd,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI;EACjC,KAAK,OAAO,CAAC;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;EACrB,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B,UAAU,CAAiB;IACpD,iBAAyB,OAAO,CAAkB;IAClD,QAAgB,KAAK,CAA4C;IACjE,6FAA6F;IAC7F,QAAgB,OAAO,CAAwB;IAC/C,uEAAuE;IACvE,QAAgB,QAAQ,CAAU;IAClC,QAAgB,IAAI,CAAiB;IACrC,QAAgB,MAAM,CAAoB;;IAsB1C;;;;;OAKG;IACH,uEAAuE;IACvE,OAAO,CAAC,EAAE;IAIV,OAAO,CAAC,MAAM;IAed;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAyBhB,wFAAwF;IACxF,OAAO,CAAC,OAAO;IAOf,OAAO,CAAC,IAAI;IAQZ,OAAO,CAAC,IAAI;IAOZ,OAAO,CAAC,KAAK;IAWb,OAAO,CAAC,IAAI;IAMZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAOd,OAAO,CAAC,GAAG;cAkDQ,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA8DhC,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CAgBpD"}
@@ -1,9 +1,9 @@
1
- import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SCAN_BUTTON, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
1
+ import { AIRPLAY_BUTTON, AUDIO_MENU, CHAPTERS_MENU, DRM_BADGE, MUTE_BUTTON, PIP_BUTTON, QUALITY_MENU, SCAN_BUTTON, SKIP_BUTTON, SPEED_MENU, SUBTITLES_MENU, VIDEO_MENU, VOLUME, VOLUME_SLIDER } from "../tags.js";
2
2
  import { Component } from "./component.js";
3
- import { number, style } from "./shared.js";
3
+ import { number, shownPaused, style } from "./shared.js";
4
4
  import { cueLift, cueStyle } from "../controls/cues.js";
5
5
  import { fullscreen } from "../controls/fullscreen.js";
6
- //#region src/elements/control-bar.ts
6
+ // src/elements/control-bar.ts
7
7
  const STYLE = ":host{box-sizing:border-box;color:var(--mbx-text);font:500 1em / 1.2 var(--mbx-font);background:linear-gradient(#0000,#0009);flex-direction:column;padding:2.5em 1em .75em;transition:opacity .2s;display:flex;position:absolute;bottom:0;left:0;right:0}:host([menu]){z-index:2;--mbx-tooltip:none}:host([idle]){opacity:0;pointer-events:none}[part~=row]{align-items:center;margin:0 -.25em;display:flex}[part~=buttons-row]{margin-top:.25em}[part~=seek-row]{margin:0 -.5em}slot:not([name])::slotted(*){margin:0 .25em}slot[name=seek]::slotted(*){margin:0 .5em}::slotted([collapsed]){display:none}@media (prefers-reduced-motion:reduce){:host{transition:none}}:host([layout=compact]){padding:1.5em .5em .25em}";
8
8
  const IDLE_MS = 3e3;
9
9
  const SEEK_STEP = 5;
@@ -12,8 +12,9 @@ const SEEK_STEP = 5;
12
12
  * suit a TV remote more than a small screen; then the slider, which takes
13
13
  * the most room for the least; then the diagnostics, the lock and the
14
14
  * menus a viewer rarely opens; then the menus for the picture and the
15
- * sound; then the skips; then the mute and the subtitles. The subtitles
16
- * menu goes last of the menus because it is the one a viewer may need.
15
+ * sound; then the skips; then the mute, the subtitles and the video
16
+ * menu. The subtitles and video menus go last of the menus because a
17
+ * viewer may need them: the video menu holds the sign-language version.
17
18
  * The diagnostics is another package's, named here as a string. A
18
19
  * `priority` attribute on the control replaces its default.
19
20
  */
@@ -30,6 +31,7 @@ const PRIORITY = {
30
31
  [AIRPLAY_BUTTON]: 2,
31
32
  [SKIP_BUTTON]: 2,
32
33
  [SUBTITLES_MENU]: 1,
34
+ [VIDEO_MENU]: 1,
33
35
  [VOLUME]: 1,
34
36
  [MUTE_BUTTON]: 1
35
37
  };
@@ -148,7 +150,7 @@ var MbxControlBar = class extends Component {
148
150
  };
149
151
  }
150
152
  held(player) {
151
- if (player.video.paused) return true;
153
+ if (shownPaused(player, ["switching"])) return true;
152
154
  if (this.querySelector("[open]") !== null) return true;
153
155
  if (!this.keyboard) return false;
154
156
  const active = this.getRootNode().activeElement;
@@ -277,7 +279,7 @@ var MbxControlBar = class extends Component {
277
279
  "pause",
278
280
  "ended"
279
281
  ], () => {
280
- this.wake(player);
282
+ if (!player.hasAttribute("switching")) this.wake(player);
281
283
  });
282
284
  this.wake(player);
283
285
  this.cues.lifted(true);
@@ -313,7 +315,6 @@ var MbxControlBar = class extends Component {
313
315
  player.removeAttribute("fullscreen");
314
316
  }
315
317
  };
316
- //#endregion
317
318
  export { MbxControlBar };
318
319
 
319
320
  //# sourceMappingURL=control-bar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-bar.js","names":[],"sources":["../../src/elements/control-bar.ts"],"sourcesContent":["/**\n * <mbx-control-bar>: an overlay over the bottom of the video that lays its\n * children out in two rows, the seek row over the buttons row. A child\n * with `slot=\"seek\"` sits in the seek row; everything else in the buttons\n * row, in its order, and an <mbx-spacer> pushes what follows to the right.\n *\n * The bar owns what no one control can: the idle fade, the shortcuts, the\n * click on the video, and the subtitles lifted above it. It sets `idle` on\n * itself and on the player while it hides.\n *\n * The fade is one timer. Any activity, a pointer moving or pressing, a\n * key, playback starting, re-arms it for `idle-ms`, and when it fires the\n * bar hides unless something it can know for certain holds it: the video\n * is paused, a descendant carries `open`, or keyboard focus is inside it,\n * where keyboard means the last input was a key and not a pointer.\n * Whether the pointer is over the player is never tracked: that goes\n * stale when the pointer leaves without a move the player sees.\n *\n * The shortcuts listen on the player, so they hear every key pressed\n * inside it, and only there: Space and `k` toggle play, `m` mutes, `f`\n * toggles fullscreen, the arrows seek by `seek-step`. The media keys a\n * remote or a keyboard sends do the same: play and pause, Stop pauses,\n * fast forward and rewind seek by `seek-step`. A seeking key fires\n * `seekkey` on the player first, which a seek bar may take to aim instead.\n * The bar is the one owner of the keys that work anywhere in the player:\n * it listens last, so the focused control, and a spatial navigation in\n * the capture phase, decide before it. Space is left to a\n * focused button, which is its own. A key another handler prevented is\n * left alone. A click on the video toggles play.\n * Fullscreen goes on the player itself, so the bar comes along.\n *\n * A narrow bar collapses the buttons row by `priority`: each child carries\n * a number, its own attribute or the default for its tag, and the bar\n * marks the highest numbers `collapsed` one at a time until the row fits\n * with a little slack, from the right among equals. Zero, the default for\n * anything unlisted, never collapses: play and fullscreen stay whatever\n * the width. The mark is an attribute and the hiding is one `::slotted`\n * rule here, so a page styles or overrides it by the tag. The volume's\n * slider is a candidate of its own, and counts at its unfolded width, so\n * the row is sized for what the pointer will make of it.\n */\n\nimport type { CueLift } from '../controls/cues.js';\nimport { cueLift, cueStyle } from '../controls/cues.js';\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\nimport type { PlayerHost } from '../host.js';\nimport {\n AIRPLAY_BUTTON,\n AUDIO_MENU,\n CHAPTERS_MENU,\n DRM_BADGE,\n MUTE_BUTTON,\n PIP_BUTTON,\n QUALITY_MENU,\n SCAN_BUTTON,\n SKIP_BUTTON,\n SPACER,\n SPEED_MENU,\n SUBTITLES_MENU,\n VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, style } from './shared.js';\n\nconst IDLE_MS = 3000;\nconst SEEK_STEP = 5;\n\n/**\n * What goes first when the row is too narrow, by tag: the scans, which\n * suit a TV remote more than a small screen; then the slider, which takes\n * the most room for the least; then the diagnostics, the lock and the\n * menus a viewer rarely opens; then the menus for the picture and the\n * sound; then the skips; then the mute and the subtitles. The subtitles\n * menu goes last of the menus because it is the one a viewer may need.\n * The diagnostics is another package's, named here as a string. A\n * `priority` attribute on the control replaces its default.\n */\nconst PRIORITY: Readonly<Record<string, number>> = {\n [SCAN_BUTTON]: 6,\n [VOLUME_SLIDER]: 5,\n 'mbx-diagnostics': 4,\n [DRM_BADGE]: 4,\n [SPEED_MENU]: 4,\n [CHAPTERS_MENU]: 4,\n [AUDIO_MENU]: 3,\n [QUALITY_MENU]: 3,\n [PIP_BUTTON]: 3,\n [AIRPLAY_BUTTON]: 2,\n [SKIP_BUTTON]: 2,\n [SUBTITLES_MENU]: 1,\n [VOLUME]: 1,\n [MUTE_BUTTON]: 1,\n};\n\n/** The width the volume group unfolds its slider to, in em, from volume.css: what a folded slider is counted at. */\nconst SLIDER_WIDTH = 5;\n\n/** Room kept between the last button and the edge, in em, so nothing sits flush against it. */\nconst SLACK = 0.5;\n\ninterface Candidate {\n readonly node: Element;\n /** The bar child it sits in, for the order among equals. */\n readonly index: number;\n readonly priority: number;\n}\n\nfunction shown(node: Element): boolean {\n return node.getClientRects().length > 0;\n}\n\n/** The slider inside a volume group child, when it has one. */\nfunction slider(child: Element): Element | null {\n return child.localName === VOLUME ? child.querySelector(VOLUME_SLIDER) : null;\n}\n\n/** A child's priority: its attribute, else its tag's default, else zero. */\nfunction priority(child: Element): number {\n const own = child.getAttribute('priority');\n if (own !== null) {\n const value = Number(own);\n return Number.isFinite(value) && value > 0 ? value : 0;\n }\n return PRIORITY[child.localName] ?? 0;\n}\n\nfunction end(video: HTMLVideoElement): number {\n if (Number.isFinite(video.duration)) return video.duration;\n const ranges = video.seekable;\n return ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;\n}\n\nfunction toggle(video: HTMLVideoElement): void {\n if (video.paused) video.play().catch(() => undefined);\n else video.pause();\n}\n\nexport class MbxControlBar extends Component {\n static get observedAttributes(): readonly string[] {\n return ['idle-ms', 'seek-step'];\n }\n\n declare private readonly seekRow: HTMLDivElement;\n declare private readonly buttonsRow: HTMLDivElement;\n declare private readonly buttons: HTMLSlotElement;\n declare private timer: ReturnType<typeof setTimeout> | undefined;\n /** Fires on a width change of the buttons row, so the collapse follows the page's layout. */\n declare private resizer: ResizeObserver | null;\n /** Whether the last input was a key, so focus inside holds the bar. */\n declare private keyboard: boolean;\n declare private cues: CueLift | null;\n declare private screen: Fullscreen | null;\n\n constructor() {\n super();\n this.timer = undefined;\n this.keyboard = false;\n this.cues = null;\n this.screen = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.seekRow = document.createElement('div');\n this.seekRow.setAttribute('part', 'row seek-row');\n const seek = document.createElement('slot');\n seek.name = 'seek';\n this.seekRow.append(seek);\n this.buttonsRow = document.createElement('div');\n this.buttonsRow.setAttribute('part', 'row buttons-row');\n this.buttons = document.createElement('slot');\n this.buttonsRow.append(this.buttons);\n root.append(style(STYLE), this.seekRow, this.buttonsRow);\n }\n\n /**\n * What the buttons need: their widths and their margins, which are the\n * gaps between them, the spacer aside since it takes what is left, and a\n * folded slider at the width it unfolds to. The row's own width says nothing, because the\n * spacer fills it whatever the buttons take.\n */\n /** The bar's em in pixels: its sizes follow the player's font size. */\n private em(): number {\n return Number.parseFloat(getComputedStyle(this).fontSize) || 16;\n }\n\n private needed(children: readonly Element[]): number {\n let sum = 0;\n for (const child of children) {\n if (child.localName === SPACER || !shown(child)) continue;\n const margins = getComputedStyle(child);\n sum += child.getBoundingClientRect().width;\n sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);\n const folded = slider(child);\n if (folded !== null && shown(folded)) {\n sum += Math.max(0, SLIDER_WIDTH * this.em() - folded.getBoundingClientRect().width);\n }\n }\n return sum;\n }\n\n /**\n * Collapses the buttons row to its width. Everything is shown first, so\n * a wider bar gets its controls back, then the highest priorities go one\n * at a time while the buttons need more than the row has, less the\n * slack. Each step lays the row out again; a bar carries a dozen\n * controls, so that is cheap.\n */\n private collapse(): void {\n const children = this.buttons.assignedElements();\n const candidates: Candidate[] = [];\n for (const [index, child] of children.entries()) {\n child.removeAttribute('collapsed');\n const inner = slider(child);\n inner?.removeAttribute('collapsed');\n // A nested slider goes before its group, so it sorts as if it sat\n // after it. What is not shown, by its own `hidden` or a page's rule,\n // takes no room, so marking it would hide nothing and say something\n // false.\n if (inner !== null && shown(inner)) {\n candidates.push({ node: inner, index: index + 0.5, priority: priority(inner) });\n }\n if (shown(child)) candidates.push({ node: child, index, priority: priority(child) });\n }\n candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);\n const room = this.buttonsRow.clientWidth - SLACK * this.em();\n for (const { node, priority: level } of candidates) {\n if (level === 0) return;\n if (this.needed(children) <= room) return;\n node.setAttribute('collapsed', '');\n }\n }\n\n /** From the first row's top to the bar's bottom: what the bar covers of the picture. */\n private covered(): { top: number; bottom: number } {\n return {\n top: this.seekRow.getBoundingClientRect().top,\n bottom: this.getBoundingClientRect().bottom,\n };\n }\n\n private held(player: PlayerHost): boolean {\n if (player.video.paused) return true;\n if (this.querySelector('[open]') !== null) return true;\n if (!this.keyboard) return false;\n const active = (this.getRootNode() as Document | ShadowRoot).activeElement;\n return active !== null && this.contains(active);\n }\n\n private idle(player: PlayerHost, on: boolean): void {\n if (this.hasAttribute('idle') === on) return;\n this.toggleAttribute('idle', on);\n player.toggleAttribute('idle', on);\n this.cues?.lifted(!on);\n }\n\n private sleep(player: PlayerHost): void {\n this.timer = undefined;\n // A hold is checked again later: a menu closes and a pause ends without\n // an event the bar hears.\n if (this.held(player)) {\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n return;\n }\n this.idle(player, true);\n }\n\n private wake(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.idle(player, false);\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n }\n\n /**\n * A seeking key: `seekkey` on the player first, cancellable, with the\n * seconds in `detail.by`. A seek bar under `key-mode=\"preview\"` takes it\n * to aim instead. Nobody took it: the playhead moves now.\n */\n private seekBy(player: PlayerHost, by: number): void {\n const asked = new CustomEvent('seekkey', { detail: { by }, cancelable: true });\n if (!player.dispatchEvent(asked)) return;\n const video = player.video;\n video.currentTime = Math.min(end(video), Math.max(0, video.currentTime + by));\n }\n\n private key(player: PlayerHost, event: KeyboardEvent): void {\n this.keyboard = true;\n this.wake(player);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const video = player.video;\n const onButton = event.composedPath()[0] instanceof HTMLButtonElement;\n switch (event.key) {\n case ' ':\n if (onButton) return;\n toggle(video);\n break;\n case 'k':\n case 'K':\n toggle(video);\n break;\n case 'm':\n case 'M':\n video.muted = !video.muted;\n break;\n case 'f':\n case 'F':\n this.screen?.toggle();\n break;\n // The media keys, which remotes and many keyboards send. UI Events\n // KeyboardEvent key values, Multimedia keys.\n case 'MediaPlayPause':\n toggle(video);\n break;\n case 'MediaPlay':\n void video.play().catch(() => undefined);\n break;\n // Stop pauses: the source stays, as a viewer expects on a remote.\n case 'MediaPause':\n case 'MediaStop':\n video.pause();\n break;\n case 'ArrowLeft':\n case 'MediaRewind':\n this.seekBy(player, -number(this, 'seek-step', SEEK_STEP));\n break;\n case 'ArrowRight':\n case 'MediaFastForward':\n this.seekBy(player, number(this, 'seek-step', SEEK_STEP));\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n cueStyle();\n this.cues = cueLift(video, player, () => this.covered());\n const screen = fullscreen(player, video);\n this.screen = screen;\n const reflect = (): void => {\n player.toggleAttribute('fullscreen', screen.active());\n };\n this.keep(screen.watch(reflect));\n reflect();\n // `menu` while one of the bar's menus is open, by its `open` attribute:\n // the bar then stacks above the screens and hides its tooltips.\n const menus = new MutationObserver(() => {\n this.toggleAttribute('menu', this.querySelector('[open]') !== null);\n });\n menus.observe(this, { subtree: true, attributes: true, attributeFilter: ['open'] });\n this.keep(() => {\n menus.disconnect();\n this.removeAttribute('menu');\n });\n\n const pointer = (): void => {\n this.keyboard = false;\n this.wake(player);\n };\n const key = (event: Event): void => {\n this.key(player, event as KeyboardEvent);\n };\n const click = (event: Event): void => {\n // The video and nothing else: a control handles its own click.\n if (event.composedPath()[0] === video) toggle(video);\n };\n this.listen(player, ['pointermove', 'pointerdown'], pointer);\n player.addEventListener('keydown', key);\n player.addEventListener('click', click);\n this.keep(() => {\n player.removeEventListener('keydown', key);\n player.removeEventListener('click', click);\n });\n this.listen(video, ['play', 'pause', 'ended'], () => {\n this.wake(player);\n });\n this.wake(player);\n this.cues.lifted(true);\n\n // The row's width, its children, and what they hide or reprioritise on\n // their own: each can change what fits. `collapsed` is left out of the\n // filter, since the bar writes it.\n const collapse = (): void => {\n this.collapse();\n };\n this.listen(this.buttons, ['slotchange'], collapse);\n this.observe(this, ['hidden', 'priority', 'slot'], collapse, true);\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(collapse);\n this.resizer.observe(this.buttonsRow);\n }\n collapse();\n }\n\n protected override detach(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.resizer?.disconnect();\n this.resizer = null;\n for (const child of this.buttons.assignedElements()) {\n child.removeAttribute('collapsed');\n slider(child)?.removeAttribute('collapsed');\n }\n this.cues?.dispose();\n this.cues = null;\n this.screen = null;\n this.removeAttribute('idle');\n player.removeAttribute('idle');\n player.removeAttribute('fullscreen');\n }\n}\n"],"mappings":";;;;;;AAgEA,MAAA,QAAA;AAGA,MAAA,UAAA;AACA,MAAA,YAAA;;;;;;;;;;;AAYA,MAAA,WAAA;EACA,cAAA;EACA,gBAAA;CACA,mBAAA;EACA,YAAA;EACA,aAAA;EACA,gBAAA;EACA,aAAA;EACA,eAAA;EACA,aAAA;EACA,iBAAA;EACA,cAAA;EACA,iBAAA;EACA,SAAA;EACA,cAAA;AACA;;AAGA,MAAA,eAAA;;AAGA,MAAA,QAAA;AASA,SAAA,MAAA,MAAA;CACA,OAAA,KAAA,eAAA,CAAA,CAAA,SAAA;AACA;;AAGA,SAAA,OAAA,OAAA;CACA,OAAA,MAAA,cAAA,eAAA,MAAA,cAAA,aAAA,IAAA;AACA;;AAGA,SAAA,SAAA,OAAA;CACA,MAAA,MAAA,MAAA,aAAA,UAAA;CACA,IAAA,QAAA,MAAA;EACA,MAAA,QAAA,OAAA,GAAA;EACA,OAAA,OAAA,SAAA,KAAA,KAAA,QAAA,IAAA,QAAA;CACA;CACA,OAAA,SAAA,MAAA,cAAA;AACA;AAEA,SAAA,IAAA,OAAA;CACA,IAAA,OAAA,SAAA,MAAA,QAAA,GAAA,OAAA,MAAA;CACA,M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MAAA;EACA,KAAA,KAAA,OAAA,IAAA;EAKA,MAAA,iBAAA;GACA,KAAA,SAAA;EACA;EACA,KAAA,OAAA,KAAA,SAAA,CAAA,YAAA,GAAA,QAAA;EACA,KAAA,QAAA,MAAA;GAAA;GAAA;GAAA;EAAA,GAAA,UAAA,IAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,eAAA,QAAA;GACA,KAAA,QAAA,QAAA,KAAA,UAAA;EACA;EACA,SAAA;CACA;CAEA,OAAA,QAAA;EACA,aAAA,KAAA,KAAA;EACA,KAAA,QAAA,KAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;EACA,KAAA,MAAA,SAAA,KAAA,QAAA,iBAAA,GAAA;GACA,MAAA,gBAAA,WAAA;GACA,OAAA,KAAA,CAAA,EAAA,gBAAA,WAAA;EACA;EACA,KAAA,MAAA,QAAA;EACA,KAAA,OAAA;EACA,KAAA,SAAA;EACA,KAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,YAAA;CACA;AACA"}
1
+ {"version":3,"file":"control-bar.js","names":[],"sources":["../../src/elements/control-bar.ts"],"sourcesContent":["/**\n * <mbx-control-bar>: an overlay over the bottom of the video that lays its\n * children out in two rows, the seek row over the buttons row. A child\n * with `slot=\"seek\"` sits in the seek row; everything else in the buttons\n * row, in its order, and an <mbx-spacer> pushes what follows to the right.\n *\n * The bar owns what no one control can: the idle fade, the shortcuts, the\n * click on the video, and the subtitles lifted above it. It sets `idle` on\n * itself and on the player while it hides.\n *\n * The fade is one timer. Any activity, a pointer moving or pressing, a\n * key, playback starting, re-arms it for `idle-ms`, and when it fires the\n * bar hides unless something it can know for certain holds it: the video\n * is paused, a descendant carries `open`, or keyboard focus is inside it,\n * where keyboard means the last input was a key and not a pointer.\n * Whether the pointer is over the player is never tracked: that goes\n * stale when the pointer leaves without a move the player sees.\n *\n * The shortcuts listen on the player, so they hear every key pressed\n * inside it, and only there: Space and `k` toggle play, `m` mutes, `f`\n * toggles fullscreen, the arrows seek by `seek-step`. The media keys a\n * remote or a keyboard sends do the same: play and pause, Stop pauses,\n * fast forward and rewind seek by `seek-step`. A seeking key fires\n * `seekkey` on the player first, which a seek bar may take to aim instead.\n * The bar is the one owner of the keys that work anywhere in the player:\n * it listens last, so the focused control, and a spatial navigation in\n * the capture phase, decide before it. Space is left to a\n * focused button, which is its own. A key another handler prevented is\n * left alone. A click on the video toggles play.\n * Fullscreen goes on the player itself, so the bar comes along.\n *\n * A narrow bar collapses the buttons row by `priority`: each child carries\n * a number, its own attribute or the default for its tag, and the bar\n * marks the highest numbers `collapsed` one at a time until the row fits\n * with a little slack, from the right among equals. Zero, the default for\n * anything unlisted, never collapses: play and fullscreen stay whatever\n * the width. The mark is an attribute and the hiding is one `::slotted`\n * rule here, so a page styles or overrides it by the tag. The volume's\n * slider is a candidate of its own, and counts at its unfolded width, so\n * the row is sized for what the pointer will make of it.\n */\n\nimport type { CueLift } from '../controls/cues.js';\nimport { cueLift, cueStyle } from '../controls/cues.js';\nimport type { Fullscreen } from '../controls/fullscreen.js';\nimport { fullscreen } from '../controls/fullscreen.js';\nimport type { PlayerHost } from '../host.js';\nimport {\n AIRPLAY_BUTTON,\n AUDIO_MENU,\n CHAPTERS_MENU,\n DRM_BADGE,\n MUTE_BUTTON,\n PIP_BUTTON,\n QUALITY_MENU,\n SCAN_BUTTON,\n SKIP_BUTTON,\n SPACER,\n SPEED_MENU,\n SUBTITLES_MENU,\n VIDEO_MENU,\n VOLUME,\n VOLUME_SLIDER,\n} from '../tags.js';\nimport { Component } from './component.js';\nimport STYLE from './control-bar.css?inline';\nimport { number, shownPaused, style } from './shared.js';\n\nconst IDLE_MS = 3000;\nconst SEEK_STEP = 5;\n\n/**\n * What goes first when the row is too narrow, by tag: the scans, which\n * suit a TV remote more than a small screen; then the slider, which takes\n * the most room for the least; then the diagnostics, the lock and the\n * menus a viewer rarely opens; then the menus for the picture and the\n * sound; then the skips; then the mute, the subtitles and the video\n * menu. The subtitles and video menus go last of the menus because a\n * viewer may need them: the video menu holds the sign-language version.\n * The diagnostics is another package's, named here as a string. A\n * `priority` attribute on the control replaces its default.\n */\nconst PRIORITY: Readonly<Record<string, number>> = {\n [SCAN_BUTTON]: 6,\n [VOLUME_SLIDER]: 5,\n 'mbx-diagnostics': 4,\n [DRM_BADGE]: 4,\n [SPEED_MENU]: 4,\n [CHAPTERS_MENU]: 4,\n [AUDIO_MENU]: 3,\n [QUALITY_MENU]: 3,\n [PIP_BUTTON]: 3,\n [AIRPLAY_BUTTON]: 2,\n [SKIP_BUTTON]: 2,\n [SUBTITLES_MENU]: 1,\n [VIDEO_MENU]: 1,\n [VOLUME]: 1,\n [MUTE_BUTTON]: 1,\n};\n\n/** The width the volume group unfolds its slider to, in em, from volume.css: what a folded slider is counted at. */\nconst SLIDER_WIDTH = 5;\n\n/** Room kept between the last button and the edge, in em, so nothing sits flush against it. */\nconst SLACK = 0.5;\n\ninterface Candidate {\n readonly node: Element;\n /** The bar child it sits in, for the order among equals. */\n readonly index: number;\n readonly priority: number;\n}\n\nfunction shown(node: Element): boolean {\n return node.getClientRects().length > 0;\n}\n\n/** The slider inside a volume group child, when it has one. */\nfunction slider(child: Element): Element | null {\n return child.localName === VOLUME ? child.querySelector(VOLUME_SLIDER) : null;\n}\n\n/** A child's priority: its attribute, else its tag's default, else zero. */\nfunction priority(child: Element): number {\n const own = child.getAttribute('priority');\n if (own !== null) {\n const value = Number(own);\n return Number.isFinite(value) && value > 0 ? value : 0;\n }\n return PRIORITY[child.localName] ?? 0;\n}\n\nfunction end(video: HTMLVideoElement): number {\n if (Number.isFinite(video.duration)) return video.duration;\n const ranges = video.seekable;\n return ranges.length > 0 ? ranges.end(ranges.length - 1) : video.currentTime;\n}\n\nfunction toggle(video: HTMLVideoElement): void {\n if (video.paused) video.play().catch(() => undefined);\n else video.pause();\n}\n\nexport class MbxControlBar extends Component {\n static get observedAttributes(): readonly string[] {\n return ['idle-ms', 'seek-step'];\n }\n\n declare private readonly seekRow: HTMLDivElement;\n declare private readonly buttonsRow: HTMLDivElement;\n declare private readonly buttons: HTMLSlotElement;\n declare private timer: ReturnType<typeof setTimeout> | undefined;\n /** Fires on a width change of the buttons row, so the collapse follows the page's layout. */\n declare private resizer: ResizeObserver | null;\n /** Whether the last input was a key, so focus inside holds the bar. */\n declare private keyboard: boolean;\n declare private cues: CueLift | null;\n declare private screen: Fullscreen | null;\n\n constructor() {\n super();\n this.timer = undefined;\n this.keyboard = false;\n this.cues = null;\n this.screen = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.seekRow = document.createElement('div');\n this.seekRow.setAttribute('part', 'row seek-row');\n const seek = document.createElement('slot');\n seek.name = 'seek';\n this.seekRow.append(seek);\n this.buttonsRow = document.createElement('div');\n this.buttonsRow.setAttribute('part', 'row buttons-row');\n this.buttons = document.createElement('slot');\n this.buttonsRow.append(this.buttons);\n root.append(style(STYLE), this.seekRow, this.buttonsRow);\n }\n\n /**\n * What the buttons need: their widths and their margins, which are the\n * gaps between them, the spacer aside since it takes what is left, and a\n * folded slider at the width it unfolds to. The row's own width says nothing, because the\n * spacer fills it whatever the buttons take.\n */\n /** The bar's em in pixels: its sizes follow the player's font size. */\n private em(): number {\n return Number.parseFloat(getComputedStyle(this).fontSize) || 16;\n }\n\n private needed(children: readonly Element[]): number {\n let sum = 0;\n for (const child of children) {\n if (child.localName === SPACER || !shown(child)) continue;\n const margins = getComputedStyle(child);\n sum += child.getBoundingClientRect().width;\n sum += Number.parseFloat(margins.marginLeft) + Number.parseFloat(margins.marginRight);\n const folded = slider(child);\n if (folded !== null && shown(folded)) {\n sum += Math.max(0, SLIDER_WIDTH * this.em() - folded.getBoundingClientRect().width);\n }\n }\n return sum;\n }\n\n /**\n * Collapses the buttons row to its width. Everything is shown first, so\n * a wider bar gets its controls back, then the highest priorities go one\n * at a time while the buttons need more than the row has, less the\n * slack. Each step lays the row out again; a bar carries a dozen\n * controls, so that is cheap.\n */\n private collapse(): void {\n const children = this.buttons.assignedElements();\n const candidates: Candidate[] = [];\n for (const [index, child] of children.entries()) {\n child.removeAttribute('collapsed');\n const inner = slider(child);\n inner?.removeAttribute('collapsed');\n // A nested slider goes before its group, so it sorts as if it sat\n // after it. What is not shown, by its own `hidden` or a page's rule,\n // takes no room, so marking it would hide nothing and say something\n // false.\n if (inner !== null && shown(inner)) {\n candidates.push({ node: inner, index: index + 0.5, priority: priority(inner) });\n }\n if (shown(child)) candidates.push({ node: child, index, priority: priority(child) });\n }\n candidates.sort((a, b) => b.priority - a.priority || b.index - a.index);\n const room = this.buttonsRow.clientWidth - SLACK * this.em();\n for (const { node, priority: level } of candidates) {\n if (level === 0) return;\n if (this.needed(children) <= room) return;\n node.setAttribute('collapsed', '');\n }\n }\n\n /** From the first row's top to the bar's bottom: what the bar covers of the picture. */\n private covered(): { top: number; bottom: number } {\n return {\n top: this.seekRow.getBoundingClientRect().top,\n bottom: this.getBoundingClientRect().bottom,\n };\n }\n\n private held(player: PlayerHost): boolean {\n if (shownPaused(player, ['switching'])) return true;\n if (this.querySelector('[open]') !== null) return true;\n if (!this.keyboard) return false;\n const active = (this.getRootNode() as Document | ShadowRoot).activeElement;\n return active !== null && this.contains(active);\n }\n\n private idle(player: PlayerHost, on: boolean): void {\n if (this.hasAttribute('idle') === on) return;\n this.toggleAttribute('idle', on);\n player.toggleAttribute('idle', on);\n this.cues?.lifted(!on);\n }\n\n private sleep(player: PlayerHost): void {\n this.timer = undefined;\n // A hold is checked again later: a menu closes and a pause ends without\n // an event the bar hears.\n if (this.held(player)) {\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n return;\n }\n this.idle(player, true);\n }\n\n private wake(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.idle(player, false);\n this.timer = setTimeout(() => this.sleep(player), number(this, 'idle-ms', IDLE_MS));\n }\n\n /**\n * A seeking key: `seekkey` on the player first, cancellable, with the\n * seconds in `detail.by`. A seek bar under `key-mode=\"preview\"` takes it\n * to aim instead. Nobody took it: the playhead moves now.\n */\n private seekBy(player: PlayerHost, by: number): void {\n const asked = new CustomEvent('seekkey', { detail: { by }, cancelable: true });\n if (!player.dispatchEvent(asked)) return;\n const video = player.video;\n video.currentTime = Math.min(end(video), Math.max(0, video.currentTime + by));\n }\n\n private key(player: PlayerHost, event: KeyboardEvent): void {\n this.keyboard = true;\n this.wake(player);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n const video = player.video;\n const onButton = event.composedPath()[0] instanceof HTMLButtonElement;\n switch (event.key) {\n case ' ':\n if (onButton) return;\n toggle(video);\n break;\n case 'k':\n case 'K':\n toggle(video);\n break;\n case 'm':\n case 'M':\n video.muted = !video.muted;\n break;\n case 'f':\n case 'F':\n this.screen?.toggle();\n break;\n // The media keys, which remotes and many keyboards send. UI Events\n // KeyboardEvent key values, Multimedia keys.\n case 'MediaPlayPause':\n toggle(video);\n break;\n case 'MediaPlay':\n void video.play().catch(() => undefined);\n break;\n // Stop pauses: the source stays, as a viewer expects on a remote.\n case 'MediaPause':\n case 'MediaStop':\n video.pause();\n break;\n case 'ArrowLeft':\n case 'MediaRewind':\n this.seekBy(player, -number(this, 'seek-step', SEEK_STEP));\n break;\n case 'ArrowRight':\n case 'MediaFastForward':\n this.seekBy(player, number(this, 'seek-step', SEEK_STEP));\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n protected override attach(player: PlayerHost): void {\n const video = player.video;\n cueStyle();\n this.cues = cueLift(video, player, () => this.covered());\n const screen = fullscreen(player, video);\n this.screen = screen;\n const reflect = (): void => {\n player.toggleAttribute('fullscreen', screen.active());\n };\n this.keep(screen.watch(reflect));\n reflect();\n // `menu` while one of the bar's menus is open, by its `open` attribute:\n // the bar then stacks above the screens and hides its tooltips.\n const menus = new MutationObserver(() => {\n this.toggleAttribute('menu', this.querySelector('[open]') !== null);\n });\n menus.observe(this, { subtree: true, attributes: true, attributeFilter: ['open'] });\n this.keep(() => {\n menus.disconnect();\n this.removeAttribute('menu');\n });\n\n const pointer = (): void => {\n this.keyboard = false;\n this.wake(player);\n };\n const key = (event: Event): void => {\n this.key(player, event as KeyboardEvent);\n };\n const click = (event: Event): void => {\n // The video and nothing else: a control handles its own click.\n if (event.composedPath()[0] === video) toggle(video);\n };\n this.listen(player, ['pointermove', 'pointerdown'], pointer);\n player.addEventListener('keydown', key);\n player.addEventListener('click', click);\n this.keep(() => {\n player.removeEventListener('keydown', key);\n player.removeEventListener('click', click);\n });\n this.listen(video, ['play', 'pause', 'ended'], () => {\n // The load of a switch pauses and plays the video, and the viewer did neither.\n if (!player.hasAttribute('switching')) this.wake(player);\n });\n this.wake(player);\n this.cues.lifted(true);\n\n // The row's width, its children, and what they hide or reprioritise on\n // their own: each can change what fits. `collapsed` is left out of the\n // filter, since the bar writes it.\n const collapse = (): void => {\n this.collapse();\n };\n this.listen(this.buttons, ['slotchange'], collapse);\n this.observe(this, ['hidden', 'priority', 'slot'], collapse, true);\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(collapse);\n this.resizer.observe(this.buttonsRow);\n }\n collapse();\n }\n\n protected override detach(player: PlayerHost): void {\n clearTimeout(this.timer);\n this.timer = undefined;\n this.resizer?.disconnect();\n this.resizer = null;\n for (const child of this.buttons.assignedElements()) {\n child.removeAttribute('collapsed');\n slider(child)?.removeAttribute('collapsed');\n }\n this.cues?.dispose();\n this.cues = null;\n this.screen = null;\n this.removeAttribute('idle');\n player.removeAttribute('idle');\n player.removeAttribute('fullscreen');\n }\n}\n"],"mappings":";;;;;;AAiEA,MAAA,QAAA;AAGA,MAAA,UAAA;AACA,MAAA,YAAA;;;;;;;;;;;;AAaA,MAAA,WAAA;EACA,cAAA;EACA,gBAAA;CACA,mBAAA;EACA,YAAA;EACA,aAAA;EACA,gBAAA;EACA,aAAA;EACA,eAAA;EACA,aAAA;EACA,iBAAA;EACA,cAAA;EACA,iBAAA;EACA,aAAA;EACA,SAAA;EACA,cA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 @@
1
1
  import { format } from "../controls/time.js";
2
2
  import { live, span, wall } from "../controls/session.js";
3
3
  import { TimeElement } from "./time-element.js";
4
- //#region src/elements/current-time.ts
4
+ // src/elements/current-time.ts
5
5
  /**
6
6
  * <mbx-current-time>: the position, "1:23". On a live stream it reads the
7
7
  * wall clock when `engine.pdt` can say it, "14:23:05", which is what a
@@ -22,7 +22,6 @@ var MbxCurrentTime = class extends TimeElement {
22
22
  this.hidden = on && player.hasAttribute("live") && !player.hasAttribute("seekable") || !on && this.getAttribute("layout") === "compact";
23
23
  }
24
24
  };
25
- //#endregion
26
25
  export { MbxCurrentTime };
27
26
 
28
27
  //# sourceMappingURL=current-time.js.map
@@ -4,7 +4,7 @@ import { namespaces } from "../namespaces.js";
4
4
  import { icon } from "../controls/icons.js";
5
5
  import { Component } from "./component.js";
6
6
  import { style } from "./shared.js";
7
- //#region src/elements/drm-badge.ts
7
+ // src/elements/drm-badge.ts
8
8
  const STYLE = ":host{width:2.5em;height:2.5em;color:var(--mbx-muted);border-radius:var(--mbx-radius);cursor:default;justify-content:center;align-items:center;display:inline-flex;position:relative}:host([hidden]){display:none}:host(:focus){outline:2px solid var(--mbx-accent);outline-offset:-2px}:host(:focus:not(:focus-visible)){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}[part~=tooltip]{border-radius:var(--mbx-radius);color:var(--mbx-text);text-align:left;white-space:nowrap;pointer-events:none;background:#1c1c20f2;margin-bottom:.6154em;padding:.6154em .7692em;font-size:.8125em;line-height:1.4;position:absolute;bottom:100%;right:0;box-shadow:0 4px 16px #00000080}[part~=tooltip][hidden]{display:none}[part~=tooltip-title]{font-weight:600}[part~=tooltip-text]{color:var(--mbx-muted)}";
9
9
  /** The name a viewer knows a key system by. */
10
10
  function keySystemName(id) {
@@ -57,12 +57,12 @@ var MbxDrmBadge = class extends Component {
57
57
  }
58
58
  /** "3 keys: usable ×2, expired", or "no key yet". */
59
59
  sessionsText(sessions) {
60
- if (sessions.length === 0) return this.getAttribute("label-no-key") ?? "no key yet";
60
+ if (sessions.length === 0) return this.word("label-no-key", "drmNoKey", "no key yet");
61
61
  const counts = /* @__PURE__ */ new Map();
62
62
  for (const session of sessions) counts.set(session.status, (counts.get(session.status) ?? 0) + 1);
63
63
  const parts = [];
64
64
  for (const [status, count] of counts) parts.push(count > 1 ? `${status} ×${count}` : status);
65
- const template = sessions.length === 1 ? this.getAttribute("label-key") ?? "{count} key: {statuses}" : this.getAttribute("label-keys") ?? "{count} keys: {statuses}";
65
+ const template = sessions.length === 1 ? this.word("label-key", "drmKey", "{count} key: {statuses}") : this.word("label-keys", "drmKeys", "{count} keys: {statuses}");
66
66
  return fill(template, {
67
67
  count: sessions.length,
68
68
  statuses: parts.join(", ")
@@ -101,13 +101,12 @@ var MbxDrmBadge = class extends Component {
101
101
  this.system.textContent = system;
102
102
  this.system_id.textContent = name;
103
103
  this.keys.textContent = keys;
104
- this.setAttribute("aria-label", fill(this.getAttribute("label") ?? "Protected by {system}, {keys}", {
104
+ this.setAttribute("aria-label", fill(this.word("label", "drmProtected", "Protected by {system}, {keys}"), {
105
105
  system,
106
106
  keys
107
107
  }));
108
108
  }
109
109
  };
110
- //#endregion
111
110
  export { MbxDrmBadge };
112
111
 
113
112
  //# sourceMappingURL=drm-badge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drm-badge.js","names":[],"sources":["../../src/elements/drm-badge.ts"],"sourcesContent":["/**\n * <mbx-drm-badge>: a lock over `engine.drm`, or over `session.eme.drm`\n * for a native session that attached DRM, hidden until a key system is\n * known and for a session without the EME stages. Hover or focus shows\n * what it knows: the key system, and the key sessions with their\n * statuses. The glyph is `icon`; the name comes from `label`, where\n * `{system}` is the key system's name and `{keys}` the sessions:\n * \"Protected by {system}, {keys}\". The sessions read from `label-keys`\n * with `{count}` and `{statuses}`, `label-key` for one, `label-no-key`\n * for none.\n */\n\nimport type { DrmApi } from 'mattebox/eme';\nimport { icon } from '../controls/icons.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { namespaces } from '../namespaces.js';\nimport { Component } from './component.js';\nimport STYLE from './drm-badge.css?inline';\nimport { style } from './shared.js';\n\n/** The name a viewer knows a key system by. */\nfunction keySystemName(id: string): string {\n if (id.startsWith('com.widevine')) return 'Widevine';\n if (id.startsWith('com.microsoft.playready')) return 'PlayReady';\n if (id.startsWith('com.apple.fps')) return 'FairPlay';\n return id;\n}\n\nexport class MbxDrmBadge extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-key', 'label-keys', 'label-no-key'];\n }\n\n declare private readonly tooltip: HTMLElement;\n declare private readonly system: HTMLElement;\n declare private readonly system_id: HTMLElement;\n declare private readonly keys: HTMLElement;\n declare private drm: DrmApi | undefined;\n\n constructor() {\n super();\n this.drm = undefined;\n const root = this.attachShadow({ mode: 'open' });\n const slot = document.createElement('slot');\n slot.name = 'icon';\n slot.append(icon('lock-closed'));\n this.tooltip = el('div', 'tooltip');\n this.tooltip.setAttribute('role', 'tooltip');\n this.system = el('div', 'tooltip-title');\n this.system_id = el('div', 'tooltip-text');\n this.keys = el('div', 'tooltip-text');\n this.tooltip.append(this.system, this.system_id, this.keys);\n this.tooltip.hidden = true;\n root.append(style(STYLE), slot, this.tooltip);\n const show = (): void => {\n this.tooltip.hidden = false;\n };\n const hide = (): void => {\n this.tooltip.hidden = true;\n };\n this.addEventListener('pointerenter', show);\n this.addEventListener('pointerleave', hide);\n this.addEventListener('focus', show);\n this.addEventListener('blur', hide);\n }\n\n /** Named and focusable before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'img');\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (this.player === null) this.hidden = true;\n super.connectedCallback();\n }\n\n /** \"3 keys: usable ×2, expired\", or \"no key yet\". */\n private sessionsText(sessions: ReadonlyArray<{ readonly status: string }>): string {\n if (sessions.length === 0) return this.getAttribute('label-no-key') ?? 'no key yet';\n const counts = new Map<string, number>();\n for (const session of sessions) {\n counts.set(session.status, (counts.get(session.status) ?? 0) + 1);\n }\n const parts: string[] = [];\n for (const [status, count] of counts) parts.push(count > 1 ? `${status} ×${count}` : status);\n const template =\n sessions.length === 1\n ? (this.getAttribute('label-key') ?? '{count} key: {statuses}')\n : (this.getAttribute('label-keys') ?? '{count} keys: {statuses}');\n return fill(template, { count: sessions.length, statuses: parts.join(', ') });\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n // The engine's DRM, or the attachment a native session made: one API, the same events.\n const eme = player.player?.session?.eme;\n const source = engine ?? eme;\n this.drm = engine === null ? eme?.drm : namespaces(engine).drm;\n this.render();\n if (source === undefined || this.drm === undefined) return undefined;\n const tick = (): void => {\n this.render();\n };\n const offs = ['drm:keysystem', 'drm:keystatus', 'drm:encrypted'].map((event) =>\n source.on(event, tick),\n );\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override detach(): void {\n this.tooltip.hidden = true;\n }\n\n protected override render(): void {\n const drm = this.drm;\n const name = drm?.keySystem ?? null;\n this.hidden = name === null;\n if (drm === undefined || name === null) return;\n const keys = this.sessionsText(drm.sessions);\n const system = keySystemName(name);\n this.system.textContent = system;\n this.system_id.textContent = name;\n this.keys.textContent = keys;\n this.setAttribute(\n 'aria-label',\n fill(this.getAttribute('label') ?? 'Protected by {system}, {keys}', { system, keys }),\n );\n }\n}\n"],"mappings":";;;;;;;AAmBA,MAAA,QAAA;;AAIA,SAAA,cAAA,IAAA;CACA,IAAA,GAAA,WAAA,cAAA,GAAA,OAAA;CACA,IAAA,GAAA,WAAA,yBAAA,GAAA,OAAA;CACA,IAAA,GAAA,WAAA,eAAA,GAAA,OAAA;CACA,OAAA;AACA;AAEA,IAAA,cAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,MAAA,KAAA;EACA,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A,4BACA,KAAA,aAAA,YAAA,KAAA;EACA,OAAA,KAAA,UAAA;GAAA,OAAA,SAAA;GAAA,UAAA,MAAA,KAAA,IAAA;EAAA,CAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,SAAA,WAAA;GAEA,MAAA,MAAA,OAAA,QAAA,SAAA;GACA,MAAA,SAAA,UAAA;GACA,KAAA,MAAA,WAAA,OAAA,KAAA,MAAA,WAAA,MAAA,CAAA,CAAA;GACA,KAAA,OAAA;GACA,IAAA,WAAA,KAAA,KAAA,KAAA,QAAA,KAAA,GAAA,OAAA,KAAA;GACA,MAAA,aAAA;IACA,KAAA,OAAA;GACA;GACA,MAAA,OAAA;IAAA;IAAA;IAAA;GAAA,CAAA,CAAA,KAAA,UACA,OAAA,GAAA,OAAA,IAAA,CACA;GACA,aAAA;IACA,KAAA,MAAA,OAAA,MAAA,IAAA;GACA;EACA,CAAA;CACA;CAEA,SAAA;EACA,KAAA,QAAA,SAAA;CACA;CAEA,SAAA;EACA,MAAA,MAAA,KAAA;EACA,MAAA,OAAA,KAAA,aAAA;EACA,KAAA,SAAA,SAAA;EACA,IAAA,QAAA,KAAA,KAAA,SAAA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,IAAA,QAAA;EACA,MAAA,SAAA,cAAA,IAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,UAAA,cAAA;EACA,KAAA,KAAA,cAAA;EACA,KAAA,aACA,cACA,KAAA,KAAA,aAAA,OAAA,KAAA,iCAAA;GAAA;GAAA;EAAA,CAAA,CACA;CACA;AACA"}
1
+ {"version":3,"file":"drm-badge.js","names":[],"sources":["../../src/elements/drm-badge.ts"],"sourcesContent":["/**\n * <mbx-drm-badge>: a lock over `engine.drm`, or over `session.eme.drm`\n * for a native session that attached DRM, hidden until a key system is\n * known and for a session without the EME stages. Hover or focus shows\n * what it knows: the key system, and the key sessions with their\n * statuses. The glyph is `icon`; the name comes from `label`, where\n * `{system}` is the key system's name and `{keys}` the sessions:\n * \"Protected by {system}, {keys}\". The sessions read from `label-keys`\n * with `{count}` and `{statuses}`, `label-key` for one, `label-no-key`\n * for none.\n */\n\nimport type { DrmApi } from 'mattebox/eme';\nimport { icon } from '../controls/icons.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { namespaces } from '../namespaces.js';\nimport { Component } from './component.js';\nimport STYLE from './drm-badge.css?inline';\nimport { style } from './shared.js';\n\n/** The name a viewer knows a key system by. */\nfunction keySystemName(id: string): string {\n if (id.startsWith('com.widevine')) return 'Widevine';\n if (id.startsWith('com.microsoft.playready')) return 'PlayReady';\n if (id.startsWith('com.apple.fps')) return 'FairPlay';\n return id;\n}\n\nexport class MbxDrmBadge extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-key', 'label-keys', 'label-no-key'];\n }\n\n declare private readonly tooltip: HTMLElement;\n declare private readonly system: HTMLElement;\n declare private readonly system_id: HTMLElement;\n declare private readonly keys: HTMLElement;\n declare private drm: DrmApi | undefined;\n\n constructor() {\n super();\n this.drm = undefined;\n const root = this.attachShadow({ mode: 'open' });\n const slot = document.createElement('slot');\n slot.name = 'icon';\n slot.append(icon('lock-closed'));\n this.tooltip = el('div', 'tooltip');\n this.tooltip.setAttribute('role', 'tooltip');\n this.system = el('div', 'tooltip-title');\n this.system_id = el('div', 'tooltip-text');\n this.keys = el('div', 'tooltip-text');\n this.tooltip.append(this.system, this.system_id, this.keys);\n this.tooltip.hidden = true;\n root.append(style(STYLE), slot, this.tooltip);\n const show = (): void => {\n this.tooltip.hidden = false;\n };\n const hide = (): void => {\n this.tooltip.hidden = true;\n };\n this.addEventListener('pointerenter', show);\n this.addEventListener('pointerleave', hide);\n this.addEventListener('focus', show);\n this.addEventListener('blur', hide);\n }\n\n /** Named and focusable before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (!this.hasAttribute('role')) this.setAttribute('role', 'img');\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n if (this.player === null) this.hidden = true;\n super.connectedCallback();\n }\n\n /** \"3 keys: usable ×2, expired\", or \"no key yet\". */\n private sessionsText(sessions: ReadonlyArray<{ readonly status: string }>): string {\n if (sessions.length === 0) return this.word('label-no-key', 'drmNoKey', 'no key yet');\n const counts = new Map<string, number>();\n for (const session of sessions) {\n counts.set(session.status, (counts.get(session.status) ?? 0) + 1);\n }\n const parts: string[] = [];\n for (const [status, count] of counts) parts.push(count > 1 ? `${status} ×${count}` : status);\n const template =\n sessions.length === 1\n ? this.word('label-key', 'drmKey', '{count} key: {statuses}')\n : this.word('label-keys', 'drmKeys', '{count} keys: {statuses}');\n return fill(template, { count: sessions.length, statuses: parts.join(', ') });\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n // The engine's DRM, or the attachment a native session made: one API, the same events.\n const eme = player.player?.session?.eme;\n const source = engine ?? eme;\n this.drm = engine === null ? eme?.drm : namespaces(engine).drm;\n this.render();\n if (source === undefined || this.drm === undefined) return undefined;\n const tick = (): void => {\n this.render();\n };\n const offs = ['drm:keysystem', 'drm:keystatus', 'drm:encrypted'].map((event) =>\n source.on(event, tick),\n );\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override detach(): void {\n this.tooltip.hidden = true;\n }\n\n protected override render(): void {\n const drm = this.drm;\n const name = drm?.keySystem ?? null;\n this.hidden = name === null;\n if (drm === undefined || name === null) return;\n const keys = this.sessionsText(drm.sessions);\n const system = keySystemName(name);\n this.system.textContent = system;\n this.system_id.textContent = name;\n this.keys.textContent = keys;\n this.setAttribute(\n 'aria-label',\n fill(this.word('label', 'drmProtected', 'Protected by {system}, {keys}'), { system, keys }),\n );\n }\n}\n"],"mappings":";;;;;;;AAmBA,MAAA,QAAA;;AAIA,SAAA,cAAA,IAAA;CACA,IAAA,GAAA,WAAA,cAAA,GAAA,OAAA;CACA,IAAA,GAAA,WAAA,yBAAA,GAAA,OAAA;CACA,IAAA,GAAA,WAAA,eAAA,GAAA,OAAA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,MAAA,QAAA,CAAA;EACA,KAAA,MAAA,CAAA,QAAA,UAAA,QAAA,MAAA,KAAA,QAAA,IAAA,GAAA,OAAA,IAAA,UAAA,MAAA;EACA,MAAA,WACA,SAAA,WAAA,IACA,KAAA,KAAA,aAAA,UAAA,yBAAA,IACA,KAAA,KAAA,cAAA,WAAA,0BAAA;EACA,OAAA,KAAA,UAAA;GAAA,OAAA,SAAA;GAAA,UAAA,MAAA,KAAA,IAAA;EAAA,CAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,SAAA,WAAA;GAEA,MAAA,MAAA,OAAA,QAAA,SAAA;GACA,MAAA,SAAA,UAAA;GACA,KAAA,MAAA,WAAA,OAAA,KAAA,MAAA,WAAA,MAAA,CAAA,CAAA;GACA,KAAA,OAAA;GACA,IAAA,WAAA,KAAA,KAAA,KAAA,QAAA,KAAA,GAAA,OAAA,KAAA;GACA,MAAA,aAAA;IACA,KAAA,OAAA;GACA;GACA,MAAA,OAAA;IAAA;IAAA;IAAA;GAAA,CAAA,CAAA,KAAA,UACA,OAAA,GAAA,OAAA,IAAA,CACA;GACA,aAAA;IACA,KAAA,MAAA,OAAA,MAAA,IAAA;GACA;EACA,CAAA;CACA;CAEA,SAAA;EACA,KAAA,QAAA,SAAA;CACA;CAEA,SAAA;EACA,MAAA,MAAA,KAAA;EACA,MAAA,OAAA,KAAA,aAAA;EACA,KAAA,SAAA,SAAA;EACA,IAAA,QAAA,KAAA,KAAA,SAAA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,IAAA,QAAA;EACA,MAAA,SAAA,cAAA,IAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,UAAA,cAAA;EACA,KAAA,KAAA,cAAA;EACA,KAAA,aACA,cACA,KAAA,KAAA,KAAA,SAAA,gBAAA,+BAAA,GAAA;GAAA;GAAA;EAAA,CAAA,CACA;CACA;AACA"}
@@ -1,7 +1,7 @@
1
1
  import { format } from "../controls/time.js";
2
2
  import { live, span } from "../controls/session.js";
3
3
  import { TimeElement } from "./time-element.js";
4
- //#region src/elements/duration.ts
4
+ // src/elements/duration.ts
5
5
  /**
6
6
  * <mbx-duration>: the duration, "4:56", once the metadata is in. A live
7
7
  * stream has none, so the element hides while the stream is live. On a
@@ -24,7 +24,6 @@ var MbxDuration = class extends TimeElement {
24
24
  this.text.data = this.getAttribute("layout") === "compact" ? `-${format(Math.max(0, end - player.video.currentTime))}` : format(end);
25
25
  }
26
26
  };
27
- //#endregion
28
27
  export { MbxDuration };
29
28
 
30
29
  //# sourceMappingURL=duration.js.map
@@ -5,13 +5,22 @@ export declare class MbxErrorScreen extends Component {
5
5
  private readonly title_;
6
6
  private readonly category;
7
7
  private readonly code;
8
+ private readonly detail;
9
+ private readonly message;
8
10
  private readonly retry;
11
+ private readonly inspect;
12
+ /** The block shown, or null for an error. */
13
+ private block;
9
14
  constructor();
10
15
  /** Hidden and named before attaching: a constructor must not add attributes. */
11
16
  connectedCallback(): void;
12
17
  private show;
18
+ /** Shows `block`, or hides the screen for null. */
19
+ private showBlock;
13
20
  protected attach(player: PlayerHost): void;
14
21
  protected detach(): void;
22
+ /** The player's diagnostics panel, when the page put one in it. */
23
+ private diagnostics;
15
24
  protected render(): void;
16
25
  }
17
26
  //# sourceMappingURL=error-screen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-screen.d.ts","sourceRoot":"","sources":["../../src/elements/error-screen.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,cAAe,SAAQ,SAAS;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAc;IAC7C,iBAAyB,QAAQ,CAAc;IAC/C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,KAAK,CAAoB;;IAwBlD,gFAAgF;IACvE,iBAAiB,IAAI,IAAI;IAMlC,OAAO,CAAC,IAAI;cAMO,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAsBhC,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAIlC"}
1
+ {"version":3,"file":"error-screen.d.ts","sourceRoot":"","sources":["../../src/elements/error-screen.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAS,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ3C,qBAAa,cAAe,SAAQ,SAAS;IAC3C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAc;IAC7C,iBAAyB,QAAQ,CAAc;IAC/C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,MAAM,CAAc;IAC7C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAoB;IAClD,iBAAyB,OAAO,CAAoB;IACpD,6CAA6C;IAC7C,QAAgB,KAAK,CAAe;;IA6BpC,gFAAgF;IACvE,iBAAiB,IAAI,IAAI;IAMlC,OAAO,CAAC,IAAI;IAQZ,mDAAmD;IACnD,OAAO,CAAC,SAAS;cAME,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA0BhC,MAAM,IAAI,IAAI;IAIjC,mEAAmE;IACnE,OAAO,CAAC,WAAW;cAIA,MAAM,IAAI,IAAI;CAuBlC"}
@@ -1,11 +1,18 @@
1
1
  import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
3
  import { style } from "./shared.js";
4
- //#region src/elements/error-screen.ts
5
- const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=retry]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
4
+ // src/elements/error-screen.ts
5
+ const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=message]{max-width:32em}[part~=actions]>:not([hidden])~:not([hidden]){margin-left:.5333em}[part~=action]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=action]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=action]:focus:not(:focus-visible){outline:none}";
6
+ /** The diagnostics element, another package's, named here as a string. */
7
+ const DIAGNOSTICS = "mbx-diagnostics";
6
8
  var MbxErrorScreen = class extends Component {
7
9
  static get observedAttributes() {
8
- return ["label-title", "label-retry"];
10
+ return [
11
+ "label-title",
12
+ "label-retry",
13
+ "label-blocked",
14
+ "label-diagnostics"
15
+ ];
9
16
  }
10
17
  constructor() {
11
18
  super();
@@ -14,16 +21,23 @@ var MbxErrorScreen = class extends Component {
14
21
  this.title_ = el("div", "title");
15
22
  this.category = el("span", "category");
16
23
  this.code = el("span", "code");
17
- const detail = el("div", "detail");
18
- detail.append(this.category, el("span", "separator", " · "), this.code);
19
- this.retry = el("button", "retry");
24
+ this.detail = el("div", "detail");
25
+ this.detail.append(this.category, el("span", "separator", " · "), this.code);
26
+ this.message = el("div", "message");
27
+ this.block = null;
28
+ this.retry = el("button", "action retry");
20
29
  this.retry.type = "button";
21
30
  this.retry.addEventListener("click", () => {
22
- const player = this.player;
23
- const src = player?.getAttribute("src");
24
- if (player !== null && player !== void 0 && src !== null && src !== void 0) player.setAttribute("src", src);
31
+ this.player?.retry();
25
32
  });
26
- box.append(this.title_, detail, this.retry);
33
+ this.inspect = el("button", "action diagnostics");
34
+ this.inspect.type = "button";
35
+ this.inspect.addEventListener("click", () => {
36
+ this.diagnostics()?.show();
37
+ });
38
+ const actions = el("div", "actions");
39
+ actions.append(this.retry, this.inspect);
40
+ box.append(this.title_, this.detail, this.message, actions);
27
41
  root.append(style(STYLE), box);
28
42
  }
29
43
  /** Hidden and named before attaching: a constructor must not add attributes. */
@@ -33,10 +47,18 @@ var MbxErrorScreen = class extends Component {
33
47
  super.connectedCallback();
34
48
  }
35
49
  show(error) {
50
+ this.block = null;
36
51
  this.category.textContent = error.category;
37
52
  this.code.textContent = error.code;
53
+ this.render();
38
54
  this.hidden = false;
39
55
  }
56
+ /** Shows `block`, or hides the screen for null. */
57
+ showBlock(block) {
58
+ this.block = block;
59
+ this.render();
60
+ this.hidden = block === null;
61
+ }
40
62
  attach(player) {
41
63
  const failure = (event) => {
42
64
  const error = event.detail;
@@ -47,23 +69,41 @@ var MbxErrorScreen = class extends Component {
47
69
  player.removeEventListener("error", failure);
48
70
  });
49
71
  this.listen(player.video, ["playing", "loadstart"], () => {
50
- this.hidden = true;
72
+ if (this.block === null) this.hidden = true;
51
73
  });
52
74
  this.listen(player, ["sourcechange"], () => {
53
- this.hidden = true;
75
+ if (this.block === null) this.hidden = true;
76
+ });
77
+ this.listen(player, ["blockchange"], () => {
78
+ this.showBlock(player.blocked);
54
79
  });
55
80
  if (player.error !== null) this.show(player.error);
81
+ if (player.blocked !== null) this.showBlock(player.blocked);
56
82
  this.render();
57
83
  }
58
84
  detach() {
59
85
  this.hidden = true;
60
86
  }
87
+ /** The player's diagnostics panel, when the page put one in it. */
88
+ diagnostics() {
89
+ return this.player?.querySelector(DIAGNOSTICS);
90
+ }
61
91
  render() {
62
- this.title_.textContent = this.getAttribute("label-title") ?? "Playback failed";
63
- this.retry.textContent = this.getAttribute("label-retry") ?? "Retry";
92
+ const block = this.block;
93
+ this.detail.hidden = block !== null;
94
+ this.retry.hidden = block !== null;
95
+ this.inspect.hidden = block !== null || this.diagnostics() === null;
96
+ this.inspect.textContent = this.word("label-diagnostics", "diagnostics", "Diagnostics");
97
+ this.message.hidden = block?.message === void 0;
98
+ if (block === null) {
99
+ this.title_.textContent = this.word("label-title", "playbackFailed", "Playback failed");
100
+ this.retry.textContent = this.word("label-retry", "retry", "Retry");
101
+ return;
102
+ }
103
+ this.title_.textContent = block.title === void 0 ? this.word("label-blocked", "blocked", "Not available") : this.pageText(block.title);
104
+ this.message.textContent = block.message === void 0 ? "" : this.pageText(block.message);
64
105
  }
65
106
  };
66
- //#endregion
67
107
  export { MbxErrorScreen };
68
108
 
69
109
  //# sourceMappingURL=error-screen.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-screen.js","names":[],"sources":["../../src/elements/error-screen.ts"],"sourcesContent":["/**\n * <mbx-error-screen>: a fatal error over the picture, with the category,\n * the code and a retry. It sits in the player beside the video, hidden\n * until the player reports a fatal error, and clears when a session\n * arrives, a resource starts loading, or playback resumes: an error over\n * a picture that then plays is wrong by definition. The title comes from `label-title`, the button's text\n * from `label-retry`.\n *\n * Retry sets the player's `src` to its own value again, which is the one\n * public way to load a source again: the element reloads on every write\n * to `src`, equal or not.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE from './error-screen.css?inline';\nimport { style } from './shared.js';\n\nexport class MbxErrorScreen extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-title', 'label-retry'];\n }\n\n declare private readonly title_: HTMLElement;\n declare private readonly category: HTMLElement;\n declare private readonly code: HTMLElement;\n declare private readonly retry: HTMLButtonElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n const box = el('div', 'box');\n this.title_ = el('div', 'title');\n this.category = el('span', 'category');\n this.code = el('span', 'code');\n const detail = el('div', 'detail');\n detail.append(this.category, el('span', 'separator', ' · '), this.code);\n this.retry = el('button', 'retry');\n this.retry.type = 'button';\n this.retry.addEventListener('click', () => {\n const player = this.player;\n const src = player?.getAttribute('src');\n if (player !== null && player !== undefined && src !== null && src !== undefined) {\n player.setAttribute('src', src);\n }\n });\n box.append(this.title_, detail, this.retry);\n root.append(style(STYLE), box);\n }\n\n /** Hidden and named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (this.player === null) this.hidden = true;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'alert');\n super.connectedCallback();\n }\n\n private show(error: PlayerError): void {\n this.category.textContent = error.category;\n this.code.textContent = error.code;\n this.hidden = false;\n }\n\n protected override attach(player: PlayerHost): void {\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (error.fatal) this.show(error);\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n // Not `emptied`: the old session's teardown fires it after the new\n // source's error, and would hide the error it should leave.\n this.listen(player.video, ['playing', 'loadstart'], () => {\n this.hidden = true;\n });\n this.listen(player, ['sourcechange'], () => {\n this.hidden = true;\n });\n // The error may have come before this element did.\n if (player.error !== null) this.show(player.error);\n this.render();\n }\n\n protected override detach(): void {\n this.hidden = true;\n }\n\n protected override render(): void {\n this.title_.textContent = this.getAttribute('label-title') ?? 'Playback failed';\n this.retry.textContent = this.getAttribute('label-retry') ?? 'Retry';\n }\n}\n"],"mappings":";;;;AAgBA,MAAA,QAAA;AAGA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA,CAAA,eAAA,aAAA;CACA;CAOA,cAAA;EACA,MAAA;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AEA,IAAA,OAAA,UAAA,MAAA,KAAA,KAAA,OAAA,KAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA;CACA;CAEA,SAAA;EACA,KAAA,OAAA,cAAA,KAAA,aAAA,aAAA,KAAA;EACA,KAAA,MAAA,cAAA,KAAA,aAAA,aAAA,KAAA;CACA;AACA"}
1
+ {"version":3,"file":"error-screen.js","names":[],"sources":["../../src/elements/error-screen.ts"],"sourcesContent":["/**\n * <mbx-error-screen>: a fatal error over the picture, with the category,\n * the code and a retry. It sits in the player beside the video, hidden\n * until the player reports a fatal error, and clears when a session\n * arrives, a resource starts loading, or playback resumes: an error over\n * a picture that then plays is wrong by definition. The title comes from `label-title`, the button's text\n * from `label-retry`.\n *\n * Retry calls the player's `retry()`, which loads the sources again from\n * the first, whether they came from `src`, `sources` or `<source>` children.\n *\n * With an `<mbx-diagnostics>` in the player, a second button opens its\n * panel, so the report of the error can be read and copied. Its text is\n * the diagnostics' own word, or `label-diagnostics`.\n *\n * It also shows the page's `block()`: its title, else `label-blocked`, and\n * its message, with no retry, since a retry cannot lift a block.\n */\nimport type { PlayerError } from '@mattebox/player-core';\nimport { el } from '../dom.js';\nimport type { Block, PlayerHost } from '../host.js';\nimport type { Messages } from '../messages.js';\nimport { Component } from './component.js';\nimport STYLE from './error-screen.css?inline';\n\n/** The diagnostics element, another package's, named here as a string. */\nconst DIAGNOSTICS = 'mbx-diagnostics';\n\nimport { style } from './shared.js';\n\nexport class MbxErrorScreen extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-title', 'label-retry', 'label-blocked', 'label-diagnostics'];\n }\n\n declare private readonly title_: HTMLElement;\n declare private readonly category: HTMLElement;\n declare private readonly code: HTMLElement;\n declare private readonly detail: HTMLElement;\n declare private readonly message: HTMLElement;\n declare private readonly retry: HTMLButtonElement;\n declare private readonly inspect: HTMLButtonElement;\n /** The block shown, or null for an error. */\n declare private block: Block | null;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n const box = el('div', 'box');\n this.title_ = el('div', 'title');\n this.category = el('span', 'category');\n this.code = el('span', 'code');\n this.detail = el('div', 'detail');\n this.detail.append(this.category, el('span', 'separator', ' · '), this.code);\n this.message = el('div', 'message');\n this.block = null;\n this.retry = el('button', 'action retry');\n this.retry.type = 'button';\n this.retry.addEventListener('click', () => {\n this.player?.retry();\n });\n this.inspect = el('button', 'action diagnostics');\n this.inspect.type = 'button';\n this.inspect.addEventListener('click', () => {\n this.diagnostics()?.show();\n });\n const actions = el('div', 'actions');\n actions.append(this.retry, this.inspect);\n box.append(this.title_, this.detail, this.message, actions);\n root.append(style(STYLE), box);\n }\n\n /** Hidden and named before attaching: a constructor must not add attributes. */\n override connectedCallback(): void {\n if (this.player === null) this.hidden = true;\n if (!this.hasAttribute('role')) this.setAttribute('role', 'alert');\n super.connectedCallback();\n }\n\n private show(error: PlayerError): void {\n this.block = null;\n this.category.textContent = error.category;\n this.code.textContent = error.code;\n this.render();\n this.hidden = false;\n }\n\n /** Shows `block`, or hides the screen for null. */\n private showBlock(block: Block | null): void {\n this.block = block;\n this.render();\n this.hidden = block === null;\n }\n\n protected override attach(player: PlayerHost): void {\n const failure = (event: Event): void => {\n const error = (event as CustomEvent<PlayerError>).detail;\n if (error.fatal) this.show(error);\n };\n player.addEventListener('error', failure);\n this.keep(() => {\n player.removeEventListener('error', failure);\n });\n // Not `emptied`: the old session's teardown fires it after the new\n // source's error, and would hide the error it should leave.\n this.listen(player.video, ['playing', 'loadstart'], () => {\n if (this.block === null) this.hidden = true;\n });\n this.listen(player, ['sourcechange'], () => {\n if (this.block === null) this.hidden = true;\n });\n this.listen(player, ['blockchange'], () => {\n this.showBlock(player.blocked);\n });\n // The error or the block may have come before this element did.\n if (player.error !== null) this.show(player.error);\n if (player.blocked !== null) this.showBlock(player.blocked);\n this.render();\n }\n\n protected override detach(): void {\n this.hidden = true;\n }\n\n /** The player's diagnostics panel, when the page put one in it. */\n private diagnostics(): { show(): void } | null {\n return this.player?.querySelector(DIAGNOSTICS) as { show(): void } | null;\n }\n\n protected override render(): void {\n const block = this.block;\n this.detail.hidden = block !== null;\n this.retry.hidden = block !== null;\n this.inspect.hidden = block !== null || this.diagnostics() === null;\n // The diagnostics package adds its word to the player's; without the package there is no button.\n this.inspect.textContent = this.word(\n 'label-diagnostics',\n 'diagnostics' as keyof Messages,\n 'Diagnostics',\n );\n this.message.hidden = block?.message === undefined;\n if (block === null) {\n this.title_.textContent = this.word('label-title', 'playbackFailed', 'Playback failed');\n this.retry.textContent = this.word('label-retry', 'retry', 'Retry');\n return;\n }\n this.title_.textContent =\n block.title === undefined\n ? this.word('label-blocked', 'blocked', 'Not available')\n : this.pageText(block.title);\n this.message.textContent = block.message === undefined ? '' : this.pageText(block.message);\n }\n}\n"],"mappings":";;;;AAuBA,MAAA,QAAA;;AAGA,MAAA,cAAA;AAIA,IAAA,iBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAYA,cAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,MAAA,MAAA,GAAA,OAAA,KAAA;EACA,KAAA,SAAA,GAAA,OAAA,OAAA;EACA,KAAA,WAAA,GAAA,QAAA,UAAA;EACA,KAAA,OAAA,GAAA,QAAA,MAAA;EACA,KAAA,SAAA,GAAA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,KAAA,UAAA,GAAA,QAAA,aAAA,KAAA,GAAA,KAAA,IAAA;EACA,KAAA,UAAA,GAAA,OAAA,SAAA;EACA,KAAA,QAAA;EACA,KAAA,QAAA,GAAA,UAAA,cAAA;EACA,KAAA,MAAA,OAAA;EACA,KAAA,MAAA,iBAAA,eAAA;GACA,KAAA,QAAA,MAAA;EACA,CAAA;EACA,KAAA,UAAA,GAAA,UAAA,oBAAA;EACA,KAAA,QAAA,OAAA;EACA,KAAA,QAAA,iBAAA,eAAA;GACA,KAAA,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