@readium/navigator-html-injectables 2.2.5 → 2.3.1-alpha.1
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/index.js +1133 -563
- package/dist/index.umd.cjs +23 -9
- package/package.json +8 -8
- package/src/comms/keys.ts +22 -3
- package/src/helpers/css.ts +2 -0
- package/src/index.ts +2 -1
- package/src/modules/ModuleLibrary.ts +10 -4
- package/src/modules/Peripherals.ts +458 -13
- package/src/modules/snapper/ColumnSnapper.ts +85 -5
- package/src/modules/snapper/ScrollSnapper.ts +59 -1
- package/src/modules/snapper/WebPubSnapper.ts +57 -3
- package/src/protection/BulkCopyProtector.ts +134 -0
- package/src/protection/KeyCombinationManager.ts +139 -0
- package/src/protection/KeyboardCombinations.ts +60 -0
- package/src/protection/PatternAnalyzer.ts +117 -0
- package/src/protection/PrintProtector.ts +87 -0
- package/src/protection/SelectionAnalyzer.ts +133 -0
- package/src/protection/config.ts +33 -0
- package/src/protection/index.ts +6 -0
- package/types/src/comms/keys.d.ts +3 -2
- package/types/src/helpers/css.d.ts +1 -0
- package/types/src/index.d.ts +1 -0
- package/types/src/modules/ModuleLibrary.d.ts +1 -1
- package/types/src/modules/Peripherals.d.ts +102 -2
- package/types/src/modules/snapper/ColumnSnapper.d.ts +10 -0
- package/types/src/modules/snapper/ScrollSnapper.d.ts +13 -0
- package/types/src/modules/snapper/WebPubSnapper.d.ts +6 -0
- package/types/src/protection/BulkCopyProtector.d.ts +20 -0
- package/types/src/protection/KeyCombinationManager.d.ts +33 -0
- package/types/src/protection/KeyboardCombinations.d.ts +15 -0
- package/types/src/protection/PatternAnalyzer.d.ts +18 -0
- package/types/src/protection/PrintProtector.d.ts +20 -0
- package/types/src/protection/SelectionAnalyzer.d.ts +20 -0
- package/types/src/protection/config.d.ts +7 -0
- package/types/src/protection/index.d.ts +6 -0
- package/src/types/protection.ts +0 -16
- package/types/src/types/protection.d.ts +0 -7
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const De = Math.pow(2, 32), _t = () => Math.round(Math.random() * De).toString(36), ze = () => `${Math.round(performance.now())}-${_t()}-${_t()}`, K = 1;
|
|
2
|
+
class Me {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
@@ -10,8 +10,8 @@ class Oe {
|
|
|
10
10
|
if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
|
|
11
11
|
if (e.key === "_ping") {
|
|
12
12
|
if (!this.destination) {
|
|
13
|
-
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !==
|
|
14
|
-
e._readium >
|
|
13
|
+
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== K) {
|
|
14
|
+
e._readium > K ? this.send("error", `received comms version ${e._readium} higher than ${K}`) : this.send("error", `received comms version ${e._readium} lower than ${K}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
@@ -71,9 +71,9 @@ class Oe {
|
|
|
71
71
|
send(t, e, i = void 0, s = []) {
|
|
72
72
|
if (!this.destination) throw Error("Attempted to send comms message before destination has been initialized");
|
|
73
73
|
const n = {
|
|
74
|
-
_readium:
|
|
74
|
+
_readium: K,
|
|
75
75
|
_channel: this.channelId,
|
|
76
|
-
id: i ??
|
|
76
|
+
id: i ?? ze(),
|
|
77
77
|
// scrict,
|
|
78
78
|
key: t,
|
|
79
79
|
data: e
|
|
@@ -89,7 +89,7 @@ class Oe {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const y = class y {
|
|
93
93
|
constructor(t) {
|
|
94
94
|
this.uri = t;
|
|
95
95
|
}
|
|
@@ -98,7 +98,7 @@ const b = class b {
|
|
|
98
98
|
*/
|
|
99
99
|
static deserialize(t) {
|
|
100
100
|
if (!(!t || typeof t != "string"))
|
|
101
|
-
return new
|
|
101
|
+
return new y(t);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Serializes an [AccessibilityProfile] to its RWPM JSON representation.
|
|
@@ -110,24 +110,24 @@ const b = class b {
|
|
|
110
110
|
* Returns true if the profile is a WCAG Level A profile.
|
|
111
111
|
*/
|
|
112
112
|
get isWCAGLevelA() {
|
|
113
|
-
return this ===
|
|
113
|
+
return this === y.EPUB_A11Y_10_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_20_A || this === y.EPUB_A11Y_11_WCAG_21_A || this === y.EPUB_A11Y_11_WCAG_22_A;
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Returns true if the profile is a WCAG Level AA profile.
|
|
117
117
|
*/
|
|
118
118
|
get isWCAGLevelAA() {
|
|
119
|
-
return this ===
|
|
119
|
+
return this === y.EPUB_A11Y_10_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_20_AA || this === y.EPUB_A11Y_11_WCAG_21_AA || this === y.EPUB_A11Y_11_WCAG_22_AA;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Returns true if the profile is a WCAG Level AAA profile.
|
|
123
123
|
*/
|
|
124
124
|
get isWCAGLevelAAA() {
|
|
125
|
-
return this ===
|
|
125
|
+
return this === y.EPUB_A11Y_10_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_20_AAA || this === y.EPUB_A11Y_11_WCAG_21_AAA || this === y.EPUB_A11Y_11_WCAG_22_AAA;
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
|
|
129
|
-
let
|
|
130
|
-
const
|
|
128
|
+
y.EPUB_A11Y_10_WCAG_20_A = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a"), y.EPUB_A11Y_10_WCAG_20_AA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"), y.EPUB_A11Y_10_WCAG_20_AAA = new y("http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"), y.EPUB_A11Y_11_WCAG_20_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"), y.EPUB_A11Y_11_WCAG_20_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"), y.EPUB_A11Y_11_WCAG_20_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"), y.EPUB_A11Y_11_WCAG_21_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"), y.EPUB_A11Y_11_WCAG_21_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"), y.EPUB_A11Y_11_WCAG_21_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"), y.EPUB_A11Y_11_WCAG_22_A = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"), y.EPUB_A11Y_11_WCAG_22_AA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"), y.EPUB_A11Y_11_WCAG_22_AAA = new y("https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa");
|
|
129
|
+
let Vt = y;
|
|
130
|
+
const v = class v {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.value = t;
|
|
133
133
|
}
|
|
@@ -136,7 +136,7 @@ const w = class w {
|
|
|
136
136
|
*/
|
|
137
137
|
static deserialize(t) {
|
|
138
138
|
if (!(!t || typeof t != "string"))
|
|
139
|
-
return new
|
|
139
|
+
return new v(t);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Serializes an [AccessMode] to its RWPM JSON representation.
|
|
@@ -145,8 +145,8 @@ const w = class w {
|
|
|
145
145
|
return this.value;
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
-
|
|
149
|
-
let
|
|
148
|
+
v.AUDITORY = new v("auditory"), v.CHART_ON_VISUAL = new v("chartOnVisual"), v.CHEM_ON_VISUAL = new v("chemOnVisual"), v.COLOR_DEPENDENT = new v("colorDependent"), v.DIAGRAM_ON_VISUAL = new v("diagramOnVisual"), v.MATH_ON_VISUAL = new v("mathOnVisual"), v.MUSIC_ON_VISUAL = new v("musicOnVisual"), v.TACTILE = new v("tactile"), v.TEXT_ON_VISUAL = new v("textOnVisual"), v.TEXTUAL = new v("textual"), v.VISUAL = new v("visual");
|
|
149
|
+
let Gt = v;
|
|
150
150
|
const T = class T {
|
|
151
151
|
constructor(t) {
|
|
152
152
|
if (typeof t == "string") {
|
|
@@ -182,7 +182,7 @@ const T = class T {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
T.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), T.AUDITORY = new T("auditory"), T.TACTILE = new T("tactile"), T.TEXTUAL = new T("textual"), T.VISUAL = new T("visual");
|
|
185
|
-
let
|
|
185
|
+
let Ft = T;
|
|
186
186
|
const c = class c {
|
|
187
187
|
constructor(t) {
|
|
188
188
|
this.value = t;
|
|
@@ -202,8 +202,8 @@ const c = class c {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
c.NONE = new c("none"), c.ANNOTATIONS = new c("annotations"), c.ARIA = new c("ARIA"), c.INDEX = new c("index"), c.PAGE_BREAK_MARKERS = new c("pageBreakMarkers"), c.PAGE_NAVIGATION = new c("pageNavigation"), c.PRINT_PAGE_NUMBERS = new c("printPageNumbers"), c.READING_ORDER = new c("readingOrder"), c.STRUCTURAL_NAVIGATION = new c("structuralNavigation"), c.TABLE_OF_CONTENTS = new c("tableOfContents"), c.TAGGED_PDF = new c("taggedPDF"), c.ALTERNATIVE_TEXT = new c("alternativeText"), c.AUDIO_DESCRIPTION = new c("audioDescription"), c.CAPTIONS = new c("captions"), c.CLOSED_CAPTIONS = new c("closedCaptions"), c.DESCRIBED_MATH = new c("describedMath"), c.LONG_DESCRIPTION = new c("longDescription"), c.OPEN_CAPTIONS = new c("openCaptions"), c.SIGN_LANGUAGE = new c("signLanguage"), c.TRANSCRIPT = new c("transcript"), c.DISPLAY_TRANSFORMABILITY = new c("displayTransformability"), c.SYNCHRONIZED_AUDIO_TEXT = new c("synchronizedAudioText"), c.TIMING_CONTROL = new c("timingControl"), c.UNLOCKED = new c("unlocked"), c.CHEM_ML = new c("ChemML"), c.LATEX = new c("latex"), c.LATEX_CHEMISTRY = new c("latex-chemistry"), c.MATH_ML = new c("MathML"), c.MATH_ML_CHEMISTRY = new c("MathML-chemistry"), c.TTS_MARKUP = new c("ttsMarkup"), c.HIGH_CONTRAST_AUDIO = new c("highContrastAudio"), c.HIGH_CONTRAST_DISPLAY = new c("highContrastDisplay"), c.LARGE_PRINT = new c("largePrint"), c.BRAILLE = new c("braille"), c.TACTILE_GRAPHIC = new c("tactileGraphic"), c.TACTILE_OBJECT = new c("tactileObject"), c.FULL_RUBY_ANNOTATIONS = new c("fullRubyAnnotations"), c.HORIZONTAL_WRITING = new c("horizontalWriting"), c.RUBY_ANNOTATIONS = new c("rubyAnnotations"), c.VERTICAL_WRITING = new c("verticalWriting"), c.WITH_ADDITIONAL_WORD_SEGMENTATION = new c("withAdditionalWordSegmentation"), c.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new c("withoutAdditionalWordSegmentation");
|
|
205
|
-
let
|
|
206
|
-
const
|
|
205
|
+
let $t = c;
|
|
206
|
+
const S = class S {
|
|
207
207
|
constructor(t) {
|
|
208
208
|
this.value = t;
|
|
209
209
|
}
|
|
@@ -212,7 +212,7 @@ const A = class A {
|
|
|
212
212
|
*/
|
|
213
213
|
static deserialize(t) {
|
|
214
214
|
if (!(!t || typeof t != "string"))
|
|
215
|
-
return new
|
|
215
|
+
return new S(t);
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* Serializes a [Hazard] to its RWPM JSON representation.
|
|
@@ -221,8 +221,8 @@ const A = class A {
|
|
|
221
221
|
return this.value;
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
|
-
|
|
225
|
-
let
|
|
224
|
+
S.FLASHING = new S("flashing"), S.NO_FLASHING_HAZARD = new S("noFlashingHazard"), S.UNKNOWN_FLASHING_HAZARD = new S("unknownFlashingHazard"), S.MOTION_SIMULATION = new S("motionSimulation"), S.NO_MOTION_SIMULATION_HAZARD = new S("noMotionSimulationHazard"), S.UNKNOWN_MOTION_SIMULATION_HAZARD = new S("unknownMotionSimulationHazard"), S.SOUND = new S("sound"), S.NO_SOUND_HAZARD = new S("noSoundHazard"), S.UNKNOWN_SOUND_HAZARD = new S("unknownSoundHazard"), S.UNKNOWN = new S("unknown"), S.NONE = new S("none");
|
|
225
|
+
let Yt = S;
|
|
226
226
|
const E = class E {
|
|
227
227
|
constructor(t) {
|
|
228
228
|
this.value = t;
|
|
@@ -242,10 +242,10 @@ const E = class E {
|
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
E.NONE = new E("none"), E.DOCUMENTED = new E("documented"), E.LEGAL = new E("legal"), E.TEMPORARY = new E("temporary"), E.TECHNICAL = new E("technical"), E.EAA_DISPROPORTIONATE_BURDEN = new E("eaa-disproportionate-burden"), E.EAA_FUNDAMENTAL_ALTERATION = new E("eaa-fundamental-alteration"), E.EAA_MICROENTERPRISE = new E("eaa-microenterprise"), E.EAA_TECHNICAL_IMPOSSIBILITY = new E("eaa-technical-impossibility"), E.EAA_TEMPORARY = new E("eaa-temporary");
|
|
245
|
-
let
|
|
246
|
-
const Vt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Pe = /* @__PURE__ */ JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`), Le = {
|
|
247
|
-
publication:
|
|
248
|
-
},
|
|
245
|
+
let Xt = E;
|
|
246
|
+
const qt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], ke = /* @__PURE__ */ JSON.parse(`{"format":{"audiobook":"Audiobook","audiobookJSON":"Audiobook Manifest","cbz":"Comic Book Archive","divina":"Divina Publication","divinaJSON":"Divina Publication Manifest","epub":"EPUB","lcpa":"LCP Protected Audiobook","lcpdf":"LCP Protected PDF","lcpl":"LCP License Document","pdf":"PDF","rwp":"Readium Web Publication","rwpm":"Readium Web Publication Manifest","zab":"Audiobook Archive","zip":"ZIP Archive"},"kind":{"audiobook_one":"audiobook","audiobook_other":"audiobooks","book_one":"book","book_other":"books","comic_one":"comic","comic_other":"comics","document_one":"document","document_other":"documents"},"metadata":{"accessibility":{"display-guide":{"accessibility-summary":{"no-metadata":"No information is available","publisher-contact":"For more information about the accessibility of this product, please contact the publisher: ","title":"Accessibility summary"},"additional-accessibility-information":{"aria":{"compact":"ARIA roles included","descriptive":"Content is enhanced with ARIA roles to optimize organization and facilitate navigation"},"audio-descriptions":"Audio descriptions","braille":"Braille","color-not-sole-means-of-conveying-information":"Color is not the sole means of conveying information","dyslexia-readability":"Dyslexia readability","full-ruby-annotations":"Full ruby annotations","high-contrast-between-foreground-and-background-audio":"High contrast between foreground and background audio","high-contrast-between-text-and-background":"High contrast between foreground text and background","large-print":"Large print","page-breaks":{"compact":"Page breaks included","descriptive":"Page breaks included from the original print source"},"ruby-annotations":"Some Ruby annotations","sign-language":"Sign language","tactile-graphics":{"compact":"Tactile graphics included","descriptive":"Tactile graphics have been integrated to facilitate access to visual elements for blind people"},"tactile-objects":"Tactile 3D objects","text-to-speech-hinting":"Text-to-speech hinting provided","title":"Additional accessibility information","ultra-high-contrast-between-text-and-background":"Ultra high contrast between text and background","visible-page-numbering":"Visible page numbering","without-background-sounds":"Without background sounds"},"conformance":{"a":{"compact":"This publication meets minimum accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level A standard"},"aa":{"compact":"This publication meets accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AA standard"},"aaa":{"compact":"This publication exceeds accepted accessibility standards","descriptive":"The publication contains a conformance statement that it meets the EPUB Accessibility and WCAG 2 Level AAA standard"},"certifier":"The publication was certified by ","certifier-credentials":"The certifier's credential is ","details":{"certification-info":"The publication was certified on ","certifier-report":"For more information refer to the certifier's report","claim":"This publication claims to meet","epub-accessibility-1-0":"EPUB Accessibility 1.0","epub-accessibility-1-1":"EPUB Accessibility 1.1","level-a":"Level A","level-aa":"Level AA","level-aaa":"Level AAA","wcag-2-0":{"compact":"WCAG 2.0","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.0"},"wcag-2-1":{"compact":"WCAG 2.1","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.1"},"wcag-2-2":{"compact":"WCAG 2.2","descriptive":"Web Content Accessibility Guidelines (WCAG) 2.2"}},"details-title":"Detailed conformance information","no":"No information is available","title":"Conformance","unknown-standard":"Conformance to accepted standards for accessibility of this publication cannot be determined"},"hazards":{"flashing":{"compact":"Flashing content","descriptive":"The publication contains flashing content that can cause photosensitive seizures"},"flashing-none":{"compact":"No flashing hazards","descriptive":"The publication does not contain flashing content that can cause photosensitive seizures"},"flashing-unknown":{"compact":"Flashing hazards not known","descriptive":"The presence of flashing content that can cause photosensitive seizures could not be determined"},"motion":{"compact":"Motion simulation","descriptive":"The publication contains motion simulations that can cause motion sickness"},"motion-none":{"compact":"No motion simulation hazards","descriptive":"The publication does not contain motion simulations that can cause motion sickness"},"motion-unknown":{"compact":"Motion simulation hazards not known","descriptive":"The presence of motion simulations that can cause motion sickness could not be determined"},"no-metadata":"No information is available","none":{"compact":"No hazards","descriptive":"The publication contains no hazards"},"sound":{"compact":"Sounds","descriptive":"The publication contains sounds that can cause sensitivity issues"},"sound-none":{"compact":"No sound hazards","descriptive":"The publication does not contain sounds that can cause sensitivity issues"},"sound-unknown":{"compact":"Sound hazards not known","descriptive":"The presence of sounds that can cause sensitivity issues could not be determined"},"title":"Hazards","unknown":"The presence of hazards is unknown"},"legal-considerations":{"exempt":{"compact":"Claims an accessibility exemption in some jurisdictions","descriptive":"This publication claims an accessibility exemption in some jurisdictions"},"no-metadata":"No information is available","title":"Legal considerations"},"navigation":{"index":{"compact":"Index","descriptive":"Index with links to referenced entries"},"no-metadata":"No information is available","page-navigation":{"compact":"Go to page","descriptive":"Page list to go to pages from the print source version"},"structural":{"compact":"Headings","descriptive":"Elements such as headings, tables, etc for structured navigation"},"title":"Navigation","toc":{"compact":"Table of contents","descriptive":"Table of contents to all chapters of the text via links"}},"rich-content":{"accessible-chemistry-as-latex":{"compact":"Chemical formulas in LaTeX","descriptive":"Chemical formulas in accessible format (LaTeX)"},"accessible-chemistry-as-mathml":{"compact":"Chemical formulas in MathML","descriptive":"Chemical formulas in accessible format (MathML)"},"accessible-math-as-latex":{"compact":"Math as LaTeX","descriptive":"Math formulas in accessible format (LaTeX)"},"accessible-math-described":"Text descriptions of math are provided","closed-captions":{"compact":"Videos have closed captions","descriptive":"Videos included in publications have closed captions"},"extended-descriptions":"Information-rich images are described by extended descriptions","math-as-mathml":{"compact":"Math as MathML","descriptive":"Math formulas in accessible format (MathML)"},"open-captions":{"compact":"Videos have open captions","descriptive":"Videos included in publications have open captions"},"title":"Rich content","transcript":"Transcript(s) provided","unknown":"No information is available"},"ways-of-reading":{"nonvisual-reading":{"alt-text":{"compact":"Has alternative text","descriptive":"Has alternative text descriptions for images"},"no-metadata":"No information about nonvisual reading is available","none":{"compact":"Not readable in read aloud or dynamic braille","descriptive":"The content is not readable as read aloud speech or dynamic braille"},"not-fully":{"compact":"Not fully readable in read aloud or dynamic braille","descriptive":"Not all of the content will be readable as read aloud speech or dynamic braille"},"readable":{"compact":"Readable in read aloud or dynamic braille","descriptive":"All content can be read as read aloud speech or dynamic braille"}},"prerecorded-audio":{"complementary":{"compact":"Prerecorded audio clips","descriptive":"Prerecorded audio clips are embedded in the content"},"no-metadata":"No information about prerecorded audio is available","only":{"compact":"Prerecorded audio only","descriptive":"Audiobook with no text alternative"},"synchronized":{"compact":"Prerecorded audio synchronized with text","descriptive":"All the content is available as prerecorded audio synchronized with text"}},"title":"Ways of reading","visual-adjustments":{"modifiable":{"compact":"Appearance can be modified","descriptive":"Appearance of the text and page layout can be modified according to the capabilities of the reading system (font family and font size, spaces between paragraphs, sentences, words, and letters, as well as color of background and text)"},"unknown":"No information about appearance modifiability is available","unmodifiable":{"compact":"Appearance cannot be modified","descriptive":"Text and page layout cannot be modified as the reading experience is close to a print version, but reading systems can still provide zooming options"}}}}},"altIdentifier_one":"alternate identifier","altIdentifier_other":"alternate identifiers","artist_one":"artist","artist_other":"artists","author_one":"author","author_other":"authors","collection_one":"editorial collection","collection_other":"editorial collections","colorist_one":"colorist","colorist_other":"colorists","contributor_one":"contributor","contributor_other":"contributors","description":"description","duration":"duration","editor_one":"editor","editor_other":"editors","identifier_one":"identifier","identifier_other":"identifiers","illustrator_one":"illustrator","illustrator_other":"illustrators","imprint_one":"imprint","imprint_other":"imprints","inker_one":"inker","inker_other":"inkers","language_one":"language","language_other":"languages","letterer_one":"letterer","letterer_other":"letterers","modified":"modification date","narrator_one":"narrator","narrator_other":"narrators","numberOfPages":"print length","penciler_one":"penciler","penciler_other":"pencilers","published":"publication date","publisher_one":"publisher","publisher_other":"publishers","series_one":"series","series_other":"series","subject_one":"subject","subject_other":"subjects","subtitle":"subtitle","title":"title","translator_one":"translator","translator_other":"translators"}}`), We = {
|
|
247
|
+
publication: ke
|
|
248
|
+
}, Kt = {
|
|
249
249
|
fr: () => import("./fr-C5HEel98.js"),
|
|
250
250
|
ar: () => import("./ar-DyHX_uy2.js"),
|
|
251
251
|
da: () => import("./da-Dct0PS3E.js"),
|
|
@@ -256,10 +256,10 @@ const Vt = ["en", "ar", "da", "fr", "it", "pt_PT", "sv"], Pe = /* @__PURE__ */ J
|
|
|
256
256
|
sv: () => import("./sv-BfzAFsVN.js")
|
|
257
257
|
// 'tr': () => import('@edrlab/thorium-locales/publication-metadata/tr.json'),
|
|
258
258
|
// 'uk': () => import('@edrlab/thorium-locales/publication-metadata/uk.json')
|
|
259
|
-
},
|
|
259
|
+
}, Zt = We?.publication?.metadata?.accessibility?.["display-guide"] || {};
|
|
260
260
|
class F {
|
|
261
261
|
constructor() {
|
|
262
|
-
this.currentLocaleCode = "en", this.locale =
|
|
262
|
+
this.currentLocaleCode = "en", this.locale = Zt, this.loadedLocales = {}, this.loadedLocales.en = Zt;
|
|
263
263
|
}
|
|
264
264
|
static getInstance() {
|
|
265
265
|
return F.instance || (F.instance = new F()), F.instance;
|
|
@@ -270,14 +270,14 @@ class F {
|
|
|
270
270
|
* @returns Promise indicating if the locale was loaded successfully
|
|
271
271
|
*/
|
|
272
272
|
async loadLocale(t) {
|
|
273
|
-
if (!
|
|
273
|
+
if (!qt.includes(t))
|
|
274
274
|
return console.warn(`Locale '${t}' is not enabled`), !1;
|
|
275
275
|
if (t in this.loadedLocales)
|
|
276
276
|
return !0;
|
|
277
277
|
try {
|
|
278
|
-
if (!(t in
|
|
278
|
+
if (!(t in Kt))
|
|
279
279
|
return console.warn(`Locale file not found for: ${t}`), !1;
|
|
280
|
-
const s = (await
|
|
280
|
+
const s = (await Kt[t]()).default?.publication?.metadata?.accessibility?.["display-guide"];
|
|
281
281
|
return s ? (this.loadedLocales[t] = s, !0) : (console.warn(`No accessibility strings found in locale ${t}`), !1);
|
|
282
282
|
} catch (e) {
|
|
283
283
|
return console.warn(`Failed to load locale ${t}:`, e), !1;
|
|
@@ -311,7 +311,7 @@ class F {
|
|
|
311
311
|
* Gets a list of available locale codes
|
|
312
312
|
*/
|
|
313
313
|
getAvailableLocales() {
|
|
314
|
-
return
|
|
314
|
+
return qt;
|
|
315
315
|
}
|
|
316
316
|
getNestedValue(t, e) {
|
|
317
317
|
const i = e.split(".");
|
|
@@ -334,7 +334,7 @@ class F {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
F.getInstance();
|
|
337
|
-
class
|
|
337
|
+
class It {
|
|
338
338
|
/**
|
|
339
339
|
* Creates a [Encryption].
|
|
340
340
|
*/
|
|
@@ -346,7 +346,7 @@ class Nt {
|
|
|
346
346
|
*/
|
|
347
347
|
static deserialize(t) {
|
|
348
348
|
if (t && t.algorithm)
|
|
349
|
-
return new
|
|
349
|
+
return new It({
|
|
350
350
|
algorithm: t.algorithm,
|
|
351
351
|
compression: t.compression,
|
|
352
352
|
originalLength: t.originalLength,
|
|
@@ -362,7 +362,7 @@ class Nt {
|
|
|
362
362
|
return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
class
|
|
365
|
+
class R {
|
|
366
366
|
constructor(t) {
|
|
367
367
|
this.otherProperties = t;
|
|
368
368
|
}
|
|
@@ -374,7 +374,7 @@ class I {
|
|
|
374
374
|
*/
|
|
375
375
|
static deserialize(t) {
|
|
376
376
|
if (t)
|
|
377
|
-
return new
|
|
377
|
+
return new R(t);
|
|
378
378
|
}
|
|
379
379
|
/**
|
|
380
380
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -389,30 +389,30 @@ class I {
|
|
|
389
389
|
const e = Object.assign({}, this.otherProperties);
|
|
390
390
|
for (const i in t)
|
|
391
391
|
e[i] = t[i];
|
|
392
|
-
return new
|
|
392
|
+
return new R(e);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
Object.defineProperty(
|
|
395
|
+
Object.defineProperty(R.prototype, "encryption", {
|
|
396
396
|
get: function() {
|
|
397
|
-
return
|
|
397
|
+
return It.deserialize(this.otherProperties.encrypted);
|
|
398
398
|
}
|
|
399
399
|
});
|
|
400
|
-
function
|
|
400
|
+
function Ue(r) {
|
|
401
401
|
return r && Array.isArray(r) ? r : void 0;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return r && typeof r == "string" ? [r] :
|
|
403
|
+
function be(r) {
|
|
404
|
+
return r && typeof r == "string" ? [r] : Ue(r);
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function Jt(r) {
|
|
407
407
|
return typeof r == "string" ? new Date(r) : void 0;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function at(r) {
|
|
410
410
|
return isNaN(r) ? void 0 : r;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
return
|
|
412
|
+
function O(r) {
|
|
413
|
+
return at(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function Be(r) {
|
|
416
416
|
const t = new Array();
|
|
417
417
|
return r.forEach((e) => t.push(e)), t;
|
|
418
418
|
}
|
|
@@ -427,19 +427,19 @@ class l {
|
|
|
427
427
|
} else
|
|
428
428
|
throw new Error("Invalid media type");
|
|
429
429
|
const o = {};
|
|
430
|
-
for (let
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
const f =
|
|
434
|
-
o[f] =
|
|
430
|
+
for (let m = 1; m < s.length; m++) {
|
|
431
|
+
const w = s[m].split("=");
|
|
432
|
+
if (w.length === 2) {
|
|
433
|
+
const f = w[0].toLocaleLowerCase(), p = f === "charset" ? w[1].toUpperCase() : w[1];
|
|
434
|
+
o[f] = p;
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
const a = {}, d = Object.keys(o);
|
|
438
|
-
d.sort((
|
|
438
|
+
d.sort((m, w) => m.localeCompare(w)), d.forEach((m) => a[m] = o[m]);
|
|
439
439
|
let h = "";
|
|
440
|
-
for (const
|
|
441
|
-
const
|
|
442
|
-
h += `;${
|
|
440
|
+
for (const m in a) {
|
|
441
|
+
const w = a[m];
|
|
442
|
+
h += `;${m}=${w}`;
|
|
443
443
|
}
|
|
444
444
|
const u = `${e}/${i}${h}`, g = a.encoding;
|
|
445
445
|
this.string = u, this.type = e, this.subtype = i, this.parameters = a, this.encoding = g, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
@@ -871,7 +871,7 @@ class l {
|
|
|
871
871
|
});
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
|
-
class
|
|
874
|
+
class Qt {
|
|
875
875
|
constructor(t) {
|
|
876
876
|
this.uri = t, this.parameters = this.getParameters(t);
|
|
877
877
|
}
|
|
@@ -899,7 +899,7 @@ class qt {
|
|
|
899
899
|
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? i(s[2]) : e(s[2]));
|
|
900
900
|
}
|
|
901
901
|
}
|
|
902
|
-
class
|
|
902
|
+
class A {
|
|
903
903
|
/**
|
|
904
904
|
* Creates a [Locations].
|
|
905
905
|
*/
|
|
@@ -911,7 +911,7 @@ class x {
|
|
|
911
911
|
*/
|
|
912
912
|
static deserialize(t) {
|
|
913
913
|
if (!t) return;
|
|
914
|
-
const e =
|
|
914
|
+
const e = at(t.progression), i = at(t.totalProgression), s = at(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
915
915
|
"fragment",
|
|
916
916
|
"fragments",
|
|
917
917
|
"progression",
|
|
@@ -920,8 +920,8 @@ class x {
|
|
|
920
920
|
]);
|
|
921
921
|
return Object.entries(t).forEach(([a, d]) => {
|
|
922
922
|
o.has(a) || n.set(a, d);
|
|
923
|
-
}), new
|
|
924
|
-
fragments:
|
|
923
|
+
}), new A({
|
|
924
|
+
fragments: be(t.fragments || t.fragment),
|
|
925
925
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
926
926
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
927
927
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
@@ -936,7 +936,7 @@ class x {
|
|
|
936
936
|
return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
|
-
class
|
|
939
|
+
class _ {
|
|
940
940
|
/**
|
|
941
941
|
* Creates a [Text].
|
|
942
942
|
*/
|
|
@@ -948,7 +948,7 @@ class H {
|
|
|
948
948
|
*/
|
|
949
949
|
static deserialize(t) {
|
|
950
950
|
if (t)
|
|
951
|
-
return new
|
|
951
|
+
return new _({
|
|
952
952
|
after: t.after,
|
|
953
953
|
before: t.before,
|
|
954
954
|
highlight: t.highlight
|
|
@@ -962,24 +962,24 @@ class H {
|
|
|
962
962
|
return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
class
|
|
965
|
+
class W {
|
|
966
966
|
/**
|
|
967
967
|
* Creates a [Locator].
|
|
968
968
|
*/
|
|
969
969
|
constructor(t) {
|
|
970
|
-
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new
|
|
970
|
+
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new A({}), this.text = t.text;
|
|
971
971
|
}
|
|
972
972
|
/**
|
|
973
973
|
* Parses a [Link] from its RWPM JSON representation.
|
|
974
974
|
*/
|
|
975
975
|
static deserialize(t) {
|
|
976
976
|
if (t && t.href && t.type)
|
|
977
|
-
return new
|
|
977
|
+
return new W({
|
|
978
978
|
href: t.href,
|
|
979
979
|
type: t.type,
|
|
980
980
|
title: t.title,
|
|
981
|
-
locations:
|
|
982
|
-
text:
|
|
981
|
+
locations: A.deserialize(t.locations),
|
|
982
|
+
text: _.deserialize(t.text)
|
|
983
983
|
});
|
|
984
984
|
}
|
|
985
985
|
/**
|
|
@@ -993,16 +993,16 @@ class U {
|
|
|
993
993
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
994
994
|
*/
|
|
995
995
|
copyWithLocations(t) {
|
|
996
|
-
return new
|
|
996
|
+
return new W({
|
|
997
997
|
href: this.href,
|
|
998
998
|
type: this.type,
|
|
999
999
|
title: this.title,
|
|
1000
1000
|
text: this.text,
|
|
1001
|
-
locations: new
|
|
1001
|
+
locations: new A({ ...this.locations, ...t })
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
|
-
class
|
|
1005
|
+
class Y {
|
|
1006
1006
|
/**
|
|
1007
1007
|
* Creates a [Link].
|
|
1008
1008
|
*/
|
|
@@ -1014,21 +1014,21 @@ class $ {
|
|
|
1014
1014
|
*/
|
|
1015
1015
|
static deserialize(t) {
|
|
1016
1016
|
if (!(!t || typeof t.href != "string"))
|
|
1017
|
-
return new
|
|
1017
|
+
return new Y({
|
|
1018
1018
|
href: t.href,
|
|
1019
1019
|
templated: t.templated,
|
|
1020
1020
|
type: t.type,
|
|
1021
1021
|
title: t.title,
|
|
1022
1022
|
rels: t.rel ? Array.isArray(t.rel) ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
1023
|
-
properties:
|
|
1024
|
-
height:
|
|
1025
|
-
width:
|
|
1026
|
-
size:
|
|
1027
|
-
duration:
|
|
1028
|
-
bitrate:
|
|
1029
|
-
languages:
|
|
1030
|
-
alternates:
|
|
1031
|
-
children:
|
|
1023
|
+
properties: R.deserialize(t.properties),
|
|
1024
|
+
height: O(t.height),
|
|
1025
|
+
width: O(t.width),
|
|
1026
|
+
size: O(t.size),
|
|
1027
|
+
duration: O(t.duration),
|
|
1028
|
+
bitrate: O(t.bitrate),
|
|
1029
|
+
languages: be(t.language),
|
|
1030
|
+
alternates: lt.deserialize(t.alternate),
|
|
1031
|
+
children: lt.deserialize(t.children)
|
|
1032
1032
|
});
|
|
1033
1033
|
}
|
|
1034
1034
|
/**
|
|
@@ -1036,7 +1036,7 @@ class $ {
|
|
|
1036
1036
|
*/
|
|
1037
1037
|
serialize() {
|
|
1038
1038
|
const t = { href: this.href };
|
|
1039
|
-
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel =
|
|
1039
|
+
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = Be(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
|
|
1040
1040
|
}
|
|
1041
1041
|
/** MediaType of the linked resource. */
|
|
1042
1042
|
get mediaType() {
|
|
@@ -1053,14 +1053,14 @@ class $ {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
1055
1055
|
get templateParameters() {
|
|
1056
|
-
return this.templated ? new
|
|
1056
|
+
return this.templated ? new Qt(this.href).parameters : /* @__PURE__ */ new Set();
|
|
1057
1057
|
}
|
|
1058
1058
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
1059
1059
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
1060
1060
|
*/
|
|
1061
1061
|
expandTemplate(t) {
|
|
1062
|
-
return new
|
|
1063
|
-
href: new
|
|
1062
|
+
return new Y({
|
|
1063
|
+
href: new Qt(this.href).expand(t),
|
|
1064
1064
|
templated: !1
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
@@ -1068,25 +1068,25 @@ class $ {
|
|
|
1068
1068
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
1069
1069
|
*/
|
|
1070
1070
|
addProperties(t) {
|
|
1071
|
-
const e =
|
|
1072
|
-
return e.properties = e.properties ? e.properties?.add(t) : new
|
|
1071
|
+
const e = Y.deserialize(this.serialize());
|
|
1072
|
+
return e.properties = e.properties ? e.properties?.add(t) : new R(t), e;
|
|
1073
1073
|
}
|
|
1074
1074
|
/**
|
|
1075
1075
|
* Creates a [Locator] from a reading order [Link].
|
|
1076
1076
|
*/
|
|
1077
1077
|
get locator() {
|
|
1078
1078
|
let t = this.href.split("#");
|
|
1079
|
-
return new
|
|
1079
|
+
return new W({
|
|
1080
1080
|
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
1081
1081
|
type: this.type ?? "",
|
|
1082
1082
|
title: this.title,
|
|
1083
|
-
locations: new
|
|
1083
|
+
locations: new A({
|
|
1084
1084
|
fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
|
|
1085
1085
|
})
|
|
1086
1086
|
});
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
|
-
class
|
|
1089
|
+
class lt {
|
|
1090
1090
|
/**
|
|
1091
1091
|
* Creates a [Links].
|
|
1092
1092
|
*/
|
|
@@ -1098,8 +1098,8 @@ class nt {
|
|
|
1098
1098
|
*/
|
|
1099
1099
|
static deserialize(t) {
|
|
1100
1100
|
if (t && Array.isArray(t))
|
|
1101
|
-
return new
|
|
1102
|
-
t.map((e) =>
|
|
1101
|
+
return new lt(
|
|
1102
|
+
t.map((e) => Y.deserialize(e)).filter((e) => e !== void 0)
|
|
1103
1103
|
);
|
|
1104
1104
|
}
|
|
1105
1105
|
/**
|
|
@@ -1180,10 +1180,10 @@ class nt {
|
|
|
1180
1180
|
return this.items.filter((t) => t.type);
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
|
-
|
|
1183
|
+
R.prototype.getContains = function() {
|
|
1184
1184
|
return new Set(this.otherProperties.contains || []);
|
|
1185
1185
|
};
|
|
1186
|
-
class
|
|
1186
|
+
class ct {
|
|
1187
1187
|
/**
|
|
1188
1188
|
* Creates a [DomRange].
|
|
1189
1189
|
*/
|
|
@@ -1195,10 +1195,10 @@ class ot {
|
|
|
1195
1195
|
*/
|
|
1196
1196
|
static deserialize(t) {
|
|
1197
1197
|
if (!(t && t.cssSelector)) return;
|
|
1198
|
-
let e =
|
|
1198
|
+
let e = O(t.textNodeIndex);
|
|
1199
1199
|
if (e === void 0) return;
|
|
1200
|
-
let i =
|
|
1201
|
-
return i === void 0 && (i =
|
|
1200
|
+
let i = O(t.charOffset);
|
|
1201
|
+
return i === void 0 && (i = O(t.offset)), new ct({
|
|
1202
1202
|
cssSelector: t.cssSelector,
|
|
1203
1203
|
textNodeIndex: e,
|
|
1204
1204
|
charOffset: i
|
|
@@ -1215,7 +1215,7 @@ class ot {
|
|
|
1215
1215
|
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
|
-
class
|
|
1218
|
+
class Dt {
|
|
1219
1219
|
/**
|
|
1220
1220
|
* Creates a [DomRange].
|
|
1221
1221
|
*/
|
|
@@ -1227,11 +1227,11 @@ class Ot {
|
|
|
1227
1227
|
*/
|
|
1228
1228
|
static deserialize(t) {
|
|
1229
1229
|
if (!t) return;
|
|
1230
|
-
let e =
|
|
1230
|
+
let e = ct.deserialize(t.start);
|
|
1231
1231
|
if (e)
|
|
1232
|
-
return new
|
|
1232
|
+
return new Dt({
|
|
1233
1233
|
start: e,
|
|
1234
|
-
end:
|
|
1234
|
+
end: ct.deserialize(t.end)
|
|
1235
1235
|
});
|
|
1236
1236
|
}
|
|
1237
1237
|
/**
|
|
@@ -1242,16 +1242,16 @@ class Ot {
|
|
|
1242
1242
|
return this.end && (t.end = this.end.serialize()), t;
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
1245
|
-
|
|
1245
|
+
A.prototype.getCssSelector = function() {
|
|
1246
1246
|
return this.otherLocations?.get("cssSelector");
|
|
1247
1247
|
};
|
|
1248
|
-
|
|
1248
|
+
A.prototype.getPartialCfi = function() {
|
|
1249
1249
|
return this.otherLocations?.get("partialCfi");
|
|
1250
1250
|
};
|
|
1251
|
-
|
|
1252
|
-
return
|
|
1251
|
+
A.prototype.getDomRange = function() {
|
|
1252
|
+
return Dt.deserialize(this.otherLocations?.get("domRange"));
|
|
1253
1253
|
};
|
|
1254
|
-
|
|
1254
|
+
A.prototype.fragmentParameters = function() {
|
|
1255
1255
|
return new Map(
|
|
1256
1256
|
this.fragments.map((r) => r.startsWith("#") ? r.slice(1) : r).join("&").split("&").filter((r) => !r.startsWith("#")).map((r) => r.split("=")).filter((r) => r.length === 2).map((r) => [
|
|
1257
1257
|
r[0].trim().toLowerCase(),
|
|
@@ -1259,7 +1259,7 @@ x.prototype.fragmentParameters = function() {
|
|
|
1259
1259
|
])
|
|
1260
1260
|
);
|
|
1261
1261
|
};
|
|
1262
|
-
|
|
1262
|
+
A.prototype.htmlId = function() {
|
|
1263
1263
|
if (!this.fragments.length) return;
|
|
1264
1264
|
let r = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1265
1265
|
if (!r) {
|
|
@@ -1268,22 +1268,26 @@ x.prototype.htmlId = function() {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
return r?.startsWith("#") ? r.slice(1) : r;
|
|
1270
1270
|
};
|
|
1271
|
-
|
|
1271
|
+
A.prototype.page = function() {
|
|
1272
1272
|
const r = parseInt(this.fragmentParameters().get("page"));
|
|
1273
1273
|
if (!isNaN(r) && r >= 0) return r;
|
|
1274
1274
|
};
|
|
1275
|
-
|
|
1275
|
+
A.prototype.time = function() {
|
|
1276
1276
|
const r = parseInt(this.fragmentParameters().get("t"));
|
|
1277
1277
|
if (!isNaN(r)) return r;
|
|
1278
1278
|
};
|
|
1279
|
-
|
|
1279
|
+
A.prototype.space = function() {
|
|
1280
1280
|
const r = this.fragmentParameters();
|
|
1281
1281
|
if (!r.has("xywh")) return;
|
|
1282
1282
|
const t = r.get("xywh").split(",").map((e) => parseInt(e));
|
|
1283
1283
|
if (t.length === 4 && !t.some(isNaN))
|
|
1284
1284
|
return t;
|
|
1285
1285
|
};
|
|
1286
|
-
|
|
1286
|
+
A.prototype.text = function() {
|
|
1287
|
+
const r = this.fragmentParameters();
|
|
1288
|
+
console.log(r);
|
|
1289
|
+
};
|
|
1290
|
+
class zt {
|
|
1287
1291
|
/** Creates a [Price]. */
|
|
1288
1292
|
constructor(t) {
|
|
1289
1293
|
this.currency = t.currency, this.value = t.value;
|
|
@@ -1296,9 +1300,9 @@ class Pt {
|
|
|
1296
1300
|
let e = t.currency;
|
|
1297
1301
|
if (!(e && typeof e == "string" && e.length > 0))
|
|
1298
1302
|
return;
|
|
1299
|
-
let i =
|
|
1303
|
+
let i = O(t.value);
|
|
1300
1304
|
if (i !== void 0)
|
|
1301
|
-
return new
|
|
1305
|
+
return new zt({ currency: e, value: i });
|
|
1302
1306
|
}
|
|
1303
1307
|
/**
|
|
1304
1308
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1307,7 +1311,7 @@ class Pt {
|
|
|
1307
1311
|
return { currency: this.currency, value: this.value };
|
|
1308
1312
|
}
|
|
1309
1313
|
}
|
|
1310
|
-
class
|
|
1314
|
+
class J {
|
|
1311
1315
|
/** Creates a [Acquisition]. */
|
|
1312
1316
|
constructor(t) {
|
|
1313
1317
|
this.type = t.type, this.children = t.children;
|
|
@@ -1317,14 +1321,14 @@ class X {
|
|
|
1317
1321
|
*/
|
|
1318
1322
|
static deserialize(t) {
|
|
1319
1323
|
if (t && t.type)
|
|
1320
|
-
return new
|
|
1324
|
+
return new J({
|
|
1321
1325
|
type: t.type,
|
|
1322
|
-
children:
|
|
1326
|
+
children: J.deserializeArray(t.children)
|
|
1323
1327
|
});
|
|
1324
1328
|
}
|
|
1325
1329
|
static deserializeArray(t) {
|
|
1326
1330
|
if (Array.isArray(t))
|
|
1327
|
-
return t.map((e) =>
|
|
1331
|
+
return t.map((e) => J.deserialize(e)).filter((e) => e !== void 0);
|
|
1328
1332
|
}
|
|
1329
1333
|
/**
|
|
1330
1334
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1334,7 +1338,7 @@ class X {
|
|
|
1334
1338
|
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1335
1339
|
}
|
|
1336
1340
|
}
|
|
1337
|
-
class
|
|
1341
|
+
class Mt {
|
|
1338
1342
|
/** Creates a [Price]. */
|
|
1339
1343
|
constructor(t) {
|
|
1340
1344
|
this.total = t.total, this.position = t.position;
|
|
@@ -1344,9 +1348,9 @@ class Lt {
|
|
|
1344
1348
|
*/
|
|
1345
1349
|
static deserialize(t) {
|
|
1346
1350
|
if (t)
|
|
1347
|
-
return new
|
|
1348
|
-
total:
|
|
1349
|
-
position:
|
|
1351
|
+
return new Mt({
|
|
1352
|
+
total: O(t.total),
|
|
1353
|
+
position: O(t.position)
|
|
1350
1354
|
});
|
|
1351
1355
|
}
|
|
1352
1356
|
/**
|
|
@@ -1357,7 +1361,7 @@ class Lt {
|
|
|
1357
1361
|
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1358
1362
|
}
|
|
1359
1363
|
}
|
|
1360
|
-
class
|
|
1364
|
+
class kt {
|
|
1361
1365
|
/** Creates a [Copies]. */
|
|
1362
1366
|
constructor(t) {
|
|
1363
1367
|
this.total = t.total, this.available = t.available;
|
|
@@ -1367,9 +1371,9 @@ class It {
|
|
|
1367
1371
|
*/
|
|
1368
1372
|
static deserialize(t) {
|
|
1369
1373
|
if (t)
|
|
1370
|
-
return new
|
|
1371
|
-
total:
|
|
1372
|
-
available:
|
|
1374
|
+
return new kt({
|
|
1375
|
+
total: O(t.total),
|
|
1376
|
+
available: O(t.available)
|
|
1373
1377
|
});
|
|
1374
1378
|
}
|
|
1375
1379
|
/**
|
|
@@ -1380,7 +1384,7 @@ class It {
|
|
|
1380
1384
|
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1381
1385
|
}
|
|
1382
1386
|
}
|
|
1383
|
-
class
|
|
1387
|
+
class Wt {
|
|
1384
1388
|
/** Creates a [Availability]. */
|
|
1385
1389
|
constructor(t) {
|
|
1386
1390
|
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
@@ -1390,10 +1394,10 @@ class Rt {
|
|
|
1390
1394
|
*/
|
|
1391
1395
|
static deserialize(t) {
|
|
1392
1396
|
if (t && t.state)
|
|
1393
|
-
return new
|
|
1397
|
+
return new Wt({
|
|
1394
1398
|
state: t.state,
|
|
1395
|
-
since:
|
|
1396
|
-
until:
|
|
1399
|
+
since: Jt(t.since),
|
|
1400
|
+
until: Jt(t.until)
|
|
1397
1401
|
});
|
|
1398
1402
|
}
|
|
1399
1403
|
/**
|
|
@@ -1404,89 +1408,89 @@ class Rt {
|
|
|
1404
1408
|
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
|
|
1405
1409
|
}
|
|
1406
1410
|
}
|
|
1407
|
-
|
|
1408
|
-
return
|
|
1411
|
+
R.prototype.getNumberOfItems = function() {
|
|
1412
|
+
return O(this.otherProperties.numberOfItems);
|
|
1409
1413
|
};
|
|
1410
|
-
|
|
1411
|
-
return
|
|
1414
|
+
R.prototype.getPrice = function() {
|
|
1415
|
+
return zt.deserialize(this.otherProperties.price);
|
|
1412
1416
|
};
|
|
1413
|
-
|
|
1417
|
+
R.prototype.getIndirectAcquisitions = function() {
|
|
1414
1418
|
const r = this.otherProperties.indirectAcquisition;
|
|
1415
1419
|
if (r && Array.isArray(r))
|
|
1416
|
-
return r.map((t) =>
|
|
1420
|
+
return r.map((t) => J.deserialize(t)).filter((t) => t !== void 0);
|
|
1417
1421
|
};
|
|
1418
|
-
|
|
1419
|
-
return
|
|
1422
|
+
R.prototype.getHolds = function() {
|
|
1423
|
+
return Mt.deserialize(this.otherProperties.holds);
|
|
1420
1424
|
};
|
|
1421
|
-
|
|
1422
|
-
return
|
|
1425
|
+
R.prototype.getCopies = function() {
|
|
1426
|
+
return kt.deserialize(this.otherProperties.copies);
|
|
1423
1427
|
};
|
|
1424
|
-
|
|
1425
|
-
return
|
|
1428
|
+
R.prototype.getAvailability = function() {
|
|
1429
|
+
return Wt.deserialize(this.otherProperties.availability);
|
|
1426
1430
|
};
|
|
1427
|
-
|
|
1428
|
-
return
|
|
1431
|
+
R.prototype.getAuthenticate = function() {
|
|
1432
|
+
return Y.deserialize(this.otherProperties.authenticate);
|
|
1429
1433
|
};
|
|
1430
|
-
const
|
|
1431
|
-
function
|
|
1432
|
-
console.warn(`${
|
|
1434
|
+
const He = "CssSelectorGenerator";
|
|
1435
|
+
function jt(r = "unknown problem", ...t) {
|
|
1436
|
+
console.warn(`${He}: ${r}`, ...t);
|
|
1433
1437
|
}
|
|
1434
|
-
function
|
|
1438
|
+
function _e(r) {
|
|
1435
1439
|
return r instanceof RegExp;
|
|
1436
1440
|
}
|
|
1437
|
-
function
|
|
1441
|
+
function Ve(r) {
|
|
1438
1442
|
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1439
1443
|
}
|
|
1440
|
-
function
|
|
1444
|
+
function Ge(r) {
|
|
1441
1445
|
const t = r.map((e) => {
|
|
1442
|
-
if (
|
|
1446
|
+
if (_e(e))
|
|
1443
1447
|
return (i) => e.test(i);
|
|
1444
1448
|
if (typeof e == "function")
|
|
1445
1449
|
return (i) => {
|
|
1446
1450
|
const s = e(i);
|
|
1447
|
-
return typeof s != "boolean" ? (
|
|
1451
|
+
return typeof s != "boolean" ? (jt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
1448
1452
|
};
|
|
1449
1453
|
if (typeof e == "string") {
|
|
1450
|
-
const i = new RegExp("^" +
|
|
1454
|
+
const i = new RegExp("^" + Ve(e) + "$");
|
|
1451
1455
|
return (s) => i.test(s);
|
|
1452
1456
|
}
|
|
1453
|
-
return
|
|
1457
|
+
return jt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1454
1458
|
});
|
|
1455
1459
|
return (e) => t.some((i) => i(e));
|
|
1456
1460
|
}
|
|
1457
|
-
|
|
1461
|
+
Ge([
|
|
1458
1462
|
"class",
|
|
1459
1463
|
"id",
|
|
1460
1464
|
// Angular attributes
|
|
1461
1465
|
"ng-*"
|
|
1462
1466
|
]);
|
|
1463
|
-
class
|
|
1467
|
+
class X {
|
|
1464
1468
|
}
|
|
1465
|
-
function
|
|
1469
|
+
function te(r) {
|
|
1466
1470
|
return r.split("").reverse().join("");
|
|
1467
1471
|
}
|
|
1468
|
-
function
|
|
1469
|
-
const i =
|
|
1472
|
+
function Fe(r, t, e) {
|
|
1473
|
+
const i = te(t);
|
|
1470
1474
|
return e.map((s) => {
|
|
1471
|
-
const n = Math.max(0, s.end - t.length - s.errors), o =
|
|
1475
|
+
const n = Math.max(0, s.end - t.length - s.errors), o = te(r.slice(n, s.end));
|
|
1472
1476
|
return {
|
|
1473
|
-
start:
|
|
1477
|
+
start: we(o, i, s.errors).reduce((d, h) => s.end - h.end < d ? s.end - h.end : d, s.end),
|
|
1474
1478
|
end: s.end,
|
|
1475
1479
|
errors: s.errors
|
|
1476
1480
|
};
|
|
1477
1481
|
});
|
|
1478
1482
|
}
|
|
1479
|
-
function
|
|
1483
|
+
function ft(r) {
|
|
1480
1484
|
return (r | -r) >> 31 & 1;
|
|
1481
1485
|
}
|
|
1482
|
-
function
|
|
1486
|
+
function ee(r, t, e, i) {
|
|
1483
1487
|
let s = r.P[e], n = r.M[e];
|
|
1484
1488
|
const o = i >>> 31, a = t[e] | o, d = a | n, h = (a & s) + s ^ s | a;
|
|
1485
1489
|
let u = n | ~(h | s), g = s & h;
|
|
1486
|
-
const
|
|
1487
|
-
return u <<= 1, g <<= 1, g |= o, u |=
|
|
1490
|
+
const m = ft(u & r.lastRowMask[e]) - ft(g & r.lastRowMask[e]);
|
|
1491
|
+
return u <<= 1, g <<= 1, g |= o, u |= ft(i) - o, s = g | ~(d | u), n = u & d, r.P[e] = s, r.M[e] = n, m;
|
|
1488
1492
|
}
|
|
1489
|
-
function
|
|
1493
|
+
function we(r, t, e) {
|
|
1490
1494
|
if (t.length === 0)
|
|
1491
1495
|
return [];
|
|
1492
1496
|
e = Math.min(e, t.length);
|
|
@@ -1497,63 +1501,63 @@ function fe(r, t, e) {
|
|
|
1497
1501
|
};
|
|
1498
1502
|
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % s;
|
|
1499
1503
|
const a = new Uint32Array(n + 1), d = /* @__PURE__ */ new Map(), h = [];
|
|
1500
|
-
for (let
|
|
1504
|
+
for (let m = 0; m < 256; m++)
|
|
1501
1505
|
h.push(a);
|
|
1502
|
-
for (let
|
|
1503
|
-
const
|
|
1504
|
-
if (d.has(
|
|
1506
|
+
for (let m = 0; m < t.length; m += 1) {
|
|
1507
|
+
const w = t.charCodeAt(m);
|
|
1508
|
+
if (d.has(w))
|
|
1505
1509
|
continue;
|
|
1506
1510
|
const f = new Uint32Array(n + 1);
|
|
1507
|
-
d.set(
|
|
1508
|
-
for (let
|
|
1509
|
-
f[
|
|
1510
|
-
for (let
|
|
1511
|
-
const
|
|
1512
|
-
if (
|
|
1511
|
+
d.set(w, f), w < h.length && (h[w] = f);
|
|
1512
|
+
for (let p = 0; p <= n; p += 1) {
|
|
1513
|
+
f[p] = 0;
|
|
1514
|
+
for (let b = 0; b < s; b += 1) {
|
|
1515
|
+
const x = p * s + b;
|
|
1516
|
+
if (x >= t.length)
|
|
1513
1517
|
continue;
|
|
1514
|
-
t.charCodeAt(
|
|
1518
|
+
t.charCodeAt(x) === w && (f[p] |= 1 << b);
|
|
1515
1519
|
}
|
|
1516
1520
|
}
|
|
1517
1521
|
}
|
|
1518
1522
|
let u = Math.max(0, Math.ceil(e / s) - 1);
|
|
1519
1523
|
const g = new Uint32Array(n + 1);
|
|
1520
|
-
for (let
|
|
1521
|
-
g[
|
|
1524
|
+
for (let m = 0; m <= u; m += 1)
|
|
1525
|
+
g[m] = (m + 1) * s;
|
|
1522
1526
|
g[n] = t.length;
|
|
1523
|
-
for (let
|
|
1524
|
-
o.P[
|
|
1525
|
-
for (let
|
|
1526
|
-
const
|
|
1527
|
+
for (let m = 0; m <= u; m += 1)
|
|
1528
|
+
o.P[m] = -1, o.M[m] = 0;
|
|
1529
|
+
for (let m = 0; m < r.length; m += 1) {
|
|
1530
|
+
const w = r.charCodeAt(m);
|
|
1527
1531
|
let f;
|
|
1528
|
-
|
|
1529
|
-
let
|
|
1530
|
-
for (let
|
|
1531
|
-
|
|
1532
|
-
if (g[u] -
|
|
1532
|
+
w < h.length ? f = h[w] : (f = d.get(w), typeof f > "u" && (f = a));
|
|
1533
|
+
let p = 0;
|
|
1534
|
+
for (let b = 0; b <= u; b += 1)
|
|
1535
|
+
p = ee(o, f, b, p), g[b] += p;
|
|
1536
|
+
if (g[u] - p <= e && u < n && (f[u + 1] & 1 || p < 0)) {
|
|
1533
1537
|
u += 1, o.P[u] = -1, o.M[u] = 0;
|
|
1534
|
-
let
|
|
1538
|
+
let b;
|
|
1535
1539
|
if (u === n) {
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1540
|
+
const x = t.length % s;
|
|
1541
|
+
b = x === 0 ? s : x;
|
|
1538
1542
|
} else
|
|
1539
|
-
|
|
1540
|
-
g[u] = g[u - 1] +
|
|
1543
|
+
b = s;
|
|
1544
|
+
g[u] = g[u - 1] + b - p + ee(o, f, u, p);
|
|
1541
1545
|
} else
|
|
1542
1546
|
for (; u > 0 && g[u] >= e + s; )
|
|
1543
1547
|
u -= 1;
|
|
1544
1548
|
u === n && g[u] <= e && (g[u] < e && i.splice(0, i.length), i.push({
|
|
1545
1549
|
start: -1,
|
|
1546
|
-
end:
|
|
1550
|
+
end: m + 1,
|
|
1547
1551
|
errors: g[u]
|
|
1548
1552
|
}), e = g[u]);
|
|
1549
1553
|
}
|
|
1550
1554
|
return i;
|
|
1551
1555
|
}
|
|
1552
|
-
function
|
|
1553
|
-
const i =
|
|
1554
|
-
return
|
|
1556
|
+
function $e(r, t, e) {
|
|
1557
|
+
const i = we(r, t, e);
|
|
1558
|
+
return Fe(r, t, i);
|
|
1555
1559
|
}
|
|
1556
|
-
function
|
|
1560
|
+
function ve(r, t, e) {
|
|
1557
1561
|
let i = 0;
|
|
1558
1562
|
const s = [];
|
|
1559
1563
|
for (; i !== -1; )
|
|
@@ -1562,30 +1566,30 @@ function me(r, t, e) {
|
|
|
1562
1566
|
end: i + t.length,
|
|
1563
1567
|
errors: 0
|
|
1564
1568
|
}), i += 1);
|
|
1565
|
-
return s.length > 0 ? s :
|
|
1569
|
+
return s.length > 0 ? s : $e(r, t, e);
|
|
1566
1570
|
}
|
|
1567
|
-
function
|
|
1568
|
-
return t.length === 0 || r.length === 0 ? 0 : 1 -
|
|
1571
|
+
function ie(r, t) {
|
|
1572
|
+
return t.length === 0 || r.length === 0 ? 0 : 1 - ve(r, t, t.length)[0].errors / t.length;
|
|
1569
1573
|
}
|
|
1570
|
-
function
|
|
1574
|
+
function Ye(r, t, e = {}) {
|
|
1571
1575
|
if (t.length === 0)
|
|
1572
1576
|
return null;
|
|
1573
|
-
const i = Math.min(256, t.length / 2), s =
|
|
1577
|
+
const i = Math.min(256, t.length / 2), s = ve(r, t, i);
|
|
1574
1578
|
if (s.length === 0)
|
|
1575
1579
|
return null;
|
|
1576
1580
|
const n = (a) => {
|
|
1577
|
-
const
|
|
1581
|
+
const m = 1 - a.errors / t.length, w = e.prefix ? ie(
|
|
1578
1582
|
r.slice(
|
|
1579
1583
|
Math.max(0, a.start - e.prefix.length),
|
|
1580
1584
|
a.start
|
|
1581
1585
|
),
|
|
1582
1586
|
e.prefix
|
|
1583
|
-
) : 1, f = e.suffix ?
|
|
1587
|
+
) : 1, f = e.suffix ? ie(
|
|
1584
1588
|
r.slice(a.end, a.end + e.suffix.length),
|
|
1585
1589
|
e.suffix
|
|
1586
1590
|
) : 1;
|
|
1587
|
-
let
|
|
1588
|
-
return typeof e.hint == "number" && (
|
|
1591
|
+
let p = 1;
|
|
1592
|
+
return typeof e.hint == "number" && (p = 1 - Math.abs(a.start - e.hint) / r.length), (50 * m + 20 * w + 20 * f + 2 * p) / 92;
|
|
1589
1593
|
}, o = s.map((a) => ({
|
|
1590
1594
|
start: a.start,
|
|
1591
1595
|
end: a.end,
|
|
@@ -1593,7 +1597,7 @@ function Be(r, t, e = {}) {
|
|
|
1593
1597
|
}));
|
|
1594
1598
|
return o.sort((a, d) => d.score - a.score), o[0];
|
|
1595
1599
|
}
|
|
1596
|
-
function
|
|
1600
|
+
function vt(r, t, e) {
|
|
1597
1601
|
const i = e === 1 ? t : t - 1;
|
|
1598
1602
|
if (r.charAt(i).trim() !== "")
|
|
1599
1603
|
return t;
|
|
@@ -1603,7 +1607,7 @@ function gt(r, t, e) {
|
|
|
1603
1607
|
const o = s.length - n.length;
|
|
1604
1608
|
return e === 2 ? t - o : t + o;
|
|
1605
1609
|
}
|
|
1606
|
-
function
|
|
1610
|
+
function se(r, t) {
|
|
1607
1611
|
const e = r.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1608
1612
|
r.commonAncestorContainer,
|
|
1609
1613
|
NodeFilter.SHOW_TEXT
|
|
@@ -1616,7 +1620,7 @@ function Qt(r, t) {
|
|
|
1616
1620
|
const a = () => {
|
|
1617
1621
|
if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
|
|
1618
1622
|
const d = n.textContent, h = t === 1 ? 0 : d.length;
|
|
1619
|
-
o =
|
|
1623
|
+
o = vt(d, h, t);
|
|
1620
1624
|
}
|
|
1621
1625
|
};
|
|
1622
1626
|
for (; n && o === -1 && n !== s; )
|
|
@@ -1625,7 +1629,7 @@ function Qt(r, t) {
|
|
|
1625
1629
|
return { node: n, offset: o };
|
|
1626
1630
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1627
1631
|
}
|
|
1628
|
-
function
|
|
1632
|
+
function Xe(r) {
|
|
1629
1633
|
if (!r.toString().trim().length)
|
|
1630
1634
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1631
1635
|
if (r.startContainer.nodeType !== Node.TEXT_NODE)
|
|
@@ -1635,13 +1639,13 @@ function He(r) {
|
|
|
1635
1639
|
const t = r.cloneRange();
|
|
1636
1640
|
let e = !1, i = !1;
|
|
1637
1641
|
const s = {
|
|
1638
|
-
start:
|
|
1642
|
+
start: vt(
|
|
1639
1643
|
r.startContainer.textContent,
|
|
1640
1644
|
r.startOffset,
|
|
1641
1645
|
1
|
|
1642
1646
|
/* Forwards */
|
|
1643
1647
|
),
|
|
1644
|
-
end:
|
|
1648
|
+
end: vt(
|
|
1645
1649
|
r.endContainer.textContent,
|
|
1646
1650
|
r.endOffset,
|
|
1647
1651
|
2
|
|
@@ -1651,7 +1655,7 @@ function He(r) {
|
|
|
1651
1655
|
if (s.start >= 0 && (t.setStart(r.startContainer, s.start), e = !0), s.end > 0 && (t.setEnd(r.endContainer, s.end), i = !0), e && i)
|
|
1652
1656
|
return t;
|
|
1653
1657
|
if (!e) {
|
|
1654
|
-
const { node: n, offset: o } =
|
|
1658
|
+
const { node: n, offset: o } = se(
|
|
1655
1659
|
t,
|
|
1656
1660
|
1
|
|
1657
1661
|
/* Forwards */
|
|
@@ -1659,7 +1663,7 @@ function He(r) {
|
|
|
1659
1663
|
n && o >= 0 && t.setStart(n, o);
|
|
1660
1664
|
}
|
|
1661
1665
|
if (!i) {
|
|
1662
|
-
const { node: n, offset: o } =
|
|
1666
|
+
const { node: n, offset: o } = se(
|
|
1663
1667
|
t,
|
|
1664
1668
|
2
|
|
1665
1669
|
/* Backwards */
|
|
@@ -1668,7 +1672,7 @@ function He(r) {
|
|
|
1668
1672
|
}
|
|
1669
1673
|
return t;
|
|
1670
1674
|
}
|
|
1671
|
-
function
|
|
1675
|
+
function Se(r) {
|
|
1672
1676
|
switch (r.nodeType) {
|
|
1673
1677
|
case Node.ELEMENT_NODE:
|
|
1674
1678
|
case Node.TEXT_NODE:
|
|
@@ -1677,13 +1681,13 @@ function ge(r) {
|
|
|
1677
1681
|
return 0;
|
|
1678
1682
|
}
|
|
1679
1683
|
}
|
|
1680
|
-
function
|
|
1684
|
+
function ne(r) {
|
|
1681
1685
|
let t = r.previousSibling, e = 0;
|
|
1682
1686
|
for (; t; )
|
|
1683
|
-
e +=
|
|
1687
|
+
e += Se(t), t = t.previousSibling;
|
|
1684
1688
|
return e;
|
|
1685
1689
|
}
|
|
1686
|
-
function
|
|
1690
|
+
function Ee(r, ...t) {
|
|
1687
1691
|
let e = t.shift();
|
|
1688
1692
|
const i = r.ownerDocument.createNodeIterator(
|
|
1689
1693
|
r,
|
|
@@ -1698,7 +1702,7 @@ function be(r, ...t) {
|
|
|
1698
1702
|
throw new RangeError("Offset exceeds text length");
|
|
1699
1703
|
return s;
|
|
1700
1704
|
}
|
|
1701
|
-
class
|
|
1705
|
+
class z {
|
|
1702
1706
|
constructor(t, e) {
|
|
1703
1707
|
if (e < 0)
|
|
1704
1708
|
throw new Error("Offset is invalid");
|
|
@@ -1715,8 +1719,8 @@ class D {
|
|
|
1715
1719
|
throw new Error("Parent is not an ancestor of current element");
|
|
1716
1720
|
let e = this.element, i = this.offset;
|
|
1717
1721
|
for (; e !== t; )
|
|
1718
|
-
i +=
|
|
1719
|
-
return new
|
|
1722
|
+
i += ne(e), e = e.parentElement;
|
|
1723
|
+
return new z(e, i);
|
|
1720
1724
|
}
|
|
1721
1725
|
/**
|
|
1722
1726
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1737,7 +1741,7 @@ class D {
|
|
|
1737
1741
|
*/
|
|
1738
1742
|
resolve(t = {}) {
|
|
1739
1743
|
try {
|
|
1740
|
-
return
|
|
1744
|
+
return Ee(this.element, this.offset)[0];
|
|
1741
1745
|
} catch (e) {
|
|
1742
1746
|
if (this.offset === 0 && t.direction !== void 0) {
|
|
1743
1747
|
const i = document.createTreeWalker(
|
|
@@ -1760,9 +1764,9 @@ class D {
|
|
|
1760
1764
|
static fromCharOffset(t, e) {
|
|
1761
1765
|
switch (t.nodeType) {
|
|
1762
1766
|
case Node.TEXT_NODE:
|
|
1763
|
-
return
|
|
1767
|
+
return z.fromPoint(t, e);
|
|
1764
1768
|
case Node.ELEMENT_NODE:
|
|
1765
|
-
return new
|
|
1769
|
+
return new z(t, e);
|
|
1766
1770
|
default:
|
|
1767
1771
|
throw new Error("Node is not an element or text node");
|
|
1768
1772
|
}
|
|
@@ -1780,23 +1784,23 @@ class D {
|
|
|
1780
1784
|
throw new Error("Text node offset is out of range");
|
|
1781
1785
|
if (!t.parentElement)
|
|
1782
1786
|
throw new Error("Text node has no parent");
|
|
1783
|
-
const i =
|
|
1784
|
-
return new
|
|
1787
|
+
const i = ne(t) + e;
|
|
1788
|
+
return new z(t.parentElement, i);
|
|
1785
1789
|
}
|
|
1786
1790
|
case Node.ELEMENT_NODE: {
|
|
1787
1791
|
if (e < 0 || e > t.childNodes.length)
|
|
1788
1792
|
throw new Error("Child node offset is out of range");
|
|
1789
1793
|
let i = 0;
|
|
1790
1794
|
for (let s = 0; s < e; s++)
|
|
1791
|
-
i +=
|
|
1792
|
-
return new
|
|
1795
|
+
i += Se(t.childNodes[s]);
|
|
1796
|
+
return new z(t, i);
|
|
1793
1797
|
}
|
|
1794
1798
|
default:
|
|
1795
1799
|
throw new Error("Point is not in an element or text node");
|
|
1796
1800
|
}
|
|
1797
1801
|
}
|
|
1798
1802
|
}
|
|
1799
|
-
class
|
|
1803
|
+
class U {
|
|
1800
1804
|
constructor(t, e) {
|
|
1801
1805
|
this.start = t, this.end = e;
|
|
1802
1806
|
}
|
|
@@ -1806,7 +1810,7 @@ class k {
|
|
|
1806
1810
|
* `end.element`.
|
|
1807
1811
|
*/
|
|
1808
1812
|
relativeTo(t) {
|
|
1809
|
-
return new
|
|
1813
|
+
return new U(
|
|
1810
1814
|
this.start.relativeTo(t),
|
|
1811
1815
|
this.end.relativeTo(t)
|
|
1812
1816
|
);
|
|
@@ -1822,7 +1826,7 @@ class k {
|
|
|
1822
1826
|
*/
|
|
1823
1827
|
toRange() {
|
|
1824
1828
|
let t, e;
|
|
1825
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] =
|
|
1829
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Ee(
|
|
1826
1830
|
this.start.element,
|
|
1827
1831
|
this.start.offset,
|
|
1828
1832
|
this.end.offset
|
|
@@ -1840,20 +1844,20 @@ class k {
|
|
|
1840
1844
|
* Create a TextRange from a (DOM) Range
|
|
1841
1845
|
*/
|
|
1842
1846
|
static fromRange(t) {
|
|
1843
|
-
const e =
|
|
1847
|
+
const e = z.fromPoint(
|
|
1844
1848
|
t.startContainer,
|
|
1845
1849
|
t.startOffset
|
|
1846
|
-
), i =
|
|
1847
|
-
return new
|
|
1850
|
+
), i = z.fromPoint(t.endContainer, t.endOffset);
|
|
1851
|
+
return new U(e, i);
|
|
1848
1852
|
}
|
|
1849
1853
|
/**
|
|
1850
1854
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1851
1855
|
* `root`
|
|
1852
1856
|
*/
|
|
1853
1857
|
static fromOffsets(t, e, i) {
|
|
1854
|
-
return new
|
|
1855
|
-
new
|
|
1856
|
-
new
|
|
1858
|
+
return new U(
|
|
1859
|
+
new z(t, e),
|
|
1860
|
+
new z(t, i)
|
|
1857
1861
|
);
|
|
1858
1862
|
}
|
|
1859
1863
|
/**
|
|
@@ -1861,23 +1865,23 @@ class k {
|
|
|
1861
1865
|
* whitespace
|
|
1862
1866
|
*/
|
|
1863
1867
|
static trimmedRange(t) {
|
|
1864
|
-
return
|
|
1868
|
+
return Xe(U.fromRange(t).toRange());
|
|
1865
1869
|
}
|
|
1866
1870
|
}
|
|
1867
|
-
class
|
|
1871
|
+
class ht {
|
|
1868
1872
|
constructor(t, e, i) {
|
|
1869
1873
|
this.root = t, this.start = e, this.end = i;
|
|
1870
1874
|
}
|
|
1871
1875
|
static fromRange(t, e) {
|
|
1872
|
-
const i =
|
|
1873
|
-
return new
|
|
1876
|
+
const i = U.fromRange(e).relativeTo(t);
|
|
1877
|
+
return new ht(
|
|
1874
1878
|
t,
|
|
1875
1879
|
i.start.offset,
|
|
1876
1880
|
i.end.offset
|
|
1877
1881
|
);
|
|
1878
1882
|
}
|
|
1879
1883
|
static fromSelector(t, e) {
|
|
1880
|
-
return new
|
|
1884
|
+
return new ht(t, e.start, e.end);
|
|
1881
1885
|
}
|
|
1882
1886
|
toSelector() {
|
|
1883
1887
|
return {
|
|
@@ -1887,10 +1891,10 @@ class at {
|
|
|
1887
1891
|
};
|
|
1888
1892
|
}
|
|
1889
1893
|
toRange() {
|
|
1890
|
-
return
|
|
1894
|
+
return U.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1891
1895
|
}
|
|
1892
1896
|
}
|
|
1893
|
-
class
|
|
1897
|
+
class dt {
|
|
1894
1898
|
/**
|
|
1895
1899
|
* @param root - A root element from which to anchor.
|
|
1896
1900
|
*/
|
|
@@ -1903,15 +1907,15 @@ class lt {
|
|
|
1903
1907
|
* Will throw if `range` does not contain any text nodes.
|
|
1904
1908
|
*/
|
|
1905
1909
|
static fromRange(t, e) {
|
|
1906
|
-
const i = t.textContent, s =
|
|
1907
|
-
return new
|
|
1910
|
+
const i = t.textContent, s = U.fromRange(e).relativeTo(t), n = s.start.offset, o = s.end.offset, a = 32;
|
|
1911
|
+
return new dt(t, i.slice(n, o), {
|
|
1908
1912
|
prefix: i.slice(Math.max(0, n - a), n),
|
|
1909
1913
|
suffix: i.slice(o, Math.min(i.length, o + a))
|
|
1910
1914
|
});
|
|
1911
1915
|
}
|
|
1912
1916
|
static fromSelector(t, e) {
|
|
1913
1917
|
const { prefix: i, suffix: s } = e;
|
|
1914
|
-
return new
|
|
1918
|
+
return new dt(t, e.exact, { prefix: i, suffix: s });
|
|
1915
1919
|
}
|
|
1916
1920
|
toSelector() {
|
|
1917
1921
|
return {
|
|
@@ -1925,26 +1929,26 @@ class lt {
|
|
|
1925
1929
|
return this.toPositionAnchor(t).toRange();
|
|
1926
1930
|
}
|
|
1927
1931
|
toPositionAnchor(t = {}) {
|
|
1928
|
-
const e = this.root.textContent, i =
|
|
1932
|
+
const e = this.root.textContent, i = Ye(e, this.exact, {
|
|
1929
1933
|
...this.context,
|
|
1930
1934
|
hint: t.hint
|
|
1931
1935
|
});
|
|
1932
1936
|
if (!i)
|
|
1933
1937
|
throw new Error("Quote not found");
|
|
1934
|
-
return new
|
|
1938
|
+
return new ht(this.root, i.start, i.end);
|
|
1935
1939
|
}
|
|
1936
1940
|
}
|
|
1937
|
-
function
|
|
1941
|
+
function qe(r) {
|
|
1938
1942
|
const t = r.tagName.toUpperCase();
|
|
1939
1943
|
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1940
1944
|
}
|
|
1941
|
-
function
|
|
1945
|
+
function pt(r, t) {
|
|
1942
1946
|
try {
|
|
1943
1947
|
const e = t.locations, i = t.text;
|
|
1944
1948
|
if (i && i.highlight) {
|
|
1945
1949
|
let s;
|
|
1946
1950
|
e && e.getCssSelector() && (s = r.querySelector(e.getCssSelector())), s || (s = r.body);
|
|
1947
|
-
const n = new
|
|
1951
|
+
const n = new dt(s, i.highlight, {
|
|
1948
1952
|
prefix: i.before,
|
|
1949
1953
|
suffix: i.after
|
|
1950
1954
|
});
|
|
@@ -1963,7 +1967,7 @@ function ht(r, t) {
|
|
|
1963
1967
|
}
|
|
1964
1968
|
if (s) {
|
|
1965
1969
|
const n = r.createRange();
|
|
1966
|
-
return s.childNodes.length === 0 ||
|
|
1970
|
+
return s.childNodes.length === 0 || qe(s) ? (n.selectNode(s), n) : (n.setStartBefore(s), n.setEndAfter(s), n);
|
|
1967
1971
|
}
|
|
1968
1972
|
}
|
|
1969
1973
|
} catch (e) {
|
|
@@ -1971,7 +1975,7 @@ function ht(r, t) {
|
|
|
1971
1975
|
}
|
|
1972
1976
|
return null;
|
|
1973
1977
|
}
|
|
1974
|
-
function
|
|
1978
|
+
function Ke(r, t) {
|
|
1975
1979
|
let e = r.getClientRects();
|
|
1976
1980
|
e.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = r.commonAncestorContainer.getClientRects());
|
|
1977
1981
|
const i = 1, s = [];
|
|
@@ -1984,10 +1988,10 @@ function _e(r, t) {
|
|
|
1984
1988
|
top: h.top,
|
|
1985
1989
|
width: h.width
|
|
1986
1990
|
});
|
|
1987
|
-
const n =
|
|
1991
|
+
const n = Ae(
|
|
1988
1992
|
s,
|
|
1989
1993
|
i
|
|
1990
|
-
), o =
|
|
1994
|
+
), o = Je(n, i), a = Ce(o), d = 4;
|
|
1991
1995
|
for (let h = a.length - 1; h >= 0; h--) {
|
|
1992
1996
|
const u = a[h];
|
|
1993
1997
|
if (!(u.width * u.height > d))
|
|
@@ -1998,16 +2002,16 @@ function _e(r, t) {
|
|
|
1998
2002
|
}
|
|
1999
2003
|
return a;
|
|
2000
2004
|
}
|
|
2001
|
-
function
|
|
2005
|
+
function Ae(r, t, e) {
|
|
2002
2006
|
for (let i = 0; i < r.length; i++)
|
|
2003
2007
|
for (let s = i + 1; s < r.length; s++) {
|
|
2004
2008
|
const n = r[i], o = r[s];
|
|
2005
2009
|
if (n === o)
|
|
2006
2010
|
continue;
|
|
2007
|
-
const a =
|
|
2008
|
-
if (a && !d &&
|
|
2009
|
-
const g = r.filter((
|
|
2010
|
-
return g.push(
|
|
2011
|
+
const a = I(n.top, o.top, t) && I(n.bottom, o.bottom, t), d = I(n.left, o.left, t) && I(n.right, o.right, t);
|
|
2012
|
+
if (a && !d && xe(n, o, t)) {
|
|
2013
|
+
const g = r.filter((w) => w !== n && w !== o), m = Ze(n, o);
|
|
2014
|
+
return g.push(m), Ae(
|
|
2011
2015
|
g,
|
|
2012
2016
|
t
|
|
2013
2017
|
);
|
|
@@ -2015,7 +2019,7 @@ function ve(r, t, e) {
|
|
|
2015
2019
|
}
|
|
2016
2020
|
return r;
|
|
2017
2021
|
}
|
|
2018
|
-
function
|
|
2022
|
+
function Ze(r, t) {
|
|
2019
2023
|
const e = Math.min(r.left, t.left), i = Math.max(r.right, t.right), s = Math.min(r.top, t.top), n = Math.max(r.bottom, t.bottom);
|
|
2020
2024
|
return {
|
|
2021
2025
|
bottom: n,
|
|
@@ -2026,7 +2030,7 @@ function Ve(r, t) {
|
|
|
2026
2030
|
width: i - e
|
|
2027
2031
|
};
|
|
2028
2032
|
}
|
|
2029
|
-
function
|
|
2033
|
+
function Je(r, t) {
|
|
2030
2034
|
const e = new Set(r);
|
|
2031
2035
|
for (const i of r) {
|
|
2032
2036
|
if (!(i.width > 1 && i.height > 1)) {
|
|
@@ -2034,40 +2038,40 @@ function Fe(r, t) {
|
|
|
2034
2038
|
continue;
|
|
2035
2039
|
}
|
|
2036
2040
|
for (const n of r)
|
|
2037
|
-
if (i !== n && e.has(n) &&
|
|
2041
|
+
if (i !== n && e.has(n) && Qe(n, i, t)) {
|
|
2038
2042
|
e.delete(i);
|
|
2039
2043
|
break;
|
|
2040
2044
|
}
|
|
2041
2045
|
}
|
|
2042
2046
|
return Array.from(e);
|
|
2043
2047
|
}
|
|
2044
|
-
function
|
|
2045
|
-
return
|
|
2048
|
+
function Qe(r, t, e) {
|
|
2049
|
+
return nt(r, t.left, t.top, e) && nt(r, t.right, t.top, e) && nt(r, t.left, t.bottom, e) && nt(r, t.right, t.bottom, e);
|
|
2046
2050
|
}
|
|
2047
|
-
function
|
|
2048
|
-
return (r.left < t ||
|
|
2051
|
+
function nt(r, t, e, i) {
|
|
2052
|
+
return (r.left < t || I(r.left, t, i)) && (r.right > t || I(r.right, t, i)) && (r.top < e || I(r.top, e, i)) && (r.bottom > e || I(r.bottom, e, i));
|
|
2049
2053
|
}
|
|
2050
|
-
function
|
|
2054
|
+
function Ce(r) {
|
|
2051
2055
|
for (let t = 0; t < r.length; t++)
|
|
2052
2056
|
for (let e = t + 1; e < r.length; e++) {
|
|
2053
2057
|
const i = r[t], s = r[e];
|
|
2054
|
-
if (i !== s &&
|
|
2058
|
+
if (i !== s && xe(i, s, -1)) {
|
|
2055
2059
|
let n = [], o;
|
|
2056
|
-
const a =
|
|
2060
|
+
const a = re(i, s);
|
|
2057
2061
|
if (a.length === 1)
|
|
2058
2062
|
n = a, o = i;
|
|
2059
2063
|
else {
|
|
2060
|
-
const h =
|
|
2064
|
+
const h = re(s, i);
|
|
2061
2065
|
a.length < h.length ? (n = a, o = i) : (n = h, o = s);
|
|
2062
2066
|
}
|
|
2063
2067
|
const d = r.filter((h) => h !== o);
|
|
2064
|
-
return Array.prototype.push.apply(d, n),
|
|
2068
|
+
return Array.prototype.push.apply(d, n), Ce(d);
|
|
2065
2069
|
}
|
|
2066
2070
|
}
|
|
2067
2071
|
return r;
|
|
2068
2072
|
}
|
|
2069
|
-
function
|
|
2070
|
-
const e =
|
|
2073
|
+
function re(r, t) {
|
|
2074
|
+
const e = je(t, r);
|
|
2071
2075
|
if (e.height === 0 || e.width === 0)
|
|
2072
2076
|
return [r];
|
|
2073
2077
|
const i = [];
|
|
@@ -2117,7 +2121,7 @@ function te(r, t) {
|
|
|
2117
2121
|
}
|
|
2118
2122
|
return i;
|
|
2119
2123
|
}
|
|
2120
|
-
function
|
|
2124
|
+
function je(r, t) {
|
|
2121
2125
|
const e = Math.max(r.left, t.left), i = Math.min(r.right, t.right), s = Math.max(r.top, t.top), n = Math.min(r.bottom, t.bottom);
|
|
2122
2126
|
return {
|
|
2123
2127
|
bottom: n,
|
|
@@ -2128,52 +2132,53 @@ function Ye(r, t) {
|
|
|
2128
2132
|
width: Math.max(0, i - e)
|
|
2129
2133
|
};
|
|
2130
2134
|
}
|
|
2131
|
-
function
|
|
2132
|
-
return (r.left < t.right || e >= 0 &&
|
|
2135
|
+
function xe(r, t, e) {
|
|
2136
|
+
return (r.left < t.right || e >= 0 && I(r.left, t.right, e)) && (t.left < r.right || e >= 0 && I(t.left, r.right, e)) && (r.top < t.bottom || e >= 0 && I(r.top, t.bottom, e)) && (t.top < r.bottom || e >= 0 && I(t.top, r.bottom, e));
|
|
2133
2137
|
}
|
|
2134
|
-
function
|
|
2138
|
+
function I(r, t, e) {
|
|
2135
2139
|
return Math.abs(r - t) <= e;
|
|
2136
2140
|
}
|
|
2137
|
-
|
|
2141
|
+
const gt = typeof window.CSSTransformValue < "u";
|
|
2142
|
+
function Ut(r) {
|
|
2138
2143
|
const t = {}, e = r.document.documentElement.style;
|
|
2139
2144
|
for (const i in r.document.documentElement.style)
|
|
2140
2145
|
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
2141
2146
|
return t;
|
|
2142
2147
|
}
|
|
2143
|
-
function
|
|
2144
|
-
const e =
|
|
2148
|
+
function Te(r, t) {
|
|
2149
|
+
const e = Ut(r);
|
|
2145
2150
|
Object.keys(e).forEach((i) => {
|
|
2146
|
-
t.hasOwnProperty(i) ||
|
|
2151
|
+
t.hasOwnProperty(i) || mt(r, i);
|
|
2147
2152
|
}), Object.entries(t).forEach(([i, s]) => {
|
|
2148
|
-
e[i] !== s &&
|
|
2153
|
+
e[i] !== s && it(r, i, s);
|
|
2149
2154
|
});
|
|
2150
2155
|
}
|
|
2151
|
-
function
|
|
2156
|
+
function yt(r, t) {
|
|
2152
2157
|
return r.document.documentElement.style.getPropertyValue(t);
|
|
2153
2158
|
}
|
|
2154
|
-
function
|
|
2159
|
+
function it(r, t, e) {
|
|
2155
2160
|
r.document.documentElement.style.setProperty(t, e);
|
|
2156
2161
|
}
|
|
2157
|
-
function
|
|
2162
|
+
function mt(r, t) {
|
|
2158
2163
|
r.document.documentElement.style.removeProperty(t);
|
|
2159
2164
|
}
|
|
2160
|
-
let
|
|
2161
|
-
const
|
|
2162
|
-
if (!
|
|
2165
|
+
let rt = null, bt = null, Z = 0;
|
|
2166
|
+
const G = { r: 255, g: 255, b: 255, a: 1 }, V = /* @__PURE__ */ new Map(), ti = () => {
|
|
2167
|
+
if (!rt)
|
|
2163
2168
|
if (typeof OffscreenCanvas < "u")
|
|
2164
|
-
|
|
2169
|
+
rt = new OffscreenCanvas(5, 5), bt = rt.getContext("2d", {
|
|
2165
2170
|
willReadFrequently: !0,
|
|
2166
2171
|
desynchronized: !0
|
|
2167
2172
|
});
|
|
2168
2173
|
else {
|
|
2169
2174
|
const r = document.createElement("canvas");
|
|
2170
|
-
r.width = 5, r.height = 5,
|
|
2175
|
+
r.width = 5, r.height = 5, rt = r, bt = r.getContext("2d", {
|
|
2171
2176
|
willReadFrequently: !0,
|
|
2172
2177
|
desynchronized: !0
|
|
2173
2178
|
});
|
|
2174
2179
|
}
|
|
2175
|
-
return
|
|
2176
|
-
},
|
|
2180
|
+
return bt;
|
|
2181
|
+
}, ei = (r) => {
|
|
2177
2182
|
if (!r) return !0;
|
|
2178
2183
|
const t = r.trim().toLowerCase();
|
|
2179
2184
|
return t.startsWith("var(") || [
|
|
@@ -2192,56 +2197,56 @@ const V = { r: 255, g: 255, b: 255, a: 1 }, _ = /* @__PURE__ */ new Map(), qe =
|
|
|
2192
2197
|
"repeating-radial-gradient",
|
|
2193
2198
|
"repeating-conic-gradient"
|
|
2194
2199
|
].some((s) => t.includes(s));
|
|
2195
|
-
},
|
|
2200
|
+
}, ot = (r, t) => {
|
|
2196
2201
|
console.warn(
|
|
2197
|
-
`[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(
|
|
2202
|
+
`[Decorator] Could not parse color: "${r}". ${t} Falling back to ${JSON.stringify(G)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`
|
|
2198
2203
|
);
|
|
2199
|
-
},
|
|
2200
|
-
const e = t ? `${r}|${t}` : r, i =
|
|
2204
|
+
}, St = (r, t = null) => {
|
|
2205
|
+
const e = t ? `${r}|${t}` : r, i = V.get(e);
|
|
2201
2206
|
if (i !== void 0)
|
|
2202
|
-
return i ??
|
|
2203
|
-
if (
|
|
2204
|
-
return
|
|
2205
|
-
const s =
|
|
2207
|
+
return i ?? G;
|
|
2208
|
+
if (ei(r))
|
|
2209
|
+
return ot(r, "Unsupported color format or special value."), V.set(e, null), G;
|
|
2210
|
+
const s = ti();
|
|
2206
2211
|
if (!s)
|
|
2207
|
-
return
|
|
2212
|
+
return ot(r, "Could not get canvas context."), V.set(e, null), G;
|
|
2208
2213
|
try {
|
|
2209
|
-
|
|
2210
|
-
const n =
|
|
2214
|
+
Z === 0 && s.clearRect(0, 0, 5, 5);
|
|
2215
|
+
const n = Z % 5, o = Math.floor(Z / 5);
|
|
2211
2216
|
s.clearRect(n, o, 1, 1), t && (s.fillStyle = t, s.fillRect(n, o, 1, 1)), s.fillStyle = r, s.fillRect(n, o, 1, 1);
|
|
2212
2217
|
const a = s.getImageData(n, o, 1, 1);
|
|
2213
|
-
|
|
2218
|
+
Z = (Z + 1) % 25;
|
|
2214
2219
|
const [d, h, u, g] = a.data;
|
|
2215
2220
|
if (g === 0)
|
|
2216
|
-
return
|
|
2217
|
-
const
|
|
2218
|
-
return
|
|
2221
|
+
return ot(r, "Fully transparent color."), V.set(e, null), G;
|
|
2222
|
+
const m = { r: d, g: h, b: u, a: g / 255 };
|
|
2223
|
+
return V.set(e, m), m;
|
|
2219
2224
|
} catch (n) {
|
|
2220
|
-
return
|
|
2225
|
+
return ot(r, `Error: ${n instanceof Error ? n.message : String(n)}`), V.set(e, null), G;
|
|
2221
2226
|
}
|
|
2222
|
-
},
|
|
2227
|
+
}, wt = (r) => {
|
|
2223
2228
|
const t = r / 255;
|
|
2224
2229
|
return t <= 0.03928 ? t / 12.92 : Math.pow((t + 0.055) / 1.055, 2.4);
|
|
2225
|
-
},
|
|
2226
|
-
const t =
|
|
2230
|
+
}, oe = (r) => {
|
|
2231
|
+
const t = wt(r.r), e = wt(r.g), i = wt(r.b);
|
|
2227
2232
|
return 0.2126 * t + 0.7152 * e + 0.0722 * i;
|
|
2228
|
-
},
|
|
2229
|
-
const e = typeof r == "string" ?
|
|
2233
|
+
}, ae = (r, t) => {
|
|
2234
|
+
const e = typeof r == "string" ? St(r) : r, i = typeof t == "string" ? St(t) : t, s = oe(e), n = oe(i), o = Math.max(s, n), a = Math.min(s, n);
|
|
2230
2235
|
return (o + 0.05) / (a + 0.05);
|
|
2231
|
-
},
|
|
2232
|
-
const e =
|
|
2236
|
+
}, Et = (r, t = null) => {
|
|
2237
|
+
const e = St(r, t), i = ae(e, { r: 255, g: 255, b: 255, a: 1 }), s = ae(e, { r: 0, g: 0, b: 0, a: 1 });
|
|
2233
2238
|
return i > s;
|
|
2234
|
-
},
|
|
2235
|
-
var
|
|
2236
|
-
const
|
|
2237
|
-
class
|
|
2239
|
+
}, ii = (r, t = null) => Et(r, t) ? "white" : "black", le = "#FFFF00";
|
|
2240
|
+
var si = /* @__PURE__ */ ((r) => (r.Wrap = "wrap", r.Viewport = "viewport", r.Bounds = "bounds", r.Page = "page", r))(si || {}), ni = /* @__PURE__ */ ((r) => (r.Boxes = "boxes", r.Bounds = "bounds", r))(ni || {});
|
|
2241
|
+
const ri = () => "Highlight" in window, ce = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2242
|
+
class oi {
|
|
2238
2243
|
/**
|
|
2239
2244
|
* Creates a DecorationGroup object
|
|
2240
2245
|
* @param id Unique HTML ID-adhering name of the group
|
|
2241
2246
|
* @param name Human-readable name of the group
|
|
2242
2247
|
*/
|
|
2243
2248
|
constructor(t, e, i, s) {
|
|
2244
|
-
this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0,
|
|
2249
|
+
this.wnd = t, this.comms = e, this.id = i, this.name = s, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, ri() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2245
2250
|
}
|
|
2246
2251
|
get activeable() {
|
|
2247
2252
|
return this.activateable;
|
|
@@ -2254,13 +2259,13 @@ class je {
|
|
|
2254
2259
|
* @param decoration Decoration to add
|
|
2255
2260
|
*/
|
|
2256
2261
|
add(t) {
|
|
2257
|
-
const e = `${this.id}-${this.lastItemId++}`, i =
|
|
2262
|
+
const e = `${this.id}-${this.lastItemId++}`, i = pt(this.wnd.document, t.locator);
|
|
2258
2263
|
if (!i) {
|
|
2259
2264
|
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2260
2265
|
return;
|
|
2261
2266
|
}
|
|
2262
2267
|
const s = i.commonAncestorContainer;
|
|
2263
|
-
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (
|
|
2268
|
+
s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (ce.includes(s.nodeName.toUpperCase()) && this.notTextFlag?.set(e, !0), i.cloneContents().querySelector(ce.join(", ").toLowerCase()) && this.notTextFlag?.set(e, !0), (s.textContent?.trim() || "").length === 0 && this.notTextFlag?.set(e, !0));
|
|
2264
2269
|
const n = {
|
|
2265
2270
|
decoration: t,
|
|
2266
2271
|
id: e,
|
|
@@ -2301,10 +2306,10 @@ class je {
|
|
|
2301
2306
|
experimentalLayout(t) {
|
|
2302
2307
|
const [e, i] = this.requireContainer(!0);
|
|
2303
2308
|
i.add(t.range);
|
|
2304
|
-
const s =
|
|
2309
|
+
const s = yt(this.wnd, "--USER__backgroundColor") || this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"), n = t.decoration?.style?.tint ?? le;
|
|
2305
2310
|
e.innerHTML = `
|
|
2306
2311
|
::highlight(${this.id}) {
|
|
2307
|
-
color: ${
|
|
2312
|
+
color: ${ii(n, s)};
|
|
2308
2313
|
background-color: ${n};
|
|
2309
2314
|
}`;
|
|
2310
2315
|
}
|
|
@@ -2321,48 +2326,48 @@ class je {
|
|
|
2321
2326
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2322
2327
|
"column-count"
|
|
2323
2328
|
)
|
|
2324
|
-
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f,
|
|
2329
|
+
), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, d = o.scrollTop, h = (f, p, b) => {
|
|
2325
2330
|
if (f.style.position = "absolute", t.decoration?.style?.width === "viewport") {
|
|
2326
|
-
f.style.width = `${i}px`, f.style.height = `${
|
|
2327
|
-
let
|
|
2328
|
-
f.style.left = `${
|
|
2331
|
+
f.style.width = `${i}px`, f.style.height = `${p.height}px`;
|
|
2332
|
+
let x = Math.floor(p.left / i) * i;
|
|
2333
|
+
f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
|
|
2329
2334
|
} else if (t.decoration?.style?.width === "bounds")
|
|
2330
|
-
f.style.width = `${
|
|
2335
|
+
f.style.width = `${b.width}px`, f.style.height = `${p.height}px`, f.style.left = `${b.left + a}px`, f.style.top = `${p.top + d}px`;
|
|
2331
2336
|
else if (t.decoration?.style?.width === "page") {
|
|
2332
|
-
f.style.width = `${n}px`, f.style.height = `${
|
|
2333
|
-
let
|
|
2334
|
-
f.style.left = `${
|
|
2337
|
+
f.style.width = `${n}px`, f.style.height = `${p.height}px`;
|
|
2338
|
+
let x = Math.floor(p.left / n) * n;
|
|
2339
|
+
f.style.left = `${x + a}px`, f.style.top = `${p.top + d}px`;
|
|
2335
2340
|
} else
|
|
2336
|
-
f.style.width = `${
|
|
2341
|
+
f.style.width = `${p.width}px`, f.style.height = `${p.height}px`, f.style.left = `${p.left + a}px`, f.style.top = `${p.top + d}px`;
|
|
2337
2342
|
}, u = t.range.getBoundingClientRect();
|
|
2338
2343
|
let g = this.wnd.document.createElement("template");
|
|
2339
|
-
const
|
|
2344
|
+
const m = this.getCurrentDarkMode();
|
|
2340
2345
|
g.innerHTML = `
|
|
2341
2346
|
<div
|
|
2342
2347
|
data-readium="true"
|
|
2343
2348
|
class="readium-highlight"
|
|
2344
2349
|
style="${[
|
|
2345
|
-
`background-color: ${t.decoration?.style?.tint ??
|
|
2350
|
+
`background-color: ${t.decoration?.style?.tint ?? le} !important`,
|
|
2346
2351
|
//"opacity: 0.3 !important",
|
|
2347
|
-
`mix-blend-mode: ${
|
|
2352
|
+
`mix-blend-mode: ${m ? "exclusion" : "multiply"} !important`,
|
|
2348
2353
|
"opacity: 1 !important",
|
|
2349
2354
|
"box-sizing: border-box !important"
|
|
2350
2355
|
].join("; ")}"
|
|
2351
2356
|
>
|
|
2352
2357
|
</div>
|
|
2353
2358
|
`.trim();
|
|
2354
|
-
const
|
|
2359
|
+
const w = g.content.firstElementChild;
|
|
2355
2360
|
if (t.decoration?.style?.layout === "bounds") {
|
|
2356
|
-
const f =
|
|
2361
|
+
const f = w.cloneNode(!0);
|
|
2357
2362
|
f.style.setProperty("pointer-events", "none"), h(f, u, u), e.append(f);
|
|
2358
2363
|
} else {
|
|
2359
|
-
let f =
|
|
2364
|
+
let f = Ke(
|
|
2360
2365
|
t.range
|
|
2361
2366
|
);
|
|
2362
|
-
f = f.sort((
|
|
2363
|
-
for (let
|
|
2364
|
-
const
|
|
2365
|
-
|
|
2367
|
+
f = f.sort((p, b) => p.top < b.top ? -1 : p.top > b.top ? 1 : 0);
|
|
2368
|
+
for (let p of f) {
|
|
2369
|
+
const b = w.cloneNode(!0);
|
|
2370
|
+
b.style.setProperty("pointer-events", "none"), h(b, p, u), e.append(b);
|
|
2366
2371
|
}
|
|
2367
2372
|
}
|
|
2368
2373
|
t.container = e, t.clickableElements = Array.from(
|
|
@@ -2389,7 +2394,7 @@ class je {
|
|
|
2389
2394
|
return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
|
|
2390
2395
|
}
|
|
2391
2396
|
getCurrentDarkMode() {
|
|
2392
|
-
return
|
|
2397
|
+
return yt(this.wnd, "--USER__appearance") === "readium-night-on" || Et(yt(this.wnd, "--USER__backgroundColor")) || Et(this.wnd.getComputedStyle(this.wnd.document.documentElement).getPropertyValue("background-color"));
|
|
2393
2398
|
}
|
|
2394
2399
|
/**
|
|
2395
2400
|
* Removes the group container.
|
|
@@ -2398,7 +2403,7 @@ class je {
|
|
|
2398
2403
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2399
2404
|
}
|
|
2400
2405
|
}
|
|
2401
|
-
const
|
|
2406
|
+
const Q = class Q extends X {
|
|
2402
2407
|
constructor() {
|
|
2403
2408
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2404
2409
|
}
|
|
@@ -2423,9 +2428,9 @@ const K = class K extends tt {
|
|
|
2423
2428
|
}, 50);
|
|
2424
2429
|
}
|
|
2425
2430
|
mount(t, e) {
|
|
2426
|
-
return this.wnd = t, e.register("decorate",
|
|
2431
|
+
return this.wnd = t, e.register("decorate", Q.moduleName, (i, s) => {
|
|
2427
2432
|
const n = i;
|
|
2428
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
2433
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new oi(
|
|
2429
2434
|
t,
|
|
2430
2435
|
e,
|
|
2431
2436
|
`readium-decoration-${this.lastGroupId++}`,
|
|
@@ -2450,8 +2455,8 @@ const K = class K extends tt {
|
|
|
2450
2455
|
}), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
|
|
2451
2456
|
i.some((n) => {
|
|
2452
2457
|
if (n.type === "attributes" && n.attributeName === "style") {
|
|
2453
|
-
const o = n.target, a = n.oldValue, d = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(d, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"),
|
|
2454
|
-
return h !== u || g !==
|
|
2458
|
+
const o = n.target, a = n.oldValue, d = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), u = this.extractCustomProperty(d, "--USER__appearance"), g = this.extractCustomProperty(a, "--USER__backgroundColor"), m = this.extractCustomProperty(d, "--USER__backgroundColor");
|
|
2459
|
+
return h !== u || g !== m;
|
|
2455
2460
|
}
|
|
2456
2461
|
return !1;
|
|
2457
2462
|
}) && this.updateHighlightStyles();
|
|
@@ -2463,12 +2468,12 @@ const K = class K extends tt {
|
|
|
2463
2468
|
}), e.log("Decorator Mounted"), !0;
|
|
2464
2469
|
}
|
|
2465
2470
|
unmount(t, e) {
|
|
2466
|
-
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(
|
|
2471
|
+
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.backgroundObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2467
2472
|
}
|
|
2468
2473
|
};
|
|
2469
|
-
|
|
2470
|
-
let
|
|
2471
|
-
const
|
|
2474
|
+
Q.moduleName = "decorator";
|
|
2475
|
+
let At = Q;
|
|
2476
|
+
const he = "readium-snapper-style", j = class j extends X {
|
|
2472
2477
|
constructor() {
|
|
2473
2478
|
super(...arguments), this.protected = !1;
|
|
2474
2479
|
}
|
|
@@ -2481,34 +2486,34 @@ const ne = "readium-snapper-style", Z = class Z extends tt {
|
|
|
2481
2486
|
}
|
|
2482
2487
|
mount(t, e) {
|
|
2483
2488
|
const i = t.document.createElement("style");
|
|
2484
|
-
return i.dataset.readium = "true", i.id =
|
|
2489
|
+
return i.dataset.readium = "true", i.id = he, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", j.moduleName, (s, n) => {
|
|
2485
2490
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2486
|
-
}), e.register("unprotect",
|
|
2491
|
+
}), e.register("unprotect", j.moduleName, (s, n) => {
|
|
2487
2492
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2488
2493
|
}), e.log("Snapper Mounted"), !0;
|
|
2489
2494
|
}
|
|
2490
2495
|
unmount(t, e) {
|
|
2491
|
-
return t.document.getElementById(
|
|
2496
|
+
return t.document.getElementById(he)?.remove(), e.log("Snapper Unmounted"), !0;
|
|
2492
2497
|
}
|
|
2493
2498
|
};
|
|
2494
|
-
|
|
2495
|
-
let
|
|
2496
|
-
function
|
|
2499
|
+
j.moduleName = "snapper";
|
|
2500
|
+
let st = j;
|
|
2501
|
+
function H(r) {
|
|
2497
2502
|
return r.document.body.dir.toLowerCase() === "rtl";
|
|
2498
2503
|
}
|
|
2499
|
-
function
|
|
2504
|
+
function Pe(r) {
|
|
2500
2505
|
return parseInt(
|
|
2501
2506
|
r.getComputedStyle(
|
|
2502
2507
|
r.document.documentElement
|
|
2503
2508
|
).getPropertyValue("column-count")
|
|
2504
2509
|
);
|
|
2505
2510
|
}
|
|
2506
|
-
function
|
|
2511
|
+
function de(r) {
|
|
2507
2512
|
const t = getComputedStyle(r), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2508
2513
|
return r.clientHeight - e - i;
|
|
2509
2514
|
}
|
|
2510
|
-
function
|
|
2511
|
-
const t =
|
|
2515
|
+
function ue(r) {
|
|
2516
|
+
const t = Pe(r);
|
|
2512
2517
|
if (!t)
|
|
2513
2518
|
return !1;
|
|
2514
2519
|
const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
@@ -2518,22 +2523,22 @@ function ae(r) {
|
|
|
2518
2523
|
if (d > 0)
|
|
2519
2524
|
for (let h = 0; h < d; h++) {
|
|
2520
2525
|
const u = r.document.createElement("div");
|
|
2521
|
-
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height =
|
|
2526
|
+
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = de(r.document.documentElement) + "px"), u.innerHTML = "​", r.document.body.appendChild(u);
|
|
2522
2527
|
}
|
|
2523
2528
|
return i !== d;
|
|
2524
2529
|
}
|
|
2525
|
-
function
|
|
2530
|
+
function Ne(r) {
|
|
2526
2531
|
const t = r.document.createElement("style");
|
|
2527
2532
|
t.appendChild(r.document.createTextNode("*{}")), r.document.body.appendChild(t), r.document.body.removeChild(t);
|
|
2528
2533
|
}
|
|
2529
|
-
function
|
|
2534
|
+
function ai(r) {
|
|
2530
2535
|
return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
|
|
2531
2536
|
}
|
|
2532
|
-
function
|
|
2537
|
+
function C(r) {
|
|
2533
2538
|
const t = r.getSelection();
|
|
2534
2539
|
t && t.removeAllRanges();
|
|
2535
2540
|
}
|
|
2536
|
-
const
|
|
2541
|
+
const li = [
|
|
2537
2542
|
"a",
|
|
2538
2543
|
"audio",
|
|
2539
2544
|
"button",
|
|
@@ -2547,35 +2552,35 @@ const ei = [
|
|
|
2547
2552
|
"textarea",
|
|
2548
2553
|
"video"
|
|
2549
2554
|
];
|
|
2550
|
-
function
|
|
2551
|
-
return
|
|
2555
|
+
function Le(r) {
|
|
2556
|
+
return li.indexOf(r.nodeName.toLowerCase()) !== -1 || r.hasAttribute("contenteditable") && r.getAttribute("contenteditable")?.toLowerCase() !== "false" ? r : r.parentElement ? Le(r.parentElement) : null;
|
|
2552
2557
|
}
|
|
2553
|
-
function
|
|
2554
|
-
const e =
|
|
2558
|
+
function Bt(r, t) {
|
|
2559
|
+
const e = Oe(r, r.document.body, t), i = r._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2555
2560
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2556
2561
|
});
|
|
2557
|
-
return new
|
|
2562
|
+
return new W({
|
|
2558
2563
|
href: "#",
|
|
2559
2564
|
type: "application/xhtml+xml",
|
|
2560
|
-
locations: new
|
|
2565
|
+
locations: new A({
|
|
2561
2566
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2562
2567
|
["cssSelector", i]
|
|
2563
2568
|
])
|
|
2564
2569
|
}),
|
|
2565
|
-
text: new
|
|
2570
|
+
text: new _({
|
|
2566
2571
|
highlight: e.textContent || void 0
|
|
2567
2572
|
})
|
|
2568
2573
|
});
|
|
2569
2574
|
}
|
|
2570
|
-
function
|
|
2575
|
+
function Oe(r, t, e) {
|
|
2571
2576
|
for (var i = 0; i < t.children.length; i++) {
|
|
2572
2577
|
const s = t.children[i];
|
|
2573
|
-
if (!
|
|
2574
|
-
return
|
|
2578
|
+
if (!di(s) && ci(r, s, e))
|
|
2579
|
+
return hi(r, s) ? s : Oe(r, s, e);
|
|
2575
2580
|
}
|
|
2576
2581
|
return t;
|
|
2577
2582
|
}
|
|
2578
|
-
function
|
|
2583
|
+
function ci(r, t, e) {
|
|
2579
2584
|
if (t === document.body || t === document.documentElement)
|
|
2580
2585
|
return !0;
|
|
2581
2586
|
if (!document || !document.documentElement || !document.body)
|
|
@@ -2583,11 +2588,11 @@ function ii(r, t, e) {
|
|
|
2583
2588
|
const i = t.getBoundingClientRect();
|
|
2584
2589
|
return e ? i.bottom > 0 && i.top < r.innerHeight : i.right > 0 && i.left < r.innerWidth;
|
|
2585
2590
|
}
|
|
2586
|
-
function
|
|
2591
|
+
function hi(r, t) {
|
|
2587
2592
|
const e = t.getBoundingClientRect();
|
|
2588
2593
|
return e.top >= 0 && e.left >= 0 && e.bottom <= r.innerHeight && e.right <= r.innerWidth;
|
|
2589
2594
|
}
|
|
2590
|
-
function
|
|
2595
|
+
function di(r) {
|
|
2591
2596
|
const t = getComputedStyle(r);
|
|
2592
2597
|
if (t) {
|
|
2593
2598
|
const e = t.getPropertyValue("display");
|
|
@@ -2596,9 +2601,75 @@ function ri(r) {
|
|
|
2596
2601
|
}
|
|
2597
2602
|
return !1;
|
|
2598
2603
|
}
|
|
2599
|
-
const
|
|
2604
|
+
const ui = {
|
|
2605
|
+
maxVelocity: 200,
|
|
2606
|
+
// Reasonable default for human-like scrolling (pixels/ms)
|
|
2607
|
+
minVariance: 0.01,
|
|
2608
|
+
// Default variance threshold
|
|
2609
|
+
historySize: 20,
|
|
2610
|
+
// Balanced history size for performance
|
|
2611
|
+
minDirectionChanges: 0.2,
|
|
2612
|
+
// Reasonable default for detecting patterns
|
|
2613
|
+
maxConsistentScrolls: 15
|
|
2614
|
+
// Balanced threshold for flagging
|
|
2615
|
+
}, Re = {
|
|
2616
|
+
maxVelocity: 200,
|
|
2617
|
+
// Extremely fast scrolling (pixels/ms)
|
|
2618
|
+
minVariance: 1e-5,
|
|
2619
|
+
// Near-perfect consistency
|
|
2620
|
+
historySize: 100,
|
|
2621
|
+
// Large history window
|
|
2622
|
+
minDirectionChanges: 0.1,
|
|
2623
|
+
// Only trigger on near-perfect patterns
|
|
2624
|
+
maxConsistentScrolls: 20
|
|
2625
|
+
// Need many consistent scrolls
|
|
2626
|
+
}, Ie = {
|
|
2627
|
+
maxSelectionsPerSecond: 500,
|
|
2628
|
+
minVariance: 50,
|
|
2629
|
+
historySize: 20
|
|
2630
|
+
}, pi = {
|
|
2631
|
+
enabled: !0,
|
|
2632
|
+
maxSelectionPercent: 0.1,
|
|
2633
|
+
minThreshold: 100,
|
|
2634
|
+
absoluteMaxChars: 5e3,
|
|
2635
|
+
historySize: 20
|
|
2636
|
+
};
|
|
2637
|
+
class Ht {
|
|
2638
|
+
constructor(t = {}) {
|
|
2639
|
+
this.history = [], this.consistentScrollCount = 0, this.options = { ...ui, ...t };
|
|
2640
|
+
}
|
|
2641
|
+
analyze(t, e, i) {
|
|
2642
|
+
if (i <= 0) return !1;
|
|
2643
|
+
const s = Math.abs(e) / i, n = Date.now();
|
|
2644
|
+
if (this.history.push({
|
|
2645
|
+
timestamp: n,
|
|
2646
|
+
direction: t,
|
|
2647
|
+
velocity: s,
|
|
2648
|
+
distance: Math.abs(e)
|
|
2649
|
+
}), this.history = this.history.filter((p) => n - p.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
|
|
2650
|
+
if (s > this.options.maxVelocity)
|
|
2651
|
+
return this.resetAfterDetection(), !0;
|
|
2652
|
+
const o = this.history.map((p) => p.velocity), a = this.history.map((p) => p.distance), d = o.reduce((p, b) => p + b, 0) / o.length, h = a.reduce((p, b) => p + b, 0) / a.length, u = o.reduce((p, b) => p + Math.pow(b - d, 2), 0) / o.length, g = a.reduce((p, b) => p + Math.pow(b - h, 2), 0) / a.length;
|
|
2653
|
+
if (u < this.options.minVariance && g < h * 0.1) {
|
|
2654
|
+
if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
|
|
2655
|
+
return this.resetAfterDetection(), !0;
|
|
2656
|
+
} else
|
|
2657
|
+
this.consistentScrollCount = Math.max(0, this.consistentScrollCount - 1);
|
|
2658
|
+
let m = 0, w = this.history[0].direction;
|
|
2659
|
+
for (let p = 1; p < this.history.length; p++)
|
|
2660
|
+
this.history[p].direction !== w && (m++, w = this.history[p].direction);
|
|
2661
|
+
return m / this.history.length > (this.options.minDirectionChanges || 0.3) ? (this.resetAfterDetection(), !0) : !1;
|
|
2662
|
+
}
|
|
2663
|
+
resetAfterDetection() {
|
|
2664
|
+
this.history = this.history.slice(-3), this.consistentScrollCount = 0;
|
|
2665
|
+
}
|
|
2666
|
+
clear() {
|
|
2667
|
+
this.history = [], this.consistentScrollCount = 0;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
const pe = "readium-column-snapper-style", mi = 200, P = class P extends st {
|
|
2600
2671
|
constructor() {
|
|
2601
|
-
super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2672
|
+
super(...arguments), this.isSnapProtectionEnabled = !1, this.patternAnalyzer = null, this.lastTurnTime = 0, this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2602
2673
|
}
|
|
2603
2674
|
doc() {
|
|
2604
2675
|
return this.wnd.document.scrollingElement;
|
|
@@ -2607,7 +2678,7 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2607
2678
|
return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
|
|
2608
2679
|
}
|
|
2609
2680
|
snapOffset(t) {
|
|
2610
|
-
const e = t + (
|
|
2681
|
+
const e = t + (H(this.wnd) ? -1 : 1);
|
|
2611
2682
|
return e - e % this.wnd.innerWidth;
|
|
2612
2683
|
}
|
|
2613
2684
|
reportProgress() {
|
|
@@ -2620,7 +2691,7 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2620
2691
|
shake() {
|
|
2621
2692
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0) return;
|
|
2622
2693
|
const t = this.doc();
|
|
2623
|
-
t.classList.add(
|
|
2694
|
+
t.classList.add(H(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
|
|
2624
2695
|
const e = this.scrollOffset();
|
|
2625
2696
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2626
2697
|
t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;
|
|
@@ -2634,24 +2705,26 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2634
2705
|
}
|
|
2635
2706
|
// Snaps the current offset to the page width.
|
|
2636
2707
|
snapCurrentOffset(t = !1, e = !1) {
|
|
2637
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o =
|
|
2708
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Pe(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), d = H(this.wnd) ? -1 : 1, h = (
|
|
2638
2709
|
// The hurdle to overcome in order to change pages
|
|
2639
2710
|
d * (this.wnd.innerWidth / 3) * (d * n > 0 ? 2 : 1)
|
|
2640
|
-
), u = this.snapOffset(a + h);
|
|
2641
|
-
if (t && u !== this.scrollOffset()) {
|
|
2711
|
+
), u = this.snapOffset(a + h), g = u > this.scrollOffset() ? "right" : "left";
|
|
2712
|
+
if (this.checkSuspiciousSnap(g, Math.abs(u - this.scrollOffset())), t && u !== this.scrollOffset()) {
|
|
2642
2713
|
this.snappingCancelled = !1;
|
|
2643
|
-
const
|
|
2714
|
+
const m = (b, x, B, q) => B > q ? x : b + (x - b) * ai(B / q), w = (
|
|
2644
2715
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2645
|
-
|
|
2716
|
+
mi * o
|
|
2646
2717
|
);
|
|
2647
|
-
let
|
|
2648
|
-
const
|
|
2718
|
+
let f;
|
|
2719
|
+
const p = (b) => {
|
|
2649
2720
|
if (this.snappingCancelled) return;
|
|
2650
|
-
|
|
2651
|
-
const
|
|
2652
|
-
s.scrollLeft =
|
|
2721
|
+
f || (f = b);
|
|
2722
|
+
const x = b - f, B = m(this.overscroll, 0, x, w), q = m(i, u, x, w);
|
|
2723
|
+
s.scrollLeft = q, this.overscroll !== 0 && (gt ? s.attributeStyleMap.set("transform", new CSSTransformValue([
|
|
2724
|
+
new CSSTranslate(CSS.px(-B), CSS.px(0), CSS.px(0))
|
|
2725
|
+
])) : s.style.transform = `translate3d(${-B}px, 0px, 0px)`), x < w ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, e || this.reportProgress());
|
|
2653
2726
|
};
|
|
2654
|
-
this.wnd.requestAnimationFrame(
|
|
2727
|
+
this.wnd.requestAnimationFrame(p);
|
|
2655
2728
|
} else
|
|
2656
2729
|
s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2657
2730
|
s.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
|
|
@@ -2689,15 +2762,42 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2689
2762
|
}
|
|
2690
2763
|
onTouchMove(t) {
|
|
2691
2764
|
if (this.touchState === 0) return;
|
|
2692
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2765
|
+
this.touchState === 1 && (this.touchState = 2, C(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2693
2766
|
const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
|
|
2694
|
-
i < 0 ? (this.overscroll = i,
|
|
2767
|
+
i < 0 ? (this.overscroll = i, gt ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
|
|
2768
|
+
new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
|
|
2769
|
+
])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, gt ? this.doc().attributeStyleMap.set("transform", new CSSTransformValue([
|
|
2770
|
+
new CSSTranslate(CSS.px(-i), CSS.px(0), CSS.px(0))
|
|
2771
|
+
])) : this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
|
|
2772
|
+
}
|
|
2773
|
+
enableSnapProtection() {
|
|
2774
|
+
this.patternAnalyzer || (this.patternAnalyzer = new Ht({
|
|
2775
|
+
maxVelocity: this.wnd.innerWidth,
|
|
2776
|
+
// page width
|
|
2777
|
+
minVariance: 0.1,
|
|
2778
|
+
// Allow for some variation in swipe speed
|
|
2779
|
+
historySize: 5,
|
|
2780
|
+
// Fewer samples needed for swipe detection
|
|
2781
|
+
maxConsistentScrolls: 3,
|
|
2782
|
+
// Lower threshold for consistent scrolling
|
|
2783
|
+
minDirectionChanges: 0.3
|
|
2784
|
+
// Require more direction changes
|
|
2785
|
+
}), this.isSnapProtectionEnabled = !0, this.comms?.log("Snap protection enabled"));
|
|
2786
|
+
}
|
|
2787
|
+
checkSuspiciousSnap(t, e) {
|
|
2788
|
+
if (!this.isSnapProtectionEnabled || !this.patternAnalyzer) return;
|
|
2789
|
+
const i = Date.now(), s = i - (this.lastTurnTime || i);
|
|
2790
|
+
this.lastTurnTime = i, this.patternAnalyzer.analyze(t, e, s) && this.comms?.send("content_protection", {
|
|
2791
|
+
type: "suspicious_snapping",
|
|
2792
|
+
timestamp: Date.now(),
|
|
2793
|
+
event: null
|
|
2794
|
+
});
|
|
2695
2795
|
}
|
|
2696
2796
|
mount(t, e) {
|
|
2697
2797
|
if (this.wnd = t, this.comms = e, !super.mount(t, e)) return !1;
|
|
2698
2798
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
2699
2799
|
const i = t.document.createElement("style");
|
|
2700
|
-
i.dataset.readium = "true", i.id =
|
|
2800
|
+
i.dataset.readium = "true", i.id = pe, i.textContent = `
|
|
2701
2801
|
@keyframes readium-bounce-l-animation {
|
|
2702
2802
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2703
2803
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2733,23 +2833,25 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2733
2833
|
}
|
|
2734
2834
|
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2735
2835
|
t.requestAnimationFrame(() => {
|
|
2736
|
-
t &&
|
|
2836
|
+
t && ue(t);
|
|
2737
2837
|
}), this.onWidthChange();
|
|
2738
2838
|
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2739
2839
|
for (const o of n)
|
|
2740
2840
|
if (o.target === this.wnd.document.documentElement) {
|
|
2741
2841
|
const a = o.oldValue, d = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a?.match(h), g = d?.match(h);
|
|
2742
2842
|
(!u && !g || u && !g || u && g && u[1] !== g[1]) && (t.requestAnimationFrame(() => {
|
|
2743
|
-
t &&
|
|
2843
|
+
t && ue(t);
|
|
2744
2844
|
}), this.onWidthChange());
|
|
2745
2845
|
} else
|
|
2746
2846
|
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2747
|
-
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] })
|
|
2847
|
+
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] }), e.register("scroll_protection", P.moduleName, (n, o) => {
|
|
2848
|
+
this.enableSnapProtection(), o(!0);
|
|
2849
|
+
});
|
|
2748
2850
|
const s = (n) => {
|
|
2749
2851
|
const o = this.doc().scrollLeft;
|
|
2750
2852
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2751
2853
|
};
|
|
2752
|
-
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression",
|
|
2854
|
+
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", P.moduleName, (n, o) => {
|
|
2753
2855
|
const a = n;
|
|
2754
2856
|
if (a < 0 || a > 1) {
|
|
2755
2857
|
e.send("error", {
|
|
@@ -2759,26 +2861,26 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2759
2861
|
}
|
|
2760
2862
|
this.wnd.requestAnimationFrame(() => {
|
|
2761
2863
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2762
|
-
const d = this.cachedScrollWidth, h =
|
|
2763
|
-
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(),
|
|
2864
|
+
const d = this.cachedScrollWidth, h = H(t) ? -1 : 1, u = d * a * h;
|
|
2865
|
+
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), C(this.wnd), o(!0);
|
|
2764
2866
|
});
|
|
2765
|
-
}), e.register("go_id",
|
|
2867
|
+
}), e.register("go_id", P.moduleName, (n, o) => {
|
|
2766
2868
|
const a = t.document.getElementById(n);
|
|
2767
2869
|
if (!a) {
|
|
2768
2870
|
o(!1);
|
|
2769
2871
|
return;
|
|
2770
2872
|
}
|
|
2771
2873
|
this.wnd.requestAnimationFrame(() => {
|
|
2772
|
-
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(),
|
|
2874
|
+
this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + t.scrollX), this.reportProgress(), C(this.wnd), o(!0);
|
|
2773
2875
|
});
|
|
2774
|
-
}), e.register("go_text",
|
|
2876
|
+
}), e.register("go_text", P.moduleName, (n, o) => {
|
|
2775
2877
|
let a;
|
|
2776
2878
|
Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
|
|
2777
|
-
const d =
|
|
2879
|
+
const d = _.deserialize(n), h = pt(this.wnd.document, new W({
|
|
2778
2880
|
href: t.location.href,
|
|
2779
2881
|
type: "text/html",
|
|
2780
2882
|
text: d,
|
|
2781
|
-
locations: a ? new
|
|
2883
|
+
locations: a ? new A({
|
|
2782
2884
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2783
2885
|
["cssSelector", a]
|
|
2784
2886
|
])
|
|
@@ -2789,56 +2891,56 @@ const le = "readium-column-snapper-style", ni = 200, N = class N extends j {
|
|
|
2789
2891
|
return;
|
|
2790
2892
|
}
|
|
2791
2893
|
this.wnd.requestAnimationFrame(() => {
|
|
2792
|
-
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(),
|
|
2894
|
+
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), C(this.wnd), o(!0);
|
|
2793
2895
|
});
|
|
2794
|
-
}), e.register("go_end",
|
|
2795
|
-
const a =
|
|
2896
|
+
}), e.register("go_end", P.moduleName, (n, o) => {
|
|
2897
|
+
const a = H(t) ? -1 : 1;
|
|
2796
2898
|
this.wnd.requestAnimationFrame(() => {
|
|
2797
2899
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2798
2900
|
const d = this.cachedScrollWidth * a;
|
|
2799
2901
|
if (this.doc().scrollLeft === d) return o(!1);
|
|
2800
|
-
this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(),
|
|
2902
|
+
this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), C(this.wnd), o(!0);
|
|
2801
2903
|
});
|
|
2802
|
-
}), e.register("go_start",
|
|
2904
|
+
}), e.register("go_start", P.moduleName, (n, o) => {
|
|
2803
2905
|
this.wnd.requestAnimationFrame(() => {
|
|
2804
2906
|
if (this.doc().scrollLeft === 0) return o(!1);
|
|
2805
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2907
|
+
this.doc().scrollLeft = 0, this.reportProgress(), C(this.wnd), o(!0);
|
|
2806
2908
|
});
|
|
2807
|
-
}), e.register("go_prev",
|
|
2909
|
+
}), e.register("go_prev", P.moduleName, (n, o) => {
|
|
2808
2910
|
this.wnd.requestAnimationFrame(() => {
|
|
2809
2911
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2810
|
-
const a = t.scrollX - t.innerWidth, d =
|
|
2811
|
-
h && (this.reportProgress(),
|
|
2912
|
+
const a = t.scrollX - t.innerWidth, d = H(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = s(Math.max(a, d));
|
|
2913
|
+
h && (this.reportProgress(), C(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(h);
|
|
2812
2914
|
});
|
|
2813
|
-
}), e.register("go_next",
|
|
2915
|
+
}), e.register("go_next", P.moduleName, (n, o) => {
|
|
2814
2916
|
this.wnd.requestAnimationFrame(() => {
|
|
2815
2917
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2816
|
-
const a = t.scrollX + t.innerWidth, d =
|
|
2817
|
-
h && (this.reportProgress(),
|
|
2918
|
+
const a = t.scrollX + t.innerWidth, d = H(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = s(Math.min(a, d));
|
|
2919
|
+
h && (this.reportProgress(), C(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(h);
|
|
2818
2920
|
});
|
|
2819
|
-
}), e.register("unfocus",
|
|
2820
|
-
this.snappingCancelled = !0,
|
|
2821
|
-
}), e.register("shake",
|
|
2921
|
+
}), e.register("unfocus", P.moduleName, (n, o) => {
|
|
2922
|
+
this.snappingCancelled = !0, C(this.wnd), o(!0);
|
|
2923
|
+
}), e.register("shake", P.moduleName, (n, o) => {
|
|
2822
2924
|
this.shake(), o(!0);
|
|
2823
|
-
}), e.register("focus",
|
|
2925
|
+
}), e.register("focus", P.moduleName, (n, o) => {
|
|
2824
2926
|
this.wnd.requestAnimationFrame(() => {
|
|
2825
2927
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2826
2928
|
});
|
|
2827
|
-
}), e.register("first_visible_locator",
|
|
2828
|
-
const a =
|
|
2929
|
+
}), e.register("first_visible_locator", P.moduleName, (n, o) => {
|
|
2930
|
+
const a = Bt(t, !1);
|
|
2829
2931
|
this.comms.send("first_visible_locator", a.serialize()), o(!0);
|
|
2830
2932
|
}), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
|
|
2831
2933
|
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2832
2934
|
}
|
|
2833
2935
|
unmount(t, e) {
|
|
2834
|
-
return this.snappingCancelled = !0, e.unregisterAll(
|
|
2936
|
+
return this.snappingCancelled = !0, e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isSnapProtectionEnabled = !1), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), t.document.getElementById(pe)?.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
|
|
2835
2937
|
}
|
|
2836
2938
|
};
|
|
2837
|
-
|
|
2838
|
-
let
|
|
2839
|
-
const
|
|
2939
|
+
P.moduleName = "column_snapper";
|
|
2940
|
+
let Ct = P;
|
|
2941
|
+
const me = "readium-scroll-snapper-style", N = class N extends st {
|
|
2840
2942
|
constructor() {
|
|
2841
|
-
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2943
|
+
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
|
|
2842
2944
|
if (this.comms.ready && !this.isResizing) {
|
|
2843
2945
|
if (!this.initialScrollHandled) {
|
|
2844
2946
|
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
@@ -2846,8 +2948,26 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
|
|
|
2846
2948
|
}
|
|
2847
2949
|
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2848
2950
|
this.reportProgress();
|
|
2849
|
-
const
|
|
2850
|
-
this.lastScrollTop =
|
|
2951
|
+
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
2952
|
+
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
2953
|
+
const s = Date.now(), n = s - (this.lastScrollTime || s);
|
|
2954
|
+
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
2955
|
+
i > 0 ? "down" : "up",
|
|
2956
|
+
Math.abs(i),
|
|
2957
|
+
n
|
|
2958
|
+
)) {
|
|
2959
|
+
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
2960
|
+
this.comms?.send("content_protection", {
|
|
2961
|
+
type: "suspicious_scrolling",
|
|
2962
|
+
timestamp: Date.now(),
|
|
2963
|
+
scrollDelta: i,
|
|
2964
|
+
scrollDirection: i > 0 ? "down" : "up",
|
|
2965
|
+
targetElement: a
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
this.lastScrollTime = s;
|
|
2969
|
+
}
|
|
2970
|
+
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
2851
2971
|
}));
|
|
2852
2972
|
}
|
|
2853
2973
|
};
|
|
@@ -2863,10 +2983,13 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
|
|
|
2863
2983
|
end: n
|
|
2864
2984
|
});
|
|
2865
2985
|
}
|
|
2986
|
+
enableScrollProtection() {
|
|
2987
|
+
this.patternAnalyzer || (this.patternAnalyzer = new Ht(Re), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
2988
|
+
}
|
|
2866
2989
|
mount(t, e) {
|
|
2867
2990
|
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "scrolling");
|
|
2868
2991
|
const i = t.document.createElement("style");
|
|
2869
|
-
return i.dataset.readium = "true", i.id =
|
|
2992
|
+
return i.dataset.readium = "true", i.id = me, i.textContent = `
|
|
2870
2993
|
* {
|
|
2871
2994
|
scrollbar-width: none; /* for Firefox */
|
|
2872
2995
|
}
|
|
@@ -2878,11 +3001,11 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
|
|
|
2878
3001
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2879
3002
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2880
3003
|
}, 50);
|
|
2881
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
2882
|
-
|
|
3004
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", N.moduleName, () => {
|
|
3005
|
+
Ne(this.wnd);
|
|
2883
3006
|
const s = this.doc().scrollTop;
|
|
2884
3007
|
s > 1 ? this.doc().scrollTop = s - 1 : this.doc().scrollTop = s + 1, this.doc().scrollTop = s;
|
|
2885
|
-
}), e.register("go_progression",
|
|
3008
|
+
}), e.register("go_progression", N.moduleName, (s, n) => {
|
|
2886
3009
|
const o = s;
|
|
2887
3010
|
if (o < 0 || o > 1) {
|
|
2888
3011
|
e.send("error", {
|
|
@@ -2891,25 +3014,25 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
|
|
|
2891
3014
|
return;
|
|
2892
3015
|
}
|
|
2893
3016
|
this.wnd.requestAnimationFrame(() => {
|
|
2894
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(),
|
|
3017
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), C(this.wnd), n(!0);
|
|
2895
3018
|
});
|
|
2896
|
-
}), e.register("go_id",
|
|
3019
|
+
}), e.register("go_id", N.moduleName, (s, n) => {
|
|
2897
3020
|
const o = t.document.getElementById(s);
|
|
2898
3021
|
if (!o) {
|
|
2899
3022
|
n(!1);
|
|
2900
3023
|
return;
|
|
2901
3024
|
}
|
|
2902
3025
|
this.wnd.requestAnimationFrame(() => {
|
|
2903
|
-
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3026
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), n(!0);
|
|
2904
3027
|
});
|
|
2905
|
-
}), e.register("go_text",
|
|
3028
|
+
}), e.register("go_text", N.moduleName, (s, n) => {
|
|
2906
3029
|
let o;
|
|
2907
3030
|
Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
|
|
2908
|
-
const a =
|
|
3031
|
+
const a = _.deserialize(s), d = pt(this.wnd.document, new W({
|
|
2909
3032
|
href: t.location.href,
|
|
2910
3033
|
type: "text/html",
|
|
2911
3034
|
text: a,
|
|
2912
|
-
locations: o ? new
|
|
3035
|
+
locations: o ? new A({
|
|
2913
3036
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2914
3037
|
["cssSelector", o]
|
|
2915
3038
|
])
|
|
@@ -2920,35 +3043,37 @@ const ce = "readium-scroll-snapper-style", O = class O extends j {
|
|
|
2920
3043
|
return;
|
|
2921
3044
|
}
|
|
2922
3045
|
this.wnd.requestAnimationFrame(() => {
|
|
2923
|
-
this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3046
|
+
this.doc().scrollTop = d.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), n(!0);
|
|
2924
3047
|
});
|
|
2925
|
-
}), e.register("go_start",
|
|
3048
|
+
}), e.register("go_start", N.moduleName, (s, n) => {
|
|
2926
3049
|
if (this.doc().scrollTop === 0) return n(!1);
|
|
2927
3050
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
2928
|
-
}), e.register("go_end",
|
|
3051
|
+
}), e.register("go_end", N.moduleName, (s, n) => {
|
|
2929
3052
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return n(!1);
|
|
2930
3053
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
2931
|
-
}), e.register("unfocus",
|
|
2932
|
-
|
|
3054
|
+
}), e.register("unfocus", N.moduleName, (s, n) => {
|
|
3055
|
+
C(this.wnd), n(!0);
|
|
3056
|
+
}), e.register("scroll_protection", N.moduleName, (s, n) => {
|
|
3057
|
+
this.enableScrollProtection(), n(!0);
|
|
2933
3058
|
}), e.register([
|
|
2934
3059
|
"go_next",
|
|
2935
3060
|
"go_prev"
|
|
2936
|
-
],
|
|
3061
|
+
], N.moduleName, (s, n) => n(!1)), e.register("focus", N.moduleName, (s, n) => {
|
|
2937
3062
|
this.reportProgress(), n(!0);
|
|
2938
|
-
}), e.register("first_visible_locator",
|
|
2939
|
-
const o =
|
|
3063
|
+
}), e.register("first_visible_locator", N.moduleName, (s, n) => {
|
|
3064
|
+
const o = Bt(t, !0);
|
|
2940
3065
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2941
3066
|
}), e.log("ScrollSnapper Mounted"), !0;
|
|
2942
3067
|
}
|
|
2943
3068
|
unmount(t, e) {
|
|
2944
|
-
return e.unregisterAll(
|
|
3069
|
+
return e.unregisterAll(N.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), t.document.getElementById(me)?.remove(), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("ScrollSnapper Unmounted"), !0;
|
|
2945
3070
|
}
|
|
2946
3071
|
};
|
|
2947
|
-
|
|
2948
|
-
let
|
|
2949
|
-
const
|
|
3072
|
+
N.moduleName = "scroll_snapper";
|
|
3073
|
+
let xt = N;
|
|
3074
|
+
const L = class L extends st {
|
|
2950
3075
|
constructor() {
|
|
2951
|
-
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
3076
|
+
super(...arguments), this.patternAnalyzer = null, this.lastScrollTime = 0, this.isScrollProtectionEnabled = !1, this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = (t) => {
|
|
2952
3077
|
if (this.comms.ready && !this.isResizing) {
|
|
2953
3078
|
if (!this.initialScrollHandled) {
|
|
2954
3079
|
this.lastScrollTop = this.doc().scrollTop, this.initialScrollHandled = !0, this.reportProgress();
|
|
@@ -2956,8 +3081,26 @@ const P = class P extends j {
|
|
|
2956
3081
|
}
|
|
2957
3082
|
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2958
3083
|
this.reportProgress();
|
|
2959
|
-
const
|
|
2960
|
-
this.lastScrollTop =
|
|
3084
|
+
const e = this.doc().scrollTop, i = e - this.lastScrollTop;
|
|
3085
|
+
if (this.lastScrollTop = e, this.isScrollProtectionEnabled && Math.abs(i) > 5) {
|
|
3086
|
+
const s = Date.now(), n = s - (this.lastScrollTime || s);
|
|
3087
|
+
if (this.patternAnalyzer && this.patternAnalyzer.analyze(
|
|
3088
|
+
i > 0 ? "down" : "up",
|
|
3089
|
+
Math.abs(i),
|
|
3090
|
+
n
|
|
3091
|
+
)) {
|
|
3092
|
+
const a = t.target && "tagName" in t.target ? { tagName: t.target.tagName } : null;
|
|
3093
|
+
this.comms?.send("content_protection", {
|
|
3094
|
+
type: "suspicious_scrolling",
|
|
3095
|
+
timestamp: Date.now(),
|
|
3096
|
+
scrollDelta: i,
|
|
3097
|
+
scrollDirection: i > 0 ? "down" : "up",
|
|
3098
|
+
targetElement: a
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3101
|
+
this.lastScrollTime = s;
|
|
3102
|
+
}
|
|
3103
|
+
this.comms.send("scroll", i), this.isScrolling = !1;
|
|
2961
3104
|
}));
|
|
2962
3105
|
}
|
|
2963
3106
|
};
|
|
@@ -2973,16 +3116,19 @@ const P = class P extends j {
|
|
|
2973
3116
|
end: n
|
|
2974
3117
|
});
|
|
2975
3118
|
}
|
|
3119
|
+
enableScrollProtection() {
|
|
3120
|
+
this.patternAnalyzer || (this.patternAnalyzer = new Ht(Re), this.isScrollProtectionEnabled = !0, this.comms?.log("Scroll protection enabled"));
|
|
3121
|
+
}
|
|
2976
3122
|
mount(t, e) {
|
|
2977
3123
|
return this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), this.resizeObserver = new ResizeObserver(() => {
|
|
2978
3124
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2979
3125
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2980
3126
|
}, 50);
|
|
2981
|
-
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc",
|
|
2982
|
-
|
|
3127
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", L.moduleName, () => {
|
|
3128
|
+
Ne(this.wnd);
|
|
2983
3129
|
const i = this.doc().scrollTop;
|
|
2984
3130
|
i > 1 ? this.doc().scrollTop = i - 1 : this.doc().scrollTop = i + 1, this.doc().scrollTop = i;
|
|
2985
|
-
}), e.register("go_progression",
|
|
3131
|
+
}), e.register("go_progression", L.moduleName, (i, s) => {
|
|
2986
3132
|
const n = i;
|
|
2987
3133
|
if (n < 0 || n > 1) {
|
|
2988
3134
|
e.send("error", {
|
|
@@ -2991,25 +3137,25 @@ const P = class P extends j {
|
|
|
2991
3137
|
return;
|
|
2992
3138
|
}
|
|
2993
3139
|
this.wnd.requestAnimationFrame(() => {
|
|
2994
|
-
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(),
|
|
3140
|
+
this.doc().scrollTop = this.doc().offsetHeight * n, this.reportProgress(), C(this.wnd), s(!0);
|
|
2995
3141
|
});
|
|
2996
|
-
}),
|
|
3142
|
+
}), e.register("go_id", L.moduleName, (i, s) => {
|
|
2997
3143
|
const n = t.document.getElementById(i);
|
|
2998
3144
|
if (!n) {
|
|
2999
3145
|
s(!1);
|
|
3000
3146
|
return;
|
|
3001
3147
|
}
|
|
3002
3148
|
this.wnd.requestAnimationFrame(() => {
|
|
3003
|
-
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3149
|
+
this.doc().scrollTop = n.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), s(!0);
|
|
3004
3150
|
});
|
|
3005
|
-
}), e.register("go_text",
|
|
3151
|
+
}), e.register("go_text", L.moduleName, (i, s) => {
|
|
3006
3152
|
let n;
|
|
3007
3153
|
Array.isArray(i) && (i.length > 1 && (n = i[1]), i = i[0]);
|
|
3008
|
-
const o =
|
|
3154
|
+
const o = _.deserialize(i), a = pt(this.wnd.document, new W({
|
|
3009
3155
|
href: t.location.href,
|
|
3010
3156
|
type: "text/html",
|
|
3011
3157
|
text: o,
|
|
3012
|
-
locations: n ? new
|
|
3158
|
+
locations: n ? new A({
|
|
3013
3159
|
otherLocations: /* @__PURE__ */ new Map([
|
|
3014
3160
|
["cssSelector", n]
|
|
3015
3161
|
])
|
|
@@ -3020,35 +3166,330 @@ const P = class P extends j {
|
|
|
3020
3166
|
return;
|
|
3021
3167
|
}
|
|
3022
3168
|
this.wnd.requestAnimationFrame(() => {
|
|
3023
|
-
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(),
|
|
3169
|
+
this.doc().scrollTop = a.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), C(this.wnd), s(!0);
|
|
3024
3170
|
});
|
|
3025
|
-
}), e.register("go_start",
|
|
3171
|
+
}), e.register("go_start", L.moduleName, (i, s) => {
|
|
3026
3172
|
if (this.doc().scrollTop === 0) return s(!1);
|
|
3027
3173
|
this.doc().scrollTop = 0, this.reportProgress(), s(!0);
|
|
3028
|
-
}), e.register("go_end",
|
|
3174
|
+
}), e.register("go_end", L.moduleName, (i, s) => {
|
|
3029
3175
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight) return s(!1);
|
|
3030
3176
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), s(!0);
|
|
3031
|
-
}), e.register("unfocus",
|
|
3032
|
-
|
|
3177
|
+
}), e.register("unfocus", L.moduleName, (i, s) => {
|
|
3178
|
+
C(this.wnd), s(!0);
|
|
3179
|
+
}), e.register("scroll_protection", L.moduleName, (i, s) => {
|
|
3180
|
+
this.enableScrollProtection(), s(!0);
|
|
3033
3181
|
}), e.register([
|
|
3034
3182
|
"go_next",
|
|
3035
3183
|
"go_prev"
|
|
3036
|
-
],
|
|
3184
|
+
], L.moduleName, (i, s) => s(!1)), e.register("focus", L.moduleName, (i, s) => {
|
|
3037
3185
|
this.reportProgress(), s(!0);
|
|
3038
|
-
}), e.register("first_visible_locator",
|
|
3039
|
-
const n =
|
|
3186
|
+
}), e.register("first_visible_locator", L.moduleName, (i, s) => {
|
|
3187
|
+
const n = Bt(t, !0);
|
|
3040
3188
|
e.send("first_visible_locator", n.serialize()), s(!0);
|
|
3041
3189
|
}), e.log("WebPubSnapper Mounted"), !0;
|
|
3042
3190
|
}
|
|
3043
3191
|
unmount(t, e) {
|
|
3044
|
-
return e.unregisterAll(
|
|
3192
|
+
return e.unregisterAll(L.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), this.patternAnalyzer && (this.patternAnalyzer.clear(), this.patternAnalyzer = null, this.isScrollProtectionEnabled = !1), e.log("WebPubSnapper Unmounted"), !0;
|
|
3045
3193
|
}
|
|
3046
3194
|
};
|
|
3047
|
-
|
|
3048
|
-
let
|
|
3049
|
-
|
|
3195
|
+
L.moduleName = "webpub_snapper";
|
|
3196
|
+
let Tt = L;
|
|
3197
|
+
class fi {
|
|
3198
|
+
constructor(t, e) {
|
|
3199
|
+
this.window = t, this.copyHistory = [], this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.options = e;
|
|
3200
|
+
}
|
|
3201
|
+
cleanupOldHistory(t) {
|
|
3202
|
+
this.copyHistory = this.copyHistory.filter(
|
|
3203
|
+
(i) => t - i.timestamp < 1e4
|
|
3204
|
+
), this.copyHistory.length > this.options.historySize && (this.copyHistory = this.copyHistory.slice(-this.options.historySize));
|
|
3205
|
+
}
|
|
3206
|
+
isSuspiciousPattern(t) {
|
|
3207
|
+
return this.copyHistory.length < 3 ? !1 : this.copyHistory.filter(
|
|
3208
|
+
(s) => t - s.timestamp < 2e3
|
|
3209
|
+
// Last 2 seconds
|
|
3210
|
+
).length >= 3 ? !0 : this.copyHistory.slice().sort((s, n) => s.timestamp - n.timestamp).every((s, n, o) => n === 0 ? !0 : s.length > o[n - 1].length * 1.5);
|
|
3211
|
+
}
|
|
3212
|
+
shouldAllowCopy(t) {
|
|
3213
|
+
if (!this.options.enabled) return !0;
|
|
3214
|
+
const e = this.window.getSelection();
|
|
3215
|
+
if (!e) return !0;
|
|
3216
|
+
const s = e.toString().length, n = this.window.document.body.innerText.length, o = Date.now();
|
|
3217
|
+
if (this.cleanupOldHistory(o), s < this.options.minThreshold)
|
|
3218
|
+
return this.copyHistory.push({
|
|
3219
|
+
timestamp: o,
|
|
3220
|
+
length: s,
|
|
3221
|
+
wasBlocked: !1
|
|
3222
|
+
}), !0;
|
|
3223
|
+
const d = o - this.lastSelectionTime < 100 && s > this.lastSelectionLength * 1.5, h = Math.min(
|
|
3224
|
+
n * this.options.maxSelectionPercent,
|
|
3225
|
+
this.options.absoluteMaxChars
|
|
3226
|
+
), u = this.isSuspiciousPattern(o), g = s > h || d || u;
|
|
3227
|
+
return this.copyHistory.push({
|
|
3228
|
+
timestamp: o,
|
|
3229
|
+
length: s,
|
|
3230
|
+
wasBlocked: g
|
|
3231
|
+
}), g ? (t?.preventDefault(), !1) : (this.lastSelectionLength = s, this.lastSelectionTime = o, !0);
|
|
3232
|
+
}
|
|
3233
|
+
destroy() {
|
|
3234
|
+
this.lastSelectionLength = 0, this.lastSelectionTime = 0, this.copyHistory = [], this.options.enabled = !1;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
class gi {
|
|
3238
|
+
constructor(t = Ie) {
|
|
3239
|
+
this.options = t, this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3240
|
+
}
|
|
3241
|
+
analyze(t) {
|
|
3242
|
+
if (!t)
|
|
3243
|
+
return this.clear(), !1;
|
|
3244
|
+
const e = t.toString();
|
|
3245
|
+
if (e.length === 0)
|
|
3246
|
+
return this.clear(), !1;
|
|
3247
|
+
if (t.type !== "Range" || !t.rangeCount)
|
|
3248
|
+
return !1;
|
|
3249
|
+
const i = Date.now();
|
|
3250
|
+
if (e.length <= 50 || e === this.lastSelectedText)
|
|
3251
|
+
return !1;
|
|
3252
|
+
if (this.selectionStartTime === 0)
|
|
3253
|
+
return this.selectionStartTime = i, this.lastSelectedText = e, !1;
|
|
3254
|
+
if (i - this.selectionStartTime < 500)
|
|
3255
|
+
return !1;
|
|
3256
|
+
i - this.lastSelectionTime > 1e3 && (this.lastSelectionTime = i), this.selectionStartTime === 0 && (this.selectionStartTime = i), this.lastSelectedText = e;
|
|
3257
|
+
const n = this.analyzeSelectionPattern(t, i);
|
|
3258
|
+
return this.cleanup(i), n;
|
|
3259
|
+
}
|
|
3260
|
+
analyzeSelectionPattern(t, e) {
|
|
3261
|
+
if (!t.rangeCount) return !1;
|
|
3262
|
+
const i = t.getRangeAt(0), s = i.toString(), n = (e - this.selectionStartTime) / 1e3;
|
|
3263
|
+
if (s.length / Math.max(1, n) > this.options.maxSelectionsPerSecond) return !0;
|
|
3264
|
+
const a = i.startOffset, d = Math.abs(a - this.lastSelectionPosition);
|
|
3265
|
+
return this.selectionPatterns.push(d), this.selectionPatterns.length > this.options.historySize && (this.selectionPatterns.shift(), this.calculateVariance(this.selectionPatterns) < this.options.minVariance) ? !0 : (this.lastSelectionPosition = a, !1);
|
|
3266
|
+
}
|
|
3267
|
+
calculateVariance(t) {
|
|
3268
|
+
if (t.length === 0) return 0;
|
|
3269
|
+
const e = t.reduce((i, s) => i + s, 0) / t.length;
|
|
3270
|
+
return t.reduce((i, s) => i + Math.pow(s - e, 2), 0) / t.length;
|
|
3271
|
+
}
|
|
3272
|
+
cleanup(t) {
|
|
3273
|
+
this.events = this.events.filter((e) => t - e.timestamp <= 1e3);
|
|
3274
|
+
}
|
|
3275
|
+
clear() {
|
|
3276
|
+
this.events = [], this.selectionStartTime = 0, this.lastSelectionTime = 0, this.lastSelectionPosition = 0, this.selectionPatterns = [], this.lastSelectedText = "";
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
class yi {
|
|
3280
|
+
/**
|
|
3281
|
+
* Checks if the given keyboard event matches any of the provided key combinations
|
|
3282
|
+
*/
|
|
3283
|
+
match(t, e) {
|
|
3284
|
+
for (const i of e) {
|
|
3285
|
+
const s = t.keyCode === i.keyCode, n = i.ctrl === void 0 || t.ctrlKey === i.ctrl, o = i.shift === void 0 || t.shiftKey === i.shift, a = i.alt === void 0 || t.altKey === i.alt, d = i.meta === void 0 || t.metaKey === i.meta;
|
|
3286
|
+
if (s && n && o && a && d)
|
|
3287
|
+
return !0;
|
|
3288
|
+
}
|
|
3289
|
+
return !1;
|
|
3290
|
+
}
|
|
3291
|
+
/**
|
|
3292
|
+
* Creates an event handler that will call the provided handler when any of the key combinations match
|
|
3293
|
+
*/
|
|
3294
|
+
createKeyHandler(t, e) {
|
|
3295
|
+
return (i) => {
|
|
3296
|
+
this.match(i, t) && (i.preventDefault(), i.stopPropagation(), e(i));
|
|
3297
|
+
};
|
|
3298
|
+
}
|
|
3299
|
+
/**
|
|
3300
|
+
* Creates a standardized activity event for keyboard shortcuts
|
|
3301
|
+
*/
|
|
3302
|
+
createActivityEvent(t, e, i, s) {
|
|
3303
|
+
let n;
|
|
3304
|
+
if (s) {
|
|
3305
|
+
const o = s.getSelection(), a = o?.toString() || "", h = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
|
|
3306
|
+
h && a && (n = {
|
|
3307
|
+
text: a,
|
|
3308
|
+
x: h.x,
|
|
3309
|
+
y: h.y,
|
|
3310
|
+
width: h.width,
|
|
3311
|
+
height: h.height
|
|
3312
|
+
});
|
|
3313
|
+
}
|
|
3314
|
+
return {
|
|
3315
|
+
type: e,
|
|
3316
|
+
timestamp: Date.now(),
|
|
3317
|
+
key: t.key,
|
|
3318
|
+
code: t.code,
|
|
3319
|
+
keyCode: t.keyCode,
|
|
3320
|
+
ctrlKey: t.ctrlKey,
|
|
3321
|
+
altKey: t.altKey,
|
|
3322
|
+
shiftKey: t.shiftKey,
|
|
3323
|
+
metaKey: t.metaKey,
|
|
3324
|
+
targetFrameSrc: i,
|
|
3325
|
+
selectedText: n
|
|
3326
|
+
};
|
|
3327
|
+
}
|
|
3328
|
+
/**
|
|
3329
|
+
* Creates handlers for keyboard shortcuts with centralized activity event dispatch
|
|
3330
|
+
*/
|
|
3331
|
+
createKeyboardHandlers(t, e, i, s) {
|
|
3332
|
+
const n = [];
|
|
3333
|
+
return e.forEach((o) => {
|
|
3334
|
+
n.push(...o.keyCombos.map((a) => ({
|
|
3335
|
+
...a,
|
|
3336
|
+
handler: (d) => {
|
|
3337
|
+
const h = o.type, u = this.createActivityEvent(d, h, t, s);
|
|
3338
|
+
i(u);
|
|
3339
|
+
}
|
|
3340
|
+
})));
|
|
3341
|
+
}), n;
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Creates a unified keyboard event handler that processes all shortcuts
|
|
3345
|
+
*/
|
|
3346
|
+
createUnifiedHandler(t, e, i, s) {
|
|
3347
|
+
const n = this.createKeyboardHandlers(t, e, i, s);
|
|
3348
|
+
return (o) => {
|
|
3349
|
+
for (const a of n)
|
|
3350
|
+
if (this.match(o, [a])) {
|
|
3351
|
+
o.preventDefault(), o.stopPropagation(), a.handler(o);
|
|
3352
|
+
return;
|
|
3353
|
+
}
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
const $ = class $ extends X {
|
|
3050
3358
|
constructor() {
|
|
3051
|
-
super(...arguments), this.
|
|
3359
|
+
super(...arguments), this.configApplied = !1, this.cleanupCallbacks = [], this.pointerMoved = !1, this.isContextMenuEnabled = !1, this.isDragAndDropEnabled = !1, this.isSelectionMonitoringEnabled = !1, this.isBulkCopyProtectionEnabled = !1, this.selectionAnalyzer = null, this.currentSelection = null, this.bulkCopyProtector = null, this.keyManager = new yi(), this.keyDownHandler = null, this.preventBulkCopy = (t) => {
|
|
3360
|
+
if (!this.isBulkCopyProtectionEnabled || !this.bulkCopyProtector)
|
|
3361
|
+
return !0;
|
|
3362
|
+
if (!this.bulkCopyProtector.shouldAllowCopy(t)) {
|
|
3363
|
+
t.preventDefault();
|
|
3364
|
+
const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i ? e?.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3365
|
+
type: "bulk_copy",
|
|
3366
|
+
timestamp: Date.now(),
|
|
3367
|
+
clipboardTypes: t.clipboardData?.types ? [...t.clipboardData.types] : [],
|
|
3368
|
+
selectedText: n ? {
|
|
3369
|
+
text: i,
|
|
3370
|
+
x: n.x,
|
|
3371
|
+
y: n.y,
|
|
3372
|
+
width: n.width,
|
|
3373
|
+
height: n.height
|
|
3374
|
+
} : void 0,
|
|
3375
|
+
selectionLength: i.length,
|
|
3376
|
+
targetFrameSrc: this.wnd.location.href
|
|
3377
|
+
};
|
|
3378
|
+
return this.comms?.send("content_protection", o), !1;
|
|
3379
|
+
}
|
|
3380
|
+
return !0;
|
|
3381
|
+
}, this.handleSelection = (t) => {
|
|
3382
|
+
if (!this.isSelectionMonitoringEnabled || !this.wnd || !this.selectionAnalyzer)
|
|
3383
|
+
return;
|
|
3384
|
+
const e = this.wnd.getSelection();
|
|
3385
|
+
if (e) {
|
|
3386
|
+
if (this.currentSelection = e.toString(), this.selectionAnalyzer.analyze(e) && this.currentSelection) {
|
|
3387
|
+
const s = this.wnd.getSelection(), n = s?.toString() || "", a = (n && s?.rangeCount ? s.getRangeAt(0)?.getClientRects() : null)?.[0], d = {
|
|
3388
|
+
type: "suspicious_selection",
|
|
3389
|
+
timestamp: Date.now(),
|
|
3390
|
+
selectionLength: n.length,
|
|
3391
|
+
selectedText: {
|
|
3392
|
+
text: n,
|
|
3393
|
+
x: a?.x ?? 0,
|
|
3394
|
+
y: a?.y ?? 0,
|
|
3395
|
+
width: a?.width ?? 0,
|
|
3396
|
+
height: a?.height ?? 0
|
|
3397
|
+
},
|
|
3398
|
+
eventType: t?.type || "selectionchange",
|
|
3399
|
+
targetFrameSrc: this.wnd.location.href
|
|
3400
|
+
};
|
|
3401
|
+
this.comms?.send("content_protection", d);
|
|
3402
|
+
}
|
|
3403
|
+
} else
|
|
3404
|
+
this.currentSelection = null;
|
|
3405
|
+
}, this.onDragStart = (t) => {
|
|
3406
|
+
if (this.isDragAndDropEnabled) {
|
|
3407
|
+
t.preventDefault();
|
|
3408
|
+
const e = {
|
|
3409
|
+
type: "drag_detected",
|
|
3410
|
+
timestamp: Date.now(),
|
|
3411
|
+
dataTransferTypes: t.dataTransfer?.types ? [...t.dataTransfer.types] : [],
|
|
3412
|
+
targetFrameSrc: this.wnd.location.href
|
|
3413
|
+
};
|
|
3414
|
+
return this.comms?.send("content_protection", e), !1;
|
|
3415
|
+
} else
|
|
3416
|
+
return !0;
|
|
3417
|
+
}, this.onDrop = (t) => {
|
|
3418
|
+
if (this.isDragAndDropEnabled) {
|
|
3419
|
+
t.preventDefault();
|
|
3420
|
+
const e = t.dataTransfer, i = {
|
|
3421
|
+
type: "drop_detected",
|
|
3422
|
+
timestamp: Date.now(),
|
|
3423
|
+
dataTransferTypes: e?.types ? [...e.types] : [],
|
|
3424
|
+
fileCount: e?.files?.length || 0,
|
|
3425
|
+
targetFrameSrc: this.wnd.location.href
|
|
3426
|
+
};
|
|
3427
|
+
return this.comms?.send("content_protection", i), !1;
|
|
3428
|
+
} else
|
|
3429
|
+
return !0;
|
|
3430
|
+
}, this.onContext = (t) => {
|
|
3431
|
+
if (this.isContextMenuEnabled) {
|
|
3432
|
+
t.preventDefault();
|
|
3433
|
+
const e = this.wnd.getSelection(), i = e?.toString() || "", n = (i && e?.rangeCount ? e.getRangeAt(0)?.getClientRects() : null)?.[0], o = {
|
|
3434
|
+
timestamp: Date.now(),
|
|
3435
|
+
clientX: t.clientX,
|
|
3436
|
+
clientY: t.clientY,
|
|
3437
|
+
...n && {
|
|
3438
|
+
selectedText: {
|
|
3439
|
+
text: i,
|
|
3440
|
+
x: n.x,
|
|
3441
|
+
y: n.y,
|
|
3442
|
+
width: n.width,
|
|
3443
|
+
height: n.height
|
|
3444
|
+
}
|
|
3445
|
+
},
|
|
3446
|
+
targetFrameSrc: this.wnd.location.href
|
|
3447
|
+
};
|
|
3448
|
+
this.comms?.send("context_menu", o);
|
|
3449
|
+
}
|
|
3450
|
+
}, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onClicker = this.onClick.bind(this);
|
|
3451
|
+
}
|
|
3452
|
+
addContextMenuPrevention() {
|
|
3453
|
+
this.isContextMenuEnabled || !this.wnd || (this.wnd.document.addEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !0);
|
|
3454
|
+
}
|
|
3455
|
+
removeContextMenuPrevention() {
|
|
3456
|
+
!this.isContextMenuEnabled || !this.wnd || (this.wnd.document.removeEventListener("contextmenu", this.onContext), this.isContextMenuEnabled = !1);
|
|
3457
|
+
}
|
|
3458
|
+
addDragAndDropPrevention() {
|
|
3459
|
+
this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.addEventListener("dragstart", this.onDragStart), this.wnd.document.addEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !0);
|
|
3460
|
+
}
|
|
3461
|
+
removeDragAndDropPrevention() {
|
|
3462
|
+
!this.isDragAndDropEnabled || !this.wnd || (this.wnd.document.removeEventListener("dragstart", this.onDragStart), this.wnd.document.removeEventListener("drop", this.onDrop), this.isDragAndDropEnabled = !1);
|
|
3463
|
+
}
|
|
3464
|
+
enableKeyboardPeripherals(t = []) {
|
|
3465
|
+
this.disableKeyboardPeripherals();
|
|
3466
|
+
const e = (i) => {
|
|
3467
|
+
this.comms?.send("keyboard_peripherals", i);
|
|
3468
|
+
};
|
|
3469
|
+
this.keyDownHandler = this.keyManager.createUnifiedHandler(this.wnd.location.href, t, e, this.wnd), this.wnd && this.wnd.document.addEventListener("keydown", this.keyDownHandler, {
|
|
3470
|
+
capture: !0
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
disableKeyboardPeripherals() {
|
|
3474
|
+
this.wnd && this.keyDownHandler && (this.wnd.document.removeEventListener("keydown", this.keyDownHandler, {
|
|
3475
|
+
capture: !0
|
|
3476
|
+
}), this.keyDownHandler = null);
|
|
3477
|
+
}
|
|
3478
|
+
addBulkCopyProtection(t = {}) {
|
|
3479
|
+
if (this.isBulkCopyProtectionEnabled || !this.wnd) return;
|
|
3480
|
+
const e = pi, i = t ? { ...e, ...t } : e;
|
|
3481
|
+
this.bulkCopyProtector = new fi(this.wnd, i), this.wnd.document.addEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.addEventListener("cut", this.preventBulkCopy, !0), this.isBulkCopyProtectionEnabled = !0;
|
|
3482
|
+
}
|
|
3483
|
+
removeBulkCopyProtection() {
|
|
3484
|
+
!this.isBulkCopyProtectionEnabled || !this.wnd || (this.wnd.document.removeEventListener("copy", this.preventBulkCopy, !0), this.wnd.document.removeEventListener("cut", this.preventBulkCopy, !0), this.bulkCopyProtector?.destroy(), this.bulkCopyProtector = null, this.isBulkCopyProtectionEnabled = !1);
|
|
3485
|
+
}
|
|
3486
|
+
addSelectionMonitoring(t) {
|
|
3487
|
+
if (this.isSelectionMonitoringEnabled || !this.wnd) return;
|
|
3488
|
+
const e = t || Ie;
|
|
3489
|
+
this.selectionAnalyzer = new gi(e), this.wnd.document.addEventListener("selectionchange", this.handleSelection), this.isSelectionMonitoringEnabled = !0;
|
|
3490
|
+
}
|
|
3491
|
+
removeSelectionMonitoring() {
|
|
3492
|
+
!this.isSelectionMonitoringEnabled || !this.wnd || (this.wnd.document.removeEventListener("selectionchange", this.handleSelection), this.selectionAnalyzer?.clear(), this.selectionAnalyzer = null, this.isSelectionMonitoringEnabled = !1);
|
|
3052
3493
|
}
|
|
3053
3494
|
onPointUp(t) {
|
|
3054
3495
|
const e = this.wnd.getSelection();
|
|
@@ -3078,7 +3519,7 @@ const Mt = class Mt extends tt {
|
|
|
3078
3519
|
y: t.clientY * i,
|
|
3079
3520
|
targetFrameSrc: this.wnd.location.href,
|
|
3080
3521
|
targetElement: t.target.outerHTML,
|
|
3081
|
-
interactiveElement:
|
|
3522
|
+
interactiveElement: Le(t.target)?.outerHTML,
|
|
3082
3523
|
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
3083
3524
|
}), this.pointerMoved = !1;
|
|
3084
3525
|
}
|
|
@@ -3092,9 +3533,6 @@ const Mt = class Mt extends tt {
|
|
|
3092
3533
|
onPointDown() {
|
|
3093
3534
|
this.pointerMoved = !1;
|
|
3094
3535
|
}
|
|
3095
|
-
onContext(t) {
|
|
3096
|
-
this.onPointUp(t), this.pointerMoved = !1;
|
|
3097
|
-
}
|
|
3098
3536
|
onClick(t) {
|
|
3099
3537
|
if (t.preventDefault(), !t.isTrusted) {
|
|
3100
3538
|
const e = new PointerEvent("pointerup", {
|
|
@@ -3107,16 +3545,40 @@ const Mt = class Mt extends tt {
|
|
|
3107
3545
|
Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
|
|
3108
3546
|
}
|
|
3109
3547
|
}
|
|
3548
|
+
registerProtectionHandlers() {
|
|
3549
|
+
this.comms?.register("peripherals_protection", $.moduleName, (t, e) => {
|
|
3550
|
+
const i = t;
|
|
3551
|
+
if (!this.configApplied) {
|
|
3552
|
+
if (this.configApplied = !0, i.monitorSelection) {
|
|
3553
|
+
const s = typeof i.monitorSelection == "boolean" ? void 0 : i.monitorSelection;
|
|
3554
|
+
this.addSelectionMonitoring(s), this.comms?.log("Selection monitoring enabled");
|
|
3555
|
+
}
|
|
3556
|
+
typeof i.protectCopy == "object" ? (this.addBulkCopyProtection({
|
|
3557
|
+
enabled: !0,
|
|
3558
|
+
...i.protectCopy
|
|
3559
|
+
}), this.comms?.log("Copy protection enabled (limited)")) : i.protectCopy === !0 && (this.addBulkCopyProtection({
|
|
3560
|
+
enabled: !0,
|
|
3561
|
+
maxSelectionPercent: 0,
|
|
3562
|
+
minThreshold: 0,
|
|
3563
|
+
absoluteMaxChars: 0
|
|
3564
|
+
}), this.comms?.log("Copy protection enabled")), i.disableContextMenu && (this.addContextMenuPrevention(), this.comms?.log("Context menu protection enabled")), i.disableDragAndDrop && (this.addDragAndDropPrevention(), this.comms?.log("Drag and drop protection enabled"));
|
|
3565
|
+
}
|
|
3566
|
+
e(!0);
|
|
3567
|
+
}), this.comms?.register("keyboard_peripherals", $.moduleName, (t, e) => {
|
|
3568
|
+
const i = t;
|
|
3569
|
+
i && i.length > 0 && (this.enableKeyboardPeripherals(i), this.comms?.log(`Keyboard peripherals enabled: ${i.map((s) => s.type).join(", ")}`)), e(!0);
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3110
3572
|
mount(t, e) {
|
|
3111
|
-
return this.wnd = t, this.comms = e,
|
|
3573
|
+
return this.wnd = t, this.comms = e, this.registerProtectionHandlers(), t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
|
|
3112
3574
|
}
|
|
3113
3575
|
unmount(t, e) {
|
|
3114
|
-
return
|
|
3576
|
+
return this.removeBulkCopyProtection(), this.removeSelectionMonitoring(), this.removeContextMenuPrevention(), this.removeDragAndDropPrevention(), this.disableKeyboardPeripherals(), this.cleanupCallbacks.forEach((i) => i()), this.cleanupCallbacks = [], t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.unregisterAll($.moduleName), this.configApplied = !1, e.log("Peripherals Unmounted"), !0;
|
|
3115
3577
|
}
|
|
3116
3578
|
};
|
|
3117
|
-
|
|
3118
|
-
let
|
|
3119
|
-
const
|
|
3579
|
+
$.moduleName = "peripherals";
|
|
3580
|
+
let Pt = $;
|
|
3581
|
+
const tt = class tt extends X {
|
|
3120
3582
|
constructor() {
|
|
3121
3583
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
3122
3584
|
}
|
|
@@ -3166,7 +3628,7 @@ const J = class J extends tt {
|
|
|
3166
3628
|
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
3167
3629
|
value: {
|
|
3168
3630
|
name: "readium-ts-toolkit",
|
|
3169
|
-
version: "2.
|
|
3631
|
+
version: "2.3.1-alpha.1",
|
|
3170
3632
|
hasFeature: (s, n = "") => {
|
|
3171
3633
|
switch (s) {
|
|
3172
3634
|
case "dom-manipulation":
|
|
@@ -3191,11 +3653,11 @@ const J = class J extends tt {
|
|
|
3191
3653
|
writable: !1
|
|
3192
3654
|
}), "getAnimations" in t.document && t.document.getAnimations().forEach((s) => {
|
|
3193
3655
|
s.cancel(), this.allAnimations.add(s);
|
|
3194
|
-
}), e.register("activate",
|
|
3656
|
+
}), e.register("activate", tt.moduleName, (s, n) => {
|
|
3195
3657
|
this.allAnimations.forEach((o) => {
|
|
3196
3658
|
o.cancel(), o.play();
|
|
3197
3659
|
}), n(!0);
|
|
3198
|
-
}), e.register("unfocus",
|
|
3660
|
+
}), e.register("unfocus", tt.moduleName, (s, n) => {
|
|
3199
3661
|
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
3200
3662
|
});
|
|
3201
3663
|
const i = t.document.querySelectorAll("audio,video");
|
|
@@ -3213,46 +3675,46 @@ const J = class J extends tt {
|
|
|
3213
3675
|
return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
|
|
3214
3676
|
}
|
|
3215
3677
|
};
|
|
3216
|
-
|
|
3217
|
-
let
|
|
3218
|
-
const
|
|
3678
|
+
tt.moduleName = "setup";
|
|
3679
|
+
let ut = tt;
|
|
3680
|
+
const fe = "readium-viewport", M = class M extends ut {
|
|
3219
3681
|
onViewportWidthChanged(t) {
|
|
3220
3682
|
const e = t.target;
|
|
3221
|
-
|
|
3683
|
+
it(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
3222
3684
|
}
|
|
3223
3685
|
mount(t, e) {
|
|
3224
3686
|
if (!super.mount(t, e)) return !1;
|
|
3225
3687
|
const i = t.document.createElement("meta");
|
|
3226
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
3688
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", fe), i.setAttribute(
|
|
3227
3689
|
"content",
|
|
3228
3690
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
3229
3691
|
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
3230
3692
|
target: t
|
|
3231
3693
|
}), e.register("get_properties", M.moduleName, (s, n) => {
|
|
3232
|
-
|
|
3694
|
+
Ut(t), n(!0);
|
|
3233
3695
|
}), e.register("update_properties", M.moduleName, (s, n) => {
|
|
3234
|
-
s["--RS__viewportWidth"] = `${t.innerWidth}px`,
|
|
3696
|
+
s["--RS__viewportWidth"] = `${t.innerWidth}px`, Te(t, s), n(!0);
|
|
3235
3697
|
}), e.register("set_property", M.moduleName, (s, n) => {
|
|
3236
3698
|
const o = s;
|
|
3237
|
-
|
|
3699
|
+
it(t, o[0], o[1]), n(!0);
|
|
3238
3700
|
}), e.register("remove_property", M.moduleName, (s, n) => {
|
|
3239
|
-
|
|
3701
|
+
mt(t, s), n(!0);
|
|
3240
3702
|
}), e.register("activate", M.moduleName, (s, n) => {
|
|
3241
3703
|
this.unblock(t), n(!0);
|
|
3242
3704
|
}), e.log("ReflowableSetup Mounted"), !0;
|
|
3243
3705
|
}
|
|
3244
3706
|
unmount(t, e) {
|
|
3245
|
-
return e.unregisterAll(M.moduleName), t.document.head.querySelector(`#${
|
|
3707
|
+
return e.unregisterAll(M.moduleName), t.document.head.querySelector(`#${fe}`)?.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
|
|
3246
3708
|
}
|
|
3247
3709
|
};
|
|
3248
3710
|
M.moduleName = "reflowable_setup";
|
|
3249
|
-
let
|
|
3250
|
-
const
|
|
3711
|
+
let Nt = M;
|
|
3712
|
+
const ge = "readium-fixed-style", D = class D extends ut {
|
|
3251
3713
|
mount(t, e) {
|
|
3252
3714
|
if (!super.mount(t, e)) return !1;
|
|
3253
3715
|
t.navigator.epubReadingSystem && (t.navigator.epubReadingSystem.layoutStyle = "paginated");
|
|
3254
3716
|
const i = t.document.createElement("style");
|
|
3255
|
-
return i.id =
|
|
3717
|
+
return i.id = ge, i.dataset.readium = "true", i.textContent = `
|
|
3256
3718
|
html, body {
|
|
3257
3719
|
text-size-adjust: none;
|
|
3258
3720
|
-ms-text-size-adjust: none;
|
|
@@ -3264,13 +3726,13 @@ const ue = "readium-fixed-style", z = class z extends ct {
|
|
|
3264
3726
|
min-height: 100%;
|
|
3265
3727
|
|
|
3266
3728
|
/*cursor: var() TODO*/
|
|
3267
|
-
}`, t.document.head.appendChild(i), e.register("set_property",
|
|
3729
|
+
}`, t.document.head.appendChild(i), e.register("set_property", D.moduleName, (s, n) => {
|
|
3268
3730
|
const o = s;
|
|
3269
|
-
|
|
3270
|
-
}), e.register("remove_property",
|
|
3271
|
-
|
|
3272
|
-
}), e.register("first_visible_locator",
|
|
3273
|
-
|
|
3731
|
+
it(t, o[0], o[1]), n(!0);
|
|
3732
|
+
}), e.register("remove_property", D.moduleName, (s, n) => {
|
|
3733
|
+
mt(t, s), n(!0);
|
|
3734
|
+
}), e.register("first_visible_locator", D.moduleName, (s, n) => n(!1)), e.register("unfocus", D.moduleName, (s, n) => {
|
|
3735
|
+
C(t), n(!0);
|
|
3274
3736
|
}), e.register([
|
|
3275
3737
|
"focus",
|
|
3276
3738
|
"go_next",
|
|
@@ -3280,17 +3742,17 @@ const ue = "readium-fixed-style", z = class z extends ct {
|
|
|
3280
3742
|
"go_start",
|
|
3281
3743
|
"go_text",
|
|
3282
3744
|
"go_progression"
|
|
3283
|
-
],
|
|
3745
|
+
], D.moduleName, (s, n) => n(!0)), e.register("activate", D.moduleName, (s, n) => {
|
|
3284
3746
|
this.unblock(t), n(!0);
|
|
3285
3747
|
}), e.log("FixedSetup Mounted"), !0;
|
|
3286
3748
|
}
|
|
3287
3749
|
unmount(t, e) {
|
|
3288
|
-
return e.unregisterAll(
|
|
3750
|
+
return e.unregisterAll(D.moduleName), t.document.getElementById(ge)?.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
3289
3751
|
}
|
|
3290
3752
|
};
|
|
3291
|
-
|
|
3292
|
-
let
|
|
3293
|
-
const
|
|
3753
|
+
D.moduleName = "fixed_setup";
|
|
3754
|
+
let Lt = D;
|
|
3755
|
+
const k = class k extends X {
|
|
3294
3756
|
wndOnErr(t) {
|
|
3295
3757
|
this.comms?.send("error", {
|
|
3296
3758
|
message: t.message,
|
|
@@ -3304,58 +3766,100 @@ const W = class W extends tt {
|
|
|
3304
3766
|
"error",
|
|
3305
3767
|
this.wndOnErr,
|
|
3306
3768
|
!1
|
|
3307
|
-
), e.register("get_properties",
|
|
3308
|
-
|
|
3309
|
-
}), e.register("update_properties",
|
|
3310
|
-
|
|
3311
|
-
}), e.register("set_property",
|
|
3769
|
+
), e.register("get_properties", k.moduleName, (i, s) => {
|
|
3770
|
+
Ut(t), s(!0);
|
|
3771
|
+
}), e.register("update_properties", k.moduleName, (i, s) => {
|
|
3772
|
+
Te(t, i), s(!0);
|
|
3773
|
+
}), e.register("set_property", k.moduleName, (i, s) => {
|
|
3312
3774
|
const n = i;
|
|
3313
|
-
|
|
3314
|
-
}), e.register("remove_property",
|
|
3315
|
-
|
|
3316
|
-
}), e.register("activate",
|
|
3775
|
+
it(t, n[0], n[1]), s(!0);
|
|
3776
|
+
}), e.register("remove_property", k.moduleName, (i, s) => {
|
|
3777
|
+
mt(t, i), s(!0);
|
|
3778
|
+
}), e.register("activate", k.moduleName, (i, s) => {
|
|
3317
3779
|
s(!0);
|
|
3318
3780
|
}), e.log("WebPubSetup Mounted"), !0;
|
|
3319
3781
|
}
|
|
3320
3782
|
unmount(t, e) {
|
|
3321
|
-
return e.unregisterAll(
|
|
3783
|
+
return e.unregisterAll(k.moduleName), t.removeEventListener("error", this.wndOnErr), e.log("WebPubSetup Unmounted"), !0;
|
|
3322
3784
|
}
|
|
3323
3785
|
};
|
|
3324
|
-
|
|
3325
|
-
let
|
|
3326
|
-
const
|
|
3786
|
+
k.moduleName = "webpub_setup";
|
|
3787
|
+
let Ot = k;
|
|
3788
|
+
const et = class et extends X {
|
|
3789
|
+
constructor() {
|
|
3790
|
+
super(...arguments), this.styleElement = null, this.beforePrintHandler = null, this.configApplied = !1;
|
|
3791
|
+
}
|
|
3792
|
+
setupPrintProtection(t, e) {
|
|
3793
|
+
if (!e.disable) return;
|
|
3794
|
+
const i = t.document.createElement("style");
|
|
3795
|
+
i.textContent = `
|
|
3796
|
+
@media print {
|
|
3797
|
+
body * {
|
|
3798
|
+
display: none !important;
|
|
3799
|
+
}
|
|
3800
|
+
body::after {
|
|
3801
|
+
content: "${e.watermark || "Printing has been disabled"}";
|
|
3802
|
+
font-size: 200%;
|
|
3803
|
+
display: block;
|
|
3804
|
+
text-align: center;
|
|
3805
|
+
margin-top: 50vh;
|
|
3806
|
+
transform: translateY(-50%);
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
`, t.document.head.appendChild(i), this.styleElement = i, this.beforePrintHandler = (s) => (s.preventDefault(), !1), t.addEventListener("beforeprint", this.beforePrintHandler);
|
|
3810
|
+
}
|
|
3811
|
+
registerPrintHandlers() {
|
|
3812
|
+
this.comms?.register("print_protection", et.moduleName, (t) => {
|
|
3813
|
+
const e = t;
|
|
3814
|
+
return this.configApplied || (this.configApplied = !0, this.setupPrintProtection(this.wnd, e), this.comms?.log("Print protection configuration applied")), !0;
|
|
3815
|
+
});
|
|
3816
|
+
}
|
|
3817
|
+
mount(t, e) {
|
|
3818
|
+
return this.wnd = t, this.comms = e, this.registerPrintHandlers(), !0;
|
|
3819
|
+
}
|
|
3820
|
+
unmount(t, e) {
|
|
3821
|
+
return this.beforePrintHandler && (t.removeEventListener("beforeprint", this.beforePrintHandler), this.beforePrintHandler = null), this.styleElement?.parentNode && (this.styleElement.parentNode.removeChild(this.styleElement), this.styleElement = null), this.comms?.unregisterAll(et.moduleName), this.configApplied = !1, !0;
|
|
3822
|
+
}
|
|
3823
|
+
};
|
|
3824
|
+
et.moduleName = "print_protection";
|
|
3825
|
+
let Rt = et;
|
|
3826
|
+
const bi = [
|
|
3327
3827
|
"fixed_setup",
|
|
3328
3828
|
"decorator",
|
|
3329
|
-
"peripherals"
|
|
3330
|
-
|
|
3829
|
+
"peripherals",
|
|
3830
|
+
"print_protection"
|
|
3831
|
+
], wi = [
|
|
3331
3832
|
"reflowable_setup",
|
|
3332
3833
|
"decorator",
|
|
3333
3834
|
"peripherals",
|
|
3334
3835
|
"column_snapper",
|
|
3335
|
-
"scroll_snapper"
|
|
3336
|
-
|
|
3836
|
+
"scroll_snapper",
|
|
3837
|
+
"print_protection"
|
|
3838
|
+
], vi = [
|
|
3337
3839
|
"webpub_setup",
|
|
3338
3840
|
"webpub_snapper",
|
|
3339
3841
|
"decorator",
|
|
3340
|
-
"peripherals"
|
|
3341
|
-
|
|
3842
|
+
"peripherals",
|
|
3843
|
+
"print_protection"
|
|
3844
|
+
], ye = new Map([
|
|
3342
3845
|
// All modules go here
|
|
3846
|
+
Lt,
|
|
3847
|
+
Nt,
|
|
3848
|
+
Ot,
|
|
3343
3849
|
Tt,
|
|
3344
|
-
|
|
3850
|
+
Pt,
|
|
3851
|
+
At,
|
|
3345
3852
|
Ct,
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
yt,
|
|
3349
|
-
wt,
|
|
3350
|
-
At
|
|
3853
|
+
xt,
|
|
3854
|
+
Rt
|
|
3351
3855
|
].map((r) => [r.moduleName, r]));
|
|
3352
|
-
class
|
|
3856
|
+
class Si {
|
|
3353
3857
|
/**
|
|
3354
3858
|
* @param wnd Window instance to operate on
|
|
3355
3859
|
* @param initialModules List of initial modules to load
|
|
3356
3860
|
*/
|
|
3357
3861
|
constructor(t = window, e = []) {
|
|
3358
|
-
this.loadedModules = [], this.wnd = t, this.comms = new
|
|
3862
|
+
this.loadedModules = [], this.wnd = t, this.comms = new Me(t);
|
|
3359
3863
|
const i = [...new Set(e)];
|
|
3360
3864
|
if (i.length) {
|
|
3361
3865
|
if (typeof t > "u")
|
|
@@ -3368,7 +3872,7 @@ class hi {
|
|
|
3368
3872
|
}
|
|
3369
3873
|
}
|
|
3370
3874
|
loadModule(t) {
|
|
3371
|
-
const e =
|
|
3875
|
+
const e = ye.get(t);
|
|
3372
3876
|
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
3373
3877
|
}
|
|
3374
3878
|
/**
|
|
@@ -3386,7 +3890,7 @@ class hi {
|
|
|
3386
3890
|
* @returns Success
|
|
3387
3891
|
*/
|
|
3388
3892
|
removeModule(t) {
|
|
3389
|
-
const e =
|
|
3893
|
+
const e = ye.get(t);
|
|
3390
3894
|
if (e === void 0)
|
|
3391
3895
|
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
3392
3896
|
const i = this.loadedModules.findIndex((s) => s instanceof e);
|
|
@@ -3399,18 +3903,84 @@ class hi {
|
|
|
3399
3903
|
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3400
3904
|
}
|
|
3401
3905
|
}
|
|
3906
|
+
const Ei = {
|
|
3907
|
+
type: "developer_tools",
|
|
3908
|
+
keyCombos: [
|
|
3909
|
+
{ keyCode: 73, meta: !0, alt: !0 },
|
|
3910
|
+
// I key
|
|
3911
|
+
{ keyCode: 74, meta: !0, alt: !0 },
|
|
3912
|
+
// J key
|
|
3913
|
+
{ keyCode: 85, meta: !0, alt: !0 },
|
|
3914
|
+
// U key
|
|
3915
|
+
{ keyCode: 67, meta: !0, alt: !0 },
|
|
3916
|
+
// C key
|
|
3917
|
+
{ keyCode: 67, meta: !0, shift: !0 },
|
|
3918
|
+
// C key (Cmd+Shift+C)
|
|
3919
|
+
{ keyCode: 67, ctrl: !0, shift: !0 },
|
|
3920
|
+
// C key (Ctrl+Shift+C)
|
|
3921
|
+
{ keyCode: 123 },
|
|
3922
|
+
// F12
|
|
3923
|
+
{ keyCode: 123, shift: !0 },
|
|
3924
|
+
// F12+Shift
|
|
3925
|
+
{ keyCode: 123, ctrl: !0, shift: !0 },
|
|
3926
|
+
// F12+Ctrl+Shift
|
|
3927
|
+
{ keyCode: 123, meta: !0, alt: !0 }
|
|
3928
|
+
// F12+Meta+Alt
|
|
3929
|
+
]
|
|
3930
|
+
}, Ai = {
|
|
3931
|
+
type: "select_all",
|
|
3932
|
+
keyCombos: [
|
|
3933
|
+
{ keyCode: 65, meta: !0 },
|
|
3934
|
+
// A key (Cmd+A)
|
|
3935
|
+
{ keyCode: 65, ctrl: !0 }
|
|
3936
|
+
// A key (Ctrl+A)
|
|
3937
|
+
]
|
|
3938
|
+
}, Ci = {
|
|
3939
|
+
type: "print",
|
|
3940
|
+
keyCombos: [
|
|
3941
|
+
{ keyCode: 80, meta: !0 },
|
|
3942
|
+
// P key (Cmd+P)
|
|
3943
|
+
{ keyCode: 80, ctrl: !0 },
|
|
3944
|
+
// P key (Ctrl+P)
|
|
3945
|
+
{ keyCode: 80, meta: !0, shift: !0 },
|
|
3946
|
+
// P key (Cmd+Shift+P)
|
|
3947
|
+
{ keyCode: 80, ctrl: !0, shift: !0 },
|
|
3948
|
+
// P key (Ctrl+Shift+P)
|
|
3949
|
+
{ keyCode: 80, meta: !0, alt: !0 },
|
|
3950
|
+
// P key (Cmd+Alt+P)
|
|
3951
|
+
{ keyCode: 80, ctrl: !0, alt: !0 }
|
|
3952
|
+
// P key (Ctrl+Alt+P)
|
|
3953
|
+
]
|
|
3954
|
+
}, xi = {
|
|
3955
|
+
type: "save",
|
|
3956
|
+
keyCombos: [
|
|
3957
|
+
{ keyCode: 83, meta: !0 },
|
|
3958
|
+
// S key (Cmd+S)
|
|
3959
|
+
{ keyCode: 83, ctrl: !0 }
|
|
3960
|
+
// S key (Ctrl+S)
|
|
3961
|
+
]
|
|
3962
|
+
};
|
|
3402
3963
|
export {
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3964
|
+
fi as BulkCopyProtector,
|
|
3965
|
+
K as COMMS_VERSION,
|
|
3966
|
+
Me as Comms,
|
|
3967
|
+
Ei as DEV_TOOLS,
|
|
3968
|
+
At as Decorator,
|
|
3969
|
+
bi as FXLModules,
|
|
3970
|
+
yi as KeyCombinationManager,
|
|
3971
|
+
ni as Layout,
|
|
3972
|
+
Si as Loader,
|
|
3973
|
+
X as Module,
|
|
3974
|
+
ye as ModuleLibrary,
|
|
3975
|
+
Ci as PRINT,
|
|
3976
|
+
Ht as PatternAnalyzer,
|
|
3977
|
+
Pt as Peripherals,
|
|
3978
|
+
Rt as PrintProtector,
|
|
3979
|
+
wi as ReflowableModules,
|
|
3980
|
+
xi as SAVE,
|
|
3981
|
+
Ai as SELECT_ALL,
|
|
3982
|
+
gi as SelectionAnalyzer,
|
|
3983
|
+
vi as WebPubModules,
|
|
3984
|
+
si as Width,
|
|
3985
|
+
ze as mid
|
|
3416
3986
|
};
|