@mattebox/player 0.9.1 → 0.10.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 (35) hide show
  1. package/dist/announcer.d.ts +7 -0
  2. package/dist/announcer.d.ts.map +1 -0
  3. package/dist/announcer.js +44 -0
  4. package/dist/announcer.js.map +1 -0
  5. package/dist/cdn/mattebox-player.min.js +3 -3
  6. package/dist/element.d.ts +17 -0
  7. package/dist/element.d.ts.map +1 -1
  8. package/dist/element.js +71 -1
  9. package/dist/element.js.map +1 -1
  10. package/dist/elements/audio-menu.js +1 -1
  11. package/dist/elements/drm-badge.js +2 -2
  12. package/dist/elements/menu-element.js +1 -1
  13. package/dist/elements/seek-bar.js +1 -1
  14. package/dist/elements/skip-button.js +1 -1
  15. package/dist/elements/subtitles-menu.js +1 -1
  16. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/asyncToGenerator.js +1 -1
  17. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/defineProperty.js +1 -1
  18. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/objectSpread2.js +1 -1
  19. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPrimitive.js +1 -1
  20. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/toPropertyKey.js +1 -1
  21. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.153.0 → _@oxc-project_runtime@0.154.0}/helpers/esm/typeof.js +1 -1
  22. package/dist/es2015/announcer.js +43 -0
  23. package/dist/es2015/controls/chapters.js +1 -1
  24. package/dist/es2015/controls/menu.js +1 -1
  25. package/dist/es2015/element.js +79 -5
  26. package/dist/es2015/elements/audio-menu.js +1 -1
  27. package/dist/es2015/elements/drm-badge.js +2 -2
  28. package/dist/es2015/elements/menu-element.js +1 -1
  29. package/dist/es2015/elements/seek-bar.js +1 -1
  30. package/dist/es2015/elements/skip-button.js +1 -1
  31. package/dist/es2015/elements/subtitles-menu.js +1 -1
  32. package/dist/es2015/presets.js +1 -1
  33. package/dist/es2015/style.js +1 -1
  34. package/dist/style.js +1 -1
  35. package/package.json +4 -4
@@ -0,0 +1,7 @@
1
+ export interface Announcer {
2
+ readonly root: HTMLElement;
3
+ /** Says the phrase of `label-<name>`, else `fallback`. */
4
+ say(name: string, fallback: string, track?: string): void;
5
+ }
6
+ export declare function announcer(host: HTMLElement): Announcer;
7
+ //# sourceMappingURL=announcer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announcer.d.ts","sourceRoot":"","sources":["../src/announcer.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,0DAA0D;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3D;AASD,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAkBtD"}
@@ -0,0 +1,44 @@
1
+ import { el } from "./dom.js";
2
+ import { fill } from "./labels.js";
3
+ //#region src/announcer.ts
4
+ /**
5
+ * The live region: what changed on the player, said to a screen reader.
6
+ * A shortcut key or a remote changes the playback with no focused control
7
+ * to read, so the element says it here: play, pause, loading, a fatal
8
+ * error and a track change (WCAG 2.2 SC 4.1.3, Status Messages). Vidstack's
9
+ * media announcer says the same things.
10
+ *
11
+ * Every phrase is an attribute on the player, `label-playing`,
12
+ * `label-paused`, `label-loading`, `label-error`, `label-audio`,
13
+ * `label-subtitles` and `label-subtitles-off`; `{track}` in the last
14
+ * three's text is the track's name. `announce="off"` keeps it quiet, for
15
+ * a page that announces on its own.
16
+ */
17
+ /**
18
+ * A screen reader reads a live region when its text changes, so the same
19
+ * phrase twice in a row, such as two pauses, has to empty the region
20
+ * first. The delay lets the reader see the empty region.
21
+ */
22
+ const REFILL_MS = 100;
23
+ function announcer(host) {
24
+ const root = el("div", "announcer");
25
+ root.setAttribute("role", "status");
26
+ root.setAttribute("aria-live", "polite");
27
+ let timer;
28
+ return {
29
+ root,
30
+ say(name, fallback, track = "") {
31
+ if (host.getAttribute("announce") === "off") return;
32
+ const text = fill(host.getAttribute(`label-${name}`) ?? fallback, { track });
33
+ root.textContent = "";
34
+ clearTimeout(timer);
35
+ timer = setTimeout(() => {
36
+ root.textContent = text;
37
+ }, REFILL_MS);
38
+ }
39
+ };
40
+ }
41
+ //#endregion
42
+ export { announcer };
43
+
44
+ //# sourceMappingURL=announcer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"announcer.js","names":[],"sources":["../src/announcer.ts"],"sourcesContent":["/**\n * The live region: what changed on the player, said to a screen reader.\n * A shortcut key or a remote changes the playback with no focused control\n * to read, so the element says it here: play, pause, loading, a fatal\n * error and a track change (WCAG 2.2 SC 4.1.3, Status Messages). Vidstack's\n * media announcer says the same things.\n *\n * Every phrase is an attribute on the player, `label-playing`,\n * `label-paused`, `label-loading`, `label-error`, `label-audio`,\n * `label-subtitles` and `label-subtitles-off`; `{track}` in the last\n * three's text is the track's name. `announce=\"off\"` keeps it quiet, for\n * a page that announces on its own.\n */\nimport { el } from './dom.js';\nimport { fill } from './labels.js';\n\nexport interface Announcer {\n readonly root: HTMLElement;\n /** Says the phrase of `label-<name>`, else `fallback`. */\n say(name: string, fallback: string, track?: string): void;\n}\n\n/**\n * A screen reader reads a live region when its text changes, so the same\n * phrase twice in a row, such as two pauses, has to empty the region\n * first. The delay lets the reader see the empty region.\n */\nconst REFILL_MS = 100;\n\nexport function announcer(host: HTMLElement): Announcer {\n const root = el('div', 'announcer');\n root.setAttribute('role', 'status');\n // role=\"status\" implies it; some older screen readers read only the attribute.\n root.setAttribute('aria-live', 'polite');\n let timer: ReturnType<typeof setTimeout> | undefined;\n return {\n root,\n say(name, fallback, track = '') {\n if (host.getAttribute('announce') === 'off') return;\n const text = fill(host.getAttribute(`label-${name}`) ?? fallback, { track });\n root.textContent = '';\n clearTimeout(timer);\n timer = setTimeout(() => {\n root.textContent = text;\n }, REFILL_MS);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,YAAY;AAElB,SAAgB,UAAU,MAA8B;CACtD,MAAM,OAAO,GAAG,OAAO,WAAW;CAClC,KAAK,aAAa,QAAQ,QAAQ;CAElC,KAAK,aAAa,aAAa,QAAQ;CACvC,IAAI;CACJ,OAAO;EACL;EACA,IAAI,MAAM,UAAU,QAAQ,IAAI;GAC9B,IAAI,KAAK,aAAa,UAAU,MAAM,OAAO;GAC7C,MAAM,OAAO,KAAK,KAAK,aAAa,SAAS,MAAM,KAAK,UAAU,EAAE,MAAM,CAAC;GAC3E,KAAK,cAAc;GACnB,aAAa,KAAK;GAClB,QAAQ,iBAAiB;IACvB,KAAK,cAAc;GACrB,GAAG,SAAS;EACd;CACF;AACF"}