@readium/navigator 2.8.1 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio/preferences/AudioPreferencesEditor.js +1 -1
- package/dist/epub/preferences/EpubPreferencesEditor.js +1 -1
- package/dist/webpub/preferences/WebPubPreferencesEditor.js +1 -1
- package/package.json +2 -2
- package/src/audio/preferences/AudioPreferencesEditor.ts +11 -2
- package/src/epub/preferences/EpubPreferencesEditor.ts +43 -2
- package/src/webpub/preferences/WebPubPreferencesEditor.ts +18 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AudioPreferences as
|
|
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{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{Feature as
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/navigator",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Next generation SDK for publications in Web Apps",
|
|
6
6
|
"author": "readium",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@readium/decorator": "1.0.2",
|
|
48
|
-
"@readium/shared": "2.4.0",
|
|
49
48
|
"@readium/navigator-html-injectables": "2.6.3",
|
|
49
|
+
"@readium/shared": "2.4.0",
|
|
50
50
|
"@readium/helpers": "1.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -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({
|
|
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]) {
|