@readium/navigator 2.8.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{AudioPreferences as l}from"./AudioPreferences.js";import{RangePreference as t,BooleanPreference as i,Preference as p}from"../../preferences/Preference.js";import{volumeRangeConfig as a,playbackRateRangeConfig as s,skipIntervalRangeConfig as n}from"../../preferences/Types.js";class h{constructor(e,r){this.preferences=e,this.settings=r}clear(){this.preferences=new l}updatePreference(e,r){this.preferences[e]=r}get volume(){return new t({initialValue:this.preferences.volume,effectiveValue:this.settings.volume,isEffective:this.preferences.volume!==null,onChange:e=>{this.updatePreference("volume",e??null)},supportedRange:a.range,step:a.step})}get playbackRate(){return new t({initialValue:this.preferences.playbackRate,effectiveValue:this.settings.playbackRate,isEffective:this.preferences.playbackRate!==null,onChange:e=>{this.updatePreference("playbackRate",e??null)},supportedRange:s.range,step:s.step})}get preservePitch(){return new i({initialValue:this.preferences.preservePitch,effectiveValue:this.settings.preservePitch,isEffective:this.preferences.preservePitch!==null,onChange:e=>{this.updatePreference("preservePitch",e??null)}})}get skipBackwardInterval(){return new t({initialValue:this.preferences.skipBackwardInterval,effectiveValue:this.settings.skipBackwardInterval,isEffective:this.preferences.skipBackwardInterval!==null,onChange:e=>{this.updatePreference("skipBackwardInterval",e??null)},supportedRange:n.range,step:n.step})}get skipForwardInterval(){return new t({initialValue:this.preferences.skipForwardInterval,effectiveValue:this.settings.skipForwardInterval,isEffective:this.preferences.skipForwardInterval!==null,onChange:e=>{this.updatePreference("skipForwardInterval",e??null)},supportedRange:n.range,step:n.step})}get pollInterval(){return new p({initialValue:this.preferences.pollInterval,effectiveValue:this.settings.pollInterval,isEffective:this.preferences.pollInterval!==null,onChange:e=>{this.updatePreference("pollInterval",e??null)}})}get autoPlay(){return new i({initialValue:this.preferences.autoPlay,effectiveValue:this.settings.autoPlay,isEffective:this.preferences.autoPlay!==null,onChange:e=>{this.updatePreference("autoPlay",e??null)}})}get enableMediaSession(){return new i({initialValue:this.preferences.enableMediaSession,effectiveValue:this.settings.enableMediaSession,isEffective:this.preferences.enableMediaSession!==null,onChange:e=>{this.updatePreference("enableMediaSession",e??null)}})}}export{h as AudioPreferencesEditor};
1
+ import{AudioPreferences as i}from"./AudioPreferences.js";import{RangePreference as t,BooleanPreference as a,Preference as p}from"../../preferences/Preference.js";import{volumeRangeConfig as l,playbackRateRangeConfig as s,skipIntervalRangeConfig as n}from"../../preferences/Types.js";class h{constructor(e,r){this.preferences=new i({...e}),this.settings=r}clear(){this.preferences=new i({volume:null,playbackRate:null,preservePitch:null,skipBackwardInterval:null,skipForwardInterval:null,pollInterval:null,autoPlay:null,enableMediaSession:null})}updatePreference(e,r){this.preferences[e]=r}get volume(){return new t({initialValue:this.preferences.volume,effectiveValue:this.settings.volume,isEffective:this.preferences.volume!==null,onChange:e=>{this.updatePreference("volume",e??null)},supportedRange:l.range,step:l.step})}get playbackRate(){return new t({initialValue:this.preferences.playbackRate,effectiveValue:this.settings.playbackRate,isEffective:this.preferences.playbackRate!==null,onChange:e=>{this.updatePreference("playbackRate",e??null)},supportedRange:s.range,step:s.step})}get preservePitch(){return new a({initialValue:this.preferences.preservePitch,effectiveValue:this.settings.preservePitch,isEffective:this.preferences.preservePitch!==null,onChange:e=>{this.updatePreference("preservePitch",e??null)}})}get skipBackwardInterval(){return new t({initialValue:this.preferences.skipBackwardInterval,effectiveValue:this.settings.skipBackwardInterval,isEffective:this.preferences.skipBackwardInterval!==null,onChange:e=>{this.updatePreference("skipBackwardInterval",e??null)},supportedRange:n.range,step:n.step})}get skipForwardInterval(){return new t({initialValue:this.preferences.skipForwardInterval,effectiveValue:this.settings.skipForwardInterval,isEffective:this.preferences.skipForwardInterval!==null,onChange:e=>{this.updatePreference("skipForwardInterval",e??null)},supportedRange:n.range,step:n.step})}get pollInterval(){return new p({initialValue:this.preferences.pollInterval,effectiveValue:this.settings.pollInterval,isEffective:this.preferences.pollInterval!==null,onChange:e=>{this.updatePreference("pollInterval",e??null)}})}get autoPlay(){return new a({initialValue:this.preferences.autoPlay,effectiveValue:this.settings.autoPlay,isEffective:this.preferences.autoPlay!==null,onChange:e=>{this.updatePreference("autoPlay",e??null)}})}get enableMediaSession(){return new a({initialValue:this.preferences.enableMediaSession,effectiveValue:this.settings.enableMediaSession,isEffective:this.preferences.enableMediaSession!==null,onChange:e=>{this.updatePreference("enableMediaSession",e??null)}})}}export{h as AudioPreferencesEditor};
@@ -1 +1 @@
1
- import{Loader as o}from"@readium/navigator-html-injectables";import{FrameComms as n}from"./FrameComms.js";import{sML as h}from"../../helpers/dist/sML.js";import{KeyboardConditionBridge as m}from"../../peripherals/KeyboardConditionBridge.js";class y{constructor(t,i={},r=[],e=[]){this.timelineFragmentIds=e,this.hidden=!0,this.destroyed=!1,this.currModules=[],this.frame=document.createElement("iframe"),this.frame.sandbox.value="allow-same-origin allow-scripts",this.frame.classList.add("readium-navigator-iframe"),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transition="visibility 0s, opacity 0.1s linear",this.source=t,this.contentProtectionConfig={...i},this.keyboardPeripheralsConfig=[...r]}async load(t){return new Promise((i,r)=>{if(this.loader){const e=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...t].sort().join("|")){try{i(e)}catch{}return}this.comms?.halt(),this.loader.destroy(),this.loader=new o(e,t),this.currModules=t,this.comms=void 0;try{i(e)}catch{}return}this.frame.onload=()=>{const e=this.frame.contentWindow;this.loader=new o(e,t),this.currModules=t;try{i(e)}catch{}},this.frame.onerror=e=>{try{r(e)}catch{}},this.frame.contentWindow.location.replace(this.source)})}applyContentProtection(){this.comms||this.comms.resume(),this.comms.send("peripherals_protection",this.contentProtectionConfig),this.keyboardPeripheralsConfig&&this.keyboardPeripheralsConfig.length>0&&(this.conditionBridge?.destroy(),this.conditionBridge=new m(this.keyboardPeripheralsConfig,t=>{t.length>0&&this.comms.send("keyboard_peripherals",t)}),this.conditionBridge.setup()),this.contentProtectionConfig.monitorScrollingExperimental&&this.comms.send("scroll_protection",{}),this.contentProtectionConfig.protectPrinting?.disable&&this.comms.send("print_protection",this.contentProtectionConfig.protectPrinting)}async destroy(){this.conditionBridge?.destroy(),await this.hide(),this.loader?.destroy(),this.frame.remove(),this.destroyed=!0}async hide(){if(!this.destroyed){if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.hidden=!0,this.frame.blur(),this.frame.parentElement)return this.comms===void 0||!this.comms.ready?void 0:new Promise((t,i)=>{this.comms?.send("unfocus",void 0,r=>{this.comms?.halt(),t()})});this.comms?.halt()}}async show(t){if(this.destroyed)throw Error("Trying to show frame when it doesn't exist");if(!this.frame.parentElement)throw Error("Trying to show frame that is not attached to the DOM");return this.comms?this.comms.resume():this.comms=new n(this.frame.contentWindow,this.source),new Promise((i,r)=>{this.comms?.send("activate",void 0,()=>{this.comms?.send("focus",void 0,()=>{this.applyContentProtection(),this.timelineFragmentIds.length>0&&this.comms?.send("timeline_entries",this.timelineFragmentIds);const e=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),this.hidden=!1,h.UA.WebKit&&this.comms?.send("force_webkit_recalc",void 0),i()};t!==void 0?this.comms?.send("go_progression",t,e):e()})})})}setCSSProperties(t){this.destroyed||!this.frame.contentWindow||(this.hidden&&(this.comms?this.comms?.resume():this.comms=new n(this.frame.contentWindow,this.source)),this.comms?.send("update_properties",t),this.hidden&&this.comms?.halt())}get iframe(){if(this.destroyed)throw Error("Trying to use frame when it doesn't exist");return this.frame}get realSize(){if(this.destroyed)throw Error("Trying to use frame client rect when it doesn't exist");return this.frame.getBoundingClientRect()}get isDestroyed(){return this.destroyed}get window(){if(this.destroyed||!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get atLeft(){return this.window.scrollX<5}get atRight(){return this.window.scrollX>this.window.document.scrollingElement.scrollWidth-this.window.innerWidth-5}get msg(){return this.comms}get ldr(){return this.loader}}export{y as FrameManager};
1
+ import{Loader as o}from"@readium/navigator-html-injectables";import{FrameComms as n}from"./FrameComms.js";import{sML as h}from"@readium/helpers";import{KeyboardConditionBridge as m}from"../../peripherals/KeyboardConditionBridge.js";class y{constructor(t,i={},r=[],e=[]){this.timelineFragmentIds=e,this.hidden=!0,this.destroyed=!1,this.currModules=[],this.frame=document.createElement("iframe"),this.frame.sandbox.value="allow-same-origin allow-scripts",this.frame.classList.add("readium-navigator-iframe"),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transition="visibility 0s, opacity 0.1s linear",this.source=t,this.contentProtectionConfig={...i},this.keyboardPeripheralsConfig=[...r]}async load(t){return new Promise((i,r)=>{if(this.loader){const e=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...t].sort().join("|")){try{i(e)}catch{}return}this.comms?.halt(),this.loader.destroy(),this.loader=new o(e,t),this.currModules=t,this.comms=void 0;try{i(e)}catch{}return}this.frame.onload=()=>{const e=this.frame.contentWindow;this.loader=new o(e,t),this.currModules=t;try{i(e)}catch{}},this.frame.onerror=e=>{try{r(e)}catch{}},this.frame.contentWindow.location.replace(this.source)})}applyContentProtection(){this.comms||this.comms.resume(),this.comms.send("peripherals_protection",this.contentProtectionConfig),this.keyboardPeripheralsConfig&&this.keyboardPeripheralsConfig.length>0&&(this.conditionBridge?.destroy(),this.conditionBridge=new m(this.keyboardPeripheralsConfig,t=>{t.length>0&&this.comms.send("keyboard_peripherals",t)}),this.conditionBridge.setup()),this.contentProtectionConfig.monitorScrollingExperimental&&this.comms.send("scroll_protection",{}),this.contentProtectionConfig.protectPrinting?.disable&&this.comms.send("print_protection",this.contentProtectionConfig.protectPrinting)}async destroy(){this.conditionBridge?.destroy(),await this.hide(),this.loader?.destroy(),this.frame.remove(),this.destroyed=!0}async hide(){if(!this.destroyed){if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.hidden=!0,this.frame.blur(),this.frame.parentElement)return this.comms===void 0||!this.comms.ready?void 0:new Promise((t,i)=>{this.comms?.send("unfocus",void 0,r=>{this.comms?.halt(),t()})});this.comms?.halt()}}async show(t){if(this.destroyed)throw Error("Trying to show frame when it doesn't exist");if(!this.frame.parentElement)throw Error("Trying to show frame that is not attached to the DOM");return this.comms?this.comms.resume():this.comms=new n(this.frame.contentWindow,this.source),new Promise((i,r)=>{this.comms?.send("activate",void 0,()=>{this.comms?.send("focus",void 0,()=>{this.applyContentProtection(),this.timelineFragmentIds.length>0&&this.comms?.send("timeline_entries",this.timelineFragmentIds);const e=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),this.hidden=!1,h.UA.WebKit&&this.comms?.send("force_webkit_recalc",void 0),i()};t!==void 0?this.comms?.send("go_progression",t,e):e()})})})}setCSSProperties(t){this.destroyed||!this.frame.contentWindow||(this.hidden&&(this.comms?this.comms?.resume():this.comms=new n(this.frame.contentWindow,this.source)),this.comms?.send("update_properties",t),this.hidden&&this.comms?.halt())}get iframe(){if(this.destroyed)throw Error("Trying to use frame when it doesn't exist");return this.frame}get realSize(){if(this.destroyed)throw Error("Trying to use frame client rect when it doesn't exist");return this.frame.getBoundingClientRect()}get isDestroyed(){return this.destroyed}get window(){if(this.destroyed||!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get atLeft(){return this.window.scrollX<5}get atRight(){return this.window.scrollX>this.window.document.scrollingElement.scrollWidth-this.window.innerWidth-5}get msg(){return this.comms}get ldr(){return this.loader}}export{y as FrameManager};
@@ -1 +1 @@
1
- import{sML as c}from"../../helpers/dist/sML.js";var l=(o=>(o[o.Left=0]="Left",o[o.Center=1]="Center",o[o.Right=2]="Right",o))(l||{}),g=(o=>(o[o.Top=0]="Top",o[o.Middle=1]="Middle",o[o.Bottom=2]="Bottom",o))(g||{});class X{constructor(){this.outerWidth=0,this.outerHeight=0,this.HTML=document.documentElement,this.Head=document.head,this.Body=document.body}refreshOuterPixels(t){c.OS.iOS||(this.outerHeight=window.outerHeight-window.innerHeight,c.OS.Android&&c.UA.Chrome&&window.screen.height>window.innerHeight&&(this.outerHeight=(window.screen.height-window.innerHeight)/1.5),this.outerWidth=window.outerWidth-window.innerWidth)}getBibiEventCoord(t,s=0){const e={X:0,Y:0};return/^touch/.test(t.type)?(e.X=t.touches[s].screenX,e.Y=t.touches[s].screenY):(e.X=t.screenX,e.Y=t.screenY),(t.target.ownerDocument?.documentElement||t.target.documentElement)===this.HTML&&(e.X-=this.HTML.scrollLeft+this.Body.scrollLeft,e.Y-=this.HTML.scrollTop+this.Body.scrollTop),e.X-=this.outerWidth,e.Y-=this.outerHeight,e}getTouchDistance(t){if(t.touches.length!==2)return 0;const s=t.touches[0].screenX-this.outerWidth,e=t.touches[0].screenY-this.outerHeight,i=t.touches[1].screenX-this.outerWidth,r=t.touches[1].screenY-this.outerHeight;return Math.sqrt(Math.pow(i-s,2)+Math.pow(r-e,2))}getTouchCenter(t){if(t.touches.length!==2)return null;const s=this.HTML.scrollLeft+this.Body.scrollLeft,e=this.HTML.scrollTop+this.Body.scrollTop,i=t.touches[0].screenX-this.outerWidth-s,r=t.touches[0].screenY-this.outerHeight-e,h=t.touches[1].screenX-this.outerWidth-s,u=t.touches[1].screenY-this.outerHeight-e;return{X:(i+h)/2,Y:(r+u)/2}}getBibiEvent(t){if(!t)return{Coord:null,Division:null,Ratio:null,Target:null};const s=this.getBibiEventCoord(t);let e=.3;const i={X:s.X/window.innerWidth,Y:s.Y/window.innerHeight};let r,h,u,d;u=r=e,d=h=1-e;const n={X:null,Y:null};return i.X<u?n.X=0:d<i.X?n.X=2:n.X=1,i.Y<r?n.Y=0:h<i.Y?n.Y=2:n.Y=1,{Target:t.target,Coord:s,Ratio:i,Division:n}}}export{X as FXLCoordinator,l as HorizontalThird,g as VerticalThird};
1
+ import{sML as c}from"@readium/helpers";var l=(o=>(o[o.Left=0]="Left",o[o.Center=1]="Center",o[o.Right=2]="Right",o))(l||{}),g=(o=>(o[o.Top=0]="Top",o[o.Middle=1]="Middle",o[o.Bottom=2]="Bottom",o))(g||{});class X{constructor(){this.outerWidth=0,this.outerHeight=0,this.HTML=document.documentElement,this.Head=document.head,this.Body=document.body}refreshOuterPixels(t){c.OS.iOS||(this.outerHeight=window.outerHeight-window.innerHeight,c.OS.Android&&c.UA.Chrome&&window.screen.height>window.innerHeight&&(this.outerHeight=(window.screen.height-window.innerHeight)/1.5),this.outerWidth=window.outerWidth-window.innerWidth)}getBibiEventCoord(t,s=0){const e={X:0,Y:0};return/^touch/.test(t.type)?(e.X=t.touches[s].screenX,e.Y=t.touches[s].screenY):(e.X=t.screenX,e.Y=t.screenY),(t.target.ownerDocument?.documentElement||t.target.documentElement)===this.HTML&&(e.X-=this.HTML.scrollLeft+this.Body.scrollLeft,e.Y-=this.HTML.scrollTop+this.Body.scrollTop),e.X-=this.outerWidth,e.Y-=this.outerHeight,e}getTouchDistance(t){if(t.touches.length!==2)return 0;const s=t.touches[0].screenX-this.outerWidth,e=t.touches[0].screenY-this.outerHeight,i=t.touches[1].screenX-this.outerWidth,r=t.touches[1].screenY-this.outerHeight;return Math.sqrt(Math.pow(i-s,2)+Math.pow(r-e,2))}getTouchCenter(t){if(t.touches.length!==2)return null;const s=this.HTML.scrollLeft+this.Body.scrollLeft,e=this.HTML.scrollTop+this.Body.scrollTop,i=t.touches[0].screenX-this.outerWidth-s,r=t.touches[0].screenY-this.outerHeight-e,h=t.touches[1].screenX-this.outerWidth-s,u=t.touches[1].screenY-this.outerHeight-e;return{X:(i+h)/2,Y:(r+u)/2}}getBibiEvent(t){if(!t)return{Coord:null,Division:null,Ratio:null,Target:null};const s=this.getBibiEventCoord(t);let e=.3;const i={X:s.X/window.innerWidth,Y:s.Y/window.innerHeight};let r,h,u,d;u=r=e,d=h=1-e;const n={X:null,Y:null};return i.X<u?n.X=0:d<i.X?n.X=2:n.X=1,i.Y<r?n.Y=0:h<i.Y?n.Y=2:n.Y=1,{Target:t.target,Coord:s,Ratio:i,Division:n}}}export{X as FXLCoordinator,l as HorizontalThird,g as VerticalThird};
@@ -1 +1 @@
1
- import{fontSizeRangeConfig as a,fontWeightRangeConfig as s,fontWidthRangeConfig as g,TextAlignment as c}from"../../preferences/Types.js";import{ensureString as e,ensureBoolean as t,ensureNonNegative as n,ensureFilter as o,ensureValueInRange as r,withFallback as h,ensureEnumValue as p,ensureMoreThanOrEqual as m,ensureLessThanOrEqual as S,ensureExperiment as u}from"../../preferences/guards.js";import{sMLWithRequest as l}from"../../helpers/dist/sML.js";class O{constructor(i){this.backgroundColor=e(i.backgroundColor)||null,this.blendFilter=t(i.blendFilter)??!1,this.constraint=n(i.constraint)||0,this.columnCount=n(i.columnCount)||null,this.darkenFilter=o(i.darkenFilter)??!1,this.deprecatedFontSize=t(i.deprecatedFontSize),(this.deprecatedFontSize===!1||this.deprecatedFontSize===null)&&(this.deprecatedFontSize=!CSS.supports("zoom","1")),this.fontFamily=e(i.fontFamily)||null,this.fontSize=r(i.fontSize,a.range)||1,this.fontSizeNormalize=t(i.fontSizeNormalize)??!1,this.fontOpticalSizing=t(i.fontOpticalSizing)??null,this.fontWeight=r(i.fontWeight,s.range)||null,this.fontWidth=r(i.fontWidth,g.range)||null,this.hyphens=t(i.hyphens)??null,this.invertFilter=o(i.invertFilter)??!1,this.invertGaijiFilter=o(i.invertGaijiFilter)??!1,this.iOSPatch=i.iOSPatch===!1?!1:(l.OS.iOS||l.OS.iPadOS)&&l.iOSRequest==="mobile",this.iPadOSPatch=i.iPadOSPatch===!1?!1:l.OS.iPadOS&&l.iOSRequest==="desktop",this.letterSpacing=n(i.letterSpacing)||null,this.ligatures=t(i.ligatures)??null,this.lineHeight=n(i.lineHeight)||null,this.linkColor=e(i.linkColor)||null,this.noRuby=t(i.noRuby)??!1,this.pageGutter=h(n(i.pageGutter),20),this.paragraphIndent=n(i.paragraphIndent)??null,this.paragraphSpacing=n(i.paragraphSpacing)??null,this.scroll=t(i.scroll)??!1,this.scrollPaddingTop=n(i.scrollPaddingTop)??null,this.scrollPaddingBottom=n(i.scrollPaddingBottom)??null,this.scrollPaddingLeft=n(i.scrollPaddingLeft)??null,this.scrollPaddingRight=n(i.scrollPaddingRight)??null,this.selectionBackgroundColor=e(i.selectionBackgroundColor)||null,this.selectionTextColor=e(i.selectionTextColor)||null,this.textAlign=p(i.textAlign,c)||null,this.textColor=e(i.textColor)||null,this.textNormalization=t(i.textNormalization)??!1,this.visitedColor=e(i.visitedColor)||null,this.wordSpacing=n(i.wordSpacing)||null,this.optimalLineLength=n(i.optimalLineLength)||65,this.maximalLineLength=h(m(i.maximalLineLength,this.optimalLineLength),80),this.minimalLineLength=h(S(i.minimalLineLength,this.optimalLineLength),40),this.experiments=u(i.experiments)||null}}export{O as EpubDefaults};
1
+ import{fontSizeRangeConfig as a,fontWeightRangeConfig as s,fontWidthRangeConfig as g,TextAlignment as c}from"../../preferences/Types.js";import{ensureString as e,ensureBoolean as t,ensureNonNegative as n,ensureFilter as o,ensureValueInRange as r,withFallback as h,ensureEnumValue as p,ensureMoreThanOrEqual as m,ensureLessThanOrEqual as S,ensureExperiment as u}from"../../preferences/guards.js";import{sMLWithRequest as l}from"@readium/helpers";class O{constructor(i){this.backgroundColor=e(i.backgroundColor)||null,this.blendFilter=t(i.blendFilter)??!1,this.constraint=n(i.constraint)||0,this.columnCount=n(i.columnCount)||null,this.darkenFilter=o(i.darkenFilter)??!1,this.deprecatedFontSize=t(i.deprecatedFontSize),(this.deprecatedFontSize===!1||this.deprecatedFontSize===null)&&(this.deprecatedFontSize=!CSS.supports("zoom","1")),this.fontFamily=e(i.fontFamily)||null,this.fontSize=r(i.fontSize,a.range)||1,this.fontSizeNormalize=t(i.fontSizeNormalize)??!1,this.fontOpticalSizing=t(i.fontOpticalSizing)??null,this.fontWeight=r(i.fontWeight,s.range)||null,this.fontWidth=r(i.fontWidth,g.range)||null,this.hyphens=t(i.hyphens)??null,this.invertFilter=o(i.invertFilter)??!1,this.invertGaijiFilter=o(i.invertGaijiFilter)??!1,this.iOSPatch=i.iOSPatch===!1?!1:(l.OS.iOS||l.OS.iPadOS)&&l.iOSRequest==="mobile",this.iPadOSPatch=i.iPadOSPatch===!1?!1:l.OS.iPadOS&&l.iOSRequest==="desktop",this.letterSpacing=n(i.letterSpacing)||null,this.ligatures=t(i.ligatures)??null,this.lineHeight=n(i.lineHeight)||null,this.linkColor=e(i.linkColor)||null,this.noRuby=t(i.noRuby)??!1,this.pageGutter=h(n(i.pageGutter),20),this.paragraphIndent=n(i.paragraphIndent)??null,this.paragraphSpacing=n(i.paragraphSpacing)??null,this.scroll=t(i.scroll)??!1,this.scrollPaddingTop=n(i.scrollPaddingTop)??null,this.scrollPaddingBottom=n(i.scrollPaddingBottom)??null,this.scrollPaddingLeft=n(i.scrollPaddingLeft)??null,this.scrollPaddingRight=n(i.scrollPaddingRight)??null,this.selectionBackgroundColor=e(i.selectionBackgroundColor)||null,this.selectionTextColor=e(i.selectionTextColor)||null,this.textAlign=p(i.textAlign,c)||null,this.textColor=e(i.textColor)||null,this.textNormalization=t(i.textNormalization)??!1,this.visitedColor=e(i.visitedColor)||null,this.wordSpacing=n(i.wordSpacing)||null,this.optimalLineLength=n(i.optimalLineLength)||65,this.maximalLineLength=h(m(i.maximalLineLength,this.optimalLineLength),80),this.minimalLineLength=h(S(i.minimalLineLength,this.optimalLineLength),40),this.experiments=u(i.experiments)||null}}export{O as EpubDefaults};
@@ -1 +1 @@
1
- import{Layout as t,ReadingProgression as V}from"@readium/shared";import{EpubPreferences as m}from"./EpubPreferences.js";import{Preference as i,BooleanPreference as r,RangePreference as n,EnumPreference as x}from"../../preferences/Preference.js";import{filterRangeConfig as s,fontSizeRangeConfig as o,fontWeightRangeConfig as u,fontWidthRangeConfig as h,letterSpacingRangeConfig as c,lineHeightRangeConfig as g,lineLengthRangeConfig as l,paragraphIndentRangeConfig as p,paragraphSpacingRangeConfig as d,TextAlignment as v,wordSpacingRangeConfig as C}from"../../preferences/Types.js";import a from"../../node_modules/.pnpm/@readium_css@2.0.5/node_modules/@readium/css/css/vars/colors.json.js";class F{constructor(e,f,P){this.preferences=e,this.settings=f,this.metadata=P,this.layout=this.metadata?.effectiveLayout||t.reflowable}clear(){this.preferences=new m({optimalLineLength:65})}updatePreference(e,f){this.preferences[e]=f}get backgroundColor(){return new i({initialValue:this.preferences.backgroundColor,effectiveValue:this.settings.backgroundColor||a.backgroundColor,isEffective:this.preferences.backgroundColor!==null,onChange:e=>{this.updatePreference("backgroundColor",e??null)}})}get blendFilter(){return new r({initialValue:this.preferences.blendFilter,effectiveValue:this.settings.blendFilter||!1,isEffective:this.preferences.blendFilter!==null,onChange:e=>{this.updatePreference("blendFilter",e??null)}})}get columnCount(){return new i({initialValue:this.preferences.columnCount,effectiveValue:this.settings.columnCount||null,isEffective:this.layout!==t.fixed&&!this.settings.scroll,onChange:e=>{this.updatePreference("columnCount",e??null)}})}get constraint(){return new i({initialValue:this.preferences.constraint,effectiveValue:this.preferences.constraint||0,isEffective:!0,onChange:e=>{this.updatePreference("constraint",e??null)}})}get darkenFilter(){return new n({initialValue:typeof this.preferences.darkenFilter=="boolean"?100:this.preferences.darkenFilter,effectiveValue:typeof this.settings.darkenFilter=="boolean"?100:this.settings.darkenFilter||0,isEffective:this.settings.darkenFilter!==null,onChange:e=>{this.updatePreference("darkenFilter",e??null)},supportedRange:s.range,step:s.step})}get deprecatedFontSize(){return new r({initialValue:this.preferences.deprecatedFontSize,effectiveValue:CSS.supports("zoom","1")?this.settings.deprecatedFontSize||!1:!0,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("deprecatedFontSize",e??null)}})}get fontFamily(){return new i({initialValue:this.preferences.fontFamily,effectiveValue:this.settings.fontFamily||null,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("fontFamily",e??null)}})}get fontSize(){return new n({initialValue:this.preferences.fontSize,effectiveValue:this.settings.fontSize||1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("fontSize",e??null)},supportedRange:o.range,step:o.step})}get fontSizeNormalize(){return new r({initialValue:this.preferences.fontSizeNormalize,effectiveValue:this.settings.fontSizeNormalize||!1,isEffective:this.layout!==t.fixed&&this.preferences.fontSizeNormalize!==null,onChange:e=>{this.updatePreference("fontSizeNormalize",e??null)}})}get fontOpticalSizing(){return new r({initialValue:this.preferences.fontOpticalSizing,effectiveValue:this.settings.fontOpticalSizing||!0,isEffective:this.layout!==t.fixed&&this.preferences.fontOpticalSizing!==null,onChange:e=>{this.updatePreference("fontOpticalSizing",e??null)}})}get fontWeight(){return new n({initialValue:this.preferences.fontWeight,effectiveValue:this.settings.fontWeight||400,isEffective:this.layout!==t.fixed&&this.preferences.fontWeight!==null,onChange:e=>{this.updatePreference("fontWeight",e??null)},supportedRange:u.range,step:u.step})}get fontWidth(){return new n({initialValue:this.preferences.fontWidth,effectiveValue:this.settings.fontWidth||100,isEffective:this.layout!==t.fixed&&this.preferences.fontWidth!==null,onChange:e=>{this.updatePreference("fontWidth",e??null)},supportedRange:h.range,step:h.step})}get hyphens(){return new r({initialValue:this.preferences.hyphens,effectiveValue:this.settings.hyphens||!1,isEffective:this.layout!==t.fixed&&this.metadata?.effectiveReadingProgression===V.ltr&&this.preferences.hyphens!==null,onChange:e=>{this.updatePreference("hyphens",e??null)}})}get invertFilter(){return new n({initialValue:typeof this.preferences.invertFilter=="boolean"?100:this.preferences.invertFilter,effectiveValue:typeof this.settings.invertFilter=="boolean"?100:this.settings.invertFilter||0,isEffective:this.settings.invertFilter!==null,onChange:e=>{this.updatePreference("invertFilter",e??null)},supportedRange:s.range,step:s.step})}get invertGaijiFilter(){return new n({initialValue:typeof this.preferences.invertGaijiFilter=="boolean"?100:this.preferences.invertGaijiFilter,effectiveValue:typeof this.settings.invertGaijiFilter=="boolean"?100:this.settings.invertGaijiFilter||0,isEffective:this.preferences.invertGaijiFilter!==null,onChange:e=>{this.updatePreference("invertGaijiFilter",e??null)},supportedRange:s.range,step:s.step})}get iOSPatch(){return new r({initialValue:this.preferences.iOSPatch,effectiveValue:this.settings.iOSPatch||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("iOSPatch",e??null)}})}get iPadOSPatch(){return new r({initialValue:this.preferences.iPadOSPatch,effectiveValue:this.settings.iPadOSPatch||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("iPadOSPatch",e??null)}})}get letterSpacing(){return new n({initialValue:this.preferences.letterSpacing,effectiveValue:this.settings.letterSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.letterSpacing!==null,onChange:e=>{this.updatePreference("letterSpacing",e??null)},supportedRange:c.range,step:c.step})}get ligatures(){return new r({initialValue:this.preferences.ligatures,effectiveValue:this.settings.ligatures||!0,isEffective:(()=>{if(this.preferences.ligatures===null||this.layout===t.fixed)return!1;const e=this.metadata?.languages?.[0]?.toLowerCase();return!(e&&["zh","ja","ko","mn-mong"].some(f=>e.startsWith(f)))})(),onChange:e=>{this.updatePreference("ligatures",e??null)}})}get lineHeight(){return new n({initialValue:this.preferences.lineHeight,effectiveValue:this.settings.lineHeight,isEffective:this.layout!==t.fixed&&this.preferences.lineHeight!==null,onChange:e=>{this.updatePreference("lineHeight",e??null)},supportedRange:g.range,step:g.step})}get linkColor(){return new i({initialValue:this.preferences.linkColor,effectiveValue:this.settings.linkColor||a.linkColor,isEffective:this.layout!==t.fixed&&this.preferences.linkColor!==null,onChange:e=>{this.updatePreference("linkColor",e??null)}})}get maximalLineLength(){return new n({initialValue:this.preferences.maximalLineLength,effectiveValue:this.settings.maximalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("maximalLineLength",e)},supportedRange:l.range,step:l.step})}get minimalLineLength(){return new n({initialValue:this.preferences.minimalLineLength,effectiveValue:this.settings.minimalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("minimalLineLength",e)},supportedRange:l.range,step:l.step})}get noRuby(){return new r({initialValue:this.preferences.noRuby,effectiveValue:this.settings.noRuby||!1,isEffective:this.layout!==t.fixed&&this.metadata?.languages?.includes("ja")||!1,onChange:e=>{this.updatePreference("noRuby",e??null)}})}get optimalLineLength(){return new n({initialValue:this.preferences.optimalLineLength,effectiveValue:this.settings.optimalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("optimalLineLength",e)},supportedRange:l.range,step:l.step})}get pageGutter(){return new i({initialValue:this.preferences.pageGutter,effectiveValue:this.settings.pageGutter,isEffective:this.layout!==t.fixed&&!this.settings.scroll,onChange:e=>{this.updatePreference("pageGutter",e??null)}})}get paragraphIndent(){return new n({initialValue:this.preferences.paragraphIndent,effectiveValue:this.settings.paragraphIndent||0,isEffective:this.layout!==t.fixed&&this.preferences.paragraphIndent!==null,onChange:e=>{this.updatePreference("paragraphIndent",e??null)},supportedRange:p.range,step:p.step})}get paragraphSpacing(){return new n({initialValue:this.preferences.paragraphSpacing,effectiveValue:this.settings.paragraphSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.paragraphSpacing!==null,onChange:e=>{this.updatePreference("paragraphSpacing",e??null)},supportedRange:d.range,step:d.step})}get scroll(){return new r({initialValue:this.preferences.scroll,effectiveValue:this.settings.scroll||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("scroll",e??null)}})}get scrollPaddingTop(){return new i({initialValue:this.preferences.scrollPaddingTop,effectiveValue:this.settings.scrollPaddingTop||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingTop!==null,onChange:e=>{this.updatePreference("scrollPaddingTop",e??null)}})}get scrollPaddingBottom(){return new i({initialValue:this.preferences.scrollPaddingBottom,effectiveValue:this.settings.scrollPaddingBottom||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingBottom!==null,onChange:e=>{this.updatePreference("scrollPaddingBottom",e??null)}})}get scrollPaddingLeft(){return new i({initialValue:this.preferences.scrollPaddingLeft,effectiveValue:this.settings.scrollPaddingLeft||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingLeft!==null,onChange:e=>{this.updatePreference("scrollPaddingLeft",e??null)}})}get scrollPaddingRight(){return new i({initialValue:this.preferences.scrollPaddingRight,effectiveValue:this.settings.scrollPaddingRight||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingRight!==null,onChange:e=>{this.updatePreference("scrollPaddingRight",e??null)}})}get selectionBackgroundColor(){return new i({initialValue:this.preferences.selectionBackgroundColor,effectiveValue:this.settings.selectionBackgroundColor||a.selectionBackgroundColor,isEffective:this.layout!==t.fixed&&this.preferences.selectionBackgroundColor!==null,onChange:e=>{this.updatePreference("selectionBackgroundColor",e??null)}})}get selectionTextColor(){return new i({initialValue:this.preferences.selectionTextColor,effectiveValue:this.settings.selectionTextColor||a.selectionTextColor,isEffective:this.layout!==t.fixed&&this.preferences.selectionTextColor!==null,onChange:e=>{this.updatePreference("selectionTextColor",e??null)}})}get textAlign(){return new x({initialValue:this.preferences.textAlign,effectiveValue:this.settings.textAlign||v.start,isEffective:this.layout!==t.fixed&&this.preferences.textAlign!==null,onChange:e=>{this.updatePreference("textAlign",e??null)},supportedValues:Object.values(v)})}get textColor(){return new i({initialValue:this.preferences.textColor,effectiveValue:this.settings.textColor||a.textColor,isEffective:this.layout!==t.fixed&&this.preferences.textColor!==null,onChange:e=>{this.updatePreference("textColor",e??null)}})}get textNormalization(){return new r({initialValue:this.preferences.textNormalization,effectiveValue:this.settings.textNormalization||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("textNormalization",e??null)}})}get visitedColor(){return new i({initialValue:this.preferences.visitedColor,effectiveValue:this.settings.visitedColor||a.visitedColor,isEffective:this.layout!==t.fixed&&this.preferences.visitedColor!==null,onChange:e=>{this.updatePreference("visitedColor",e??null)}})}get wordSpacing(){return new n({initialValue:this.preferences.wordSpacing,effectiveValue:this.settings.wordSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.wordSpacing!==null,onChange:e=>{this.updatePreference("wordSpacing",e??null)},supportedRange:C.range,step:C.step})}}export{F as EpubPreferencesEditor};
1
+ import{Layout as t,ReadingProgression as m}from"@readium/shared";import{EpubPreferences as f}from"./EpubPreferences.js";import{Preference as i,BooleanPreference as l,RangePreference as n,EnumPreference as x}from"../../preferences/Preference.js";import{filterRangeConfig as r,fontSizeRangeConfig as u,fontWeightRangeConfig as g,fontWidthRangeConfig as h,letterSpacingRangeConfig as c,lineHeightRangeConfig as p,lineLengthRangeConfig as s,paragraphIndentRangeConfig as d,paragraphSpacingRangeConfig as v,TextAlignment as C,wordSpacingRangeConfig as P}from"../../preferences/Types.js";import a from"../../node_modules/.pnpm/@readium_css@2.0.5/node_modules/@readium/css/css/vars/colors.json.js";class R{constructor(e,o,V){this.preferences=new f({...e}),this.settings=o,this.metadata=V,this.layout=this.metadata?.effectiveLayout||t.reflowable}clear(){this.preferences=new f({backgroundColor:null,blendFilter:null,columnCount:null,constraint:null,darkenFilter:null,deprecatedFontSize:null,fontFamily:null,fontSize:null,fontSizeNormalize:null,fontOpticalSizing:null,fontWeight:null,fontWidth:null,hyphens:null,invertFilter:null,invertGaijiFilter:null,iOSPatch:null,iPadOSPatch:null,letterSpacing:null,ligatures:null,lineHeight:null,linkColor:null,maximalLineLength:null,minimalLineLength:null,noRuby:null,optimalLineLength:null,pageGutter:null,paragraphIndent:null,paragraphSpacing:null,scroll:null,scrollPaddingTop:null,scrollPaddingBottom:null,scrollPaddingLeft:null,scrollPaddingRight:null,selectionBackgroundColor:null,selectionTextColor:null,textAlign:null,textColor:null,textNormalization:null,visitedColor:null,wordSpacing:null})}updatePreference(e,o){this.preferences[e]=o}get backgroundColor(){return new i({initialValue:this.preferences.backgroundColor,effectiveValue:this.settings.backgroundColor||a.backgroundColor,isEffective:this.preferences.backgroundColor!==null,onChange:e=>{this.updatePreference("backgroundColor",e??null)}})}get blendFilter(){return new l({initialValue:this.preferences.blendFilter,effectiveValue:this.settings.blendFilter||!1,isEffective:this.preferences.blendFilter!==null,onChange:e=>{this.updatePreference("blendFilter",e??null)}})}get columnCount(){return new i({initialValue:this.preferences.columnCount,effectiveValue:this.settings.columnCount||null,isEffective:this.layout!==t.fixed&&!this.settings.scroll,onChange:e=>{this.updatePreference("columnCount",e??null)}})}get constraint(){return new i({initialValue:this.preferences.constraint,effectiveValue:this.preferences.constraint||0,isEffective:!0,onChange:e=>{this.updatePreference("constraint",e??null)}})}get darkenFilter(){return new n({initialValue:typeof this.preferences.darkenFilter=="boolean"?100:this.preferences.darkenFilter,effectiveValue:typeof this.settings.darkenFilter=="boolean"?100:this.settings.darkenFilter||0,isEffective:this.settings.darkenFilter!==null,onChange:e=>{this.updatePreference("darkenFilter",e??null)},supportedRange:r.range,step:r.step})}get deprecatedFontSize(){return new l({initialValue:this.preferences.deprecatedFontSize,effectiveValue:CSS.supports("zoom","1")?this.settings.deprecatedFontSize||!1:!0,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("deprecatedFontSize",e??null)}})}get fontFamily(){return new i({initialValue:this.preferences.fontFamily,effectiveValue:this.settings.fontFamily||null,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("fontFamily",e??null)}})}get fontSize(){return new n({initialValue:this.preferences.fontSize,effectiveValue:this.settings.fontSize||1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("fontSize",e??null)},supportedRange:u.range,step:u.step})}get fontSizeNormalize(){return new l({initialValue:this.preferences.fontSizeNormalize,effectiveValue:this.settings.fontSizeNormalize||!1,isEffective:this.layout!==t.fixed&&this.preferences.fontSizeNormalize!==null,onChange:e=>{this.updatePreference("fontSizeNormalize",e??null)}})}get fontOpticalSizing(){return new l({initialValue:this.preferences.fontOpticalSizing,effectiveValue:this.settings.fontOpticalSizing||!0,isEffective:this.layout!==t.fixed&&this.preferences.fontOpticalSizing!==null,onChange:e=>{this.updatePreference("fontOpticalSizing",e??null)}})}get fontWeight(){return new n({initialValue:this.preferences.fontWeight,effectiveValue:this.settings.fontWeight||400,isEffective:this.layout!==t.fixed&&this.preferences.fontWeight!==null,onChange:e=>{this.updatePreference("fontWeight",e??null)},supportedRange:g.range,step:g.step})}get fontWidth(){return new n({initialValue:this.preferences.fontWidth,effectiveValue:this.settings.fontWidth||100,isEffective:this.layout!==t.fixed&&this.preferences.fontWidth!==null,onChange:e=>{this.updatePreference("fontWidth",e??null)},supportedRange:h.range,step:h.step})}get hyphens(){return new l({initialValue:this.preferences.hyphens,effectiveValue:this.settings.hyphens||!1,isEffective:this.layout!==t.fixed&&this.metadata?.effectiveReadingProgression===m.ltr&&this.preferences.hyphens!==null,onChange:e=>{this.updatePreference("hyphens",e??null)}})}get invertFilter(){return new n({initialValue:typeof this.preferences.invertFilter=="boolean"?100:this.preferences.invertFilter,effectiveValue:typeof this.settings.invertFilter=="boolean"?100:this.settings.invertFilter||0,isEffective:this.settings.invertFilter!==null,onChange:e=>{this.updatePreference("invertFilter",e??null)},supportedRange:r.range,step:r.step})}get invertGaijiFilter(){return new n({initialValue:typeof this.preferences.invertGaijiFilter=="boolean"?100:this.preferences.invertGaijiFilter,effectiveValue:typeof this.settings.invertGaijiFilter=="boolean"?100:this.settings.invertGaijiFilter||0,isEffective:this.preferences.invertGaijiFilter!==null,onChange:e=>{this.updatePreference("invertGaijiFilter",e??null)},supportedRange:r.range,step:r.step})}get iOSPatch(){return new l({initialValue:this.preferences.iOSPatch,effectiveValue:this.settings.iOSPatch||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("iOSPatch",e??null)}})}get iPadOSPatch(){return new l({initialValue:this.preferences.iPadOSPatch,effectiveValue:this.settings.iPadOSPatch||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("iPadOSPatch",e??null)}})}get letterSpacing(){return new n({initialValue:this.preferences.letterSpacing,effectiveValue:this.settings.letterSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.letterSpacing!==null,onChange:e=>{this.updatePreference("letterSpacing",e??null)},supportedRange:c.range,step:c.step})}get ligatures(){return new l({initialValue:this.preferences.ligatures,effectiveValue:this.settings.ligatures||!0,isEffective:(()=>{if(this.preferences.ligatures===null||this.layout===t.fixed)return!1;const e=this.metadata?.languages?.[0]?.toLowerCase();return!(e&&["zh","ja","ko","mn-mong"].some(o=>e.startsWith(o)))})(),onChange:e=>{this.updatePreference("ligatures",e??null)}})}get lineHeight(){return new n({initialValue:this.preferences.lineHeight,effectiveValue:this.settings.lineHeight,isEffective:this.layout!==t.fixed&&this.preferences.lineHeight!==null,onChange:e=>{this.updatePreference("lineHeight",e??null)},supportedRange:p.range,step:p.step})}get linkColor(){return new i({initialValue:this.preferences.linkColor,effectiveValue:this.settings.linkColor||a.linkColor,isEffective:this.layout!==t.fixed&&this.preferences.linkColor!==null,onChange:e=>{this.updatePreference("linkColor",e??null)}})}get maximalLineLength(){return new n({initialValue:this.preferences.maximalLineLength,effectiveValue:this.settings.maximalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("maximalLineLength",e)},supportedRange:s.range,step:s.step})}get minimalLineLength(){return new n({initialValue:this.preferences.minimalLineLength,effectiveValue:this.settings.minimalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("minimalLineLength",e)},supportedRange:s.range,step:s.step})}get noRuby(){return new l({initialValue:this.preferences.noRuby,effectiveValue:this.settings.noRuby||!1,isEffective:this.layout!==t.fixed&&this.metadata?.languages?.includes("ja")||!1,onChange:e=>{this.updatePreference("noRuby",e??null)}})}get optimalLineLength(){return new n({initialValue:this.preferences.optimalLineLength,effectiveValue:this.settings.optimalLineLength,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("optimalLineLength",e)},supportedRange:s.range,step:s.step})}get pageGutter(){return new i({initialValue:this.preferences.pageGutter,effectiveValue:this.settings.pageGutter,isEffective:this.layout!==t.fixed&&!this.settings.scroll,onChange:e=>{this.updatePreference("pageGutter",e??null)}})}get paragraphIndent(){return new n({initialValue:this.preferences.paragraphIndent,effectiveValue:this.settings.paragraphIndent||0,isEffective:this.layout!==t.fixed&&this.preferences.paragraphIndent!==null,onChange:e=>{this.updatePreference("paragraphIndent",e??null)},supportedRange:d.range,step:d.step})}get paragraphSpacing(){return new n({initialValue:this.preferences.paragraphSpacing,effectiveValue:this.settings.paragraphSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.paragraphSpacing!==null,onChange:e=>{this.updatePreference("paragraphSpacing",e??null)},supportedRange:v.range,step:v.step})}get scroll(){return new l({initialValue:this.preferences.scroll,effectiveValue:this.settings.scroll||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("scroll",e??null)}})}get scrollPaddingTop(){return new i({initialValue:this.preferences.scrollPaddingTop,effectiveValue:this.settings.scrollPaddingTop||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingTop!==null,onChange:e=>{this.updatePreference("scrollPaddingTop",e??null)}})}get scrollPaddingBottom(){return new i({initialValue:this.preferences.scrollPaddingBottom,effectiveValue:this.settings.scrollPaddingBottom||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingBottom!==null,onChange:e=>{this.updatePreference("scrollPaddingBottom",e??null)}})}get scrollPaddingLeft(){return new i({initialValue:this.preferences.scrollPaddingLeft,effectiveValue:this.settings.scrollPaddingLeft||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingLeft!==null,onChange:e=>{this.updatePreference("scrollPaddingLeft",e??null)}})}get scrollPaddingRight(){return new i({initialValue:this.preferences.scrollPaddingRight,effectiveValue:this.settings.scrollPaddingRight||0,isEffective:this.layout!==t.fixed&&!!this.settings.scroll&&this.preferences.scrollPaddingRight!==null,onChange:e=>{this.updatePreference("scrollPaddingRight",e??null)}})}get selectionBackgroundColor(){return new i({initialValue:this.preferences.selectionBackgroundColor,effectiveValue:this.settings.selectionBackgroundColor||a.selectionBackgroundColor,isEffective:this.layout!==t.fixed&&this.preferences.selectionBackgroundColor!==null,onChange:e=>{this.updatePreference("selectionBackgroundColor",e??null)}})}get selectionTextColor(){return new i({initialValue:this.preferences.selectionTextColor,effectiveValue:this.settings.selectionTextColor||a.selectionTextColor,isEffective:this.layout!==t.fixed&&this.preferences.selectionTextColor!==null,onChange:e=>{this.updatePreference("selectionTextColor",e??null)}})}get textAlign(){return new x({initialValue:this.preferences.textAlign,effectiveValue:this.settings.textAlign||C.start,isEffective:this.layout!==t.fixed&&this.preferences.textAlign!==null,onChange:e=>{this.updatePreference("textAlign",e??null)},supportedValues:Object.values(C)})}get textColor(){return new i({initialValue:this.preferences.textColor,effectiveValue:this.settings.textColor||a.textColor,isEffective:this.layout!==t.fixed&&this.preferences.textColor!==null,onChange:e=>{this.updatePreference("textColor",e??null)}})}get textNormalization(){return new l({initialValue:this.preferences.textNormalization,effectiveValue:this.settings.textNormalization||!1,isEffective:this.layout!==t.fixed,onChange:e=>{this.updatePreference("textNormalization",e??null)}})}get visitedColor(){return new i({initialValue:this.preferences.visitedColor,effectiveValue:this.settings.visitedColor||a.visitedColor,isEffective:this.layout!==t.fixed&&this.preferences.visitedColor!==null,onChange:e=>{this.updatePreference("visitedColor",e??null)}})}get wordSpacing(){return new n({initialValue:this.preferences.wordSpacing,effectiveValue:this.settings.wordSpacing||0,isEffective:this.layout!==t.fixed&&this.preferences.wordSpacing!==null,onChange:e=>{this.updatePreference("wordSpacing",e??null)},supportedRange:P.range,step:P.step})}}export{R as EpubPreferencesEditor};
@@ -1 +1 @@
1
- import{sMLWithRequest as t}from"../../helpers/dist/sML.js";class a{constructor(i,o){this.backgroundColor=i.backgroundColor||o.backgroundColor||null,this.blendFilter=typeof i.blendFilter=="boolean"?i.blendFilter:o.blendFilter??null,this.columnCount=i.columnCount!==void 0?i.columnCount:o.columnCount!==void 0?o.columnCount:null,this.constraint=i.constraint||o.constraint,this.darkenFilter=typeof i.darkenFilter=="boolean"?i.darkenFilter:o.darkenFilter??null,this.deprecatedFontSize=typeof i.deprecatedFontSize=="boolean"?i.deprecatedFontSize:o.deprecatedFontSize??null,this.fontFamily=i.fontFamily||o.fontFamily||null,this.fontSize=i.fontSize!==void 0?i.fontSize:o.fontSize!==void 0?o.fontSize:null,this.fontSizeNormalize=typeof i.fontSizeNormalize=="boolean"?i.fontSizeNormalize:o.fontSizeNormalize??null,this.fontOpticalSizing=typeof i.fontOpticalSizing=="boolean"?i.fontOpticalSizing:o.fontOpticalSizing??null,this.fontWeight=i.fontWeight!==void 0?i.fontWeight:o.fontWeight!==void 0?o.fontWeight:null,this.fontWidth=i.fontWidth!==void 0?i.fontWidth:o.fontWidth!==void 0?o.fontWidth:null,this.hyphens=typeof i.hyphens=="boolean"?i.hyphens:o.hyphens??null,this.invertFilter=typeof i.invertFilter=="boolean"?i.invertFilter:o.invertFilter??null,this.invertGaijiFilter=typeof i.invertGaijiFilter=="boolean"?i.invertGaijiFilter:o.invertGaijiFilter??null,this.iOSPatch=this.deprecatedFontSize||i.iOSPatch===!1?!1:i.iOSPatch===!0?(t.OS.iOS||t.OS.iPadOS)&&t.iOSRequest==="mobile":o.iOSPatch,this.iPadOSPatch=this.deprecatedFontSize||i.iPadOSPatch===!1?!1:i.iPadOSPatch===!0?t.OS.iPadOS&&t.iOSRequest==="desktop":o.iPadOSPatch,this.letterSpacing=i.letterSpacing!==void 0?i.letterSpacing:o.letterSpacing!==void 0?o.letterSpacing:null,this.ligatures=typeof i.ligatures=="boolean"?i.ligatures:o.ligatures??null,this.lineHeight=i.lineHeight!==void 0?i.lineHeight:o.lineHeight!==void 0?o.lineHeight:null,this.linkColor=i.linkColor||o.linkColor||null,this.maximalLineLength=i.maximalLineLength===null?null:i.maximalLineLength||o.maximalLineLength||null,this.minimalLineLength=i.minimalLineLength===null?null:i.minimalLineLength||o.minimalLineLength||null,this.noRuby=typeof i.noRuby=="boolean"?i.noRuby:o.noRuby??null,this.optimalLineLength=i.optimalLineLength||o.optimalLineLength,this.pageGutter=i.pageGutter!==void 0?i.pageGutter:o.pageGutter!==void 0?o.pageGutter:null,this.paragraphIndent=i.paragraphIndent!==void 0?i.paragraphIndent:o.paragraphIndent!==void 0?o.paragraphIndent:null,this.paragraphSpacing=i.paragraphSpacing!==void 0?i.paragraphSpacing:o.paragraphSpacing!==void 0?o.paragraphSpacing:null,this.scroll=typeof i.scroll=="boolean"?i.scroll:o.scroll??null,this.scrollPaddingTop=i.scrollPaddingTop!==void 0?i.scrollPaddingTop:o.scrollPaddingTop!==void 0?o.scrollPaddingTop:null,this.scrollPaddingBottom=i.scrollPaddingBottom!==void 0?i.scrollPaddingBottom:o.scrollPaddingBottom!==void 0?o.scrollPaddingBottom:null,this.scrollPaddingLeft=i.scrollPaddingLeft!==void 0?i.scrollPaddingLeft:o.scrollPaddingLeft!==void 0?o.scrollPaddingLeft:null,this.scrollPaddingRight=i.scrollPaddingRight!==void 0?i.scrollPaddingRight:o.scrollPaddingRight!==void 0?o.scrollPaddingRight:null,this.selectionBackgroundColor=i.selectionBackgroundColor||o.selectionBackgroundColor||null,this.selectionTextColor=i.selectionTextColor||o.selectionTextColor||null,this.textAlign=i.textAlign||o.textAlign||null,this.textColor=i.textColor||o.textColor||null,this.textNormalization=typeof i.textNormalization=="boolean"?i.textNormalization:o.textNormalization??null,this.visitedColor=i.visitedColor||o.visitedColor||null,this.wordSpacing=i.wordSpacing!==void 0?i.wordSpacing:o.wordSpacing!==void 0?o.wordSpacing:null,this.experiments=o.experiments||null}}export{a as EpubSettings};
1
+ import{sMLWithRequest as t}from"@readium/helpers";class a{constructor(i,o){this.backgroundColor=i.backgroundColor||o.backgroundColor||null,this.blendFilter=typeof i.blendFilter=="boolean"?i.blendFilter:o.blendFilter??null,this.columnCount=i.columnCount!==void 0?i.columnCount:o.columnCount!==void 0?o.columnCount:null,this.constraint=i.constraint||o.constraint,this.darkenFilter=typeof i.darkenFilter=="boolean"?i.darkenFilter:o.darkenFilter??null,this.deprecatedFontSize=typeof i.deprecatedFontSize=="boolean"?i.deprecatedFontSize:o.deprecatedFontSize??null,this.fontFamily=i.fontFamily||o.fontFamily||null,this.fontSize=i.fontSize!==void 0?i.fontSize:o.fontSize!==void 0?o.fontSize:null,this.fontSizeNormalize=typeof i.fontSizeNormalize=="boolean"?i.fontSizeNormalize:o.fontSizeNormalize??null,this.fontOpticalSizing=typeof i.fontOpticalSizing=="boolean"?i.fontOpticalSizing:o.fontOpticalSizing??null,this.fontWeight=i.fontWeight!==void 0?i.fontWeight:o.fontWeight!==void 0?o.fontWeight:null,this.fontWidth=i.fontWidth!==void 0?i.fontWidth:o.fontWidth!==void 0?o.fontWidth:null,this.hyphens=typeof i.hyphens=="boolean"?i.hyphens:o.hyphens??null,this.invertFilter=typeof i.invertFilter=="boolean"?i.invertFilter:o.invertFilter??null,this.invertGaijiFilter=typeof i.invertGaijiFilter=="boolean"?i.invertGaijiFilter:o.invertGaijiFilter??null,this.iOSPatch=this.deprecatedFontSize||i.iOSPatch===!1?!1:i.iOSPatch===!0?(t.OS.iOS||t.OS.iPadOS)&&t.iOSRequest==="mobile":o.iOSPatch,this.iPadOSPatch=this.deprecatedFontSize||i.iPadOSPatch===!1?!1:i.iPadOSPatch===!0?t.OS.iPadOS&&t.iOSRequest==="desktop":o.iPadOSPatch,this.letterSpacing=i.letterSpacing!==void 0?i.letterSpacing:o.letterSpacing!==void 0?o.letterSpacing:null,this.ligatures=typeof i.ligatures=="boolean"?i.ligatures:o.ligatures??null,this.lineHeight=i.lineHeight!==void 0?i.lineHeight:o.lineHeight!==void 0?o.lineHeight:null,this.linkColor=i.linkColor||o.linkColor||null,this.maximalLineLength=i.maximalLineLength===null?null:i.maximalLineLength||o.maximalLineLength||null,this.minimalLineLength=i.minimalLineLength===null?null:i.minimalLineLength||o.minimalLineLength||null,this.noRuby=typeof i.noRuby=="boolean"?i.noRuby:o.noRuby??null,this.optimalLineLength=i.optimalLineLength||o.optimalLineLength,this.pageGutter=i.pageGutter!==void 0?i.pageGutter:o.pageGutter!==void 0?o.pageGutter:null,this.paragraphIndent=i.paragraphIndent!==void 0?i.paragraphIndent:o.paragraphIndent!==void 0?o.paragraphIndent:null,this.paragraphSpacing=i.paragraphSpacing!==void 0?i.paragraphSpacing:o.paragraphSpacing!==void 0?o.paragraphSpacing:null,this.scroll=typeof i.scroll=="boolean"?i.scroll:o.scroll??null,this.scrollPaddingTop=i.scrollPaddingTop!==void 0?i.scrollPaddingTop:o.scrollPaddingTop!==void 0?o.scrollPaddingTop:null,this.scrollPaddingBottom=i.scrollPaddingBottom!==void 0?i.scrollPaddingBottom:o.scrollPaddingBottom!==void 0?o.scrollPaddingBottom:null,this.scrollPaddingLeft=i.scrollPaddingLeft!==void 0?i.scrollPaddingLeft:o.scrollPaddingLeft!==void 0?o.scrollPaddingLeft:null,this.scrollPaddingRight=i.scrollPaddingRight!==void 0?i.scrollPaddingRight:o.scrollPaddingRight!==void 0?o.scrollPaddingRight:null,this.selectionBackgroundColor=i.selectionBackgroundColor||o.selectionBackgroundColor||null,this.selectionTextColor=i.selectionTextColor||o.selectionTextColor||null,this.textAlign=i.textAlign||o.textAlign||null,this.textColor=i.textColor||o.textColor||null,this.textNormalization=typeof i.textNormalization=="boolean"?i.textNormalization:o.textNormalization??null,this.visitedColor=i.visitedColor||o.visitedColor||null,this.wordSpacing=i.wordSpacing!==void 0?i.wordSpacing:o.wordSpacing!==void 0?o.wordSpacing:null,this.experiments=o.experiments||null}}export{a as EpubSettings};
@@ -1 +1 @@
1
- import{sML as i}from"../helpers/dist/sML.js";import{WorkerConsole as s}from"./utils/WorkerConsole.js";import{table as o,log as c,clear as l}from"./utils/console.js";import{isBrave as n}from"./utils/platform.js";import{match as h}from"./utils/match.js";class d{constructor(e={}){if(this.isOpen=!1,this.checkCount=0,this.maxChecks=10,this.maxPrintTime=0,this.largeObjectArray=null,this.options={onDetected:e.onDetected||(()=>{}),onClosed:e.onClosed||(()=>{}),interval:e.interval||1e3,enableDebuggerDetection:e.enableDebuggerDetection||!1},!i.UA.Firefox)try{const t=new Blob([s.workerScript],{type:"application/javascript"}),r=URL.createObjectURL(t),a=new Worker(r);this.workerConsole=new s(a,r)}catch(t){console.warn("Failed to create Web Worker for DevTools detection:",t)}this.startDetection()}createLargeObjectArray(){const e={};for(let r=0;r<500;r++)e[`${r}`]=`${r}`;const t=[];for(let r=0;r<50;r++)t.push(e);return t}getLargeObjectArray(){return this.largeObjectArray===null&&(this.largeObjectArray=this.createLargeObjectArray()),this.largeObjectArray}async calcTablePrintTime(){const e=this.getLargeObjectArray();if(this.workerConsole)try{return(await this.workerConsole.table(e)).time}catch{const r=performance.now();return o(e),performance.now()-r}else{const t=performance.now();return o(e),performance.now()-t}}async calcLogPrintTime(){const e=this.getLargeObjectArray();if(this.workerConsole)return(await this.workerConsole.log(e)).time;{const t=performance.now();return c(e),performance.now()-t}}isPerformanceDetectionEnabled(){return h({includes:[()=>!!i.UA.Chrome,()=>!!i.UA.Chromium,()=>!!i.UA.Safari,()=>!!i.UA.Firefox],excludes:[]})}isDebuggerDetectionEnabled(){return this.options.enableDebuggerDetection}async checkPerformanceBased(){if(!this.isPerformanceDetectionEnabled())return!1;const e=await this.calcTablePrintTime(),t=Math.max(await this.calcLogPrintTime(),await this.calcLogPrintTime());return this.maxPrintTime=Math.max(this.maxPrintTime,t),this.workerConsole?await this.workerConsole.clear():l(),e===0?!1:this.maxPrintTime===0?!!await n():e>this.maxPrintTime*10}async checkDebuggerBased(){if(!this.isDebuggerDetectionEnabled()||await n())return!1;const e=performance.now();try{(()=>{}).constructor("debugger")()}catch{debugger}return performance.now()-e>100}async detectDevTools(){return await this.checkPerformanceBased()?!0:this.options.enableDebuggerDetection&&this.checkCount>=this.maxChecks?await this.checkDebuggerBased():!1}startDetection(){this.intervalId=window.setInterval(async()=>{this.checkCount++;const e=await this.detectDevTools();e!==this.isOpen&&(this.isOpen=e,e?this.options.onDetected():this.options.onClosed()),this.checkCount>this.maxChecks*2&&(this.checkCount=0)},this.options.interval),window.addEventListener("beforeunload",()=>this.destroy())}isDevToolsOpen(){return this.isOpen}async checkNow(){const e=this.isOpen;return this.isOpen=await this.detectDevTools(),this.isOpen!==e&&(this.isOpen?this.options.onDetected():this.options.onClosed()),this.isOpen}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.workerConsole&&(this.workerConsole.destroy(),this.workerConsole=void 0),this.isOpen=!1,this.checkCount=0}}export{d as DevToolsDetector};
1
+ import{sML as i}from"@readium/helpers";import{WorkerConsole as s}from"./utils/WorkerConsole.js";import{table as o,log as c,clear as l}from"./utils/console.js";import{isBrave as n}from"./utils/platform.js";import{match as h}from"./utils/match.js";class d{constructor(e={}){if(this.isOpen=!1,this.checkCount=0,this.maxChecks=10,this.maxPrintTime=0,this.largeObjectArray=null,this.options={onDetected:e.onDetected||(()=>{}),onClosed:e.onClosed||(()=>{}),interval:e.interval||1e3,enableDebuggerDetection:e.enableDebuggerDetection||!1},!i.UA.Firefox)try{const t=new Blob([s.workerScript],{type:"application/javascript"}),r=URL.createObjectURL(t),a=new Worker(r);this.workerConsole=new s(a,r)}catch(t){console.warn("Failed to create Web Worker for DevTools detection:",t)}this.startDetection()}createLargeObjectArray(){const e={};for(let r=0;r<500;r++)e[`${r}`]=`${r}`;const t=[];for(let r=0;r<50;r++)t.push(e);return t}getLargeObjectArray(){return this.largeObjectArray===null&&(this.largeObjectArray=this.createLargeObjectArray()),this.largeObjectArray}async calcTablePrintTime(){const e=this.getLargeObjectArray();if(this.workerConsole)try{return(await this.workerConsole.table(e)).time}catch{const r=performance.now();return o(e),performance.now()-r}else{const t=performance.now();return o(e),performance.now()-t}}async calcLogPrintTime(){const e=this.getLargeObjectArray();if(this.workerConsole)return(await this.workerConsole.log(e)).time;{const t=performance.now();return c(e),performance.now()-t}}isPerformanceDetectionEnabled(){return h({includes:[()=>!!i.UA.Chrome,()=>!!i.UA.Chromium,()=>!!i.UA.Safari,()=>!!i.UA.Firefox],excludes:[]})}isDebuggerDetectionEnabled(){return this.options.enableDebuggerDetection}async checkPerformanceBased(){if(!this.isPerformanceDetectionEnabled())return!1;const e=await this.calcTablePrintTime(),t=Math.max(await this.calcLogPrintTime(),await this.calcLogPrintTime());return this.maxPrintTime=Math.max(this.maxPrintTime,t),this.workerConsole?await this.workerConsole.clear():l(),e===0?!1:this.maxPrintTime===0?!!await n():e>this.maxPrintTime*10}async checkDebuggerBased(){if(!this.isDebuggerDetectionEnabled()||await n())return!1;const e=performance.now();try{(()=>{}).constructor("debugger")()}catch{debugger}return performance.now()-e>100}async detectDevTools(){return await this.checkPerformanceBased()?!0:this.options.enableDebuggerDetection&&this.checkCount>=this.maxChecks?await this.checkDebuggerBased():!1}startDetection(){this.intervalId=window.setInterval(async()=>{this.checkCount++;const e=await this.detectDevTools();e!==this.isOpen&&(this.isOpen=e,e?this.options.onDetected():this.options.onClosed()),this.checkCount>this.maxChecks*2&&(this.checkCount=0)},this.options.interval),window.addEventListener("beforeunload",()=>this.destroy())}isDevToolsOpen(){return this.isOpen}async checkNow(){const e=this.isOpen;return this.isOpen=await this.detectDevTools(),this.isOpen!==e&&(this.isOpen?this.options.onDetected():this.options.onClosed()),this.isOpen}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0),this.workerConsole&&(this.workerConsole.destroy(),this.workerConsole=void 0),this.isOpen=!1,this.checkCount=0}}export{d as DevToolsDetector};
@@ -1 +1 @@
1
- import{Loader as o}from"@readium/navigator-html-injectables";import{FrameComms as n}from"../epub/frame/FrameComms.js";import{sML as h}from"../helpers/dist/sML.js";import{KeyboardConditionBridge as m}from"../peripherals/KeyboardConditionBridge.js";class y{constructor(t,i={},r=[],e=[]){this.timelineFragmentIds=e,this.hidden=!0,this.destroyed=!1,this.currModules=[],this.frame=document.createElement("iframe"),this.frame.classList.add("readium-navigator-iframe"),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transition="visibility 0s, opacity 0.1s linear",this.frame.style.backgroundColor="#FFFFFF",this.source=t,this.contentProtectionConfig={...i},this.keyboardPeripheralsConfig=[...r]}async load(t=[]){return new Promise((i,r)=>{if(this.loader){const e=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...t].sort().join("|")){try{i(e)}catch{}return}this.comms?.halt(),this.loader.destroy(),this.loader=new o(e,t),this.currModules=t,this.comms=void 0;try{i(e)}catch{}return}this.frame.onload=()=>{const e=this.frame.contentWindow;this.loader=new o(e,t),this.currModules=t;try{i(e)}catch{}},this.frame.onerror=e=>{try{r(e)}catch{}},this.frame.contentWindow.location.replace(this.source)})}applyContentProtection(){this.comms||this.comms.resume(),this.comms.send("peripherals_protection",this.contentProtectionConfig),this.keyboardPeripheralsConfig&&this.keyboardPeripheralsConfig.length>0&&(this.conditionBridge?.destroy(),this.conditionBridge=new m(this.keyboardPeripheralsConfig,t=>{t.length>0&&this.comms.send("keyboard_peripherals",t)}),this.conditionBridge.setup()),this.contentProtectionConfig.monitorScrollingExperimental&&this.comms.send("scroll_protection",{}),this.contentProtectionConfig.protectPrinting?.disable&&this.comms.send("print_protection",this.contentProtectionConfig.protectPrinting)}async destroy(){this.conditionBridge?.destroy(),await this.hide(),this.loader?.destroy(),this.frame.remove(),this.destroyed=!0}async hide(){if(!this.destroyed){if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.hidden=!0,this.frame.parentElement)return this.comms===void 0||!this.comms.ready?void 0:new Promise((t,i)=>{this.comms?.send("unfocus",void 0,r=>{this.comms?.halt(),t()})});this.comms?.halt()}}async show(t){if(this.destroyed)throw Error("Trying to show frame when it doesn't exist");if(!this.frame.parentElement)throw Error("Trying to show frame that is not attached to the DOM");return this.comms?this.comms.resume():this.comms=new n(this.frame.contentWindow,this.source),new Promise((i,r)=>{this.comms?.send("activate",void 0,()=>{this.comms?.send("focus",void 0,()=>{this.applyContentProtection(),this.timelineFragmentIds.length>0&&this.comms?.send("timeline_entries",this.timelineFragmentIds);const e=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),this.hidden=!1,h.UA.WebKit&&this.comms?.send("force_webkit_recalc",void 0),i()};t!==void 0?this.comms?.send("go_progression",t,e):e()})})})}setCSSProperties(t){this.destroyed||!this.frame.contentWindow||(this.hidden&&(this.comms?this.comms?.resume():this.comms=new n(this.frame.contentWindow,this.source)),this.comms?.send("update_properties",t),this.hidden&&this.comms?.halt())}get iframe(){if(this.destroyed)throw Error("Trying to use frame when it doesn't exist");return this.frame}get realSize(){if(this.destroyed)throw Error("Trying to use frame client rect when it doesn't exist");return this.frame.getBoundingClientRect()}get window(){if(this.destroyed||!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get msg(){return this.comms}get ldr(){return this.loader}}export{y as WebPubFrameManager};
1
+ import{Loader as o}from"@readium/navigator-html-injectables";import{FrameComms as n}from"../epub/frame/FrameComms.js";import{sML as h}from"@readium/helpers";import{KeyboardConditionBridge as m}from"../peripherals/KeyboardConditionBridge.js";class y{constructor(t,i={},r=[],e=[]){this.timelineFragmentIds=e,this.hidden=!0,this.destroyed=!1,this.currModules=[],this.frame=document.createElement("iframe"),this.frame.classList.add("readium-navigator-iframe"),this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.position="absolute",this.frame.style.pointerEvents="none",this.frame.style.transition="visibility 0s, opacity 0.1s linear",this.frame.style.backgroundColor="#FFFFFF",this.source=t,this.contentProtectionConfig={...i},this.keyboardPeripheralsConfig=[...r]}async load(t=[]){return new Promise((i,r)=>{if(this.loader){const e=this.frame.contentWindow;if([...this.currModules].sort().join("|")===[...t].sort().join("|")){try{i(e)}catch{}return}this.comms?.halt(),this.loader.destroy(),this.loader=new o(e,t),this.currModules=t,this.comms=void 0;try{i(e)}catch{}return}this.frame.onload=()=>{const e=this.frame.contentWindow;this.loader=new o(e,t),this.currModules=t;try{i(e)}catch{}},this.frame.onerror=e=>{try{r(e)}catch{}},this.frame.contentWindow.location.replace(this.source)})}applyContentProtection(){this.comms||this.comms.resume(),this.comms.send("peripherals_protection",this.contentProtectionConfig),this.keyboardPeripheralsConfig&&this.keyboardPeripheralsConfig.length>0&&(this.conditionBridge?.destroy(),this.conditionBridge=new m(this.keyboardPeripheralsConfig,t=>{t.length>0&&this.comms.send("keyboard_peripherals",t)}),this.conditionBridge.setup()),this.contentProtectionConfig.monitorScrollingExperimental&&this.comms.send("scroll_protection",{}),this.contentProtectionConfig.protectPrinting?.disable&&this.comms.send("print_protection",this.contentProtectionConfig.protectPrinting)}async destroy(){this.conditionBridge?.destroy(),await this.hide(),this.loader?.destroy(),this.frame.remove(),this.destroyed=!0}async hide(){if(!this.destroyed){if(this.frame.style.visibility="hidden",this.frame.style.setProperty("aria-hidden","true"),this.frame.style.opacity="0",this.frame.style.pointerEvents="none",this.hidden=!0,this.frame.parentElement)return this.comms===void 0||!this.comms.ready?void 0:new Promise((t,i)=>{this.comms?.send("unfocus",void 0,r=>{this.comms?.halt(),t()})});this.comms?.halt()}}async show(t){if(this.destroyed)throw Error("Trying to show frame when it doesn't exist");if(!this.frame.parentElement)throw Error("Trying to show frame that is not attached to the DOM");return this.comms?this.comms.resume():this.comms=new n(this.frame.contentWindow,this.source),new Promise((i,r)=>{this.comms?.send("activate",void 0,()=>{this.comms?.send("focus",void 0,()=>{this.applyContentProtection(),this.timelineFragmentIds.length>0&&this.comms?.send("timeline_entries",this.timelineFragmentIds);const e=()=>{this.frame.style.removeProperty("visibility"),this.frame.style.removeProperty("aria-hidden"),this.frame.style.removeProperty("opacity"),this.frame.style.removeProperty("pointer-events"),this.hidden=!1,h.UA.WebKit&&this.comms?.send("force_webkit_recalc",void 0),i()};t!==void 0?this.comms?.send("go_progression",t,e):e()})})})}setCSSProperties(t){this.destroyed||!this.frame.contentWindow||(this.hidden&&(this.comms?this.comms?.resume():this.comms=new n(this.frame.contentWindow,this.source)),this.comms?.send("update_properties",t),this.hidden&&this.comms?.halt())}get iframe(){if(this.destroyed)throw Error("Trying to use frame when it doesn't exist");return this.frame}get realSize(){if(this.destroyed)throw Error("Trying to use frame client rect when it doesn't exist");return this.frame.getBoundingClientRect()}get window(){if(this.destroyed||!this.frame.contentWindow)throw Error("Trying to use frame window when it doesn't exist");return this.frame.contentWindow}get msg(){return this.comms}get ldr(){return this.loader}}export{y as WebPubFrameManager};
@@ -1 +1 @@
1
- import{fontWeightRangeConfig as r,zoomRangeConfig as o,TextAlignment as h}from"../../preferences/Types.js";import{ensureString as l,ensureValueInRange as a,ensureBoolean as t,ensureNonNegative as n,ensureEnumValue as g,ensureExperiment as s}from"../../preferences/guards.js";import{sMLWithRequest as e}from"../../helpers/dist/sML.js";class c{constructor(i){this.fontFamily=l(i.fontFamily)||null,this.fontWeight=a(i.fontWeight,r.range)||null,this.hyphens=t(i.hyphens)??null,this.iOSPatch=i.iOSPatch===!1?!1:(e.OS.iOS||e.OS.iPadOS)&&e.iOSRequest==="mobile",this.iPadOSPatch=i.iPadOSPatch===!1?!1:e.OS.iPadOS&&e.iOSRequest==="desktop",this.letterSpacing=n(i.letterSpacing)||null,this.ligatures=t(i.ligatures)??null,this.lineHeight=n(i.lineHeight)||null,this.noRuby=t(i.noRuby)??!1,this.paragraphIndent=n(i.paragraphIndent)??null,this.paragraphSpacing=n(i.paragraphSpacing)??null,this.textAlign=g(i.textAlign,h)||null,this.textNormalization=t(i.textNormalization)??!1,this.wordSpacing=n(i.wordSpacing)||null,this.zoom=a(i.zoom,o.range)||1,this.experiments=s(i.experiments)??null}}export{c as WebPubDefaults};
1
+ import{fontWeightRangeConfig as a,zoomRangeConfig as o,TextAlignment as h}from"../../preferences/Types.js";import{ensureString as l,ensureValueInRange as r,ensureBoolean as t,ensureNonNegative as n,ensureEnumValue as g,ensureExperiment as s}from"../../preferences/guards.js";import{sMLWithRequest as e}from"@readium/helpers";class c{constructor(i){this.fontFamily=l(i.fontFamily)||null,this.fontWeight=r(i.fontWeight,a.range)||null,this.hyphens=t(i.hyphens)??null,this.iOSPatch=i.iOSPatch===!1?!1:(e.OS.iOS||e.OS.iPadOS)&&e.iOSRequest==="mobile",this.iPadOSPatch=i.iPadOSPatch===!1?!1:e.OS.iPadOS&&e.iOSRequest==="desktop",this.letterSpacing=n(i.letterSpacing)||null,this.ligatures=t(i.ligatures)??null,this.lineHeight=n(i.lineHeight)||null,this.noRuby=t(i.noRuby)??!1,this.paragraphIndent=n(i.paragraphIndent)??null,this.paragraphSpacing=n(i.paragraphSpacing)??null,this.textAlign=g(i.textAlign,h)||null,this.textNormalization=t(i.textNormalization)??!1,this.wordSpacing=n(i.wordSpacing)||null,this.zoom=r(i.zoom,o.range)||1,this.experiments=s(i.experiments)??null}}export{c as WebPubDefaults};
@@ -1 +1 @@
1
- import{Feature as c}from"@readium/shared";import{WebPubPreferences as o}from"./WebPubPreferences.js";import{Preference as d,RangePreference as t,BooleanPreference as i,EnumPreference as m}from"../../preferences/Preference.js";import{fontWeightRangeConfig as a,letterSpacingRangeConfig as s,lineHeightRangeConfig as r,paragraphIndentRangeConfig as l,paragraphSpacingRangeConfig as f,TextAlignment as p,wordSpacingRangeConfig as g,zoomRangeConfig as h}from"../../preferences/Types.js";class b{constructor(e,n,u){this.preferences=e,this.settings=n,this.metadata=u}clear(){this.preferences=new o({})}updatePreference(e,n){this.preferences[e]=n}get isDisplayTransformable(){return this.metadata?.accessibility?.feature?.some(e=>e.value===c.DISPLAY_TRANSFORMABILITY.value)??!1}get fontFamily(){return new d({initialValue:this.preferences.fontFamily,effectiveValue:this.settings.fontFamily||null,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontFamily",e??null)}})}get fontWeight(){return new t({initialValue:this.preferences.fontWeight,effectiveValue:this.settings.fontWeight||400,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontWeight",e??null)},supportedRange:a.range,step:a.step})}get hyphens(){return new i({initialValue:this.preferences.hyphens,effectiveValue:this.settings.hyphens||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("hyphens",e??null)}})}get iOSPatch(){return new i({initialValue:this.preferences.iOSPatch,effectiveValue:this.settings.iOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iOSPatch",e??null)}})}get iPadOSPatch(){return new i({initialValue:this.preferences.iPadOSPatch,effectiveValue:this.settings.iPadOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iPadOSPatch",e??null)}})}get letterSpacing(){return new t({initialValue:this.preferences.letterSpacing,effectiveValue:this.settings.letterSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("letterSpacing",e??null)},supportedRange:s.range,step:s.step})}get ligatures(){return new i({initialValue:this.preferences.ligatures,effectiveValue:this.settings.ligatures||!0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("ligatures",e??null)}})}get lineHeight(){return new t({initialValue:this.preferences.lineHeight,effectiveValue:this.settings.lineHeight,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("lineHeight",e??null)},supportedRange:r.range,step:r.step})}get noRuby(){return new i({initialValue:this.preferences.noRuby,effectiveValue:this.settings.noRuby||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("noRuby",e??null)}})}get paragraphIndent(){return new t({initialValue:this.preferences.paragraphIndent,effectiveValue:this.settings.paragraphIndent||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphIndent",e??null)},supportedRange:l.range,step:l.step})}get paragraphSpacing(){return new t({initialValue:this.preferences.paragraphSpacing,effectiveValue:this.settings.paragraphSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphSpacing",e??null)},supportedRange:f.range,step:f.step})}get textAlign(){return new m({initialValue:this.preferences.textAlign,effectiveValue:this.settings.textAlign||p.start,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textAlign",e??null)},supportedValues:Object.values(p)})}get textNormalization(){return new i({initialValue:this.preferences.textNormalization,effectiveValue:this.settings.textNormalization||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textNormalization",e??null)}})}get wordSpacing(){return new t({initialValue:this.preferences.wordSpacing,effectiveValue:this.settings.wordSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("wordSpacing",e??null)},supportedRange:g.range,step:g.step})}get zoom(){return new t({initialValue:this.preferences.zoom,effectiveValue:this.settings.zoom||1,isEffective:CSS.supports("zoom","1")??!1,onChange:e=>{this.updatePreference("zoom",e??null)},supportedRange:h.range,step:h.step})}}export{b as WebPubPreferencesEditor};
1
+ import{Feature as o}from"@readium/shared";import{WebPubPreferences as a}from"./WebPubPreferences.js";import{Preference as d,RangePreference as t,BooleanPreference as i,EnumPreference as m}from"../../preferences/Preference.js";import{fontWeightRangeConfig as r,letterSpacingRangeConfig as s,lineHeightRangeConfig as l,paragraphIndentRangeConfig as f,paragraphSpacingRangeConfig as p,TextAlignment as g,wordSpacingRangeConfig as u,zoomRangeConfig as h}from"../../preferences/Types.js";class b{constructor(e,n,c){this.preferences=new a({...e}),this.settings=n,this.metadata=c}clear(){this.preferences=new a({fontFamily:null,fontWeight:null,hyphens:null,iOSPatch:null,iPadOSPatch:null,letterSpacing:null,ligatures:null,lineHeight:null,noRuby:null,paragraphIndent:null,paragraphSpacing:null,textAlign:null,textNormalization:null,wordSpacing:null,zoom:null})}updatePreference(e,n){this.preferences[e]=n}get isDisplayTransformable(){return this.metadata?.accessibility?.feature?.some(e=>e.value===o.DISPLAY_TRANSFORMABILITY.value)??!1}get fontFamily(){return new d({initialValue:this.preferences.fontFamily,effectiveValue:this.settings.fontFamily||null,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontFamily",e??null)}})}get fontWeight(){return new t({initialValue:this.preferences.fontWeight,effectiveValue:this.settings.fontWeight||400,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("fontWeight",e??null)},supportedRange:r.range,step:r.step})}get hyphens(){return new i({initialValue:this.preferences.hyphens,effectiveValue:this.settings.hyphens||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("hyphens",e??null)}})}get iOSPatch(){return new i({initialValue:this.preferences.iOSPatch,effectiveValue:this.settings.iOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iOSPatch",e??null)}})}get iPadOSPatch(){return new i({initialValue:this.preferences.iPadOSPatch,effectiveValue:this.settings.iPadOSPatch||!1,isEffective:!0,onChange:e=>{this.updatePreference("iPadOSPatch",e??null)}})}get letterSpacing(){return new t({initialValue:this.preferences.letterSpacing,effectiveValue:this.settings.letterSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("letterSpacing",e??null)},supportedRange:s.range,step:s.step})}get ligatures(){return new i({initialValue:this.preferences.ligatures,effectiveValue:this.settings.ligatures||!0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("ligatures",e??null)}})}get lineHeight(){return new t({initialValue:this.preferences.lineHeight,effectiveValue:this.settings.lineHeight,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("lineHeight",e??null)},supportedRange:l.range,step:l.step})}get noRuby(){return new i({initialValue:this.preferences.noRuby,effectiveValue:this.settings.noRuby||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("noRuby",e??null)}})}get paragraphIndent(){return new t({initialValue:this.preferences.paragraphIndent,effectiveValue:this.settings.paragraphIndent||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphIndent",e??null)},supportedRange:f.range,step:f.step})}get paragraphSpacing(){return new t({initialValue:this.preferences.paragraphSpacing,effectiveValue:this.settings.paragraphSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("paragraphSpacing",e??null)},supportedRange:p.range,step:p.step})}get textAlign(){return new m({initialValue:this.preferences.textAlign,effectiveValue:this.settings.textAlign||g.start,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textAlign",e??null)},supportedValues:Object.values(g)})}get textNormalization(){return new i({initialValue:this.preferences.textNormalization,effectiveValue:this.settings.textNormalization||!1,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("textNormalization",e??null)}})}get wordSpacing(){return new t({initialValue:this.preferences.wordSpacing,effectiveValue:this.settings.wordSpacing||0,isEffective:this.isDisplayTransformable,onChange:e=>{this.updatePreference("wordSpacing",e??null)},supportedRange:u.range,step:u.step})}get zoom(){return new t({initialValue:this.preferences.zoom,effectiveValue:this.settings.zoom||1,isEffective:CSS.supports("zoom","1")??!1,onChange:e=>{this.updatePreference("zoom",e??null)},supportedRange:h.range,step:h.step})}}export{b as WebPubPreferencesEditor};
@@ -1 +1 @@
1
- import{sMLWithRequest as a}from"../../helpers/dist/sML.js";class o{constructor(i,t,h){this.fontFamily=null,this.fontWeight=null,this.hyphens=null,this.iOSPatch=null,this.iPadOSPatch=null,this.letterSpacing=null,this.ligatures=null,this.lineHeight=null,this.noRuby=null,this.paragraphIndent=null,this.paragraphSpacing=null,this.textAlign=null,this.textNormalization=null,this.wordSpacing=null,h&&(this.fontFamily=i.fontFamily||t.fontFamily||null,this.fontWeight=i.fontWeight!==void 0?i.fontWeight:t.fontWeight!==void 0?t.fontWeight:null,this.hyphens=typeof i.hyphens=="boolean"?i.hyphens:t.hyphens??null,this.iOSPatch=i.iOSPatch===!1?!1:i.iOSPatch===!0?(a.OS.iOS||a.OS.iPadOS)&&a.iOSRequest==="mobile":t.iOSPatch,this.iPadOSPatch=i.iPadOSPatch===!1?!1:i.iPadOSPatch===!0?a.OS.iPadOS&&a.iOSRequest==="desktop":t.iPadOSPatch,this.letterSpacing=i.letterSpacing!==void 0?i.letterSpacing:t.letterSpacing!==void 0?t.letterSpacing:null,this.ligatures=typeof i.ligatures=="boolean"?i.ligatures:t.ligatures??null,this.lineHeight=i.lineHeight!==void 0?i.lineHeight:t.lineHeight!==void 0?t.lineHeight:null,this.noRuby=typeof i.noRuby=="boolean"?i.noRuby:t.noRuby??null,this.paragraphIndent=i.paragraphIndent!==void 0?i.paragraphIndent:t.paragraphIndent!==void 0?t.paragraphIndent:null,this.paragraphSpacing=i.paragraphSpacing!==void 0?i.paragraphSpacing:t.paragraphSpacing!==void 0?t.paragraphSpacing:null,this.textAlign=i.textAlign||t.textAlign||null,this.textNormalization=typeof i.textNormalization=="boolean"?i.textNormalization:t.textNormalization??null,this.wordSpacing=i.wordSpacing!==void 0?i.wordSpacing:t.wordSpacing!==void 0?t.wordSpacing:null),this.zoom=i.zoom!==void 0?i.zoom:t.zoom!==void 0?t.zoom:null,this.experiments=t.experiments||null}}export{o as WebPubSettings};
1
+ import{sMLWithRequest as a}from"@readium/helpers";class o{constructor(i,t,h){this.fontFamily=null,this.fontWeight=null,this.hyphens=null,this.iOSPatch=null,this.iPadOSPatch=null,this.letterSpacing=null,this.ligatures=null,this.lineHeight=null,this.noRuby=null,this.paragraphIndent=null,this.paragraphSpacing=null,this.textAlign=null,this.textNormalization=null,this.wordSpacing=null,h&&(this.fontFamily=i.fontFamily||t.fontFamily||null,this.fontWeight=i.fontWeight!==void 0?i.fontWeight:t.fontWeight!==void 0?t.fontWeight:null,this.hyphens=typeof i.hyphens=="boolean"?i.hyphens:t.hyphens??null,this.iOSPatch=i.iOSPatch===!1?!1:i.iOSPatch===!0?(a.OS.iOS||a.OS.iPadOS)&&a.iOSRequest==="mobile":t.iOSPatch,this.iPadOSPatch=i.iPadOSPatch===!1?!1:i.iPadOSPatch===!0?a.OS.iPadOS&&a.iOSRequest==="desktop":t.iPadOSPatch,this.letterSpacing=i.letterSpacing!==void 0?i.letterSpacing:t.letterSpacing!==void 0?t.letterSpacing:null,this.ligatures=typeof i.ligatures=="boolean"?i.ligatures:t.ligatures??null,this.lineHeight=i.lineHeight!==void 0?i.lineHeight:t.lineHeight!==void 0?t.lineHeight:null,this.noRuby=typeof i.noRuby=="boolean"?i.noRuby:t.noRuby??null,this.paragraphIndent=i.paragraphIndent!==void 0?i.paragraphIndent:t.paragraphIndent!==void 0?t.paragraphIndent:null,this.paragraphSpacing=i.paragraphSpacing!==void 0?i.paragraphSpacing:t.paragraphSpacing!==void 0?t.paragraphSpacing:null,this.textAlign=i.textAlign||t.textAlign||null,this.textNormalization=typeof i.textNormalization=="boolean"?i.textNormalization:t.textNormalization??null,this.wordSpacing=i.wordSpacing!==void 0?i.wordSpacing:t.wordSpacing!==void 0?t.wordSpacing:null),this.zoom=i.zoom!==void 0?i.zoom:t.zoom!==void 0?t.zoom:null,this.experiments=t.experiments||null}}export{o as WebPubSettings};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/navigator",
3
- "version": "2.8.1",
3
+ "version": "2.9.0",
4
4
  "type": "module",
5
5
  "description": "Next generation SDK for publications in Web Apps",
6
6
  "author": "readium",
@@ -44,10 +44,10 @@
44
44
  "node": ">=18"
45
45
  },
46
46
  "dependencies": {
47
- "@readium/decorator": "1.0.2",
48
- "@readium/shared": "2.4.0",
49
- "@readium/navigator-html-injectables": "2.6.3",
50
- "@readium/helpers": "1.0.0"
47
+ "@readium/helpers": "1.1.0",
48
+ "@readium/navigator-html-injectables": "2.7.0",
49
+ "@readium/shared": "2.5.0",
50
+ "@readium/decorator": "1.1.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@readium/css": "^2.0.5",
@@ -13,12 +13,21 @@ export class AudioPreferencesEditor implements IPreferencesEditor {
13
13
  private settings: AudioSettings;
14
14
 
15
15
  constructor(initialPreferences: AudioPreferences, settings: AudioSettings) {
16
- this.preferences = initialPreferences;
16
+ this.preferences = new AudioPreferences({ ...initialPreferences });
17
17
  this.settings = settings;
18
18
  }
19
19
 
20
20
  clear(): void {
21
- this.preferences = new AudioPreferences();
21
+ this.preferences = new AudioPreferences({
22
+ volume: null,
23
+ playbackRate: null,
24
+ preservePitch: null,
25
+ skipBackwardInterval: null,
26
+ skipForwardInterval: null,
27
+ pollInterval: null,
28
+ autoPlay: null,
29
+ enableMediaSession: null
30
+ });
22
31
  }
23
32
 
24
33
  private updatePreference<K extends keyof AudioPreferences>(key: K, value: AudioPreferences[K]) {
@@ -27,14 +27,55 @@ export class EpubPreferencesEditor implements IPreferencesEditor {
27
27
  private layout: Layout;
28
28
 
29
29
  constructor(initialPreferences: EpubPreferences, settings: EpubSettings, metadata: Metadata) {
30
- this.preferences = initialPreferences;
30
+ this.preferences = new EpubPreferences({ ...initialPreferences });
31
31
  this.settings = settings;
32
32
  this.metadata = metadata;
33
33
  this.layout = this.metadata?.effectiveLayout || Layout.reflowable;
34
34
  }
35
35
 
36
36
  clear() {
37
- this.preferences = new EpubPreferences({ optimalLineLength: 65 });
37
+ this.preferences = new EpubPreferences({
38
+ backgroundColor: null,
39
+ blendFilter: null,
40
+ columnCount: null,
41
+ constraint: null,
42
+ darkenFilter: null,
43
+ deprecatedFontSize: null,
44
+ fontFamily: null,
45
+ fontSize: null,
46
+ fontSizeNormalize: null,
47
+ fontOpticalSizing: null,
48
+ fontWeight: null,
49
+ fontWidth: null,
50
+ hyphens: null,
51
+ invertFilter: null,
52
+ invertGaijiFilter: null,
53
+ iOSPatch: null,
54
+ iPadOSPatch: null,
55
+ letterSpacing: null,
56
+ ligatures: null,
57
+ lineHeight: null,
58
+ linkColor: null,
59
+ maximalLineLength: null,
60
+ minimalLineLength: null,
61
+ noRuby: null,
62
+ optimalLineLength: null,
63
+ pageGutter: null,
64
+ paragraphIndent: null,
65
+ paragraphSpacing: null,
66
+ scroll: null,
67
+ scrollPaddingTop: null,
68
+ scrollPaddingBottom: null,
69
+ scrollPaddingLeft: null,
70
+ scrollPaddingRight: null,
71
+ selectionBackgroundColor: null,
72
+ selectionTextColor: null,
73
+ textAlign: null,
74
+ textColor: null,
75
+ textNormalization: null,
76
+ visitedColor: null,
77
+ wordSpacing: null
78
+ });
38
79
  }
39
80
 
40
81
  private updatePreference<K extends keyof EpubPreferences>(key: K, value: EpubPreferences[K]) {
@@ -20,13 +20,29 @@ export class WebPubPreferencesEditor implements IPreferencesEditor {
20
20
  private metadata: Metadata | null;
21
21
 
22
22
  constructor(initialPreferences: WebPubPreferences, settings: WebPubSettings, metadata: Metadata) {
23
- this.preferences = initialPreferences;
23
+ this.preferences = new WebPubPreferences({ ...initialPreferences });
24
24
  this.settings = settings;
25
25
  this.metadata = metadata;
26
26
  }
27
27
 
28
28
  clear() {
29
- this.preferences = new WebPubPreferences({});
29
+ this.preferences = new WebPubPreferences({
30
+ fontFamily: null,
31
+ fontWeight: null,
32
+ hyphens: null,
33
+ iOSPatch: null,
34
+ iPadOSPatch: null,
35
+ letterSpacing: null,
36
+ ligatures: null,
37
+ lineHeight: null,
38
+ noRuby: null,
39
+ paragraphIndent: null,
40
+ paragraphSpacing: null,
41
+ textAlign: null,
42
+ textNormalization: null,
43
+ wordSpacing: null,
44
+ zoom: null
45
+ });
30
46
  }
31
47
 
32
48
  private updatePreference<K extends keyof WebPubPreferences>(key: K, value: WebPubPreferences[K]) {
@@ -1 +0,0 @@
1
- const O=()=>typeof navigator>"u"?"":navigator.userAgent||"",S=()=>typeof navigator>"u"?void 0:navigator.userAgentData||void 0;class h{constructor(){const n=S(),o=O(),d=t=>(typeof t=="string"||typeof t=="number")&&t?String(t).replace(/_/g,".").split(".").map(s=>parseInt(s)||0):[],i=(t="")=>{if(!t)return[];const s=new RegExp("^.*"+t+"[ :\\/]?(\\d+([\\._]\\d+)*).*$");return s.test(o)?d(o.replace(s,"$1")):[]};this.OS=(t=>(/(macOS|Mac OS X)/.test(o)?(/\(iP(hone|od touch);/.test(o)&&(t.iOS=i("CPU (?:iPhone )?OS ")),/\(iPad;/.test(o)?t.iOS=t.iPadOS=i("CPU (?:iPhone )?OS "):/(macOS|Mac OS X) \d/.test(o)&&(document.ontouchend!==void 0?t.iOS=t.iPadOS=i():t.macOS=i("(?:macOS|Mac OS X) "))):/Windows( NT)? \d/.test(o)?t.Windows=(s=>s[0]!==6||!s[1]?s:s[1]===1?[7]:s[1]===2?[8]:[8,1])(i("Windows(?: NT)?")):/Android \d/.test(o)?t.Android=i("Android"):/CrOS/.test(o)?t.ChromeOS=i():/X11;/.test(o)&&(t.Linux=i()),t))({}),n&&n.getHighEntropyValues(["architecture","model","platform","platformVersion","uaFullVersion"]).then(t=>(s=>{const e=t.platform,r=t.platformVersion;if(!(!e||!r)){if(/^i(OS|P(hone|od touch))$/.test(e))s.iOS=d(r);else if(/^iPad(OS)?$/.test(e))s.iOS=s.iPadOS=d(r);else if(/^(macOS|(Mac )?OS X|Mac(Intel)?)$/.test(e))document.ontouchend!==void 0?s.iOS=s.iPadOS=d():s.macOS=d(r);else if(/^(Microsoft )?Windows$/.test(e))s.Windows=d(r);else if(/^(Google )?Android$/.test(e))s.Android=d(r);else if(/^((Google )?Chrome OS|CrOS)$/.test(e))s.ChromeOS=d(r);else if(/^(Linux|Ubuntu|X11)$/.test(e))s.Linux=d(r);else return;Object.keys(this.OS).forEach(a=>delete this.OS[a]),Object.assign(this.OS,s)}})({})),this.UA=(t=>{let s=!1;if(n&&Array.isArray(n.brands)){const e=n.brands.reduce((r,a)=>(r[a.brand]=[a.version*1],r),{});e["Google Chrome"]?(s=!0,t.Blink=t.Chromium=e.Chromium||[],t.Chrome=e["Google Chrome"]):e["Microsoft Edge"]?(s=!0,t.Blink=t.Chromium=e.Chromium||[],t.Edge=e["Microsoft Edge"]):e.Opera&&(s=!0,t.Blink=t.Chromium=e.Chromium||[],t.Opera=e.Opera)}return s||(/ Gecko\/\d/.test(o)?(t.Gecko=i("rv"),/ Waterfox\/\d/.test(o)?t.Waterfox=i("Waterfox"):/ Firefox\/\d/.test(o)&&(t.Firefox=i("Firefox"))):/ Edge\/\d/.test(o)?(t.EdgeHTML=i("Edge"),t.Edge=t.EdgeHTML):/ Chrom(ium|e)\/\d/.test(o)?(t.Blink=t.Chromium=(e=>e[0]?e:i("Chrome"))(i("Chromium")),/ EdgA?\/\d/.test(o)?t.Edge=(e=>e[0]?e:i("Edg"))(i("EdgA")):/ OPR\/\d/.test(o)?t.Opera=i("OPR"):/ Vivaldi\/\d/.test(o)?t.Vivaldi=i("Vivaldi"):/ Silk\/\d/.test(o)?t.Silk=i("Silk"):/ UCBrowser\/\d/.test(o)?t.UCBrowser=i("UCBrowser"):/ Phoebe\/\d/.test(o)?t.Phoebe=i("Phoebe"):t.Chrome=(e=>e[0]?e:t.Chromium)(i("Chrome"))):/ AppleWebKit\/\d/.test(o)?(t.WebKit=i("AppleWebKit"),/ CriOS \d/.test(o)?t.Chrome=i("CriOS"):/ FxiOS \d/.test(o)?t.Firefox=i("FxiOS"):/ EdgiOS\/\d/.test(o)?t.Edge=i("EdgiOS"):/ Version\/\d/.test(o)&&(t.Safari=i("Version"))):/ Trident\/\d/.test(o)&&(t.Trident=i("Trident"),t.InternetExplorer=(e=>e[0]?e:i("MSIE"))(i("rv")))),/[\[; ]FB(AN|_IAB)\//.test(o)&&(t.Facebook=i("FBAV")),/ Line\/\d/.test(o)&&(t.LINE=i("Line")),t})({}),this.Env={get:()=>[this.OS,this.UA].reduce((t,s)=>{for(const e in s)s[e]&&t.push(e);return t},[])}}}class u extends h{get iOSRequest(){const n=S(),o=O();if(this.OS.iOS&&!this.OS.iPadOS)return"mobile";if(this.OS.iPadOS)return/\(iPad;/.test(o)||n&&/^iPad(OS)?$/.test(n.platform)?"mobile":"desktop"}}const l=new h,c=new u;export{l as sML,c as sMLWithRequest};