@edrlab/thorium-web 1.2.1 → 1.3.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/{ThPreferencesAdapter-DrZ5_6Dv.d.mts → ThPreferencesAdapter-D0rzsGRl.d.mts} +50 -13
- package/dist/{ThSettingsWrapper-8Kx0SnH4.d.mts → ThSettingsWrapper-BXuRgdqp.d.mts} +42 -4
- package/dist/{actions-D2CHvCHu.d.mts → actions-BLAr0oaM.d.mts} +16 -4
- package/dist/{actionsReducer-kc-S130w.d.mts → actionsReducer-XWTGGNUd.d.mts} +46 -14
- package/dist/chunk-2ORXUOH3.mjs +134 -0
- package/dist/chunk-2ORXUOH3.mjs.map +1 -0
- package/dist/chunk-3GDQP6AS.mjs +14 -0
- package/dist/chunk-3GDQP6AS.mjs.map +1 -0
- package/dist/chunk-6BUN7DEA.mjs +854 -0
- package/dist/chunk-6BUN7DEA.mjs.map +1 -0
- package/dist/{chunk-IYAFKTPL.mjs → chunk-6EHFW43Y.mjs} +5 -4
- package/dist/chunk-6EHFW43Y.mjs.map +1 -0
- package/dist/chunk-7CGMWOZN.mjs +20 -0
- package/dist/chunk-7CGMWOZN.mjs.map +1 -0
- package/dist/{chunk-4VHEHMJN.mjs → chunk-A3FZBEUL.mjs} +228 -94
- package/dist/chunk-A3FZBEUL.mjs.map +1 -0
- package/dist/{chunk-NYZBHYW2.mjs → chunk-DETZMFZ7.mjs} +366 -61
- package/dist/chunk-DETZMFZ7.mjs.map +1 -0
- package/dist/{chunk-QPE574OW.mjs → chunk-DMZFSOHK.mjs} +28 -36
- package/dist/chunk-DMZFSOHK.mjs.map +1 -0
- package/dist/{chunk-7NEQAW7J.mjs → chunk-DTPO3J2C.mjs} +676 -930
- package/dist/chunk-DTPO3J2C.mjs.map +1 -0
- package/dist/{chunk-K3K7TUWM.mjs → chunk-EZG6SBSO.mjs} +358 -94
- package/dist/chunk-EZG6SBSO.mjs.map +1 -0
- package/dist/chunk-GPWW5OML.mjs +1955 -0
- package/dist/chunk-GPWW5OML.mjs.map +1 -0
- package/dist/{chunk-P4V3LA5R.mjs → chunk-I4BKU5NN.mjs} +13 -9
- package/dist/chunk-I4BKU5NN.mjs.map +1 -0
- package/dist/{chunk-47AIIJFO.mjs → chunk-ITDBOMY5.mjs} +3 -3
- package/dist/{chunk-47AIIJFO.mjs.map → chunk-ITDBOMY5.mjs.map} +1 -1
- package/dist/{chunk-XVSFXHYB.mjs → chunk-L4XGZAZ5.mjs} +23 -20
- package/dist/chunk-L4XGZAZ5.mjs.map +1 -0
- package/dist/{chunk-PXAUQJEU.mjs → chunk-LP3JFZ4A.mjs} +2425 -1634
- package/dist/chunk-LP3JFZ4A.mjs.map +1 -0
- package/dist/{chunk-72XCX5TD.mjs → chunk-NKO3K3QS.mjs} +14 -9
- package/dist/chunk-NKO3K3QS.mjs.map +1 -0
- package/dist/chunk-SAUOY37Q.mjs +862 -0
- package/dist/chunk-SAUOY37Q.mjs.map +1 -0
- package/dist/chunk-TEZB4ULX.mjs +57 -0
- package/dist/chunk-TEZB4ULX.mjs.map +1 -0
- package/dist/components/Audio/index.css +1858 -0
- package/dist/components/Audio/index.css.map +1 -0
- package/dist/components/Audio/index.d.mts +103 -0
- package/dist/components/Audio/index.mjs +23 -0
- package/dist/components/Audio/index.mjs.map +1 -0
- package/dist/components/Epub/index.css +365 -9
- package/dist/components/Epub/index.css.map +1 -1
- package/dist/components/Epub/index.d.mts +17 -19
- package/dist/components/Epub/index.mjs +18 -13
- package/dist/components/Misc/index.css +7 -4
- package/dist/components/Misc/index.css.map +1 -1
- package/dist/components/Misc/index.mjs +5 -133
- package/dist/components/Misc/index.mjs.map +1 -1
- package/dist/components/Reader/index.css +1022 -183
- package/dist/components/Reader/index.css.map +1 -1
- package/dist/components/Reader/index.d.mts +16 -16
- package/dist/components/Reader/index.mjs +124 -25
- package/dist/components/Reader/index.mjs.map +1 -1
- package/dist/components/WebPub/index.css +365 -9
- package/dist/components/WebPub/index.css.map +1 -1
- package/dist/components/WebPub/index.d.mts +16 -16
- package/dist/components/WebPub/index.mjs +18 -13
- package/dist/core/Components/index.d.mts +64 -15
- package/dist/core/Components/index.mjs +2 -1
- package/dist/core/Helpers/index.d.mts +2 -2
- package/dist/core/Helpers/index.mjs +4 -2
- package/dist/core/Hooks/index.d.mts +7 -8
- package/dist/core/Hooks/index.mjs +3 -1
- package/dist/i18n/index.mjs +6 -7
- package/dist/lib/index.d.mts +159 -15
- package/dist/lib/index.mjs +4 -2
- package/dist/lib-M3PPQDJJ.mjs +6548 -0
- package/dist/lib-M3PPQDJJ.mjs.map +1 -0
- package/dist/locales/en/thorium-web.json +22 -0
- package/dist/next-lib/index.mjs +2 -0
- package/dist/next-lib/index.mjs.map +1 -1
- package/dist/preferences/index.d.mts +111 -13
- package/dist/preferences/index.mjs +6 -3
- package/dist/{settingsReducer-C1wwCAMv.d.mts → settingsReducer-Bu1zeveu.d.mts} +1 -1
- package/dist/{ui-CamWuqOo.d.mts → ui-nBv8gfr0.d.mts} +20 -1
- package/dist/useAudioNavigator-C5aW4-eT.d.mts +133 -0
- package/dist/{useContrast-D6sjPjxy.d.mts → useContrast-2t429O9O.d.mts} +16 -8
- package/dist/usePreferences-VaBf46eP.d.mts +230 -0
- package/dist/useReaderTransitions-IBGdE7qi.d.mts +530 -0
- package/dist/{useTimeline-DyMx_aWY.d.mts → useTimeline-DCZ1qoCO.d.mts} +4 -2
- package/package.json +17 -13
- package/dist/chunk-4VHEHMJN.mjs.map +0 -1
- package/dist/chunk-72XCX5TD.mjs.map +0 -1
- package/dist/chunk-7NEQAW7J.mjs.map +0 -1
- package/dist/chunk-IYAFKTPL.mjs.map +0 -1
- package/dist/chunk-K3K7TUWM.mjs.map +0 -1
- package/dist/chunk-NYZBHYW2.mjs.map +0 -1
- package/dist/chunk-P4V3LA5R.mjs.map +0 -1
- package/dist/chunk-PXAUQJEU.mjs.map +0 -1
- package/dist/chunk-QPE574OW.mjs.map +0 -1
- package/dist/chunk-XVSFXHYB.mjs.map +0 -1
- package/dist/useEpubNavigator-CwHJfoiV.d.mts +0 -42
- package/dist/usePreferences-BXFJbval.d.mts +0 -43
- package/dist/useReaderTransitions-guT-eA-Q.d.mts +0 -365
- package/dist/useWebPubNavigator-CuSNQKMw.d.mts +0 -39
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { toEntryRef, buildTocTree } from './chunk-TEZB4ULX.mjs';
|
|
1
2
|
import { useEffect, useState, useLayoutEffect, useCallback, useRef, useMemo } from 'react';
|
|
2
3
|
import { Layout, Link, Locator } from '@readium/shared';
|
|
3
|
-
import { EpubPreferences, EpubNavigator, WebPubPreferences, ExperimentalWebPubNavigator } from '@readium/navigator';
|
|
4
|
+
import { AudioPreferences, AudioNavigator, EpubPreferences, EpubNavigator, WebPubPreferences, ExperimentalWebPubNavigator } from '@readium/navigator';
|
|
4
5
|
|
|
5
|
-
// src/core/Hooks/useDocumentTitle.ts
|
|
6
6
|
var useDocumentTitle = (title) => {
|
|
7
7
|
useEffect(() => {
|
|
8
8
|
if (title) document.title = title;
|
|
@@ -47,22 +47,22 @@ var useFullscreen = (onChange) => {
|
|
|
47
47
|
var useLocalStorage = (key) => {
|
|
48
48
|
const [localData, setLocalData] = useState(null);
|
|
49
49
|
const cachedLocalData = useRef(null);
|
|
50
|
-
const setValue = (newValue) => {
|
|
50
|
+
const setValue = useCallback((newValue) => {
|
|
51
51
|
if (!key) return;
|
|
52
52
|
setLocalData(newValue);
|
|
53
53
|
localStorage.setItem(key, JSON.stringify(newValue));
|
|
54
|
-
};
|
|
55
|
-
const getValue = () => {
|
|
54
|
+
}, [key]);
|
|
55
|
+
const getValue = useCallback(() => {
|
|
56
56
|
if (!key) return null;
|
|
57
57
|
if (localData !== null) return localData;
|
|
58
58
|
const value = localStorage.getItem(key);
|
|
59
59
|
return value ? JSON.parse(value) : null;
|
|
60
|
-
};
|
|
61
|
-
const clearValue = () => {
|
|
60
|
+
}, [key, localData]);
|
|
61
|
+
const clearValue = useCallback(() => {
|
|
62
62
|
if (!key) return;
|
|
63
63
|
setLocalData(null);
|
|
64
64
|
localStorage.removeItem(key);
|
|
65
|
-
};
|
|
65
|
+
}, [key]);
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
if (!key) return;
|
|
68
68
|
cachedLocalData.current = localData;
|
|
@@ -134,30 +134,6 @@ var useTimeline = ({
|
|
|
134
134
|
relativeProgression,
|
|
135
135
|
totalProgression
|
|
136
136
|
]);
|
|
137
|
-
const buildTocTree = useCallback((links, idGenerator, positionsList2, publicationTitle) => {
|
|
138
|
-
return links.map((link) => {
|
|
139
|
-
const newId = idGenerator();
|
|
140
|
-
let href = link.href;
|
|
141
|
-
const fragmentIndex = href.indexOf("#");
|
|
142
|
-
if (fragmentIndex !== -1) {
|
|
143
|
-
const baseHref = href.substring(0, fragmentIndex);
|
|
144
|
-
const duplicateLink = links.find((l) => l.href.startsWith(baseHref) && l.href !== href);
|
|
145
|
-
if (!duplicateLink) {
|
|
146
|
-
href = baseHref;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const treeNode = {
|
|
150
|
-
id: newId,
|
|
151
|
-
href,
|
|
152
|
-
title: link.title || (publicationTitle ? `${publicationTitle} ${idCounterRef.current}` : newId),
|
|
153
|
-
position: positionsList2?.find((position) => position.href === href)?.locations.position
|
|
154
|
-
};
|
|
155
|
-
if (link.children) {
|
|
156
|
-
treeNode.children = buildTocTree(link.children.items, idGenerator, positionsList2, publicationTitle);
|
|
157
|
-
}
|
|
158
|
-
return treeNode;
|
|
159
|
-
});
|
|
160
|
-
}, []);
|
|
161
137
|
const handleTocEntryOnNav = useCallback((locator, currentPos) => {
|
|
162
138
|
if (!locator || !tocTree.length) return;
|
|
163
139
|
const findMatch = (items, link) => {
|
|
@@ -174,7 +150,7 @@ var useTimeline = ({
|
|
|
174
150
|
};
|
|
175
151
|
const currentMatch = findMatch(tocTree, new Link(locator));
|
|
176
152
|
if (currentMatch) {
|
|
177
|
-
setCurrentTocEntry(currentMatch.id);
|
|
153
|
+
setCurrentTocEntry((prev) => prev?.id === currentMatch.id ? prev : toEntryRef(currentMatch));
|
|
178
154
|
return;
|
|
179
155
|
}
|
|
180
156
|
if (layout === Layout.fixed) {
|
|
@@ -184,7 +160,7 @@ var useTimeline = ({
|
|
|
184
160
|
if (otherPositionInList) {
|
|
185
161
|
const match = findMatch(tocTree, new Link(otherPositionInList));
|
|
186
162
|
if (match) {
|
|
187
|
-
setCurrentTocEntry(match.id);
|
|
163
|
+
setCurrentTocEntry((prev) => prev?.id === match.id ? prev : toEntryRef(match));
|
|
188
164
|
return;
|
|
189
165
|
}
|
|
190
166
|
}
|
|
@@ -196,7 +172,7 @@ var useTimeline = ({
|
|
|
196
172
|
if (otherPositionInList) {
|
|
197
173
|
const match = findMatch(tocTree, new Link(otherPositionInList));
|
|
198
174
|
if (match) {
|
|
199
|
-
setCurrentTocEntry(match.id);
|
|
175
|
+
setCurrentTocEntry((prev) => prev?.id === match.id ? prev : toEntryRef(match));
|
|
200
176
|
return;
|
|
201
177
|
}
|
|
202
178
|
}
|
|
@@ -261,7 +237,7 @@ var useTimeline = ({
|
|
|
261
237
|
}
|
|
262
238
|
}
|
|
263
239
|
return timelineItems2;
|
|
264
|
-
}, [publication
|
|
240
|
+
}, [publication, positionsList]);
|
|
265
241
|
const updateTimelineItems = useCallback((currentLoc) => {
|
|
266
242
|
if (!currentLoc || !timelineItems) {
|
|
267
243
|
setPreviousItem(null);
|
|
@@ -294,7 +270,7 @@ var useTimeline = ({
|
|
|
294
270
|
const publicationTitle = publication?.metadata.title.getTranslation("en");
|
|
295
271
|
setTocTree(buildTocTree(tocItems, idGenerator, positionsList, publicationTitle));
|
|
296
272
|
setTimelineItems(buildTimelineItems());
|
|
297
|
-
}, [publication, positionsList,
|
|
273
|
+
}, [publication, positionsList, buildTimelineItems]);
|
|
298
274
|
useEffect(() => {
|
|
299
275
|
if (!tocTree.length || !timelineItems) return;
|
|
300
276
|
if (currentLocation) {
|
|
@@ -315,15 +291,173 @@ var useTimeline = ({
|
|
|
315
291
|
return timeline;
|
|
316
292
|
};
|
|
317
293
|
var navigatorInstance = null;
|
|
294
|
+
var useAudioNavigator = () => {
|
|
295
|
+
const publication = useRef(null);
|
|
296
|
+
const submitPreferences = useCallback(async (preferences) => {
|
|
297
|
+
await navigatorInstance?.submitPreferences(new AudioPreferences(preferences));
|
|
298
|
+
}, []);
|
|
299
|
+
const getSetting = useCallback((settingKey) => {
|
|
300
|
+
return navigatorInstance?.settings?.[settingKey];
|
|
301
|
+
}, []);
|
|
302
|
+
const AudioNavigatorLoad = useCallback((config, cb) => {
|
|
303
|
+
publication.current = config.publication;
|
|
304
|
+
navigatorInstance = new AudioNavigator(
|
|
305
|
+
config.publication,
|
|
306
|
+
config.listeners,
|
|
307
|
+
config.initialPosition,
|
|
308
|
+
{
|
|
309
|
+
preferences: config.preferences || {},
|
|
310
|
+
defaults: config.defaults || {},
|
|
311
|
+
contentProtection: config.contentProtection
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
cb();
|
|
315
|
+
}, []);
|
|
316
|
+
const AudioNavigatorDestroy = useCallback((cb) => {
|
|
317
|
+
cb();
|
|
318
|
+
navigatorInstance?.destroy();
|
|
319
|
+
navigatorInstance = null;
|
|
320
|
+
}, []);
|
|
321
|
+
const play = useCallback(() => {
|
|
322
|
+
navigatorInstance?.play();
|
|
323
|
+
}, []);
|
|
324
|
+
const pause = useCallback(() => {
|
|
325
|
+
navigatorInstance?.pause();
|
|
326
|
+
}, []);
|
|
327
|
+
const stop = useCallback(() => {
|
|
328
|
+
navigatorInstance?.stop();
|
|
329
|
+
}, []);
|
|
330
|
+
const seek = useCallback((time) => {
|
|
331
|
+
navigatorInstance?.seek(time);
|
|
332
|
+
}, []);
|
|
333
|
+
const jump = useCallback((seconds) => {
|
|
334
|
+
navigatorInstance?.jump(seconds);
|
|
335
|
+
}, []);
|
|
336
|
+
const skipForward = useCallback(() => {
|
|
337
|
+
navigatorInstance?.skipForward();
|
|
338
|
+
}, []);
|
|
339
|
+
const skipBackward = useCallback(() => {
|
|
340
|
+
navigatorInstance?.skipBackward();
|
|
341
|
+
}, []);
|
|
342
|
+
const go = useCallback((locator, animated, callback) => {
|
|
343
|
+
navigatorInstance?.go(locator, animated, callback);
|
|
344
|
+
}, []);
|
|
345
|
+
const goLink = useCallback((link, animated, callback) => {
|
|
346
|
+
navigatorInstance?.goLink(link, animated, callback);
|
|
347
|
+
}, []);
|
|
348
|
+
const goForward = useCallback((animated, callback) => {
|
|
349
|
+
navigatorInstance?.goForward(animated, callback);
|
|
350
|
+
}, []);
|
|
351
|
+
const goBackward = useCallback((animated, callback) => {
|
|
352
|
+
navigatorInstance?.goBackward(animated, callback);
|
|
353
|
+
}, []);
|
|
354
|
+
const currentLocator = useCallback(() => {
|
|
355
|
+
return navigatorInstance?.currentLocator;
|
|
356
|
+
}, []);
|
|
357
|
+
const canGoBackward = useCallback(() => {
|
|
358
|
+
return navigatorInstance?.canGoBackward || false;
|
|
359
|
+
}, []);
|
|
360
|
+
const canGoForward = useCallback(() => {
|
|
361
|
+
return navigatorInstance?.canGoForward || false;
|
|
362
|
+
}, []);
|
|
363
|
+
const isTrackStart = useCallback(() => {
|
|
364
|
+
return navigatorInstance?.isTrackStart || false;
|
|
365
|
+
}, []);
|
|
366
|
+
const isTrackEnd = useCallback(() => {
|
|
367
|
+
return navigatorInstance?.isTrackEnd || false;
|
|
368
|
+
}, []);
|
|
369
|
+
const isPlaying = useCallback(() => {
|
|
370
|
+
return navigatorInstance?.isPlaying || false;
|
|
371
|
+
}, []);
|
|
372
|
+
const isPaused = useCallback(() => {
|
|
373
|
+
return navigatorInstance?.isPaused || false;
|
|
374
|
+
}, []);
|
|
375
|
+
const duration = useCallback(() => {
|
|
376
|
+
return navigatorInstance?.duration || 0;
|
|
377
|
+
}, []);
|
|
378
|
+
const currentTime = useCallback(() => {
|
|
379
|
+
return navigatorInstance?.currentTime || 0;
|
|
380
|
+
}, []);
|
|
381
|
+
return {
|
|
382
|
+
AudioNavigatorLoad,
|
|
383
|
+
AudioNavigatorDestroy,
|
|
384
|
+
play,
|
|
385
|
+
pause,
|
|
386
|
+
stop,
|
|
387
|
+
seek,
|
|
388
|
+
jump,
|
|
389
|
+
skipForward,
|
|
390
|
+
skipBackward,
|
|
391
|
+
go,
|
|
392
|
+
goLink,
|
|
393
|
+
goForward,
|
|
394
|
+
goBackward,
|
|
395
|
+
currentLocator,
|
|
396
|
+
canGoBackward,
|
|
397
|
+
canGoForward,
|
|
398
|
+
isTrackStart,
|
|
399
|
+
isTrackEnd,
|
|
400
|
+
isPlaying,
|
|
401
|
+
isPaused,
|
|
402
|
+
duration,
|
|
403
|
+
currentTime,
|
|
404
|
+
preferencesEditor: navigatorInstance?.preferencesEditor,
|
|
405
|
+
remotePlayback: navigatorInstance?.remotePlayback,
|
|
406
|
+
getSetting,
|
|
407
|
+
submitPreferences,
|
|
408
|
+
timeline: useCallback(() => navigatorInstance?.timeline, [])
|
|
409
|
+
};
|
|
410
|
+
};
|
|
411
|
+
var useAudioSettingsCache = (volume, playbackRate, preservePitch, skipBackwardInterval, skipForwardInterval, skipInterval, pollInterval, autoPlay, enableMediaSession) => {
|
|
412
|
+
const cache = useRef({
|
|
413
|
+
settings: {
|
|
414
|
+
volume,
|
|
415
|
+
playbackRate,
|
|
416
|
+
preservePitch,
|
|
417
|
+
skipBackwardInterval,
|
|
418
|
+
skipForwardInterval,
|
|
419
|
+
skipInterval,
|
|
420
|
+
pollInterval,
|
|
421
|
+
autoPlay,
|
|
422
|
+
enableMediaSession
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
const memoizedCache = useMemo(() => ({
|
|
426
|
+
settings: {
|
|
427
|
+
volume,
|
|
428
|
+
playbackRate,
|
|
429
|
+
preservePitch,
|
|
430
|
+
skipBackwardInterval,
|
|
431
|
+
skipForwardInterval,
|
|
432
|
+
skipInterval,
|
|
433
|
+
pollInterval,
|
|
434
|
+
autoPlay,
|
|
435
|
+
enableMediaSession
|
|
436
|
+
}
|
|
437
|
+
}), [
|
|
438
|
+
volume,
|
|
439
|
+
playbackRate,
|
|
440
|
+
preservePitch,
|
|
441
|
+
skipBackwardInterval,
|
|
442
|
+
skipForwardInterval,
|
|
443
|
+
skipInterval,
|
|
444
|
+
pollInterval,
|
|
445
|
+
autoPlay,
|
|
446
|
+
enableMediaSession
|
|
447
|
+
]);
|
|
448
|
+
cache.current = memoizedCache;
|
|
449
|
+
return cache;
|
|
450
|
+
};
|
|
451
|
+
var navigatorInstance2 = null;
|
|
318
452
|
var useEpubNavigator = () => {
|
|
319
453
|
const container = useRef(null);
|
|
320
454
|
const containerParent = useRef(null);
|
|
321
455
|
const publication = useRef(null);
|
|
322
456
|
const submitPreferences = useCallback(async (preferences) => {
|
|
323
|
-
await
|
|
457
|
+
await navigatorInstance2?.submitPreferences(new EpubPreferences(preferences));
|
|
324
458
|
}, []);
|
|
325
459
|
const getSetting = useCallback((settingKey) => {
|
|
326
|
-
return
|
|
460
|
+
return navigatorInstance2?.settings[settingKey];
|
|
327
461
|
}, []);
|
|
328
462
|
const FXLPositionChangedCallbackRef = useRef(void 0);
|
|
329
463
|
const FXLPositionChanged = useMemo(() => {
|
|
@@ -333,7 +467,7 @@ var useEpubNavigator = () => {
|
|
|
333
467
|
const newVal = mutation.target.getAttribute(mutation.attributeName);
|
|
334
468
|
const oldVal = mutation.oldValue;
|
|
335
469
|
if (newVal?.split(re)[1] !== oldVal?.split(re)[1]) {
|
|
336
|
-
const locator =
|
|
470
|
+
const locator = navigatorInstance2?.currentLocator;
|
|
337
471
|
if (locator && FXLPositionChangedCallbackRef.current) {
|
|
338
472
|
FXLPositionChangedCallbackRef.current(locator);
|
|
339
473
|
}
|
|
@@ -349,7 +483,7 @@ var useEpubNavigator = () => {
|
|
|
349
483
|
if (fxlCallback) {
|
|
350
484
|
FXLPositionChangedCallbackRef.current = fxlCallback;
|
|
351
485
|
}
|
|
352
|
-
|
|
486
|
+
navigatorInstance2 = new EpubNavigator(
|
|
353
487
|
config.container,
|
|
354
488
|
config.publication,
|
|
355
489
|
config.listeners,
|
|
@@ -362,10 +496,10 @@ var useEpubNavigator = () => {
|
|
|
362
496
|
contentProtection: config.contentProtection || void 0
|
|
363
497
|
}
|
|
364
498
|
);
|
|
365
|
-
|
|
499
|
+
navigatorInstance2.load().then(() => {
|
|
366
500
|
cb();
|
|
367
|
-
if (
|
|
368
|
-
FXLPositionChanged.observe(
|
|
501
|
+
if (navigatorInstance2?.layout === Layout.fixed) {
|
|
502
|
+
FXLPositionChanged.observe(navigatorInstance2?.pool.spineElement, {
|
|
369
503
|
attributeFilter: ["style"],
|
|
370
504
|
attributeOldValue: true
|
|
371
505
|
});
|
|
@@ -375,41 +509,41 @@ var useEpubNavigator = () => {
|
|
|
375
509
|
}, [FXLPositionChanged]);
|
|
376
510
|
const EpubNavigatorDestroy = useCallback((cb) => {
|
|
377
511
|
cb();
|
|
378
|
-
if (
|
|
512
|
+
if (navigatorInstance2?.layout === Layout.fixed) {
|
|
379
513
|
FXLPositionChanged.disconnect();
|
|
380
514
|
}
|
|
381
|
-
|
|
382
|
-
|
|
515
|
+
navigatorInstance2?.destroy().then(() => {
|
|
516
|
+
navigatorInstance2 = null;
|
|
383
517
|
});
|
|
384
518
|
}, [FXLPositionChanged]);
|
|
385
519
|
const goRight = useCallback((animated, callback) => {
|
|
386
|
-
|
|
520
|
+
navigatorInstance2?.goRight(animated, callback);
|
|
387
521
|
}, []);
|
|
388
522
|
const goLeft = useCallback((animated, callback) => {
|
|
389
|
-
|
|
523
|
+
navigatorInstance2?.goLeft(animated, callback);
|
|
390
524
|
}, []);
|
|
391
525
|
const goBackward = useCallback((animated, callback) => {
|
|
392
|
-
|
|
526
|
+
navigatorInstance2?.goBackward(animated, callback);
|
|
393
527
|
}, []);
|
|
394
528
|
const goForward = useCallback((animated, callback) => {
|
|
395
|
-
|
|
529
|
+
navigatorInstance2?.goForward(animated, callback);
|
|
396
530
|
}, []);
|
|
397
531
|
const goLink = useCallback((link, animated, callback) => {
|
|
398
|
-
|
|
532
|
+
navigatorInstance2?.goLink(link, animated, callback);
|
|
399
533
|
}, []);
|
|
400
534
|
const go = useCallback((locator, animated, callback) => {
|
|
401
|
-
|
|
535
|
+
navigatorInstance2?.go(locator, animated, callback);
|
|
402
536
|
}, []);
|
|
403
537
|
const navLayout = useCallback(() => {
|
|
404
|
-
return
|
|
538
|
+
return navigatorInstance2?.layout;
|
|
405
539
|
}, []);
|
|
406
540
|
const currentLocator = useCallback(() => {
|
|
407
|
-
return
|
|
541
|
+
return navigatorInstance2?.currentLocator;
|
|
408
542
|
}, []);
|
|
409
543
|
const getLocatorAtOffset = useCallback((offset) => {
|
|
410
|
-
const readingOrder =
|
|
544
|
+
const readingOrder = navigatorInstance2?.publication?.readingOrder;
|
|
411
545
|
if (!readingOrder) return null;
|
|
412
|
-
const currentLocator2 =
|
|
546
|
+
const currentLocator2 = navigatorInstance2?.currentLocator;
|
|
413
547
|
if (!currentLocator2) return null;
|
|
414
548
|
const currentLocatorIndex = readingOrder.findIndexWithHref(currentLocator2.href);
|
|
415
549
|
if (currentLocatorIndex === -1) return null;
|
|
@@ -420,30 +554,30 @@ var useEpubNavigator = () => {
|
|
|
420
554
|
const previousLocator = useCallback(() => {
|
|
421
555
|
const link = getLocatorAtOffset(-1);
|
|
422
556
|
if (!link) return null;
|
|
423
|
-
return
|
|
557
|
+
return navigatorInstance2?.publication?.manifest?.locatorFromLink(link);
|
|
424
558
|
}, [getLocatorAtOffset]);
|
|
425
559
|
const nextLocator = useCallback(() => {
|
|
426
560
|
const link = getLocatorAtOffset(1);
|
|
427
561
|
if (!link) return null;
|
|
428
|
-
return
|
|
562
|
+
return navigatorInstance2?.publication?.manifest?.locatorFromLink(link);
|
|
429
563
|
}, [getLocatorAtOffset]);
|
|
430
564
|
const currentPositions = useCallback(() => {
|
|
431
|
-
return
|
|
565
|
+
return navigatorInstance2?.viewport?.positions;
|
|
432
566
|
}, []);
|
|
433
567
|
const canGoBackward = useCallback(() => {
|
|
434
|
-
return
|
|
568
|
+
return navigatorInstance2?.canGoBackward;
|
|
435
569
|
}, []);
|
|
436
570
|
const canGoForward = useCallback(() => {
|
|
437
|
-
return
|
|
571
|
+
return navigatorInstance2?.canGoForward;
|
|
438
572
|
}, []);
|
|
439
573
|
const isScrollStart = useCallback(() => {
|
|
440
|
-
return
|
|
574
|
+
return navigatorInstance2?.isScrollStart;
|
|
441
575
|
}, []);
|
|
442
576
|
const isScrollEnd = useCallback(() => {
|
|
443
|
-
return
|
|
577
|
+
return navigatorInstance2?.isScrollEnd;
|
|
444
578
|
}, []);
|
|
445
579
|
const getCframes = useCallback(() => {
|
|
446
|
-
return
|
|
580
|
+
return navigatorInstance2?._cframes;
|
|
447
581
|
}, []);
|
|
448
582
|
return {
|
|
449
583
|
EpubNavigatorLoad,
|
|
@@ -463,7 +597,7 @@ var useEpubNavigator = () => {
|
|
|
463
597
|
canGoForward,
|
|
464
598
|
isScrollStart,
|
|
465
599
|
isScrollEnd,
|
|
466
|
-
preferencesEditor:
|
|
600
|
+
preferencesEditor: navigatorInstance2?.preferencesEditor,
|
|
467
601
|
getSetting,
|
|
468
602
|
submitPreferences,
|
|
469
603
|
getCframes,
|
|
@@ -533,23 +667,23 @@ var useEpubSettingsCache = (textAlign, columnCount, fontFamily, fontSize, fontWe
|
|
|
533
667
|
cache.current = memoizedCache;
|
|
534
668
|
return cache;
|
|
535
669
|
};
|
|
536
|
-
var
|
|
670
|
+
var navigatorInstance3 = null;
|
|
537
671
|
var useWebPubNavigator = () => {
|
|
538
672
|
const container = useRef(null);
|
|
539
673
|
const containerParent = useRef(null);
|
|
540
674
|
const publication = useRef(null);
|
|
541
675
|
const submitPreferences = useCallback(async (preferences) => {
|
|
542
|
-
await
|
|
676
|
+
await navigatorInstance3?.submitPreferences(new WebPubPreferences(preferences));
|
|
543
677
|
}, []);
|
|
544
678
|
const getSetting = useCallback((settingKey) => {
|
|
545
|
-
return
|
|
679
|
+
return navigatorInstance3?.settings[settingKey];
|
|
546
680
|
}, []);
|
|
547
681
|
const WebPubNavigatorLoad = useCallback((config, cb) => {
|
|
548
682
|
if (config.container) {
|
|
549
683
|
container.current = config.container;
|
|
550
684
|
containerParent.current = container.current?.parentElement || null;
|
|
551
685
|
publication.current = config.publication;
|
|
552
|
-
|
|
686
|
+
navigatorInstance3 = new ExperimentalWebPubNavigator(
|
|
553
687
|
config.container,
|
|
554
688
|
config.publication,
|
|
555
689
|
config.listeners,
|
|
@@ -561,42 +695,42 @@ var useWebPubNavigator = () => {
|
|
|
561
695
|
contentProtection: config.contentProtection || void 0
|
|
562
696
|
}
|
|
563
697
|
);
|
|
564
|
-
|
|
698
|
+
navigatorInstance3.load().then(() => {
|
|
565
699
|
cb();
|
|
566
700
|
});
|
|
567
701
|
}
|
|
568
702
|
}, []);
|
|
569
703
|
const WebPubNavigatorDestroy = useCallback((cb) => {
|
|
570
704
|
cb();
|
|
571
|
-
|
|
572
|
-
|
|
705
|
+
navigatorInstance3?.destroy().then(() => {
|
|
706
|
+
navigatorInstance3 = null;
|
|
573
707
|
});
|
|
574
708
|
}, []);
|
|
575
709
|
const goRight = useCallback((animated, callback) => {
|
|
576
|
-
|
|
710
|
+
navigatorInstance3?.goRight(animated, callback);
|
|
577
711
|
}, []);
|
|
578
712
|
const goLeft = useCallback((animated, callback) => {
|
|
579
|
-
|
|
713
|
+
navigatorInstance3?.goLeft(animated, callback);
|
|
580
714
|
}, []);
|
|
581
715
|
const goBackward = useCallback((animated, callback) => {
|
|
582
|
-
|
|
716
|
+
navigatorInstance3?.goBackward(animated, callback);
|
|
583
717
|
}, []);
|
|
584
718
|
const goForward = useCallback((animated, callback) => {
|
|
585
|
-
|
|
719
|
+
navigatorInstance3?.goForward(animated, callback);
|
|
586
720
|
}, []);
|
|
587
721
|
const goLink = useCallback((link, animated, callback) => {
|
|
588
|
-
|
|
722
|
+
navigatorInstance3?.goLink(link, animated, callback);
|
|
589
723
|
}, []);
|
|
590
724
|
const go = useCallback((locator, animated, callback) => {
|
|
591
|
-
|
|
725
|
+
navigatorInstance3?.go(locator, animated, callback);
|
|
592
726
|
}, []);
|
|
593
727
|
const currentLocator = useCallback(() => {
|
|
594
|
-
return
|
|
728
|
+
return navigatorInstance3?.currentLocator;
|
|
595
729
|
}, []);
|
|
596
730
|
const getLocatorAtOffset = useCallback((offset) => {
|
|
597
|
-
const readingOrder =
|
|
731
|
+
const readingOrder = navigatorInstance3?.publication?.readingOrder;
|
|
598
732
|
if (!readingOrder) return null;
|
|
599
|
-
const currentLocator2 =
|
|
733
|
+
const currentLocator2 = navigatorInstance3?.currentLocator;
|
|
600
734
|
if (!currentLocator2) return null;
|
|
601
735
|
const currentLocatorIndex = readingOrder.findIndexWithHref(currentLocator2.href);
|
|
602
736
|
if (currentLocatorIndex === -1) return null;
|
|
@@ -607,30 +741,30 @@ var useWebPubNavigator = () => {
|
|
|
607
741
|
const previousLocator = useCallback(() => {
|
|
608
742
|
const link = getLocatorAtOffset(-1);
|
|
609
743
|
if (!link) return null;
|
|
610
|
-
return
|
|
744
|
+
return navigatorInstance3?.publication?.manifest?.locatorFromLink(link);
|
|
611
745
|
}, [getLocatorAtOffset]);
|
|
612
746
|
const nextLocator = useCallback(() => {
|
|
613
747
|
const link = getLocatorAtOffset(1);
|
|
614
748
|
if (!link) return null;
|
|
615
|
-
return
|
|
749
|
+
return navigatorInstance3?.publication?.manifest?.locatorFromLink(link);
|
|
616
750
|
}, [getLocatorAtOffset]);
|
|
617
751
|
const currentPositions = useCallback(() => {
|
|
618
|
-
return
|
|
752
|
+
return navigatorInstance3?.viewport?.positions;
|
|
619
753
|
}, []);
|
|
620
754
|
const canGoBackward = useCallback(() => {
|
|
621
|
-
return
|
|
755
|
+
return navigatorInstance3?.canGoBackward;
|
|
622
756
|
}, []);
|
|
623
757
|
const canGoForward = useCallback(() => {
|
|
624
|
-
return
|
|
758
|
+
return navigatorInstance3?.canGoForward;
|
|
625
759
|
}, []);
|
|
626
760
|
const isScrollStart = useCallback(() => {
|
|
627
|
-
return
|
|
761
|
+
return navigatorInstance3?.isScrollStart;
|
|
628
762
|
}, []);
|
|
629
763
|
const isScrollEnd = useCallback(() => {
|
|
630
|
-
return
|
|
764
|
+
return navigatorInstance3?.isScrollEnd;
|
|
631
765
|
}, []);
|
|
632
766
|
const getCframes = useCallback(() => {
|
|
633
|
-
return
|
|
767
|
+
return navigatorInstance3?._cframes;
|
|
634
768
|
}, []);
|
|
635
769
|
return {
|
|
636
770
|
WebPubNavigatorLoad,
|
|
@@ -649,7 +783,7 @@ var useWebPubNavigator = () => {
|
|
|
649
783
|
canGoForward,
|
|
650
784
|
isScrollStart,
|
|
651
785
|
isScrollEnd,
|
|
652
|
-
preferencesEditor:
|
|
786
|
+
preferencesEditor: navigatorInstance3?.preferencesEditor,
|
|
653
787
|
getSetting,
|
|
654
788
|
submitPreferences,
|
|
655
789
|
getCframes
|
|
@@ -705,6 +839,6 @@ var useWebPubSettingsCache = (fontFamily, fontWeight, hyphens, letterSpacing, li
|
|
|
705
839
|
return cache;
|
|
706
840
|
};
|
|
707
841
|
|
|
708
|
-
export { timelineInstance, useDocumentTitle, useEpubNavigator, useEpubSettingsCache, useFullscreen, useIsClient, useLocalStorage, useTimeline, useWebPubNavigator, useWebPubSettingsCache };
|
|
709
|
-
//# sourceMappingURL=chunk-
|
|
710
|
-
//# sourceMappingURL=chunk-
|
|
842
|
+
export { timelineInstance, useAudioNavigator, useAudioSettingsCache, useDocumentTitle, useEpubNavigator, useEpubSettingsCache, useFullscreen, useIsClient, useLocalStorage, useTimeline, useWebPubNavigator, useWebPubSettingsCache };
|
|
843
|
+
//# sourceMappingURL=chunk-A3FZBEUL.mjs.map
|
|
844
|
+
//# sourceMappingURL=chunk-A3FZBEUL.mjs.map
|