@hyperframes/player 0.7.15 → 0.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/slideshow/hyperframes-slideshow.cjs +3 -3
- package/dist/slideshow/hyperframes-slideshow.cjs.map +1 -1
- package/dist/slideshow/hyperframes-slideshow.global.js +3 -3
- package/dist/slideshow/hyperframes-slideshow.global.js.map +1 -1
- package/dist/slideshow/hyperframes-slideshow.js +2 -2
- package/dist/slideshow/hyperframes-slideshow.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var U="application/hyperframes-slideshow+json";function K(i="i"){let e=U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<script[^>]*type=["']${e}["'][^>]*>([\\s\\S]*?)<\\/script>`,i)}function E(i){let t=K("i").exec(i);if(!t||t[1]===void 0)return null;let n=t[1].trim();if(n.length===0)return null;let r=JSON.parse(n);if(!Y(r))throw new Error("slideshow island is not a valid SlideshowManifest");return r}function z(i){return i===void 0||Array.isArray(i)&&i.every(e=>typeof e=="number")}function G(i){return i===void 0||typeof i=="boolean"}function I(i){if(typeof i!="object"||i===null)return!1;let e=i;return!(typeof e.sceneId!="string"||!z(e.fragments)||e.hotspots!==void 0&&!Array.isArray(e.hotspots)||!G(e.autoplay))}function j(i){if(typeof i!="object"||i===null)return!1;let e=i;return typeof e.id=="string"&&typeof e.label=="string"&&Array.isArray(e.slides)&&e.slides.every(I)}function Y(i){if(typeof i!="object"||i===null||Array.isArray(i))return!1;let e=i;return!(!Array.isArray(e.slides)||!e.slides.every(I)||e.slideSequences!==void 0&&(!Array.isArray(e.slideSequences)||!e.slideSequences.every(j)))}function V(i,e){return`slide "${i}" sets ${e==="startTime"?"endTime":"startTime"} but ${e} cannot be resolved (no scene "${i}")`}function W(i,e,t){let{startTime:n,endTime:r,sceneId:s}=i;if(n!==void 0&&r!==void 0)return{start:n,end:r};if(n===void 0&&r===void 0)return e?{start:e.start,end:e.start+e.duration}:(t.push(`slide references unresolved sceneId "${s}"`),{start:0,end:0});if(!e){let o=n===void 0?"startTime":"endTime";t.push(V(s,o));let d=n??r??0;return{start:d,end:d}}return{start:n??e.start,end:r??e.start+e.duration}}function X(i,e,t,n,r){for(let s of e)(s<t||s>n)&&r.push(`slide "${i}" fragment ${s} is outside range [${t}, ${n}]`)}function T(i,e,t){let n=e.get(i.sceneId),{start:r,end:s}=W(i,n,t);i.startTime!==void 0&&i.endTime!==void 0&&s<=r&&t.push(`slide "${i.sceneId}" has endTime (${s}) <= startTime (${r})`);let o=[...new Set(i.fragments??[])].sort((d,a)=>d-a);return X(i.sceneId,o,r,s,t),{...i,start:r,end:s,fragments:o,hotspots:i.hotspots??[]}}function P(i,e){let t=[],n=new Map(e.map(a=>[a.id,a])),r={};for(let a of i.slideSequences??[])Object.prototype.hasOwnProperty.call(r,a.id)&&t.push(`duplicate slideSequence id "${a.id}" \u2014 only the last definition is kept`),r[a.id]={id:a.id,label:a.label,slides:a.slides.map(l=>T(l,n,t))};let s=i.slides.map(a=>T(a,n,t)),o=[...s,...Object.values(r).flatMap(a=>a.slides)];for(let a of o)for(let l of a.hotspots){let u=r[l.target];u?u.slides.length===0&&t.push(`hotspot "${l.id}" targets empty sequence "${l.target}"`):t.push(`hotspot "${l.id}" targets unknown sequence "${l.target}"`)}let d=[...s].sort((a,l)=>a.start-l.start);for(let a=1;a<d.length;a++){let l=d[a-1],u=d[a];l!==void 0&&u!==void 0&&u.start<l.end&&t.push(`main-line slides "${l.sceneId}" and "${u.sceneId}" overlap`)}return{resolved:{slides:s,sequences:r},errors:t}}var f="main",y=class{constructor(e,t){this.player=e;this.show=t;this.enterSlide(0)}player;show;stack=[{sequenceId:f,slideIndex:0,fragmentIndex:-1}];changeCbs=new Set;dispose(){}slidesOf(e){return e===f?this.show.slides:this.show.sequences[e]?.slides??[]}get frame(){return this.stack[this.stack.length-1]}get currentSlide(){return this.slidesOf(this.frame.sequenceId)[this.frame.slideIndex]}get nextSlide(){return this.slidesOf(this.frame.sequenceId)[this.frame.slideIndex+1]??null}get position(){return{...this.frame}}get counter(){return{index:this.frame.slideIndex+1,total:this.slidesOf(this.frame.sequenceId).length}}get canPrev(){return this.frame.slideIndex>0||this.stack.length>1}get canNext(){let e=this.slidesOf(this.frame.sequenceId);return this.frame.slideIndex+1<e.length||this.stack.length>1}get breadcrumb(){return this.stack.map(e=>e.sequenceId===f?{id:f,label:"Main deck"}:{id:e.sequenceId,label:this.show.sequences[e.sequenceId]?.label??e.sequenceId})}onChange(e){return this.changeCbs.add(e),()=>this.changeCbs.delete(e)}emitChange(){for(let e of this.changeCbs)e()}stopSlideMedia(){this.player.stopMedia?.()}enterSlide(e){e!==this.frame.slideIndex&&this.stopSlideMedia(),this.frame.slideIndex=e;let t=this.currentSlide;if(!t){this.frame.fragmentIndex=-1;return}t.fragments.length>0?(this.frame.fragmentIndex=0,this.playTo(t.fragments[0]??t.end)):(this.frame.fragmentIndex=-1,this.playTo(this.restFrame(t))),t.autoplay&&this.player.playSceneMedia?.(t.sceneId),this.emitChange()}restFrame(e){return e.start+(e.end-e.start)*.5}resumeSlide(e,t){this.frame.slideIndex=e,this.frame.fragmentIndex=t;let n=this.currentSlide;if(!n)return;let r=t>=0&&t<n.fragments.length?n.fragments[t]??n.start:n.fragments.length>0?n.start:this.restFrame(n);this.playTo(r),this.emitChange()}playTo(e){this.player.seek(e)}next(){let e=this.currentSlide;if(!e)return;if(this.frame.fragmentIndex+1<e.fragments.length){this.frame.fragmentIndex+=1;let r=e.fragments[this.frame.fragmentIndex]??e.end;this.playTo(r),this.emitChange();return}let n=this.slidesOf(this.frame.sequenceId);this.frame.slideIndex+1<n.length?this.enterSlide(this.frame.slideIndex+1):this.stack.length>1&&this.back()}prev(){if(this.frame.slideIndex>0){this.enterSlide(this.frame.slideIndex-1);return}this.stack.length>1&&this.back()}goToSlide(e){let t=this.slidesOf(this.frame.sequenceId);e>=0&&e<t.length&&this.enterSlide(e)}enterBranch(e){let t=this.show.sequences[e];!t||t.slides.length===0||(this.stopSlideMedia(),this.stack.push({sequenceId:e,slideIndex:0,fragmentIndex:-1}),this.enterSlide(0))}back(){this.stack.length<=1||(this.stopSlideMedia(),this.stack.pop(),this.resumeSlide(this.frame.slideIndex,this.frame.fragmentIndex))}backToMain(){this.stack.length<=1||(this.stopSlideMedia(),this.stack=[this.stack[0]],this.resumeSlide(this.frame.slideIndex,this.frame.fragmentIndex))}syncTo(e,t,n){this.isValidSyncTarget(e,t)&&(this.isCrossSlide(e,t)&&this.stopSlideMedia(),this.rerootStackTo(e)&&this.resumeSlide(t,n))}isValidSyncTarget(e,t){if(!this.stack[0])return!1;let n=e===f?this.show.slides:this.show.sequences[e]?.slides??null;return n?t>=0&&t<n.length:!1}isCrossSlide(e,t){return this.frame.sequenceId!==e||this.frame.slideIndex!==t}rerootStackTo(e){if(this.frame.sequenceId===e)return!0;let t=this.stack[0];if(!t)return!1;if(this.stack=[t],e===f)return!0;let n=this.show.sequences[e];return!n||n.slides.length===0?!1:(this.stack.push({sequenceId:e,slideIndex:0,fragmentIndex:-1}),!0)}};var A="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",J=new Set(["play","pause","seeking","seeked","ratechange","volumechange","ended","timeupdate"]),Q=["currentTime","volume","playbackRate"],Z=["paused","ended","muted"];function
|
|
1
|
+
var U="application/hyperframes-slideshow+json";function K(i="i"){let e=U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`<script[^>]*type=["']${e}["'][^>]*>([\\s\\S]*?)<\\/script>`,i)}function E(i){let t=K("i").exec(i);if(!t||t[1]===void 0)return null;let n=t[1].trim();if(n.length===0)return null;let r=JSON.parse(n);if(!Y(r))throw new Error("slideshow island is not a valid SlideshowManifest");return r}function z(i){return i===void 0||Array.isArray(i)&&i.every(e=>typeof e=="number")}function G(i){return i===void 0||typeof i=="boolean"}function I(i){if(typeof i!="object"||i===null)return!1;let e=i;return!(typeof e.sceneId!="string"||!z(e.fragments)||e.hotspots!==void 0&&!Array.isArray(e.hotspots)||!G(e.autoplay))}function j(i){if(typeof i!="object"||i===null)return!1;let e=i;return typeof e.id=="string"&&typeof e.label=="string"&&Array.isArray(e.slides)&&e.slides.every(I)}function Y(i){if(typeof i!="object"||i===null||Array.isArray(i))return!1;let e=i;return!(!Array.isArray(e.slides)||!e.slides.every(I)||e.slideSequences!==void 0&&(!Array.isArray(e.slideSequences)||!e.slideSequences.every(j)))}function V(i,e){return`slide "${i}" sets ${e==="startTime"?"endTime":"startTime"} but ${e} cannot be resolved (no scene "${i}")`}function W(i,e,t){let{startTime:n,endTime:r,sceneId:s}=i;if(n!==void 0&&r!==void 0)return{start:n,end:r};if(n===void 0&&r===void 0)return e?{start:e.start,end:e.start+e.duration}:(t.push(`slide references unresolved sceneId "${s}"`),{start:0,end:0});if(!e){let o=n===void 0?"startTime":"endTime";t.push(V(s,o));let d=n??r??0;return{start:d,end:d}}return{start:n??e.start,end:r??e.start+e.duration}}function X(i,e,t,n,r){for(let s of e)(s<t||s>n)&&r.push(`slide "${i}" fragment ${s} is outside range [${t}, ${n}]`)}function T(i,e,t){let n=e.get(i.sceneId),{start:r,end:s}=W(i,n,t);i.startTime!==void 0&&i.endTime!==void 0&&s<=r&&t.push(`slide "${i.sceneId}" has endTime (${s}) <= startTime (${r})`);let o=[...new Set(i.fragments??[])].sort((d,a)=>d-a);return X(i.sceneId,o,r,s,t),{...i,start:r,end:s,fragments:o,hotspots:i.hotspots??[]}}function P(i,e){let t=[],n=new Map(e.map(a=>[a.id,a])),r={};for(let a of i.slideSequences??[])Object.prototype.hasOwnProperty.call(r,a.id)&&t.push(`duplicate slideSequence id "${a.id}" \u2014 only the last definition is kept`),r[a.id]={id:a.id,label:a.label,slides:a.slides.map(l=>T(l,n,t))};let s=i.slides.map(a=>T(a,n,t)),o=[...s,...Object.values(r).flatMap(a=>a.slides)];for(let a of o)for(let l of a.hotspots){let u=r[l.target];u?u.slides.length===0&&t.push(`hotspot "${l.id}" targets empty sequence "${l.target}"`):t.push(`hotspot "${l.id}" targets unknown sequence "${l.target}"`)}let d=[...s].sort((a,l)=>a.start-l.start);for(let a=1;a<d.length;a++){let l=d[a-1],u=d[a];l!==void 0&&u!==void 0&&u.start<l.end&&t.push(`main-line slides "${l.sceneId}" and "${u.sceneId}" overlap`)}return{resolved:{slides:s,sequences:r},errors:t}}var f="main",y=class{constructor(e,t){this.player=e;this.show=t;this.enterSlide(0)}player;show;stack=[{sequenceId:f,slideIndex:0,fragmentIndex:-1}];changeCbs=new Set;dispose(){}slidesOf(e){return e===f?this.show.slides:this.show.sequences[e]?.slides??[]}get frame(){return this.stack[this.stack.length-1]}get currentSlide(){return this.slidesOf(this.frame.sequenceId)[this.frame.slideIndex]}get nextSlide(){return this.slidesOf(this.frame.sequenceId)[this.frame.slideIndex+1]??null}get position(){return{...this.frame}}get counter(){return{index:this.frame.slideIndex+1,total:this.slidesOf(this.frame.sequenceId).length}}get canPrev(){return this.frame.slideIndex>0||this.stack.length>1}get canNext(){let e=this.slidesOf(this.frame.sequenceId);return this.frame.slideIndex+1<e.length||this.stack.length>1}get breadcrumb(){return this.stack.map(e=>e.sequenceId===f?{id:f,label:"Main deck"}:{id:e.sequenceId,label:this.show.sequences[e.sequenceId]?.label??e.sequenceId})}onChange(e){return this.changeCbs.add(e),()=>this.changeCbs.delete(e)}emitChange(){for(let e of this.changeCbs)e()}stopSlideMedia(){this.player.stopMedia?.()}enterSlide(e){e!==this.frame.slideIndex&&this.stopSlideMedia(),this.frame.slideIndex=e;let t=this.currentSlide;if(!t){this.frame.fragmentIndex=-1;return}t.fragments.length>0?(this.frame.fragmentIndex=0,this.playTo(t.fragments[0]??t.end)):(this.frame.fragmentIndex=-1,this.playTo(this.restFrame(t))),t.autoplay&&this.player.playSceneMedia?.(t.sceneId),this.emitChange()}restFrame(e){return e.start+(e.end-e.start)*.5}resumeSlide(e,t){this.frame.slideIndex=e,this.frame.fragmentIndex=t;let n=this.currentSlide;if(!n)return;let r=t>=0&&t<n.fragments.length?n.fragments[t]??n.start:n.fragments.length>0?n.start:this.restFrame(n);this.playTo(r),this.emitChange()}playTo(e){this.player.seek(e)}next(){let e=this.currentSlide;if(!e)return;if(this.frame.fragmentIndex+1<e.fragments.length){this.frame.fragmentIndex+=1;let r=e.fragments[this.frame.fragmentIndex]??e.end;this.playTo(r),this.emitChange();return}let n=this.slidesOf(this.frame.sequenceId);this.frame.slideIndex+1<n.length?this.enterSlide(this.frame.slideIndex+1):this.stack.length>1&&this.back()}prev(){if(this.frame.slideIndex>0){this.enterSlide(this.frame.slideIndex-1);return}this.stack.length>1&&this.back()}goToSlide(e){let t=this.slidesOf(this.frame.sequenceId);e>=0&&e<t.length&&this.enterSlide(e)}enterBranch(e){let t=this.show.sequences[e];!t||t.slides.length===0||(this.stopSlideMedia(),this.stack.push({sequenceId:e,slideIndex:0,fragmentIndex:-1}),this.enterSlide(0))}back(){this.stack.length<=1||(this.stopSlideMedia(),this.stack.pop(),this.resumeSlide(this.frame.slideIndex,this.frame.fragmentIndex))}backToMain(){this.stack.length<=1||(this.stopSlideMedia(),this.stack=[this.stack[0]],this.resumeSlide(this.frame.slideIndex,this.frame.fragmentIndex))}syncTo(e,t,n){this.isValidSyncTarget(e,t)&&(this.isCrossSlide(e,t)&&this.stopSlideMedia(),this.rerootStackTo(e)&&this.resumeSlide(t,n))}isValidSyncTarget(e,t){if(!this.stack[0])return!1;let n=e===f?this.show.slides:this.show.sequences[e]?.slides??null;return n?t>=0&&t<n.length:!1}isCrossSlide(e,t){return this.frame.sequenceId!==e||this.frame.slideIndex!==t}rerootStackTo(e){if(this.frame.sequenceId===e)return!0;let t=this.stack[0];if(!t)return!1;if(this.stack=[t],e===f)return!0;let n=this.show.sequences[e];return!n||n.slides.length===0?!1:(this.stack.push({sequenceId:e,slideIndex:0,fragmentIndex:-1}),!0)}};var A="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",J=new Set(["play","pause","seeking","seeked","ratechange","volumechange","ended","timeupdate"]),Q=["currentTime","volume","playbackRate"],Z=["paused","ended","muted"];function $(i){return!(typeof i!="object"||i===null)}function ee(i){if(!$(i))return!1;let e=i;return e.type==="goto"&&typeof e.sequenceId=="string"&&typeof e.slideIndex=="number"&&typeof e.fragmentIndex=="number"}function te(i){return J.has(i)}function ne(i){return i==="presenter"||i==="audience"}function ie(i){return Q.every(e=>typeof i[e]=="number")}function re(i){return Z.every(e=>typeof i[e]=="boolean")}function se(i){if(!$(i))return!1;let e=i;return e.type==="media"&&ne(e.sender)&&typeof e.key=="string"&&te(e.action)&&ie(e)&&re(e)}function oe(){return`hf-slideshow:${typeof location<"u"?location.pathname:""}`}var m=class{constructor(e,t,n=()=>{}){this.mode=e;this.onGoto=t;this.onMedia=n;try{this.channel=new BroadcastChannel(oe())}catch{return}this.channel.onmessage=r=>{if(ee(r.data)){e==="audience"&&this.onGoto(r.data);return}se(r.data)&&r.data.sender!==e&&this.onMedia(r.data)}}mode;onGoto;onMedia;channel=null;postPosition(e){if(this.mode!=="presenter"||!this.channel)return;let t={type:"goto",...e};this.channel.postMessage(t)}postMedia(e){this.channel&&this.channel.postMessage({type:"media",sender:this.mode,...e})}destroy(){this.channel&&(this.channel.onmessage=null,this.channel.close(),this.channel=null)}};function C(i){let e=s=>s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),t=s=>e(s).replace(/"/g,"""),n=e(i.notes),r=i.hotspots.length?`<div style="display:flex;flex-direction:column;gap:6px;">
|
|
2
2
|
<div style="font-size:12px;text-transform:uppercase;letter-spacing:.12em;opacity:.55;">Branches</div>
|
|
3
3
|
${i.hotspots.map(s=>`<button data-hotspot-id="${t(s.id)}" data-hotspot-target="${t(s.target)}" type="button" title="${t(s.label)}" style="text-align:left;background:rgba(244,183,64,0.14);color:#f4b740;border:1px solid rgba(244,183,64,0.4);border-radius:8px;padding:8px 12px;font-size:15px;cursor:pointer;pointer-events:auto;font-family:inherit;">↳ ${e(s.label)}</button>`).join("")}
|
|
4
4
|
</div>`:"";return`
|
|
@@ -144,6 +144,6 @@ var U="application/hyperframes-slideshow+json";function K(i="i"){let e=U.replace
|
|
|
144
144
|
<span aria-hidden="true" style="width:1px;height:20px;background:rgba(255,255,255,0.12);margin:0 2px;flex-shrink:0;"></span>
|
|
145
145
|
${O}
|
|
146
146
|
${S}
|
|
147
|
-
</div>`}wireChromeButtons(){let e=this.chrome;e&&(this.wireChromeClick(e,"[data-hf-mute]",()=>this.toggleMute()),this.wireChromeClick(e,"[data-hf-prev]",()=>this.controller?.prev()),this.wireChromeClick(e,"[data-hf-next]",()=>this.controller?.next()),this.wireChromeClick(e,"[data-hf-present]",()=>this.present()),this.wireChromeClick(e,"[data-hf-fullscreen]",()=>this.toggleFullscreen()),this.wirePresenterNotes(e),this.wireHotspots(e))}wireChromeClick(e,t,n){let r=e.querySelector(t);r&&r.addEventListener("click",n)}wirePresenterNotes(e){let t=e.querySelector("[data-hf-presenter-notes]");if(t instanceof HTMLTextAreaElement){let n=t.getAttribute("data-hf-presenter-notes-key");t.addEventListener("input",()=>this.writePresenterNotes(n,t.value))}}wireHotspots(e){for(let t of e.querySelectorAll("[data-hotspot-id]")){let n=t.getAttribute("data-hotspot-target")??"";t.addEventListener("click",()=>this.controller?.enterBranch?.(n))}}onFsChange=()=>{let e=this.chrome?.querySelector("[data-hf-fullscreen]");if(!e)return;let t=document.fullscreenElement===this;e.innerHTML=t?q:N;let n=t?"Exit full screen":"Full screen";e.setAttribute("aria-label",n),e.setAttribute("title",n),e.setAttribute("data-hf-tooltip",n),e.setAttribute("aria-pressed",t?"true":"false")};toggleFullscreen(){document.fullscreenElement===this?document.exitFullscreen().catch(()=>{}):this.requestFullscreen().catch(()=>{})}shouldShowPresentControl(){return this.resolveMode()!=="audience"&&this.getAttribute("data-hf-presenting")!=="true"}toggleMute(){this._muted=!this._muted,this._muted?this.setAttribute("data-hf-muted",""):this.removeAttribute("data-hf-muted"),this.applyGlobalMute(this._muted),this.dispatchEvent(new CustomEvent("hf-sound",{detail:{muted:this._muted},bubbles:!0,composed:!0})),this.render()}applyGlobalMute(e){for(let n of this.querySelectorAll("hyperframes-player")){if(!(n instanceof HTMLElement))continue;let r=n;"muted"in r?r.muted=e:e?r.setAttribute("muted",""):r.removeAttribute("muted")}let t=this.ownerDocument;for(let n of t.querySelectorAll("video, audio"))n instanceof HTMLMediaElement&&(n.muted=e||n.defaultMuted)}stopDocumentMedia(){this.autoplayToken++;let e=this.ownerDocument;for(let t of e.querySelectorAll("video, audio"))t instanceof HTMLMediaElement&&t.pause()}playSceneDocumentMedia(e){if(this.resolveMode()==="audience")return;let t=e.replace(/["\\]/g,"\\$&"),n=++this.autoplayToken,r={started:!1,lastTime:-1,advancingTicks:0,waited:0,warned:!1},s=()=>{if(n!==this.autoplayToken)return;let o=this.stepAutoplay(t,r);r.waited+=L,!o&&r.waited<=ae&&window.setTimeout(s,L)};s()}findSceneVideo(e){for(let t of this.mediaPlayerElements()){let r=this.playerFrameDocument(t)?.querySelector(`[data-composition-id="${e}"] video`)??null;if(r instanceof HTMLVideoElement)return r}return null}stepAutoplay(e,t){let n=this.findSceneVideo(e);if(!n)return!1;if(!t.started){t.started=!0,n.muted=this._muted||n.defaultMuted;try{n.currentTime=0}catch{}}let r=!n.paused&&n.currentTime>t.lastTime;return t.lastTime=n.currentTime,r?++t.advancingTicks>=2:(t.advancingTicks=0,n.play().catch(s=>{let o=s instanceof DOMException?s.name:"";o!=="AbortError"&&o!=="NotAllowedError"&&!t.warned&&(t.warned=!0,console.warn("[hyperframes-slideshow] autoplay play() failed:",s))}),!1)}presenterNotesDeckKey(){let e=this.getAttribute("notes-storage-key")?.trim();if(e)return e;let t=this.querySelector("hyperframes-player")?.getAttribute("src")??"",n=t;try{let o=typeof location<"u"?location.href:"http://localhost/";n=new URL(t,o).href}catch{}let r=typeof location<"u"?`${location.origin}${location.pathname}`:"",s=this.ownerDocument.title;return`${r}|${s}|${n}`}presenterNotesStorageKey(e){let t=this.controller?.position;return t?`${de}${JSON.stringify([this.presenterNotesDeckKey(),t.sequenceId,t.slideIndex,e.sceneId??""])}`:null}readPresenterNotes(e){if(!e||typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}writePresenterNotes(e,t){if(e&&!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}renderPresenter(){if(!this.controller)return;let{counter:e,currentSlide:t,nextSlide:n}=this.controller;if(!t)return;let r=this.presenterStartMs!==null?Math.floor((Date.now()-this.presenterStartMs)/1e3):0,s=this.querySelector("hyperframes-player");s instanceof HTMLElement&&(s.style.top="0",s.style.bottom="32%",s.style.height="auto");let o=this.presenterNotesStorageKey(t),d=this.readPresenterNotes(o)??t.notes??"";this.paintChrome(
|
|
147
|
+
</div>`}wireChromeButtons(){let e=this.chrome;e&&(this.wireChromeClick(e,"[data-hf-mute]",()=>this.toggleMute()),this.wireChromeClick(e,"[data-hf-prev]",()=>this.controller?.prev()),this.wireChromeClick(e,"[data-hf-next]",()=>this.controller?.next()),this.wireChromeClick(e,"[data-hf-present]",()=>this.present()),this.wireChromeClick(e,"[data-hf-fullscreen]",()=>this.toggleFullscreen()),this.wirePresenterNotes(e),this.wireHotspots(e))}wireChromeClick(e,t,n){let r=e.querySelector(t);r&&r.addEventListener("click",n)}wirePresenterNotes(e){let t=e.querySelector("[data-hf-presenter-notes]");if(t instanceof HTMLTextAreaElement){let n=t.getAttribute("data-hf-presenter-notes-key");t.addEventListener("input",()=>this.writePresenterNotes(n,t.value))}}wireHotspots(e){for(let t of e.querySelectorAll("[data-hotspot-id]")){let n=t.getAttribute("data-hotspot-target")??"";t.addEventListener("click",()=>this.controller?.enterBranch?.(n))}}onFsChange=()=>{let e=this.chrome?.querySelector("[data-hf-fullscreen]");if(!e)return;let t=document.fullscreenElement===this;e.innerHTML=t?q:N;let n=t?"Exit full screen":"Full screen";e.setAttribute("aria-label",n),e.setAttribute("title",n),e.setAttribute("data-hf-tooltip",n),e.setAttribute("aria-pressed",t?"true":"false")};toggleFullscreen(){document.fullscreenElement===this?document.exitFullscreen().catch(()=>{}):this.requestFullscreen().catch(()=>{})}shouldShowPresentControl(){return this.resolveMode()!=="audience"&&this.getAttribute("data-hf-presenting")!=="true"}toggleMute(){this._muted=!this._muted,this._muted?this.setAttribute("data-hf-muted",""):this.removeAttribute("data-hf-muted"),this.applyGlobalMute(this._muted),this.dispatchEvent(new CustomEvent("hf-sound",{detail:{muted:this._muted},bubbles:!0,composed:!0})),this.render()}applyGlobalMute(e){for(let n of this.querySelectorAll("hyperframes-player")){if(!(n instanceof HTMLElement))continue;let r=n;"muted"in r?r.muted=e:e?r.setAttribute("muted",""):r.removeAttribute("muted")}let t=this.ownerDocument;for(let n of t.querySelectorAll("video, audio"))n instanceof HTMLMediaElement&&(n.muted=e||n.defaultMuted)}stopDocumentMedia(){this.autoplayToken++;let e=this.ownerDocument;for(let t of e.querySelectorAll("video, audio"))t instanceof HTMLMediaElement&&t.pause()}playSceneDocumentMedia(e){if(this.resolveMode()==="audience")return;let t=e.replace(/["\\]/g,"\\$&"),n=++this.autoplayToken,r={started:!1,lastTime:-1,advancingTicks:0,waited:0,warned:!1},s=()=>{if(n!==this.autoplayToken)return;let o=this.stepAutoplay(t,r);r.waited+=L,!o&&r.waited<=ae&&window.setTimeout(s,L)};s()}findSceneVideo(e){for(let t of this.mediaPlayerElements()){let r=this.playerFrameDocument(t)?.querySelector(`[data-composition-id="${e}"] video`)??null;if(r instanceof HTMLVideoElement)return r}return null}stepAutoplay(e,t){let n=this.findSceneVideo(e);if(!n)return!1;if(!t.started){t.started=!0,n.muted=this._muted||n.defaultMuted;try{n.currentTime=0}catch{}}let r=!n.paused&&n.currentTime>t.lastTime;return t.lastTime=n.currentTime,r?++t.advancingTicks>=2:(t.advancingTicks=0,n.play().catch(s=>{let o=s instanceof DOMException?s.name:"";o!=="AbortError"&&o!=="NotAllowedError"&&!t.warned&&(t.warned=!0,console.warn("[hyperframes-slideshow] autoplay play() failed:",s))}),!1)}presenterNotesDeckKey(){let e=this.getAttribute("notes-storage-key")?.trim();if(e)return e;let t=this.querySelector("hyperframes-player")?.getAttribute("src")??"",n=t;try{let o=typeof location<"u"?location.href:"http://localhost/";n=new URL(t,o).href}catch{}let r=typeof location<"u"?`${location.origin}${location.pathname}`:"",s=this.ownerDocument.title;return`${r}|${s}|${n}`}presenterNotesStorageKey(e){let t=this.controller?.position;return t?`${de}${JSON.stringify([this.presenterNotesDeckKey(),t.sequenceId,t.slideIndex,e.sceneId??""])}`:null}readPresenterNotes(e){if(!e||typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}writePresenterNotes(e,t){if(e&&!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}renderPresenter(){if(!this.controller)return;let{counter:e,currentSlide:t,nextSlide:n}=this.controller;if(!t)return;let r=this.presenterStartMs!==null?Math.floor((Date.now()-this.presenterStartMs)/1e3):0,s=this.querySelector("hyperframes-player");s instanceof HTMLElement&&(s.style.top="0",s.style.bottom="32%",s.style.height="auto");let o=this.presenterNotesStorageKey(t),d=this.readPresenterNotes(o)??t.notes??"";this.paintChrome(C({notes:d,notesStorageKey:o,nextText:pe(n),counterText:`${e.index} / ${e.total}`,elapsedText:x(r),hotspots:t.hotspots})+this.buildNavCluster(e,"calc(32% + 18px)"))}};function pe(i){if(i===null)return"End of sequence";let e=i.notes!=null?i.notes.split(`
|
|
148
148
|
`)[0]??"":"";return e.length>0?`${h(i.sceneId)}: ${h(e)}`:h(i.sceneId)}function fe(i){let e=i.ownerDocument.defaultView;return!e||typeof e.HTMLMediaElement!="function"?!1:i instanceof e.HTMLMediaElement}function v(i,e){return Number.isFinite(i)?i:e}function k(i){return"scenes"in i&&Array.isArray(i.scenes)?i.scenes:[]}var me=5e3;function ve(i){return i.ready===!0?Promise.resolve():new Promise(e=>{let t=null,n=()=>{t!==null&&(clearTimeout(t),t=null),e()};i.addEventListener("ready",n,{once:!0}),t=setTimeout(()=>{i.removeEventListener("ready",n),e()},me)})}function ye(i,e,t=()=>!1){let n=k(i);if(n.length>0)return Promise.resolve(n);let r=Math.ceil(e/100);return new Promise(s=>{let o=!1,d=null,a=0,l=c=>{o||(o=!0,d!==null&&clearTimeout(d),i.removeEventListener("scenes",u),s(c))},u=()=>{if(t())return l([]);let c=k(i);c.length>0&&l(c)},p=()=>{if(o)return;if(t())return l([]);let c=k(i);if(c.length>0)return l(c);if(a+=1,a>=r)return l([]);d=setTimeout(p,100)};i.addEventListener("scenes",u),d=setTimeout(p,100)})}function ge(i){let e=r=>r.end>r.start,t=i.slides.filter(e),n={};for(let[r,s]of Object.entries(i.sequences))n[r]={...s,slides:s.slides.filter(e)};return{slides:t,sequences:n}}function h(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}customElements.get("hyperframes-slideshow")||customElements.define("hyperframes-slideshow",w);export{w as HyperframesSlideshow,ge as dropInvalidSlides};
|
|
149
149
|
//# sourceMappingURL=hyperframes-slideshow.js.map
|