@internetarchive/bookreader 5.0.0-24-sortingstate-2 → 5.0.0-24-sortingstate-6
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/BookReader/BookReader.js +1 -1
- package/BookReader/icons/1up.svg +12 -1
- package/BookReader/icons/2up.svg +15 -1
- package/BookReader/icons/advance.svg +26 -3
- package/BookReader/icons/chevron-right.svg +1 -1
- package/BookReader/icons/close-circle-dark.svg +1 -1
- package/BookReader/icons/close-circle.svg +1 -1
- package/BookReader/icons/fullscreen.svg +17 -1
- package/BookReader/icons/fullscreen_exit.svg +17 -1
- package/BookReader/icons/hamburger.svg +15 -1
- package/BookReader/icons/left-arrow.svg +12 -1
- package/BookReader/icons/magnify-minus.svg +16 -1
- package/BookReader/icons/magnify-plus.svg +17 -1
- package/BookReader/icons/magnify.svg +15 -1
- package/BookReader/icons/pause.svg +23 -1
- package/BookReader/icons/play.svg +22 -1
- package/BookReader/icons/playback-speed.svg +34 -1
- package/BookReader/icons/read-aloud.svg +22 -1
- package/BookReader/icons/review.svg +22 -3
- package/BookReader/icons/thumbnails.svg +17 -1
- package/BookReader/icons/voice.svg +1 -1
- package/BookReader/icons/volume-full.svg +22 -1
- package/BookReader/images/BRicons.svg +94 -5
- package/BookReader/images/books_graphic.svg +177 -1
- package/BookReader/images/icon_book.svg +12 -1
- package/BookReader/images/icon_bookmark.svg +12 -1
- package/BookReader/images/icon_gear.svg +14 -1
- package/BookReader/images/icon_hamburger.svg +20 -1
- package/BookReader/images/icon_home.svg +21 -1
- package/BookReader/images/icon_info.svg +11 -1
- package/BookReader/images/icon_one_page.svg +8 -1
- package/BookReader/images/icon_pause.svg +1 -1
- package/BookReader/images/icon_play.svg +1 -1
- package/BookReader/images/icon_playback-rate.svg +15 -1
- package/BookReader/images/icon_search_button.svg +8 -1
- package/BookReader/images/icon_share.svg +9 -1
- package/BookReader/images/icon_skip-ahead.svg +6 -1
- package/BookReader/images/icon_skip-back.svg +13 -2
- package/BookReader/images/icon_speaker.svg +18 -1
- package/BookReader/images/icon_speaker_open.svg +10 -1
- package/BookReader/images/icon_thumbnails.svg +12 -1
- package/BookReader/images/icon_toc.svg +5 -1
- package/BookReader/images/icon_two_pages.svg +9 -1
- package/BookReader/images/marker_chap-off.svg +11 -1
- package/BookReader/images/marker_chap-on.svg +11 -1
- package/BookReader/images/marker_srch-on.svg +11 -1
- package/BookReader/jquery-1.10.1.js +108 -2
- package/BookReader/plugins/plugin.archive_analytics.js +170 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js +163 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +333 -1
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +72 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.mobile_nav.js +332 -1
- package/BookReader/plugins/plugin.mobile_nav.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js +241 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1263 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +839 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +9114 -2
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +17 -15
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +326 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/webcomponents-bundle.js +411 -2
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/package.json +1 -1
- package/src/plugins/plugin.url.js +9 -9
- package/tests/jest/plugins/plugin.url.test.js +11 -20
package/package.json
CHANGED
@@ -212,7 +212,7 @@ export class UrlPlugin {
|
|
212
212
|
];
|
213
213
|
|
214
214
|
this.urlState = {};
|
215
|
-
this.urlMode = 'hash';
|
215
|
+
this.urlMode = this.bookReaderOptions.urlMode || 'hash';
|
216
216
|
this.urlHistoryBasePath = '/';
|
217
217
|
this.urlLocationPollId = null;
|
218
218
|
this.oldLocationHash = null;
|
@@ -222,18 +222,17 @@ export class UrlPlugin {
|
|
222
222
|
/**
|
223
223
|
* Parse JSON object URL state to string format
|
224
224
|
* Arrange path names in an order that it is positioned on the urlSchema
|
225
|
-
* @param {object} urlSchema
|
226
225
|
* @param {string} urlState
|
227
226
|
* @returns {string}
|
228
227
|
*/
|
229
|
-
urlStateToUrlString(
|
228
|
+
urlStateToUrlString(urlState) {
|
230
229
|
const searchParams = new URLSearchParams();
|
231
230
|
const pathParams = {};
|
232
231
|
|
233
232
|
Object.keys(urlState).forEach(key => {
|
234
|
-
let schema = urlSchema.find(schema => schema.name === key);
|
233
|
+
let schema = this.urlSchema.find(schema => schema.name === key);
|
235
234
|
if (schema?.deprecated_for) {
|
236
|
-
schema = urlSchema.find(schemaKey => schemaKey.name === schema.deprecated_for);
|
235
|
+
schema = this.urlSchema.find(schemaKey => schemaKey.name === schema.deprecated_for);
|
237
236
|
}
|
238
237
|
if (schema?.position == 'path') {
|
239
238
|
pathParams[schema?.name] = urlState[key];
|
@@ -242,7 +241,7 @@ export class UrlPlugin {
|
|
242
241
|
}
|
243
242
|
});
|
244
243
|
|
245
|
-
const strPathParams = urlSchema
|
244
|
+
const strPathParams = this.urlSchema
|
246
245
|
.filter(s => s.position == 'path')
|
247
246
|
.map(schema => pathParams[schema.name] ? `${schema.name}/${pathParams[schema.name]}` : '')
|
248
247
|
.join('/');
|
@@ -257,16 +256,16 @@ export class UrlPlugin {
|
|
257
256
|
* Example:
|
258
257
|
* /page/n7/mode/2up => {page: 'n7', mode: '2up'}
|
259
258
|
* /page/n7/mode/2up/search/hello => {page: 'n7', mode: '2up', q: 'hello'}
|
260
|
-
* @param {array} urlSchema
|
261
259
|
* @param {string} urlString
|
262
260
|
* @returns {object}
|
263
261
|
*/
|
264
|
-
urlStringToUrlState(
|
262
|
+
urlStringToUrlState(urlString) {
|
265
263
|
const urlState = {};
|
266
264
|
|
267
265
|
// Fetch searchParams from given {urlString}
|
268
266
|
// Note: whole URL path is needed for URLSearchParams
|
269
267
|
const urlPath = new URL(urlString, 'http://example.com');
|
268
|
+
console.log('urlSearch: ', urlPath.searchParams, ' urlPath: ', urlPath.pathname);
|
270
269
|
const urlSearchParamsObj = Object.fromEntries(urlPath.searchParams.entries());
|
271
270
|
const urlStrSplitSlashObj = Object.fromEntries(urlPath.pathname
|
272
271
|
.match(/[^\\/]+\/[^\\/]+/g)
|
@@ -277,7 +276,7 @@ export class UrlPlugin {
|
|
277
276
|
};
|
278
277
|
|
279
278
|
// Add path objects to urlState
|
280
|
-
urlSchema
|
279
|
+
this.urlSchema
|
281
280
|
.filter(schema => schema.position == 'path')
|
282
281
|
.forEach(schema => {
|
283
282
|
if (!urlStrSplitSlashObj[schema.name] && schema.default) {
|
@@ -384,6 +383,7 @@ export class UrlPlugin {
|
|
384
383
|
const path = this.urlMode === 'history'
|
385
384
|
? (location.pathname.substr(this.urlHistoryBasePath.length) + location.search)
|
386
385
|
: location.hash.substr(1);
|
386
|
+
console.log('path: ', path);
|
387
387
|
this.urlState = this.urlStringToUrlState(this.urlSchema, path);
|
388
388
|
}
|
389
389
|
}
|
@@ -17,15 +17,6 @@ afterEach(() => {
|
|
17
17
|
|
18
18
|
describe.only('UrlPlugin tests', () => {
|
19
19
|
const urlPlugin = new UrlPlugin();
|
20
|
-
const urlSchema = [
|
21
|
-
{ name: 'page', position: 'path', default: 'n0' },
|
22
|
-
{ name: 'mode', position: 'path', default: '2up' },
|
23
|
-
{ name: 'search', position: 'path', deprecated_for: 'q' },
|
24
|
-
{ name: 'q', position: 'query_param' },
|
25
|
-
{ name: 'sort', position: 'query_param' },
|
26
|
-
{ name: 'view', position: 'query_param' },
|
27
|
-
{ name: 'admin', position: 'query_param' },
|
28
|
-
];
|
29
20
|
|
30
21
|
describe('urlStateToUrlString tests', () => {
|
31
22
|
test('urlStateToUrlString with known states in schema', () => {
|
@@ -35,8 +26,8 @@ describe.only('UrlPlugin tests', () => {
|
|
35
26
|
const expectedUrlFromState = '/page/n7/mode/1up?q=foo';
|
36
27
|
const expectedUrlFromStateWithQueries = '/page/n7/mode/1up?q=hello&view=theater&sort=title_asc';
|
37
28
|
|
38
|
-
expect(urlPlugin.urlStateToUrlString(
|
39
|
-
expect(urlPlugin.urlStateToUrlString(
|
29
|
+
expect(urlPlugin.urlStateToUrlString(urlState)).toBe(expectedUrlFromState);
|
30
|
+
expect(urlPlugin.urlStateToUrlString(urlStateWithQueries)).toBe(expectedUrlFromStateWithQueries);
|
40
31
|
});
|
41
32
|
|
42
33
|
test('urlStateToUrlString with unknown states in schema', () => {
|
@@ -46,15 +37,15 @@ describe.only('UrlPlugin tests', () => {
|
|
46
37
|
const expectedUrlFromState = '/page/n7/mode/1up';
|
47
38
|
const expectedUrlFromStateWithQueries = '/page/n7/mode/1up?q=hello&viewer=theater&sortBy=title_asc';
|
48
39
|
|
49
|
-
expect(urlPlugin.urlStateToUrlString(
|
50
|
-
expect(urlPlugin.urlStateToUrlString(
|
40
|
+
expect(urlPlugin.urlStateToUrlString(urlState)).toBe(expectedUrlFromState);
|
41
|
+
expect(urlPlugin.urlStateToUrlString(urlStateWithQueries)).toBe(expectedUrlFromStateWithQueries);
|
51
42
|
});
|
52
43
|
|
53
44
|
test('urlStateToUrlString with boolean value', () => {
|
54
45
|
const urlState = { page: 'n7', mode: '1up', search: 'foo', view: 'theater', wrapper: false };
|
55
46
|
const expectedUrlFromState = '/page/n7/mode/1up?q=foo&view=theater&wrapper=false';
|
56
47
|
|
57
|
-
expect(urlPlugin.urlStateToUrlString(
|
48
|
+
expect(urlPlugin.urlStateToUrlString(urlState)).toBe(expectedUrlFromState);
|
58
49
|
});
|
59
50
|
});
|
60
51
|
|
@@ -63,24 +54,24 @@ describe.only('UrlPlugin tests', () => {
|
|
63
54
|
const url = '/page/n7/mode/2up';
|
64
55
|
const url1 = '/page/n7/mode/1up';
|
65
56
|
|
66
|
-
expect(urlPlugin.urlStringToUrlState(
|
67
|
-
expect(urlPlugin.urlStringToUrlState(
|
57
|
+
expect(urlPlugin.urlStringToUrlState(url)).toEqual({page: 'n7', mode: '2up'});
|
58
|
+
expect(urlPlugin.urlStringToUrlState(url1)).toEqual({page: 'n7', mode: '1up'});
|
68
59
|
});
|
69
60
|
|
70
61
|
test('urlStringToUrlState with deprecated_for', () => {
|
71
62
|
const url = '/page/n7/mode/2up/search/hello';
|
72
63
|
|
73
|
-
expect(urlPlugin.urlStringToUrlState(
|
64
|
+
expect(urlPlugin.urlStringToUrlState(url)).toEqual({page: 'n7', mode: '2up', q: 'hello'});
|
74
65
|
});
|
75
66
|
|
76
67
|
test('urlStringToUrlState with query string', () => {
|
77
68
|
const url = '/page/n7/mode/2up/search/hello?view=theather&foo=bar&sort=title_asc';
|
78
69
|
const url1 = '/mode/2up?ref=ol&ui=embed&wrapper=false&view=theater';
|
79
70
|
|
80
|
-
expect(urlPlugin.urlStringToUrlState(
|
71
|
+
expect(urlPlugin.urlStringToUrlState(url)).toEqual(
|
81
72
|
{page: 'n7', mode: '2up', q: 'hello', view: 'theather', foo: 'bar', sort: 'title_asc'}
|
82
73
|
);
|
83
|
-
expect(urlPlugin.urlStringToUrlState(
|
74
|
+
expect(urlPlugin.urlStringToUrlState(url1)).toEqual(
|
84
75
|
{page: 'n0', mode: '2up', ref: 'ol', ui: 'embed', wrapper: false, view: 'theater'}
|
85
76
|
);
|
86
77
|
});
|
@@ -89,7 +80,7 @@ describe.only('UrlPlugin tests', () => {
|
|
89
80
|
const url = '/page/n7/mode/2up/search/hello';
|
90
81
|
urlPlugin.urlState = { q: 'hello' };
|
91
82
|
|
92
|
-
expect(urlPlugin.urlStringToUrlState(
|
83
|
+
expect(urlPlugin.urlStringToUrlState(url)).toEqual({page: 'n7', mode: '2up', q: 'hello'});
|
93
84
|
});
|
94
85
|
});
|
95
86
|
|