@mattebox/player 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -435
  2. package/dist/controls/airplay.js +28 -44
  3. package/dist/controls/airplay.js.map +1 -1
  4. package/dist/controls/chapters.d.ts +22 -11
  5. package/dist/controls/chapters.d.ts.map +1 -1
  6. package/dist/controls/chapters.js +87 -73
  7. package/dist/controls/chapters.js.map +1 -1
  8. package/dist/controls/cues.d.ts +0 -22
  9. package/dist/controls/cues.d.ts.map +1 -1
  10. package/dist/controls/cues.js +161 -191
  11. package/dist/controls/cues.js.map +1 -1
  12. package/dist/controls/fullscreen.js +52 -70
  13. package/dist/controls/fullscreen.js.map +1 -1
  14. package/dist/controls/icons.d.ts +1 -1
  15. package/dist/controls/icons.d.ts.map +1 -1
  16. package/dist/controls/icons.js +46 -70
  17. package/dist/controls/icons.js.map +1 -1
  18. package/dist/controls/menu.d.ts +7 -4
  19. package/dist/controls/menu.d.ts.map +1 -1
  20. package/dist/controls/menu.js +241 -223
  21. package/dist/controls/menu.js.map +1 -1
  22. package/dist/controls/pip.js +35 -49
  23. package/dist/controls/pip.js.map +1 -1
  24. package/dist/controls/ranges.js +42 -37
  25. package/dist/controls/ranges.js.map +1 -1
  26. package/dist/controls/session.d.ts +6 -1
  27. package/dist/controls/session.d.ts.map +1 -1
  28. package/dist/controls/session.js +41 -26
  29. package/dist/controls/session.js.map +1 -1
  30. package/dist/controls/slider.d.ts +2 -2
  31. package/dist/controls/slider.d.ts.map +1 -1
  32. package/dist/controls/slider.js +151 -159
  33. package/dist/controls/slider.js.map +1 -1
  34. package/dist/controls/time.js +17 -17
  35. package/dist/controls/time.js.map +1 -1
  36. package/dist/dom.d.ts +6 -0
  37. package/dist/dom.d.ts.map +1 -1
  38. package/dist/dom.js +28 -19
  39. package/dist/dom.js.map +1 -1
  40. package/dist/element-entry.js +9 -6
  41. package/dist/element-entry.js.map +1 -1
  42. package/dist/element.d.ts +4 -2
  43. package/dist/element.d.ts.map +1 -1
  44. package/dist/element.js +384 -443
  45. package/dist/element.js.map +1 -1
  46. package/dist/elements/airplay-button.js +51 -53
  47. package/dist/elements/airplay-button.js.map +1 -1
  48. package/dist/elements/audio-menu.js +62 -63
  49. package/dist/elements/audio-menu.js.map +1 -1
  50. package/dist/elements/chapters-menu.d.ts.map +1 -1
  51. package/dist/elements/chapters-menu.js +75 -65
  52. package/dist/elements/chapters-menu.js.map +1 -1
  53. package/dist/elements/component.d.ts +1 -1
  54. package/dist/elements/component.d.ts.map +1 -1
  55. package/dist/elements/component.js +86 -89
  56. package/dist/elements/component.js.map +1 -1
  57. package/dist/elements/control-bar.d.ts +18 -5
  58. package/dist/elements/control-bar.d.ts.map +1 -1
  59. package/dist/elements/control-bar.js +282 -319
  60. package/dist/elements/control-bar.js.map +1 -1
  61. package/dist/elements/current-time.js +26 -25
  62. package/dist/elements/current-time.js.map +1 -1
  63. package/dist/elements/drm-badge.d.ts.map +1 -1
  64. package/dist/elements/drm-badge.js +107 -141
  65. package/dist/elements/drm-badge.js.map +1 -1
  66. package/dist/elements/duration.d.ts.map +1 -1
  67. package/dist/elements/duration.js +24 -21
  68. package/dist/elements/duration.js.map +1 -1
  69. package/dist/elements/error-screen.d.ts.map +1 -1
  70. package/dist/elements/error-screen.js +68 -102
  71. package/dist/elements/error-screen.js.map +1 -1
  72. package/dist/elements/fullscreen-button.js +48 -54
  73. package/dist/elements/fullscreen-button.js.map +1 -1
  74. package/dist/elements/live-button.d.ts.map +1 -1
  75. package/dist/elements/live-button.js +67 -94
  76. package/dist/elements/live-button.js.map +1 -1
  77. package/dist/elements/menu-element.js +31 -28
  78. package/dist/elements/menu-element.js.map +1 -1
  79. package/dist/elements/mute-button.js +58 -59
  80. package/dist/elements/mute-button.js.map +1 -1
  81. package/dist/elements/pip-button.js +54 -54
  82. package/dist/elements/pip-button.js.map +1 -1
  83. package/dist/elements/play-button.d.ts.map +1 -1
  84. package/dist/elements/play-button.js +73 -58
  85. package/dist/elements/play-button.js.map +1 -1
  86. package/dist/elements/quality-menu.js +66 -69
  87. package/dist/elements/quality-menu.js.map +1 -1
  88. package/dist/elements/remaining-time.d.ts.map +1 -1
  89. package/dist/elements/remaining-time.js +27 -24
  90. package/dist/elements/remaining-time.js.map +1 -1
  91. package/dist/elements/scan-button.d.ts +17 -0
  92. package/dist/elements/scan-button.d.ts.map +1 -0
  93. package/dist/elements/scan-button.js +117 -0
  94. package/dist/elements/scan-button.js.map +1 -0
  95. package/dist/elements/seek-bar.d.ts +93 -14
  96. package/dist/elements/seek-bar.d.ts.map +1 -1
  97. package/dist/elements/seek-bar.js +475 -335
  98. package/dist/elements/seek-bar.js.map +1 -1
  99. package/dist/elements/shared.d.ts +3 -11
  100. package/dist/elements/shared.d.ts.map +1 -1
  101. package/dist/elements/shared.js +44 -144
  102. package/dist/elements/shared.js.map +1 -1
  103. package/dist/elements/skip-button.d.ts.map +1 -1
  104. package/dist/elements/skip-button.js +54 -55
  105. package/dist/elements/skip-button.js.map +1 -1
  106. package/dist/elements/spacer.d.ts.map +1 -1
  107. package/dist/elements/spacer.js +12 -7
  108. package/dist/elements/spacer.js.map +1 -1
  109. package/dist/elements/speed-menu.js +60 -55
  110. package/dist/elements/speed-menu.js.map +1 -1
  111. package/dist/elements/spinner.d.ts.map +1 -1
  112. package/dist/elements/spinner.js +52 -78
  113. package/dist/elements/spinner.js.map +1 -1
  114. package/dist/elements/start-button.d.ts.map +1 -1
  115. package/dist/elements/start-button.js +107 -120
  116. package/dist/elements/start-button.js.map +1 -1
  117. package/dist/elements/subtitles-menu.js +95 -103
  118. package/dist/elements/subtitles-menu.js.map +1 -1
  119. package/dist/elements/time-element.d.ts.map +1 -1
  120. package/dist/elements/time-element.js +36 -28
  121. package/dist/elements/time-element.js.map +1 -1
  122. package/dist/elements/title.d.ts.map +1 -1
  123. package/dist/elements/title.js +105 -137
  124. package/dist/elements/title.js.map +1 -1
  125. package/dist/elements/volume-slider.d.ts.map +1 -1
  126. package/dist/elements/volume-slider.js +47 -45
  127. package/dist/elements/volume-slider.js.map +1 -1
  128. package/dist/elements/volume.d.ts.map +1 -1
  129. package/dist/elements/volume.js +42 -50
  130. package/dist/elements/volume.js.map +1 -1
  131. package/dist/entries/airplay-button.js +7 -7
  132. package/dist/entries/airplay-button.js.map +1 -1
  133. package/dist/entries/audio-menu.js +7 -6
  134. package/dist/entries/audio-menu.js.map +1 -1
  135. package/dist/entries/chapters-menu.js +7 -7
  136. package/dist/entries/chapters-menu.js.map +1 -1
  137. package/dist/entries/control-bar.js +7 -6
  138. package/dist/entries/control-bar.js.map +1 -1
  139. package/dist/entries/current-time.js +7 -6
  140. package/dist/entries/current-time.js.map +1 -1
  141. package/dist/entries/drm-badge.js +7 -6
  142. package/dist/entries/drm-badge.js.map +1 -1
  143. package/dist/entries/duration.js +7 -6
  144. package/dist/entries/duration.js.map +1 -1
  145. package/dist/entries/error-screen.js +7 -6
  146. package/dist/entries/error-screen.js.map +1 -1
  147. package/dist/entries/fullscreen-button.js +7 -6
  148. package/dist/entries/fullscreen-button.js.map +1 -1
  149. package/dist/entries/live-button.js +7 -6
  150. package/dist/entries/live-button.js.map +1 -1
  151. package/dist/entries/mute-button.js +7 -6
  152. package/dist/entries/mute-button.js.map +1 -1
  153. package/dist/entries/pip-button.js +7 -6
  154. package/dist/entries/pip-button.js.map +1 -1
  155. package/dist/entries/play-button.js +7 -6
  156. package/dist/entries/play-button.js.map +1 -1
  157. package/dist/entries/quality-menu.js +7 -6
  158. package/dist/entries/quality-menu.js.map +1 -1
  159. package/dist/entries/remaining-time.js +7 -7
  160. package/dist/entries/remaining-time.js.map +1 -1
  161. package/dist/entries/scan-button.d.ts +5 -0
  162. package/dist/entries/scan-button.d.ts.map +1 -0
  163. package/dist/entries/scan-button.js +9 -0
  164. package/dist/entries/scan-button.js.map +1 -0
  165. package/dist/entries/seek-bar.js +7 -6
  166. package/dist/entries/seek-bar.js.map +1 -1
  167. package/dist/entries/skip-button.js +7 -6
  168. package/dist/entries/skip-button.js.map +1 -1
  169. package/dist/entries/spacer.js +7 -6
  170. package/dist/entries/spacer.js.map +1 -1
  171. package/dist/entries/speed-menu.js +7 -6
  172. package/dist/entries/speed-menu.js.map +1 -1
  173. package/dist/entries/spinner.js +7 -7
  174. package/dist/entries/spinner.js.map +1 -1
  175. package/dist/entries/start-button.js +7 -6
  176. package/dist/entries/start-button.js.map +1 -1
  177. package/dist/entries/subtitles-menu.js +7 -6
  178. package/dist/entries/subtitles-menu.js.map +1 -1
  179. package/dist/entries/title.js +7 -7
  180. package/dist/entries/title.js.map +1 -1
  181. package/dist/entries/volume-slider.js +7 -6
  182. package/dist/entries/volume-slider.js.map +1 -1
  183. package/dist/entries/volume.js +9 -8
  184. package/dist/entries/volume.js.map +1 -1
  185. package/dist/es2015/controls/chapters.js +40 -7
  186. package/dist/es2015/controls/cues.js +1 -8
  187. package/dist/es2015/controls/icons.js +3 -1
  188. package/dist/es2015/controls/menu.js +27 -8
  189. package/dist/es2015/controls/session.js +16 -4
  190. package/dist/es2015/controls/slider.js +5 -4
  191. package/dist/es2015/dom.js +10 -1
  192. package/dist/es2015/element.js +23 -7
  193. package/dist/es2015/elements/chapters-menu.js +18 -10
  194. package/dist/es2015/elements/control-bar.js +41 -35
  195. package/dist/es2015/elements/drm-badge.js +1 -25
  196. package/dist/es2015/elements/duration.js +2 -1
  197. package/dist/es2015/elements/error-screen.js +1 -30
  198. package/dist/es2015/elements/live-button.js +1 -29
  199. package/dist/es2015/elements/menu-element.js +2 -2
  200. package/dist/es2015/elements/play-button.js +10 -3
  201. package/dist/es2015/elements/remaining-time.js +2 -1
  202. package/dist/es2015/elements/scan-button.js +118 -0
  203. package/dist/es2015/elements/seek-bar.js +264 -71
  204. package/dist/es2015/elements/shared.js +5 -106
  205. package/dist/es2015/elements/skip-button.js +2 -1
  206. package/dist/es2015/elements/spacer.js +2 -1
  207. package/dist/es2015/elements/spinner.js +1 -32
  208. package/dist/es2015/elements/start-button.js +8 -26
  209. package/dist/es2015/elements/time-element.js +1 -4
  210. package/dist/es2015/elements/title.js +1 -45
  211. package/dist/es2015/elements/volume-slider.js +2 -1
  212. package/dist/es2015/elements/volume.js +1 -11
  213. package/dist/es2015/entries/scan-button.js +7 -0
  214. package/dist/es2015/index.js +3 -1
  215. package/dist/es2015/style.js +1 -101
  216. package/dist/es2015/tags.js +2 -1
  217. package/dist/host.js +19 -17
  218. package/dist/host.js.map +1 -1
  219. package/dist/index.d.ts +3 -0
  220. package/dist/index.d.ts.map +1 -1
  221. package/dist/index.js +55 -27
  222. package/dist/labels.js +13 -9
  223. package/dist/labels.js.map +1 -1
  224. package/dist/namespaces.d.ts +9 -26
  225. package/dist/namespaces.d.ts.map +1 -1
  226. package/dist/namespaces.js +6 -2
  227. package/dist/namespaces.js.map +1 -1
  228. package/dist/presets.js +33 -28
  229. package/dist/presets.js.map +1 -1
  230. package/dist/style.d.ts +1 -20
  231. package/dist/style.d.ts.map +1 -1
  232. package/dist/style.js +4 -100
  233. package/dist/style.js.map +1 -1
  234. package/dist/surface.js +25 -21
  235. package/dist/surface.js.map +1 -1
  236. package/dist/tags.d.ts +1 -0
  237. package/dist/tags.d.ts.map +1 -1
  238. package/dist/tags.js +31 -26
  239. package/dist/tags.js.map +1 -1
  240. package/package.json +4 -4
  241. package/dist/index.js.map +0 -1
@@ -1,108 +1,100 @@
1
- import { icon } from '../controls/icons.js';
2
- import { onTracks, trackItems } from './audio-menu.js';
3
- import { MenuElement } from './menu-element.js';
4
- import { show } from './shared.js';
5
- const OFF = 'off';
6
- export const SUBTITLE_SIZE = 'subtitle-size';
7
- export const SUBTITLE_BACKGROUND = 'subtitle-background';
1
+ import { icon } from "../controls/icons.js";
2
+ import { show } from "./shared.js";
3
+ import { MenuElement } from "./menu-element.js";
4
+ import { onTracks, trackItems } from "./audio-menu.js";
5
+ //#region src/elements/subtitles-menu.ts
6
+ const OFF = "off";
7
+ const SUBTITLE_SIZE = "subtitle-size";
8
+ const SUBTITLE_BACKGROUND = "subtitle-background";
8
9
  const SIZES = [
9
- ['small', 'Small'],
10
- ['medium', 'Medium'],
11
- ['large', 'Large'],
12
- ['xlarge', 'Extra large'],
10
+ ["small", "Small"],
11
+ ["medium", "Medium"],
12
+ ["large", "Large"],
13
+ ["xlarge", "Extra large"]
13
14
  ];
14
15
  const BACKGROUNDS = [
15
- ['none', 'None'],
16
- ['dark', 'Dark'],
17
- ['solid', 'Solid'],
16
+ ["none", "None"],
17
+ ["dark", "Dark"],
18
+ ["solid", "Solid"]
18
19
  ];
19
- const STATES = ['off', 'on'];
20
- export class MbxSubtitlesMenu extends MenuElement {
21
- static get observedAttributes() {
22
- return [
23
- 'label',
24
- 'label-back',
25
- 'label-off',
26
- 'label-track',
27
- 'label-settings',
28
- 'label-size',
29
- 'label-background',
30
- ...SIZES.map(([id]) => `label-${id}`),
31
- ...BACKGROUNDS.map(([id]) => `label-${id}`),
32
- ];
33
- }
34
- constructor() {
35
- super(STATES, (state) => icon(state === 'on' ? 'closed-captions-on' : 'closed-captions'));
36
- this.engine = null;
37
- show(this.slots, 'off');
38
- }
39
- name() {
40
- return 'Subtitles';
41
- }
42
- /** A look's group: the choices named from the attributes, the value from the player's. */
43
- looks(player, attribute, name, fallback, choices, initial) {
44
- const set = player.getAttribute(attribute);
45
- const value = set !== null && choices.some(([id]) => id === set) ? set : initial;
46
- return {
47
- name,
48
- label: this.getAttribute(`label-${name}`) ?? fallback,
49
- items: choices.map(([id, text]) => [id, this.getAttribute(`label-${id}`) ?? text]),
50
- value,
51
- onSelect: (chosen) => {
52
- player.setAttribute(attribute, chosen);
53
- this.render();
54
- },
55
- };
56
- }
57
- attach(player) {
58
- this.follow(player, (engine) => {
59
- this.engine = engine;
60
- this.render();
61
- if (engine === null)
62
- return undefined;
63
- return onTracks(engine, () => {
64
- this.render();
65
- });
66
- });
67
- }
68
- render() {
69
- super.render();
70
- const engine = this.engine;
71
- const player = this.player;
72
- if (engine === null || player === null) {
73
- this.hidden = true;
74
- return;
75
- }
76
- const [tracks, active] = trackItems(engine, 'text');
77
- const items = [
78
- [OFF, this.getAttribute('label-off') ?? 'Off'],
79
- ...tracks,
80
- ];
81
- this.menu.fill([
82
- {
83
- name: 'track',
84
- label: this.getAttribute('label-track') ?? 'Track',
85
- items,
86
- value: active ?? OFF,
87
- onSelect: (value) => {
88
- if (value === OFF)
89
- engine.tracks.deselect('text');
90
- else
91
- engine.tracks.select(value);
92
- this.render();
93
- },
94
- },
95
- {
96
- name: 'settings',
97
- label: this.getAttribute('label-settings') ?? 'Settings',
98
- entries: [
99
- this.looks(player, SUBTITLE_SIZE, 'size', 'Size', SIZES, 'medium'),
100
- this.looks(player, SUBTITLE_BACKGROUND, 'background', 'Background', BACKGROUNDS, 'dark'),
101
- ],
102
- },
103
- ]);
104
- show(this.slots, active === null ? 'off' : 'on');
105
- this.hidden = tracks.length === 0;
106
- }
107
- }
20
+ const STATES = ["off", "on"];
21
+ var MbxSubtitlesMenu = class extends MenuElement {
22
+ static get observedAttributes() {
23
+ return [
24
+ "label",
25
+ "label-back",
26
+ "label-off",
27
+ "label-track",
28
+ "label-settings",
29
+ "label-size",
30
+ "label-background",
31
+ ...SIZES.map(([id]) => `label-${id}`),
32
+ ...BACKGROUNDS.map(([id]) => `label-${id}`)
33
+ ];
34
+ }
35
+ constructor() {
36
+ super(STATES, (state) => icon(state === "on" ? "closed-captions-on" : "closed-captions"));
37
+ this.engine = null;
38
+ show(this.slots, "off");
39
+ }
40
+ name() {
41
+ return "Subtitles";
42
+ }
43
+ /** A look's group: the choices named from the attributes, the value from the player's. */
44
+ looks(player, attribute, name, fallback, choices, initial) {
45
+ const set = player.getAttribute(attribute);
46
+ const value = set !== null && choices.some(([id]) => id === set) ? set : initial;
47
+ return {
48
+ name,
49
+ label: this.getAttribute(`label-${name}`) ?? fallback,
50
+ items: choices.map(([id, text]) => [id, this.getAttribute(`label-${id}`) ?? text]),
51
+ value,
52
+ onSelect: (chosen) => {
53
+ player.setAttribute(attribute, chosen);
54
+ this.render();
55
+ }
56
+ };
57
+ }
58
+ attach(player) {
59
+ this.follow(player, (engine) => {
60
+ this.engine = engine;
61
+ this.render();
62
+ if (engine === null) return void 0;
63
+ return onTracks(engine, () => {
64
+ this.render();
65
+ });
66
+ });
67
+ }
68
+ render() {
69
+ super.render();
70
+ const engine = this.engine;
71
+ const player = this.player;
72
+ if (engine === null || player === null) {
73
+ this.hidden = true;
74
+ return;
75
+ }
76
+ const [tracks, active] = trackItems(engine, "text");
77
+ const items = [[OFF, this.getAttribute("label-off") ?? "Off"], ...tracks];
78
+ this.menu.fill([{
79
+ name: "track",
80
+ label: this.getAttribute("label-track") ?? "Track",
81
+ items,
82
+ value: active ?? OFF,
83
+ onSelect: (value) => {
84
+ if (value === OFF) engine.tracks.deselect("text");
85
+ else engine.tracks.select(value);
86
+ this.render();
87
+ }
88
+ }, {
89
+ name: "settings",
90
+ label: this.getAttribute("label-settings") ?? "Settings",
91
+ entries: [this.looks(player, SUBTITLE_SIZE, "size", "Size", SIZES, "medium"), this.looks(player, SUBTITLE_BACKGROUND, "background", "Background", BACKGROUNDS, "dark")]
92
+ }]);
93
+ show(this.slots, active === null ? "off" : "on");
94
+ this.hidden = tracks.length === 0;
95
+ }
96
+ };
97
+ //#endregion
98
+ export { MbxSubtitlesMenu, SUBTITLE_BACKGROUND, SUBTITLE_SIZE };
99
+
108
100
  //# sourceMappingURL=subtitles-menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subtitles-menu.js","sourceRoot":"","sources":["../../src/elements/subtitles-menu.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;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AAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC;iBACzF;aACF;SACF,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IACpC,CAAC;CACF"}
1
+ {"version":3,"file":"subtitles-menu.js","names":[],"sources":["../../src/elements/subtitles-menu.ts"],"sourcesContent":["/**\n * <mbx-subtitles-menu>: the text track over `engine.tracks`, with \"off\"\n * because a text selection is releasable and an audio one is not, and a\n * Settings page behind it with the size and the background. The glyph\n * says whether a track is on: `icon` or `icon-on`. Hidden without text\n * tracks, and for a native session.\n *\n * The looks are attributes on the player, `subtitle-size` and\n * `subtitle-background`, where the element's stylesheet turns them into\n * the cue rules; a page can set them in markup and persist them however\n * it likes. Every word the menu shows is an attribute: `label`,\n * `label-off`, `label-track`, `label-settings`, `label-size`,\n * `label-background`, one per size and one per background.\n */\nimport type { Mattebox } from 'mattebox';\nimport { icon } from '../controls/icons.js';\nimport type { MenuGroup } from '../controls/menu.js';\nimport type { PlayerHost } from '../host.js';\nimport { onTracks, trackItems } from './audio-menu.js';\nimport { MenuElement } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst OFF = 'off';\nexport const SUBTITLE_SIZE = 'subtitle-size';\nexport const SUBTITLE_BACKGROUND = 'subtitle-background';\n\nconst SIZES: ReadonlyArray<readonly [string, string]> = [\n ['small', 'Small'],\n ['medium', 'Medium'],\n ['large', 'Large'],\n ['xlarge', 'Extra large'],\n];\nconst BACKGROUNDS: ReadonlyArray<readonly [string, string]> = [\n ['none', 'None'],\n ['dark', 'Dark'],\n ['solid', 'Solid'],\n];\n\ntype State = 'off' | 'on';\nconst STATES: readonly State[] = ['off', 'on'];\n\nexport class MbxSubtitlesMenu extends MenuElement<State> {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-back',\n 'label-off',\n 'label-track',\n 'label-settings',\n 'label-size',\n 'label-background',\n ...SIZES.map(([id]) => `label-${id}`),\n ...BACKGROUNDS.map(([id]) => `label-${id}`),\n ];\n }\n\n declare private engine: Mattebox | null;\n\n constructor() {\n super(STATES, (state) => icon(state === 'on' ? 'closed-captions-on' : 'closed-captions'));\n this.engine = null;\n show(this.slots, 'off');\n }\n\n protected override name(): string {\n return 'Subtitles';\n }\n\n /** A look's group: the choices named from the attributes, the value from the player's. */\n private looks(\n player: PlayerHost,\n attribute: string,\n name: string,\n fallback: string,\n choices: ReadonlyArray<readonly [string, string]>,\n initial: string,\n ): MenuGroup {\n const set = player.getAttribute(attribute);\n const value = set !== null && choices.some(([id]) => id === set) ? set : initial;\n return {\n name,\n label: this.getAttribute(`label-${name}`) ?? fallback,\n items: choices.map(([id, text]) => [id, this.getAttribute(`label-${id}`) ?? text]),\n value,\n onSelect: (chosen) => {\n player.setAttribute(attribute, chosen);\n this.render();\n },\n };\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n return onTracks(engine, () => {\n this.render();\n });\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n const player = this.player;\n if (engine === null || player === null) {\n this.hidden = true;\n return;\n }\n const [tracks, active] = trackItems(engine, 'text');\n const items: Array<readonly [string, string]> = [\n [OFF, this.getAttribute('label-off') ?? 'Off'],\n ...tracks,\n ];\n this.menu.fill([\n {\n name: 'track',\n label: this.getAttribute('label-track') ?? 'Track',\n items,\n value: active ?? OFF,\n onSelect: (value) => {\n if (value === OFF) engine.tracks.deselect('text');\n else engine.tracks.select(value);\n this.render();\n },\n },\n {\n name: 'settings',\n label: this.getAttribute('label-settings') ?? 'Settings',\n entries: [\n this.looks(player, SUBTITLE_SIZE, 'size', 'Size', SIZES, 'medium'),\n this.looks(player, SUBTITLE_BACKGROUND, 'background', 'Background', BACKG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AAC;gBAE1B,KAAK,SAAK;IAOb,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CASpD"}
1
+ {"version":3,"file":"time-element.d.ts","sourceRoot":"","sources":["../../src/elements/time-element.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAM3C,8BAAsB,WAAY,SAAQ,SAAS;IACjD,mBAA2B,IAAI,EAAE,IAAI,CAAC;gBAE1B,KAAK,SAAK;IAOb,iBAAiB,IAAI,IAAI;cAKf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;CASpD"}
@@ -1,29 +1,37 @@
1
- import { Component } from './component.js';
2
- import { seekRow, style } from './shared.js';
3
- const STYLE = `
4
- :host { display: inline-block; min-width: 3ch; white-space: nowrap; font-variant-numeric: tabular-nums; }
5
- :host([hidden]) { display: none; }
6
- `;
7
- const EVENTS = ['timeupdate', 'durationchange', 'loadedmetadata', 'seeking', 'seeked', 'emptied'];
8
- export class TimeElement extends Component {
9
- constructor(extra = '') {
10
- super();
11
- const root = this.attachShadow({ mode: 'open' });
12
- this.text = document.createTextNode('0:00');
13
- root.append(style(STYLE + extra), this.text);
14
- }
15
- connectedCallback() {
16
- seekRow(this);
17
- super.connectedCallback();
18
- }
19
- attach(player) {
20
- const tick = () => {
21
- this.render();
22
- };
23
- this.listen(player.video, EVENTS, tick);
24
- this.listen(player, ['sourcechange'], tick);
25
- this.observe(player, ['live', 'seekable'], tick);
26
- this.render();
27
- }
28
- }
1
+ import { Component } from "./component.js";
2
+ import { seekRow, style } from "./shared.js";
3
+ //#region src/elements/time-element.ts
4
+ const STYLE = ":host{white-space:nowrap;font-variant-numeric:tabular-nums;min-width:3ch;display:inline-block}:host([hidden]){display:none}";
5
+ const EVENTS = [
6
+ "timeupdate",
7
+ "durationchange",
8
+ "loadedmetadata",
9
+ "seeking",
10
+ "seeked",
11
+ "emptied"
12
+ ];
13
+ var TimeElement = class extends Component {
14
+ constructor(extra = "") {
15
+ super();
16
+ const root = this.attachShadow({ mode: "open" });
17
+ this.text = document.createTextNode("0:00");
18
+ root.append(style(STYLE + extra), this.text);
19
+ }
20
+ connectedCallback() {
21
+ seekRow(this);
22
+ super.connectedCallback();
23
+ }
24
+ attach(player) {
25
+ const tick = () => {
26
+ this.render();
27
+ };
28
+ this.listen(player.video, EVENTS, tick);
29
+ this.listen(player, ["sourcechange"], tick);
30
+ this.observe(player, ["live", "seekable"], tick);
31
+ this.render();
32
+ }
33
+ };
34
+ //#endregion
35
+ export { TimeElement };
36
+
29
37
  //# sourceMappingURL=time-element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-element.js","sourceRoot":"","sources":["../../src/elements/time-element.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,KAAK,GAAG;;;CAGb,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAElG,MAAM,OAAgB,WAAY,SAAQ,SAAS;IAGjD,YAAY,KAAK,GAAG,EAAE;QACpB,KAAK,EAAE,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEQ,iBAAiB;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAC5B,CAAC;IAEkB,MAAM,CAAC,MAAkB;QAC1C,MAAM,IAAI,GAAG,GAAS,EAAE;YACtB,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,CAAC,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;CACF"}
1
+ {"version":3,"file":"time-element.js","names":[],"sources":["../../src/elements/time-element.ts"],"sourcesContent":["/**\n * What the two time readouts share: the events they re-read the video on,\n * and the live and seekable states of the player, which the seek bar sets.\n * Each sits in the bar's seek row unless the page says otherwise.\n */\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport { seekRow, style } from './shared.js';\nimport STYLE from './time-element.css?inline';\n\nconst EVENTS = ['timeupdate', 'durationchange', 'loadedmetadata', 'seeking', 'seeked', 'emptied'];\n\nexport abstract class TimeElement extends Component {\n declare protected readonly text: Text;\n\n constructor(extra = '') {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.text = document.createTextNode('0:00');\n root.append(style(STYLE + extra), this.text);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.listen(player, ['sourcechange'], tick);\n this.observe(player, ['live', 'seekable'], tick);\n this.render();\n }\n}\n"],"mappings":";;;AAQA,MAAA,QAAA;AAEA,MAAA,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAAA;AAEA,IAAA,cAAA,cAAA,UAAA;CAGA,YAAA,QAAA,IAAA;EACA,MAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,OAAA,SAAA,eAAA,MAAA;EACA,KAAA,OAAA,MAAA,QAAA,KAAA,GAAA,KAAA,IAAA;CACA;CAEA,oBAAA;EACA,QAAA,IAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,MAAA,aAAA;GACA,KAAA,OAAA;EACA;EACA,KAAA,OAAA,OAAA,OAAA,QAAA,IAAA;EACA,KAAA,OAAA,QAAA,CAAA,cAAA,GAAA,IAAA;EACA,KAAA,QAAA,QAAA,CAAA,QAAA,UAAA,GAAA,IAAA;EACA,KAAA,OAAA;CACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiD3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,OAAO,CAAmB;IACnD,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,UAAU,CAAc;IACjD,0FAA0F;IAC1F,QAAgB,OAAO,CAAwB;;cAgB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAehC,MAAM,IAAI,IAAI;IAOjC,uEAAuE;IACvE,OAAO,CAAC,KAAK;IAIb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAelC"}
1
+ {"version":3,"file":"title.d.ts","sourceRoot":"","sources":["../../src/elements/title.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI3C,qBAAa,QAAS,SAAQ,SAAS;IACrC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,OAAO,CAAmB;IACnD,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,UAAU,CAAc;IACjD,0FAA0F;IAC1F,QAAgB,OAAO,CAAwB;;cAgB5B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAehC,MAAM,IAAI,IAAI;IAOjC,uEAAuE;IACvE,OAAO,CAAC,KAAK;IAIb,gHAAgH;IAChH,OAAO,CAAC,GAAG;cAUQ,MAAM,IAAI,IAAI;CAelC"}
@@ -1,139 +1,107 @@
1
+ import { el } from "../dom.js";
2
+ import { Component } from "./component.js";
3
+ import { style } from "./shared.js";
4
+ //#region src/elements/title.ts
1
5
  /**
2
- * <mbx-title>: the heading, the subheading and the artwork of what plays,
3
- * as a lower third across the picture above the bar: a scrim that fades
4
- * upward, the artwork in the first column, the two lines in the second,
5
- * so a heading alone sits on a band and never floats. The content comes
6
- * from attributes, `heading`,
7
- * `subheading` and `artwork`, because the stream carries none of it: a page
8
- * writes what it knows, and a Cast receiver writes what the sender said.
9
- * With none of the three the element draws nothing.
10
- *
11
- * Shown while the video is paused, which includes before the first play,
12
- * and hidden while it plays. The element carries `playing` for that rule,
13
- * so a page changes it in CSS: `mattebox-player[started] mbx-title
14
- * { display: none }` keeps it to the time before the first play, like the
15
- * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it
16
- * back on hover. The height of the bar's rows, its box less the fade it
17
- * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits
18
- * just above the seek row while the band runs under the bar to the bottom
19
- * edge, one ramp with the bar's own fade. The scrim is the page's to
20
- * override. Placed first among the screens, so the start button, the
21
- * error screen and the spinner paint over its band.
22
- */
23
- import { el } from '../dom.js';
24
- import { Component } from './component.js';
25
- import { style } from './shared.js';
26
- const STYLE = `
27
- :host {
28
- position: absolute;
29
- left: 0;
30
- right: 0;
31
- bottom: 0;
32
- display: flex;
33
- align-items: flex-end;
34
- gap: 14px;
35
- /* The band runs under the bar to the bottom edge, one ramp with the
36
- bar's own fade, so there is no seam where the bar begins; the text
37
- sits 12px above the bar's rows, inside the bar's fade. */
38
- padding: 72px calc(var(--mbx-pad) + 8px) calc(var(--mbx-bar-rows, 0px) + 12px);
39
- background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.3) 45%, rgba(0, 0, 0, 0));
40
- color: var(--mbx-text);
41
- font: 400 14px/1.35 var(--mbx-font);
42
- text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
43
- pointer-events: none;
44
- }
45
- :host([playing]) { display: none; }
46
- :host([empty]) { display: none; }
47
- :host([hidden]) { display: none; }
48
- [part~="artwork"] {
49
- flex: none;
50
- height: 72px;
51
- width: auto;
52
- max-width: 128px;
53
- border-radius: var(--mbx-radius);
54
- object-fit: cover;
55
- box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
56
- }
57
- [part~="artwork"][hidden] { display: none; }
58
- [part~="text"] { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 60ch; }
59
- [part~="heading"] {
60
- font-size: 20px;
61
- font-weight: 600;
62
- letter-spacing: -0.01em;
63
- line-height: 1.2;
64
- white-space: nowrap;
65
- overflow: hidden;
66
- text-overflow: ellipsis;
67
- }
68
- [part~="subheading"] { color: rgba(255, 255, 255, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
69
- [part~="heading"]:empty, [part~="subheading"]:empty { display: none; }
70
- `;
71
- export class MbxTitle extends Component {
72
- static get observedAttributes() {
73
- return ['heading', 'subheading', 'artwork'];
74
- }
75
- constructor() {
76
- super();
77
- this.resizer = null;
78
- const root = this.attachShadow({ mode: 'open' });
79
- this.artwork = el('img', 'artwork');
80
- this.artwork.alt = '';
81
- this.artwork.hidden = true;
82
- const text = el('div', 'text');
83
- this.heading = el('div', 'heading');
84
- this.subheading = el('div', 'subheading');
85
- text.append(this.heading, this.subheading);
86
- root.append(style(STYLE), this.artwork, text);
87
- }
88
- attach(player) {
89
- this.listen(player.video, ['play', 'pause', 'ended', 'emptied'], () => {
90
- this.state(player);
91
- });
92
- if (typeof ResizeObserver !== 'undefined') {
93
- this.resizer = new ResizeObserver(() => {
94
- this.fit(player);
95
- });
96
- this.resizer.observe(player);
97
- }
98
- this.fit(player);
99
- this.state(player);
100
- this.render();
101
- }
102
- detach() {
103
- this.resizer?.disconnect();
104
- this.resizer = null;
105
- this.removeAttribute('playing');
106
- this.style.removeProperty('--mbx-bar-rows');
107
- }
108
- /** `playing` on the element, for its own stylesheet and the page's. */
109
- state(player) {
110
- this.toggleAttribute('playing', !player.video.paused);
111
- }
112
- /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
113
- fit(player) {
114
- const bar = player.querySelector('mbx-control-bar');
115
- let rows = 0;
116
- if (bar !== null) {
117
- const top = Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;
118
- rows = Math.max(0, bar.getBoundingClientRect().height - top);
119
- }
120
- this.style.setProperty('--mbx-bar-rows', `${rows}px`);
121
- }
122
- render() {
123
- const heading = this.getAttribute('heading') ?? '';
124
- const subheading = this.getAttribute('subheading') ?? '';
125
- const artwork = this.getAttribute('artwork');
126
- this.heading.textContent = heading;
127
- this.subheading.textContent = subheading;
128
- if (artwork === null) {
129
- this.artwork.removeAttribute('src');
130
- this.artwork.hidden = true;
131
- }
132
- else {
133
- this.artwork.src = artwork;
134
- this.artwork.hidden = false;
135
- }
136
- this.toggleAttribute('empty', heading === '' && subheading === '' && artwork === null);
137
- }
138
- }
6
+ * <mbx-title>: the heading, the subheading and the artwork of what plays,
7
+ * as a lower third across the picture above the bar: a scrim that fades
8
+ * upward, the artwork in the first column, the two lines in the second,
9
+ * so a heading alone sits on a band and never floats. The content comes
10
+ * from attributes, `heading`,
11
+ * `subheading` and `artwork`, because the stream carries none of it: a page
12
+ * writes what it knows, and a Cast receiver writes what the sender said.
13
+ * With none of the three the element draws nothing.
14
+ *
15
+ * Shown while the video is paused, which includes before the first play,
16
+ * and hidden while it plays. The element carries `playing` for that rule,
17
+ * so a page changes it in CSS: `mattebox-player[started] mbx-title
18
+ * { display: none }` keeps it to the time before the first play, like the
19
+ * poster, and `mattebox-player:hover mbx-title { display: flex }` brings it
20
+ * back on hover. The height of the bar's rows, its box less the fade it
21
+ * pads itself with, goes on the host as `--mbx-bar-rows`, so the text sits
22
+ * just above the seek row while the band runs under the bar to the bottom
23
+ * edge, one ramp with the bar's own fade. The scrim is the page's to
24
+ * override. Placed first among the screens, so the start button, the
25
+ * error screen and the spinner paint over its band.
26
+ */
27
+ const STYLE = ":host{padding:72px calc(var(--mbx-pad) + 8px) calc(var(--mbx-bar-rows,0px) + 12px);color:var(--mbx-text);font:400 14px / 1.35 var(--mbx-font);text-shadow:0 1px 2px #0006;pointer-events:none;background:linear-gradient(#0000,#0000004d 55%,#0000008c);align-items:flex-end;display:flex;position:absolute;bottom:0;left:0;right:0}:host([playing]),:host([empty]),:host([hidden]){display:none}[part~=artwork]{border-radius:var(--mbx-radius);object-fit:cover;flex:none;width:auto;max-width:128px;height:72px;margin-right:14px;box-shadow:0 0 0 1px #ffffff24}[part~=artwork][hidden]{display:none}[part~=text]{flex-direction:column;min-width:0;max-width:60ch;display:flex}[part~=text]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=heading]{letter-spacing:-.01em;white-space:nowrap;text-overflow:ellipsis;font-size:20px;font-weight:600;line-height:1.2;overflow:hidden}[part~=subheading]{color:#ffffffc7;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}[part~=heading]:empty,[part~=subheading]:empty{display:none}";
28
+ var MbxTitle = class extends Component {
29
+ static get observedAttributes() {
30
+ return [
31
+ "heading",
32
+ "subheading",
33
+ "artwork"
34
+ ];
35
+ }
36
+ constructor() {
37
+ super();
38
+ this.resizer = null;
39
+ const root = this.attachShadow({ mode: "open" });
40
+ this.artwork = el("img", "artwork");
41
+ this.artwork.alt = "";
42
+ this.artwork.hidden = true;
43
+ const text = el("div", "text");
44
+ this.heading = el("div", "heading");
45
+ this.subheading = el("div", "subheading");
46
+ text.append(this.heading, this.subheading);
47
+ root.append(style(STYLE), this.artwork, text);
48
+ }
49
+ attach(player) {
50
+ this.listen(player.video, [
51
+ "play",
52
+ "pause",
53
+ "ended",
54
+ "emptied"
55
+ ], () => {
56
+ this.state(player);
57
+ });
58
+ if (typeof ResizeObserver !== "undefined") {
59
+ this.resizer = new ResizeObserver(() => {
60
+ this.fit(player);
61
+ });
62
+ this.resizer.observe(player);
63
+ }
64
+ this.fit(player);
65
+ this.state(player);
66
+ this.render();
67
+ }
68
+ detach() {
69
+ this.resizer?.disconnect();
70
+ this.resizer = null;
71
+ this.removeAttribute("playing");
72
+ this.style.removeProperty("--mbx-bar-rows");
73
+ }
74
+ /** `playing` on the element, for its own stylesheet and the page's. */
75
+ state(player) {
76
+ this.toggleAttribute("playing", !player.video.paused);
77
+ }
78
+ /** The height of the bar's rows: its box less the padding above them, which is its fade. Zero without a bar. */
79
+ fit(player) {
80
+ const bar = player.querySelector("mbx-control-bar");
81
+ let rows = 0;
82
+ if (bar !== null) {
83
+ const top = Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;
84
+ rows = Math.max(0, bar.getBoundingClientRect().height - top);
85
+ }
86
+ this.style.setProperty("--mbx-bar-rows", `${rows}px`);
87
+ }
88
+ render() {
89
+ const heading = this.getAttribute("heading") ?? "";
90
+ const subheading = this.getAttribute("subheading") ?? "";
91
+ const artwork = this.getAttribute("artwork");
92
+ this.heading.textContent = heading;
93
+ this.subheading.textContent = subheading;
94
+ if (artwork === null) {
95
+ this.artwork.removeAttribute("src");
96
+ this.artwork.hidden = true;
97
+ } else {
98
+ this.artwork.src = artwork;
99
+ this.artwork.hidden = false;
100
+ }
101
+ this.toggleAttribute("empty", heading === "" && subheading === "" && artwork === null);
102
+ }
103
+ };
104
+ //#endregion
105
+ export { MbxTitle };
106
+
139
107
  //# sourceMappingURL=title.js.map