@mattebox/player 0.15.0 → 0.16.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.
- package/dist/cdn/mattebox-player.min.js +3 -3
- package/dist/controls/chapters.d.ts +2 -8
- package/dist/controls/chapters.d.ts.map +1 -1
- package/dist/controls/chapters.js.map +1 -1
- package/dist/controls/cues.d.ts.map +1 -1
- package/dist/controls/cues.js +2 -2
- package/dist/controls/cues.js.map +1 -1
- package/dist/controls/icons.d.ts +1 -1
- package/dist/controls/icons.d.ts.map +1 -1
- package/dist/controls/icons.js +2 -0
- package/dist/controls/icons.js.map +1 -1
- package/dist/element.d.ts +19 -2
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +46 -6
- package/dist/element.js.map +1 -1
- package/dist/elements/casting.d.ts +3 -0
- package/dist/elements/casting.d.ts.map +1 -1
- package/dist/elements/casting.js +12 -15
- package/dist/elements/casting.js.map +1 -1
- package/dist/elements/control-bar.d.ts +16 -2
- package/dist/elements/control-bar.d.ts.map +1 -1
- package/dist/elements/control-bar.js +23 -2
- package/dist/elements/control-bar.js.map +1 -1
- package/dist/elements/drm-badge.js +1 -1
- package/dist/elements/error-screen.js +1 -1
- package/dist/elements/live-button.js +1 -1
- package/dist/elements/shared.js +3 -3
- package/dist/elements/speed-menu.d.ts.map +1 -1
- package/dist/elements/speed-menu.js +1 -1
- package/dist/elements/speed-menu.js.map +1 -1
- package/dist/elements/subtitles-menu.d.ts.map +1 -1
- package/dist/elements/subtitles-menu.js +29 -6
- package/dist/elements/subtitles-menu.js.map +1 -1
- package/dist/es2015/controls/cues.js +2 -2
- package/dist/es2015/controls/icons.js +2 -0
- package/dist/es2015/element.js +63 -25
- package/dist/es2015/elements/casting.js +13 -15
- package/dist/es2015/elements/control-bar.js +23 -2
- package/dist/es2015/elements/drm-badge.js +1 -1
- package/dist/es2015/elements/error-screen.js +1 -1
- package/dist/es2015/elements/live-button.js +1 -1
- package/dist/es2015/elements/shared.js +3 -3
- package/dist/es2015/elements/speed-menu.js +1 -1
- package/dist/es2015/elements/subtitles-menu.js +29 -6
- package/dist/es2015/locales/ar.js +2 -0
- package/dist/es2015/locales/ca.js +2 -0
- package/dist/es2015/locales/de.js +2 -0
- package/dist/es2015/locales/es.js +2 -0
- package/dist/es2015/locales/fr.js +2 -0
- package/dist/es2015/locales/hi.js +2 -0
- package/dist/es2015/locales/it.js +2 -0
- package/dist/es2015/locales/ja.js +2 -0
- package/dist/es2015/locales/ko.js +2 -0
- package/dist/es2015/locales/pt.js +2 -0
- package/dist/es2015/locales/zh.js +2 -0
- package/dist/es2015/presets.js +2 -1
- package/dist/es2015/style.js +1 -1
- package/dist/host.d.ts +13 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/ar.d.ts +2 -0
- package/dist/locales/ar.d.ts.map +1 -1
- package/dist/locales/ar.js +2 -0
- package/dist/locales/ar.js.map +1 -1
- package/dist/locales/ca.d.ts +2 -0
- package/dist/locales/ca.d.ts.map +1 -1
- package/dist/locales/ca.js +2 -0
- package/dist/locales/ca.js.map +1 -1
- package/dist/locales/de.d.ts +2 -0
- package/dist/locales/de.d.ts.map +1 -1
- package/dist/locales/de.js +2 -0
- package/dist/locales/de.js.map +1 -1
- package/dist/locales/es.d.ts +2 -0
- package/dist/locales/es.d.ts.map +1 -1
- package/dist/locales/es.js +2 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.d.ts +2 -0
- package/dist/locales/fr.d.ts.map +1 -1
- package/dist/locales/fr.js +2 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/hi.d.ts +2 -0
- package/dist/locales/hi.d.ts.map +1 -1
- package/dist/locales/hi.js +2 -0
- package/dist/locales/hi.js.map +1 -1
- package/dist/locales/it.d.ts +2 -0
- package/dist/locales/it.d.ts.map +1 -1
- package/dist/locales/it.js +2 -0
- package/dist/locales/it.js.map +1 -1
- package/dist/locales/ja.d.ts +2 -0
- package/dist/locales/ja.d.ts.map +1 -1
- package/dist/locales/ja.js +2 -0
- package/dist/locales/ja.js.map +1 -1
- package/dist/locales/ko.d.ts +2 -0
- package/dist/locales/ko.d.ts.map +1 -1
- package/dist/locales/ko.js +2 -0
- package/dist/locales/ko.js.map +1 -1
- package/dist/locales/pt.d.ts +2 -0
- package/dist/locales/pt.d.ts.map +1 -1
- package/dist/locales/pt.js +2 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/locales/zh.d.ts +2 -0
- package/dist/locales/zh.d.ts.map +1 -1
- package/dist/locales/zh.js +2 -0
- package/dist/locales/zh.js.map +1 -1
- package/dist/messages.d.ts +4 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/presets.js +2 -1
- package/dist/presets.js.map +1 -1
- package/dist/style.js +1 -1
- package/package.json +3 -3
|
@@ -16,14 +16,8 @@
|
|
|
16
16
|
* hidden draws nothing, and the cues arrive.
|
|
17
17
|
*/
|
|
18
18
|
import type { Mattebox } from 'mattebox';
|
|
19
|
-
import type { PlayerHost } from '../host.js';
|
|
20
|
-
export
|
|
21
|
-
readonly start: number;
|
|
22
|
-
readonly end: number;
|
|
23
|
-
readonly title: string;
|
|
24
|
-
/** The URL of the chapter's picture. Only the engine's chapters carry one. */
|
|
25
|
-
readonly image?: string;
|
|
26
|
-
}
|
|
19
|
+
import type { Chapter, PlayerHost } from '../host.js';
|
|
20
|
+
export type { Chapter };
|
|
27
21
|
/** The first chapters track on the video, or null. */
|
|
28
22
|
export declare function chapterTrack(video: HTMLVideoElement): TextTrack | null;
|
|
29
23
|
/** The chapters of the session: the engine's when it holds some, else the video's track. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../src/controls/chapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chapters.d.ts","sourceRoot":"","sources":["../../src/controls/chapters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGtD,YAAY,EAAE,OAAO,EAAE,CAAC;AAExB,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,GAAG,IAAI,CAGtE;AA0BD,4FAA4F;AAC5F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,OAAO,EAAE,CAGpF;AAED,8FAA8F;AAC9F,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAIxE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CA0C7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chapters.js","names":[],"sources":["../../src/controls/chapters.ts"],"sourcesContent":["/**\n * Chapters come from one of two places, read through these helpers so the\n * seek bar and the chapters menu agree without knowing each other.\n *\n * - The engine's `chapters` namespace, when the session has one and it\n * holds chapters: a file the player's `chapters` attribute loaded, the\n * manifest's own, or chapters the page set. See the engine guide's\n * chapters chapter.\n * - Otherwise the browser's own: a text track of kind `chapters` on the\n * video, from a `<track>` the page or the player's `chapters` attribute\n * put there, or from `addTextTrack`. A native session has chapters this\n * way.\n *\n * A track from a `<track>` element loads its cues only while its mode is\n * `hidden` or `showing`, so a disabled chapters track is set hidden here:\n * hidden draws nothing, and the cues arrive.\n */\nimport type { Mattebox } from 'mattebox';\nimport type { PlayerHost } from '../host.js';\nimport { optional } from './session.js';\n\nexport
|
|
1
|
+
{"version":3,"file":"chapters.js","names":[],"sources":["../../src/controls/chapters.ts"],"sourcesContent":["/**\n * Chapters come from one of two places, read through these helpers so the\n * seek bar and the chapters menu agree without knowing each other.\n *\n * - The engine's `chapters` namespace, when the session has one and it\n * holds chapters: a file the player's `chapters` attribute loaded, the\n * manifest's own, or chapters the page set. See the engine guide's\n * chapters chapter.\n * - Otherwise the browser's own: a text track of kind `chapters` on the\n * video, from a `<track>` the page or the player's `chapters` attribute\n * put there, or from `addTextTrack`. A native session has chapters this\n * way.\n *\n * A track from a `<track>` element loads its cues only while its mode is\n * `hidden` or `showing`, so a disabled chapters track is set hidden here:\n * hidden draws nothing, and the cues arrive.\n */\nimport type { Mattebox } from 'mattebox';\nimport type { Chapter, PlayerHost } from '../host.js';\nimport { optional } from './session.js';\n\nexport type { Chapter };\n\n/** The first chapters track on the video, or null. */\nexport function chapterTrack(video: HTMLVideoElement): TextTrack | null {\n for (const track of video.textTracks) if (track.kind === 'chapters') return track;\n return null;\n}\n\n/** The engine's chapters, already in order, or none. */\nfunction engineChapters(engine: Mattebox | null): Chapter[] {\n const api = optional(engine).chapters;\n if (api === undefined) return [];\n return api.all.map((chapter) => ({\n start: chapter.start,\n end: chapter.end,\n title: chapter.title,\n ...(chapter.image === undefined ? {} : { image: chapter.image.url }),\n }));\n}\n\n/** The cues of the video's chapters track, in order, or none. */\nfunction trackChapters(video: HTMLVideoElement): Chapter[] {\n const track = chapterTrack(video);\n if (track === null || track.cues === null) return [];\n const out: Chapter[] = [];\n for (const cue of track.cues) {\n const text = cue instanceof VTTCue ? cue.text : '';\n out.push({ start: cue.startTime, end: cue.endTime, title: text.trim() });\n }\n return out.sort((a, b) => a.start - b.start);\n}\n\n/** The chapters of the session: the engine's when it holds some, else the video's track. */\nexport function chapters(video: HTMLVideoElement, engine: Mattebox | null): Chapter[] {\n const own = engineChapters(engine);\n return own.length > 0 ? own : trackChapters(video);\n}\n\n/** The index of the chapter `time` falls in, the last one started, or -1 before the first. */\nexport function chapterAt(list: readonly Chapter[], time: number): number {\n let found = -1;\n for (const [i, chapter] of list.entries()) if (chapter.start <= time) found = i;\n return found;\n}\n\n/**\n * Runs `fn` whenever the chapters may have changed: the engine reported a\n * change, a session came in, a track was added or removed, the cues of a\n * `<track>` arrived, or the active cue moved on. Returns the unsubscribe.\n * Every chapters track found is set hidden, so its cues load.\n */\nexport function followChapters(player: PlayerHost, fn: () => void): () => void {\n const video = player.media;\n const listen = (target: EventTarget, name: string, handler: () => void): (() => void) => {\n target.addEventListener(name, handler);\n return () => {\n target.removeEventListener(name, handler);\n };\n };\n /** The listeners on the tracks of the moment, replaced when the list changes. */\n let inner: Array<() => void> = [];\n /** The listener on the engine of the moment, replaced when the session changes. */\n let own: () => void = () => undefined;\n const wire = (): void => {\n for (const off of inner) off();\n inner = [];\n for (const track of video.textTracks) {\n if (track.kind !== 'chapters') continue;\n if (track.mode === 'disabled') track.mode = 'hidden';\n inner.push(listen(track, 'cuechange', fn));\n }\n for (const node of video.querySelectorAll('track')) {\n if (node.kind === 'chapters') inner.push(listen(node, 'load', fn));\n }\n fn();\n };\n const session = (): void => {\n own();\n own = player.engine?.on('chapters:changed', fn) ?? (() => undefined);\n fn();\n };\n const outer = [\n listen(video.textTracks, 'addtrack', wire),\n listen(video.textTracks, 'removetrack', wire),\n listen(player, 'sourcechange', session),\n ];\n wire();\n session();\n return () => {\n for (const off of [...outer, ...inner]) off();\n own();\n inner = [];\n };\n}\n"],"mappings":";;;AAwBA,SAAgB,aAAa,OAA2C;CACtE,KAAK,MAAM,SAAS,MAAM,YAAY,IAAI,MAAM,SAAS,YAAY,OAAO;CAC5E,OAAO;AACT;;AAGA,SAAS,eAAe,QAAoC;CAC1D,MAAM,MAAM,SAAS,MAAM,CAAC,CAAC;CAC7B,IAAI,QAAQ,KAAA,GAAW,OAAO,CAAC;CAC/B,OAAO,IAAI,IAAI,KAAK,aAAa;EAC/B,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M,OAAO;GAC5C,MAAM,KAAK,OAAO,OAAO,aAAa,EAAE,CAAC;EAC3C;EACA,KAAK,MAAM,QAAQ,MAAM,iBAAiB,OAAO,GAC/C,IAAI,KAAK,SAAS,YAAY,MAAM,KAAK,OAAO,MAAM,QAAQ,EAAE,CAAC;EAEnE,GAAG;CACL;CACA,MAAM,gBAAsB;EAC1B,IAAI;EACJ,MAAM,OAAO,QAAQ,GAAG,oBAAoB,EAAE,YAAY,KAAA;EAC1D,GAAG;CACL;CACA,MAAM,QAAQ;EACZ,OAAO,MAAM,YAAY,YAAY,IAAI;EACzC,OAAO,MAAM,YAAY,eAAe,IAAI;EAC5C,OAAO,QAAQ,gBAAgB,OAAO;CACxC;CACA,KAAK;CACL,QAAQ;CACR,aAAa;EACX,KAAK,MAAM,OAAO,CAAC,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI;EAC5C,IAAI;EACJ,QAAQ,CAAC;CACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cues.d.ts","sourceRoot":"","sources":["../../src/controls/cues.ts"],"names":[],"mappings":"AAwBA,mFAAmF;AACnF,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKnD,CAAC;AAqBF,gDAAgD;AAChD,wBAAgB,QAAQ,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"cues.d.ts","sourceRoot":"","sources":["../../src/controls/cues.ts"],"names":[],"mappings":"AAwBA,mFAAmF;AACnF,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKnD,CAAC;AAqBF,gDAAgD;AAChD,wBAAgB,QAAQ,IAAI,IAAI,CAO/B;AASD,MAAM,WAAW,OAAO;IACtB,qEAAqE;IACrE,MAAM,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,4GAA4G;AAC5G,MAAM,MAAM,OAAO,GAAG,MAAM;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,wBAAgB,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAmJ7F"}
|
package/dist/controls/cues.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* already follows the video's height, in the page and in fullscreen alike.
|
|
23
23
|
* A page that wants more writes its own `mattebox-player > video::cue`.
|
|
24
24
|
*/
|
|
25
|
-
const CUE_RULES = "mattebox-player[subtitle-size=small]>video::cue{font-size:75%}mattebox-player[subtitle-size=large]>video::cue{font-size:150%}mattebox-player[subtitle-size=xlarge]>video::cue{font-size:200%}mattebox-player[subtitle-background=none]>video::cue{background-color:#0000}mattebox-player[subtitle-background=solid]>video::cue{background-color:#000}mattebox-player[subtitle-background=none]>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-background=solid]>video::-webkit-media-text-track-display-backdrop{background-color:#000}";
|
|
25
|
+
const CUE_RULES = "mattebox-player>video::cue{background-color:#0009}mattebox-player>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-size=small]>video::cue{font-size:75%}mattebox-player[subtitle-size=large]>video::cue{font-size:150%}mattebox-player[subtitle-size=xlarge]>video::cue{font-size:200%}mattebox-player[subtitle-background=none]>video::cue{background-color:#0000}mattebox-player[subtitle-background=solid]>video::cue{background-color:#000}mattebox-player[subtitle-background=none]>video::-webkit-media-text-track-display-backdrop{background-color:#0000}mattebox-player[subtitle-background=solid]>video::-webkit-media-text-track-display-backdrop{background-color:#000}";
|
|
26
26
|
/** How the sizes scale the browser's own cue size; the lift counts lines by it. */
|
|
27
27
|
const SCALES = {
|
|
28
28
|
small: .75,
|
|
@@ -52,7 +52,7 @@ function cueStyle() {
|
|
|
52
52
|
const style = document.createElement("style");
|
|
53
53
|
style.setAttribute(MARK, "");
|
|
54
54
|
style.textContent = CUE_RULES;
|
|
55
|
-
document.head.
|
|
55
|
+
document.head.prepend(style);
|
|
56
56
|
}
|
|
57
57
|
function cueLift(video, host, covered) {
|
|
58
58
|
/** The cues moved, with what they were, so they and only they are put back. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cues.js","names":[],"sources":["../../src/controls/cues.ts"],"sourcesContent":["/**\n * Subtitles and the bar. Two things.\n *\n * The lift: the browser draws native cues on the bottom edge of the video,\n * and under the bar. Every active cue the author left unpositioned is\n * moved up: above the bar while it shows, and one line off the edge while\n * it is hidden, so the text never sits on the picture's border. The\n * position is a negative line count, the one form every browser wraps at\n * the video's width; a percentage does not wrap in Chromium. Chromium\n * anchors the box's top on the count and Gecko its bottom, and their\n * overlap avoidance pushes in opposite directions, so nothing is left to\n * them: subtitles often show two cues at once, and the cues stack by their\n * own measured heights, wrapping included, clear under both readings. A\n * cue with a position of its own is the author's and is not touched.\n *\n * The look: `::cue` can only be styled from the document that holds the\n * video, which is the page and not the shadow root, and it takes no custom\n * properties. So a small sheet goes into the document, once, with one rule\n * per look the host's `subtitle-size` and `subtitle-background` attributes\n * can take. Sizes are percentages of the browser's own cue size, which\n * already follows the video's height, in the page and in fullscreen alike.\n * A page that wants more writes its own `mattebox-player > video::cue`.\n */\nimport CUE_RULES from './cues.css?inline';\n/** How the sizes scale the browser's own cue size; the lift counts lines by it. */\nexport const SCALES: Readonly<Record<string, number>> = {\n small: 0.75,\n medium: 1,\n large: 1.5,\n xlarge: 2,\n};\n\n/**\n * The sheet in the document. `mattebox-player` is the element's tag. The\n * background goes on `::cue` and on the backdrop pseudo-element Chromium\n * and WebKit have, both: which of the two paints it differs by browser and\n * version, and a selector a browser does not know only voids its own rule.\n */\n\nconst MARK = 'data-mattebox-cue';\n\n/** The browser's cue size against the video's height, per WebVTT, and its line against the size. */\nconst CUE_SIZE = 0.05;\nconst LINE_HEIGHT = 1.2;\n/** What a cue box spans of the video's width by default, so wrapping is measured against it. */\nconst CUE_WIDTH = 0.96;\n/** Pixels of air between the bar and the cue above it, before rounding up to a line. */\nconst AIR = 6;\n/** Lines of air under a cue while the bar is hidden. */\nconst REST = 1;\n\n/** Puts the cue rules in the document, once. */\nexport function cueStyle(): void {\n if (document.head.querySelector(`style[${MARK}]`) !== null) return;\n const style = document.createElement('style');\n style.setAttribute(MARK, '');\n style.textContent = CUE_RULES;\n document.head.append(style);\n}\n\n/** What a lifted cue looked like before, to put back. */\ninterface Placed {\n readonly line: number | 'auto';\n readonly snapToLines: boolean;\n readonly lineAlign: LineAlignSetting;\n}\n\nexport interface CueLift {\n /** Whether the bar is showing, so the cues move above it or back. */\n lifted(on: boolean): void;\n dispose(): void;\n}\n\n/** What the bar covers of the picture: from its first row's top, not its gradient run-in, to its bottom. */\nexport type Covered = () => { readonly top: number; readonly bottom: number };\n\nexport function cueLift(video: HTMLVideoElement, host: HTMLElement, covered: Covered): CueLift {\n /** The cues moved, with what they were, so they and only they are put back. */\n const lifted = new Map<VTTCue, Placed>();\n let on = false;\n /** False once disposed: the cues go back to where the author left them. */\n let live = true;\n let canvas: CanvasRenderingContext2D | null | undefined;\n\n function showing(): TextTrack[] {\n const out: TextTrack[] = [];\n for (const track of video.textTracks) if (track.mode === 'showing') out.push(track);\n return out;\n }\n\n /** The browser's cue font size, in pixels, from the video's height and the host's scale. */\n function fontSize(height: number): number {\n const scale = SCALES[host.getAttribute('subtitle-size') ?? ''] ?? 1;\n return height * CUE_SIZE * scale;\n }\n\n /** Measures text the way the browser draws cues, to count the lines a cue wraps into. */\n function measure(): CanvasRenderingContext2D | null {\n if (canvas === undefined) canvas = document.createElement('canvas').getContext('2d');\n return canvas;\n }\n\n /**\n * A cue's text without its tags, for measuring: `<b>`, `<c.name>`, the\n * timestamps and their closers. Brackets are counted, so a tag inside\n * another's brackets goes with it.\n */\n function plain(text: string): string {\n let out = '';\n let depth = 0;\n for (const char of text) {\n if (char === '<') depth += 1;\n else if (char === '>') depth = Math.max(0, depth - 1);\n else if (depth === 0) out += char;\n }\n return out;\n }\n\n /** The lines a cue takes: its own, each wrapped at the cue box's width. */\n function lines(cue: VTTCue, font: number, width: number): number {\n const context = measure();\n let total = 0;\n for (const line of plain(cue.text).split('\\n')) {\n if (context === null) {\n total += 1;\n continue;\n }\n context.font = `${font}px sans-serif`;\n total += Math.max(1, Math.ceil(context.measureText(line).width / (width * CUE_WIDTH)));\n }\n return total;\n }\n\n function apply(): void {\n const box = video.getBoundingClientRect();\n const height = box.height;\n const span = covered();\n const pixels = span.bottom - span.top;\n const lift = live && height > 0;\n const font = fontSize(height);\n const unit = font * LINE_HEIGHT;\n // The lines the bar covers, with a little air, rounded up to whole\n // lines. With the bar hidden, the cue rests a line off the edge.\n const barred = on && pixels > 0 && pixels < height;\n const base = barred ? Math.ceil((pixels + AIR) / unit) : REST;\n for (const track of showing()) {\n // Earliest first, the order the browser stacks them in, so the first\n // sits lowest and the rest climb.\n const active = [...(track.activeCues ?? [])]\n .filter((cue): cue is VTTCue => cue instanceof VTTCue)\n .sort((a, b) => a.startTime - b.startTime);\n let previous: { line: number; height: number } | null = null;\n let changed = false;\n for (const cue of active) {\n const was = lifted.get(cue);\n if (!lift) {\n if (was === undefined) continue;\n cue.line = was.line;\n cue.snapToLines = was.snapToLines;\n cue.lineAlign = was.lineAlign;\n lifted.delete(cue);\n changed = true;\n continue;\n }\n // The author's own placement is the author's.\n if (was === undefined && cue.line !== 'auto') continue;\n if (was === undefined) {\n lifted.set(cue, {\n line: cue.line,\n snapToLines: cue.snapToLines,\n lineAlign: cue.lineAlign,\n });\n }\n // A negative line count, which every browser wraps at the video's\n // width, unlike a percentage. Chromium anchors the box's top on it\n // and Gecko its bottom, so the count clears the bar and the cue\n // below under both readings, with a little air to spare in one.\n const own = lines(cue, font, box.width);\n const line: number =\n previous === null ? base + own : previous.line + Math.max(own, previous.height);\n if (cue.line !== -line || !cue.snapToLines) changed = true;\n cue.snapToLines = true;\n cue.line = -line;\n previous = { line, height: own };\n }\n // Chromium lays a changed line out again only when the track's display\n // is rebuilt, which neither time nor a seek does for a cue already\n // showing; the mode flipped off and on in one task rebuilds it with no\n // paint in between. Only on a change, so the change event this fires\n // finds nothing to do and the loop ends there.\n if (changed) {\n track.mode = 'hidden';\n track.mode = 'showing';\n }\n }\n }\n\n function watch(): void {\n for (const track of video.textTracks) {\n track.removeEventListener('cuechange', apply);\n track.addEventListener('cuechange', apply);\n }\n apply();\n }\n\n video.textTracks.addEventListener('change', watch);\n video.textTracks.addEventListener('addtrack', watch);\n watch();\n\n return {\n lifted(next: boolean): void {\n on = next;\n apply();\n },\n dispose(): void {\n on = false;\n live = false;\n apply();\n video.textTracks.removeEventListener('change', watch);\n video.textTracks.removeEventListener('addtrack', watch);\n for (const track of video.textTracks) track.removeEventListener('cuechange', apply);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAA,YAAA;;AAEA,MAAa,SAA2C;CACtD,OAAO;CACP,QAAQ;CACR,OAAO;CACP,QAAQ;AACV;;;;;;;AASA,MAAM,OAAO;;AAGb,MAAM,WAAW;AACjB,MAAM,cAAc;;AAEpB,MAAM,YAAY;;AAElB,MAAM,MAAM;;AAEZ,MAAM,OAAO;;AAGb,SAAgB,WAAiB;CAC/B,IAAI,SAAS,KAAK,cAAc,SAAS,KAAK,EAAE,MAAM,MAAM;CAC5D,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,aAAa,MAAM,EAAE;CAC3B,MAAM,cAAc;CACpB,SAAS,KAAK,OAAO,KAAK;AAC5B;AAkBA,SAAgB,QAAQ,OAAyB,MAAmB,SAA2B;;CAE7F,MAAM,yBAAS,IAAI,IAAoB;CACvC,IAAI,KAAK;;CAET,IAAI,OAAO;CACX,IAAI;CAEJ,SAAS,UAAuB;EAC9B,MAAM,MAAmB,CAAC;EAC1B,KAAK,MAAM,SAAS,MAAM,YAAY,I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KAAK;GACL,OAAO;GACP,MAAM;GACN,MAAM,WAAW,oBAAoB,UAAU,KAAK;GACpD,MAAM,WAAW,oBAAoB,YAAY,KAAK;GACtD,KAAK,MAAM,SAAS,MAAM,YAAY,MAAM,oBAAoB,aAAa,KAAK;EACpF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"cues.js","names":[],"sources":["../../src/controls/cues.ts"],"sourcesContent":["/**\n * Subtitles and the bar. Two things.\n *\n * The lift: the browser draws native cues on the bottom edge of the video,\n * and under the bar. Every active cue the author left unpositioned is\n * moved up: above the bar while it shows, and one line off the edge while\n * it is hidden, so the text never sits on the picture's border. The\n * position is a negative line count, the one form every browser wraps at\n * the video's width; a percentage does not wrap in Chromium. Chromium\n * anchors the box's top on the count and Gecko its bottom, and their\n * overlap avoidance pushes in opposite directions, so nothing is left to\n * them: subtitles often show two cues at once, and the cues stack by their\n * own measured heights, wrapping included, clear under both readings. A\n * cue with a position of its own is the author's and is not touched.\n *\n * The look: `::cue` can only be styled from the document that holds the\n * video, which is the page and not the shadow root, and it takes no custom\n * properties. So a small sheet goes into the document, once, with one rule\n * per look the host's `subtitle-size` and `subtitle-background` attributes\n * can take. Sizes are percentages of the browser's own cue size, which\n * already follows the video's height, in the page and in fullscreen alike.\n * A page that wants more writes its own `mattebox-player > video::cue`.\n */\nimport CUE_RULES from './cues.css?inline';\n/** How the sizes scale the browser's own cue size; the lift counts lines by it. */\nexport const SCALES: Readonly<Record<string, number>> = {\n small: 0.75,\n medium: 1,\n large: 1.5,\n xlarge: 2,\n};\n\n/**\n * The sheet in the document. `mattebox-player` is the element's tag. The\n * background goes on `::cue` and on the backdrop pseudo-element Chromium\n * and WebKit have, both: which of the two paints it differs by browser and\n * version, and a selector a browser does not know only voids its own rule.\n */\n\nconst MARK = 'data-mattebox-cue';\n\n/** The browser's cue size against the video's height, per WebVTT, and its line against the size. */\nconst CUE_SIZE = 0.05;\nconst LINE_HEIGHT = 1.2;\n/** What a cue box spans of the video's width by default, so wrapping is measured against it. */\nconst CUE_WIDTH = 0.96;\n/** Pixels of air between the bar and the cue above it, before rounding up to a line. */\nconst AIR = 6;\n/** Lines of air under a cue while the bar is hidden. */\nconst REST = 1;\n\n/** Puts the cue rules in the document, once. */\nexport function cueStyle(): void {\n if (document.head.querySelector(`style[${MARK}]`) !== null) return;\n const style = document.createElement('style');\n style.setAttribute(MARK, '');\n style.textContent = CUE_RULES;\n // First in the head: a page's own rule of the same weight comes later and wins.\n document.head.prepend(style);\n}\n\n/** What a lifted cue looked like before, to put back. */\ninterface Placed {\n readonly line: number | 'auto';\n readonly snapToLines: boolean;\n readonly lineAlign: LineAlignSetting;\n}\n\nexport interface CueLift {\n /** Whether the bar is showing, so the cues move above it or back. */\n lifted(on: boolean): void;\n dispose(): void;\n}\n\n/** What the bar covers of the picture: from its first row's top, not its gradient run-in, to its bottom. */\nexport type Covered = () => { readonly top: number; readonly bottom: number };\n\nexport function cueLift(video: HTMLVideoElement, host: HTMLElement, covered: Covered): CueLift {\n /** The cues moved, with what they were, so they and only they are put back. */\n const lifted = new Map<VTTCue, Placed>();\n let on = false;\n /** False once disposed: the cues go back to where the author left them. */\n let live = true;\n let canvas: CanvasRenderingContext2D | null | undefined;\n\n function showing(): TextTrack[] {\n const out: TextTrack[] = [];\n for (const track of video.textTracks) if (track.mode === 'showing') out.push(track);\n return out;\n }\n\n /** The browser's cue font size, in pixels, from the video's height and the host's scale. */\n function fontSize(height: number): number {\n const scale = SCALES[host.getAttribute('subtitle-size') ?? ''] ?? 1;\n return height * CUE_SIZE * scale;\n }\n\n /** Measures text the way the browser draws cues, to count the lines a cue wraps into. */\n function measure(): CanvasRenderingContext2D | null {\n if (canvas === undefined) canvas = document.createElement('canvas').getContext('2d');\n return canvas;\n }\n\n /**\n * A cue's text without its tags, for measuring: `<b>`, `<c.name>`, the\n * timestamps and their closers. Brackets are counted, so a tag inside\n * another's brackets goes with it.\n */\n function plain(text: string): string {\n let out = '';\n let depth = 0;\n for (const char of text) {\n if (char === '<') depth += 1;\n else if (char === '>') depth = Math.max(0, depth - 1);\n else if (depth === 0) out += char;\n }\n return out;\n }\n\n /** The lines a cue takes: its own, each wrapped at the cue box's width. */\n function lines(cue: VTTCue, font: number, width: number): number {\n const context = measure();\n let total = 0;\n for (const line of plain(cue.text).split('\\n')) {\n if (context === null) {\n total += 1;\n continue;\n }\n context.font = `${font}px sans-serif`;\n total += Math.max(1, Math.ceil(context.measureText(line).width / (width * CUE_WIDTH)));\n }\n return total;\n }\n\n function apply(): void {\n const box = video.getBoundingClientRect();\n const height = box.height;\n const span = covered();\n const pixels = span.bottom - span.top;\n const lift = live && height > 0;\n const font = fontSize(height);\n const unit = font * LINE_HEIGHT;\n // The lines the bar covers, with a little air, rounded up to whole\n // lines. With the bar hidden, the cue rests a line off the edge.\n const barred = on && pixels > 0 && pixels < height;\n const base = barred ? Math.ceil((pixels + AIR) / unit) : REST;\n for (const track of showing()) {\n // Earliest first, the order the browser stacks them in, so the first\n // sits lowest and the rest climb.\n const active = [...(track.activeCues ?? [])]\n .filter((cue): cue is VTTCue => cue instanceof VTTCue)\n .sort((a, b) => a.startTime - b.startTime);\n let previous: { line: number; height: number } | null = null;\n let changed = false;\n for (const cue of active) {\n const was = lifted.get(cue);\n if (!lift) {\n if (was === undefined) continue;\n cue.line = was.line;\n cue.snapToLines = was.snapToLines;\n cue.lineAlign = was.lineAlign;\n lifted.delete(cue);\n changed = true;\n continue;\n }\n // The author's own placement is the author's.\n if (was === undefined && cue.line !== 'auto') continue;\n if (was === undefined) {\n lifted.set(cue, {\n line: cue.line,\n snapToLines: cue.snapToLines,\n lineAlign: cue.lineAlign,\n });\n }\n // A negative line count, which every browser wraps at the video's\n // width, unlike a percentage. Chromium anchors the box's top on it\n // and Gecko its bottom, so the count clears the bar and the cue\n // below under both readings, with a little air to spare in one.\n const own = lines(cue, font, box.width);\n const line: number =\n previous === null ? base + own : previous.line + Math.max(own, previous.height);\n if (cue.line !== -line || !cue.snapToLines) changed = true;\n cue.snapToLines = true;\n cue.line = -line;\n previous = { line, height: own };\n }\n // Chromium lays a changed line out again only when the track's display\n // is rebuilt, which neither time nor a seek does for a cue already\n // showing; the mode flipped off and on in one task rebuilds it with no\n // paint in between. Only on a change, so the change event this fires\n // finds nothing to do and the loop ends there.\n if (changed) {\n track.mode = 'hidden';\n track.mode = 'showing';\n }\n }\n }\n\n function watch(): void {\n for (const track of video.textTracks) {\n track.removeEventListener('cuechange', apply);\n track.addEventListener('cuechange', apply);\n }\n apply();\n }\n\n video.textTracks.addEventListener('change', watch);\n video.textTracks.addEventListener('addtrack', watch);\n watch();\n\n return {\n lifted(next: boolean): void {\n on = next;\n apply();\n },\n dispose(): void {\n on = false;\n live = false;\n apply();\n video.textTracks.removeEventListener('change', watch);\n video.textTracks.removeEventListener('addtrack', watch);\n for (const track of video.textTracks) track.removeEventListener('cuechange', apply);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAA,YAAA;;AAEA,MAAa,SAA2C;CACtD,OAAO;CACP,QAAQ;CACR,OAAO;CACP,QAAQ;AACV;;;;;;;AASA,MAAM,OAAO;;AAGb,MAAM,WAAW;AACjB,MAAM,cAAc;;AAEpB,MAAM,YAAY;;AAElB,MAAM,MAAM;;AAEZ,MAAM,OAAO;;AAGb,SAAgB,WAAiB;CAC/B,IAAI,SAAS,KAAK,cAAc,SAAS,KAAK,EAAE,MAAM,MAAM;CAC5D,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,aAAa,MAAM,EAAE;CAC3B,MAAM,cAAc;CAEpB,SAAS,KAAK,QAAQ,KAAK;AAC7B;AAkBA,SAAgB,QAAQ,OAAyB,MAAmB,SAA2B;;CAE7F,MAAM,yBAAS,IAAI,IAAoB;CACvC,IAAI,KAAK;;CAET,IAAI,OAAO;CACX,IAAI;CAEJ,SAAS,UAAuB;EAC9B,MAAM,MAAmB,CAAC;EAC1B,KAAK,MAAM,SAAS,MAAM,YAAY,IAAI,MAAM,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OAAO;GACP,MAAM;GACN,MAAM,WAAW,oBAAoB,UAAU,KAAK;GACpD,MAAM,WAAW,oBAAoB,YAAY,KAAK;GACtD,KAAK,MAAM,SAAS,MAAM,YAAY,MAAM,oBAAoB,aAAa,KAAK;EACpF;CACF;AACF"}
|
package/dist/controls/icons.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* like the panels of the mark. Each is one path, so a glyph scales to any
|
|
5
5
|
* size and takes the text colour.
|
|
6
6
|
*/
|
|
7
|
-
export type IconName = 'play' | 'pause' | 'replay' | 'mute' | 'volume-low' | 'volume-high' | 'fullscreen' | 'fullscreen-exit' | 'quality' | 'audio' | 'video' | 'subtitles' | 'subtitles-on' | 'lock-closed' | 'seek-backward' | 'seek-forward' | 'seek-backward-5' | 'seek-forward-5' | 'seek-backward-10' | 'seek-forward-10' | 'seek-backward-15' | 'seek-forward-15' | 'seek-backward-30' | 'seek-forward-30' | 'playback-speed' | 'picture-in-picture' | 'picture-in-picture-exit' | 'airplay' | 'airplay-active' | 'chapters' | 'fast-forward' | 'fast-backward' | 'audio-description' | 'sdh' | 'closed-captions' | 'text-size' | 'text-background';
|
|
7
|
+
export type IconName = 'play' | 'pause' | 'replay' | 'mute' | 'volume-low' | 'volume-high' | 'fullscreen' | 'fullscreen-exit' | 'quality' | 'audio' | 'video' | 'subtitles' | 'subtitles-on' | 'lock-closed' | 'seek-backward' | 'seek-forward' | 'seek-backward-5' | 'seek-forward-5' | 'seek-backward-10' | 'seek-forward-10' | 'seek-backward-15' | 'seek-forward-15' | 'seek-backward-30' | 'seek-forward-30' | 'playback-speed' | 'picture-in-picture' | 'picture-in-picture-exit' | 'airplay' | 'airplay-active' | 'cast' | 'chapters' | 'fast-forward' | 'fast-backward' | 'audio-description' | 'sdh' | 'closed-captions' | 'generated' | 'text-size' | 'text-background';
|
|
8
8
|
/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */
|
|
9
9
|
export declare function icon(name: IconName): SVGSVGElement;
|
|
10
10
|
//# sourceMappingURL=icons.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/controls/icons.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,SAAS,GACT,OAAO,GACP,OAAO,GACP,WAAW,GACX,cAAc,GACd,aAAa,GACb,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,GAChB,oBAAoB,GACpB,yBAAyB,GACzB,SAAS,GACT,gBAAgB,GAChB,UAAU,GACV,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,KAAK,GACL,iBAAiB,GACjB,WAAW,GACX,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/controls/icons.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,QAAQ,GACR,MAAM,GACN,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,SAAS,GACT,OAAO,GACP,OAAO,GACP,WAAW,GACX,cAAc,GACd,aAAa,GACb,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,GAChB,oBAAoB,GACpB,yBAAyB,GACzB,SAAS,GACT,gBAAgB,GAChB,MAAM,GACN,UAAU,GACV,cAAc,GACd,eAAe,GACf,mBAAmB,GACnB,KAAK,GACL,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,iBAAiB,CAAC;AAkFtB,2FAA2F;AAC3F,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,aAAa,CAUlD"}
|
package/dist/controls/icons.js
CHANGED
|
@@ -34,12 +34,14 @@ const PATHS = {
|
|
|
34
34
|
"picture-in-picture-exit": "M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z",
|
|
35
35
|
airplay: "M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z",
|
|
36
36
|
"airplay-active": "M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z",
|
|
37
|
+
cast: "M4 6H28V26H17.5V23.5H25.5V8.5H6.5V12H4zM4 22.5A3.5 3.5 0 0 1 7.5 26H4zM4 16A10 10 0 0 1 14 26H11.5A7.5 7.5 0 0 0 4 18.5z",
|
|
37
38
|
chapters: "M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z",
|
|
38
39
|
"fast-forward": "M4 7L15 16L4 25zM16 7L27 16L16 25z",
|
|
39
40
|
"fast-backward": "M28 7L17 16L28 25zM16 7L5 16L16 25z",
|
|
40
41
|
"audio-description": "M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z",
|
|
41
42
|
sdh: "M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z",
|
|
42
43
|
"closed-captions": "M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z",
|
|
44
|
+
generated: "M13 6Q13.8 15.2 23 16Q13.8 16.8 13 26Q12.2 16.8 3 16Q12.2 15.2 13 6zM24 2Q24.4 6.6 29 7Q24.4 7.4 24 12Q23.6 7.4 19 7Q23.6 6.6 24 2z",
|
|
43
45
|
"text-size": "M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z",
|
|
44
46
|
"text-background": "M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z"
|
|
45
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","names":[],"sources":["../../src/controls/icons.ts"],"sourcesContent":["/**\n * The glyphs, Mattebox's own drawings: filled paths on a 32-unit viewBox,\n * one visual weight across the set, with hard corners and 45 degree cuts\n * like the panels of the mark. Each is one path, so a glyph scales to any\n * size and takes the text colour.\n */\n\nexport type IconName =\n | 'play'\n | 'pause'\n | 'replay'\n | 'mute'\n | 'volume-low'\n | 'volume-high'\n | 'fullscreen'\n | 'fullscreen-exit'\n | 'quality'\n | 'audio'\n | 'video'\n | 'subtitles'\n | 'subtitles-on'\n | 'lock-closed'\n | 'seek-backward'\n | 'seek-forward'\n | 'seek-backward-5'\n | 'seek-forward-5'\n | 'seek-backward-10'\n | 'seek-forward-10'\n | 'seek-backward-15'\n | 'seek-forward-15'\n | 'seek-backward-30'\n | 'seek-forward-30'\n | 'playback-speed'\n | 'picture-in-picture'\n | 'picture-in-picture-exit'\n | 'airplay'\n | 'airplay-active'\n | 'chapters'\n | 'fast-forward'\n | 'fast-backward'\n | 'audio-description'\n | 'sdh'\n | 'closed-captions'\n | 'text-size'\n | 'text-background';\n\n/**\n * Each glyph's subpaths joined into one `d`. The path is drawn even-odd:\n * a frame, a ring or a letter cuts its hole with a nested subpath, and no\n * two filled subpaths overlap.\n */\nconst PATHS: Readonly<Record<IconName, string>> = {\n play: 'M9 5L26 16L9 27z',\n pause: 'M8 6h5.5v20h-5.5zM18.5 6h5.5v20h-5.5z',\n replay:\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n mute: 'M4 12L9 12L16 6L16 26L9 20L4 20zM24 17.77L20.99 20.77L19.23 19.01L22.23 16L19.23 12.99L20.99 11.23L24 14.23L27.01 11.23L28.77 12.99L25.77 16L28.77 19.01L27.01 20.77z',\n 'volume-low':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64z',\n 'volume-high':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64zM24.31 7.69A11.75 11.75 0 0 1 24.31 24.31L22.54 22.54A9.25 9.25 0 0 0 22.54 9.46z',\n fullscreen:\n 'M5 5L14 5L11 8L8 8L8 11L5 14zM18 5L27 5L27 14L24 11L24 8L21 8zM5 18L8 21L8 24L11 24L14 27L5 27zM27 18L27 27L18 27L21 24L24 24L24 21z',\n 'fullscreen-exit':\n 'M13 4L13 13L4 13L7 10L10 10L10 7zM19 4L22 7L22 10L25 10L28 13L19 13zM4 19L13 19L13 28L10 25L10 22L7 22zM19 19L28 19L25 22L22 22L22 25L19 28z',\n quality:\n 'M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z',\n audio:\n 'M4.75 13h2.5v6h-2.5zM9.75 9h2.5v14h-2.5zM14.75 5h2.5v22h-2.5zM19.75 10.5h2.5v11h-2.5zM24.75 13.5h2.5v5h-2.5z',\n // A camera: the body as a frame, the lens solid.\n video: 'M4 9h16v14H4zM6.5 11.5h11v9h-11zM21 14l7-4v12l-7-4z',\n subtitles:\n 'M4 6h20l4 4v16H4zM6.5 8.5H22.96L25.5 11.04V23.5H6.5zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'subtitles-on':\n 'M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'lock-closed':\n 'M7 14h18v13H7zM14.75 18.5v4.5h2.5v-4.5zM9.75 14V11A6.25 6.25 0 0 1 22.25 11V14H19.75V11A3.75 3.75 0 0 0 12.25 11V14z',\n 'seek-backward':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n 'seek-forward':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5z',\n 'seek-backward-5':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-forward-5':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-backward-10':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-10':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-backward-15':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-forward-15':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-backward-30':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-30':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'playback-speed':\n 'M7.69 26.31A11.75 11.75 0 1 1 24.31 26.31L22.54 24.54A9.25 9.25 0 1 0 9.46 24.54zM16.41 20.31L21.14 11.87L13.66 17.99z',\n 'picture-in-picture': 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM15 15h8v6h-8z',\n 'picture-in-picture-exit':\n 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z',\n airplay: 'M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z',\n 'airplay-active': 'M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z',\n chapters:\n 'M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z',\n 'fast-forward': 'M4 7L15 16L4 25zM16 7L27 16L16 25z',\n 'fast-backward': 'M28 7L17 16L28 25zM16 7L5 16L16 25z',\n 'audio-description':\n 'M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z',\n sdh: 'M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z',\n 'closed-captions':\n 'M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z',\n 'text-size':\n 'M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z',\n 'text-background':\n 'M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z',\n};\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */\nexport function icon(name: IconName): SVGSVGElement {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 32 32');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('part', 'icon');\n const path = document.createElementNS(SVG, 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('d', PATHS[name]);\n svg.append(path);\n return svg;\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"icons.js","names":[],"sources":["../../src/controls/icons.ts"],"sourcesContent":["/**\n * The glyphs, Mattebox's own drawings: filled paths on a 32-unit viewBox,\n * one visual weight across the set, with hard corners and 45 degree cuts\n * like the panels of the mark. Each is one path, so a glyph scales to any\n * size and takes the text colour.\n */\n\nexport type IconName =\n | 'play'\n | 'pause'\n | 'replay'\n | 'mute'\n | 'volume-low'\n | 'volume-high'\n | 'fullscreen'\n | 'fullscreen-exit'\n | 'quality'\n | 'audio'\n | 'video'\n | 'subtitles'\n | 'subtitles-on'\n | 'lock-closed'\n | 'seek-backward'\n | 'seek-forward'\n | 'seek-backward-5'\n | 'seek-forward-5'\n | 'seek-backward-10'\n | 'seek-forward-10'\n | 'seek-backward-15'\n | 'seek-forward-15'\n | 'seek-backward-30'\n | 'seek-forward-30'\n | 'playback-speed'\n | 'picture-in-picture'\n | 'picture-in-picture-exit'\n | 'airplay'\n | 'airplay-active'\n | 'cast'\n | 'chapters'\n | 'fast-forward'\n | 'fast-backward'\n | 'audio-description'\n | 'sdh'\n | 'closed-captions'\n | 'generated'\n | 'text-size'\n | 'text-background';\n\n/**\n * Each glyph's subpaths joined into one `d`. The path is drawn even-odd:\n * a frame, a ring or a letter cuts its hole with a nested subpath, and no\n * two filled subpaths overlap.\n */\nconst PATHS: Readonly<Record<IconName, string>> = {\n play: 'M9 5L26 16L9 27z',\n pause: 'M8 6h5.5v20h-5.5zM18.5 6h5.5v20h-5.5z',\n replay:\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n mute: 'M4 12L9 12L16 6L16 26L9 20L4 20zM24 17.77L20.99 20.77L19.23 19.01L22.23 16L19.23 12.99L20.99 11.23L24 14.23L27.01 11.23L28.77 12.99L25.77 16L28.77 19.01L27.01 20.77z',\n 'volume-low':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64z',\n 'volume-high':\n 'M4 12L9 12L16 6L16 26L9 20L4 20zM21.13 10.87A7.25 7.25 0 0 1 21.13 21.13L19.36 19.36A4.75 4.75 0 0 0 19.36 12.64zM24.31 7.69A11.75 11.75 0 0 1 24.31 24.31L22.54 22.54A9.25 9.25 0 0 0 22.54 9.46z',\n fullscreen:\n 'M5 5L14 5L11 8L8 8L8 11L5 14zM18 5L27 5L27 14L24 11L24 8L21 8zM5 18L8 21L8 24L11 24L14 27L5 27zM27 18L27 27L18 27L21 24L24 24L24 21z',\n 'fullscreen-exit':\n 'M13 4L13 13L4 13L7 10L10 10L10 7zM19 4L22 7L22 10L25 10L28 13L19 13zM4 19L13 19L13 28L10 25L10 22L7 22zM19 19L28 19L25 22L22 22L22 25L19 28z',\n quality:\n 'M5 22L10 18.1L10 27L5 27zM13.5 15.4L18.5 11.6L18.5 27L13.5 27zM22 8.9L27 5L27 27L22 27z',\n audio:\n 'M4.75 13h2.5v6h-2.5zM9.75 9h2.5v14h-2.5zM14.75 5h2.5v22h-2.5zM19.75 10.5h2.5v11h-2.5zM24.75 13.5h2.5v5h-2.5z',\n // A camera: the body as a frame, the lens solid.\n video: 'M4 9h16v14H4zM6.5 11.5h11v9h-11zM21 14l7-4v12l-7-4z',\n subtitles:\n 'M4 6h20l4 4v16H4zM6.5 8.5H22.96L25.5 11.04V23.5H6.5zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'subtitles-on':\n 'M4 6h20l4 4v16H4zM9 14h8v2.5h-8zM19 14h4v2.5h-4zM9 18.5h4v2.5h-4zM15 18.5h8v2.5h-8z',\n 'lock-closed':\n 'M7 14h18v13H7zM14.75 18.5v4.5h2.5v-4.5zM9.75 14V11A6.25 6.25 0 0 1 22.25 11V14H19.75V11A3.75 3.75 0 0 0 12.25 11V14z',\n 'seek-backward':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8z',\n 'seek-forward':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5z',\n 'seek-backward-5':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-forward-5':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h6v2h-6zM13 15.5h2v0.5h-2zM13 16h6v2h-6zM17 18h2v0.5h-2zM13 18.5h6v2h-6z',\n 'seek-backward-10':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-10':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM11.5 13.5h2.2v7h-2.2zM15.5 13.5h5.5v7h-5.5zM17.6 15.6v2.8h1.3v-2.8z',\n 'seek-backward-15':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-forward-15':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM10.5 13.5h2.2v7h-2.2zM14.7 13.5h5.8v2h-5.8zM14.7 15.5h2v0.5h-2zM14.7 16h5.8v2h-5.8zM18.5 18h2v0.5h-2zM14.7 18.5h5.8v2h-5.8z',\n 'seek-backward-30':\n 'M16 6.75A10.25 10.25 0 1 1 7.12 11.88L9.29 13.12A7.75 7.75 0 1 0 16 9.25zM16 3.5L16 12.5L10 8zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'seek-forward-30':\n 'M24.88 11.88A10.25 10.25 0 1 1 16 6.75L16 9.25A7.75 7.75 0 1 0 22.71 13.12zM16 3.5L22 8L16 12.5zM13 13.5h2v7h-2zM10 13.5h3v2h-3zM11 16h2v2h-2zM10 18.5h3v2h-3zM16.5 13.5h5.5v7h-5.5zM18.6 15.6v2.8h1.3v-2.8z',\n 'playback-speed':\n 'M7.69 26.31A11.75 11.75 0 1 1 24.31 26.31L22.54 24.54A9.25 9.25 0 1 0 9.46 24.54zM16.41 20.31L21.14 11.87L13.66 17.99z',\n 'picture-in-picture': 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM15 15h8v6h-8z',\n 'picture-in-picture-exit':\n 'M4 6h24v20H4zM6.5 8.5v15h19v-15zM9.5 11.5L16 11.5L9.5 18zM13.63 13.87L19.29 19.52L17.52 21.29L11.87 15.63z',\n airplay: 'M4 6H28V23.25H23V20.75H25.5V8.5H6.5V20.75H9V23.25H4zM16 17.5L23.5 27L8.5 27z',\n 'airplay-active': 'M4 6H28V23.25H22.1L16 15.5L9.9 23.25H4zM16 17.5L23.5 27L8.5 27z',\n // A screen with the cast waves in its corner: what a Chromecast plays on.\n cast: 'M4 6H28V26H17.5V23.5H25.5V8.5H6.5V12H4zM4 22.5A3.5 3.5 0 0 1 7.5 26H4zM4 16A10 10 0 0 1 14 26H11.5A7.5 7.5 0 0 0 4 18.5z',\n chapters:\n 'M5 6.5h4v4h-4zM12 7.25h15v2.5h-15zM5 14h4v4h-4zM12 14.75h15v2.5h-15zM5 21.5h4v4h-4zM12 22.25h15v2.5h-15z',\n 'fast-forward': 'M4 7L15 16L4 25zM16 7L27 16L16 25z',\n 'fast-backward': 'M28 7L17 16L28 25zM16 7L5 16L16 25z',\n 'audio-description':\n 'M1.5 23L4.8 9h2.6L10.7 23H8.4l-.75-3.2H4.55L3.8 23zM5.1 17.4h2L6.1 12.9zM12.2 9h2.8a7 7 0 0 1 0 14h-2.8zM14.6 11.4v9.2h.4a4.6 4.6 0 0 0 0-9.2zM24.2 9.96A9.4 9.4 0 0 1 24.2 22.04L22.82 20.89A7.6 7.6 0 0 0 22.82 11.11zM27.11 7.52A13.2 13.2 0 0 1 27.11 24.48L25.73 23.33A11.4 11.4 0 0 0 25.73 8.67z',\n sdh: 'M9.7 13.2L10.3 10.4L11.6 8.5L13.6 7.2L16 6.8L18.7 7.3L20.8 8.6L22.2 10.6L22.7 13L22.5 14.9L21.8 16.3L20.8 17.5L19.6 18.7L18.5 19.9L17.9 21.3L17.5 22.5L17.1 23.5L16.7 24.5L16 25.2L15.2 25.6L14.3 25.7L13.3 25.6L12.6 25.1L12 24.4L11.7 23.4L9.3 24.2L9.8 25.7L10.9 27L12.5 27.9L14.3 28.3L16 28L17.6 27.2L18.7 26L19.5 24.5L19.8 23.3L20.2 22.2L20.6 21.3L21.4 20.3L22.6 19.2L23.9 17.7L24.9 15.7L25.3 13L24.6 9.5L22.6 6.7L19.6 4.9L16 4.2L12.7 4.9L9.9 6.6L7.9 9.4L7.3 12.8zM13.7 13.2L13.9 12.1L14.4 11.4L15.1 10.9L16 10.8L16.9 10.9L17.6 11.4L18.1 12.1L18.3 13.2L20.7 12.8L20.4 11.1L19.4 9.6L17.9 8.6L16 8.2L14.1 8.6L12.6 9.6L11.6 11.1L11.3 12.8z',\n 'closed-captions':\n 'M14.24 20.24A6 6 0 1 1 14.24 11.76L12.47 13.53A3.5 3.5 0 1 0 12.47 18.47zM26.24 20.24A6 6 0 1 1 26.24 11.76L24.47 13.53A3.5 3.5 0 1 0 24.47 18.47z',\n // Sparkles: words a machine made, not a person.\n generated:\n 'M13 6Q13.8 15.2 23 16Q13.8 16.8 13 26Q12.2 16.8 3 16Q12.2 15.2 13 6zM24 2Q24.4 6.6 29 7Q24.4 7.4 24 12Q23.6 7.4 19 7Q23.6 6.6 24 2z',\n 'text-size':\n 'M2.5 23L5.9 13L8.1 13L11.5 23zM7 16.53L7.64 18.4L6.36 18.4zM5.65 20.5L8.35 20.5L9.2 23L4.8 23zM12.5 23L19.5 6L22.5 6L29.5 23zM21 9.64L23.45 15.6L18.55 15.6zM17.48 18.2L24.52 18.2L26.5 23L15.5 23z',\n 'text-background':\n 'M4 6h24v20h-24zM9 22.5L14.6 9.5L17.4 9.5L23 22.5zM16 12.75L17.66 16.6L14.34 16.6zM13.35 18.9L18.65 18.9L20.2 22.5L11.8 22.5z',\n};\n\nconst SVG = 'http://www.w3.org/2000/svg';\n\n/** A glyph, hidden from the accessibility tree: the button it sits in carries the name. */\nexport function icon(name: IconName): SVGSVGElement {\n const svg = document.createElementNS(SVG, 'svg');\n svg.setAttribute('viewBox', '0 0 32 32');\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('part', 'icon');\n const path = document.createElementNS(SVG, 'path');\n path.setAttribute('fill-rule', 'evenodd');\n path.setAttribute('d', PATHS[name]);\n svg.append(path);\n return svg;\n}\n"],"mappings":";;;;;;AAqDA,MAAM,QAA4C;CAChD,MAAM;CACN,OAAO;CACP,QACE;CACF,MAAM;CACN,cACE;CACF,eACE;CACF,YACE;CACF,mBACE;CACF,SACE;CACF,OACE;CAEF,OAAO;CACP,WACE;CACF,gBACE;CACF,eACE;CACF,iBACE;CACF,gBACE;CACF,mBACE;CACF,kBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,oBACE;CACF,mBACE;CACF,kBACE;CACF,sBAAsB;CACtB,2BACE;CACF,SAAS;CACT,kBAAkB;CAElB,MAAM;CACN,UACE;CACF,gBAAgB;CAChB,iBAAiB;CACjB,qBACE;CACF,KAAK;CACL,mBACE;CAEF,WACE;CACF,aACE;CACF,mBACE;AACJ;AAEA,MAAM,MAAM;;AAGZ,SAAgB,KAAK,MAA+B;CAClD,MAAM,MAAM,SAAS,gBAAgB,KAAK,KAAK;CAC/C,IAAI,aAAa,WAAW,WAAW;CACvC,IAAI,aAAa,eAAe,MAAM;CACtC,IAAI,aAAa,QAAQ,MAAM;CAC/B,MAAM,OAAO,SAAS,gBAAgB,KAAK,MAAM;CACjD,KAAK,aAAa,aAAa,SAAS;CACxC,KAAK,aAAa,KAAK,MAAM,KAAK;CAClC,IAAI,OAAO,IAAI;CACf,OAAO;AACT"}
|
package/dist/element.d.ts
CHANGED
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
* them into runtime helpers, and the emit check bans helpers. Statics are
|
|
18
18
|
* getters and instance state is declared, then assigned in the constructor.
|
|
19
19
|
*/
|
|
20
|
-
import type { Connector, Handler, Player, PlayerError, Programme, ProgrammeSource, Session, Source, SourceVideoTrack } from '@mattebox/player-core';
|
|
20
|
+
import type { Connector, Handler, Player, PlayerError, Programme, ProgrammeSource, Projection, Session, Source, SourceVideoTrack } from '@mattebox/player-core';
|
|
21
21
|
import type { KernelConfig, Mattebox, Stage } from 'mattebox';
|
|
22
22
|
import type { AttachEmeOptions } from 'mattebox/eme';
|
|
23
23
|
import { type BreakMarks } from './controls/breaks.js';
|
|
24
|
+
import { type Chapter } from './controls/chapters.js';
|
|
24
25
|
import type { Marker, Markers } from './controls/markers.js';
|
|
25
26
|
import type { Block, PlayerAddon, PlayerHost } from './host.js';
|
|
26
27
|
import type { LocaleSource } from './locales.js';
|
|
@@ -205,6 +206,11 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
|
|
|
205
206
|
* `<video>` child of the player.
|
|
206
207
|
*/
|
|
207
208
|
get media(): HTMLVideoElement;
|
|
209
|
+
/**
|
|
210
|
+
* The programme's chapters, in order: the engine's when its session holds
|
|
211
|
+
* some, else the video's chapters track. Read again on each access.
|
|
212
|
+
*/
|
|
213
|
+
get chapters(): readonly Chapter[];
|
|
208
214
|
/** The ranges the page named in this source: credits to skip, parts that must not play. */
|
|
209
215
|
get markers(): Markers;
|
|
210
216
|
/** Where the programme's ad breaks are, which the seek bar draws: each add-on gives its own. */
|
|
@@ -273,6 +279,12 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
|
|
|
273
279
|
private queued;
|
|
274
280
|
/** The other versions of the picture the source names at their own URLs, for the video menu. */
|
|
275
281
|
get videoSources(): readonly SourceVideoTrack[];
|
|
282
|
+
/**
|
|
283
|
+
* How the playing picture maps onto a sphere, for 360° video: the
|
|
284
|
+
* source's `projection`, else the manifest's, else null for a flat one.
|
|
285
|
+
* A version of `videoSources` is flat.
|
|
286
|
+
*/
|
|
287
|
+
get projection(): Projection | null;
|
|
276
288
|
/** The version of `videoSources` that plays, or null for the source itself. */
|
|
277
289
|
get videoSource(): SourceVideoTrack | null;
|
|
278
290
|
/**
|
|
@@ -398,7 +410,7 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
|
|
|
398
410
|
*/
|
|
399
411
|
private mode;
|
|
400
412
|
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
401
|
-
private
|
|
413
|
+
private chaptersAttribute;
|
|
402
414
|
private forward;
|
|
403
415
|
private enqueue;
|
|
404
416
|
/**
|
|
@@ -419,6 +431,11 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
|
|
|
419
431
|
/** Sets a session up. It runs for every session, the one that replaces a failed source included. */
|
|
420
432
|
private adopt;
|
|
421
433
|
private ensure;
|
|
434
|
+
/**
|
|
435
|
+
* An add-on or an element inside the player needs the engine, so Safari's
|
|
436
|
+
* own HLS is not the default. Read at each load: an element may come later.
|
|
437
|
+
*/
|
|
438
|
+
private needsEngine;
|
|
422
439
|
/**
|
|
423
440
|
* Read at each use, not once in the constructor. Importing the package
|
|
424
441
|
* registers the element, and the parser's elements are constructed then,
|
package/dist/element.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc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MAAM;IAwCd,oGAAoG;IACpG,OAAO,CAAC,KAAK;YAiBC,MAAM;IAgDpB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;OAIG;IACH,OAAO,KAAK,OAAO,GAElB;YAEa,KAAK;IA4CnB;;;;OAIG;IACH,OAAO,CAAC,GAAG;IAeX,8EAA8E;IAC9E,OAAO,CAAC,SAAS;IA6BjB,OAAO,CAAC,OAAO;YAID,QAAQ;IAKtB,mFAAmF;YACrE,OAAO;CAMtB"}
|
package/dist/element.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { announcer } from "./announcer.js";
|
|
2
2
|
import { createBreakMarks } from "./controls/breaks.js";
|
|
3
|
+
import { chapters } from "./controls/chapters.js";
|
|
3
4
|
import { createMarkers } from "./controls/markers.js";
|
|
4
5
|
import { live } from "./controls/session.js";
|
|
5
6
|
import { languageName } from "./controls/track-names.js";
|
|
@@ -43,11 +44,12 @@ function emeAvailable() {
|
|
|
43
44
|
return drmGuard().without === void 0;
|
|
44
45
|
}
|
|
45
46
|
/** `source` without its DRM, for a browser without EME. */
|
|
46
|
-
function withoutDrm({ url, type, videoTracks }) {
|
|
47
|
+
function withoutDrm({ url, type, videoTracks, projection }) {
|
|
47
48
|
return {
|
|
48
49
|
url,
|
|
49
50
|
...type === void 0 ? {} : { type },
|
|
50
|
-
...videoTracks === void 0 ? {} : { videoTracks }
|
|
51
|
+
...videoTracks === void 0 ? {} : { videoTracks },
|
|
52
|
+
...projection === void 0 ? {} : { projection }
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
const CERTIFICATE_URL = "certificate-url";
|
|
@@ -276,6 +278,13 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
276
278
|
get media() {
|
|
277
279
|
return this.playback.media;
|
|
278
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* The programme's chapters, in order: the engine's when its session holds
|
|
283
|
+
* some, else the video's chapters track. Read again on each access.
|
|
284
|
+
*/
|
|
285
|
+
get chapters() {
|
|
286
|
+
return chapters(this.node, this.engine);
|
|
287
|
+
}
|
|
279
288
|
/** The ranges the page named in this source: credits to skip, parts that must not play. */
|
|
280
289
|
get markers() {
|
|
281
290
|
return this.marks;
|
|
@@ -452,6 +461,19 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
452
461
|
get videoSources() {
|
|
453
462
|
return this.original?.videoTracks ?? [];
|
|
454
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* How the playing picture maps onto a sphere, for 360° video: the
|
|
466
|
+
* source's `projection`, else the manifest's, else null for a flat one.
|
|
467
|
+
* A version of `videoSources` is flat.
|
|
468
|
+
*/
|
|
469
|
+
get projection() {
|
|
470
|
+
if (this.version !== null) return null;
|
|
471
|
+
const given = this.original?.projection;
|
|
472
|
+
if (given !== void 0) return given;
|
|
473
|
+
const track = this.current?.engine?.tracks.active("video");
|
|
474
|
+
for (const rendition of track?.renditions ?? []) if (rendition.projection !== void 0) return rendition.projection;
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
455
477
|
/** The version of `videoSources` that plays, or null for the source itself. */
|
|
456
478
|
get videoSource() {
|
|
457
479
|
return this.version;
|
|
@@ -838,6 +860,9 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
838
860
|
this.toggleAttribute("ended", video.ended);
|
|
839
861
|
this.toggleAttribute("muted", video.muted);
|
|
840
862
|
this.toggleAttribute("audio", this.audio());
|
|
863
|
+
const projection = this.projection;
|
|
864
|
+
if (projection === null) this.removeAttribute("projection");
|
|
865
|
+
else this.setAttribute("projection", projection);
|
|
841
866
|
this.toggleAttribute("started", this.started);
|
|
842
867
|
this.toggleAttribute("waiting", this.waiting);
|
|
843
868
|
this.toggleAttribute("error", this.failure !== null);
|
|
@@ -883,7 +908,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
883
908
|
return;
|
|
884
909
|
}
|
|
885
910
|
if (name === CHAPTERS) {
|
|
886
|
-
this.
|
|
911
|
+
this.chaptersAttribute();
|
|
887
912
|
return;
|
|
888
913
|
}
|
|
889
914
|
if (name === LAYOUT) {
|
|
@@ -925,7 +950,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
925
950
|
}
|
|
926
951
|
}
|
|
927
952
|
/** Hands the `chapters` attribute to the engine, or keeps a hidden chapters track on the video for it. */
|
|
928
|
-
|
|
953
|
+
chaptersAttribute() {
|
|
929
954
|
const url = this.getAttribute(CHAPTERS);
|
|
930
955
|
const engine = this.current?.engine ?? null;
|
|
931
956
|
const api = engine === null ? void 0 : namespaces(engine).chapters;
|
|
@@ -994,6 +1019,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
994
1019
|
}
|
|
995
1020
|
async run() {
|
|
996
1021
|
this.unmount();
|
|
1022
|
+
if (!this.hasAttribute("poster")) this.node.removeAttribute("poster");
|
|
997
1023
|
if (!this.isConnected) return;
|
|
998
1024
|
const sources = this.wanted();
|
|
999
1025
|
this.tried = JSON.stringify(sources);
|
|
@@ -1053,7 +1079,7 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
1053
1079
|
this.configure(session);
|
|
1054
1080
|
const chapters = this.core?.programme?.metadata?.chapters;
|
|
1055
1081
|
if (chapters !== void 0 && session.engine !== null && this.getAttribute(CHAPTERS) === null) namespaces(session.engine).chapters?.set(chapters);
|
|
1056
|
-
this.
|
|
1082
|
+
this.chaptersAttribute();
|
|
1057
1083
|
}
|
|
1058
1084
|
async ensure() {
|
|
1059
1085
|
if (this.core !== null) return this.core;
|
|
@@ -1088,6 +1114,15 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
1088
1114
|
return core;
|
|
1089
1115
|
}
|
|
1090
1116
|
/**
|
|
1117
|
+
* An add-on or an element inside the player needs the engine, so Safari's
|
|
1118
|
+
* own HLS is not the default. Read at each load: an element may come later.
|
|
1119
|
+
*/
|
|
1120
|
+
needsEngine() {
|
|
1121
|
+
if ((this.options.addons ?? []).some((addon) => addon.engine === true)) return true;
|
|
1122
|
+
for (const element of this.querySelectorAll("*")) if (element.needsEngine === true) return true;
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1091
1126
|
* Read at each use, not once in the constructor. Importing the package
|
|
1092
1127
|
* registers the element, and the parser's elements are constructed then,
|
|
1093
1128
|
* before the page's own `define()` call can run.
|
|
@@ -1099,7 +1134,12 @@ var MatteboxPlayerElement = class MatteboxPlayerElement extends HTMLElement {
|
|
|
1099
1134
|
if (this.options.handlers !== void 0) return this.options.handlers;
|
|
1100
1135
|
const config = this.options.config === void 0 ? {} : { config: this.options.config };
|
|
1101
1136
|
const native = (stages) => nativeHandler({
|
|
1102
|
-
prefer: (source, env) =>
|
|
1137
|
+
prefer: (source, env) => {
|
|
1138
|
+
const asked = this.getAttribute(NATIVE_HLS);
|
|
1139
|
+
if (asked === "off") return false;
|
|
1140
|
+
if (asked !== "on" && this.needsEngine()) return false;
|
|
1141
|
+
return preferNativeHls(source, env);
|
|
1142
|
+
},
|
|
1103
1143
|
drm: () => this.drm(stages)
|
|
1104
1144
|
});
|
|
1105
1145
|
if (this.isConnected) this.attachAddons();
|