@mattebox/player-ads 0.0.0 → 1.1.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -2
  3. package/dist/ad-info.d.ts +25 -0
  4. package/dist/ad-info.d.ts.map +1 -0
  5. package/dist/ad-info.js +80 -0
  6. package/dist/ad-info.js.map +1 -0
  7. package/dist/ad-link.d.ts +19 -0
  8. package/dist/ad-link.d.ts.map +1 -0
  9. package/dist/ad-link.js +51 -0
  10. package/dist/ad-link.js.map +1 -0
  11. package/dist/ad-progress.d.ts +18 -0
  12. package/dist/ad-progress.d.ts.map +1 -0
  13. package/dist/ad-progress.js +51 -0
  14. package/dist/ad-progress.js.map +1 -0
  15. package/dist/ad-skip-button.d.ts +21 -0
  16. package/dist/ad-skip-button.d.ts.map +1 -0
  17. package/dist/ad-skip-button.js +66 -0
  18. package/dist/ad-skip-button.js.map +1 -0
  19. package/dist/beacons.d.ts +29 -0
  20. package/dist/beacons.d.ts.map +1 -0
  21. package/dist/beacons.js +44 -0
  22. package/dist/beacons.js.map +1 -0
  23. package/dist/cdn/mattebox-player-ads.min.js +1 -0
  24. package/dist/component.d.ts +54 -0
  25. package/dist/component.d.ts.map +1 -0
  26. package/dist/component.js +95 -0
  27. package/dist/component.js.map +1 -0
  28. package/dist/controller.d.ts +200 -0
  29. package/dist/controller.d.ts.map +1 -0
  30. package/dist/controller.js +830 -0
  31. package/dist/controller.js.map +1 -0
  32. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/asyncToGenerator.js +26 -0
  33. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/defineProperty.js +11 -0
  34. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/objectSpread2.js +24 -0
  35. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPrimitive.js +13 -0
  36. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/toPropertyKey.js +8 -0
  37. package/dist/es2015/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/typeof.js +10 -0
  38. package/dist/es2015/ad-info.js +79 -0
  39. package/dist/es2015/ad-link.js +53 -0
  40. package/dist/es2015/ad-progress.js +51 -0
  41. package/dist/es2015/ad-skip-button.js +68 -0
  42. package/dist/es2015/beacons.js +42 -0
  43. package/dist/es2015/component.js +94 -0
  44. package/dist/es2015/controller.js +854 -0
  45. package/dist/es2015/host.js +18 -0
  46. package/dist/es2015/index.js +72 -0
  47. package/dist/es2015/locales/ar.js +13 -0
  48. package/dist/es2015/locales/ca.js +13 -0
  49. package/dist/es2015/locales/de.js +13 -0
  50. package/dist/es2015/locales/es.js +13 -0
  51. package/dist/es2015/locales/fr.js +13 -0
  52. package/dist/es2015/locales/hi.js +13 -0
  53. package/dist/es2015/locales/it.js +13 -0
  54. package/dist/es2015/locales/ja.js +13 -0
  55. package/dist/es2015/locales/ko.js +13 -0
  56. package/dist/es2015/locales/pt.js +13 -0
  57. package/dist/es2015/locales/zh.js +13 -0
  58. package/dist/es2015/shared.js +26 -0
  59. package/dist/es2015/vast.js +255 -0
  60. package/dist/es2015/vmap.js +73 -0
  61. package/dist/host.d.ts +14 -0
  62. package/dist/host.d.ts.map +1 -0
  63. package/dist/host.js +20 -0
  64. package/dist/host.js.map +1 -0
  65. package/dist/index.d.ts +40 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +74 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/locales/ar.d.ts +13 -0
  70. package/dist/locales/ar.d.ts.map +1 -0
  71. package/dist/locales/ar.js +15 -0
  72. package/dist/locales/ar.js.map +1 -0
  73. package/dist/locales/ca.d.ts +13 -0
  74. package/dist/locales/ca.d.ts.map +1 -0
  75. package/dist/locales/ca.js +15 -0
  76. package/dist/locales/ca.js.map +1 -0
  77. package/dist/locales/de.d.ts +13 -0
  78. package/dist/locales/de.d.ts.map +1 -0
  79. package/dist/locales/de.js +15 -0
  80. package/dist/locales/de.js.map +1 -0
  81. package/dist/locales/es.d.ts +13 -0
  82. package/dist/locales/es.d.ts.map +1 -0
  83. package/dist/locales/es.js +15 -0
  84. package/dist/locales/es.js.map +1 -0
  85. package/dist/locales/fr.d.ts +13 -0
  86. package/dist/locales/fr.d.ts.map +1 -0
  87. package/dist/locales/fr.js +15 -0
  88. package/dist/locales/fr.js.map +1 -0
  89. package/dist/locales/hi.d.ts +13 -0
  90. package/dist/locales/hi.d.ts.map +1 -0
  91. package/dist/locales/hi.js +15 -0
  92. package/dist/locales/hi.js.map +1 -0
  93. package/dist/locales/it.d.ts +13 -0
  94. package/dist/locales/it.d.ts.map +1 -0
  95. package/dist/locales/it.js +15 -0
  96. package/dist/locales/it.js.map +1 -0
  97. package/dist/locales/ja.d.ts +13 -0
  98. package/dist/locales/ja.d.ts.map +1 -0
  99. package/dist/locales/ja.js +15 -0
  100. package/dist/locales/ja.js.map +1 -0
  101. package/dist/locales/ko.d.ts +13 -0
  102. package/dist/locales/ko.d.ts.map +1 -0
  103. package/dist/locales/ko.js +15 -0
  104. package/dist/locales/ko.js.map +1 -0
  105. package/dist/locales/pt.d.ts +13 -0
  106. package/dist/locales/pt.d.ts.map +1 -0
  107. package/dist/locales/pt.js +15 -0
  108. package/dist/locales/pt.js.map +1 -0
  109. package/dist/locales/zh.d.ts +13 -0
  110. package/dist/locales/zh.d.ts.map +1 -0
  111. package/dist/locales/zh.js +15 -0
  112. package/dist/locales/zh.js.map +1 -0
  113. package/dist/messages.d.ts +30 -0
  114. package/dist/messages.d.ts.map +1 -0
  115. package/dist/shared.d.ts +7 -0
  116. package/dist/shared.d.ts.map +1 -0
  117. package/dist/shared.js +25 -0
  118. package/dist/shared.js.map +1 -0
  119. package/dist/vast.d.ts +94 -0
  120. package/dist/vast.d.ts.map +1 -0
  121. package/dist/vast.js +254 -0
  122. package/dist/vast.js.map +1 -0
  123. package/dist/vmap.d.ts +31 -0
  124. package/dist/vmap.d.ts.map +1 -0
  125. package/dist/vmap.js +71 -0
  126. package/dist/vmap.js.map +1 -0
  127. package/package.json +52 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","names":[],"sources":["../src/controller.ts"],"sourcesContent":["/**\n * The ads of one player: the schedule a page or a VMAP gives, the VAST of\n * each break, the breaks the stream signals, the beacons, and the state the\n * ad controls draw.\n *\n * Every ad plays on the player's own video, so the controls drive it and a\n * TV with one decoder plays it. An ad with an HLS or DASH file plays\n * through the engine's interstitials stage. An ad with only a progressive\n * file (MP4, WebM) plays through `player.interrupt`, which loads it in the\n * programme's place, and `player.resume` loads the programme again where\n * it stopped. On a native session, every ad plays that way.\n */\nimport type { BreakMark, Marker, PlayerHost } from '@mattebox/player';\nimport type { AdCreative, Break, InterstitialsApi } from 'mattebox/stages/interstitials';\nimport { expand, type MacroValues, send } from './beacons.js';\nimport { fetchText, resolveVast, type VastAd, type VastFetch, type VastMediaFile } from './vast.js';\nimport { type BreakOffset, offsetTime, parseVmap, type ScheduledBreak } from './vmap.js';\n\n/** What the ad controls show while an ad plays. */\nexport interface AdState {\n readonly breakId: string;\n /** 1 for the first ad of the break. */\n readonly index: number;\n readonly total: number;\n /** Seconds into the ad that plays. */\n readonly currentTime: number;\n /** Seconds of the ad that plays, or NaN while unknown. */\n readonly duration: number;\n /** Seconds left in the whole break, or NaN while unknown. */\n readonly remaining: number;\n /** Seconds until the viewer may skip, 0 once they may, null when the ad cannot be skipped. */\n readonly skipIn: number | null;\n readonly clickThrough?: string;\n /** The VAST ad, absent for an ad the stream signalled. */\n readonly ad?: VastAd;\n /** The stream plays the break itself: a cue-out with no ad of the page's. */\n readonly stitched: boolean;\n /** An ad, or a promotion of the channel's own. */\n readonly role: 'ad' | 'promo';\n /**\n * A break the stream plays that sets no rule, under `stitched: 'free'`:\n * the programme's controls stay, the seek bar among them, and the ad can be\n * skipped at once.\n */\n readonly free: boolean;\n}\n\n/** A break the page schedules: where, and the VAST to ask. */\nexport interface AdBreakInput {\n readonly id?: string;\n /** 'start', 'end', seconds, or a VMAP `timeOffset` such as '00:10:00' or '50%'. */\n readonly offset: 'start' | 'end' | number | string;\n /** The VAST URL. */\n readonly vast: string;\n}\n\n/** A cue-out of a live stream, which the page can fill with ads. */\nexport interface AdOpportunity {\n readonly id: string;\n readonly start: number;\n readonly duration: number;\n}\n\nexport interface AdsApi {\n /** The ad that plays, or null. */\n readonly state: AdState | null;\n /** Loads a VMAP, or a VAST as one pre-roll, for the current programme. */\n load(url: string): Promise<void>;\n /** Adds breaks for the current programme. A new programme clears them. */\n schedule(breaks: readonly AdBreakInput[]): void;\n /** Skips the ad that plays, when it may be skipped by now. */\n skip(): void;\n /** Opens the ad's page, pauses the ad, and reports the click. */\n click(): void;\n /** The VAST URL to fill a cue-out with, or null to let the stream play. */\n onOpportunity: ((opportunity: AdOpportunity) => string | null) | null;\n /** Runs `fn` whenever the state changes; returns the unsubscribe. */\n watch(fn: () => void): () => void;\n}\n\n/**\n * What the add-on sends with a load to a device that plays in the video's\n * place: the schedule the page gave for the programme, through `load`,\n * `schedule` or the `ad-schedule` attribute. The page of the device gives\n * it to its own add-on, with the same two calls.\n */\nexport interface AdsRemoteData {\n /** The VMAP or VAST URLs of `load`, absolute. */\n readonly urls?: readonly string[];\n /** The breaks of `schedule`. */\n readonly breaks?: readonly AdBreakInput[];\n}\n\nexport interface AdsOptions {\n /** How VAST and VMAP documents are fetched: a page that signs its ad requests gives its own. */\n readonly fetch?: VastFetch;\n /** Ads with only a progressive file: played on the player's video, or skipped. */\n readonly progressive?: 'play' | 'skip';\n /** Sends each beacon, in place of the add-on: a page that logs them, or sends them through its own server. */\n readonly beacon?: (url: string) => void;\n /**\n * A break the stream plays itself and that sets no rule, as every SCTE-35\n * cue: `free`, the default, keeps the programme's controls and lets the\n * viewer skip it; `strict` takes no seek, as a break that forbids one.\n */\n readonly stitched?: 'free' | 'strict';\n}\n\n/** Seconds before a break at which its VAST is fetched: fresh, and in time for the preload. */\nconst LOOKAHEAD = 10;\nconst QUARTILE_EVENTS = ['firstQuartile', 'midpoint', 'thirdQuartile'] as const;\n/** The keys that seek: the bar's arrows and media keys, the seek bar's Home, End and pages. */\nconst SEEK_KEYS = new Set([\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n 'MediaRewind',\n 'MediaFastForward',\n 'MediaTrackNext',\n 'MediaTrackPrevious',\n 'j',\n 'J',\n 'l',\n 'L',\n ...'0123456789',\n]);\nconst STREAMING = /mpegurl|dash\\+xml/i;\n\n/** What of the engine's chapters this add-on reads and writes. */\ninterface ChaptersView {\n readonly source: string;\n set(chapters: readonly { start: number; end?: number; title: string }[]): number;\n}\n\ninterface Plan {\n readonly id: string;\n readonly offset: BreakOffset;\n readonly vast: ScheduledBreak['vast'];\n readonly tracking: ScheduledBreak['tracking'];\n /** Seconds a cue-out lasts, for a fill. */\n readonly covers?: number;\n status: 'waiting' | 'resolving' | 'stream' | 'progressive' | 'done';\n ads: readonly VastAd[];\n files: readonly VastMediaFile[];\n start?: number;\n}\n\ninterface Current {\n readonly plan: Plan | null;\n readonly entry: Break | null;\n readonly stitched: boolean;\n index: number;\n ad: VastAd | undefined;\n /** What the stream says of the ad, SVTA2053, for an ad without a VAST. */\n creative: AdCreative | undefined;\n file: VastMediaFile | undefined;\n skipped: boolean;\n quartiles: number;\n /** Progress beacons and stream tracking already sent, by index. */\n sent: Set<number>;\n viewable: boolean;\n /** The viewer paused the ad: the next play is a resume. */\n paused: boolean;\n /** A progressive ad, which `player.interrupt` plays in the programme's place. */\n readonly interrupt: boolean;\n /** The ad's last time, which a refused seek goes back to. */\n last: number;\n /** The programme time where the break started, for the macros. */\n readonly at: number;\n}\n\nconst controllers = new WeakMap<PlayerHost, Controller>();\n\n/** The ads of `player`, created on first use. */\nexport function controllerFor(player: PlayerHost, options?: AdsOptions): Controller {\n let found = controllers.get(player);\n if (found === undefined) {\n found = new Controller(player, options ?? {});\n controllers.set(player, found);\n } else if (options !== undefined) {\n // The add-on's options, for a controller a page or an element made first.\n found.configure(options);\n }\n return found;\n}\n\n/** The time form of a scheduled offset. */\nfunction offsetFrom(value: AdBreakInput['offset']): BreakOffset {\n if (value === 'start' || value === 'end') return value;\n if (typeof value === 'number') return { time: value };\n if (value.endsWith('%')) return { percent: Number(value.slice(0, -1)) };\n const parts = value.split(':').map(Number);\n return { time: parts.reduce((sum, part) => sum * 60 + part, 0) };\n}\n\n/** The file to play: a streaming one the engine reads, else the progressive one closest above the player's height. */\nfunction pick(\n ad: VastAd,\n engine: boolean,\n video: HTMLVideoElement,\n height: number,\n): VastMediaFile | undefined {\n const usable = ad.mediaFiles.filter((file) => file.apiFramework === undefined);\n if (engine) {\n const stream = usable.find((file) => STREAMING.test(file.type));\n if (stream !== undefined) return stream;\n }\n const progressive = usable\n .filter((file) => !STREAMING.test(file.type) && video.canPlayType(file.type) !== '')\n .sort((a, b) => (a.height ?? 0) - (b.height ?? 0));\n return (\n progressive.find((file) => (file.height ?? 0) >= height) ?? progressive[progressive.length - 1]\n );\n}\n\nexport class Controller implements AdsApi {\n declare onOpportunity: ((opportunity: AdOpportunity) => string | null) | null;\n declare private readonly player: PlayerHost;\n declare private fetchDoc: VastFetch;\n declare private progressive: 'play' | 'skip';\n declare private send: (url: string) => void;\n declare private stitchedMode: 'free' | 'strict';\n /** The credits markers this add-on gave the player, so a page's own stay. */\n declare private own: ReadonlySet<Marker>;\n declare private plans: Map<string, Plan>;\n /** What the page gave for this programme, as it gave it. */\n declare private given: { urls: string[]; breaks: AdBreakInput[] };\n declare private current: Current | null;\n declare private watchers: Set<() => void>;\n declare private offEngine: (() => void) | null;\n declare private lastTime: number;\n /** A pre-roll is still being asked for: the programme waits for it. */\n declare private holding: boolean;\n /** Schedules being fetched, which may hold a pre-roll. */\n declare private fetching: number;\n declare private observer: IntersectionObserver | null;\n declare private visibleSince: number | null;\n declare private seq: number;\n /** The breaks that played, by id, which the seek bar draws faded. */\n declare private done: Set<string>;\n\n constructor(player: PlayerHost, options: AdsOptions) {\n this.onOpportunity = null;\n this.player = player;\n this.fetchDoc = fetchText;\n this.progressive = 'play';\n this.send = send;\n this.stitchedMode = 'free';\n this.own = new Set();\n this.configure(options);\n this.plans = new Map();\n this.given = { urls: [], breaks: [] };\n this.current = null;\n this.watchers = new Set();\n this.offEngine = null;\n this.lastTime = 0;\n this.holding = false;\n this.fetching = 0;\n this.observer = null;\n this.visibleSince = null;\n this.seq = 0;\n this.done = new Set();\n }\n\n configure(options: AdsOptions): void {\n this.fetchDoc = options.fetch ?? fetchText;\n this.progressive = options.progressive ?? 'play';\n this.send = options.beacon ?? send;\n this.stitchedMode = options.stitched ?? 'free';\n }\n\n /** Follows the player until `detach`. */\n attach(): () => void {\n const player = this.player;\n const video = player.media;\n const onSource = (): void => {\n this.reset();\n this.bindEngine();\n const schedule = player.getAttribute('ad-schedule');\n if (schedule !== null && schedule !== '') void this.load(schedule);\n };\n const onTime = (): void => this.tick();\n const onMetadata = (): void => {\n this.mark();\n this.tick();\n };\n const onPlay = (): void => {\n if (this.away()) return;\n // The pre-roll first: the programme waits while its ad server answers,\n // and a progressive pre-roll already answered starts now.\n if (this.current === null && this.pending('start')) {\n this.holding = true;\n video.pause();\n } else if (this.current === null) {\n const pre = [...this.plans.values()].find(\n (plan) => plan.offset === 'start' && plan.status === 'progressive',\n );\n if (pre !== undefined) {\n video.pause();\n this.startProgressive(pre);\n }\n }\n this.tick();\n };\n const onEnded = (): void => {\n if (this.away() && this.current === null) return;\n if (this.current?.interrupt === true) {\n this.nextProgressive();\n return;\n }\n if (this.current !== null || this.engineBreaks()?.playing != null) return;\n const post = [...this.plans.values()].find(\n (plan) => plan.offset === 'end' && plan.status === 'progressive',\n );\n if (post !== undefined) this.startProgressive(post);\n };\n const onError = (): void => {\n const current = this.current;\n if (current?.interrupt !== true) return;\n if (current.ad !== undefined) {\n for (const url of current.ad.errors)\n this.send(expand(url, { ...this.macros(current), errorCode: 405 }));\n }\n this.emit('aderror', { id: current.plan?.id, code: 405 });\n this.nextProgressive();\n };\n const onSeeking = (): void => {\n // An ad takes no seek: back to where it was.\n const current = this.current;\n if (current?.interrupt !== true) return;\n if (Math.abs(video.currentTime - current.last) > 0.5) video.currentTime = current.last;\n };\n // An ad of the engine's plays on the player's own video.\n const onAdPause = (): void => {\n if (this.current !== null) this.adPaused(video);\n };\n const onAdPlay = (): void => {\n if (this.current !== null) this.adResumed(video);\n };\n const onAdVolume = (): void => {\n if (this.current !== null && !this.current.stitched) this.adVolume(video);\n };\n // An ad takes no seek: the keys that seek go nowhere while one plays.\n // Play, pause, mute and fullscreen stay the bar's. In the capture phase,\n // so the bar and the seek bar never hear them.\n const onKey = (event: KeyboardEvent): void => {\n if (this.current === null || this.free(this.current)) return;\n if (!SEEK_KEYS.has(event.key)) return;\n // The volume's own arrows, when it has focus, are the volume's.\n const volume = event\n .composedPath()\n .some((node) => node instanceof HTMLElement && node.localName.startsWith('mbx-volume'));\n if (volume) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n };\n player.addEventListener('keydown', onKey, true);\n // A page's markers replace the list: the credits this add-on gave come back.\n const onMarkers = (): void => this.spans();\n player.addEventListener('markerschange', onMarkers);\n // At the end of a drag, the ad the stream plays where it landed, if any.\n const scrub = new MutationObserver(() => {\n if (!player.hasAttribute('scrubbing')) this.landed();\n });\n scrub.observe(player, { attributes: true, attributeFilter: ['scrubbing'] });\n player.addEventListener('sourcechange', onSource);\n video.addEventListener('timeupdate', onTime);\n video.addEventListener('play', onPlay);\n video.addEventListener('loadedmetadata', onMetadata);\n video.addEventListener('ended', onEnded);\n video.addEventListener('error', onError);\n video.addEventListener('seeking', onSeeking);\n video.addEventListener('pause', onAdPause);\n video.addEventListener('playing', onAdPlay);\n video.addEventListener('volumechange', onAdVolume);\n this.bindEngine();\n return () => {\n scrub.disconnect();\n player.removeEventListener('markerschange', onMarkers);\n player.removeEventListener('keydown', onKey, true);\n player.removeEventListener('sourcechange', onSource);\n video.removeEventListener('timeupdate', onTime);\n video.removeEventListener('play', onPlay);\n video.removeEventListener('loadedmetadata', onMetadata);\n video.removeEventListener('ended', onEnded);\n video.removeEventListener('error', onError);\n video.removeEventListener('seeking', onSeeking);\n video.removeEventListener('pause', onAdPause);\n video.removeEventListener('playing', onAdPlay);\n video.removeEventListener('volumechange', onAdVolume);\n this.reset();\n this.offEngine?.();\n this.offEngine = null;\n };\n }\n\n get state(): AdState | null {\n const current = this.current;\n if (current === null) return null;\n const media = this.player.media;\n const ads = current.plan?.ads ?? [];\n const assets = current.entry?.assets ?? [];\n const total = Math.max(1, ads.length || assets.length);\n const time = current.stitched\n ? this.player.media.currentTime - (current.entry?.start ?? 0)\n : media.currentTime;\n const duration = current.stitched\n ? (current.entry?.covers ?? Number.NaN)\n : Number.isFinite(media.duration)\n ? media.duration\n : (current.ad?.duration ?? assets[current.index]?.duration ?? Number.NaN);\n const later = (\n ads.length > 0\n ? ads.map((ad) => ad.duration)\n : assets.map((asset) => asset.duration ?? Number.NaN)\n )\n .slice(current.index + 1)\n .reduce((sum, value) => sum + value, 0);\n const free = this.free(current);\n // A break the stream plays and that sets no rule skips at once when free.\n const skipOffset =\n current.ad?.skipOffset ??\n current.creative?.skipOffset ??\n (current.ad === undefined && !current.stitched ? current.entry?.skipAfter : undefined);\n const clickThrough = current.ad?.clickThrough ?? current.creative?.clickThrough;\n return {\n breakId: current.plan?.id ?? current.entry?.id ?? '',\n index: current.index + 1,\n total,\n currentTime: time,\n duration,\n remaining: duration - time + later,\n skipIn: free ? 0 : skipOffset === undefined ? null : Math.max(0, skipOffset - time),\n ...(clickThrough !== undefined ? { clickThrough } : {}),\n ...(current.ad !== undefined ? { ad: current.ad } : {}),\n stitched: current.stitched,\n role: current.entry?.role === 'promo' ? 'promo' : 'ad',\n free,\n };\n }\n\n /** A break the stream plays itself, with no rule of its own, under `stitched: 'free'`. */\n private free(current: Current): boolean {\n const entry = current.entry;\n return (\n current.stitched &&\n this.stitchedMode === 'free' &&\n entry !== null &&\n !entry.noSkip &&\n !entry.noJump &&\n current.creative?.skipOffset === undefined\n );\n }\n\n watch(fn: () => void): () => void {\n this.watchers.add(fn);\n return () => {\n this.watchers.delete(fn);\n };\n }\n\n /** The schedule the page gave, for the page of a device. Undefined without one. */\n remoteData(): AdsRemoteData | undefined {\n const { urls, breaks } = this.given;\n if (urls.length === 0 && breaks.length === 0) return undefined;\n return {\n ...(urls.length === 0 ? {} : { urls: [...urls] }),\n ...(breaks.length === 0 ? {} : { breaks: [...breaks] }),\n };\n }\n\n /**\n * A device plays in the video's place, and it is not the video itself as\n * under AirPlay. The device's own page plays the ads then, so nothing\n * starts here: the same break would play twice.\n */\n private away(): boolean {\n const target = this.player.casting;\n return target !== null && target.kind !== 'airplay';\n }\n\n async load(source: string): Promise<void> {\n // Absolute, so the ad tags of a VMAP resolve against it.\n const url = new URL(source, location.href).href;\n this.given.urls.push(url);\n let text: string;\n this.fetching += 1;\n try {\n text = await this.fetchDoc(url, new AbortController().signal);\n } catch {\n this.fetching -= 1;\n this.emit('aderror', { code: 900, url });\n this.release();\n return;\n }\n this.fetching -= 1;\n const breaks = parseVmap(text, url);\n if (breaks === null) {\n this.add({ id: 'preroll', offset: 'start', vast: { xml: text }, tracking: [] });\n } else {\n for (const entry of breaks) this.add(entry);\n }\n // A schedule without a pre-roll lets the programme play.\n this.release();\n this.tick();\n }\n\n schedule(breaks: readonly AdBreakInput[]): void {\n this.given.breaks.push(...breaks);\n for (const entry of breaks) {\n this.seq += 1;\n this.add({\n id: entry.id ?? `ad-break-${this.seq}`,\n offset: offsetFrom(entry.offset),\n vast: { url: new URL(entry.vast, location.href).href },\n tracking: [],\n });\n }\n this.tick();\n }\n\n skip(): void {\n const current = this.current;\n const state = this.state;\n if (current === null || state === null || state.skipIn === null || state.skipIn > 0) return;\n if (current.interrupt) {\n current.skipped = true;\n this.track(current, 'skip');\n this.emit('adskip', this.detail());\n this.nextProgressive();\n return;\n }\n current.skipped = true;\n this.track(current, 'skip');\n this.emit('adskip', this.detail());\n if (current.stitched && current.entry !== null) {\n // The stream plays this ad itself: a skip is a seek past it.\n this.player.media.currentTime = current.entry.start + current.entry.covers;\n return;\n }\n this.engineBreaks()?.skip();\n }\n\n click(): void {\n const current = this.current;\n const target = current?.ad?.clickThrough ?? current?.creative?.clickThrough;\n if (current === null || target === undefined) return;\n for (const url of current.ad?.clickTracking ?? []) this.send(expand(url, this.macros(current)));\n this.track(current, 'clickTracking');\n window.open(target, '_blank', 'noopener');\n this.player.media.pause();\n this.emit('adclick', this.detail());\n }\n\n // ---- the schedule ------------------------------------------------------\n\n private add(entry: ScheduledBreak & { readonly covers?: number }): void {\n this.plans.set(entry.id, { ...entry, status: 'waiting', ads: [], files: [] });\n this.mark();\n }\n\n /**\n * The seek bar's ticks: the mid-roll breaks of the engine and of the\n * schedule, spans where a break replaces a part, faded once played. A\n * pre-roll and a post-roll sit at the ends and get none.\n */\n private mark(): void {\n const marks: BreakMark[] = [];\n const engine = this.engineBreaks();\n const ids = new Set<string>();\n for (const entry of engine?.breaks ?? []) {\n ids.add(entry.id);\n if (entry.cue !== undefined) continue;\n if (entry.role !== undefined && entry.role !== 'ad' && entry.role !== 'promo') continue;\n marks.push({\n start: entry.start,\n ...(entry.covers > 0 ? { end: entry.start + entry.covers } : {}),\n ...(this.done.has(entry.id) ? { played: true } : {}),\n });\n }\n const duration = this.programmeDuration();\n for (const plan of this.plans.values()) {\n if (ids.has(plan.id) || plan.offset === 'start' || plan.offset === 'end') continue;\n const at = offsetTime(plan.offset, duration);\n if (at === null) continue;\n marks.push({ start: at, ...(plan.status === 'done' ? { played: true } : {}) });\n }\n this.player.breaks.set('ads', marks);\n this.spans();\n }\n\n /**\n * The credits and chapters a SCTE-35 section names, as the player shows\n * them: the credits as markers, which give Skip intro and Skip credits,\n * beside the page's own, and the chapters in the chapter menu when nothing\n * else gives chapters.\n */\n private spans(): void {\n const breaks = this.engineBreaks()?.breaks ?? [];\n const credits: Marker[] = breaks.flatMap((entry) =>\n (entry.role === 'opening-credits' || entry.role === 'closing-credits') && entry.covers > 0\n ? [{ start: entry.start, end: entry.start + entry.covers, kind: entry.role }]\n : [],\n );\n const markers = this.player.markers;\n const theirs = markers.list.filter((marker) => !this.own.has(marker));\n const same =\n credits.length === this.own.size &&\n [...this.own].every((marker, i) => {\n const next = credits[i];\n return next !== undefined && next.start === marker.start && next.end === marker.end;\n }) &&\n [...this.own].every((marker) => markers.list.includes(marker));\n if (!same) {\n this.own = new Set(credits);\n markers.set([...theirs, ...credits]);\n }\n const chapters = breaks.filter((entry) => entry.role === 'chapter');\n const api = (this.player.engine as { chapters?: ChaptersView } | null)?.chapters;\n if (\n api !== undefined &&\n chapters.length > 0 &&\n api.source !== 'manifest' &&\n api.source !== 'app'\n ) {\n api.set(\n chapters.map((entry, i) => ({\n start: entry.start,\n ...(entry.covers > 0 ? { end: entry.start + entry.covers } : {}),\n title: `${i + 1}`,\n })),\n );\n }\n }\n\n private pending(offset: 'start'): boolean {\n if (this.fetching > 0) return true;\n return [...this.plans.values()].some(\n (plan) =>\n plan.offset === offset && (plan.status === 'waiting' || plan.status === 'resolving'),\n );\n }\n\n private engineBreaks(): InterstitialsApi | undefined {\n return (this.player.engine as { interstitials?: InterstitialsApi } | null)?.interstitials;\n }\n\n /** The programme's own time, through a break. */\n private programmeTime(): number {\n return this.engineBreaks()?.primary.currentTime ?? this.player.media.currentTime;\n }\n\n private programmeDuration(): number {\n return this.engineBreaks()?.primary.duration ?? this.player.media.duration;\n }\n\n /** Fetches the VAST of each break as it comes near, and starts the progressive ones on time. */\n private tick(): void {\n this.update();\n if (this.current !== null) {\n this.followAd(this.current);\n return;\n }\n if (this.away()) return;\n const time = this.programmeTime();\n const duration = this.programmeDuration();\n const seeked = Math.abs(time - this.lastTime) > 2;\n for (const plan of this.plans.values()) {\n const at = offsetTime(plan.offset, duration);\n if (at === null) continue;\n if (plan.status === 'waiting' && (plan.offset === 'start' || at - time <= LOOKAHEAD)) {\n void this.resolve(plan, at);\n } else if (\n plan.status === 'progressive' &&\n plan.offset !== 'end' &&\n !seeked &&\n this.lastTime <= at &&\n time >= at &&\n plan.offset !== 'start'\n ) {\n this.startProgressive(plan);\n break;\n }\n }\n this.lastTime = time;\n }\n\n private async resolve(plan: Plan, at: number): Promise<void> {\n plan.status = 'resolving';\n const result = await resolveVast(plan.vast, this.fetchDoc);\n if (this.plans.get(plan.id) !== plan) return;\n const engine = this.engineBreaks() !== undefined;\n const height = this.player.clientHeight;\n const playable: VastAd[] = [];\n const files: VastMediaFile[] = [];\n for (const ad of result.ads) {\n const file = pick(ad, engine, this.player.media, height);\n if (file === undefined || (!STREAMING.test(file.type) && this.progressive === 'skip')) {\n for (const url of ad.errors) this.send(expand(url, { errorCode: 403 }));\n continue;\n }\n playable.push(ad);\n files.push(file);\n }\n if (result.ads.length === 0) {\n for (const url of result.errors) this.send(expand(url, { errorCode: result.code ?? 303 }));\n }\n plan.ads = playable;\n plan.files = files;\n plan.start = at;\n if (playable.length === 0) {\n plan.status = 'done';\n this.vmapTrack(plan, 'error');\n this.emit('aderror', { id: plan.id, code: result.code ?? 403 });\n this.release();\n return;\n }\n const streams = files.every((file) => STREAMING.test(file.type));\n if (engine && streams) {\n plan.status = 'stream';\n // A skippable ad still takes no seek: the controls skip it from its offset.\n const offsets = playable.flatMap((ad) =>\n ad.skipOffset === undefined ? [] : [ad.skipOffset],\n );\n if (this.holding) {\n this.holding = false;\n void this.player.media.play()?.catch(() => {});\n }\n this.engineBreaks()?.schedule({\n id: plan.id,\n start: at,\n ...(plan.offset === 'start'\n ? { cue: 'pre' as const }\n : plan.offset === 'end'\n ? { cue: 'post' as const }\n : {}),\n ...(plan.covers !== undefined ? { covers: plan.covers } : {}),\n assets: files.map((file, i) => ({\n url: file.url,\n duration: playable[i]?.duration ?? 0,\n mimeType: /dash/i.test(file.type)\n ? 'application/dash+xml'\n : 'application/vnd.apple.mpegurl',\n })),\n noSkip: true,\n noJump: true,\n // An ad server's break plays once per programme, as IMA plays a VMAP.\n once: true,\n ...(offsets.length > 0 ? { skipAfter: Math.min(...offsets) } : {}),\n });\n return;\n }\n plan.status = 'progressive';\n if (plan.offset === 'start' && (this.holding || !this.player.media.paused)) {\n this.holding = false;\n this.player.media.pause();\n this.startProgressive(plan);\n }\n }\n\n /** Lets the programme play once no pre-roll holds it. */\n private release(): void {\n if (!this.holding || this.pending('start')) return;\n this.holding = false;\n void this.player.media.play()?.catch(() => {});\n }\n\n // ---- the engine's breaks -----------------------------------------------\n\n private bindEngine(): void {\n this.offEngine?.();\n this.offEngine = null;\n const engine = this.player.engine;\n if (engine === null || this.engineBreaks() === undefined) return;\n const on = (name: string, fn: (payload: Record<string, unknown>) => void): (() => void) =>\n engine.on(`interstitials:${name}`, (payload) => fn(payload as Record<string, unknown>));\n const offs = [\n on('break-start', (p) => {\n // A drag on the seek bar crosses a break the stream plays at each of\n // its seeks: where the drag ends decides, not each step of it.\n if (p.stitched === true && this.player.hasAttribute('scrubbing')) return;\n this.engineBreakStart(p.break as Break, p.stitched === true);\n }),\n on('asset-start', (p) => this.engineAssetStart(Number(p.asset))),\n on('progress', (p) => this.quartile(Number(p.quartile))),\n on('asset-end', () => this.adEnd()),\n on('break-end', (p) => {\n if (p.stitched === true && this.player.hasAttribute('scrubbing')) return;\n this.breakEnd();\n }),\n on('warning', (p) => {\n const current = this.current;\n if (current?.ad !== undefined) {\n for (const url of current.ad.errors)\n this.send(expand(url, { ...this.macros(current), errorCode: 405 }));\n }\n this.emit('aderror', { id: p.id, code: 405, reason: p.reason });\n }),\n on('opportunity', (p) => this.opportunity(p.break as Break, Number(p.duration))),\n ];\n offs.push(engine.on('interstitials:changed', () => this.mark()));\n this.offEngine = () => {\n for (const off of offs) off();\n };\n this.mark();\n }\n\n /** After a drag: in an ad the stream plays, it starts; out of it, the ad that showed ends. */\n private landed(): void {\n const time = this.player.media.currentTime;\n const inside = (this.engineBreaks()?.breaks ?? []).find(\n (entry) =>\n entry.assets.length === 0 &&\n entry.assetList === undefined &&\n time >= entry.start &&\n time < entry.start + Math.max(entry.covers, 0.001),\n );\n const current = this.current;\n if (current?.stitched === true && current.entry?.id !== inside?.id) this.breakEnd();\n if (inside !== undefined && this.current === null) this.engineBreakStart(inside, true);\n }\n\n private engineBreakStart(entry: Break, stitched: boolean): void {\n const plan = this.plans.get(entry.id) ?? null;\n this.current = {\n plan,\n entry,\n stitched,\n index: -1,\n ad: undefined,\n creative: undefined,\n file: undefined,\n skipped: false,\n quartiles: 0,\n sent: new Set(),\n viewable: false,\n paused: false,\n interrupt: false,\n last: 0,\n at: this.programmeTime(),\n };\n this.breakStart();\n // A break the stream plays itself is one ad, from its start.\n if (stitched) this.engineAssetStart(0);\n }\n\n private engineAssetStart(index: number): void {\n const current = this.current;\n if (current === null) return;\n current.index = index;\n current.ad = current.plan?.ads[index];\n current.creative = current.stitched\n ? current.entry?.creatives?.[0]\n : current.entry?.assets[index]?.creatives?.[0];\n current.file = current.plan?.files[index];\n current.skipped = false;\n current.quartiles = 0;\n current.sent = new Set();\n current.viewable = false;\n this.adStart(current);\n }\n\n private opportunity(entry: Break, duration: number): void {\n const url = this.onOpportunity?.({ id: entry.id, start: entry.start, duration });\n if (url === null || url === undefined) return;\n this.add({\n id: entry.id,\n offset: { time: entry.start },\n vast: { url: new URL(url, location.href).href },\n tracking: [],\n covers: duration,\n });\n const plan = this.plans.get(entry.id);\n if (plan !== undefined) void this.resolve(plan, entry.start);\n }\n\n // ---- progressive ads, on the player's video -------------------------------\n\n /** A break of progressive ads: each in the programme's place, then the programme again. */\n private startProgressive(plan: Plan): void {\n plan.status = 'done';\n this.current = {\n plan,\n entry: null,\n stitched: false,\n index: -1,\n ad: undefined,\n creative: undefined,\n file: undefined,\n skipped: false,\n quartiles: 0,\n sent: new Set(),\n viewable: false,\n paused: false,\n interrupt: true,\n last: 0,\n at: this.programmeTime(),\n };\n this.breakStart();\n this.nextProgressive();\n }\n\n private nextProgressive(): void {\n const current = this.current;\n if (current === null || !current.interrupt || current.plan === null) return;\n if (current.index >= 0) this.adEnd();\n current.index += 1;\n const ad = current.plan.ads[current.index];\n const file = current.plan.files[current.index];\n if (ad === undefined || file === undefined) {\n const plan = current.plan;\n this.breakEnd();\n // After a post-roll the programme comes back on its last frame, paused.\n void this.player.resume(\n plan.offset === 'end' ? { at: plan.start ?? null, playing: false } : { playing: true },\n );\n return;\n }\n current.ad = ad;\n current.file = file;\n current.skipped = false;\n current.quartiles = 0;\n current.sent = new Set();\n current.viewable = false;\n current.paused = false;\n current.last = 0;\n this.player.interrupt({ url: file.url, type: file.type }).catch(() => {\n // No handler plays the file: the next ad, or the programme.\n if (this.current !== current) return;\n for (const url of ad.errors)\n this.send(expand(url, { ...this.macros(current), errorCode: 405 }));\n this.emit('aderror', { id: current.plan?.id, code: 405 });\n this.nextProgressive();\n });\n this.adStart(current);\n }\n\n // ---- one ad ------------------------------------------------------------\n\n private breakStart(): void {\n const current = this.current;\n if (current === null) return;\n // `stitched` keeps the programme's controls; any other ad takes their place.\n this.player.setAttribute('ad', this.free(current) ? 'stitched' : '');\n if (current.plan !== null) this.vmapTrack(current.plan, 'breakStart');\n this.observe();\n this.emit('adbreakstart', this.detail());\n }\n\n private adStart(current: Current): void {\n if (current.ad !== undefined) {\n for (const url of current.ad.impressions) this.send(expand(url, this.macros(current)));\n }\n // SVTA2053 names the impression among its tracking events.\n this.track(current, 'impression');\n this.track(current, 'creativeView');\n this.track(current, 'start');\n this.visibleSince = null;\n this.emit('adstart', this.detail());\n this.update();\n }\n\n private quartile(n: number): void {\n const current = this.current;\n if (current === null || n <= current.quartiles) return;\n current.quartiles = n;\n const event = QUARTILE_EVENTS[n - 1];\n if (event !== undefined) this.track(current, event);\n this.emit('adprogress', { ...this.detail(), quartile: n });\n }\n\n /** The ad's own time: progressive quartiles, progress beacons, the stream's callbacks, viewability. */\n private followAd(current: Current): void {\n const media = this.player.media;\n const time = current.stitched\n ? this.player.media.currentTime - (current.entry?.start ?? 0)\n : media.currentTime;\n if (current.interrupt && !media.seeking) current.last = time;\n if (current.interrupt && Number.isFinite(media.duration) && media.duration > 0) {\n const reached = Math.floor((time / media.duration) * 4);\n for (let n = current.quartiles + 1; n <= Math.min(3, reached); n += 1) this.quartile(n);\n }\n const progress = current.ad?.tracking ?? [];\n progress.forEach((entry, i) => {\n if (\n entry.event !== 'progress' ||\n entry.offset === undefined ||\n current.sent.has(i) ||\n time < entry.offset\n )\n return;\n current.sent.add(i);\n this.send(expand(entry.url, this.macros(current)));\n });\n // DASH callback events of a List MPD, at their offsets in the asset.\n const tracking = current.entry?.assets[current.index]?.tracking ?? [];\n tracking.forEach((entry, i) => {\n const key = 1000 + i;\n if (current.sent.has(key) || time < entry.offset) return;\n current.sent.add(key);\n this.send(entry.url);\n });\n this.view(current);\n }\n\n private adPaused(media: HTMLVideoElement): void {\n const current = this.current;\n if (current === null || media.ended || current.paused) return;\n current.paused = true;\n this.track(current, 'pause');\n }\n\n private adResumed(media: HTMLVideoElement): void {\n const current = this.current;\n if (current === null || !current.paused || media !== this.player.media) return;\n current.paused = false;\n this.track(current, 'resume');\n }\n\n private adVolume(media: HTMLVideoElement): void {\n const current = this.current;\n if (current === null) return;\n this.track(current, media.muted ? 'mute' : 'unmute');\n }\n\n private adEnd(): void {\n const current = this.current;\n if (current === null || current.index < 0) return;\n if (!current.skipped) this.track(current, 'complete');\n if (current.ad !== undefined && !current.viewable) {\n for (const url of current.ad.notViewable) this.send(expand(url, this.macros(current)));\n }\n this.emit('adend', this.detail());\n }\n\n private breakEnd(): void {\n const current = this.current;\n if (current === null) return;\n // A break the stream plays has no asset of its own to end.\n if (current.stitched) this.adEnd();\n if (current.plan !== null) {\n current.plan.status = 'done';\n this.vmapTrack(current.plan, 'breakEnd');\n }\n const detail = this.detail();\n const id = current.plan?.id ?? current.entry?.id;\n if (id !== undefined) this.done.add(id);\n this.current = null;\n this.player.removeAttribute('ad');\n this.mark();\n this.observer?.disconnect();\n this.observer = null;\n this.emit('adbreakend', detail);\n this.update();\n }\n\n // ---- viewability -------------------------------------------------------\n\n /** MRC: half the player in view for two seconds in a row. */\n private observe(): void {\n if (typeof IntersectionObserver === 'undefined' || this.observer !== null) return;\n this.observer = new IntersectionObserver(\n (entries) => {\n const seen = entries.some((entry) => entry.intersectionRatio >= 0.5);\n this.visibleSince = seen ? (this.visibleSince ?? performance.now()) : null;\n },\n { threshold: [0, 0.5] },\n );\n this.observer.observe(this.player);\n }\n\n private view(current: Current): void {\n if (current.viewable || current.ad === undefined || this.visibleSince === null) return;\n if (performance.now() - this.visibleSince < 2000) return;\n current.viewable = true;\n for (const url of current.ad.viewable) this.send(expand(url, this.macros(current)));\n this.emit('adviewable', this.detail());\n }\n\n // ---- beacons and events ------------------------------------------------\n\n private macros(current: Current): MacroValues {\n const media = this.player.media;\n const offset = current.plan?.offset;\n return {\n mediaPlayhead: current.at,\n adPlayhead: media.currentTime,\n ...(current.file !== undefined ? { assetUri: current.file.url } : {}),\n breakPosition: offset === 'start' ? 1 : offset === 'end' ? 3 : 2,\n playerSize: [this.player.clientWidth, this.player.clientHeight],\n };\n }\n\n private track(current: Current, event: string): void {\n for (const entry of current.ad?.tracking ?? []) {\n if (entry.event === event) this.send(expand(entry.url, this.macros(current)));\n }\n }\n\n private vmapTrack(plan: Plan, event: string): void {\n for (const entry of plan.tracking) if (entry.event === event) this.send(entry.url);\n }\n\n private detail(): Record<string, unknown> {\n const current = this.current;\n return {\n breakId: current?.plan?.id ?? current?.entry?.id ?? null,\n index: (current?.index ?? 0) + 1,\n ad: current?.ad ?? null,\n stitched: current?.stitched ?? false,\n };\n }\n\n private emit(name: string, detail: object): void {\n this.player.dispatchEvent(new CustomEvent(name, { detail }));\n }\n\n private update(): void {\n for (const fn of [...this.watchers]) fn();\n }\n\n private reset(): void {\n const current = this.current;\n if (current !== null) this.player.removeAttribute('ad');\n this.current = null;\n this.plans = new Map();\n this.given = { urls: [], breaks: [] };\n this.done = new Set();\n this.own = new Set();\n this.player.breaks.set('ads', []);\n this.holding = false;\n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C/B,IAAI,SAAS,MAAM;GACnB,UAAU,SAAS,YAAY;EACjC;CACF;CAEQ,KAAK,MAAc,QAAsB;EAC/C,KAAK,OAAO,cAAc,IAAI,YAAY,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7D;CAEQ,SAAe;EACrB,KAAK,MAAM,MAAM,CAAC,GAAG,KAAK,QAAQ,GAAG,GAAG;CAC1C;CAEQ,QAAc;EAEpB,IADgB,KAAK,YACL,MAAM,KAAK,OAAO,gBAAgB,IAAI;EACtD,KAAK,UAAU;EACf,KAAK,wBAAQ,IAAI,IAAI;EACrB,KAAK,QAAQ;GAAE,MAAM,CAAC;GAAG,QAAQ,CAAC;EAAE;EACpC,KAAK,uBAAO,IAAI,IAAI;EACpB,KAAK,sBAAM,IAAI,IAAI;EACnB,KAAK,OAAO,OAAO,IAAI,OAAO,CAAC,CAAC;EAChC,KAAK,UAAU;EACf,KAAK,WAAW;EAChB,KAAK,UAAU,WAAW;EAC1B,KAAK,WAAW;EAChB,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,26 @@
1
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/asyncToGenerator.js
2
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
3
+ try {
4
+ var i = n[a](c), u = i.value;
5
+ } catch (n) {
6
+ e(n);
7
+ return;
8
+ }
9
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
10
+ }
11
+ function _asyncToGenerator(n) {
12
+ return function() {
13
+ var t = this, e = arguments;
14
+ return new Promise(function(r, o) {
15
+ var a = n.apply(t, e);
16
+ function _next(n) {
17
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18
+ }
19
+ function _throw(n) {
20
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
21
+ }
22
+ _next(void 0);
23
+ });
24
+ };
25
+ }
26
+ export { _asyncToGenerator as default };
@@ -0,0 +1,11 @@
1
+ import toPropertyKey from "./toPropertyKey.js";
2
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/defineProperty.js
3
+ function _defineProperty(e, r, t) {
4
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
+ value: t,
6
+ enumerable: !0,
7
+ configurable: !0,
8
+ writable: !0
9
+ }) : e[r] = t, e;
10
+ }
11
+ export { _defineProperty as default };
@@ -0,0 +1,24 @@
1
+ import _defineProperty from "./defineProperty.js";
2
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/objectSpread2.js
3
+ function ownKeys(e, r) {
4
+ var t = Object.keys(e);
5
+ if (Object.getOwnPropertySymbols) {
6
+ var o = Object.getOwnPropertySymbols(e);
7
+ r && (o = o.filter(function(r) {
8
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
9
+ })), t.push.apply(t, o);
10
+ }
11
+ return t;
12
+ }
13
+ function _objectSpread2(e) {
14
+ for (var r = 1; r < arguments.length; r++) {
15
+ var t = null != arguments[r] ? arguments[r] : {};
16
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
17
+ _defineProperty(e, r, t[r]);
18
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
19
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
20
+ });
21
+ }
22
+ return e;
23
+ }
24
+ export { _objectSpread2 as default };
@@ -0,0 +1,13 @@
1
+ import _typeof from "./typeof.js";
2
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPrimitive.js
3
+ function toPrimitive(t, e) {
4
+ if ("object" != _typeof(t) || !t) return t;
5
+ var r;
6
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
7
+ var i = r.call(t, e || "default");
8
+ if ("object" != _typeof(i)) return i;
9
+ throw new TypeError("@@toPrimitive must return a primitive value.");
10
+ }
11
+ return ("string" === e ? String : Number)(t);
12
+ }
13
+ export { toPrimitive as default };
@@ -0,0 +1,8 @@
1
+ import _typeof from "./typeof.js";
2
+ import toPrimitive from "./toPrimitive.js";
3
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/toPropertyKey.js
4
+ function toPropertyKey(t) {
5
+ var i = toPrimitive(t, "string");
6
+ return "symbol" == _typeof(i) ? i : i + "";
7
+ }
8
+ export { toPropertyKey as default };
@@ -0,0 +1,10 @@
1
+ // \0@oxc-project+runtime@0.158.0/helpers/esm/typeof.js
2
+ function _typeof(o) {
3
+ "@babel/helpers - typeof";
4
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
+ return typeof o;
6
+ } : function(o) {
7
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
+ }, _typeof(o);
9
+ }
10
+ export { _typeof as default };
@@ -0,0 +1,79 @@
1
+ import { Component } from "./component.js";
2
+ import { controllerFor } from "./controller.js";
3
+ import { clock, fill, style } from "./shared.js";
4
+ // src/ad-info.ts
5
+ /**
6
+ * <mbx-ad-info>: "Ad" or "Promo", or "Ad 2 of 3", and the time left in the
7
+ * break, at the top left while an ad plays. For a break the stream plays
8
+ * with the controls kept, a line under it shows how far it has played,
9
+ * since the seek bar still shows the programme. A screen reader hears "Ad
10
+ * break, 30 seconds" when a break starts. `label`, `label-count`,
11
+ * `label-promo`, `label-promo-count` and `label-break` replace the words.
12
+ */
13
+ var MbxAdInfo = class extends Component {
14
+ static get observedAttributes() {
15
+ return [
16
+ "label",
17
+ "label-count",
18
+ "label-promo",
19
+ "label-promo-count",
20
+ "label-break"
21
+ ];
22
+ }
23
+ constructor() {
24
+ super();
25
+ this.ads = null;
26
+ this.told = null;
27
+ const root = this.attachShadow({ mode: "open" });
28
+ const panel = document.createElement("div");
29
+ panel.setAttribute("part", "panel");
30
+ const row = document.createElement("div");
31
+ row.setAttribute("part", "row");
32
+ this.label = document.createElement("span");
33
+ this.label.setAttribute("part", "label");
34
+ this.time = document.createElement("span");
35
+ this.time.setAttribute("part", "time");
36
+ row.append(this.label, this.time);
37
+ this.line = document.createElement("div");
38
+ this.line.setAttribute("part", "line");
39
+ this.lineFill = document.createElement("div");
40
+ this.lineFill.setAttribute("part", "line-fill");
41
+ this.line.append(this.lineFill);
42
+ panel.append(row, this.line);
43
+ this.live = document.createElement("span");
44
+ this.live.setAttribute("part", "live");
45
+ this.live.setAttribute("role", "status");
46
+ root.append(style("top:0.875em;left:1em"), panel, this.live);
47
+ }
48
+ attach(player) {
49
+ this.ads = controllerFor(player);
50
+ this.keep(this.ads.watch(() => this.render()));
51
+ this.render();
52
+ }
53
+ detach() {
54
+ this.ads = null;
55
+ }
56
+ render() {
57
+ var _this$ads$state, _this$ads;
58
+ const state = (_this$ads$state = (_this$ads = this.ads) === null || _this$ads === void 0 ? void 0 : _this$ads.state) !== null && _this$ads$state !== void 0 ? _this$ads$state : null;
59
+ this.hidden = state === null;
60
+ if (state === null) {
61
+ this.told = null;
62
+ return;
63
+ }
64
+ const promo = state.role === "promo";
65
+ this.label.textContent = state.total > 1 ? fill(promo ? this.word("label-promo-count", "adPromoCount", "Promo {index} of {total}") : this.word("label-count", "adCount", "Ad {index} of {total}"), {
66
+ index: state.index,
67
+ total: state.total
68
+ }) : promo ? this.word("label-promo", "adPromo", "Promo") : this.word("label", "adLabel", "Ad");
69
+ this.time.textContent = Number.isFinite(state.remaining) ? `· ${clock(state.remaining)}` : "";
70
+ this.line.hidden = !state.free;
71
+ const share = Number.isFinite(state.duration) && state.duration > 0 ? Math.min(1, Math.max(0, state.currentTime / state.duration)) : 0;
72
+ this.lineFill.style.width = `${(share * 100).toFixed(2)}%`;
73
+ if (this.told !== state.breakId && Number.isFinite(state.remaining)) {
74
+ this.told = state.breakId;
75
+ this.live.textContent = fill(this.word("label-break", "adBreak", "Ad break, {seconds} seconds"), { seconds: Math.ceil(state.remaining) });
76
+ }
77
+ }
78
+ };
79
+ export { MbxAdInfo };
@@ -0,0 +1,53 @@
1
+ import { Component } from "./component.js";
2
+ import { controllerFor } from "./controller.js";
3
+ import { style } from "./shared.js";
4
+ // src/ad-link.ts
5
+ /**
6
+ * <mbx-ad-link>: an info button at the top right while an ad with a page of
7
+ * its own plays, named "Learn more" for a screen reader and in its tooltip.
8
+ * It opens the page in a new tab, pauses the ad, and reports the click.
9
+ * `label` replaces the words; a page's own SVG in `slot="icon"` replaces the
10
+ * glyph.
11
+ */
12
+ var MbxAdLink = class extends Component {
13
+ static get observedAttributes() {
14
+ return ["label"];
15
+ }
16
+ constructor() {
17
+ super();
18
+ this.ads = null;
19
+ const root = this.attachShadow({ mode: "open" });
20
+ this.button = document.createElement("button");
21
+ this.button.type = "button";
22
+ this.button.setAttribute("part", "icon-button");
23
+ const glyph = document.createElement("slot");
24
+ glyph.name = "icon";
25
+ glyph.innerHTML = "<svg part=\"icon\" viewBox=\"0 0 32 32\" aria-hidden=\"true\"><path fill-rule=\"evenodd\" d=\"M16 3a13 13 0 1 1 0 26a13 13 0 1 1 0-26zM16 5.5a10.5 10.5 0 1 0 0 21a10.5 10.5 0 1 0 0-21zM14.5 14h3v9h-3zM14.5 9h3v3h-3z\"/></svg>";
26
+ const disc = document.createElement("span");
27
+ disc.setAttribute("part", "disc");
28
+ disc.append(glyph);
29
+ this.button.append(disc);
30
+ this.button.addEventListener("click", () => {
31
+ var _this$ads;
32
+ return (_this$ads = this.ads) === null || _this$ads === void 0 ? void 0 : _this$ads.click();
33
+ });
34
+ root.append(style("top:0.5em;right:0.75em"), this.button);
35
+ }
36
+ attach(player) {
37
+ this.ads = controllerFor(player);
38
+ this.keep(this.ads.watch(() => this.render()));
39
+ this.render();
40
+ }
41
+ detach() {
42
+ this.ads = null;
43
+ }
44
+ render() {
45
+ var _this$ads$state, _this$ads2;
46
+ const state = (_this$ads$state = (_this$ads2 = this.ads) === null || _this$ads2 === void 0 ? void 0 : _this$ads2.state) !== null && _this$ads$state !== void 0 ? _this$ads$state : null;
47
+ this.hidden = (state === null || state === void 0 ? void 0 : state.clickThrough) === void 0;
48
+ const label = this.word("label", "adLearnMore", "Learn more");
49
+ this.button.setAttribute("aria-label", label);
50
+ this.button.title = label;
51
+ }
52
+ };
53
+ export { MbxAdLink };
@@ -0,0 +1,51 @@
1
+ import { Component } from "./component.js";
2
+ import { controllerFor } from "./controller.js";
3
+ // src/ad-progress.ts
4
+ /**
5
+ * <mbx-ad-progress>: how far the ad has played, as a bar in the seek bar's
6
+ * place while an ad plays, as YouTube shows it. Put it beside the seek bar,
7
+ * in the bar's seek row; it is hidden outside ads, and the seek bar during
8
+ * them.
9
+ */
10
+ const PROGRESS_CSS = ":host{flex:1;display:block}:host([hidden]){display:none}[part~=rail]{height:2.5em;margin:0 .5em;position:relative}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-ad,#f5c518);position:absolute;top:0;bottom:0;left:0}";
11
+ var MbxAdProgress = class extends Component {
12
+ constructor() {
13
+ super();
14
+ this.ads = null;
15
+ const root = this.attachShadow({ mode: "open" });
16
+ const style = document.createElement("style");
17
+ style.textContent = PROGRESS_CSS;
18
+ this.rail = document.createElement("div");
19
+ this.rail.setAttribute("part", "rail");
20
+ this.rail.setAttribute("role", "progressbar");
21
+ this.rail.setAttribute("aria-valuemin", "0");
22
+ this.rail.setAttribute("aria-valuemax", "100");
23
+ const track = document.createElement("div");
24
+ track.setAttribute("part", "track");
25
+ this.fill = document.createElement("div");
26
+ this.fill.setAttribute("part", "fill");
27
+ track.append(this.fill);
28
+ this.rail.append(track);
29
+ root.append(style, this.rail);
30
+ }
31
+ attach(player) {
32
+ var _this$parentElement;
33
+ if (((_this$parentElement = this.parentElement) === null || _this$parentElement === void 0 ? void 0 : _this$parentElement.localName) === "mbx-control-bar" && !this.hasAttribute("slot")) this.setAttribute("slot", "seek");
34
+ this.ads = controllerFor(player);
35
+ this.keep(this.ads.watch(() => this.render()));
36
+ this.render();
37
+ }
38
+ detach() {
39
+ this.ads = null;
40
+ }
41
+ render() {
42
+ var _this$ads$state, _this$ads;
43
+ const state = (_this$ads$state = (_this$ads = this.ads) === null || _this$ads === void 0 ? void 0 : _this$ads.state) !== null && _this$ads$state !== void 0 ? _this$ads$state : null;
44
+ this.hidden = state === null || state.free;
45
+ if (state === null) return;
46
+ const share = Number.isFinite(state.duration) && state.duration > 0 ? Math.min(1, Math.max(0, state.currentTime / state.duration)) : 0;
47
+ this.fill.style.width = `${(share * 100).toFixed(2)}%`;
48
+ this.rail.setAttribute("aria-valuenow", String(Math.round(share * 100)));
49
+ }
50
+ };
51
+ export { MbxAdProgress };
@@ -0,0 +1,68 @@
1
+ import { Component } from "./component.js";
2
+ import { controllerFor } from "./controller.js";
3
+ import { fill, style } from "./shared.js";
4
+ // src/ad-skip-button.ts
5
+ /**
6
+ * <mbx-ad-skip-button>: "Skip in 5" while the ad may not be skipped yet,
7
+ * then "Skip ad" or "Skip promo", at the bottom right above the bar. Hidden
8
+ * for an ad that cannot be skipped. A break the stream plays with the
9
+ * controls kept skips at once, to its end. `label`, `label-promo` and
10
+ * `label-wait` replace the words.
11
+ */
12
+ const SVG = "http://www.w3.org/2000/svg";
13
+ var MbxAdSkipButton = class extends Component {
14
+ static get observedAttributes() {
15
+ return [
16
+ "label",
17
+ "label-promo",
18
+ "label-wait"
19
+ ];
20
+ }
21
+ constructor() {
22
+ super();
23
+ this.ads = null;
24
+ const root = this.attachShadow({ mode: "open" });
25
+ this.button = document.createElement("button");
26
+ this.button.type = "button";
27
+ this.button.setAttribute("part", "button");
28
+ this.text = document.createElement("span");
29
+ this.chevron = document.createElementNS(SVG, "svg");
30
+ this.chevron.setAttribute("viewBox", "0 0 32 32");
31
+ this.chevron.setAttribute("aria-hidden", "true");
32
+ this.chevron.setAttribute("part", "chevron");
33
+ const path = document.createElementNS(SVG, "path");
34
+ path.setAttribute("d", "M12 8l8 8l-8 8");
35
+ path.setAttribute("fill", "none");
36
+ path.setAttribute("stroke", "currentColor");
37
+ path.setAttribute("stroke-width", "3");
38
+ path.setAttribute("stroke-linecap", "round");
39
+ path.setAttribute("stroke-linejoin", "round");
40
+ this.chevron.append(path);
41
+ this.button.append(this.text, this.chevron);
42
+ this.button.addEventListener("click", () => {
43
+ var _this$ads;
44
+ return (_this$ads = this.ads) === null || _this$ads === void 0 ? void 0 : _this$ads.skip();
45
+ });
46
+ root.append(style("right:1em;bottom:calc(var(--mbx-bar-rows, 6.5em) + 0.75em)"), this.button);
47
+ }
48
+ attach(player) {
49
+ this.ads = controllerFor(player);
50
+ this.keep(this.ads.watch(() => this.render()));
51
+ this.render();
52
+ }
53
+ detach() {
54
+ this.ads = null;
55
+ }
56
+ render() {
57
+ var _this$ads$state, _this$ads2, _state$skipIn;
58
+ const state = (_this$ads$state = (_this$ads2 = this.ads) === null || _this$ads2 === void 0 ? void 0 : _this$ads2.state) !== null && _this$ads$state !== void 0 ? _this$ads$state : null;
59
+ const skipIn = (_state$skipIn = state === null || state === void 0 ? void 0 : state.skipIn) !== null && _state$skipIn !== void 0 ? _state$skipIn : null;
60
+ this.hidden = state === null || skipIn === null;
61
+ if (state === null || skipIn === null) return;
62
+ const waiting = skipIn > 0;
63
+ this.button.disabled = waiting;
64
+ this.chevron.toggleAttribute("hidden", waiting);
65
+ this.text.textContent = waiting ? fill(this.word("label-wait", "adSkipIn", "Skip in {seconds}"), { seconds: Math.ceil(skipIn) }) : state.role === "promo" ? this.word("label-promo", "adSkipPromo", "Skip promo") : this.word("label", "adSkip", "Skip ad");
66
+ }
67
+ };
68
+ export { MbxAdSkipButton };
@@ -0,0 +1,42 @@
1
+ // src/beacons.ts
2
+ /** `HH:MM:SS.mmm`, the time form VAST macros take. */
3
+ function timecode(seconds) {
4
+ const ms = Math.max(0, Math.round(seconds * 1e3));
5
+ const pad = (n, width = 2) => String(n).padStart(width, "0");
6
+ return `${pad(Math.floor(ms / 36e5))}:${pad(Math.floor(ms / 6e4) % 60)}:${pad(Math.floor(ms / 1e3) % 60)}.${pad(ms % 1e3, 3)}`;
7
+ }
8
+ /** The beacon URL with every macro filled. A macro the player cannot fill becomes -1, as VAST 4.3 §6.1 asks. */
9
+ function expand(url, values) {
10
+ return url.replace(/\[([A-Z_]+)\]/g, (_, name) => {
11
+ const value = (() => {
12
+ switch (name) {
13
+ case "CACHEBUSTING": return String(Math.floor(1e7 + Math.random() * 89999999));
14
+ case "TIMESTAMP": return (/* @__PURE__ */ new Date()).toISOString();
15
+ case "ERRORCODE": return values.errorCode === void 0 ? void 0 : String(values.errorCode);
16
+ case "MEDIAPLAYHEAD":
17
+ case "CONTENTPLAYHEAD": return values.mediaPlayhead === void 0 ? void 0 : timecode(values.mediaPlayhead);
18
+ case "ADPLAYHEAD": return values.adPlayhead === void 0 ? void 0 : timecode(values.adPlayhead);
19
+ case "ASSETURI": return values.assetUri;
20
+ case "BREAKPOSITION": return values.breakPosition === void 0 ? void 0 : String(values.breakPosition);
21
+ case "PLAYERSIZE": return values.playerSize === void 0 ? void 0 : values.playerSize.join(",");
22
+ default: return;
23
+ }
24
+ })();
25
+ return encodeURIComponent(value !== null && value !== void 0 ? value : "-1");
26
+ });
27
+ }
28
+ /**
29
+ * Requests a beacon. `no-cors`, because an ad server rarely answers with
30
+ * CORS headers, and `keepalive`, so one sent as the page closes still
31
+ * goes.
32
+ */
33
+ function send(url) {
34
+ try {
35
+ fetch(url, {
36
+ mode: "no-cors",
37
+ keepalive: true,
38
+ credentials: "include"
39
+ }).catch(() => {});
40
+ } catch (_unused) {}
41
+ }
42
+ export { expand, send };
@@ -0,0 +1,94 @@
1
+ import { PLAYER, findPlayer } from "./host.js";
2
+ // src/component.ts
3
+ var Component = class extends HTMLElement {
4
+ constructor() {
5
+ super();
6
+ this.player = null;
7
+ this.offs = [];
8
+ this.epoch = 0;
9
+ }
10
+ connectedCallback() {
11
+ const found = findPlayer(this);
12
+ if (found === null) return;
13
+ this.epoch += 1;
14
+ const epoch = this.epoch;
15
+ const attach = () => {
16
+ if (epoch !== this.epoch || !this.isConnected) return;
17
+ customElements.upgrade(found);
18
+ if (!("media" in found)) return;
19
+ this.player = found;
20
+ this.listen(found, ["localechange"], () => {
21
+ this.render();
22
+ });
23
+ this.attach(this.player);
24
+ };
25
+ if ("media" in found) attach();
26
+ else customElements.whenDefined(PLAYER).then(attach);
27
+ }
28
+ disconnectedCallback() {
29
+ this.epoch += 1;
30
+ for (const off of this.offs) off();
31
+ this.offs = [];
32
+ const player = this.player;
33
+ if (player === null) return;
34
+ this.player = null;
35
+ this.detach(player);
36
+ }
37
+ attributeChangedCallback() {
38
+ if (this.player !== null) this.render();
39
+ }
40
+ /**
41
+ * A word the element shows: its `attribute` when the page set one, else
42
+ * the player's language's `id`, else `english`.
43
+ */
44
+ word(attribute, id, english) {
45
+ var _ref, _this$getAttribute, _this$player;
46
+ return (_ref = (_this$getAttribute = this.getAttribute(attribute)) !== null && _this$getAttribute !== void 0 ? _this$getAttribute : (_this$player = this.player) === null || _this$player === void 0 ? void 0 : _this$player.message(id)) !== null && _ref !== void 0 ? _ref : english;
47
+ }
48
+ /** Adds `fn` for every name on `target`, to be removed on detach. */
49
+ listen(target, names, fn) {
50
+ for (const name of names) target.addEventListener(name, fn);
51
+ this.offs.push(() => {
52
+ for (const name of names) target.removeEventListener(name, fn);
53
+ });
54
+ }
55
+ /** Keeps `off` to run on detach. */
56
+ keep(off) {
57
+ this.offs.push(off);
58
+ }
59
+ /**
60
+ * Runs `fn` over the current engine now and on every session change,
61
+ * running what the last call returned first, so a control's engine
62
+ * subscriptions live exactly as long as the session. Detach runs it too.
63
+ */
64
+ follow(player, fn) {
65
+ let off;
66
+ const run = () => {
67
+ off === null || off === void 0 || off();
68
+ off = fn(player.engine);
69
+ };
70
+ this.listen(player, ["sourcechange"], run);
71
+ this.offs.push(() => {
72
+ off === null || off === void 0 || off();
73
+ off = void 0;
74
+ });
75
+ run();
76
+ }
77
+ /** Runs `fn` when any of `names` changes on `target`, or under it with `subtree`, until detach. */
78
+ observe(target, names, fn, subtree = false) {
79
+ const observer = new MutationObserver(fn);
80
+ observer.observe(target, {
81
+ attributes: true,
82
+ attributeFilter: [...names],
83
+ subtree
84
+ });
85
+ this.offs.push(() => {
86
+ observer.disconnect();
87
+ });
88
+ }
89
+ /** The control left its player. Listeners are already gone; undo anything else. */
90
+ detach(_player) {}
91
+ /** Draws the current state. Called on every observed attribute change while attached. */
92
+ render() {}
93
+ };
94
+ export { Component };