@internetarchive/bookreader 5.0.0-88-alpha.10 → 5.0.0-88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/BookReader/BookReader.css +3 -3
  2. package/BookReader/BookReader.js +1 -1
  3. package/BookReader/BookReader.js.map +1 -1
  4. package/BookReader/ia-bookreader-bundle.js +87 -108
  5. package/BookReader/ia-bookreader-bundle.js.map +1 -1
  6. package/BookReader/plugins/plugin.archive_analytics.js +1 -1
  7. package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
  8. package/BookReader/plugins/plugin.search.js +1 -1
  9. package/BookReader/plugins/plugin.search.js.map +1 -1
  10. package/BookReader/plugins/plugin.text_selection.js +1 -1
  11. package/BookReader/plugins/plugin.text_selection.js.map +1 -1
  12. package/BookReader/plugins/plugin.tts.js +1 -1
  13. package/BookReader/plugins/plugin.tts.js.map +1 -1
  14. package/BookReader/plugins/plugin.url.js +1 -1
  15. package/BookReader/plugins/plugin.url.js.map +1 -1
  16. package/CHANGELOG.md +4 -0
  17. package/babel.config.js +12 -30
  18. package/jsconfig.json +1 -3
  19. package/package.json +14 -16
  20. package/src/BookNavigator/search/search-results.js +1 -1
  21. package/src/BookReader/Mode1UpLit.js +56 -86
  22. package/src/BookReader/Mode2UpLit.js +2 -3
  23. package/src/BookReader/Navbar/Navbar.js +53 -11
  24. package/src/BookReader/options.js +3 -0
  25. package/src/BookReader.js +49 -1
  26. package/src/BookReaderPlugin.js +28 -0
  27. package/src/css/_BRnav.scss +0 -3
  28. package/src/css/_controls.scss +4 -0
  29. package/src/plugins/plugin.archive_analytics.js +84 -78
  30. package/src/plugins/plugin.chapters.js +17 -22
  31. package/src/plugins/plugin.text_selection.js +1 -1
  32. package/src/plugins/tts/plugin.tts.js +2 -2
  33. package/tests/jest/BookReader/Navbar/Navbar.test.js +16 -3
  34. package/tests/jest/plugins/plugin.archive_analytics.test.js +8 -11
  35. package/dist/esm/BookNavigator/assets/bookmark-colors.js +0 -4
  36. package/dist/esm/BookNavigator/assets/button-base.js +0 -4
  37. package/dist/esm/BookNavigator/assets/ia-logo.js +0 -4
  38. package/dist/esm/BookNavigator/assets/icon_checkmark.js +0 -8
  39. package/dist/esm/BookNavigator/assets/icon_close.js +0 -4
  40. package/dist/esm/BookNavigator/book-navigator.js +0 -612
  41. package/dist/esm/BookNavigator/bookmarks/bookmark-button.js +0 -35
  42. package/dist/esm/BookNavigator/bookmarks/bookmark-edit.js +0 -78
  43. package/dist/esm/BookNavigator/bookmarks/bookmarks-list.js +0 -160
  44. package/dist/esm/BookNavigator/bookmarks/bookmarks-loginCTA.js +0 -24
  45. package/dist/esm/BookNavigator/bookmarks/bookmarks-provider.js +0 -55
  46. package/dist/esm/BookNavigator/bookmarks/ia-bookmarks.js +0 -521
  47. package/dist/esm/BookNavigator/delete-modal-actions.js +0 -29
  48. package/dist/esm/BookNavigator/downloads/downloads-provider.js +0 -84
  49. package/dist/esm/BookNavigator/downloads/downloads.js +0 -69
  50. package/dist/esm/BookNavigator/search/search-provider.js +0 -238
  51. package/dist/esm/BookNavigator/search/search-results.js +0 -161
  52. package/dist/esm/BookNavigator/sharing.js +0 -26
  53. package/dist/esm/BookNavigator/viewable-files.js +0 -94
  54. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments-provider.js +0 -83
  55. package/dist/esm/BookNavigator/visual-adjustments/visual-adjustments.js +0 -131
  56. package/dist/esm/BookReader/BookModel.js +0 -575
  57. package/dist/esm/BookReader/DragScrollable.js +0 -224
  58. package/dist/esm/BookReader/ImageCache.js +0 -122
  59. package/dist/esm/BookReader/Mode1Up.js +0 -114
  60. package/dist/esm/BookReader/Mode1UpLit.js +0 -579
  61. package/dist/esm/BookReader/Mode2Up.js +0 -106
  62. package/dist/esm/BookReader/Mode2UpLit.js +0 -1020
  63. package/dist/esm/BookReader/ModeCoordinateSpace.js +0 -28
  64. package/dist/esm/BookReader/ModeSmoothZoom.js +0 -318
  65. package/dist/esm/BookReader/ModeThumb.js +0 -366
  66. package/dist/esm/BookReader/Navbar/Navbar.js +0 -253
  67. package/dist/esm/BookReader/PageContainer.js +0 -165
  68. package/dist/esm/BookReader/ReduceSet.js +0 -27
  69. package/dist/esm/BookReader/Toolbar/Toolbar.js +0 -242
  70. package/dist/esm/BookReader/events.js +0 -20
  71. package/dist/esm/BookReader/options.js +0 -331
  72. package/dist/esm/BookReader/utils/HTMLDimensionsCacher.js +0 -48
  73. package/dist/esm/BookReader/utils/ScrollClassAdder.js +0 -31
  74. package/dist/esm/BookReader/utils/SelectionObserver.js +0 -42
  75. package/dist/esm/BookReader/utils/classes.js +0 -37
  76. package/dist/esm/BookReader/utils.js +0 -315
  77. package/dist/esm/BookReader.js +0 -1827
  78. package/dist/esm/assets/icons/1up.svg +0 -12
  79. package/dist/esm/assets/icons/2up.svg +0 -15
  80. package/dist/esm/assets/icons/advance.svg +0 -26
  81. package/dist/esm/assets/icons/chevron-right.svg +0 -1
  82. package/dist/esm/assets/icons/close-circle-dark.svg +0 -1
  83. package/dist/esm/assets/icons/close-circle.svg +0 -1
  84. package/dist/esm/assets/icons/fullscreen.svg +0 -17
  85. package/dist/esm/assets/icons/fullscreen_exit.svg +0 -17
  86. package/dist/esm/assets/icons/hamburger.svg +0 -15
  87. package/dist/esm/assets/icons/left-arrow.svg +0 -12
  88. package/dist/esm/assets/icons/magnify-minus.svg +0 -12
  89. package/dist/esm/assets/icons/magnify-plus.svg +0 -13
  90. package/dist/esm/assets/icons/magnify.svg +0 -15
  91. package/dist/esm/assets/icons/pause.svg +0 -23
  92. package/dist/esm/assets/icons/play.svg +0 -22
  93. package/dist/esm/assets/icons/playback-speed.svg +0 -34
  94. package/dist/esm/assets/icons/read-aloud.svg +0 -22
  95. package/dist/esm/assets/icons/review.svg +0 -22
  96. package/dist/esm/assets/icons/thumbnails.svg +0 -17
  97. package/dist/esm/assets/icons/voice.svg +0 -1
  98. package/dist/esm/assets/icons/volume-full.svg +0 -22
  99. package/dist/esm/assets/images/BRicons.png +0 -0
  100. package/dist/esm/assets/images/BRicons.svg +0 -94
  101. package/dist/esm/assets/images/BRicons_ia.png +0 -0
  102. package/dist/esm/assets/images/back_pages.png +0 -0
  103. package/dist/esm/assets/images/book_bottom_icon.png +0 -0
  104. package/dist/esm/assets/images/book_down_icon.png +0 -0
  105. package/dist/esm/assets/images/book_left_icon.png +0 -0
  106. package/dist/esm/assets/images/book_leftmost_icon.png +0 -0
  107. package/dist/esm/assets/images/book_right_icon.png +0 -0
  108. package/dist/esm/assets/images/book_rightmost_icon.png +0 -0
  109. package/dist/esm/assets/images/book_top_icon.png +0 -0
  110. package/dist/esm/assets/images/book_up_icon.png +0 -0
  111. package/dist/esm/assets/images/books_graphic.svg +0 -177
  112. package/dist/esm/assets/images/booksplit.png +0 -0
  113. package/dist/esm/assets/images/control_pause_icon.png +0 -0
  114. package/dist/esm/assets/images/control_play_icon.png +0 -0
  115. package/dist/esm/assets/images/embed_icon.png +0 -0
  116. package/dist/esm/assets/images/icon-home-ia.png +0 -0
  117. package/dist/esm/assets/images/icon_OL-logo-xs.png +0 -0
  118. package/dist/esm/assets/images/icon_alert-xs.png +0 -0
  119. package/dist/esm/assets/images/icon_book.svg +0 -12
  120. package/dist/esm/assets/images/icon_bookmark.svg +0 -12
  121. package/dist/esm/assets/images/icon_close-pop.png +0 -0
  122. package/dist/esm/assets/images/icon_download.png +0 -0
  123. package/dist/esm/assets/images/icon_gear.svg +0 -14
  124. package/dist/esm/assets/images/icon_hamburger.svg +0 -20
  125. package/dist/esm/assets/images/icon_home.png +0 -0
  126. package/dist/esm/assets/images/icon_home.svg +0 -21
  127. package/dist/esm/assets/images/icon_home_ia.png +0 -0
  128. package/dist/esm/assets/images/icon_indicator.png +0 -0
  129. package/dist/esm/assets/images/icon_info.svg +0 -11
  130. package/dist/esm/assets/images/icon_one_page.svg +0 -8
  131. package/dist/esm/assets/images/icon_pause.svg +0 -1
  132. package/dist/esm/assets/images/icon_play.svg +0 -1
  133. package/dist/esm/assets/images/icon_playback-rate.svg +0 -15
  134. package/dist/esm/assets/images/icon_return.png +0 -0
  135. package/dist/esm/assets/images/icon_search_button.svg +0 -8
  136. package/dist/esm/assets/images/icon_share.svg +0 -9
  137. package/dist/esm/assets/images/icon_skip-ahead.svg +0 -6
  138. package/dist/esm/assets/images/icon_skip-back.svg +0 -13
  139. package/dist/esm/assets/images/icon_speaker.svg +0 -18
  140. package/dist/esm/assets/images/icon_speaker_open.svg +0 -10
  141. package/dist/esm/assets/images/icon_thumbnails.svg +0 -12
  142. package/dist/esm/assets/images/icon_toc.svg +0 -5
  143. package/dist/esm/assets/images/icon_two_pages.svg +0 -9
  144. package/dist/esm/assets/images/icon_zoomer.png +0 -0
  145. package/dist/esm/assets/images/loading.gif +0 -0
  146. package/dist/esm/assets/images/logo_icon.png +0 -0
  147. package/dist/esm/assets/images/marker_chap-off.png +0 -0
  148. package/dist/esm/assets/images/marker_chap-off.svg +0 -11
  149. package/dist/esm/assets/images/marker_chap-off_ia.png +0 -0
  150. package/dist/esm/assets/images/marker_chap-on.png +0 -0
  151. package/dist/esm/assets/images/marker_chap-on.svg +0 -11
  152. package/dist/esm/assets/images/marker_srch-on.svg +0 -11
  153. package/dist/esm/assets/images/marker_srchchap-off.png +0 -0
  154. package/dist/esm/assets/images/marker_srchchap-on.png +0 -0
  155. package/dist/esm/assets/images/nav_control-dn.png +0 -0
  156. package/dist/esm/assets/images/nav_control-dn_ia.png +0 -0
  157. package/dist/esm/assets/images/nav_control-up.png +0 -0
  158. package/dist/esm/assets/images/nav_control-up_ia.png +0 -0
  159. package/dist/esm/assets/images/nav_control.png +0 -0
  160. package/dist/esm/assets/images/one_page_mode_icon.png +0 -0
  161. package/dist/esm/assets/images/paper-badge.png +0 -0
  162. package/dist/esm/assets/images/print_icon.png +0 -0
  163. package/dist/esm/assets/images/progressbar.gif +0 -0
  164. package/dist/esm/assets/images/right_edges.png +0 -0
  165. package/dist/esm/assets/images/slider.png +0 -0
  166. package/dist/esm/assets/images/slider_ia.png +0 -0
  167. package/dist/esm/assets/images/thumbnail_mode_icon.png +0 -0
  168. package/dist/esm/assets/images/transparent.png +0 -0
  169. package/dist/esm/assets/images/two_page_mode_icon.png +0 -0
  170. package/dist/esm/assets/images/unviewable_page.png +0 -0
  171. package/dist/esm/assets/images/zoom_in_icon.png +0 -0
  172. package/dist/esm/assets/images/zoom_out_icon.png +0 -0
  173. package/dist/esm/css/BookReader.scss +0 -85
  174. package/dist/esm/css/_BRBookmarks.scss +0 -29
  175. package/dist/esm/css/_BRComponent.scss +0 -13
  176. package/dist/esm/css/_BRfloat.scss +0 -197
  177. package/dist/esm/css/_BRicon.scss +0 -54
  178. package/dist/esm/css/_BRmain.scss +0 -262
  179. package/dist/esm/css/_BRnav.scss +0 -354
  180. package/dist/esm/css/_BRpages.scss +0 -213
  181. package/dist/esm/css/_BRsearch.scss +0 -268
  182. package/dist/esm/css/_BRtoolbar.scss +0 -84
  183. package/dist/esm/css/_BRvendor.scss +0 -5
  184. package/dist/esm/css/_TextSelection.scss +0 -108
  185. package/dist/esm/css/_colorbox.scss +0 -52
  186. package/dist/esm/css/_controls.scss +0 -257
  187. package/dist/esm/css/_icons.scss +0 -121
  188. package/dist/esm/ia-bookreader/ia-bookreader.js +0 -141
  189. package/dist/esm/jquery-wrapper.js +0 -3
  190. package/dist/esm/plugins/plugin.archive_analytics.js +0 -72
  191. package/dist/esm/plugins/plugin.autoplay.js +0 -119
  192. package/dist/esm/plugins/plugin.chapters.js +0 -288
  193. package/dist/esm/plugins/plugin.iframe.js +0 -44
  194. package/dist/esm/plugins/plugin.iiif.js +0 -146
  195. package/dist/esm/plugins/plugin.resume.js +0 -66
  196. package/dist/esm/plugins/plugin.text_selection.js +0 -621
  197. package/dist/esm/plugins/plugin.vendor-fullscreen.js +0 -227
  198. package/dist/esm/plugins/search/plugin.search.js +0 -499
  199. package/dist/esm/plugins/search/utils.js +0 -42
  200. package/dist/esm/plugins/search/view.js +0 -360
  201. package/dist/esm/plugins/tts/AbstractTTSEngine.js +0 -282
  202. package/dist/esm/plugins/tts/FestivalTTSEngine.js +0 -192
  203. package/dist/esm/plugins/tts/PageChunk.js +0 -105
  204. package/dist/esm/plugins/tts/PageChunkIterator.js +0 -155
  205. package/dist/esm/plugins/tts/WebTTSEngine.js +0 -364
  206. package/dist/esm/plugins/tts/plugin.tts.js +0 -315
  207. package/dist/esm/plugins/tts/tooltip_dict.js +0 -14
  208. package/dist/esm/plugins/tts/utils.js +0 -79
  209. package/dist/esm/plugins/url/UrlPlugin.js +0 -197
  210. package/dist/esm/plugins/url/plugin.url.js +0 -212
  211. package/dist/esm/util/browserSniffing.js +0 -56
  212. package/dist/esm/util/debouncer.js +0 -25
  213. package/dist/esm/util/docCookies.js +0 -75
  214. package/dist/esm/util/strings.js +0 -34
  215. package/index.js +0 -2
@@ -1,315 +0,0 @@
1
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
2
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
3
- /**
4
- * Bind mouse handlers
5
- * Disable mouse click to avoid selected/highlighted page images
6
- * @param {JQuery} jObject
7
- */
8
- export function disableSelect(jObject) {
9
- // $$$ check here for right-click and don't disable. Also use jQuery style
10
- // for stopping propagation. See https://bugs.edge.launchpad.net/gnubook/+bug/362626
11
- jObject.bind('mousedown', () => false);
12
- // Special hack for IE7
13
- jObject[0].onselectstart = () => false;
14
- }
15
-
16
- /**
17
- * @param {number} value
18
- * @param {number} min
19
- * @param {number} max
20
- * @return {number}
21
- */
22
- export function clamp(value, min, max) {
23
- return Math.min(Math.max(value, min), max);
24
- }
25
-
26
- /**
27
- * Given value and maximum, calculate a percentage suitable for CSS
28
- * @param {number} value
29
- * @param {number} max
30
- * @return {string}
31
- */
32
- export function cssPercentage(value, max) {
33
- return value / max * 100 + '%';
34
- }
35
-
36
- /**
37
- * @param {*} value
38
- * @param {Array} array
39
- * @return {boolean}
40
- */
41
- export function notInArray(value, array) {
42
- return !array.includes(value);
43
- }
44
-
45
- /**
46
- * Determines the active element, going into shadow doms.
47
- * @return {Element}
48
- */
49
- export function getActiveElement() {
50
- var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
51
- var recurseShadowDom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
52
- var activeElement = doc.activeElement;
53
- if (recurseShadowDom && activeElement !== null && activeElement !== void 0 && activeElement.shadowRoot) {
54
- return getActiveElement(activeElement.shadowRoot, true);
55
- }
56
- return activeElement;
57
- }
58
-
59
- /** Check if an input field/textarea is active. Also checks shadow DOMs. */
60
- export function isInputActive() {
61
- var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
62
- var activeEl = getActiveElement(doc);
63
- return (activeEl === null || activeEl === void 0 ? void 0 : activeEl.tagName) == "INPUT" || (activeEl === null || activeEl === void 0 ? void 0 : activeEl.tagName) == "TEXTAREA";
64
- }
65
-
66
- /**
67
- * @param {HTMLIFrameElement} iframe
68
- * @return {Document}
69
- */
70
- export function getIFrameDocument(iframe) {
71
- // Adapted from http://xkr.us/articles/dom/iframe-document/
72
- var outer = iframe.contentWindow || iframe.contentDocument;
73
- return outer.document || outer;
74
- }
75
-
76
- /**
77
- * @param {string} str
78
- * @return {string}
79
- */
80
- export function escapeHTML(str) {
81
- return str.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
82
- }
83
-
84
- /**
85
- * Decodes a URI component and converts '+' to ' '
86
- * @param {string} value
87
- * @return {string}
88
- */
89
- export function decodeURIComponentPlus(value) {
90
- return decodeURIComponent(value).replace(/\+/g, ' ');
91
- }
92
-
93
- /**
94
- * Encodes a URI component and converts ' ' to '+'
95
- * @param {string|number|boolean} value
96
- * @return {string};
97
- */
98
- export function encodeURIComponentPlus(value) {
99
- return encodeURIComponent(value).replace(/%20/g, '+');
100
- }
101
-
102
- /**
103
- * @template {Function} T
104
- * Returns a function, that, as long as it continues to be invoked, will not
105
- * be triggered. The function will be called after it stops being called for
106
- * N milliseconds. If `immediate` is passed, trigger the function on the
107
- * leading edge, instead of the trailing.
108
- * @see https://davidwalsh.name/javascript-debounce-function
109
- *
110
- * @param {T} func
111
- * @param {number} wait
112
- * @param {boolean} immediate
113
- * @return {T}
114
- */
115
- export function debounce(func, wait, immediate) {
116
- var timeout;
117
- return function () {
118
- var context = this;
119
- var args = arguments;
120
- var later = () => {
121
- timeout = null;
122
- if (!immediate) func.apply(context, args);
123
- };
124
- var callNow = immediate && !timeout;
125
- clearTimeout(timeout);
126
- timeout = setTimeout(later, wait);
127
- if (callNow) func.apply(context, args);
128
- };
129
- }
130
-
131
- /**
132
- * @template T
133
- * Throttle function
134
- * @see https://remysharp.com/2010/07/21/throttling-function-calls
135
- * @param {T} fn
136
- * @param {number} threshold
137
- * @param {boolean} delay
138
- * @return {T}
139
- */
140
- export function throttle(fn, threshold, delay) {
141
- threshold || (threshold = 250);
142
- var last;
143
- var deferTimer;
144
- if (delay) last = +new Date();
145
- return function () {
146
- var context = this;
147
- var now = +new Date();
148
- var args = arguments;
149
- if (last && now < last + threshold) {
150
- // hold on to it
151
- clearTimeout(deferTimer);
152
- deferTimer = setTimeout(() => {
153
- last = now;
154
- fn.apply(context, args);
155
- }, threshold);
156
- } else {
157
- last = now;
158
- fn.apply(context, args);
159
- }
160
- };
161
- }
162
-
163
- /**
164
- * FIXME we need a better way to do this :/ This is not automatically poly-filled by
165
- * core-js https://github.com/zloirock/core-js/issues/354
166
- * @param {Window} window
167
- */
168
- export function polyfillCustomEvent(window) {
169
- if (typeof window.CustomEvent === "function") return false;
170
- window.CustomEvent = PolyfilledCustomEvent;
171
- }
172
-
173
- /**
174
- * https://caniuse.com/customevent has issues on older browsers where it can't be
175
- * called as a constructor, so we have to use older methods.
176
- * @param {String} eventName
177
- * @return {CustomEvent}
178
- */
179
- export function PolyfilledCustomEvent(eventName) {
180
- var {
181
- bubbles = false,
182
- cancelable = false,
183
- detail = null
184
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
185
- var event = document.createEvent('CustomEvent');
186
- event.initCustomEvent(eventName, bubbles, cancelable, detail);
187
- return event;
188
- }
189
-
190
- /*
191
- * Returns the number pixels something should be rendered at to be ~1n on the users
192
- * screen when measured with a ruler.
193
- */
194
- export function calcScreenDPI() {
195
- var el = document.createElement('div');
196
- el.style.width = '1in';
197
- document.body.appendChild(el);
198
- var dpi = el.offsetWidth;
199
- document.body.removeChild(el);
200
-
201
- // Do you believe in magic... numbers? We tested on some devices, and the displayed
202
- // size of `width: 1in` was less than desired. On @pezvi's mac, it was ~75% ; on
203
- // @cdrini's laptop it was ~85%. Since we want to avoid things appearing too small,
204
- // let's just use a multiplier of 1.25
205
- var screenDPI = dpi * 1.25;
206
- // This will return 0 in testing; never want it to be 0!
207
- return screenDPI == 0 ? 100 : screenDPI;
208
- }
209
-
210
- /**
211
- * @param {number[]} nums
212
- * @returns {number}
213
- */
214
- export function sum(nums) {
215
- return nums.reduce((cur, acc) => cur + acc, 0);
216
- }
217
-
218
- /**
219
- * @template T
220
- * @param {Generator<T>} gen
221
- * @returns {T[]}
222
- */
223
- export function genToArray(gen) {
224
- var result = [];
225
- for (var item of gen) {
226
- result.push(item);
227
- }
228
- return result;
229
- }
230
-
231
- /**
232
- * Check if arrays contain the same elements. Does reference comparison.
233
- * @param {Array} arr1
234
- * @param {Array} arr2
235
- */
236
- export function arrEquals(arr1, arr2) {
237
- return arr1.length == arr2.length && arr1.every((x, i) => x == arr2[i]);
238
- }
239
-
240
- /**
241
- * Check if array has changed; namely to be used with lit's property.hasChanged
242
- * @param {Array} [arr1]
243
- * @param {Array} [arr2]
244
- */
245
- export function arrChanged(arr1, arr2) {
246
- return arr1 && arr2 && !arrEquals(arr1, arr2);
247
- }
248
-
249
- /**
250
- * Waits the provided number of ms and then resolves with a promise
251
- * @param {number} ms
252
- **/
253
- export function sleep(_x) {
254
- return _sleep2.apply(this, arguments);
255
- }
256
-
257
- /**
258
- * @template T
259
- * @param {function(): T} fn
260
- * @param {Object} options
261
- * @param {function(T): boolean} [options.until]
262
- * @return {T | undefined}
263
- */
264
- function _sleep2() {
265
- _sleep2 = _asyncToGenerator(function* (ms) {
266
- return new Promise(resolve => setTimeout(resolve, ms));
267
- });
268
- return _sleep2.apply(this, arguments);
269
- }
270
- export function poll(_x2) {
271
- return _poll.apply(this, arguments);
272
- }
273
-
274
- /**
275
- * Convert a EventTarget style event into a promise
276
- * @param {EventTarget} target
277
- * @param {string} eventType
278
- * @return {Promise<Event>}
279
- */
280
- function _poll() {
281
- _poll = _asyncToGenerator(function* (fn) {
282
- var {
283
- step = 50,
284
- timeout = 500,
285
- until = val => Boolean(val),
286
- _sleep = sleep
287
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
288
- var startTime = Date.now();
289
- while (Date.now() - startTime < timeout) {
290
- var result = fn();
291
- if (until(result)) return result;
292
- yield _sleep(step);
293
- }
294
- });
295
- return _poll.apply(this, arguments);
296
- }
297
- export function promisifyEvent(target, eventType) {
298
- return new Promise(res => {
299
- var resolver = ev => {
300
- target.removeEventListener(eventType, resolver);
301
- res(ev);
302
- };
303
- target.addEventListener(eventType, resolver);
304
- });
305
- }
306
-
307
- /**
308
- * Escapes regex special characters in a string. Allows for safe usage in regexes.
309
- * Src: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
310
- * @param {string} string
311
- * @returns {string}
312
- */
313
- export function escapeRegExp(string) {
314
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
315
- }