@mattebox/player 0.7.0 → 0.9.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 (138) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/icons.d.ts +5 -28
  3. package/dist/controls/icons.d.ts.map +1 -1
  4. package/dist/controls/icons.js +38 -29
  5. package/dist/controls/icons.js.map +1 -1
  6. package/dist/controls/markers.d.ts +39 -0
  7. package/dist/controls/markers.d.ts.map +1 -0
  8. package/dist/controls/markers.js +38 -0
  9. package/dist/controls/markers.js.map +1 -0
  10. package/dist/controls/menu.d.ts +14 -2
  11. package/dist/controls/menu.d.ts.map +1 -1
  12. package/dist/controls/menu.js +50 -4
  13. package/dist/controls/menu.js.map +1 -1
  14. package/dist/controls/native-tracks.d.ts +28 -0
  15. package/dist/controls/native-tracks.d.ts.map +1 -0
  16. package/dist/controls/native-tracks.js +30 -0
  17. package/dist/controls/native-tracks.js.map +1 -0
  18. package/dist/controls/quality-names.d.ts +15 -0
  19. package/dist/controls/quality-names.d.ts.map +1 -0
  20. package/dist/controls/quality-names.js +62 -0
  21. package/dist/controls/quality-names.js.map +1 -0
  22. package/dist/controls/track-names.d.ts +40 -0
  23. package/dist/controls/track-names.d.ts.map +1 -0
  24. package/dist/controls/track-names.js +59 -0
  25. package/dist/controls/track-names.js.map +1 -0
  26. package/dist/element.d.ts +60 -2
  27. package/dist/element.d.ts.map +1 -1
  28. package/dist/element.js +182 -23
  29. package/dist/element.js.map +1 -1
  30. package/dist/elements/audio-menu.d.ts +19 -8
  31. package/dist/elements/audio-menu.d.ts.map +1 -1
  32. package/dist/elements/audio-menu.js +60 -19
  33. package/dist/elements/audio-menu.js.map +1 -1
  34. package/dist/elements/component.d.ts.map +1 -1
  35. package/dist/elements/component.js +10 -0
  36. package/dist/elements/component.js.map +1 -1
  37. package/dist/elements/control-bar.d.ts +2 -0
  38. package/dist/elements/control-bar.d.ts.map +1 -1
  39. package/dist/elements/control-bar.js +23 -7
  40. package/dist/elements/control-bar.js.map +1 -1
  41. package/dist/elements/current-time.d.ts.map +1 -1
  42. package/dist/elements/current-time.js +1 -1
  43. package/dist/elements/current-time.js.map +1 -1
  44. package/dist/elements/drm-badge.d.ts +3 -2
  45. package/dist/elements/drm-badge.d.ts.map +1 -1
  46. package/dist/elements/drm-badge.js +11 -9
  47. package/dist/elements/drm-badge.js.map +1 -1
  48. package/dist/elements/duration.d.ts.map +1 -1
  49. package/dist/elements/duration.js +6 -2
  50. package/dist/elements/duration.js.map +1 -1
  51. package/dist/elements/error-screen.js +1 -1
  52. package/dist/elements/live-button.js +1 -1
  53. package/dist/elements/marker-button.d.ts +22 -0
  54. package/dist/elements/marker-button.d.ts.map +1 -0
  55. package/dist/elements/marker-button.js +95 -0
  56. package/dist/elements/marker-button.js.map +1 -0
  57. package/dist/elements/quality-menu.d.ts +4 -0
  58. package/dist/elements/quality-menu.d.ts.map +1 -1
  59. package/dist/elements/quality-menu.js +22 -8
  60. package/dist/elements/quality-menu.js.map +1 -1
  61. package/dist/elements/scan-button.js +1 -1
  62. package/dist/elements/seek-bar.d.ts +6 -1
  63. package/dist/elements/seek-bar.d.ts.map +1 -1
  64. package/dist/elements/seek-bar.js +37 -25
  65. package/dist/elements/seek-bar.js.map +1 -1
  66. package/dist/elements/shared.js +3 -3
  67. package/dist/elements/skip-button.js +2 -2
  68. package/dist/elements/skip-button.js.map +1 -1
  69. package/dist/elements/spinner.js +1 -1
  70. package/dist/elements/start-button.d.ts +5 -0
  71. package/dist/elements/start-button.d.ts.map +1 -1
  72. package/dist/elements/start-button.js +15 -2
  73. package/dist/elements/start-button.js.map +1 -1
  74. package/dist/elements/subtitles-menu.d.ts +7 -1
  75. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  76. package/dist/elements/subtitles-menu.js +62 -20
  77. package/dist/elements/subtitles-menu.js.map +1 -1
  78. package/dist/elements/title.d.ts.map +1 -1
  79. package/dist/elements/title.js +3 -1
  80. package/dist/elements/title.js.map +1 -1
  81. package/dist/elements/volume-slider.js +1 -1
  82. package/dist/elements/volume.js +1 -1
  83. package/dist/entries/marker-button.d.ts +5 -0
  84. package/dist/entries/marker-button.d.ts.map +1 -0
  85. package/dist/entries/marker-button.js +9 -0
  86. package/dist/entries/marker-button.js.map +1 -0
  87. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/asyncToGenerator.js +1 -1
  88. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/defineProperty.js +1 -1
  89. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/objectSpread2.js +1 -1
  90. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPrimitive.js +1 -1
  91. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/toPropertyKey.js +1 -1
  92. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.150.0 → _@oxc-project_runtime@0.152.0}/helpers/esm/typeof.js +1 -1
  93. package/dist/es2015/controls/chapters.js +1 -1
  94. package/dist/es2015/controls/icons.js +38 -29
  95. package/dist/es2015/controls/markers.js +36 -0
  96. package/dist/es2015/controls/menu.js +52 -5
  97. package/dist/es2015/controls/native-tracks.js +29 -0
  98. package/dist/es2015/controls/quality-names.js +67 -0
  99. package/dist/es2015/controls/track-names.js +57 -0
  100. package/dist/es2015/element.js +185 -29
  101. package/dist/es2015/elements/audio-menu.js +66 -20
  102. package/dist/es2015/elements/component.js +10 -0
  103. package/dist/es2015/elements/control-bar.js +23 -7
  104. package/dist/es2015/elements/current-time.js +1 -1
  105. package/dist/es2015/elements/drm-badge.js +12 -9
  106. package/dist/es2015/elements/duration.js +6 -2
  107. package/dist/es2015/elements/error-screen.js +1 -1
  108. package/dist/es2015/elements/live-button.js +1 -1
  109. package/dist/es2015/elements/marker-button.js +96 -0
  110. package/dist/es2015/elements/quality-menu.js +23 -8
  111. package/dist/es2015/elements/scan-button.js +1 -1
  112. package/dist/es2015/elements/seek-bar.js +42 -29
  113. package/dist/es2015/elements/shared.js +3 -3
  114. package/dist/es2015/elements/skip-button.js +2 -2
  115. package/dist/es2015/elements/spinner.js +1 -1
  116. package/dist/es2015/elements/start-button.js +15 -2
  117. package/dist/es2015/elements/subtitles-menu.js +72 -26
  118. package/dist/es2015/elements/title.js +3 -1
  119. package/dist/es2015/elements/volume-slider.js +1 -1
  120. package/dist/es2015/elements/volume.js +1 -1
  121. package/dist/es2015/entries/marker-button.js +7 -0
  122. package/dist/es2015/index.js +3 -1
  123. package/dist/es2015/presets.js +1 -1
  124. package/dist/es2015/style.js +1 -1
  125. package/dist/es2015/tags.js +2 -1
  126. package/dist/host.d.ts +3 -0
  127. package/dist/host.d.ts.map +1 -1
  128. package/dist/host.js.map +1 -1
  129. package/dist/index.d.ts +4 -0
  130. package/dist/index.d.ts.map +1 -1
  131. package/dist/index.js +3 -1
  132. package/dist/style.js +1 -1
  133. package/dist/tags.d.ts +1 -0
  134. package/dist/tags.d.ts.map +1 -1
  135. package/dist/tags.js +2 -1
  136. package/dist/tags.js.map +1 -1
  137. package/package.json +4 -5
  138. package/NOTICE +0 -24
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","names":[],"sources":["../../src/controls/menu.ts"],"sourcesContent":["/**\n * The menu primitive the quality, audio, subtitles and speed menus share: a\n * button that opens a popup of radio items above it, in one or more groups\n * with a heading each, and pages behind entries that open them. The button\n * carries the name and `aria-expanded`; the popup is `role=\"menu\"`, every\n * choice a `menuitemradio` with `aria-checked`, the checked one also\n * carrying `checked` on its part name, because an item inside a shadow\n * root has no other seam a page can style; an entry that opens a page is\n * a `menuitem` with `aria-haspopup`, and the page starts with a Back.\n *\n * Open on click. Inside, the arrows move focus across every item, Home and\n * End jump, Enter and Space choose, Escape goes back a page or closes and\n * hands focus to the button. A choice closes the popup. A pointer down\n * anywhere else closes it too.\n *\n * The popup never leaves the picture: on opening it takes the room above\n * the button up to the top of `picture()` as its height and scrolls past\n * that, and the room from its right edge to the picture's left as its\n * width, where a long item ends in an ellipsis. The\n * element that owns the menu carries `open` while the popup shows, which\n * the bar reads to hold its fade.\n */\nimport { el, setChildren, state } from '../dom.js';\n\nexport interface MenuGroup {\n /** The part suffix: `track`, `size`. */\n readonly name: string;\n /** A heading, or none for a menu of one group. */\n readonly label?: string;\n /**\n * Each item's id, its text, a detail drawn at its end, such as a chapter's\n * time, and the URL of a picture drawn at its start.\n */\n readonly items: ReadonlyArray<readonly [string, string, string?, string?]>;\n readonly value: string;\n readonly onSelect: (value: string) => void;\n}\n\n/** An entry that opens a page of groups, with a Back at its top. */\nexport interface MenuPage {\n readonly name: string;\n readonly label: string;\n readonly entries: readonly MenuEntry[];\n}\n\nexport type MenuEntry = MenuGroup | MenuPage;\n\nexport interface MenuOptions {\n /** The element the menu belongs to: it carries `open`, and a pointer inside it is not outside. */\n readonly host: HTMLElement;\n /** The picture, in viewport pixels, which the popup never leaves. */\n readonly picture: () => DOMRect | null;\n /** The name of the Back item, from the page it leaves: \"Back from {page}\". */\n readonly back: (page: string) => string;\n}\n\nexport interface Menu {\n readonly button: HTMLButtonElement;\n readonly popup: HTMLElement;\n /** The accessible name of the button and the popup. */\n label(text: string): void;\n /** Replaces the entries, back at the first page. */\n fill(entries: readonly MenuEntry[]): void;\n close(): void;\n dispose(): void;\n}\n\n/** Air between the popup's top and the picture's. */\nconst AIR = 8;\n\n/** An item's picture. Decorative: the item's text names it. Loaded when the popup first shows it. */\nfunction picture(url: string): HTMLImageElement {\n const node = el('img', 'item-image');\n node.alt = '';\n node.loading = 'lazy';\n node.decoding = 'async';\n node.src = url;\n return node;\n}\n\nfunction isPage(entry: MenuEntry): entry is MenuPage {\n return 'entries' in entry;\n}\n\nexport function menu(options: MenuOptions): Menu {\n const { host } = options;\n const button = el('button', 'button');\n button.type = 'button';\n button.setAttribute('aria-haspopup', 'menu');\n button.setAttribute('aria-expanded', 'false');\n const popup = el('div', 'popup');\n popup.setAttribute('role', 'menu');\n popup.hidden = true;\n\n let open = false;\n let name = '';\n let first: readonly MenuEntry[] = [];\n /** The pages opened, the first being the menu itself. */\n let stack: MenuPage[] = [];\n const handlers = new WeakMap<HTMLButtonElement, () => void>();\n\n function items(): HTMLButtonElement[] {\n return [...popup.querySelectorAll('button')];\n }\n\n function checked(): HTMLButtonElement | undefined {\n return items().find((item) => item.getAttribute('aria-checked') === 'true');\n }\n\n /** The focused element as this tree sees it: inside shadow DOM, `document.activeElement` is the host. */\n function focused(): Element | null {\n return (popup.getRootNode() as Document | ShadowRoot).activeElement;\n }\n\n function outside(event: PointerEvent): void {\n if (!event.composedPath().includes(host)) close();\n }\n\n /** Whatever room there is above the button and left of the popup's right edge, so the popup never leaves the picture. */\n function fit(): void {\n const picture = options.picture();\n if (picture === null) return;\n const room = button.getBoundingClientRect().top - picture.top - AIR;\n popup.style.maxHeight = `${Math.max(0, Math.floor(room))}px`;\n // The popup is anchored at the host's right edge and grows leftwards.\n const wide = host.getBoundingClientRect().right - picture.left - AIR;\n popup.style.maxWidth = `${Math.max(0, Math.floor(wide))}px`;\n }\n\n function clear(): void {\n for (const item of items()) {\n const handler = handlers.get(item);\n if (handler !== undefined) item.removeEventListener('click', handler);\n }\n setChildren(popup);\n }\n\n function item(part: string, text: string, handler: () => void): HTMLButtonElement {\n const node = el('button', part, text);\n node.type = 'button';\n node.tabIndex = -1;\n handlers.set(node, handler);\n node.addEventListener('click', handler);\n return node;\n }\n\n /** Draws the page on top of the stack. */\n function render(): void {\n clear();\n const page = stack[stack.length - 1];\n if (page === undefined) return;\n let tab = true;\n if (stack.length > 1) {\n const back = item('item back-item', page.label, () => {\n stack.pop();\n render();\n items()[0]?.focus();\n });\n back.setAttribute('role', 'menuitem');\n back.setAttribute('aria-label', options.back(page.label));\n popup.append(back);\n }\n for (const entry of page.entries) {\n if (isPage(entry)) {\n const link = item(`item page-item ${entry.name}-item`, entry.label, () => {\n stack.push(entry);\n render();\n items()[0]?.focus();\n });\n link.setAttribute('role', 'menuitem');\n link.setAttribute('aria-haspopup', 'menu');\n popup.append(link);\n continue;\n }\n const section = el('div', `section ${entry.name}-section`);\n section.setAttribute('role', 'group');\n if (entry.label !== undefined) {\n section.setAttribute('aria-label', entry.label);\n section.append(el('div', `section-label ${entry.name}-label`, entry.label));\n }\n for (const [id, text, detail, image] of entry.items) {\n const choice = item(`item ${entry.name}-item`, text, () => {\n close();\n button.focus();\n entry.onSelect(id);\n });\n if (detail !== undefined) choice.append(el('span', 'item-detail', detail));\n if (image !== undefined) {\n // The text in a box of its own, so a long title ends in an ellipsis beside the picture.\n const [, ...rest] = choice.childNodes;\n setChildren(choice, el('span', 'item-text', text), ...rest);\n choice.prepend(picture(image));\n }\n choice.value = id;\n choice.setAttribute('role', 'menuitemradio');\n const on = id === entry.value;\n choice.setAttribute('aria-checked', String(on));\n state(choice, `item ${entry.name}-item`, { checked: on });\n // One tab stop: the first checked item.\n if (on && tab) {\n choice.tabIndex = 0;\n tab = false;\n }\n section.append(choice);\n }\n popup.append(section);\n }\n fit();\n }\n\n function close(): void {\n if (!open) return;\n open = false;\n popup.hidden = true;\n button.setAttribute('aria-expanded', 'false');\n host.removeAttribute('open');\n document.removeEventListener('pointerdown', outside, true);\n if (stack.length > 1) {\n stack = stack.slice(0, 1);\n render();\n }\n }\n\n function show(): void {\n if (open) return;\n open = true;\n popup.hidden = false;\n button.setAttribute('aria-expanded', 'true');\n host.setAttribute('open', '');\n document.addEventListener('pointerdown', outside, true);\n fit();\n (checked() ?? items()[0])?.focus();\n }\n\n function toggle(): void {\n if (open) close();\n else show();\n }\n\n function key(event: KeyboardEvent): void {\n // Handled already, by a handler that decides first.\n if (event.defaultPrevented) return;\n const list = items();\n const index = list.indexOf(focused() as HTMLButtonElement);\n let next: number;\n switch (event.key) {\n case 'ArrowDown':\n next = (index + 1) % list.length;\n break;\n case 'ArrowUp':\n next = (index - 1 + list.length) % list.length;\n break;\n case 'Home':\n next = 0;\n break;\n case 'End':\n next = list.length - 1;\n break;\n case 'Escape':\n event.preventDefault();\n if (stack.length > 1) {\n stack.pop();\n render();\n items()[0]?.focus();\n return;\n }\n close();\n button.focus();\n return;\n default:\n return;\n }\n event.preventDefault();\n list[next]?.focus();\n }\n\n button.addEventListener('click', toggle);\n popup.addEventListener('keydown', key);\n\n return {\n button,\n popup,\n label(text: string): void {\n name = text;\n button.setAttribute('aria-label', text);\n popup.setAttribute('aria-label', text);\n const root = stack[0];\n if (root !== undefined) stack[0] = { ...root, label: text };\n },\n fill(entries): void {\n first = entries;\n stack = [{ name: 'menu', label: name, entries: first }];\n render();\n },\n close,\n dispose(): void {\n close();\n clear();\n button.removeEventListener('click', toggle);\n popup.removeEventListener('keydown', key);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAM,MAAM;;AAGZ,SAAS,QAAQ,KAA+B;CAC9C,MAAM,OAAO,GAAG,OAAO,YAAY;CACnC,KAAK,MAAM;CACX,KAAK,UAAU;CACf,KAAK,WAAW;CAChB,KAAK,MAAM;CACX,OAAO;AACT;AAEA,SAAS,OAAO,OAAqC;CACnD,OAAO,aAAa;AACtB;AAEA,SAAgB,KAAK,SAA4B;CAC/C,MAAM,EAAE,SAAS;CACjB,MAAM,SAAS,GAAG,UAAU,QAAQ;CACpC,OAAO,OAAO;CACd,OAAO,aAAa,iBAAiB,MAAM;CAC3C,OAAO,aAAa,iBAAiB,OAAO;CAC5C,MAAM,QAAQ,GAAG,OAAO,OAAO;CAC/B,MAAM,aAAa,QAAQ,MAAM;CACjC,MAAM,SAAS;CAEf,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,QAA8B,CAAC;;CAEnC,IAAI,QAAoB,CAAC;CACzB,MAAM,2BAAW,IAAI,QAAuC;CAE5D,SAAS,QAA6B;EACpC,OAAO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AI,MAAM,SAAS,GAAG;KACpB,MAAM,IAAI;KACV,OAAO;KACP,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM;KAClB;IACF;IACA,MAAM;IACN,OAAO,MAAM;IACb;GACF,SACE;EACJ;EACA,MAAM,eAAe;EACrB,KAAK,KAAK,EAAE,MAAM;CACpB;CAEA,OAAO,iBAAiB,SAAS,MAAM;CACvC,MAAM,iBAAiB,WAAW,GAAG;CAErC,OAAO;EACL;EACA;EACA,MAAM,MAAoB;GACxB,OAAO;GACP,OAAO,aAAa,cAAc,IAAI;GACtC,MAAM,aAAa,cAAc,IAAI;GACrC,MAAM,OAAO,MAAM;GACnB,IAAI,SAAS,KAAA,GAAW,MAAM,KAAK;IAAE,GAAG;IAAM,OAAO;GAAK;EAC5D;EACA,KAAK,SAAe;GAClB,QAAQ;GACR,QAAQ,CAAC;IAAE,MAAM;IAAQ,OAAO;IAAM,SAAS;GAAM,CAAC;GACtD,OAAO;EACT;EACA;EACA,UAAgB;GACd,MAAM;GACN,MAAM;GACN,OAAO,oBAAoB,SAAS,MAAM;GAC1C,MAAM,oBAAoB,WAAW,GAAG;EAC1C;CACF;AACF"}
1
+ {"version":3,"file":"menu.js","names":[],"sources":["../../src/controls/menu.ts"],"sourcesContent":["/**\n * The menu primitive the quality, audio, subtitles and speed menus share: a\n * button that opens a popup of radio items above it, in one or more groups\n * with a heading each, and pages behind entries that open them. The button\n * carries the name and `aria-expanded`; the popup is `role=\"menu\"`, every\n * choice a `menuitemradio` with `aria-checked`, the checked one also\n * carrying `checked` on its part name, because an item inside a shadow\n * root has no other seam a page can style; an entry that opens a page is\n * a `menuitem` with `aria-haspopup`, and the page starts with a Back.\n *\n * Open on click. Inside, the arrows move focus across every item, Home and\n * End jump, Enter and Space choose, Escape goes back a page or closes and\n * hands focus to the button. A choice closes the popup. A pointer down\n * anywhere else closes it too.\n *\n * The popup never leaves the picture: on opening it takes the room above\n * the button up to the top of `picture()` as its height and scrolls past\n * that, and the room from its right edge to the picture's left as its\n * width, where a long item ends in an ellipsis. The\n * element that owns the menu carries `open` while the popup shows, which\n * the bar reads to hold its fade.\n */\nimport { el, setChildren, state } from '../dom.js';\n\nexport interface MenuGroup {\n /** The part suffix: `track`, `size`. */\n readonly name: string;\n /** A heading, or none for a menu of one group. */\n readonly label?: string;\n /** The label names the group for a screen reader, and no heading is drawn. */\n readonly hideLabel?: boolean;\n /**\n * Each item's id, its text, a detail drawn at its end, such as a chapter's\n * time, the URL of a picture drawn at its start, and short badges drawn\n * after the text, such as \"AD\" on an audio description track.\n */\n readonly items: ReadonlyArray<\n readonly [string, string, (string | undefined)?, (string | undefined)?, (readonly string[])?]\n >;\n readonly value: string;\n readonly onSelect: (value: string) => void;\n /**\n * The badges drawn as a glyph, by their text. The text stays in the\n * badge for a screen reader and as its tooltip.\n */\n readonly badgeGlyphs?: Readonly<Record<string, () => SVGSVGElement>>;\n}\n\n/** An entry that opens a page of groups, with a Back at its top. */\nexport interface MenuPage {\n readonly name: string;\n readonly label: string;\n readonly entries: readonly MenuEntry[];\n /** A glyph drawn before the label of the item that opens the page. */\n readonly glyph?: () => SVGSVGElement;\n /** A detail drawn at the end of that item, such as the value chosen on the page. */\n readonly detail?: string;\n}\n\nexport type MenuEntry = MenuGroup | MenuPage;\n\nexport interface MenuOptions {\n /** The element the menu belongs to: it carries `open`, and a pointer inside it is not outside. */\n readonly host: HTMLElement;\n /** The picture, in viewport pixels, which the popup never leaves. */\n readonly picture: () => DOMRect | null;\n /** The name of the Back item, from the page it leaves: \"Back from {page}\". */\n readonly back: (page: string) => string;\n}\n\nexport interface Menu {\n readonly button: HTMLButtonElement;\n readonly popup: HTMLElement;\n /** The accessible name of the button and the popup. */\n label(text: string): void;\n /** Replaces the entries, back at the first page. */\n fill(entries: readonly MenuEntry[]): void;\n close(): void;\n dispose(): void;\n}\n\n/** Air between the popup's top and the picture's. */\nconst AIR = 8;\n\n/**\n * The tallest a popup grows, in pixels: the title and about seven and a half rows, so\n * the half row at the foot says the list goes on. A page sets its own\n * with `--mbx-menu-max-height`.\n */\n/* In em of the menu's own font size. */\nconst MAX_HEIGHT = 22;\n\n/** An item's picture. Decorative: the item's text names it. Loaded when the popup first shows it. */\nfunction picture(url: string): HTMLImageElement {\n const node = el('img', 'item-image');\n node.alt = '';\n node.loading = 'lazy';\n node.decoding = 'async';\n node.src = url;\n return node;\n}\n\nfunction isPage(entry: MenuEntry): entry is MenuPage {\n return 'entries' in entry;\n}\n\nexport function menu(options: MenuOptions): Menu {\n const { host } = options;\n const button = el('button', 'button');\n button.type = 'button';\n button.setAttribute('aria-haspopup', 'menu');\n button.setAttribute('aria-expanded', 'false');\n const popup = el('div', 'popup');\n popup.addEventListener('scroll', () => {\n more();\n });\n popup.setAttribute('role', 'menu');\n popup.hidden = true;\n\n let open = false;\n let name = '';\n let first: readonly MenuEntry[] = [];\n /** The pages opened, the first being the menu itself. */\n let stack: MenuPage[] = [];\n const handlers = new WeakMap<HTMLButtonElement, () => void>();\n\n function items(): HTMLButtonElement[] {\n return [...popup.querySelectorAll('button')];\n }\n\n function checked(): HTMLButtonElement | undefined {\n return items().find((item) => item.getAttribute('aria-checked') === 'true');\n }\n\n /** The focused element as this tree sees it: inside shadow DOM, `document.activeElement` is the host. */\n function focused(): Element | null {\n return (popup.getRootNode() as Document | ShadowRoot).activeElement;\n }\n\n function outside(event: PointerEvent): void {\n if (!event.composedPath().includes(host)) close();\n }\n\n /**\n * The popup's height: its maximum, or the room above the button if that\n * is less, so the popup never leaves the picture. Its width: the room\n * left of its right edge.\n */\n function fit(): void {\n // A compact player's menu is a sheet on the page: the stylesheet sizes it.\n if (host.getAttribute('layout') === 'compact') {\n popup.style.maxHeight = '';\n popup.style.maxWidth = '';\n more();\n return;\n }\n const picture = options.picture();\n if (picture === null) return;\n const room = button.getBoundingClientRect().top - picture.top - AIR;\n const most =\n Number.parseFloat(getComputedStyle(host).getPropertyValue('--mbx-menu-max-height')) ||\n MAX_HEIGHT * (Number.parseFloat(getComputedStyle(host).fontSize) || 16);\n popup.style.maxHeight = `${Math.max(0, Math.floor(Math.min(most, room)))}px`;\n more();\n // The popup is anchored at the host's right edge and grows leftwards.\n const wide = host.getBoundingClientRect().right - picture.left - AIR;\n popup.style.maxWidth = `${Math.max(0, Math.floor(wide))}px`;\n }\n\n /** `more` on the popup while rows wait below its foot, which then fades out. */\n function more(): void {\n popup.toggleAttribute('more', popup.scrollTop + popup.clientHeight < popup.scrollHeight - 1);\n }\n\n function clear(): void {\n for (const item of items()) {\n const handler = handlers.get(item);\n if (handler !== undefined) item.removeEventListener('click', handler);\n }\n setChildren(popup);\n }\n\n function item(part: string, text: string, handler: () => void): HTMLButtonElement {\n const node = el('button', part, text);\n node.type = 'button';\n node.tabIndex = -1;\n handlers.set(node, handler);\n node.addEventListener('click', handler);\n return node;\n }\n\n /** Draws the page on top of the stack. */\n function render(): void {\n clear();\n const page = stack[stack.length - 1];\n if (page === undefined) return;\n let tab = true;\n // The first page starts with the menu's name. The popup already carries it for a screen reader.\n if (stack.length === 1 && name !== '') {\n const title = el('div', 'title', name);\n title.setAttribute('aria-hidden', 'true');\n popup.append(title);\n }\n if (stack.length > 1) {\n const back = item('item back-item', page.label, () => {\n stack.pop();\n render();\n items()[0]?.focus();\n });\n back.setAttribute('role', 'menuitem');\n back.setAttribute('aria-label', options.back(page.label));\n popup.append(back);\n }\n for (const entry of page.entries) {\n if (isPage(entry)) {\n const link = item(`item page-item ${entry.name}-item`, entry.label, () => {\n stack.push(entry);\n render();\n items()[0]?.focus();\n });\n link.setAttribute('role', 'menuitem');\n link.setAttribute('aria-haspopup', 'menu');\n if (entry.glyph !== undefined) {\n link.prepend(entry.glyph());\n state(link, `item page-item ${entry.name}-item`, { 'glyph-item': true });\n }\n if (entry.detail !== undefined) link.append(el('span', 'item-detail', entry.detail));\n popup.append(link);\n continue;\n }\n const section = el('div', `section ${entry.name}-section`);\n section.setAttribute('role', 'group');\n if (entry.label !== undefined) {\n section.setAttribute('aria-label', entry.label);\n if (entry.hideLabel !== true) {\n section.append(el('div', `section-label ${entry.name}-label`, entry.label));\n }\n }\n for (const [id, text, detail, image, badges] of entry.items) {\n const choice = item(`item ${entry.name}-item`, text, () => {\n close();\n button.focus();\n entry.onSelect(id);\n });\n for (const badge of badges ?? []) {\n const glyph = entry.badgeGlyphs?.[badge];\n if (glyph === undefined) {\n choice.append(el('span', 'item-badge', badge));\n continue;\n }\n // The glyph is what a viewer sees, and the text is what a screen reader says.\n const drawn = el('span', 'item-badge item-glyph');\n drawn.title = badge;\n drawn.append(glyph(), el('span', 'badge-text', badge));\n choice.append(drawn);\n }\n if (detail !== undefined) choice.append(el('span', 'item-detail', detail));\n if (image !== undefined) {\n // The text in a box of its own, so a long title ends in an ellipsis beside the picture.\n const [, ...rest] = choice.childNodes;\n setChildren(choice, el('span', 'item-text', text), ...rest);\n choice.prepend(picture(image));\n }\n choice.value = id;\n choice.setAttribute('role', 'menuitemradio');\n const on = id === entry.value;\n choice.setAttribute('aria-checked', String(on));\n state(choice, `item ${entry.name}-item`, { checked: on });\n // One tab stop: the first checked item.\n if (on && tab) {\n choice.tabIndex = 0;\n tab = false;\n }\n section.append(choice);\n }\n popup.append(section);\n }\n fit();\n }\n\n function close(): void {\n if (!open) return;\n open = false;\n popup.hidden = true;\n button.setAttribute('aria-expanded', 'false');\n host.removeAttribute('open');\n document.removeEventListener('pointerdown', outside, true);\n if (stack.length > 1) {\n stack = stack.slice(0, 1);\n render();\n }\n }\n\n function show(): void {\n if (open) return;\n open = true;\n popup.hidden = false;\n button.setAttribute('aria-expanded', 'true');\n host.setAttribute('open', '');\n document.addEventListener('pointerdown', outside, true);\n fit();\n (checked() ?? items()[0])?.focus();\n }\n\n function toggle(): void {\n if (open) close();\n else show();\n }\n\n function key(event: KeyboardEvent): void {\n // Handled already, by a handler that decides first.\n if (event.defaultPrevented) return;\n const list = items();\n const index = list.indexOf(focused() as HTMLButtonElement);\n let next: number;\n switch (event.key) {\n case 'ArrowDown':\n next = (index + 1) % list.length;\n break;\n case 'ArrowUp':\n next = (index - 1 + list.length) % list.length;\n break;\n case 'Home':\n next = 0;\n break;\n case 'End':\n next = list.length - 1;\n break;\n case 'Escape':\n event.preventDefault();\n if (stack.length > 1) {\n stack.pop();\n render();\n items()[0]?.focus();\n return;\n }\n close();\n button.focus();\n return;\n default:\n return;\n }\n event.preventDefault();\n list[next]?.focus();\n }\n\n button.addEventListener('click', toggle);\n popup.addEventListener('keydown', key);\n\n return {\n button,\n popup,\n label(text: string): void {\n name = text;\n button.setAttribute('aria-label', text);\n popup.setAttribute('aria-label', text);\n const root = stack[0];\n if (root !== undefined) stack[0] = { ...root, label: text };\n },\n fill(entries): void {\n first = entries;\n stack = [{ name: 'menu', label: name, entries: first }];\n render();\n },\n close,\n dispose(): void {\n close();\n clear();\n button.removeEventListener('click', toggle);\n popup.removeEventListener('keydown', key);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,MAAM,MAAM;;;;;;AAQZ,MAAM,aAAa;;AAGnB,SAAS,QAAQ,KAA+B;CAC9C,MAAM,OAAO,GAAG,OAAO,YAAY;CACnC,KAAK,MAAM;CACX,KAAK,UAAU;CACf,KAAK,WAAW;CAChB,KAAK,MAAM;CACX,OAAO;AACT;AAEA,SAAS,OAAO,OAAqC;CACnD,OAAO,aAAa;AACtB;AAEA,SAAgB,KAAK,SAA4B;CAC/C,MAAM,EAAE,SAAS;CACjB,MAAM,SAAS,GAAG,UAAU,QAAQ;CACpC,OAAO,OAAO;CACd,OAAO,aAAa,iBAAiB,MAAM;CAC3C,OAAO,aAAa,iBAAiB,OAAO;CAC5C,MAAM,QAAQ,GAAG,OAAO,OAAO;CAC/B,MAAM,iBAAiB,gBAAgB;EACrC,KAAK;CACP,CAAC;CACD,MAAM,aAAa,QAAQ,MAAM;CACjC,MAAM,SAAS;CAEf,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,QAA8B,CAAC;;CAEnC,IAAI,QAAoB,CAAC;CACzB,MA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AAM,CAAC,CAAC,EAAE,EAAE,MAAM;KAClB;IACF;IACA,MAAM;IACN,OAAO,MAAM;IACb;GACF,SACE;EACJ;EACA,MAAM,eAAe;EACrB,KAAK,KAAK,EAAE,MAAM;CACpB;CAEA,OAAO,iBAAiB,SAAS,MAAM;CACvC,MAAM,iBAAiB,WAAW,GAAG;CAErC,OAAO;EACL;EACA;EACA,MAAM,MAAoB;GACxB,OAAO;GACP,OAAO,aAAa,cAAc,IAAI;GACtC,MAAM,aAAa,cAAc,IAAI;GACrC,MAAM,OAAO,MAAM;GACnB,IAAI,SAAS,KAAA,GAAW,MAAM,KAAK;IAAE,GAAG;IAAM,OAAO;GAAK;EAC5D;EACA,KAAK,SAAe;GAClB,QAAQ;GACR,QAAQ,CAAC;IAAE,MAAM;IAAQ,OAAO;IAAM,SAAS;GAAM,CAAC;GACtD,OAAO;EACT;EACA;EACA,UAAgB;GACd,MAAM;GACN,MAAM;GACN,OAAO,oBAAoB,SAAS,MAAM;GAC1C,MAAM,oBAAoB,WAAW,GAAG;EAC1C;CACF;AACF"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The element's own track lists, for the audio and subtitles menus of a
3
+ * native session. Safari lists the renditions of an HLS stream it plays
4
+ * itself in `audioTracks` and `textTracks`. No engine-shaped object goes
5
+ * over them: the menus read the lists and write `enabled` and `mode`.
6
+ * Each list is feature-tested, so a browser without it keeps the menu hidden.
7
+ */
8
+ import type { PlayerHost } from '../host.js';
9
+ /** What the menus read of an `AudioTrack` or a `TextTrack`. */
10
+ export interface NativeTrack {
11
+ readonly kind: string;
12
+ readonly label: string;
13
+ readonly language: string;
14
+ }
15
+ /** An `AudioTrackList` or a `TextTrackList`. lib.dom has no `AudioTrackList`. */
16
+ export interface NativeTrackList<T extends NativeTrack> extends EventTarget {
17
+ readonly length: number;
18
+ readonly [index: number]: T;
19
+ }
20
+ /**
21
+ * The video's `audioTracks` or `textTracks` during a native session, or
22
+ * undefined: an engine session has its own tracks, and Chromium has no
23
+ * `audioTracks` without a flag.
24
+ */
25
+ export declare function nativeTracks<T extends NativeTrack>(player: PlayerHost, name: 'audioTracks' | 'textTracks'): T[] | undefined;
26
+ /** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */
27
+ export declare function onNativeTracks(video: HTMLVideoElement, name: 'audioTracks' | 'textTracks', tick: () => void): (() => void) | undefined;
28
+ //# sourceMappingURL=native-tracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-tracks.d.ts","sourceRoot":"","sources":["../../src/controls/native-tracks.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,iFAAiF;AACjF,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,WAAW,CAAE,SAAQ,WAAW;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,WAAW,EAChD,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,aAAa,GAAG,YAAY,GACjC,CAAC,EAAE,GAAG,SAAS,CAKjB;AAED,yFAAyF;AACzF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,aAAa,GAAG,YAAY,EAClC,IAAI,EAAE,MAAM,IAAI,GACf,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAQ1B"}
@@ -0,0 +1,30 @@
1
+ //#region src/controls/native-tracks.ts
2
+ /**
3
+ * The video's `audioTracks` or `textTracks` during a native session, or
4
+ * undefined: an engine session has its own tracks, and Chromium has no
5
+ * `audioTracks` without a flag.
6
+ */
7
+ function nativeTracks(player, name) {
8
+ const session = player.player?.session;
9
+ if (session == null || session.engine !== null) return void 0;
10
+ const list = player.video[name];
11
+ return list === void 0 ? void 0 : Array.from(list);
12
+ }
13
+ /** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */
14
+ function onNativeTracks(video, name, tick) {
15
+ const list = video[name];
16
+ if (list === void 0) return void 0;
17
+ const events = [
18
+ "change",
19
+ "addtrack",
20
+ "removetrack"
21
+ ];
22
+ for (const event of events) list.addEventListener(event, tick);
23
+ return () => {
24
+ for (const event of events) list.removeEventListener(event, tick);
25
+ };
26
+ }
27
+ //#endregion
28
+ export { nativeTracks, onNativeTracks };
29
+
30
+ //# sourceMappingURL=native-tracks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-tracks.js","names":[],"sources":["../../src/controls/native-tracks.ts"],"sourcesContent":["/**\n * The element's own track lists, for the audio and subtitles menus of a\n * native session. Safari lists the renditions of an HLS stream it plays\n * itself in `audioTracks` and `textTracks`. No engine-shaped object goes\n * over them: the menus read the lists and write `enabled` and `mode`.\n * Each list is feature-tested, so a browser without it keeps the menu hidden.\n */\nimport type { PlayerHost } from '../host.js';\n\n/** What the menus read of an `AudioTrack` or a `TextTrack`. */\nexport interface NativeTrack {\n readonly kind: string;\n readonly label: string;\n readonly language: string;\n}\n\n/** An `AudioTrackList` or a `TextTrackList`. lib.dom has no `AudioTrackList`. */\nexport interface NativeTrackList<T extends NativeTrack> extends EventTarget {\n readonly length: number;\n readonly [index: number]: T;\n}\n\n/**\n * The video's `audioTracks` or `textTracks` during a native session, or\n * undefined: an engine session has its own tracks, and Chromium has no\n * `audioTracks` without a flag.\n */\nexport function nativeTracks<T extends NativeTrack>(\n player: PlayerHost,\n name: 'audioTracks' | 'textTracks',\n): T[] | undefined {\n const session = player.player?.session;\n if (session == null || session.engine !== null) return undefined;\n const list = (player.video as unknown as Record<string, NativeTrackList<T> | undefined>)[name];\n return list === undefined ? undefined : Array.from(list);\n}\n\n/** Calls `tick` when the video's list of `name` changes, and answers the unsubscribe. */\nexport function onNativeTracks(\n video: HTMLVideoElement,\n name: 'audioTracks' | 'textTracks',\n tick: () => void,\n): (() => void) | undefined {\n const list = (video as unknown as Record<string, EventTarget | undefined>)[name];\n if (list === undefined) return undefined;\n const events = ['change', 'addtrack', 'removetrack'];\n for (const event of events) list.addEventListener(event, tick);\n return () => {\n for (const event of events) list.removeEventListener(event, tick);\n };\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,aACd,QACA,MACiB;CACjB,MAAM,UAAU,OAAO,QAAQ;CAC/B,IAAI,WAAW,QAAQ,QAAQ,WAAW,MAAM,OAAO,KAAA;CACvD,MAAM,OAAQ,OAAO,MAAoE;CACzF,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,IAAI;AACzD;;AAGA,SAAgB,eACd,OACA,MACA,MAC0B;CAC1B,MAAM,OAAQ,MAA6D;CAC3E,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,MAAM,SAAS;EAAC;EAAU;EAAY;CAAa;CACnD,KAAK,MAAM,SAAS,QAAQ,KAAK,iBAAiB,OAAO,IAAI;CAC7D,aAAa;EACX,KAAK,MAAM,SAAS,QAAQ,KAAK,oBAAoB,OAAO,IAAI;CAClE;AACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The words the quality menu shows for each rendition, best first. Pure,
3
+ * node-tested.
4
+ *
5
+ * A label grows only as far as it must to tell entries apart: the height,
6
+ * the frame rate above 30, Dolby Vision or HDR, then the bitrate where two
7
+ * entries read the same, then the codec where they still do. Entries that
8
+ * read the same after that are one choice for a viewer, and show once.
9
+ */
10
+ import type { Rendition } from 'mattebox';
11
+ /** The label of every rendition, best first, twins included. */
12
+ export declare function qualityLabels(renditions: readonly Rendition[]): Array<readonly [id: string, label: string]>;
13
+ /** The label of each rendition, best first, one entry per distinct label. */
14
+ export declare function qualityNames(renditions: readonly Rendition[]): Array<readonly [id: string, label: string]>;
15
+ //# sourceMappingURL=quality-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quality-names.d.ts","sourceRoot":"","sources":["../../src/controls/quality-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAqC1C,gEAAgE;AAChE,wBAAgB,aAAa,CAC3B,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CA8B7C;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,KAAK,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAO7C"}
@@ -0,0 +1,62 @@
1
+ //#region src/controls/quality-names.ts
2
+ /** The codec families a viewer may recognise, by their RFC 6381 prefix. */
3
+ const CODECS = [
4
+ [/^av(c1|c3)/, "H.264"],
5
+ [/^h(vc1|ev1)/, "HEVC"],
6
+ [/^vp0?9/, "VP9"],
7
+ [/^av01/, "AV1"]
8
+ ];
9
+ /** Dolby Vision, in the codec itself or as a layer over it. */
10
+ function dolbyVision(rendition) {
11
+ const codecs = `${rendition.codecs ?? ""},${rendition.supplementalCodecs ?? ""}`;
12
+ return /(^|[,/])\s*(dvh1|dvhe|dav1|dva1)/.test(codecs);
13
+ }
14
+ /** 0 for SDR, 1 for HDR, 2 for Dolby Vision: the sort order and the word. */
15
+ function range(rendition) {
16
+ if (dolbyVision(rendition)) return 2;
17
+ return rendition.videoRange === "PQ" || rendition.videoRange === "HLG" ? 1 : 0;
18
+ }
19
+ function rate(rendition) {
20
+ return Math.round(rendition.frameRate ?? 0);
21
+ }
22
+ /** The average bitrate where the manifest gives one: closer to what plays. */
23
+ function bitrate(rendition) {
24
+ const bps = rendition.averageBitrate ?? rendition.bitrate;
25
+ return bps < 1e6 ? `${Math.round(bps / 1e3)} kbps` : `${(bps / 1e6).toFixed(1)} Mbps`;
26
+ }
27
+ function codec(rendition) {
28
+ const codecs = rendition.codecs ?? "";
29
+ return CODECS.find(([pattern]) => pattern.test(codecs))?.[1];
30
+ }
31
+ /** The label of every rendition, best first, twins included. */
32
+ function qualityLabels(renditions) {
33
+ const sorted = [...renditions].sort((a, b) => (b.height ?? 0) - (a.height ?? 0) || rate(b) - rate(a) || range(b) - range(a) || (b.averageBitrate ?? b.bitrate) - (a.averageBitrate ?? a.bitrate));
34
+ const bases = sorted.map((r) => {
35
+ return `${r.height === void 0 ? bitrate(r) : `${r.height}p`}${rate(r) > 30 ? String(rate(r)) : ""}${[
36
+ "",
37
+ " HDR",
38
+ " Dolby Vision"
39
+ ][range(r)]}`;
40
+ });
41
+ let labels = bases;
42
+ for (const part of [bitrate, codec]) labels = labels.map((label, i) => {
43
+ const twin = labels.some((other, j) => j !== i && other === label);
44
+ const extra = part(sorted[i]);
45
+ return twin && extra !== void 0 && !label.endsWith(extra) ? `${label} · ${extra}` : label;
46
+ });
47
+ labels = labels.map((label, i) => bases.every((base, j) => base !== bases[i] || labels[j] === label) ? bases[i] : label);
48
+ return sorted.map((r, i) => [r.id, labels[i]]);
49
+ }
50
+ /** The label of each rendition, best first, one entry per distinct label. */
51
+ function qualityNames(renditions) {
52
+ const seen = /* @__PURE__ */ new Set();
53
+ return qualityLabels(renditions).filter(([, label]) => {
54
+ if (seen.has(label)) return false;
55
+ seen.add(label);
56
+ return true;
57
+ });
58
+ }
59
+ //#endregion
60
+ export { qualityLabels, qualityNames };
61
+
62
+ //# sourceMappingURL=quality-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quality-names.js","names":[],"sources":["../../src/controls/quality-names.ts"],"sourcesContent":["/**\n * The words the quality menu shows for each rendition, best first. Pure,\n * node-tested.\n *\n * A label grows only as far as it must to tell entries apart: the height,\n * the frame rate above 30, Dolby Vision or HDR, then the bitrate where two\n * entries read the same, then the codec where they still do. Entries that\n * read the same after that are one choice for a viewer, and show once.\n */\nimport type { Rendition } from 'mattebox';\n\n/** The codec families a viewer may recognise, by their RFC 6381 prefix. */\nconst CODECS: ReadonlyArray<readonly [RegExp, string]> = [\n [/^av(c1|c3)/, 'H.264'],\n [/^h(vc1|ev1)/, 'HEVC'],\n [/^vp0?9/, 'VP9'],\n [/^av01/, 'AV1'],\n];\n\n/** Dolby Vision, in the codec itself or as a layer over it. */\nfunction dolbyVision(rendition: Rendition): boolean {\n const codecs = `${rendition.codecs ?? ''},${rendition.supplementalCodecs ?? ''}`;\n return /(^|[,/])\\s*(dvh1|dvhe|dav1|dva1)/.test(codecs);\n}\n\n/** 0 for SDR, 1 for HDR, 2 for Dolby Vision: the sort order and the word. */\nfunction range(rendition: Rendition): number {\n if (dolbyVision(rendition)) return 2;\n return rendition.videoRange === 'PQ' || rendition.videoRange === 'HLG' ? 1 : 0;\n}\n\nfunction rate(rendition: Rendition): number {\n return Math.round(rendition.frameRate ?? 0);\n}\n\n/** The average bitrate where the manifest gives one: closer to what plays. */\nfunction bitrate(rendition: Rendition): string {\n const bps = rendition.averageBitrate ?? rendition.bitrate;\n return bps < 1e6 ? `${Math.round(bps / 1000)} kbps` : `${(bps / 1e6).toFixed(1)} Mbps`;\n}\n\nfunction codec(rendition: Rendition): string | undefined {\n const codecs = rendition.codecs ?? '';\n return CODECS.find(([pattern]) => pattern.test(codecs))?.[1];\n}\n\n/** The label of every rendition, best first, twins included. */\nexport function qualityLabels(\n renditions: readonly Rendition[],\n): Array<readonly [id: string, label: string]> {\n const sorted = [...renditions].sort(\n (a, b) =>\n (b.height ?? 0) - (a.height ?? 0) ||\n rate(b) - rate(a) ||\n range(b) - range(a) ||\n (b.averageBitrate ?? b.bitrate) - (a.averageBitrate ?? a.bitrate),\n );\n const bases = sorted.map((r) => {\n const base = r.height === undefined ? bitrate(r) : `${r.height}p`;\n const fps = rate(r) > 30 ? String(rate(r)) : '';\n return `${base}${fps}${['', ' HDR', ' Dolby Vision'][range(r)]}`;\n });\n // Each step adds its part only to the entries that still share a label.\n let labels = bases;\n for (const part of [bitrate, codec]) {\n labels = labels.map((label, i) => {\n const twin = labels.some((other, j) => j !== i && other === label);\n const extra = part(sorted[i] as Rendition);\n return twin && extra !== undefined && !label.endsWith(extra) ? `${label} · ${extra}` : label;\n });\n }\n // Where nothing told a group apart (one stream on two CDNs), the parts\n // added are noise: the group keeps its base label.\n labels = labels.map((label, i) =>\n bases.every((base, j) => base !== bases[i] || labels[j] === label)\n ? (bases[i] as string)\n : label,\n );\n return sorted.map((r, i) => [r.id, labels[i] as string] as const);\n}\n\n/** The label of each rendition, best first, one entry per distinct label. */\nexport function qualityNames(\n renditions: readonly Rendition[],\n): Array<readonly [id: string, label: string]> {\n const seen = new Set<string>();\n return qualityLabels(renditions).filter(([, label]) => {\n if (seen.has(label)) return false;\n seen.add(label);\n return true;\n });\n}\n"],"mappings":";;AAYA,MAAM,SAAmD;CACvD,CAAC,cAAc,OAAO;CACtB,CAAC,eAAe,MAAM;CACtB,CAAC,UAAU,KAAK;CAChB,CAAC,SAAS,KAAK;AACjB;;AAGA,SAAS,YAAY,WAA+B;CAClD,MAAM,SAAS,GAAG,UAAU,UAAU,GAAG,GAAG,UAAU,sBAAsB;CAC5E,OAAO,mCAAmC,KAAK,MAAM;AACvD;;AAGA,SAAS,MAAM,WAA8B;CAC3C,IAAI,YAAY,SAAS,GAAG,OAAO;CACnC,OAAO,UAAU,eAAe,QAAQ,UAAU,eAAe,QAAQ,IAAI;AAC/E;AAEA,SAAS,KAAK,WAA8B;CAC1C,OAAO,KAAK,MAAM,UAAU,aAAa,CAAC;AAC5C;;AAGA,SAAS,QAAQ,WAA8B;CAC7C,MAAM,MAAM,UAAU,kBAAkB,UAAU;CAClD,OAAO,MAAM,MAAM,GAAG,KAAK,MAAM,MAAM,GAAI,EAAE,SAAS,IAAI,MAAM,IAAA,CAAK,QAAQ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AAc,UAAU,CAAC,CAAC,QAAQ,GAAG,WAAW;EACrD,IAAI,KAAK,IAAI,KAAK,GAAG,OAAO;EAC5B,KAAK,IAAI,KAAK;EACd,OAAO;CACT,CAAC;AACH"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The words the audio and subtitles menus show for a track, for an engine
3
+ * session and a native one alike. Pure, node-tested.
4
+ */
5
+ import type { MenuGroup } from './menu.js';
6
+ /**
7
+ * One menu entry: its value, the stream's name for it, its language code,
8
+ * its badges, and the hints that tell it from a twin, in the order they
9
+ * are tried.
10
+ */
11
+ export type TrackEntry = readonly [
12
+ value: string,
13
+ name: string | undefined,
14
+ lang: string | undefined,
15
+ badges: readonly string[],
16
+ hints: ReadonlyArray<string | undefined>
17
+ ];
18
+ /**
19
+ * The language's name in `locale`, with a capital first letter as the
20
+ * browsers' own menus show it: French gives "anglais", the menu shows
21
+ * "Anglais". Undefined without `Intl.DisplayNames` (Chromium 81, so not on
22
+ * Tizen 6 or webOS 6), for a code it does not know, and for a locale or a
23
+ * code it rejects.
24
+ */
25
+ export declare function languageName(lang: string, locale?: string): string | undefined;
26
+ /**
27
+ * The audio layout of an HLS CHANNELS value (RFC 8216bis §4.4.6.1): "2"
28
+ * reads Stereo, "6" reads 5.1, a "/JOC" suffix reads Dolby Atmos. Any
29
+ * other count reads as written.
30
+ */
31
+ export declare function layout(channels: string | undefined): string | undefined;
32
+ /**
33
+ * The entries as menu items. Each reads as its name, else its language's
34
+ * name, else its language code, else `word` ("Track") and its place. An
35
+ * entry that would read like another, badges included, takes in
36
+ * parentheses its first hint that differs from the other's, and at last
37
+ * its place.
38
+ */
39
+ export declare function trackNames(entries: readonly TrackEntry[], word: string | null, locale?: string): MenuGroup['items'];
40
+ //# sourceMappingURL=track-names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track-names.d.ts","sourceRoot":"","sources":["../../src/controls/track-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS;IAChC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM,GAAG,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS;IACxB,MAAM,EAAE,SAAS,MAAM,EAAE;IACzB,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW9E;AAID;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,GAAE,MAA4D,GACnE,SAAS,CAAC,OAAO,CAAC,CA2BpB"}
@@ -0,0 +1,59 @@
1
+ //#region src/controls/track-names.ts
2
+ /**
3
+ * The language's name in `locale`, with a capital first letter as the
4
+ * browsers' own menus show it: French gives "anglais", the menu shows
5
+ * "Anglais". Undefined without `Intl.DisplayNames` (Chromium 81, so not on
6
+ * Tizen 6 or webOS 6), for a code it does not know, and for a locale or a
7
+ * code it rejects.
8
+ */
9
+ function languageName(lang, locale) {
10
+ try {
11
+ const name = new Intl.DisplayNames(locale, {
12
+ type: "language",
13
+ fallback: "none"
14
+ }).of(lang);
15
+ return name.charAt(0).toUpperCase() + name.slice(1);
16
+ } catch {
17
+ return;
18
+ }
19
+ }
20
+ const LAYOUTS = {
21
+ 1: "Mono",
22
+ 2: "Stereo",
23
+ 6: "5.1",
24
+ 8: "7.1"
25
+ };
26
+ /**
27
+ * The audio layout of an HLS CHANNELS value (RFC 8216bis §4.4.6.1): "2"
28
+ * reads Stereo, "6" reads 5.1, a "/JOC" suffix reads Dolby Atmos. Any
29
+ * other count reads as written.
30
+ */
31
+ function layout(channels) {
32
+ return channels && (/\/JOC$/.test(channels) ? "Dolby Atmos" : LAYOUTS[channels] || channels);
33
+ }
34
+ /**
35
+ * The entries as menu items. Each reads as its name, else its language's
36
+ * name, else its language code, else `word` ("Track") and its place. An
37
+ * entry that would read like another, badges included, takes in
38
+ * parentheses its first hint that differs from the other's, and at last
39
+ * its place.
40
+ */
41
+ function trackNames(entries, word, locale = document.documentElement.lang || navigator.language) {
42
+ let texts = entries.map(([, name, lang], index) => name || lang && (languageName(lang, locale) || lang) || `${word || "Track"} ${index + 1}`);
43
+ for (let round = 0; round < 3; round++) {
44
+ const keys = texts.map((text, index) => text + entries[index][3]);
45
+ const hint = (index) => round < 2 ? entries[index][4][round] : String(index + 1);
46
+ texts = texts.map((text, index) => hint(index) && keys.some((key, other) => other !== index && key === keys[index] && hint(other) !== hint(index)) ? `${text} (${hint(index)})` : text);
47
+ }
48
+ return entries.map(([value, , , badges], index) => [
49
+ value,
50
+ texts[index],
51
+ void 0,
52
+ void 0,
53
+ badges
54
+ ]);
55
+ }
56
+ //#endregion
57
+ export { languageName, layout, trackNames };
58
+
59
+ //# sourceMappingURL=track-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track-names.js","names":[],"sources":["../../src/controls/track-names.ts"],"sourcesContent":["/**\n * The words the audio and subtitles menus show for a track, for an engine\n * session and a native one alike. Pure, node-tested.\n */\nimport type { MenuGroup } from './menu.js';\n\n/**\n * One menu entry: its value, the stream's name for it, its language code,\n * its badges, and the hints that tell it from a twin, in the order they\n * are tried.\n */\nexport type TrackEntry = readonly [\n value: string,\n name: string | undefined,\n lang: string | undefined,\n badges: readonly string[],\n hints: ReadonlyArray<string | undefined>,\n];\n\n/**\n * The language's name in `locale`, with a capital first letter as the\n * browsers' own menus show it: French gives \"anglais\", the menu shows\n * \"Anglais\". Undefined without `Intl.DisplayNames` (Chromium 81, so not on\n * Tizen 6 or webOS 6), for a code it does not know, and for a locale or a\n * code it rejects.\n */\nexport function languageName(lang: string, locale?: string): string | undefined {\n try {\n // lib.dom types `Intl.DisplayNames` as always present.\n const name = new (Intl as { DisplayNames: typeof Intl.DisplayNames }).DisplayNames(locale, {\n type: 'language',\n fallback: 'none',\n }).of(lang) as string;\n return name.charAt(0).toUpperCase() + name.slice(1);\n } catch {\n return undefined;\n }\n}\n\nconst LAYOUTS: Readonly<Record<string, string>> = { 1: 'Mono', 2: 'Stereo', 6: '5.1', 8: '7.1' };\n\n/**\n * The audio layout of an HLS CHANNELS value (RFC 8216bis §4.4.6.1): \"2\"\n * reads Stereo, \"6\" reads 5.1, a \"/JOC\" suffix reads Dolby Atmos. Any\n * other count reads as written.\n */\nexport function layout(channels: string | undefined): string | undefined {\n return channels && (/\\/JOC$/.test(channels) ? 'Dolby Atmos' : LAYOUTS[channels] || channels);\n}\n\n/**\n * The entries as menu items. Each reads as its name, else its language's\n * name, else its language code, else `word` (\"Track\") and its place. An\n * entry that would read like another, badges included, takes in\n * parentheses its first hint that differs from the other's, and at last\n * its place.\n */\nexport function trackNames(\n entries: readonly TrackEntry[],\n word: string | null,\n locale: string = document.documentElement.lang || navigator.language,\n): MenuGroup['items'] {\n let texts = entries.map(\n ([, name, lang], index) =>\n name || (lang && (languageName(lang, locale) || lang)) || `${word || 'Track'} ${index + 1}`,\n );\n // Two rounds of hints at most (the audio menu's layout and role), then the place.\n for (let round = 0; round < 3; round++) {\n const keys = texts.map((text, index) => text + (entries[index] as TrackEntry)[3]);\n const hint = (index: number): string | undefined =>\n round < 2 ? (entries[index] as TrackEntry)[4][round] : String(index + 1);\n // A hint the twins share tells nothing apart, so the next round tries another.\n texts = texts.map((text, index) =>\n hint(index) &&\n keys.some(\n (key, other) => other !== index && key === keys[index] && hint(other) !== hint(index),\n )\n ? `${text} (${hint(index)})`\n : text,\n );\n }\n return entries.map(([value, , , badges], index) => [\n value,\n texts[index] as string,\n undefined,\n und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ANGED
@@ -17,8 +17,10 @@
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 { Handler, Player, PlayerError, Session } from '@mattebox/player-core';
20
+ import type { Handler, Player, PlayerError, Session, Source } from '@mattebox/player-core';
21
21
  import type { KernelConfig, Mattebox, Stage } from 'mattebox';
22
+ import type { AttachEmeOptions } from 'mattebox/eme';
23
+ import type { Marker, Markers } from './controls/markers.js';
22
24
  import type { PlayerHost } from './host.js';
23
25
  /**
24
26
  * What the element dispatches. `error` is also a standard DOM event name, so
@@ -27,7 +29,13 @@ import type { PlayerHost } from './host.js';
27
29
  */
28
30
  export interface MatteboxPlayerEventMap {
29
31
  sourcechange: CustomEvent<Session | null>;
32
+ /** The size tier changed: `compact`, `regular` or `wide`. */
33
+ layoutchange: CustomEvent<string>;
30
34
  error: CustomEvent<PlayerError>;
35
+ /** The markers changed: set by the page, or cleared by a new source. */
36
+ markerschange: CustomEvent<readonly Marker[]>;
37
+ /** Playback reached a blocked range and moved past it. */
38
+ blocked: CustomEvent<Marker>;
31
39
  }
32
40
  export interface MatteboxPlayerElement {
33
41
  addEventListener<K extends keyof MatteboxPlayerEventMap>(type: K, listener: (this: MatteboxPlayerElement, event: MatteboxPlayerEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
@@ -46,6 +54,15 @@ export interface MatteboxPlayerOptions {
46
54
  * `handlers`, which carry their own.
47
55
  */
48
56
  readonly config?: Partial<KernelConfig>;
57
+ /**
58
+ * DRM for a native session, as `attachEme` from `mattebox/eme` takes it:
59
+ * `keySystems`, `licenseUrl`, `licenseUrls`, `requestHook`. Without
60
+ * `keySystems` the session offers the key-system stages of the engine's
61
+ * stack. The `license-url` attribute overrides `licenseUrl`, and
62
+ * `certificate-url` gives the FairPlay certificate. Ignored
63
+ * with `handlers`, which carry their own.
64
+ */
65
+ readonly drm?: AttachEmeOptions;
49
66
  }
50
67
  /**
51
68
  * The interface above merges only `addEventListener` and `removeEventListener`
@@ -68,16 +85,26 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
68
85
  /** Whether the element gave itself a tabindex for the bar, to take back with it. */
69
86
  private focusable;
70
87
  private readonly surface;
88
+ private readonly marks;
71
89
  /** The chapters track element, while the `chapters` attribute names one and the engine takes none. */
72
90
  private track;
73
91
  /** The chapters URL the current session's engine was given, or null. */
74
92
  private given;
75
- private readonly options;
93
+ /** The sources the page set from script, or null. */
94
+ private list;
95
+ /** The sources of the last run, as text: what tells a new `<source>` child from the ones already tried. */
96
+ private tried;
97
+ /** The options this element was constructed with, or null for the ones `define()` recorded. */
98
+ private readonly own;
76
99
  private core;
77
100
  private current;
78
101
  private failure;
79
102
  /** Whether an attribute change is the element's own reflection, which must not write back to the video. */
80
103
  private reflecting;
104
+ /** Watches the element's box for `layout`, while connected. */
105
+ private sizes;
106
+ /** Whether the page wrote `layout`, so the element leaves it alone. */
107
+ private fixed;
81
108
  /** The video has played once since its source was set: `started`, which tells a first play from a pause. */
82
109
  private started;
83
110
  /** The video waits for data: `waiting`, set on `waiting` and `stalled`, cleared once it can play. */
@@ -90,6 +117,15 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
90
117
  constructor(options?: MatteboxPlayerOptions);
91
118
  /** The media element. Everything the browser already does is here. */
92
119
  get video(): HTMLVideoElement;
120
+ /** The ranges the page named in this source: credits to skip, parts that must not play. */
121
+ get markers(): Markers;
122
+ /**
123
+ * The sources to try in order, set from script. The `src` attribute wins
124
+ * over them, and they win over the `<source>` children. Setting them
125
+ * loads, and null returns to the children.
126
+ */
127
+ get sources(): readonly Source[] | null;
128
+ set sources(value: readonly Source[] | null);
93
129
  /** The core, or null until the first source has been set up: resolving a preset is asynchronous. */
94
130
  get player(): Player | null;
95
131
  /** The engine feeding the video, or null for a native session and before the first load. */
@@ -102,6 +138,8 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
102
138
  */
103
139
  get error(): PlayerError | null;
104
140
  connectedCallback(): void;
141
+ /** Sets `layout` from the element's box, unless the page fixed it. */
142
+ private measure;
105
143
  /** The two states the video does not hold: whether it has played once, and whether it waits for data. */
106
144
  private note;
107
145
  /** The video's state on the element, for `mattebox-player[paused]` and the like. */
@@ -135,8 +173,28 @@ export declare class MatteboxPlayerElement extends HTMLElement implements Player
135
173
  private emit;
136
174
  private report;
137
175
  private run;
176
+ /**
177
+ * What to load, ranked as a video ranks them: the `src` attribute, then
178
+ * the `sources` property, then the `<source>` children in their order.
179
+ * A child carries its own `license-url` and `certificate-url`.
180
+ */
181
+ private wanted;
182
+ /** Sets a session up. It runs for every session, the one that replaces a failed source included. */
183
+ private adopt;
138
184
  private ensure;
185
+ /**
186
+ * Read at each use, not once in the constructor. Importing the package
187
+ * registers the element, and the parser's elements are constructed then,
188
+ * before the page's own `define()` call can run.
189
+ */
190
+ private get options();
139
191
  private chain;
192
+ /**
193
+ * The DRM a native session attaches: the page's `drm` option, the
194
+ * key-system stages of the engine's stack, and the `license-url`
195
+ * attribute. None on a browser without EME, as for the engine.
196
+ */
197
+ private drm;
140
198
  /** What the attributes ask of the session's namespaces, once there is one. */
141
199
  private configure;
142
200
  private unmount;
@@ -1 +1 @@
1
- {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAU,MAAM,uBAAuB,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA2D5C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1C,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CACjC;AAED,MAAM,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