stormcloud-video-player 0.8.53 → 0.8.55

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 (70) hide show
  1. package/dist/stormcloud-vp.min.js +1 -1
  2. package/lib/index.cjs +204 -110
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +2 -0
  5. package/lib/index.d.ts +2 -0
  6. package/lib/index.js +204 -110
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +69 -66
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +1 -1
  11. package/lib/player/AdConfigManager.cjs +38 -33
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +1 -1
  14. package/lib/player/AdTimingService.cjs +18 -25
  15. package/lib/player/AdTimingService.cjs.map +1 -1
  16. package/lib/player/AdTimingService.d.cts +1 -1
  17. package/lib/player/HlsEngine.cjs +86 -30
  18. package/lib/player/HlsEngine.cjs.map +1 -1
  19. package/lib/player/HlsEngine.d.cts +6 -1
  20. package/lib/player/PlaceholderLayer.cjs +1 -3
  21. package/lib/player/PlaceholderLayer.cjs.map +1 -1
  22. package/lib/player/PlayerControls.cjs.map +1 -1
  23. package/lib/player/PlayerControls.d.cts +1 -1
  24. package/lib/player/Scte35CueManager.cjs +2 -4
  25. package/lib/player/Scte35CueManager.cjs.map +1 -1
  26. package/lib/player/Scte35CueManager.d.cts +1 -1
  27. package/lib/player/Scte35Parser.cjs +6 -12
  28. package/lib/player/Scte35Parser.cjs.map +1 -1
  29. package/lib/player/Scte35Parser.d.cts +1 -1
  30. package/lib/player/StormcloudVideoPlayer.cjs +194 -96
  31. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/player/StormcloudVideoPlayer.d.cts +2 -1
  33. package/lib/player/playerTypes.cjs.map +1 -1
  34. package/lib/player/playerTypes.d.cts +1 -1
  35. package/lib/players/FilePlayer.cjs +17 -26
  36. package/lib/players/FilePlayer.cjs.map +1 -1
  37. package/lib/players/HlsPlayer.cjs +204 -110
  38. package/lib/players/HlsPlayer.cjs.map +1 -1
  39. package/lib/players/HlsPlayer.d.cts +1 -1
  40. package/lib/players/index.cjs +204 -110
  41. package/lib/players/index.cjs.map +1 -1
  42. package/lib/sdk/hlsAdPlayer.cjs +42 -19
  43. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  44. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  45. package/lib/sdk/pal.cjs +6 -9
  46. package/lib/sdk/pal.cjs.map +1 -1
  47. package/lib/{types-cTqIKw_D.d.cts → types-DpbgEvSH.d.cts} +1 -0
  48. package/lib/ui/StormcloudVideoPlayer.cjs +194 -96
  49. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  50. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  51. package/lib/utils/browserCompat.cjs +3 -6
  52. package/lib/utils/browserCompat.cjs.map +1 -1
  53. package/lib/utils/ctvVastSignals.cjs +3 -6
  54. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  55. package/lib/utils/devUrl.cjs.map +1 -1
  56. package/lib/utils/mqttClient.cjs +1 -3
  57. package/lib/utils/mqttClient.cjs.map +1 -1
  58. package/lib/utils/mqttConfig.cjs +1 -3
  59. package/lib/utils/mqttConfig.cjs.map +1 -1
  60. package/lib/utils/polyfills.cjs +4 -7
  61. package/lib/utils/polyfills.cjs.map +1 -1
  62. package/lib/utils/tracking.cjs +27 -20
  63. package/lib/utils/tracking.cjs.map +1 -1
  64. package/lib/utils/tracking.d.cts +1 -1
  65. package/lib/utils/vastEnvironmentSignals.cjs +7 -6
  66. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  67. package/lib/utils/vastEnvironmentSignals.d.cts +2 -1
  68. package/lib/utils/vastMacros.cjs +4 -2
  69. package/lib/utils/vastMacros.cjs.map +1 -1
  70. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/PlaceholderLayer.cjs","../../src/player/PlaceholderLayer.ts"],"names":["__defProp","Object","defineProperty","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__getOwnPropDesc","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","get","name","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","PlaceholderLayer_exports","PlaceholderLayer","module","exports","video","debug","ensureContainer","container","el","document","createElement","style","position","left","top","right","bottom","display","alignItems","justifyContent","pointerEvents","zIndex","backgroundColor","transition","opacity","parentElement","console","warn","appendChild","show"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,GAAAA,OAAAA,EAAYC,CAAAA,MAAOC,OAAAA,OAAc;AACrC,qCAAuBD,OAAOE,wBAAwB;8BAClDC,KAAAA,EAAAA,GAAoBH,EAAAA,KAAOI,mBAAmB;gCAD9CC;QAEAC,IAAAA,CAAAA,KAAAA,GAAAA,EAAeN,OAAOO,SAAS,CAACC,cAAc;QAC9CC,IAAAA,CAAAA,KAAAA,CAAW,EAAA,gBAACC,QAAQC;;;;;kCAEMC,KAAKD,GAAG,CAACE,KAAK;oBAAEC,IAAAA,CAAAA,OAAY,EAAA,EAAA;oBAAK;gBAC/D;gBACIC,IAAAA,KAAAA,GAAc,MAAA,aAAA,CAAA,CAACC,IAAIC,MAAMC,QAAQC;gBACnC,GAAA,CAAIF,IAAAA,CAAAA,GAAQ,CAAA,IAAA,GAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;wBAC7D,CAAA,IAAA,GAAA,0BAAA,2BAAA;;;4BAAA,GAAA,CAAIG,EAAAA,IAAJ;4BACH,IAAI,CAACd,EAAAA,WAAae,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCnB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EAAA,CAAA,aAAA,CAAA,WAAA,CAAA,IAAA,CAAA,SAAA;8BACF;8BAEA,IAAA,CAAKvB,EAAAA,GAAA,CAAMqB,CAAAA,YAAA,CAAcG,WAAA,CAAYpB;4BACrC,IAAA,CAAKD,SAAA,GAAYC;sBACnB;;;;;;YAEAqB,CAAAA,IAAAA,GAAAA,GAAAA;uCAAAA,SAAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/PlaceholderLayer.ts\nvar PlaceholderLayer_exports = {};\n__export(PlaceholderLayer_exports, {\n PlaceholderLayer: () => PlaceholderLayer\n});\nmodule.exports = __toCommonJS(PlaceholderLayer_exports);\nvar PlaceholderLayer = class {\n constructor(video, debug) {\n this.video = video;\n this.debug = debug;\n }\n ensureContainer() {\n if (this.container) {\n return;\n }\n const el = document.createElement(\"div\");\n el.style.position = \"absolute\";\n el.style.left = \"0\";\n el.style.top = \"0\";\n el.style.right = \"0\";\n el.style.bottom = \"0\";\n el.style.display = \"none\";\n el.style.alignItems = \"center\";\n el.style.justifyContent = \"center\";\n el.style.pointerEvents = \"none\";\n el.style.zIndex = \"5\";\n el.style.backgroundColor = \"#000\";\n el.style.transition = \"opacity 0.3s ease-in-out\";\n el.style.opacity = \"0\";\n if (!this.video.parentElement) {\n if (this.debug) {\n console.warn(\"[StormcloudVideoPlayer] Video element has no parent for placeholder container\");\n }\n return;\n }\n this.video.parentElement.appendChild(el);\n this.container = el;\n }\n show() {\n this.ensureContainer();\n if (!this.container) {\n return;\n }\n if (!this.video.muted) {\n this.video.muted = true;\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Muted video when showing placeholder\");\n }\n }\n const wasHidden = this.container.style.display === \"none\" || this.container.style.opacity === \"0\";\n if (wasHidden) {\n this.container.style.transition = \"none\";\n } else {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n this.container.style.backgroundColor = \"#000\";\n this.container.style.display = \"flex\";\n this.container.offsetHeight;\n this.container.style.opacity = \"1\";\n this.container.style.pointerEvents = \"auto\";\n if (wasHidden) {\n requestAnimationFrame(() => {\n if (this.container) {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n });\n }\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)\");\n }\n }\n hide() {\n if (!this.container) {\n return;\n }\n this.container.style.opacity = \"0\";\n setTimeout(() => {\n if (this.container) {\n this.container.style.display = \"none\";\n this.container.style.pointerEvents = \"none\";\n this.container.style.backgroundColor = \"#000\";\n }\n }, 300);\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Hiding placeholder layer\");\n }\n }\n destroy() {\n if (this.container) {\n if (this.container.parentElement) {\n this.container.parentElement.removeChild(this.container);\n }\n this.container = void 0;\n }\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n PlaceholderLayer\n});\n","export class PlaceholderLayer {\n private container: HTMLDivElement | undefined;\n private debug: boolean;\n private video: HTMLVideoElement;\n\n constructor(video: HTMLVideoElement, debug: boolean) {\n this.video = video;\n this.debug = debug;\n }\n\n private ensureContainer(): void {\n if (this.container) {\n return;\n }\n\n const el = document.createElement(\"div\");\n el.style.position = \"absolute\";\n el.style.left = \"0\";\n el.style.top = \"0\";\n el.style.right = \"0\";\n el.style.bottom = \"0\";\n el.style.display = \"none\";\n el.style.alignItems = \"center\";\n el.style.justifyContent = \"center\";\n el.style.pointerEvents = \"none\";\n el.style.zIndex = \"5\";\n el.style.backgroundColor = \"#000\";\n el.style.transition = \"opacity 0.3s ease-in-out\";\n el.style.opacity = \"0\";\n\n if (!this.video.parentElement) {\n if (this.debug) {\n console.warn(\"[StormcloudVideoPlayer] Video element has no parent for placeholder container\");\n }\n return;\n }\n\n this.video.parentElement.appendChild(el);\n this.container = el;\n }\n\n show(): void {\n this.ensureContainer();\n\n if (!this.container) {\n return;\n }\n\n if (!this.video.muted) {\n this.video.muted = true;\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Muted video when showing placeholder\");\n }\n }\n\n const wasHidden = this.container.style.display === \"none\" || this.container.style.opacity === \"0\";\n if (wasHidden) {\n this.container.style.transition = \"none\";\n } else {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n\n this.container.style.backgroundColor = \"#000\";\n this.container.style.display = \"flex\";\n this.container.offsetHeight;\n this.container.style.opacity = \"1\";\n this.container.style.pointerEvents = \"auto\";\n\n if (wasHidden) {\n requestAnimationFrame(() => {\n if (this.container) {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n });\n }\n\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)\");\n }\n }\n\n hide(): void {\n if (!this.container) {\n return;\n }\n\n this.container.style.opacity = \"0\";\n setTimeout(() => {\n if (this.container) {\n this.container.style.display = \"none\";\n this.container.style.pointerEvents = \"none\";\n this.container.style.backgroundColor = \"#000\";\n }\n }, 300);\n\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Hiding placeholder layer\");\n }\n }\n\n destroy(): void {\n if (this.container) {\n if (this.container.parentElement) {\n this.container.parentElement.removeChild(this.container);\n }\n this.container = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/PlaceholderLayer.cjs"],"names":[],"mappings":"AAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/PlaceholderLayer.ts\nvar PlaceholderLayer_exports = {};\n__export(PlaceholderLayer_exports, {\n PlaceholderLayer: () => PlaceholderLayer\n});\nmodule.exports = __toCommonJS(PlaceholderLayer_exports);\nvar PlaceholderLayer = class {\n constructor(video, debug) {\n this.video = video;\n this.debug = debug;\n }\n ensureContainer() {\n if (this.container) {\n return;\n }\n const el = document.createElement(\"div\");\n el.style.position = \"absolute\";\n el.style.left = \"0\";\n el.style.top = \"0\";\n el.style.right = \"0\";\n el.style.bottom = \"0\";\n el.style.display = \"none\";\n el.style.alignItems = \"center\";\n el.style.justifyContent = \"center\";\n el.style.pointerEvents = \"none\";\n el.style.zIndex = \"5\";\n el.style.backgroundColor = \"#000\";\n el.style.transition = \"opacity 0.3s ease-in-out\";\n el.style.opacity = \"0\";\n if (!this.video.parentElement) {\n if (this.debug) {\n console.warn(\"[StormcloudVideoPlayer] Video element has no parent for placeholder container\");\n }\n return;\n }\n this.video.parentElement.appendChild(el);\n this.container = el;\n }\n show() {\n this.ensureContainer();\n if (!this.container) {\n return;\n }\n if (!this.video.muted) {\n this.video.muted = true;\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Muted video when showing placeholder\");\n }\n }\n const wasHidden = this.container.style.display === \"none\" || this.container.style.opacity === \"0\";\n if (wasHidden) {\n this.container.style.transition = \"none\";\n } else {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n this.container.style.backgroundColor = \"#000\";\n this.container.style.display = \"flex\";\n this.container.offsetHeight;\n this.container.style.opacity = \"1\";\n this.container.style.pointerEvents = \"auto\";\n if (wasHidden) {\n requestAnimationFrame(() => {\n if (this.container) {\n this.container.style.transition = \"opacity 0.3s ease-in-out\";\n }\n });\n }\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Showing placeholder layer (between content and ad layer)\");\n }\n }\n hide() {\n if (!this.container) {\n return;\n }\n this.container.style.opacity = \"0\";\n setTimeout(() => {\n if (this.container) {\n this.container.style.display = \"none\";\n this.container.style.pointerEvents = \"none\";\n this.container.style.backgroundColor = \"#000\";\n }\n }, 300);\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Hiding placeholder layer\");\n }\n }\n destroy() {\n if (this.container) {\n if (this.container.parentElement) {\n this.container.parentElement.removeChild(this.container);\n }\n this.container = void 0;\n }\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n PlaceholderLayer\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/PlayerControls.cjs","../../src/player/PlayerControls.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","__getOwnPropNames","getOwnPropertyDescriptor","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","value","mod","PlayerControls_exports","getAdAudioVolume","getVolume","isFullscreen","isMuted","resizePlayer","setMuted","setVolume","toggleFullscreen","toggleMute","exports","__toCommonJS","adPlayer","getOriginalMutedState","getOriginalVolume","isAdPlaying","newMutedState","restoreVolume","updateOriginalMutedState","video","volume","setAdVolume","debug","console","log","muted","Promise","resolve","reject","document","fullscreenElement","container","Error","requestFullscreen","then","catch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,CAAA,iBAAA;QACb3B,SAASM,wBAAA,CAAyBO,OAAON,MAAMC,MAAM;QACrDR,CAAAA,QAASS,KAAAA,KAAAA,CAAA,CAAYI,QAAQ,EAAA,EAAI,GAAA;UACjC,IAAIH,CAAAA,MAAO;gBACTC,GAAAA,CAAAA,IAAQC,GAAA,CAAI,sDAAsD;kBAChEC,OAAAA;cACF,MAAA,SAAA,WAAA,IAAA;YACF,QAAA,MAAA,WAAA,IAAA;YACA,SAAA,MAAA,YAAA,IAAA;QACF,IAAA,OAAA;YAEAb,OAASM,CAAAA,GAAAA,CACLI,MAAO,aADF,CAAyBG,OAAON,MAAMC,MAAM,YAC1C,OAAA,OAAA,KAAA,OAAA;QAEX;QACF,SAAA,MAAA,CAAA,OAAA;IAEO,OAASb,UACdY,KAAA,EACAP,QAAA,EACAQ,MAAA,EACAE,KAAA;IAEA,IAAMkB,gBAAgBC,KAAKC,GAAA,CAAI,GAAGD,KAAKE,GAAA,CAAI,GAAGvB;IAC9C,IAAMmB,YAAY3B,SAASG,WAAA,qBAAA;IAE3B,CAAA,CAAA,EAAIwB,KAAAA,MAAW,CAAA,GAAA;4BACb3B,SAASS,WAAA,CAAYmB;qBACrB5B,SAASM,wBAAA,CAAyBsB,kBAAkB,GAAGA;wBACvD,IAAIlB,OAAO;uBACTC,QAAQC,GAAA,CAAI,uDAAuD;gCACjEJ,QAAQoB;wBACV;qBACF;wBACF,OAAO;sBACLrB,MAAMC,MAAA,GAASoB;SACfrB,MAAMM,KAAA,GAAQe,kBAAkB","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/PlayerControls.ts\nvar PlayerControls_exports = {};\n__export(PlayerControls_exports, {\n getAdAudioVolume: () => getAdAudioVolume,\n getVolume: () => getVolume,\n isFullscreen: () => isFullscreen,\n isMuted: () => isMuted,\n resizePlayer: () => resizePlayer,\n setMuted: () => setMuted,\n setVolume: () => setVolume,\n toggleFullscreen: () => toggleFullscreen,\n toggleMute: () => toggleMute\n});\nmodule.exports = __toCommonJS(PlayerControls_exports);\nfunction getAdAudioVolume(adPlayer) {\n return adPlayer.getOriginalMutedState() ? 0 : adPlayer.getOriginalVolume();\n}\nfunction toggleMute(video, adPlayer, debug) {\n if (adPlayer.isAdPlaying()) {\n const newMutedState = !adPlayer.getOriginalMutedState();\n const restoreVolume = adPlayer.getOriginalVolume() || 1;\n adPlayer.updateOriginalMutedState(newMutedState, video.volume);\n adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:\",\n newMutedState\n );\n }\n } else {\n video.muted = !video.muted;\n adPlayer.updateOriginalMutedState(video.muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Muted:\", video.muted);\n }\n }\n}\nfunction toggleFullscreen(video, debug) {\n return new Promise((resolve, reject) => {\n if (!document.fullscreenElement) {\n const container = video.parentElement;\n if (!container) {\n reject(new Error(\"No parent container found for fullscreen\"));\n return;\n }\n container.requestFullscreen().then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Entered fullscreen\");\n }\n resolve();\n }).catch((err) => {\n if (debug) {\n console.error(\"[StormcloudVideoPlayer] Fullscreen error:\", err);\n }\n reject(err);\n });\n } else {\n document.exitFullscreen().then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Exited fullscreen\");\n }\n resolve();\n }).catch((err) => {\n if (debug) {\n console.error(\n \"[StormcloudVideoPlayer] Exit fullscreen error:\",\n err\n );\n }\n reject(err);\n });\n }\n });\n}\nfunction isMuted(video, adPlayer) {\n if (adPlayer.isAdPlaying()) {\n return adPlayer.getOriginalMutedState();\n }\n return video.muted;\n}\nfunction setMuted(video, adPlayer, muted, debug) {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying && muted === video.muted) {\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] setMuted reflective update during ad ignored\",\n { muted }\n );\n }\n return;\n }\n video.muted = muted;\n if (adPlaying) {\n adPlayer.updateOriginalMutedState(muted, video.volume);\n adPlayer.setAdVolume(muted ? 0 : 1);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted applied during ad\", {\n muted\n });\n }\n return;\n }\n adPlayer.updateOriginalMutedState(muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted called:\", muted);\n }\n}\nfunction setVolume(video, adPlayer, volume, debug) {\n const clampedVolume = Math.max(0, Math.min(1, volume));\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n adPlayer.setAdVolume(clampedVolume);\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume applied during ad\", {\n volume: clampedVolume\n });\n }\n } else {\n video.volume = clampedVolume;\n video.muted = clampedVolume === 0;\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume called:\", clampedVolume);\n }\n }\n}\nfunction getVolume(video, adPlayer) {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n return adPlayer.getAdVolume();\n }\n return video.volume;\n}\nfunction isFullscreen() {\n return !!document.fullscreenElement;\n}\nfunction resizePlayer(video, adPlayer, debug) {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Resizing player\");\n }\n if (adPlayer && adPlayer.isAdPlaying()) {\n const width = video.clientWidth || 640;\n const height = video.clientHeight || 480;\n if (debug) {\n console.log(\n `[StormcloudVideoPlayer] Resizing ads manager to ${width}x${height}`\n );\n }\n adPlayer.resize(width, height);\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n getAdAudioVolume,\n getVolume,\n isFullscreen,\n isMuted,\n resizePlayer,\n setMuted,\n setVolume,\n toggleFullscreen,\n toggleMute\n});\n","import type { AdController } from \"../types\";\n\nexport function getAdAudioVolume(adPlayer: AdController): number {\n return adPlayer.getOriginalMutedState() ? 0 : adPlayer.getOriginalVolume();\n}\n\nexport function toggleMute(\n video: HTMLVideoElement,\n adPlayer: AdController,\n debug: boolean\n): void {\n if (adPlayer.isAdPlaying()) {\n const newMutedState = !adPlayer.getOriginalMutedState();\n const restoreVolume = adPlayer.getOriginalVolume() || 1;\n\n adPlayer.updateOriginalMutedState(newMutedState, video.volume);\n adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);\n\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:\",\n newMutedState\n );\n }\n } else {\n video.muted = !video.muted;\n adPlayer.updateOriginalMutedState(video.muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Muted:\", video.muted);\n }\n }\n}\n\nexport function toggleFullscreen(\n video: HTMLVideoElement,\n debug: boolean\n): Promise<void> {\n return new Promise((resolve, reject) => {\n if (!document.fullscreenElement) {\n const container = video.parentElement;\n if (!container) {\n reject(new Error(\"No parent container found for fullscreen\"));\n return;\n }\n container\n .requestFullscreen()\n .then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Entered fullscreen\");\n }\n resolve();\n })\n .catch((err) => {\n if (debug) {\n console.error(\"[StormcloudVideoPlayer] Fullscreen error:\", err);\n }\n reject(err);\n });\n } else {\n document\n .exitFullscreen()\n .then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Exited fullscreen\");\n }\n resolve();\n })\n .catch((err) => {\n if (debug) {\n console.error(\n \"[StormcloudVideoPlayer] Exit fullscreen error:\",\n err\n );\n }\n reject(err);\n });\n }\n });\n}\n\nexport function isMuted(\n video: HTMLVideoElement,\n adPlayer: AdController\n): boolean {\n if (adPlayer.isAdPlaying()) {\n return adPlayer.getOriginalMutedState();\n }\n return video.muted;\n}\n\nexport function setMuted(\n video: HTMLVideoElement,\n adPlayer: AdController,\n muted: boolean,\n debug: boolean\n): void {\n const adPlaying = adPlayer.isAdPlaying();\n\n if (adPlaying && muted === video.muted) {\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] setMuted reflective update during ad ignored\",\n { muted }\n );\n }\n return;\n }\n\n video.muted = muted;\n\n if (adPlaying) {\n adPlayer.updateOriginalMutedState(muted, video.volume);\n adPlayer.setAdVolume(muted ? 0 : 1);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted applied during ad\", {\n muted,\n });\n }\n return;\n }\n\n adPlayer.updateOriginalMutedState(muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted called:\", muted);\n }\n}\n\nexport function setVolume(\n video: HTMLVideoElement,\n adPlayer: AdController,\n volume: number,\n debug: boolean\n): void {\n const clampedVolume = Math.max(0, Math.min(1, volume));\n const adPlaying = adPlayer.isAdPlaying();\n\n if (adPlaying) {\n adPlayer.setAdVolume(clampedVolume);\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume applied during ad\", {\n volume: clampedVolume,\n });\n }\n } else {\n video.volume = clampedVolume;\n video.muted = clampedVolume === 0;\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume called:\", clampedVolume);\n }\n }\n}\n\nexport function getVolume(\n video: HTMLVideoElement,\n adPlayer: AdController\n): number {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n return adPlayer.getAdVolume();\n }\n return video.volume;\n}\n\nexport function isFullscreen(): boolean {\n return !!document.fullscreenElement;\n}\n\nexport function resizePlayer(\n video: HTMLVideoElement,\n adPlayer: AdController,\n debug: boolean\n): void {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Resizing player\");\n }\n\n if (adPlayer && adPlayer.isAdPlaying()) {\n const width = video.clientWidth || 640;\n const height = video.clientHeight || 480;\n\n if (debug) {\n console.log(\n `[StormcloudVideoPlayer] Resizing ads manager to ${width}x${height}`\n );\n }\n\n adPlayer.resize(width, height);\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/PlayerControls.cjs","../../src/player/PlayerControls.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","__getOwnPropNames","getOwnPropertyDescriptor","getOwnPropertyNames","__hasOwnProp","__export","prototype","hasOwnProperty","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","value","mod","PlayerControls_exports","getAdAudioVolume","getVolume","isFullscreen","isMuted","resizePlayer","setMuted","setVolume","toggleFullscreen","toggleMute","exports","__toCommonJS","adPlayer","getOriginalMutedState","getOriginalVolume","isAdPlaying","newMutedState","restoreVolume","updateOriginalMutedState","video","volume","setAdVolume","debug","console","log"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACA,EAAIA,KAAAA,MAAAA,GAAAA,qBAAAA,IAAAA,MAAAA,IAAYC,IAAAA,GAAOC,CAAAA,aAAc;MACrC,EAAIC,EAAAA,IAAAA,EAAAA,CAAAA,OAAAA,qCAAAA,MAAAA,GAAAA,KACAC,MAAAA,CAD0BC,GAC1BD,QAAAA,EAAoBH,IAAAA,CAAAA,MAD8B,GAAA,YAAA;;;;;;;oBACvBK,GAAAA,CAAAA,EAAAA,GAAAA,CAAAA;kBAAAA,EAAAA,CAAAA,CAAmB,QAAA,GAAA,CAAA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AAC,EAAAA,WAAAX;4CAEgBC,IAAAA,CAAAA,GAAAA,KAAAA,CACPW,EADwBA,MACfC,EADe,mBACf,KAA0B,IAAID,SAASE,GACzD,cADyD;iCAQnDF,SAASG,WAAA,CAAA,CAAA,EAAe,gBAAA,GAAA;oCAC1B,IAAMC,GAAAA,aAAgB,CAACJ,SAASC,qBAAA;+BAChC,GAAA,CAAMI,gBAAgBL,SAASE,iBAAA,MAAuB,OAAA;oCAEtDF,IAAAA,KAASM,wBAAA,CAAyBF,eAAeG,MAAMC,MAAM;4BAC7DR,SAASS,WAAA,CAAYL,gBAAgB,IAAIC;yBAEzC,IAAIK,OAAO;kCACTC,KAAAA,GAAQC,EAAAA,CAAA,CACN,QAAA,gEACAR;4BAEJ,MAAA,CAAA,EAAA,SAAA,IAAA;aACF,EAAA,KAAO,GAAA,MAAA,YAAA,SAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/PlayerControls.ts\nvar PlayerControls_exports = {};\n__export(PlayerControls_exports, {\n getAdAudioVolume: () => getAdAudioVolume,\n getVolume: () => getVolume,\n isFullscreen: () => isFullscreen,\n isMuted: () => isMuted,\n resizePlayer: () => resizePlayer,\n setMuted: () => setMuted,\n setVolume: () => setVolume,\n toggleFullscreen: () => toggleFullscreen,\n toggleMute: () => toggleMute\n});\nmodule.exports = __toCommonJS(PlayerControls_exports);\nfunction getAdAudioVolume(adPlayer) {\n return adPlayer.getOriginalMutedState() ? 0 : adPlayer.getOriginalVolume();\n}\nfunction toggleMute(video, adPlayer, debug) {\n if (adPlayer.isAdPlaying()) {\n const newMutedState = !adPlayer.getOriginalMutedState();\n const restoreVolume = adPlayer.getOriginalVolume() || 1;\n adPlayer.updateOriginalMutedState(newMutedState, video.volume);\n adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:\",\n newMutedState\n );\n }\n } else {\n video.muted = !video.muted;\n adPlayer.updateOriginalMutedState(video.muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Muted:\", video.muted);\n }\n }\n}\nfunction toggleFullscreen(video, debug) {\n return new Promise((resolve, reject) => {\n if (!document.fullscreenElement) {\n const container = video.parentElement;\n if (!container) {\n reject(new Error(\"No parent container found for fullscreen\"));\n return;\n }\n container.requestFullscreen().then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Entered fullscreen\");\n }\n resolve();\n }).catch((err) => {\n if (debug) {\n console.error(\"[StormcloudVideoPlayer] Fullscreen error:\", err);\n }\n reject(err);\n });\n } else {\n document.exitFullscreen().then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Exited fullscreen\");\n }\n resolve();\n }).catch((err) => {\n if (debug) {\n console.error(\n \"[StormcloudVideoPlayer] Exit fullscreen error:\",\n err\n );\n }\n reject(err);\n });\n }\n });\n}\nfunction isMuted(video, adPlayer) {\n if (adPlayer.isAdPlaying()) {\n return adPlayer.getOriginalMutedState();\n }\n return video.muted;\n}\nfunction setMuted(video, adPlayer, muted, debug) {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying && muted === video.muted) {\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] setMuted reflective update during ad ignored\",\n { muted }\n );\n }\n return;\n }\n video.muted = muted;\n if (adPlaying) {\n adPlayer.updateOriginalMutedState(muted, video.volume);\n adPlayer.setAdVolume(muted ? 0 : 1);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted applied during ad\", {\n muted\n });\n }\n return;\n }\n adPlayer.updateOriginalMutedState(muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted called:\", muted);\n }\n}\nfunction setVolume(video, adPlayer, volume, debug) {\n const clampedVolume = Math.max(0, Math.min(1, volume));\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n adPlayer.setAdVolume(clampedVolume);\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume applied during ad\", {\n volume: clampedVolume\n });\n }\n } else {\n video.volume = clampedVolume;\n video.muted = clampedVolume === 0;\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume called:\", clampedVolume);\n }\n }\n}\nfunction getVolume(video, adPlayer) {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n return adPlayer.getAdVolume();\n }\n return video.volume;\n}\nfunction isFullscreen() {\n return !!document.fullscreenElement;\n}\nfunction resizePlayer(video, adPlayer, debug) {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Resizing player\");\n }\n if (adPlayer && adPlayer.isAdPlaying()) {\n const width = video.clientWidth || 640;\n const height = video.clientHeight || 480;\n if (debug) {\n console.log(\n `[StormcloudVideoPlayer] Resizing ads manager to ${width}x${height}`\n );\n }\n adPlayer.resize(width, height);\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n getAdAudioVolume,\n getVolume,\n isFullscreen,\n isMuted,\n resizePlayer,\n setMuted,\n setVolume,\n toggleFullscreen,\n toggleMute\n});\n","import type { AdController } from \"../types\";\n\nexport function getAdAudioVolume(adPlayer: AdController): number {\n return adPlayer.getOriginalMutedState() ? 0 : adPlayer.getOriginalVolume();\n}\n\nexport function toggleMute(\n video: HTMLVideoElement,\n adPlayer: AdController,\n debug: boolean\n): void {\n if (adPlayer.isAdPlaying()) {\n const newMutedState = !adPlayer.getOriginalMutedState();\n const restoreVolume = adPlayer.getOriginalVolume() || 1;\n\n adPlayer.updateOriginalMutedState(newMutedState, video.volume);\n adPlayer.setAdVolume(newMutedState ? 0 : restoreVolume);\n\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] Mute toggle during ad - immediately applied:\",\n newMutedState\n );\n }\n } else {\n video.muted = !video.muted;\n adPlayer.updateOriginalMutedState(video.muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Muted:\", video.muted);\n }\n }\n}\n\nexport function toggleFullscreen(\n video: HTMLVideoElement,\n debug: boolean\n): Promise<void> {\n return new Promise((resolve, reject) => {\n if (!document.fullscreenElement) {\n const container = video.parentElement;\n if (!container) {\n reject(new Error(\"No parent container found for fullscreen\"));\n return;\n }\n container\n .requestFullscreen()\n .then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Entered fullscreen\");\n }\n resolve();\n })\n .catch((err) => {\n if (debug) {\n console.error(\"[StormcloudVideoPlayer] Fullscreen error:\", err);\n }\n reject(err);\n });\n } else {\n document\n .exitFullscreen()\n .then(() => {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Exited fullscreen\");\n }\n resolve();\n })\n .catch((err) => {\n if (debug) {\n console.error(\n \"[StormcloudVideoPlayer] Exit fullscreen error:\",\n err\n );\n }\n reject(err);\n });\n }\n });\n}\n\nexport function isMuted(\n video: HTMLVideoElement,\n adPlayer: AdController\n): boolean {\n if (adPlayer.isAdPlaying()) {\n return adPlayer.getOriginalMutedState();\n }\n return video.muted;\n}\n\nexport function setMuted(\n video: HTMLVideoElement,\n adPlayer: AdController,\n muted: boolean,\n debug: boolean\n): void {\n const adPlaying = adPlayer.isAdPlaying();\n\n if (adPlaying && muted === video.muted) {\n if (debug) {\n console.log(\n \"[StormcloudVideoPlayer] setMuted reflective update during ad ignored\",\n { muted }\n );\n }\n return;\n }\n\n video.muted = muted;\n\n if (adPlaying) {\n adPlayer.updateOriginalMutedState(muted, video.volume);\n adPlayer.setAdVolume(muted ? 0 : 1);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted applied during ad\", {\n muted,\n });\n }\n return;\n }\n\n adPlayer.updateOriginalMutedState(muted, video.volume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setMuted called:\", muted);\n }\n}\n\nexport function setVolume(\n video: HTMLVideoElement,\n adPlayer: AdController,\n volume: number,\n debug: boolean\n): void {\n const clampedVolume = Math.max(0, Math.min(1, volume));\n const adPlaying = adPlayer.isAdPlaying();\n\n if (adPlaying) {\n adPlayer.setAdVolume(clampedVolume);\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume applied during ad\", {\n volume: clampedVolume,\n });\n }\n } else {\n video.volume = clampedVolume;\n video.muted = clampedVolume === 0;\n adPlayer.updateOriginalMutedState(clampedVolume === 0, clampedVolume);\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] setVolume called:\", clampedVolume);\n }\n }\n}\n\nexport function getVolume(\n video: HTMLVideoElement,\n adPlayer: AdController\n): number {\n const adPlaying = adPlayer.isAdPlaying();\n if (adPlaying) {\n return adPlayer.getAdVolume();\n }\n return video.volume;\n}\n\nexport function isFullscreen(): boolean {\n return !!document.fullscreenElement;\n}\n\nexport function resizePlayer(\n video: HTMLVideoElement,\n adPlayer: AdController,\n debug: boolean\n): void {\n if (debug) {\n console.log(\"[StormcloudVideoPlayer] Resizing player\");\n }\n\n if (adPlayer && adPlayer.isAdPlaying()) {\n const width = video.clientWidth || 640;\n const height = video.clientHeight || 480;\n\n if (debug) {\n console.log(\n `[StormcloudVideoPlayer] Resizing ads manager to ${width}x${height}`\n );\n }\n\n adPlayer.resize(width, height);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { A as AdController } from '../types-cTqIKw_D.cjs';
1
+ import { A as AdController } from '../types-DpbgEvSH.cjs';
2
2
 
3
3
  declare function getAdAudioVolume(adPlayer: AdController): number;
4
4
  declare function toggleMute(video: HTMLVideoElement, adPlayer: AdController, debug: boolean): void;
@@ -8,9 +8,7 @@ function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
10
  function _class_call_check(instance, Constructor) {
11
- if (!(instance instanceof Constructor)) {
12
- throw new TypeError("Cannot call a class as a function");
13
- }
11
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
14
12
  }
15
13
  function _defineProperties(target, props) {
16
14
  for(var i = 0; i < props.length; i++){
@@ -51,7 +49,7 @@ function _iterable_to_array_limit(arr, i) {
51
49
  return _arr;
52
50
  }
53
51
  function _non_iterable_rest() {
54
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55
53
  }
56
54
  function _sliced_to_array(arr, i) {
57
55
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/Scte35CueManager.cjs","../../src/player/Scte35CueManager.ts","../../src/player/Scte35Parser.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","Scte35CueManager_exports","Scte35CueManager","frag","module","exports","getFragmentStartSeconds","candidates","start","startPTS","candidate","Number","isFinite","debug","callbacks","pendingScte35Cues","Map","recentScte35CueKeys","recentScte35CueLimit","tsScte35Pids","Set","pmtPids","processedTsScte35Sections","pendingScte35CueKey","pendingScte35CueKeyValue","activeScte35BreakKey","activeScte35BreakKeyValue","scheduledScte35BreakKey","scheduledScte35BreakKeyValue","createScte35CueContext","source","readiness","context","sn","fragmentSn","fragmentStartSec","fragmentStartSeconds","onScte35Cue","marker","cue","createScte35Cue","pendingKey","getPendingScte35CueKey","set","trimRecentScte35CueMaps","type","onEarlyStartCue","shouldAcceptScte35EndCue","console","log"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBACIA,QAAAA,EAAYC,OAAOC,CAAAA,GAAAA,KAAAA,EAAAA,GAAc;gBACjCC,mBAAmBF,OAAOG,wBAAwB;gBAClDC,IAAAA,cAAoBJ,KAAAA,EAAOK,mBAAmB,GAAA;gBAC9CC,IAAAA,WAAeN,OAAOO,GAAAA,KAAAA,CAAS,CAACC,CAAAA,aAAc;oBAC9CC,QAAAA,CAAW,kBAACC,CAAAA,GAAAA,IAAQC;gBACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;oBAAEC,GAAAA,EAAKF,GAAG,CAACC,KAAK;kBAAEE,YAAY;;;;8BAAK,UAAA,MAAA,EAAA,OAAA;gBAC/D,IAAA,MAAA,IAAA,CAAA,eAAA,CAAA,QAAA;gBACIC,IAAAA,QAAc,KAAA,IAAA,CAAA,WAACC,IAAIC,MAAMC,CAAAA,CAAAA,MAAQC;gBACnC,IAAIF,QAAQ,CAAA,OAAOA,CAAAA,KAAAA,SAAAA,sBAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;0BAC7D,gBAAA,CAAA,GAAA,CAAA,Y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,sBAAA,CAAuBH;8BAE/C,IAAIP,QAAQD,SAAA,KAAc,SAAS;kCACjC,IAAA,CAAKhB,GAAAA,CAAAA,MAAAA,CAAAA,MAAA,CAAkB4B,GAAA,CAAIF,YAAYF;gCACvC,IAAA,CAAKK,uBAAA;8BAEL,IAAIN,OAAOO,IAAA,KAAS,SAAS;;;;kDAC3B,GAAA,CAAA,CAAK/B,CAAAA,QAAA,CAAUgC,eAAA,CAAgBR,QAAQN,QAAQE,UAAA,EAAYK,IAAI3C,GAAG;gCACpE,GAAA,CAAA,WAAA,IAAA;kCACA;4BACF;4BAEA,IAAI0C,OAAOO,IAAA,EAAA,CAAA,EAAS,EAAA,CAAA,MAAS,CAAC,IAAA,CAAKE,aAAAA,KAAAA,IAAAA,CAAAA,CAAA,CAAyBR,MAAM,YAAA,CAAA,IAAA,GAAA,KAAA,IAAA,CAAA,yBAAA,KAAA,IAAA,GAAA,EAAA;kCAChE,IAAI,IAAA,CAAK1B,KAAA,EAAO;oCACdmC,QAAQC,GAAA,CAAI,oDAAoD;wCAC9DrD,KAAK2C,IAAI3C,GAAA;sCACT6B,sBAAsB,IAAA,CAAKC,yBAAA;;;;;4BAE3BI,QAAQS,IAAIT,MAAA,eAAA;wBACd;wCACF;qBACA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/Scte35CueManager.ts\nvar Scte35CueManager_exports = {};\n__export(Scte35CueManager_exports, {\n Scte35CueManager: () => Scte35CueManager\n});\nmodule.exports = __toCommonJS(Scte35CueManager_exports);\n\n// src/player/Scte35Parser.ts\nfunction getFragmentStartSeconds(frag) {\n const candidates = [frag?.start, frag?.startPTS];\n for (const candidate of candidates) {\n if (typeof candidate === \"number\" && Number.isFinite(candidate)) {\n return candidate;\n }\n }\n return void 0;\n}\n\n// src/player/Scte35CueManager.ts\nvar Scte35CueManager = class {\n constructor(debug, callbacks) {\n this.pendingScte35Cues = /* @__PURE__ */ new Map();\n this.recentScte35CueKeys = /* @__PURE__ */ new Map();\n this.recentScte35CueLimit = 200;\n this.tsScte35Pids = /* @__PURE__ */ new Set();\n this.pmtPids = /* @__PURE__ */ new Set();\n this.processedTsScte35Sections = /* @__PURE__ */ new Set();\n this.debug = debug;\n this.callbacks = callbacks;\n }\n get pendingScte35CueKey() {\n return this.pendingScte35CueKeyValue;\n }\n set pendingScte35CueKey(value) {\n this.pendingScte35CueKeyValue = value;\n }\n get activeScte35BreakKey() {\n return this.activeScte35BreakKeyValue;\n }\n set activeScte35BreakKey(value) {\n this.activeScte35BreakKeyValue = value;\n }\n get scheduledScte35BreakKey() {\n return this.scheduledScte35BreakKeyValue;\n }\n set scheduledScte35BreakKey(value) {\n this.scheduledScte35BreakKeyValue = value;\n }\n createScte35CueContext(source, readiness, frag) {\n const context = { source, readiness };\n if (typeof frag?.sn === \"number\") {\n context.fragmentSn = frag.sn;\n }\n const fragmentStartSec = getFragmentStartSeconds(frag);\n if (fragmentStartSec !== void 0) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n return context;\n }\n onScte35Cue(marker, context) {\n const cue = this.createScte35Cue(marker, context);\n const pendingKey = this.getPendingScte35CueKey(cue);\n if (context.readiness === \"early\") {\n this.pendingScte35Cues.set(pendingKey, cue);\n this.trimRecentScte35CueMaps();\n if (marker.type === \"start\") {\n this.callbacks.onEarlyStartCue(marker, context.fragmentSn, cue.key);\n }\n return;\n }\n if (marker.type === \"end\" && !this.shouldAcceptScte35EndCue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring SCTE-35 end cue\", {\n key: cue.key,\n activeScte35BreakKey: this.activeScte35BreakKeyValue,\n inAdBreak: this.callbacks.isInAdBreak(),\n source: cue.source\n });\n }\n return;\n }\n if (marker.type === \"start\" && this.hasRecentlyHandledScte35Cue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring duplicate SCTE-35 start cue\", {\n key: cue.key,\n source: cue.source\n });\n }\n return;\n }\n this.pendingScte35Cues.delete(pendingKey);\n this.markScte35CueHandled(cue);\n this.callbacks.onPlaybackCue(marker, cue.key);\n }\n activatePendingScte35CuesForFragment(frag) {\n const fragmentSn = typeof frag?.sn === \"number\" ? frag.sn : void 0;\n if (fragmentSn === void 0) {\n return;\n }\n const matchingCues = Array.from(this.pendingScte35Cues.entries()).filter(\n ([, cue]) => cue.fragmentSn === fragmentSn\n );\n matchingCues.forEach(([pendingKey, cue]) => {\n this.pendingScte35Cues.delete(pendingKey);\n const context = {\n source: cue.source,\n readiness: \"playback\"\n };\n context.fragmentSn = fragmentSn;\n const fragmentStartSec = cue.fragmentStartSeconds ?? getFragmentStartSeconds(frag);\n if (fragmentStartSec !== void 0) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n this.onScte35Cue(cue.marker, context);\n });\n }\n createScte35Cue(marker, context) {\n const cue = {\n marker,\n source: context.source,\n readiness: context.readiness,\n key: this.getScte35CueKey(marker, context)\n };\n if (context.fragmentSn !== void 0) {\n cue.fragmentSn = context.fragmentSn;\n }\n if (context.fragmentStartSeconds !== void 0) {\n cue.fragmentStartSeconds = context.fragmentStartSeconds;\n }\n return cue;\n }\n getScte35CueKey(marker, context) {\n const raw = this.getScte35MarkerRaw(marker);\n const spliceEventId = this.toIdentityString(raw?.splice_event_id);\n if (spliceEventId) {\n return `splice:${spliceEventId}`;\n }\n const segmentationEventId = this.toIdentityString(raw?.segmentation_event_id);\n if (segmentationEventId) {\n return `segmentation:${segmentationEventId}`;\n }\n const daterangeId = this.toIdentityString(raw?.attrs?.ID);\n if (daterangeId) {\n return `daterange:${daterangeId}`;\n }\n const scteValue = this.toIdentityString(raw?.attrs?.[\"SCTE35-OUT\"]) || this.toIdentityString(raw?.attrs?.[\"SCTE35-IN\"]);\n if (scteValue) {\n return `daterange-scte:${scteValue}`;\n }\n if (typeof marker.ptsSeconds === \"number\" && Number.isFinite(marker.ptsSeconds)) {\n return `pts:${Math.round(marker.ptsSeconds * 2) / 2}`;\n }\n if (context.fragmentSn !== void 0) {\n return `fragment:${context.fragmentSn}`;\n }\n return `${context.source}:wallclock:${Math.floor(Date.now() / 1e3)}`;\n }\n getPendingScte35CueKey(cue) {\n return `${cue.marker.type}:${cue.key}:${cue.fragmentSn !== void 0 ? cue.fragmentSn : \"unknown\"}`;\n }\n getScte35MarkerRaw(marker) {\n return typeof marker.raw === \"object\" && marker.raw !== null ? marker.raw : {};\n }\n toIdentityString(value) {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return String(value);\n }\n if (typeof value === \"string\" && value.trim().length > 0) {\n return value.trim();\n }\n return void 0;\n }\n isStrongScte35CueKey(key) {\n return !!(key && (key.startsWith(\"splice:\") || key.startsWith(\"segmentation:\") || key.startsWith(\"daterange:\") || key.startsWith(\"daterange-scte:\")));\n }\n hasRecentlyHandledScte35Cue(cue) {\n if (this.activeScte35BreakKeyValue === cue.key || this.scheduledScte35BreakKeyValue === cue.key) {\n return true;\n }\n const recentKey = `${cue.marker.type}:${cue.key}`;\n return this.recentScte35CueKeys.has(recentKey);\n }\n markScte35CueHandled(cue) {\n this.recentScte35CueKeys.set(`${cue.marker.type}:${cue.key}`, Date.now());\n this.trimRecentScte35CueMaps();\n }\n trimRecentScte35CueMaps() {\n while (this.recentScte35CueKeys.size > this.recentScte35CueLimit) {\n const firstKey = this.recentScte35CueKeys.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.recentScte35CueKeys.delete(firstKey);\n }\n while (this.pendingScte35Cues.size > this.recentScte35CueLimit) {\n const firstKey = this.pendingScte35Cues.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.pendingScte35Cues.delete(firstKey);\n }\n }\n shouldAcceptScte35EndCue(cue) {\n if (!this.callbacks.isInAdBreak()) {\n return false;\n }\n if (this.isStrongScte35CueKey(this.activeScte35BreakKeyValue) && this.isStrongScte35CueKey(cue.key) && this.activeScte35BreakKeyValue !== cue.key) {\n return false;\n }\n return true;\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n Scte35CueManager\n});\n","import type { Scte35Marker } from \"../types\";\nimport type {\n NormalizedScte35Cue,\n Scte35CueContext,\n Scte35CueSource,\n Scte35CueReadiness,\n} from \"./playerTypes\";\nimport { getFragmentStartSeconds } from \"./Scte35Parser\";\n\nexport interface Scte35CueManagerCallbacks {\n onEarlyStartCue(marker: Scte35Marker, fragmentSn: number | undefined, cueKey: string): void;\n onPlaybackCue(marker: Scte35Marker, cueKey?: string): void;\n isInAdBreak(): boolean;\n}\n\nexport class Scte35CueManager {\n private readonly pendingScte35Cues: Map<string, NormalizedScte35Cue> = new Map();\n private readonly recentScte35CueKeys: Map<string, number> = new Map();\n private readonly recentScte35CueLimit: number = 200;\n private pendingScte35CueKeyValue: string | undefined;\n private activeScte35BreakKeyValue: string | undefined;\n private scheduledScte35BreakKeyValue: string | undefined;\n\n readonly tsScte35Pids: Set<number> = new Set();\n readonly pmtPids: Set<number> = new Set();\n readonly processedTsScte35Sections: Set<string> = new Set();\n\n private debug: boolean;\n private callbacks: Scte35CueManagerCallbacks;\n\n constructor(debug: boolean, callbacks: Scte35CueManagerCallbacks) {\n this.debug = debug;\n this.callbacks = callbacks;\n }\n\n get pendingScte35CueKey(): string | undefined {\n return this.pendingScte35CueKeyValue;\n }\n set pendingScte35CueKey(value: string | undefined) {\n this.pendingScte35CueKeyValue = value;\n }\n\n get activeScte35BreakKey(): string | undefined {\n return this.activeScte35BreakKeyValue;\n }\n set activeScte35BreakKey(value: string | undefined) {\n this.activeScte35BreakKeyValue = value;\n }\n\n get scheduledScte35BreakKey(): string | undefined {\n return this.scheduledScte35BreakKeyValue;\n }\n set scheduledScte35BreakKey(value: string | undefined) {\n this.scheduledScte35BreakKeyValue = value;\n }\n\n createScte35CueContext(\n source: Scte35CueSource,\n readiness: Scte35CueReadiness,\n frag?: any\n ): Scte35CueContext {\n const context: Scte35CueContext = { source, readiness };\n if (typeof frag?.sn === \"number\") {\n context.fragmentSn = frag.sn;\n }\n const fragmentStartSec = getFragmentStartSeconds(frag);\n if (fragmentStartSec !== undefined) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n return context;\n }\n\n onScte35Cue(marker: Scte35Marker, context: Scte35CueContext): void {\n const cue = this.createScte35Cue(marker, context);\n const pendingKey = this.getPendingScte35CueKey(cue);\n\n if (context.readiness === \"early\") {\n this.pendingScte35Cues.set(pendingKey, cue);\n this.trimRecentScte35CueMaps();\n\n if (marker.type === \"start\") {\n this.callbacks.onEarlyStartCue(marker, context.fragmentSn, cue.key);\n }\n return;\n }\n\n if (marker.type === \"end\" && !this.shouldAcceptScte35EndCue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring SCTE-35 end cue\", {\n key: cue.key,\n activeScte35BreakKey: this.activeScte35BreakKeyValue,\n inAdBreak: this.callbacks.isInAdBreak(),\n source: cue.source,\n });\n }\n return;\n }\n\n if (marker.type === \"start\" && this.hasRecentlyHandledScte35Cue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring duplicate SCTE-35 start cue\", {\n key: cue.key,\n source: cue.source,\n });\n }\n return;\n }\n\n this.pendingScte35Cues.delete(pendingKey);\n this.markScte35CueHandled(cue);\n this.callbacks.onPlaybackCue(marker, cue.key);\n }\n\n activatePendingScte35CuesForFragment(frag: any): void {\n const fragmentSn = typeof frag?.sn === \"number\" ? frag.sn : undefined;\n if (fragmentSn === undefined) {\n return;\n }\n\n const matchingCues = Array.from(this.pendingScte35Cues.entries()).filter(\n ([, cue]) => cue.fragmentSn === fragmentSn\n );\n\n matchingCues.forEach(([pendingKey, cue]) => {\n this.pendingScte35Cues.delete(pendingKey);\n const context: Scte35CueContext = {\n source: cue.source,\n readiness: \"playback\",\n };\n context.fragmentSn = fragmentSn;\n const fragmentStartSec =\n cue.fragmentStartSeconds ?? getFragmentStartSeconds(frag);\n if (fragmentStartSec !== undefined) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n this.onScte35Cue(cue.marker, context);\n });\n }\n\n private createScte35Cue(\n marker: Scte35Marker,\n context: Scte35CueContext\n ): NormalizedScte35Cue {\n const cue: NormalizedScte35Cue = {\n marker,\n source: context.source,\n readiness: context.readiness,\n key: this.getScte35CueKey(marker, context),\n };\n if (context.fragmentSn !== undefined) {\n cue.fragmentSn = context.fragmentSn;\n }\n if (context.fragmentStartSeconds !== undefined) {\n cue.fragmentStartSeconds = context.fragmentStartSeconds;\n }\n return cue;\n }\n\n private getScte35CueKey(\n marker: Scte35Marker,\n context: Scte35CueContext\n ): string {\n const raw = this.getScte35MarkerRaw(marker);\n const spliceEventId = this.toIdentityString(raw?.splice_event_id);\n if (spliceEventId) {\n return `splice:${spliceEventId}`;\n }\n\n const segmentationEventId = this.toIdentityString(raw?.segmentation_event_id);\n if (segmentationEventId) {\n return `segmentation:${segmentationEventId}`;\n }\n\n const daterangeId = this.toIdentityString(raw?.attrs?.ID);\n if (daterangeId) {\n return `daterange:${daterangeId}`;\n }\n\n const scteValue =\n this.toIdentityString(raw?.attrs?.[\"SCTE35-OUT\"]) ||\n this.toIdentityString(raw?.attrs?.[\"SCTE35-IN\"]);\n if (scteValue) {\n return `daterange-scte:${scteValue}`;\n }\n\n if (typeof marker.ptsSeconds === \"number\" && Number.isFinite(marker.ptsSeconds)) {\n return `pts:${Math.round(marker.ptsSeconds * 2) / 2}`;\n }\n\n if (context.fragmentSn !== undefined) {\n return `fragment:${context.fragmentSn}`;\n }\n\n return `${context.source}:wallclock:${Math.floor(Date.now() / 1000)}`;\n }\n\n private getPendingScte35CueKey(cue: NormalizedScte35Cue): string {\n return `${cue.marker.type}:${cue.key}:${\n cue.fragmentSn !== undefined ? cue.fragmentSn : \"unknown\"\n }`;\n }\n\n private getScte35MarkerRaw(marker: Scte35Marker): any {\n return typeof marker.raw === \"object\" && marker.raw !== null\n ? (marker.raw as any)\n : {};\n }\n\n private toIdentityString(value: unknown): string | undefined {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return String(value);\n }\n if (typeof value === \"string\" && value.trim().length > 0) {\n return value.trim();\n }\n return undefined;\n }\n\n isStrongScte35CueKey(key: string | undefined): boolean {\n return !!(\n key &&\n (key.startsWith(\"splice:\") ||\n key.startsWith(\"segmentation:\") ||\n key.startsWith(\"daterange:\") ||\n key.startsWith(\"daterange-scte:\"))\n );\n }\n\n private hasRecentlyHandledScte35Cue(cue: NormalizedScte35Cue): boolean {\n if (\n this.activeScte35BreakKeyValue === cue.key ||\n this.scheduledScte35BreakKeyValue === cue.key\n ) {\n return true;\n }\n\n const recentKey = `${cue.marker.type}:${cue.key}`;\n return this.recentScte35CueKeys.has(recentKey);\n }\n\n private markScte35CueHandled(cue: NormalizedScte35Cue): void {\n this.recentScte35CueKeys.set(`${cue.marker.type}:${cue.key}`, Date.now());\n this.trimRecentScte35CueMaps();\n }\n\n private trimRecentScte35CueMaps(): void {\n while (this.recentScte35CueKeys.size > this.recentScte35CueLimit) {\n const firstKey = this.recentScte35CueKeys.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.recentScte35CueKeys.delete(firstKey);\n }\n\n while (this.pendingScte35Cues.size > this.recentScte35CueLimit) {\n const firstKey = this.pendingScte35Cues.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.pendingScte35Cues.delete(firstKey);\n }\n }\n\n private shouldAcceptScte35EndCue(cue: NormalizedScte35Cue): boolean {\n if (!this.callbacks.isInAdBreak()) {\n return false;\n }\n\n if (\n this.isStrongScte35CueKey(this.activeScte35BreakKeyValue) &&\n this.isStrongScte35CueKey(cue.key) &&\n this.activeScte35BreakKeyValue !== cue.key\n ) {\n return false;\n }\n\n return true;\n }\n}\n","import type { Scte35Marker, Id3TagInfo } from \"../types\";\n\nexport function parseCueOutDuration(value: string): number | undefined {\n const num = parseFloat(value.trim());\n if (!Number.isNaN(num)) return num;\n const match =\n value.match(/(?:^|[,\\s])DURATION\\s*=\\s*([0-9.]+)/i) ||\n value.match(/Duration\\s*=\\s*([0-9.]+)/i);\n if (match && match[1] != null) {\n const dStr = match[1];\n const d = parseFloat(dStr);\n return Number.isNaN(d) ? undefined : d;\n }\n return undefined;\n}\n\nexport function parseCueOutCont(\n value: string\n): { elapsed?: number; duration?: number } | undefined {\n const res: { elapsed?: number; duration?: number } = {};\n\n const elapsedMatch = value.match(/Elapsed\\s*=\\s*([0-9.]+)/i);\n const durationMatch = value.match(/Duration\\s*=\\s*([0-9.]+)/i);\n if (elapsedMatch && elapsedMatch[1] != null) {\n const e = parseFloat(elapsedMatch[1]);\n if (!Number.isNaN(e)) res.elapsed = e;\n }\n if (durationMatch && durationMatch[1] != null) {\n const d = parseFloat(durationMatch[1]);\n if (!Number.isNaN(d)) res.duration = d;\n }\n\n if (!(\"elapsed\" in res) || !(\"duration\" in res)) {\n const slashMatch = value.match(/([0-9.]+)\\s*\\/\\s*([0-9.]+)/);\n if (slashMatch && slashMatch[1] && slashMatch[2]) {\n const elapsed = parseFloat(slashMatch[1]);\n const duration = parseFloat(slashMatch[2]);\n if (!Number.isNaN(elapsed) && !(\"elapsed\" in res)) res.elapsed = elapsed;\n if (!Number.isNaN(duration) && !(\"duration\" in res)) res.duration = duration;\n }\n }\n\n if (\"elapsed\" in res || \"duration\" in res) return res;\n return undefined;\n}\n\nexport function parseAttributeList(value: string): Record<string, string> {\n const attrs: Record<string, string> = {};\n const regex = /([A-Z0-9-]+)=((\"[^\"]*\")|([^\",]*))(?:,|$)/gi;\n let match: RegExpExecArray | null;\n while ((match = regex.exec(value)) !== null) {\n const key: string = (match[1] ?? \"\") as string;\n let rawVal: string = (match[3] ?? match[4] ?? \"\") as string;\n if (rawVal.startsWith('\"') && rawVal.endsWith('\"')) {\n rawVal = rawVal.slice(1, -1);\n }\n if (key) {\n attrs[key] = rawVal;\n }\n }\n return attrs;\n}\n\nexport function toNumber(val: unknown): number | undefined {\n if (val == null) return undefined;\n const n = typeof val === \"string\" ? parseFloat(val) : Number(val);\n return Number.isNaN(n) ? undefined : n;\n}\n\nexport function isManifestBasedMarker(marker: Scte35Marker): boolean {\n const raw = marker.raw as any;\n if (!raw) return false;\n\n if (raw.tag) {\n const tag = String(raw.tag);\n return (\n tag.includes(\"EXT-X-CUE-OUT\") ||\n tag.includes(\"EXT-X-CUE-IN\") ||\n tag.includes(\"EXT-X-DATERANGE\")\n );\n }\n\n if (raw.id3) return false;\n\n if (raw.splice_command_type) return false;\n\n return false;\n}\n\nexport function decodeId3ValueToText(value: string | Uint8Array): string | undefined {\n try {\n if (typeof value === \"string\") return value;\n const decoder = new TextDecoder(\"utf-8\", { fatal: false });\n const text = decoder.decode(value);\n if (text && /[\\x20-\\x7E]/.test(text)) return text;\n let out = \"\";\n for (let i = 0; i < value.length; i++)\n out += String.fromCharCode(value[i]!);\n return out;\n } catch {\n return undefined;\n }\n}\n\nexport function getFragmentStartSeconds(frag: any): number | undefined {\n const candidates = [frag?.start, frag?.startPTS];\n for (const candidate of candidates) {\n if (typeof candidate === \"number\" && Number.isFinite(candidate)) {\n return candidate;\n }\n }\n return undefined;\n}\n\nexport function parseScte35FromId3(tag: Id3TagInfo): Scte35Marker | undefined {\n const text = decodeId3ValueToText(tag.value);\n if (!text) return undefined;\n\n const cueOutMatch =\n text.match(/EXT-X-CUE-OUT(?::([^\\r\\n]*))?/i) ||\n text.match(/CUE-OUT(?::([^\\r\\n]*))?/i);\n if (cueOutMatch) {\n const arg = (cueOutMatch[1] ?? \"\").trim();\n const dur = parseCueOutDuration(arg);\n const marker: Scte35Marker = {\n type: \"start\",\n ...(tag.ptsSeconds !== undefined ? { ptsSeconds: tag.ptsSeconds } : {}),\n ...(dur !== undefined ? { durationSeconds: dur } : {}),\n raw: { id3: text },\n } as Scte35Marker;\n return marker;\n }\n\n const cueOutContMatch = text.match(/EXT-X-CUE-OUT-CONT:([^\\r\\n]*)/i);\n if (cueOutContMatch) {\n const arg = (cueOutContMatch[1] ?? \"\").trim();\n const cont = parseCueOutCont(arg);\n const marker: Scte35Marker = {\n type: \"progress\",\n ...(tag.ptsSeconds !== undefined ? { ptsSeconds: tag.ptsSeconds } : {}),\n ...(cont?.duration !== undefined\n ? { durationSeconds: cont.duration }\n : {}),\n raw: { id3: text },\n } as Scte35Marker;\n return marker;\n }\n\n const cueInMatch = text.match(/EXT-X-CUE-IN\\b/i) || text.match(/CUE-IN\\b/i);\n if (cueInMatch) {\n const marker: Scte35Marker = {\n type: \"end\",\n ...(tag.ptsSeconds !== undefined ? { ptsSeconds: tag.ptsSeconds } : {}),\n raw: { id3: text },\n } as Scte35Marker;\n return marker;\n }\n\n const daterangeMatch = text.match(/EXT-X-DATERANGE:([^\\r\\n]*)/i);\n if (daterangeMatch) {\n const attrs = parseAttributeList(daterangeMatch[1] ?? \"\");\n const hasScteOut =\n \"SCTE35-OUT\" in attrs || attrs[\"SCTE35-OUT\"] !== undefined;\n const hasScteIn =\n \"SCTE35-IN\" in attrs || attrs[\"SCTE35-IN\"] !== undefined;\n const klass = String(attrs[\"CLASS\"] ?? \"\");\n const duration = toNumber(attrs[\"DURATION\"]);\n if (hasScteOut || /com\\.apple\\.hls\\.cue/i.test(klass)) {\n const marker: Scte35Marker = {\n type: \"start\",\n ...(tag.ptsSeconds !== undefined\n ? { ptsSeconds: tag.ptsSeconds }\n : {}),\n ...(duration !== undefined ? { durationSeconds: duration } : {}),\n raw: { id3: text, attrs },\n } as Scte35Marker;\n return marker;\n }\n if (hasScteIn) {\n const marker: Scte35Marker = {\n type: \"end\",\n ...(tag.ptsSeconds !== undefined\n ? { ptsSeconds: tag.ptsSeconds }\n : {}),\n raw: { id3: text, attrs },\n } as Scte35Marker;\n return marker;\n }\n }\n\n if (/SCTE35-OUT/i.test(text)) {\n const marker: Scte35Marker = {\n type: \"start\",\n ...(tag.ptsSeconds !== undefined ? { ptsSeconds: tag.ptsSeconds } : {}),\n raw: { id3: text },\n } as Scte35Marker;\n return marker;\n }\n if (/SCTE35-IN/i.test(text)) {\n const marker: Scte35Marker = {\n type: \"end\",\n ...(tag.ptsSeconds !== undefined ? { ptsSeconds: tag.ptsSeconds } : {}),\n raw: { id3: text },\n } as Scte35Marker;\n return marker;\n }\n\n if (tag.value instanceof Uint8Array) {\n const bin = parseScte35Binary(tag.value);\n if (bin) return bin;\n }\n\n return undefined;\n}\n\nexport function normalizeFragmentPayload(payload: unknown): Uint8Array | undefined {\n if (payload instanceof Uint8Array) {\n return payload;\n }\n if (payload instanceof ArrayBuffer) {\n return new Uint8Array(payload);\n }\n if (ArrayBuffer.isView(payload)) {\n const view = payload as ArrayBufferView;\n return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);\n }\n return undefined;\n}\n\n// --- Transport Stream SCTE-35 parsing ---\n\nexport function detectTsPacketFormat(\n data: Uint8Array\n): { offset: number; packetSize: number; tsPayloadOffset: number } | undefined {\n const packetSizes = [188, 192, 204];\n for (const packetSize of packetSizes) {\n const tsPayloadOffset = packetSize === 192 ? 4 : 0;\n for (let offset = 0; offset < packetSize; offset++) {\n let matchedPackets = 0;\n for (\n let packetStart = offset;\n packetStart + tsPayloadOffset < data.length &&\n matchedPackets < 5;\n packetStart += packetSize\n ) {\n if (data[packetStart + tsPayloadOffset] !== 0x47) {\n break;\n }\n matchedPackets++;\n }\n if (matchedPackets >= 2) {\n return { offset, packetSize, tsPayloadOffset };\n }\n }\n }\n return undefined;\n}\n\nfunction getPsiSectionStart(\n payload: Uint8Array,\n payloadUnitStart: boolean\n): number | undefined {\n if (!payloadUnitStart) {\n return undefined;\n }\n const pointerField = payload[0];\n if (pointerField == null) {\n return undefined;\n }\n const sectionStart = 1 + pointerField;\n return sectionStart < payload.length ? sectionStart : undefined;\n}\n\nfunction getPsiSectionLength(data: Uint8Array, offset: number): number {\n return (((data[offset + 1] ?? 0) & 0x0f) << 8) | (data[offset + 2] ?? 0);\n}\n\nfunction parsePatSection(\n payload: Uint8Array,\n payloadUnitStart: boolean,\n pmtPids: Set<number>\n): void {\n const sectionStart = getPsiSectionStart(payload, payloadUnitStart);\n if (sectionStart == null || sectionStart + 8 >= payload.length) {\n return;\n }\n if (payload[sectionStart] !== 0x00) {\n return;\n }\n\n const sectionLength = getPsiSectionLength(payload, sectionStart);\n const sectionEnd = Math.min(\n payload.length,\n sectionStart + 3 + sectionLength\n );\n\n for (let offset = sectionStart + 8; offset + 4 <= sectionEnd - 4; offset += 4) {\n const programNumber =\n ((payload[offset] ?? 0) << 8) | (payload[offset + 1] ?? 0);\n const pid =\n (((payload[offset + 2] ?? 0) & 0x1f) << 8) |\n (payload[offset + 3] ?? 0);\n if (programNumber !== 0) {\n pmtPids.add(pid);\n }\n }\n}\n\nfunction descriptorsIdentifyScte35(\n data: Uint8Array,\n start: number,\n end: number\n): boolean {\n let offset = start;\n while (offset + 2 <= end) {\n const tag = data[offset] ?? 0;\n const length = data[offset + 1] ?? 0;\n const descriptorStart = offset + 2;\n const descriptorEnd = descriptorStart + length;\n if (descriptorEnd > end) {\n return false;\n }\n\n const registration =\n length >= 4\n ? String.fromCharCode(\n data[descriptorStart] ?? 0,\n data[descriptorStart + 1] ?? 0,\n data[descriptorStart + 2] ?? 0,\n data[descriptorStart + 3] ?? 0\n )\n : \"\";\n if (tag === 0x8a || registration === \"CUEI\" || registration === \"SCTE\") {\n return true;\n }\n\n offset = descriptorEnd;\n }\n return false;\n}\n\nfunction parsePmtSection(\n payload: Uint8Array,\n payloadUnitStart: boolean,\n tsScte35Pids: Set<number>\n): void {\n const sectionStart = getPsiSectionStart(payload, payloadUnitStart);\n if (sectionStart == null || sectionStart + 12 >= payload.length) {\n return;\n }\n if (payload[sectionStart] !== 0x02) {\n return;\n }\n\n const sectionLength = getPsiSectionLength(payload, sectionStart);\n const sectionEnd = Math.min(\n payload.length,\n sectionStart + 3 + sectionLength\n );\n const programInfoLength =\n (((payload[sectionStart + 10] ?? 0) & 0x0f) << 8) |\n (payload[sectionStart + 11] ?? 0);\n\n let offset = sectionStart + 12 + programInfoLength;\n while (offset + 5 <= sectionEnd - 4) {\n const streamType = payload[offset] ?? 0;\n const elementaryPid =\n (((payload[offset + 1] ?? 0) & 0x1f) << 8) |\n (payload[offset + 2] ?? 0);\n const esInfoLength =\n (((payload[offset + 3] ?? 0) & 0x0f) << 8) |\n (payload[offset + 4] ?? 0);\n const descriptorStart = offset + 5;\n const descriptorEnd = Math.min(descriptorStart + esInfoLength, sectionEnd - 4);\n\n if (\n streamType === 0x86 ||\n (streamType === 0x06 &&\n descriptorsIdentifyScte35(payload, descriptorStart, descriptorEnd))\n ) {\n tsScte35Pids.add(elementaryPid);\n }\n\n offset = descriptorStart + esInfoLength;\n }\n}\n\nfunction hasProcessedTsScte35Section(\n section: Uint8Array,\n processedSections: Set<string>\n): boolean {\n let checksum = 0;\n for (let i = 0; i < section.length; i++) {\n checksum = (checksum * 31 + (section[i] ?? 0)) >>> 0;\n }\n\n const key = `${section.length}:${checksum}`;\n if (processedSections.has(key)) {\n return true;\n }\n\n processedSections.add(key);\n if (processedSections.size > 200) {\n const firstKey = processedSections.values().next().value;\n if (firstKey) {\n processedSections.delete(firstKey);\n }\n }\n return false;\n}\n\nfunction addScte35SectionMarker(\n section: Uint8Array,\n markers: Scte35Marker[],\n processedSections: Set<string>\n): void {\n if (section[0] !== 0xfc || hasProcessedTsScte35Section(section, processedSections)) {\n return;\n }\n\n const marker = parseScte35Binary(section);\n if (!marker) {\n return;\n }\n\n marker.raw = {\n ...(typeof marker.raw === \"object\" && marker.raw ? marker.raw : {}),\n source: \"ts-packet\",\n };\n markers.push(marker);\n}\n\nfunction appendScte35Bytes(\n pid: number,\n bytes: Uint8Array,\n assemblers: Map<number, { bytes: number[]; expectedLength: number }>,\n markers: Scte35Marker[],\n processedSections: Set<string>\n): void {\n const assembler = assemblers.get(pid);\n if (!assembler) {\n return;\n }\n\n for (let i = 0; i < bytes.length && assembler.bytes.length < assembler.expectedLength; i++) {\n assembler.bytes.push(bytes[i] ?? 0);\n }\n\n if (assembler.bytes.length >= assembler.expectedLength) {\n assemblers.delete(pid);\n addScte35SectionMarker(new Uint8Array(assembler.bytes), markers, processedSections);\n }\n}\n\nfunction collectScte35SectionsFromPayload(\n pid: number,\n payload: Uint8Array,\n payloadUnitStart: boolean,\n assemblers: Map<number, { bytes: number[]; expectedLength: number }>,\n markers: Scte35Marker[],\n processedSections: Set<string>\n): void {\n if (payload.length === 0) {\n return;\n }\n\n let offset = 0;\n if (payloadUnitStart) {\n const pointerField = payload[0] ?? 0;\n const previousAssembler = assemblers.get(pid);\n if (previousAssembler && pointerField > 0) {\n appendScte35Bytes(\n pid,\n payload.subarray(1, Math.min(1 + pointerField, payload.length)),\n assemblers,\n markers,\n processedSections\n );\n }\n assemblers.delete(pid);\n offset = 1 + pointerField;\n } else {\n appendScte35Bytes(pid, payload, assemblers, markers, processedSections);\n return;\n }\n\n while (offset + 3 <= payload.length) {\n const tableId = payload[offset];\n if (tableId == null || tableId === 0xff) {\n return;\n }\n\n const sectionLength = getPsiSectionLength(payload, offset);\n const totalLength = 3 + sectionLength;\n if (sectionLength <= 0 || totalLength <= 3) {\n return;\n }\n\n if (offset + totalLength <= payload.length) {\n addScte35SectionMarker(\n payload.subarray(offset, offset + totalLength),\n markers,\n processedSections\n );\n offset += totalLength;\n } else {\n assemblers.set(pid, {\n bytes: Array.from(payload.subarray(offset)),\n expectedLength: totalLength,\n });\n return;\n }\n }\n}\n\nexport function parseScte35FromTsPackets(\n data: Uint8Array,\n tsScte35Pids: Set<number>,\n pmtPids: Set<number>,\n processedSections: Set<string>\n): Scte35Marker[] {\n const packetInfo = detectTsPacketFormat(data);\n if (!packetInfo) {\n return [];\n }\n\n const markers: Scte35Marker[] = [];\n const sectionAssemblers = new Map<\n number,\n { bytes: number[]; expectedLength: number }\n >();\n\n for (\n let packetStart = packetInfo.offset;\n packetStart + packetInfo.packetSize <= data.length;\n packetStart += packetInfo.packetSize\n ) {\n const tsStart = packetStart + packetInfo.tsPayloadOffset;\n if (data[tsStart] !== 0x47) {\n continue;\n }\n\n const secondByte = data[tsStart + 1];\n const thirdByte = data[tsStart + 2];\n const fourthByte = data[tsStart + 3];\n if (\n secondByte == null ||\n thirdByte == null ||\n fourthByte == null ||\n (secondByte & 0x80) !== 0\n ) {\n continue;\n }\n\n const payloadUnitStart = (secondByte & 0x40) !== 0;\n const pid = ((secondByte & 0x1f) << 8) | thirdByte;\n const adaptationFieldControl = (fourthByte >> 4) & 0x03;\n const hasPayload =\n adaptationFieldControl === 1 || adaptationFieldControl === 3;\n if (!hasPayload) {\n continue;\n }\n\n let payloadStart = tsStart + 4;\n if (adaptationFieldControl === 3) {\n const adaptationLength = data[payloadStart];\n if (adaptationLength == null) {\n continue;\n }\n payloadStart += 1 + adaptationLength;\n }\n\n const payloadEnd = Math.min(tsStart + 188, data.length);\n if (payloadStart >= payloadEnd || payloadStart >= data.length) {\n continue;\n }\n\n const payload = data.subarray(payloadStart, payloadEnd);\n if (pid === 0) {\n parsePatSection(payload, payloadUnitStart, pmtPids);\n } else if (pmtPids.has(pid)) {\n parsePmtSection(payload, payloadUnitStart, tsScte35Pids);\n } else if (tsScte35Pids.has(pid)) {\n collectScte35SectionsFromPayload(\n pid,\n payload,\n payloadUnitStart,\n sectionAssemblers,\n markers,\n processedSections\n );\n }\n }\n\n return markers;\n}\n\n// --- Binary SCTE-35 parsing ---\n\nclass BitReader {\n private bytePos = 0;\n private bitPos = 0;\n constructor(private readonly buf: Uint8Array) {}\n readBits(numBits: number): number {\n let result = 0;\n while (numBits > 0) {\n if (this.bytePos >= this.buf.length) return result;\n const remainingInByte = 8 - this.bitPos;\n const toRead = Math.min(numBits, remainingInByte);\n const currentByte = this.buf[this.bytePos]!;\n const shift = remainingInByte - toRead;\n const mask = ((1 << toRead) - 1) & 0xff;\n const bits = (currentByte >> shift) & mask;\n result = (result << toRead) | bits;\n this.bitPos += toRead;\n if (this.bitPos >= 8) {\n this.bitPos = 0;\n this.bytePos += 1;\n }\n numBits -= toRead;\n }\n return result >>> 0;\n }\n skipBits(n: number): void {\n this.readBits(n);\n }\n get bytePosition(): number {\n return this.bitPos === 0 ? this.bytePos : this.bytePos + 1;\n }\n}\n\nfunction readSpliceTime(\n r: BitReader,\n ptsAdjustmentTicks: number\n): number | undefined {\n const timeSpecifiedFlag = r.readBits(1) === 1;\n if (!timeSpecifiedFlag) {\n r.readBits(7);\n return undefined;\n }\n r.readBits(6);\n const high = r.readBits(1);\n const low = r.readBits(32);\n const ptsTicks =\n (high * 0x100000000 + low + ptsAdjustmentTicks) % 0x200000000;\n return ptsTicks / 90000;\n}\n\nfunction markerTypeFromSegmentationTypeId(\n segmentationTypeId: number\n): Scte35Marker[\"type\"] | undefined {\n switch (segmentationTypeId) {\n case 0x10:\n case 0x22:\n case 0x30:\n case 0x32:\n case 0x34:\n case 0x36:\n return \"start\";\n case 0x11:\n case 0x23:\n case 0x31:\n case 0x33:\n case 0x35:\n case 0x37:\n return \"end\";\n default:\n return undefined;\n }\n}\n\nfunction parseScte35SegmentationDescriptor(\n descriptor: Uint8Array\n):\n | {\n type: Scte35Marker[\"type\"];\n durationSeconds?: number;\n segmentationEventId?: number;\n }\n | undefined {\n if (descriptor.length < 11) {\n return undefined;\n }\n\n const identifier = String.fromCharCode(\n descriptor[0] ?? 0,\n descriptor[1] ?? 0,\n descriptor[2] ?? 0,\n descriptor[3] ?? 0\n );\n if (identifier !== \"CUEI\") {\n return undefined;\n }\n\n const segmentationEventId =\n ((descriptor[4] ?? 0) * 0x1000000) +\n ((descriptor[5] ?? 0) << 16) +\n ((descriptor[6] ?? 0) << 8) +\n (descriptor[7] ?? 0);\n const cancelIndicator = ((descriptor[8] ?? 0) & 0x80) !== 0;\n if (cancelIndicator) {\n return undefined;\n }\n\n const flags = descriptor[9] ?? 0;\n const programSegmentationFlag = (flags & 0x80) !== 0;\n const segmentationDurationFlag = (flags & 0x40) !== 0;\n let offset = 10;\n\n if (!programSegmentationFlag) {\n const componentCount = descriptor[offset] ?? 0;\n offset += 1 + componentCount * 6;\n if (offset > descriptor.length) {\n return undefined;\n }\n }\n\n let durationSeconds: number | undefined = undefined;\n if (segmentationDurationFlag) {\n if (offset + 5 > descriptor.length) {\n return undefined;\n }\n const durationTicks =\n ((descriptor[offset] ?? 0) * 0x100000000) +\n ((descriptor[offset + 1] ?? 0) * 0x1000000) +\n ((descriptor[offset + 2] ?? 0) << 16) +\n ((descriptor[offset + 3] ?? 0) << 8) +\n (descriptor[offset + 4] ?? 0);\n durationSeconds = durationTicks / 90000;\n offset += 5;\n }\n\n if (offset + 2 > descriptor.length) {\n return undefined;\n }\n offset += 1;\n const segmentationUpidLength = descriptor[offset] ?? 0;\n offset += 1 + segmentationUpidLength;\n if (offset >= descriptor.length) {\n return undefined;\n }\n\n const segmentationTypeId = descriptor[offset] ?? 0;\n const markerType = markerTypeFromSegmentationTypeId(segmentationTypeId);\n if (!markerType) {\n return undefined;\n }\n\n return {\n type: markerType,\n ...(durationSeconds !== undefined ? { durationSeconds } : {}),\n segmentationEventId,\n };\n}\n\nfunction parseScte35SegmentationDescriptors(\n data: Uint8Array,\n offset: number\n):\n | {\n type: Scte35Marker[\"type\"];\n durationSeconds?: number;\n segmentationEventId?: number;\n }\n | undefined {\n if (offset + 2 > data.length) {\n return undefined;\n }\n\n const descriptorLoopLength =\n ((data[offset] ?? 0) << 8) | (data[offset + 1] ?? 0);\n let descriptorOffset = offset + 2;\n const descriptorEnd = Math.min(\n data.length,\n descriptorOffset + descriptorLoopLength\n );\n\n while (descriptorOffset + 2 <= descriptorEnd) {\n const descriptorTag = data[descriptorOffset] ?? 0;\n const descriptorLength = data[descriptorOffset + 1] ?? 0;\n const descriptorDataStart = descriptorOffset + 2;\n const descriptorDataEnd = descriptorDataStart + descriptorLength;\n if (descriptorDataEnd > descriptorEnd) {\n return undefined;\n }\n\n if (descriptorTag === 0x02) {\n const descriptorMarker = parseScte35SegmentationDescriptor(\n data.subarray(descriptorDataStart, descriptorDataEnd)\n );\n if (descriptorMarker) {\n return descriptorMarker;\n }\n }\n\n descriptorOffset = descriptorDataEnd;\n }\n\n return undefined;\n}\n\nexport function parseScte35Binary(data: Uint8Array): Scte35Marker | undefined {\n const r = new BitReader(data);\n const tableId = r.readBits(8);\n if (tableId !== 0xfc) return undefined;\n r.readBits(1);\n r.readBits(1);\n r.readBits(2);\n const sectionLength = r.readBits(12);\n if (sectionLength <= 0 || data.length < 3 + sectionLength) {\n return undefined;\n }\n r.readBits(8);\n r.readBits(1);\n r.readBits(6);\n const ptsAdjHigh = r.readBits(1);\n const ptsAdjLow = r.readBits(32);\n const ptsAdjustmentTicks = ptsAdjHigh * 0x100000000 + ptsAdjLow;\n r.readBits(8);\n r.readBits(12);\n const spliceCommandLength = r.readBits(12);\n const spliceCommandType = r.readBits(8);\n\n let markerType: Scte35Marker[\"type\"] | undefined;\n let durationSeconds: number | undefined = undefined;\n let ptsSeconds: number | undefined = undefined;\n let spliceEventId: number | undefined = undefined;\n const commandBodyStart = r.bytePosition;\n\n if (spliceCommandType === 5) {\n spliceEventId = r.readBits(32);\n const cancel = r.readBits(1) === 1;\n r.readBits(7);\n if (cancel) return undefined;\n const outOfNetwork = r.readBits(1) === 1;\n const programSpliceFlag = r.readBits(1) === 1;\n const durationFlag = r.readBits(1) === 1;\n const spliceImmediateFlag = r.readBits(1) === 1;\n r.readBits(4);\n markerType = outOfNetwork ? \"start\" : \"end\";\n\n if (programSpliceFlag && !spliceImmediateFlag) {\n ptsSeconds = readSpliceTime(r, ptsAdjustmentTicks);\n } else if (!programSpliceFlag) {\n const componentCount = r.readBits(8);\n for (let i = 0; i < componentCount; i++) {\n r.readBits(8);\n if (!spliceImmediateFlag) {\n const componentPtsSeconds = readSpliceTime(r, ptsAdjustmentTicks);\n if (ptsSeconds === undefined) {\n ptsSeconds = componentPtsSeconds;\n }\n }\n }\n }\n\n if (durationFlag) {\n r.readBits(6);\n r.readBits(1);\n const high = r.readBits(1);\n const low = r.readBits(32);\n const durationTicks = high * 0x100000000 + low;\n durationSeconds = durationTicks / 90000;\n }\n r.readBits(16);\n r.readBits(8);\n r.readBits(8);\n } else if (spliceCommandType === 6) {\n ptsSeconds = readSpliceTime(r, ptsAdjustmentTicks);\n } else {\n return undefined;\n }\n\n const expectedDescriptorOffset =\n spliceCommandLength === 0x0fff\n ? r.bytePosition\n : commandBodyStart + spliceCommandLength;\n const descriptorMarker = parseScte35SegmentationDescriptors(\n data,\n expectedDescriptorOffset\n );\n\n if (descriptorMarker) {\n markerType = descriptorMarker.type;\n if (durationSeconds === undefined) {\n durationSeconds = descriptorMarker.durationSeconds;\n }\n }\n\n if (!markerType) {\n return undefined;\n }\n\n const marker: Scte35Marker = {\n type: markerType,\n ...(ptsSeconds !== undefined ? { ptsSeconds } : {}),\n ...(durationSeconds !== undefined ? { durationSeconds } : {}),\n raw: {\n splice_command_type: spliceCommandType,\n ...(spliceEventId !== undefined ? { splice_event_id: spliceEventId } : {}),\n ...(descriptorMarker?.segmentationEventId !== undefined\n ? { segmentation_event_id: descriptorMarker.segmentationEventId }\n : {}),\n },\n } as Scte35Marker;\n return marker;\n}\n"]}
1
+ {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/player/Scte35CueManager.cjs"],"names":[],"mappings":"AAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/player/Scte35CueManager.ts\nvar Scte35CueManager_exports = {};\n__export(Scte35CueManager_exports, {\n Scte35CueManager: () => Scte35CueManager\n});\nmodule.exports = __toCommonJS(Scte35CueManager_exports);\n\n// src/player/Scte35Parser.ts\nfunction getFragmentStartSeconds(frag) {\n const candidates = [frag?.start, frag?.startPTS];\n for (const candidate of candidates) {\n if (typeof candidate === \"number\" && Number.isFinite(candidate)) {\n return candidate;\n }\n }\n return void 0;\n}\n\n// src/player/Scte35CueManager.ts\nvar Scte35CueManager = class {\n constructor(debug, callbacks) {\n this.pendingScte35Cues = /* @__PURE__ */ new Map();\n this.recentScte35CueKeys = /* @__PURE__ */ new Map();\n this.recentScte35CueLimit = 200;\n this.tsScte35Pids = /* @__PURE__ */ new Set();\n this.pmtPids = /* @__PURE__ */ new Set();\n this.processedTsScte35Sections = /* @__PURE__ */ new Set();\n this.debug = debug;\n this.callbacks = callbacks;\n }\n get pendingScte35CueKey() {\n return this.pendingScte35CueKeyValue;\n }\n set pendingScte35CueKey(value) {\n this.pendingScte35CueKeyValue = value;\n }\n get activeScte35BreakKey() {\n return this.activeScte35BreakKeyValue;\n }\n set activeScte35BreakKey(value) {\n this.activeScte35BreakKeyValue = value;\n }\n get scheduledScte35BreakKey() {\n return this.scheduledScte35BreakKeyValue;\n }\n set scheduledScte35BreakKey(value) {\n this.scheduledScte35BreakKeyValue = value;\n }\n createScte35CueContext(source, readiness, frag) {\n const context = { source, readiness };\n if (typeof frag?.sn === \"number\") {\n context.fragmentSn = frag.sn;\n }\n const fragmentStartSec = getFragmentStartSeconds(frag);\n if (fragmentStartSec !== void 0) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n return context;\n }\n onScte35Cue(marker, context) {\n const cue = this.createScte35Cue(marker, context);\n const pendingKey = this.getPendingScte35CueKey(cue);\n if (context.readiness === \"early\") {\n this.pendingScte35Cues.set(pendingKey, cue);\n this.trimRecentScte35CueMaps();\n if (marker.type === \"start\") {\n this.callbacks.onEarlyStartCue(marker, context.fragmentSn, cue.key);\n }\n return;\n }\n if (marker.type === \"end\" && !this.shouldAcceptScte35EndCue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring SCTE-35 end cue\", {\n key: cue.key,\n activeScte35BreakKey: this.activeScte35BreakKeyValue,\n inAdBreak: this.callbacks.isInAdBreak(),\n source: cue.source\n });\n }\n return;\n }\n if (marker.type === \"start\" && this.hasRecentlyHandledScte35Cue(cue)) {\n if (this.debug) {\n console.log(\"[StormcloudVideoPlayer] Ignoring duplicate SCTE-35 start cue\", {\n key: cue.key,\n source: cue.source\n });\n }\n return;\n }\n this.pendingScte35Cues.delete(pendingKey);\n this.markScte35CueHandled(cue);\n this.callbacks.onPlaybackCue(marker, cue.key);\n }\n activatePendingScte35CuesForFragment(frag) {\n const fragmentSn = typeof frag?.sn === \"number\" ? frag.sn : void 0;\n if (fragmentSn === void 0) {\n return;\n }\n const matchingCues = Array.from(this.pendingScte35Cues.entries()).filter(\n ([, cue]) => cue.fragmentSn === fragmentSn\n );\n matchingCues.forEach(([pendingKey, cue]) => {\n this.pendingScte35Cues.delete(pendingKey);\n const context = {\n source: cue.source,\n readiness: \"playback\"\n };\n context.fragmentSn = fragmentSn;\n const fragmentStartSec = cue.fragmentStartSeconds ?? getFragmentStartSeconds(frag);\n if (fragmentStartSec !== void 0) {\n context.fragmentStartSeconds = fragmentStartSec;\n }\n this.onScte35Cue(cue.marker, context);\n });\n }\n createScte35Cue(marker, context) {\n const cue = {\n marker,\n source: context.source,\n readiness: context.readiness,\n key: this.getScte35CueKey(marker, context)\n };\n if (context.fragmentSn !== void 0) {\n cue.fragmentSn = context.fragmentSn;\n }\n if (context.fragmentStartSeconds !== void 0) {\n cue.fragmentStartSeconds = context.fragmentStartSeconds;\n }\n return cue;\n }\n getScte35CueKey(marker, context) {\n const raw = this.getScte35MarkerRaw(marker);\n const spliceEventId = this.toIdentityString(raw?.splice_event_id);\n if (spliceEventId) {\n return `splice:${spliceEventId}`;\n }\n const segmentationEventId = this.toIdentityString(raw?.segmentation_event_id);\n if (segmentationEventId) {\n return `segmentation:${segmentationEventId}`;\n }\n const daterangeId = this.toIdentityString(raw?.attrs?.ID);\n if (daterangeId) {\n return `daterange:${daterangeId}`;\n }\n const scteValue = this.toIdentityString(raw?.attrs?.[\"SCTE35-OUT\"]) || this.toIdentityString(raw?.attrs?.[\"SCTE35-IN\"]);\n if (scteValue) {\n return `daterange-scte:${scteValue}`;\n }\n if (typeof marker.ptsSeconds === \"number\" && Number.isFinite(marker.ptsSeconds)) {\n return `pts:${Math.round(marker.ptsSeconds * 2) / 2}`;\n }\n if (context.fragmentSn !== void 0) {\n return `fragment:${context.fragmentSn}`;\n }\n return `${context.source}:wallclock:${Math.floor(Date.now() / 1e3)}`;\n }\n getPendingScte35CueKey(cue) {\n return `${cue.marker.type}:${cue.key}:${cue.fragmentSn !== void 0 ? cue.fragmentSn : \"unknown\"}`;\n }\n getScte35MarkerRaw(marker) {\n return typeof marker.raw === \"object\" && marker.raw !== null ? marker.raw : {};\n }\n toIdentityString(value) {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return String(value);\n }\n if (typeof value === \"string\" && value.trim().length > 0) {\n return value.trim();\n }\n return void 0;\n }\n isStrongScte35CueKey(key) {\n return !!(key && (key.startsWith(\"splice:\") || key.startsWith(\"segmentation:\") || key.startsWith(\"daterange:\") || key.startsWith(\"daterange-scte:\")));\n }\n hasRecentlyHandledScte35Cue(cue) {\n if (this.activeScte35BreakKeyValue === cue.key || this.scheduledScte35BreakKeyValue === cue.key) {\n return true;\n }\n const recentKey = `${cue.marker.type}:${cue.key}`;\n return this.recentScte35CueKeys.has(recentKey);\n }\n markScte35CueHandled(cue) {\n this.recentScte35CueKeys.set(`${cue.marker.type}:${cue.key}`, Date.now());\n this.trimRecentScte35CueMaps();\n }\n trimRecentScte35CueMaps() {\n while (this.recentScte35CueKeys.size > this.recentScte35CueLimit) {\n const firstKey = this.recentScte35CueKeys.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.recentScte35CueKeys.delete(firstKey);\n }\n while (this.pendingScte35Cues.size > this.recentScte35CueLimit) {\n const firstKey = this.pendingScte35Cues.keys().next().value;\n if (!firstKey) {\n break;\n }\n this.pendingScte35Cues.delete(firstKey);\n }\n }\n shouldAcceptScte35EndCue(cue) {\n if (!this.callbacks.isInAdBreak()) {\n return false;\n }\n if (this.isStrongScte35CueKey(this.activeScte35BreakKeyValue) && this.isStrongScte35CueKey(cue.key) && this.activeScte35BreakKeyValue !== cue.key) {\n return false;\n }\n return true;\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n Scte35CueManager\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { S as Scte35Marker } from '../types-cTqIKw_D.cjs';
1
+ import { S as Scte35Marker } from '../types-DpbgEvSH.cjs';
2
2
  import { Scte35CueSource, Scte35CueReadiness, Scte35CueContext } from './playerTypes.cjs';
3
3
 
4
4
  interface Scte35CueManagerCallbacks {
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  function _class_call_check(instance, Constructor) {
3
- if (!(instance instanceof Constructor)) {
4
- throw new TypeError("Cannot call a class as a function");
5
- }
3
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
6
4
  }
7
5
  function _defineProperties(target, props) {
8
6
  for(var i = 0; i < props.length; i++){
@@ -26,17 +24,14 @@ function _define_property(obj, key, value) {
26
24
  configurable: true,
27
25
  writable: true
28
26
  });
29
- } else {
30
- obj[key] = value;
31
- }
27
+ } else obj[key] = value;
32
28
  return obj;
33
29
  }
34
30
  function _instanceof(left, right) {
31
+ "@swc/helpers - instanceof";
35
32
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
36
33
  return !!right[Symbol.hasInstance](left);
37
- } else {
38
- return left instanceof right;
39
- }
34
+ } else return left instanceof right;
40
35
  }
41
36
  function _object_spread(target) {
42
37
  for(var i = 1; i < arguments.length; i++){
@@ -68,9 +63,8 @@ function ownKeys(object, enumerableOnly) {
68
63
  }
69
64
  function _object_spread_props(target, source) {
70
65
  source = source != null ? source : {};
71
- if (Object.getOwnPropertyDescriptors) {
72
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
73
- } else {
66
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
67
+ else {
74
68
  ownKeys(Object(source)).forEach(function(key) {
75
69
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
76
70
  });