@edrlab/thorium-web 1.5.4 → 1.5.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/dist/{ThPreferencesAdapter-B3a-f5v-.d.mts → ThPreferencesAdapter-GepvYoaL.d.mts} +4 -3
- package/dist/{ThSettingsWrapper-D4WIzlXA.d.mts → ThSettingsWrapper-DyYC678Q.d.mts} +1 -1
- package/dist/{actions-C33UN3Ji.d.mts → actions-CTg9C4C-.d.mts} +1 -1
- package/dist/{actionsReducer-Bzcj3wk3.d.mts → actionsReducer-Cnd7Cdh9.d.mts} +1 -1
- package/dist/{chunk-VYSDLACR.mjs → chunk-3R5JARA2.mjs} +3 -3
- package/dist/{chunk-VYSDLACR.mjs.map → chunk-3R5JARA2.mjs.map} +1 -1
- package/dist/{chunk-X6Z4WZLX.mjs → chunk-5IT53TCU.mjs} +55 -35
- package/dist/chunk-5IT53TCU.mjs.map +1 -0
- package/dist/{chunk-7WGC22F3.mjs → chunk-6DR4EAK3.mjs} +42 -49
- package/dist/chunk-6DR4EAK3.mjs.map +1 -0
- package/dist/chunk-7SMOXFAF.mjs +121 -0
- package/dist/chunk-7SMOXFAF.mjs.map +1 -0
- package/dist/{chunk-AEEGHJVM.mjs → chunk-CXKDZVAV.mjs} +113 -258
- package/dist/chunk-CXKDZVAV.mjs.map +1 -0
- package/dist/{chunk-MD5LZNDG.mjs → chunk-DKF53WEQ.mjs} +39 -16
- package/dist/chunk-DKF53WEQ.mjs.map +1 -0
- package/dist/{chunk-GFSLVQIG.mjs → chunk-EREFYF5J.mjs} +3 -3
- package/dist/{chunk-GFSLVQIG.mjs.map → chunk-EREFYF5J.mjs.map} +1 -1
- package/dist/{chunk-YE5QOQUT.mjs → chunk-I765HTBI.mjs} +15 -109
- package/dist/chunk-I765HTBI.mjs.map +1 -0
- package/dist/{chunk-G4T4RXFB.mjs → chunk-LF6IMH7J.mjs} +83 -70
- package/dist/chunk-LF6IMH7J.mjs.map +1 -0
- package/dist/{chunk-NQ2ZSGCX.mjs → chunk-MFVZ5AEN.mjs} +7 -3
- package/dist/chunk-MFVZ5AEN.mjs.map +1 -0
- package/dist/{chunk-2YRT7RNW.mjs → chunk-QOU3R5ZT.mjs} +9 -3
- package/dist/chunk-QOU3R5ZT.mjs.map +1 -0
- package/dist/{chunk-G35H3K32.mjs → chunk-VWKUZP5V.mjs} +43 -48
- package/dist/chunk-VWKUZP5V.mjs.map +1 -0
- package/dist/{chunk-IVCUCIYN.mjs → chunk-WOJR6ALR.mjs} +41 -18
- package/dist/chunk-WOJR6ALR.mjs.map +1 -0
- package/dist/components/Audio/index.css +1 -0
- package/dist/components/Audio/index.css.map +1 -1
- package/dist/components/Audio/index.d.mts +13 -13
- package/dist/components/Audio/index.mjs +10 -11
- package/dist/components/Epub/index.d.mts +13 -13
- package/dist/components/Epub/index.mjs +11 -12
- package/dist/components/Reader/index.css +1 -0
- package/dist/components/Reader/index.css.map +1 -1
- package/dist/components/Reader/index.d.mts +12 -12
- package/dist/components/Reader/index.mjs +18 -18
- package/dist/components/Reader/index.mjs.map +1 -1
- package/dist/components/WebPub/index.d.mts +13 -13
- package/dist/components/WebPub/index.mjs +11 -12
- package/dist/core/Components/index.d.mts +6 -6
- package/dist/core/Helpers/index.d.mts +4 -4
- package/dist/core/Helpers/index.mjs +2 -2
- package/dist/core/Hooks/index.d.mts +14 -9
- package/dist/core/Hooks/index.mjs +4 -4
- package/dist/lib/index.d.mts +43 -33
- package/dist/lib/index.mjs +3 -4
- package/dist/locales/ar/thorium-shared.json +39 -0
- package/dist/locales/bg/thorium-web.json +23 -0
- package/dist/locales/brh/thorium-shared.json +1 -0
- package/dist/locales/brh/thorium-web.json +1 -0
- package/dist/locales/da/thorium-shared.json +3 -0
- package/dist/locales/el/thorium-web.json +41 -6
- package/dist/locales/en/thorium-shared.json +3 -0
- package/dist/locales/es/thorium-shared.json +3 -0
- package/dist/locales/et/thorium-shared.json +3 -0
- package/dist/locales/fi/thorium-shared.json +3 -0
- package/dist/locales/fi/thorium-web.json +4 -4
- package/dist/locales/he/thorium-shared.json +3 -1
- package/dist/locales/it/thorium-shared.json +3 -0
- package/dist/locales/lt/thorium-shared.json +30 -4
- package/dist/locales/pt-PT/thorium-shared.json +8 -5
- package/dist/locales/sv/thorium-shared.json +3 -3
- package/dist/locales/sv/thorium-web.json +7 -7
- package/dist/locales/tr/thorium-shared.json +80 -0
- package/dist/preferences/index.d.mts +10 -10
- package/dist/preferences/index.mjs +4 -5
- package/dist/{settingsReducer-Pp9aoiiC.d.mts → settingsReducer-DRWEq8Cm.d.mts} +1 -1
- package/dist/{ui-DnZZhozX.d.mts → ui-DHQ_zvWn.d.mts} +7 -1
- package/dist/{useAudioNavigator-9RuOpLGB.d.mts → useAudioNavigator-B4NBPvmZ.d.mts} +4 -5
- package/dist/{useContrast-Bl08zDTU.d.mts → useContrast-Unp3534Z.d.mts} +1 -1
- package/dist/{usePreferences-Cy7-JN2x.d.mts → usePreferences-Bi-ptif0.d.mts} +6 -9
- package/dist/usePublicationProgress-DT-X5ZLf.d.mts +44 -0
- package/dist/{useReaderTransitions-BsTdWZDK.d.mts → useReaderTransitions-B9fOF61y.d.mts} +10 -14
- package/package.json +13 -10
- package/dist/chunk-2YRT7RNW.mjs.map +0 -1
- package/dist/chunk-7WGC22F3.mjs.map +0 -1
- package/dist/chunk-A575ZW4A.mjs +0 -10
- package/dist/chunk-A575ZW4A.mjs.map +0 -1
- package/dist/chunk-AEEGHJVM.mjs.map +0 -1
- package/dist/chunk-G35H3K32.mjs.map +0 -1
- package/dist/chunk-G4T4RXFB.mjs.map +0 -1
- package/dist/chunk-IVCUCIYN.mjs.map +0 -1
- package/dist/chunk-MD5LZNDG.mjs.map +0 -1
- package/dist/chunk-NQ2ZSGCX.mjs.map +0 -1
- package/dist/chunk-TEZB4ULX.mjs +0 -57
- package/dist/chunk-TEZB4ULX.mjs.map +0 -1
- package/dist/chunk-X6Z4WZLX.mjs.map +0 -1
- package/dist/chunk-YE5QOQUT.mjs.map +0 -1
- package/dist/useTimeline-DCZ1qoCO.d.mts +0 -55
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
+
|
|
3
|
+
// src/lib/publicationReducer.ts
|
|
4
|
+
|
|
5
|
+
// src/helpers/buildTocTree.ts
|
|
6
|
+
var toEntryRef = ({ children: _, ...ref }) => ref;
|
|
7
|
+
var buildTocTreeFromTimeline = (timeline, publicationTitle) => {
|
|
8
|
+
let counter = 0;
|
|
9
|
+
const map = (entries) => entries.map((entry) => {
|
|
10
|
+
counter += 1;
|
|
11
|
+
return {
|
|
12
|
+
id: `toc-${counter}`,
|
|
13
|
+
href: entry.link.href,
|
|
14
|
+
title: entry.link.title || (publicationTitle ? `${publicationTitle} ${counter}` : `Resource ${counter}`),
|
|
15
|
+
position: entry.position ?? entry.timestamp,
|
|
16
|
+
children: entry.children ? map(entry.children) : void 0
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
return map(timeline.contextualizedToc);
|
|
20
|
+
};
|
|
21
|
+
var findTocItemById = (items, id) => {
|
|
22
|
+
for (const item of items) {
|
|
23
|
+
if (item.id === id) return item;
|
|
24
|
+
if (item.children) {
|
|
25
|
+
const found = findTocItemById(item.children, id);
|
|
26
|
+
if (found) return found;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return void 0;
|
|
30
|
+
};
|
|
31
|
+
var findTocItemByHref = (items, href) => {
|
|
32
|
+
for (const item of items) {
|
|
33
|
+
if (item.href === href) return item;
|
|
34
|
+
if (item.children) {
|
|
35
|
+
const found = findTocItemByHref(item.children, href);
|
|
36
|
+
if (found) return found;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return void 0;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/lib/publicationReducer.ts
|
|
43
|
+
var initialState = {
|
|
44
|
+
fontLanguage: "default",
|
|
45
|
+
isFXL: false,
|
|
46
|
+
isRTL: false,
|
|
47
|
+
scriptMode: "ltr",
|
|
48
|
+
hasDisplayTransformability: false,
|
|
49
|
+
positionsList: [],
|
|
50
|
+
atPublicationStart: false,
|
|
51
|
+
atPublicationEnd: false,
|
|
52
|
+
progress: void 0,
|
|
53
|
+
toc: { tree: void 0, currentEntry: void 0 },
|
|
54
|
+
adjacentTimelineItems: { previous: null, next: null },
|
|
55
|
+
coverTheme: void 0
|
|
56
|
+
};
|
|
57
|
+
var publicationSlice = createSlice({
|
|
58
|
+
name: "publication",
|
|
59
|
+
initialState,
|
|
60
|
+
reducers: {
|
|
61
|
+
setFontLanguage: (state, action) => {
|
|
62
|
+
state.fontLanguage = action.payload;
|
|
63
|
+
},
|
|
64
|
+
setFXL: (state, action) => {
|
|
65
|
+
state.isFXL = action.payload;
|
|
66
|
+
},
|
|
67
|
+
setRTL: (state, action) => {
|
|
68
|
+
state.isRTL = action.payload;
|
|
69
|
+
},
|
|
70
|
+
setScriptMode: (state, action) => {
|
|
71
|
+
state.scriptMode = action.payload;
|
|
72
|
+
},
|
|
73
|
+
setHasDisplayTransformability: (state, action) => {
|
|
74
|
+
state.hasDisplayTransformability = action.payload;
|
|
75
|
+
},
|
|
76
|
+
setPositionsList: (state, action) => {
|
|
77
|
+
state.positionsList = action.payload;
|
|
78
|
+
},
|
|
79
|
+
setPublicationStart: (state, action) => {
|
|
80
|
+
state.atPublicationStart = action.payload;
|
|
81
|
+
},
|
|
82
|
+
setPublicationEnd: (state, action) => {
|
|
83
|
+
state.atPublicationEnd = action.payload;
|
|
84
|
+
},
|
|
85
|
+
setProgress: (state, action) => {
|
|
86
|
+
state.progress = action.payload;
|
|
87
|
+
},
|
|
88
|
+
setTocTree: (state, action) => {
|
|
89
|
+
state.toc.tree = action.payload;
|
|
90
|
+
},
|
|
91
|
+
setAdjacentTimelineItems: (state, action) => {
|
|
92
|
+
state.adjacentTimelineItems = action.payload;
|
|
93
|
+
},
|
|
94
|
+
setCoverTheme: (state, action) => {
|
|
95
|
+
state.coverTheme = action.payload;
|
|
96
|
+
},
|
|
97
|
+
setTocEntry: (state, action) => {
|
|
98
|
+
state.toc.currentEntry = action.payload ? toEntryRef(action.payload) : null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var {
|
|
103
|
+
setFontLanguage,
|
|
104
|
+
setFXL,
|
|
105
|
+
setRTL,
|
|
106
|
+
setScriptMode,
|
|
107
|
+
setHasDisplayTransformability,
|
|
108
|
+
setPositionsList,
|
|
109
|
+
setPublicationStart,
|
|
110
|
+
setPublicationEnd,
|
|
111
|
+
setProgress,
|
|
112
|
+
setTocTree,
|
|
113
|
+
setTocEntry,
|
|
114
|
+
setAdjacentTimelineItems,
|
|
115
|
+
setCoverTheme
|
|
116
|
+
} = publicationSlice.actions;
|
|
117
|
+
var publicationReducer_default = publicationSlice.reducer;
|
|
118
|
+
|
|
119
|
+
export { buildTocTreeFromTimeline, findTocItemByHref, findTocItemById, publicationReducer_default, publicationSlice, setAdjacentTimelineItems, setCoverTheme, setFXL, setFontLanguage, setHasDisplayTransformability, setPositionsList, setProgress, setPublicationEnd, setPublicationStart, setRTL, setScriptMode, setTocEntry, setTocTree };
|
|
120
|
+
//# sourceMappingURL=chunk-7SMOXFAF.mjs.map
|
|
121
|
+
//# sourceMappingURL=chunk-7SMOXFAF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/buildTocTree.ts","../src/lib/publicationReducer.ts"],"names":[],"mappings":";;;;;AAYO,IAAM,aAAa,CAAC,EAAE,UAAU,CAAA,EAAG,GAAG,KAAI,KAA4B,GAAA;AAEtE,IAAM,wBAAA,GAA2B,CAAC,QAAA,EAAoB,gBAAA,KAAyC;AACpG,EAAA,IAAI,OAAA,GAAU,CAAA;AAEd,EAAA,MAAM,MAAM,CAAC,OAAA,KACX,OAAA,CAAQ,GAAA,CAAI,CAAC,KAAA,KAAU;AACrB,IAAA,OAAA,IAAW,CAAA;AAEX,I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AAA,EACA,WAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,wBAAA;AAAA,EACA;AACF,CAAA,GAAI,gBAAA,CAAiB;AAErB,IAAO,6BAAQ,gBAAA,CAAiB","file":"chunk-7SMOXFAF.mjs","sourcesContent":["import { ContextualizedTocEntry, Timeline } from \"@readium/shared\";\n\nexport interface TocItem {\n id: string;\n href: string;\n title: string;\n position?: string;\n children?: TocItem[];\n}\n\nexport type TocEntryRef = Omit<TocItem, \"children\">;\n\nexport const toEntryRef = ({ children: _, ...ref }: TocItem): TocEntryRef => ref;\n\nexport const buildTocTreeFromTimeline = (timeline: Timeline, publicationTitle?: string): TocItem[] => {\n let counter = 0;\n\n const map = (entries: ContextualizedTocEntry[]): TocItem[] =>\n entries.map((entry) => {\n counter += 1;\n\n return {\n id: `toc-${ counter }`,\n href: entry.link.href,\n title: entry.link.title || (\n publicationTitle\n ? `${ publicationTitle } ${ counter }`\n : `Resource ${ counter }`\n ),\n position: entry.position ?? entry.timestamp,\n children: entry.children ? map(entry.children) : undefined\n };\n });\n\n return map(timeline.contextualizedToc);\n};\n\nexport const findTocItemById = (items: TocItem[], id: string): TocItem | undefined => {\n for (const item of items) {\n if (item.id === id) return item;\n if (item.children) {\n const found = findTocItemById(item.children, id);\n if (found) return found;\n }\n }\n return undefined;\n};\n\nexport const findTocItemByHref = (items: TocItem[], href: string): TocItem | undefined => {\n for (const item of items) {\n if (item.href === href) return item;\n if (item.children) {\n const found = findTocItemByHref(item.children, href);\n if (found) return found;\n }\n }\n return undefined;\n};\n","import { createSlice } from \"@reduxjs/toolkit\";\n\nimport { SerializedLocator } from \"@/helpers/serializePositions\";\nimport { ThemeTokens } from \"@/preferences/hooks/useTheming\";\nimport { ScriptMode } from \"@readium/navigator\";\nimport { Progress } from \"@/core/Hooks/usePublicationProgress\";\nimport { TocItem, TocEntryRef, toEntryRef } from \"@/helpers/buildTocTree\";\n\nexport interface TimelineItemRef {\n title?: string;\n href: string;\n}\n\nexport interface PublicationReducerState {\n fontLanguage: string;\n isFXL: boolean;\n isRTL: boolean;\n scriptMode: ScriptMode;\n hasDisplayTransformability: boolean;\n positionsList: SerializedLocator[],\n atPublicationStart: boolean;\n atPublicationEnd: boolean;\n progress?: Progress;\n toc: {\n tree?: TocItem[];\n currentEntry?: TocEntryRef | null;\n };\n adjacentTimelineItems: {\n previous: TimelineItemRef | null;\n next: TimelineItemRef | null;\n };\n coverTheme?: ThemeTokens;\n}\n\nconst initialState: PublicationReducerState = {\n fontLanguage: \"default\",\n isFXL: false,\n isRTL: false,\n scriptMode: \"ltr\",\n hasDisplayTransformability: false,\n positionsList: [],\n atPublicationStart: false,\n atPublicationEnd: false,\n progress: undefined,\n toc: { tree: undefined, currentEntry: undefined },\n adjacentTimelineItems: { previous: null, next: null },\n coverTheme: undefined,\n}\n\nexport const publicationSlice = createSlice({\n name: \"publication\",\n initialState,\n reducers: {\n setFontLanguage: (state, action) => {\n state.fontLanguage = action.payload\n },\n setFXL: (state, action) => {\n state.isFXL = action.payload\n },\n setRTL: (state, action) => {\n state.isRTL = action.payload\n },\n setScriptMode: (state, action) => {\n state.scriptMode = action.payload\n },\n setHasDisplayTransformability: (state, action) => {\n state.hasDisplayTransformability = action.payload\n },\n setPositionsList: (state, action) => {\n state.positionsList = action.payload\n },\n setPublicationStart: (state, action) => {\n state.atPublicationStart = action.payload\n },\n setPublicationEnd: (state, action) => {\n state.atPublicationEnd = action.payload\n },\n setProgress: (state, action: { payload: Progress }) => {\n state.progress = action.payload;\n },\n setTocTree: (state, action: { payload: TocItem[] | undefined }) => {\n state.toc.tree = action.payload;\n },\n setAdjacentTimelineItems: (state, action: { payload: { previous: TimelineItemRef | null; next: TimelineItemRef | null } }) => {\n state.adjacentTimelineItems = action.payload;\n },\n setCoverTheme: (state, action: { payload: ThemeTokens | undefined }) => {\n state.coverTheme = action.payload;\n },\n setTocEntry: (state, action: { payload: TocItem | null }) => {\n state.toc.currentEntry = action.payload ? toEntryRef(action.payload) : null;\n }\n }\n});\n\n// Action creators are generated for each case reducer function\nexport const {\n setFontLanguage,\n setFXL,\n setRTL,\n setScriptMode,\n setHasDisplayTransformability,\n setPositionsList,\n setPublicationStart,\n setPublicationEnd,\n setProgress,\n setTocTree,\n setTocEntry,\n setAdjacentTimelineItems,\n setCoverTheme,\n} = publicationSlice.actions;\n\nexport default publicationSlice.reducer;\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setAdjacentTimelineItems } from './chunk-7SMOXFAF.mjs';
|
|
2
|
+
import { useAppDispatch } from './chunk-MFVZ5AEN.mjs';
|
|
2
3
|
import { isIOSish } from './chunk-KQ3KS5O5.mjs';
|
|
3
4
|
import { useEffect, useState, useRef, useCallback, useMemo } from 'react';
|
|
4
|
-
import { Layout, Link, Locator } from '@readium/shared';
|
|
5
5
|
import { AudioPreferences, AudioNavigator, EpubPreferences, EpubNavigator, getScriptMode, WebPubPreferences, ExperimentalWebPubNavigator } from '@readium/navigator';
|
|
6
|
+
import { Locator } from '@readium/shared';
|
|
6
7
|
|
|
7
8
|
var useDocumentTitle = (title) => {
|
|
8
9
|
useEffect(() => {
|
|
@@ -93,220 +94,109 @@ var useObservableCondition = (value) => {
|
|
|
93
94
|
}, [value]);
|
|
94
95
|
return condition;
|
|
95
96
|
};
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
|
|
98
|
+
// src/helpers/timelineFallback.ts
|
|
99
|
+
var walkPrecedingResources = (timeline, href, resolve) => {
|
|
100
|
+
const timelineItems = timeline.items;
|
|
101
|
+
const startIndex = timelineItems.findIndex((item) => timeline.linkFor(item)?.href === href);
|
|
102
|
+
if (startIndex === -1) return void 0;
|
|
103
|
+
for (let i = startIndex - 1; i >= 0; i--) {
|
|
104
|
+
const candidate = timelineItems[i];
|
|
105
|
+
if (!candidate) continue;
|
|
106
|
+
const result = resolve(candidate, startIndex - i);
|
|
107
|
+
if (result !== void 0) return result;
|
|
108
|
+
}
|
|
109
|
+
return void 0;
|
|
110
|
+
};
|
|
111
|
+
var resolveChapterTitle = (timeline, item) => {
|
|
112
|
+
if (item.title !== void 0) return item.title;
|
|
113
|
+
const href = timeline.linkFor(item)?.href;
|
|
114
|
+
if (!href) return void 0;
|
|
115
|
+
return walkPrecedingResources(
|
|
116
|
+
timeline,
|
|
117
|
+
href,
|
|
118
|
+
(candidate, stepsBack) => candidate.title !== void 0 ? `${candidate.title} (${stepsBack + 1})` : void 0
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/core/Hooks/usePublicationProgress.ts
|
|
123
|
+
var usePublicationProgress = ({
|
|
98
124
|
publication,
|
|
125
|
+
getNavigatorTimeline,
|
|
126
|
+
currentTimelineItem,
|
|
99
127
|
currentLocation,
|
|
100
128
|
currentPositions,
|
|
101
129
|
positionsList,
|
|
102
130
|
onChange
|
|
103
131
|
}) => {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const [currentTocEntry, setCurrentTocEntry] = useState(null);
|
|
108
|
-
const [currentItem, setCurrentItem] = useState(null);
|
|
109
|
-
const [previousItem, setPreviousItem] = useState(null);
|
|
110
|
-
const [nextItem, setNextItem] = useState(null);
|
|
111
|
-
const [relativeProgression, setRelativeProgression] = useState(void 0);
|
|
112
|
-
const [totalProgression, setTotalProgression] = useState(void 0);
|
|
113
|
-
const idCounterRef = useRef(0);
|
|
114
|
-
const timeline = useMemo(() => ({
|
|
115
|
-
title: publication?.metadata.title.getTranslation("en"),
|
|
116
|
-
items: timelineItems,
|
|
117
|
-
toc: {
|
|
118
|
-
tree: tocTree,
|
|
119
|
-
currentEntry: currentTocEntry
|
|
120
|
-
},
|
|
121
|
-
currentItem,
|
|
122
|
-
previousItem,
|
|
123
|
-
nextItem,
|
|
124
|
-
progression: {
|
|
125
|
-
totalItems: publication?.readingOrder.items.length,
|
|
126
|
-
currentIndex: currentItem?.readingOrderIndex !== void 0 ? currentItem.readingOrderIndex + 1 : void 0,
|
|
127
|
-
totalPositions: positionsList?.length,
|
|
128
|
-
currentPositions: currentPositions || [],
|
|
129
|
-
relativeProgression,
|
|
130
|
-
totalProgression,
|
|
131
|
-
currentChapter: currentItem?.title,
|
|
132
|
-
positionsLeft: (() => {
|
|
133
|
-
const endPosition = currentItem?.positionRange?.[1];
|
|
134
|
-
const currentPosition = currentPositions?.[0];
|
|
135
|
-
if (!positionsList?.length || endPosition === void 0 || currentPosition === void 0) {
|
|
136
|
-
return void 0;
|
|
137
|
-
}
|
|
138
|
-
return Math.max(0, endPosition - currentPosition);
|
|
139
|
-
})()
|
|
140
|
-
}
|
|
141
|
-
}), [
|
|
142
|
-
publication?.metadata.title,
|
|
143
|
-
publication?.readingOrder.items,
|
|
144
|
-
timelineItems,
|
|
145
|
-
tocTree,
|
|
146
|
-
currentTocEntry,
|
|
147
|
-
currentItem,
|
|
148
|
-
previousItem,
|
|
149
|
-
nextItem,
|
|
150
|
-
positionsList,
|
|
151
|
-
currentPositions,
|
|
152
|
-
relativeProgression,
|
|
153
|
-
totalProgression
|
|
154
|
-
]);
|
|
155
|
-
const handleTocEntryOnNav = useCallback((locator, currentPos) => {
|
|
156
|
-
if (!locator || !tocTree.length) return;
|
|
157
|
-
const findMatch = (items, link) => {
|
|
158
|
-
for (const item of items) {
|
|
159
|
-
if (item.href === link?.href) {
|
|
160
|
-
return item;
|
|
161
|
-
}
|
|
162
|
-
if (item.children) {
|
|
163
|
-
const match = findMatch(item.children, link);
|
|
164
|
-
if (match) return match;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return void 0;
|
|
168
|
-
};
|
|
169
|
-
const currentMatch = findMatch(tocTree, new Link(locator));
|
|
170
|
-
if (currentMatch) {
|
|
171
|
-
setCurrentTocEntry((prev) => prev?.id === currentMatch.id ? prev : toEntryRef(currentMatch));
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (layout === Layout.fixed) {
|
|
175
|
-
if (currentPos && currentPos.length === 2) {
|
|
176
|
-
const otherPosition = currentPos[0] === locator.locations.position ? currentPos[1] : currentPos[0];
|
|
177
|
-
const otherPositionInList = positionsList?.find((pos) => pos.locations.position === otherPosition);
|
|
178
|
-
if (otherPositionInList) {
|
|
179
|
-
const match = findMatch(tocTree, new Link(otherPositionInList));
|
|
180
|
-
if (match) {
|
|
181
|
-
setCurrentTocEntry((prev) => prev?.id === match.id ? prev : toEntryRef(match));
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const otherPositions = currentPos?.filter((pos) => pos !== locator.locations.position) || [];
|
|
188
|
-
for (const otherPosition of otherPositions) {
|
|
189
|
-
const otherPositionInList = positionsList?.find((pos) => pos.locations.position === otherPosition);
|
|
190
|
-
if (otherPositionInList) {
|
|
191
|
-
const match = findMatch(tocTree, new Link(otherPositionInList));
|
|
192
|
-
if (match) {
|
|
193
|
-
setCurrentTocEntry((prev) => prev?.id === match.id ? prev : toEntryRef(match));
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}, [tocTree, layout, positionsList]);
|
|
199
|
-
const buildTimelineItems = useCallback(() => {
|
|
200
|
-
const timelineItems2 = {};
|
|
132
|
+
const positionEntries = useMemo(() => {
|
|
133
|
+
const entries = {};
|
|
134
|
+
if (!positionsList?.length) return entries;
|
|
201
135
|
const readingOrder = publication?.readingOrder?.items || [];
|
|
202
|
-
const toc = publication?.toc?.items && publication?.toc?.items.length > 0 ? publication.toc.items : publication?.readingOrder?.items || [];
|
|
203
|
-
const flatToc = toc.flatMap((t) => [t, ...t.children?.items || []]);
|
|
204
|
-
const getBaseUrl = (url) => {
|
|
205
|
-
const [base] = url.split("#");
|
|
206
|
-
const [path] = base.split("?");
|
|
207
|
-
return path;
|
|
208
|
-
};
|
|
209
|
-
const findNearestTitle = (currentHref) => {
|
|
210
|
-
const currentIndex = readingOrder.findIndex((item) => getBaseUrl(item.href) === getBaseUrl(currentHref));
|
|
211
|
-
if (currentIndex === -1) return "";
|
|
212
|
-
for (let i = currentIndex; i >= 0; i--) {
|
|
213
|
-
const item = readingOrder[i];
|
|
214
|
-
const matchingTocItems = flatToc.filter(
|
|
215
|
-
(t) => getBaseUrl(t.href) === getBaseUrl(item.href)
|
|
216
|
-
);
|
|
217
|
-
const title = matchingTocItems[0]?.title?.trim();
|
|
218
|
-
if (title) {
|
|
219
|
-
const diff = currentIndex - i;
|
|
220
|
-
return diff > 0 ? `${title} (${diff + 1})` : title;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return "";
|
|
224
|
-
};
|
|
225
|
-
readingOrder.forEach((item, index) => {
|
|
226
|
-
const matchingTocItems = flatToc.filter((t) => {
|
|
227
|
-
const baseHref = getBaseUrl(t.href);
|
|
228
|
-
const baseItemHref = getBaseUrl(item.href);
|
|
229
|
-
return baseHref === baseItemHref;
|
|
230
|
-
});
|
|
231
|
-
const timelineItem = {
|
|
232
|
-
href: item.href,
|
|
233
|
-
readingOrderIndex: index,
|
|
234
|
-
title: item.title || matchingTocItems[0]?.title || findNearestTitle(item.href),
|
|
235
|
-
fragments: matchingTocItems.map((t) => t.href.split("#")[1]).filter(Boolean),
|
|
236
|
-
children: matchingTocItems[0]?.children?.items?.map((child) => ({
|
|
237
|
-
// We do not care about index for children
|
|
238
|
-
// since currentLocation is guaranteed to be in the reading order
|
|
239
|
-
title: child.title,
|
|
240
|
-
href: child.href
|
|
241
|
-
})) || []
|
|
242
|
-
};
|
|
243
|
-
timelineItems2[item.href] = timelineItem;
|
|
244
|
-
});
|
|
245
136
|
for (const item of readingOrder) {
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
timelineItem.progressionRange = start.progression !== void 0 ? [start.progression, end.progression] : void 0;
|
|
254
|
-
timelineItem.totalProgressionRange = start.totalProgression !== void 0 ? [start.totalProgression, end.totalProgression] : void 0;
|
|
255
|
-
}
|
|
137
|
+
const positions = positionsList.filter((p) => p.href === item.href).sort((a, b) => (a.locations?.position || 0) - (b.locations?.position || 0));
|
|
138
|
+
if (positions.length === 0) continue;
|
|
139
|
+
const start = positions[0].locations;
|
|
140
|
+
const end = positions.length > 1 ? positions[positions.length - 1].locations : start;
|
|
141
|
+
entries[item.href] = {
|
|
142
|
+
positionRange: start?.position !== void 0 ? [start.position, end?.position] : void 0
|
|
143
|
+
};
|
|
256
144
|
}
|
|
257
|
-
return
|
|
145
|
+
return entries;
|
|
258
146
|
}, [publication, positionsList]);
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
setTimelineItems(buildTimelineItems());
|
|
291
|
-
}, [publication, positionsList, buildTimelineItems]);
|
|
292
|
-
useEffect(() => {
|
|
293
|
-
if (!tocTree.length || !timelineItems) return;
|
|
294
|
-
if (currentLocation) {
|
|
295
|
-
handleTocEntryOnNav(currentLocation, currentPositions);
|
|
296
|
-
} else if (tocTree.length > 0) {
|
|
297
|
-
handleTocEntryOnNav(new Locator({ href: tocTree[0].href, type: "" }), currentPositions);
|
|
298
|
-
}
|
|
299
|
-
updateTimelineItems(currentLocation);
|
|
300
|
-
setRelativeProgression(currentLocation?.locations.progression);
|
|
301
|
-
setTotalProgression(currentLocation?.locations.totalProgression);
|
|
302
|
-
}, [currentLocation, currentPositions, tocTree, timelineItems, handleTocEntryOnNav, updateTimelineItems]);
|
|
147
|
+
const navigatorTimeline = getNavigatorTimeline();
|
|
148
|
+
const currentHref = currentLocation?.href;
|
|
149
|
+
const currentIndex = currentHref ? publication?.readingOrder.items.findIndex((item) => item.href === currentHref) : void 0;
|
|
150
|
+
const currentChapter = currentTimelineItem && navigatorTimeline ? resolveChapterTitle(navigatorTimeline, currentTimelineItem) : void 0;
|
|
151
|
+
const progress = useMemo(() => {
|
|
152
|
+
const positionRange = currentHref ? positionEntries[currentHref]?.positionRange : void 0;
|
|
153
|
+
const endPosition = positionRange?.[1];
|
|
154
|
+
const currentPosition = currentPositions?.[0];
|
|
155
|
+
return {
|
|
156
|
+
title: publication?.metadata.title.getTranslation("en"),
|
|
157
|
+
progression: {
|
|
158
|
+
totalItems: publication?.readingOrder.items.length,
|
|
159
|
+
currentIndex: currentIndex !== void 0 && currentIndex >= 0 ? currentIndex + 1 : void 0,
|
|
160
|
+
totalPositions: positionsList?.length,
|
|
161
|
+
currentPositions: currentPositions || [],
|
|
162
|
+
relativeProgression: currentLocation?.locations.progression,
|
|
163
|
+
totalProgression: currentLocation?.locations.totalProgression,
|
|
164
|
+
currentChapter,
|
|
165
|
+
positionsLeft: !positionsList?.length || endPosition === void 0 || currentPosition === void 0 ? void 0 : Math.max(0, endPosition - currentPosition)
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}, [
|
|
169
|
+
publication,
|
|
170
|
+
currentChapter,
|
|
171
|
+
currentHref,
|
|
172
|
+
currentIndex,
|
|
173
|
+
positionEntries,
|
|
174
|
+
positionsList,
|
|
175
|
+
currentPositions,
|
|
176
|
+
currentLocation
|
|
177
|
+
]);
|
|
303
178
|
useEffect(() => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
179
|
+
if (onChange) onChange(progress);
|
|
180
|
+
}, [progress, onChange]);
|
|
181
|
+
return progress;
|
|
182
|
+
};
|
|
183
|
+
var useTimelineAdjacency = (getNavigatorTimeline) => {
|
|
184
|
+
const dispatch = useAppDispatch();
|
|
185
|
+
const updateAdjacentItems = useCallback((item) => {
|
|
186
|
+
const tl = getNavigatorTimeline();
|
|
187
|
+
if (!tl) return;
|
|
188
|
+
const { previous, next } = tl.navigableFrom(item);
|
|
189
|
+
const previousHref = previous ? tl.linkFor(previous)?.href : void 0;
|
|
190
|
+
const nextHref = next ? tl.linkFor(next)?.href : void 0;
|
|
191
|
+
dispatch(setAdjacentTimelineItems({
|
|
192
|
+
previous: previous && previousHref ? { title: resolveChapterTitle(tl, previous), href: previousHref } : null,
|
|
193
|
+
next: next && nextHref ? { title: resolveChapterTitle(tl, next), href: nextHref } : null
|
|
194
|
+
}));
|
|
195
|
+
}, [dispatch, getNavigatorTimeline]);
|
|
196
|
+
const clearAdjacentItems = useCallback(() => {
|
|
197
|
+
dispatch(setAdjacentTimelineItems({ previous: null, next: null }));
|
|
198
|
+
}, [dispatch]);
|
|
199
|
+
return { updateAdjacentItems, clearAdjacentItems };
|
|
310
200
|
};
|
|
311
201
|
var navigatorInstance = null;
|
|
312
202
|
var useAudioNavigator = () => {
|
|
@@ -397,6 +287,9 @@ var useAudioNavigator = () => {
|
|
|
397
287
|
const currentTime = useCallback(() => {
|
|
398
288
|
return navigatorInstance?.currentTime || 0;
|
|
399
289
|
}, []);
|
|
290
|
+
const timeline = useCallback(() => {
|
|
291
|
+
return navigatorInstance?.timeline;
|
|
292
|
+
}, []);
|
|
400
293
|
return {
|
|
401
294
|
AudioNavigatorLoad,
|
|
402
295
|
AudioNavigatorDestroy,
|
|
@@ -424,7 +317,7 @@ var useAudioNavigator = () => {
|
|
|
424
317
|
remotePlayback: navigatorInstance?.remotePlayback,
|
|
425
318
|
getSetting,
|
|
426
319
|
submitPreferences,
|
|
427
|
-
timeline
|
|
320
|
+
timeline
|
|
428
321
|
};
|
|
429
322
|
};
|
|
430
323
|
var useAudioSettingsCache = (volume, playbackRate, preservePitch, skipBackwardInterval, skipForwardInterval, skipInterval, pollInterval, autoPlay, enableMediaSession) => {
|
|
@@ -487,7 +380,7 @@ var useEpubNavigator = () => {
|
|
|
487
380
|
config.container,
|
|
488
381
|
config.publication,
|
|
489
382
|
config.listeners,
|
|
490
|
-
config.positionsList,
|
|
383
|
+
config.positionsList?.map((p) => Locator.deserialize(p)).filter((l) => !!l),
|
|
491
384
|
config.initialPosition,
|
|
492
385
|
{
|
|
493
386
|
preferences: config.preferences || {},
|
|
@@ -532,27 +425,6 @@ var useEpubNavigator = () => {
|
|
|
532
425
|
const currentLocator = useCallback(() => {
|
|
533
426
|
return navigatorInstance2?.currentLocator;
|
|
534
427
|
}, []);
|
|
535
|
-
const getLocatorAtOffset = useCallback((offset) => {
|
|
536
|
-
const readingOrder = navigatorInstance2?.publication?.readingOrder;
|
|
537
|
-
if (!readingOrder) return null;
|
|
538
|
-
const currentLocator2 = navigatorInstance2?.currentLocator;
|
|
539
|
-
if (!currentLocator2) return null;
|
|
540
|
-
const currentLocatorIndex = readingOrder.findIndexWithHref(currentLocator2.href);
|
|
541
|
-
if (currentLocatorIndex === -1) return null;
|
|
542
|
-
const newIndex = currentLocatorIndex + offset;
|
|
543
|
-
if (newIndex < 0 || newIndex >= readingOrder.items.length) return null;
|
|
544
|
-
return readingOrder.items[newIndex];
|
|
545
|
-
}, []);
|
|
546
|
-
const previousLocator = useCallback(() => {
|
|
547
|
-
const link = getLocatorAtOffset(-1);
|
|
548
|
-
if (!link) return null;
|
|
549
|
-
return navigatorInstance2?.publication?.manifest?.locatorFromLink(link);
|
|
550
|
-
}, [getLocatorAtOffset]);
|
|
551
|
-
const nextLocator = useCallback(() => {
|
|
552
|
-
const link = getLocatorAtOffset(1);
|
|
553
|
-
if (!link) return null;
|
|
554
|
-
return navigatorInstance2?.publication?.manifest?.locatorFromLink(link);
|
|
555
|
-
}, [getLocatorAtOffset]);
|
|
556
428
|
const currentPositions = useCallback(() => {
|
|
557
429
|
return navigatorInstance2?.viewport?.positions;
|
|
558
430
|
}, []);
|
|
@@ -576,6 +448,9 @@ var useEpubNavigator = () => {
|
|
|
576
448
|
if (!metadata) return void 0;
|
|
577
449
|
return getScriptMode(metadata);
|
|
578
450
|
}, []);
|
|
451
|
+
const timeline = useCallback(() => {
|
|
452
|
+
return navigatorInstance2?.timeline;
|
|
453
|
+
}, []);
|
|
579
454
|
return {
|
|
580
455
|
EpubNavigatorLoad,
|
|
581
456
|
EpubNavigatorDestroy,
|
|
@@ -587,8 +462,6 @@ var useEpubNavigator = () => {
|
|
|
587
462
|
go,
|
|
588
463
|
navLayout,
|
|
589
464
|
currentLocator,
|
|
590
|
-
previousLocator,
|
|
591
|
-
nextLocator,
|
|
592
465
|
currentPositions,
|
|
593
466
|
canGoBackward,
|
|
594
467
|
canGoForward,
|
|
@@ -598,7 +471,8 @@ var useEpubNavigator = () => {
|
|
|
598
471
|
getSetting,
|
|
599
472
|
submitPreferences,
|
|
600
473
|
getCframes,
|
|
601
|
-
getScriptMode: currentScriptMode
|
|
474
|
+
getScriptMode: currentScriptMode,
|
|
475
|
+
timeline
|
|
602
476
|
};
|
|
603
477
|
};
|
|
604
478
|
var useEpubSettingsCache = (textAlign, columnCount, fontFamily, fontSize, fontWeight, hyphens, letterSpacing, ligatures, lineLength, lineHeight, noRuby, paragraphIndent, paragraphSpacing, publisherStyles, scroll, textNormalization, wordSpacing, theme) => {
|
|
@@ -729,27 +603,6 @@ var useWebPubNavigator = () => {
|
|
|
729
603
|
const currentLocator = useCallback(() => {
|
|
730
604
|
return navigatorInstance3?.currentLocator;
|
|
731
605
|
}, []);
|
|
732
|
-
const getLocatorAtOffset = useCallback((offset) => {
|
|
733
|
-
const readingOrder = navigatorInstance3?.publication?.readingOrder;
|
|
734
|
-
if (!readingOrder) return null;
|
|
735
|
-
const currentLocator2 = navigatorInstance3?.currentLocator;
|
|
736
|
-
if (!currentLocator2) return null;
|
|
737
|
-
const currentLocatorIndex = readingOrder.findIndexWithHref(currentLocator2.href);
|
|
738
|
-
if (currentLocatorIndex === -1) return null;
|
|
739
|
-
const newIndex = currentLocatorIndex + offset;
|
|
740
|
-
if (newIndex < 0 || newIndex >= readingOrder.items.length) return null;
|
|
741
|
-
return readingOrder.items[newIndex];
|
|
742
|
-
}, []);
|
|
743
|
-
const previousLocator = useCallback(() => {
|
|
744
|
-
const link = getLocatorAtOffset(-1);
|
|
745
|
-
if (!link) return null;
|
|
746
|
-
return navigatorInstance3?.publication?.manifest?.locatorFromLink(link);
|
|
747
|
-
}, [getLocatorAtOffset]);
|
|
748
|
-
const nextLocator = useCallback(() => {
|
|
749
|
-
const link = getLocatorAtOffset(1);
|
|
750
|
-
if (!link) return null;
|
|
751
|
-
return navigatorInstance3?.publication?.manifest?.locatorFromLink(link);
|
|
752
|
-
}, [getLocatorAtOffset]);
|
|
753
606
|
const currentPositions = useCallback(() => {
|
|
754
607
|
return navigatorInstance3?.viewport?.positions;
|
|
755
608
|
}, []);
|
|
@@ -773,6 +626,9 @@ var useWebPubNavigator = () => {
|
|
|
773
626
|
if (!metadata) return void 0;
|
|
774
627
|
return getScriptMode(metadata);
|
|
775
628
|
}, []);
|
|
629
|
+
const timeline = useCallback(() => {
|
|
630
|
+
return navigatorInstance3?.timeline;
|
|
631
|
+
}, []);
|
|
776
632
|
return {
|
|
777
633
|
WebPubNavigatorLoad,
|
|
778
634
|
WebPubNavigatorDestroy,
|
|
@@ -783,8 +639,6 @@ var useWebPubNavigator = () => {
|
|
|
783
639
|
goLink,
|
|
784
640
|
go,
|
|
785
641
|
currentLocator,
|
|
786
|
-
previousLocator,
|
|
787
|
-
nextLocator,
|
|
788
642
|
currentPositions,
|
|
789
643
|
canGoBackward,
|
|
790
644
|
canGoForward,
|
|
@@ -794,7 +648,8 @@ var useWebPubNavigator = () => {
|
|
|
794
648
|
getSetting,
|
|
795
649
|
submitPreferences,
|
|
796
650
|
getCframes,
|
|
797
|
-
getScriptMode: currentScriptMode
|
|
651
|
+
getScriptMode: currentScriptMode,
|
|
652
|
+
timeline
|
|
798
653
|
};
|
|
799
654
|
};
|
|
800
655
|
var useWebPubSettingsCache = (fontFamily, fontWeight, hyphens, letterSpacing, ligatures, lineHeight, noRuby, paragraphIndent, paragraphSpacing, publisherStyles, textAlign, textNormalization, wordSpacing, zoom) => {
|
|
@@ -853,6 +708,6 @@ var useWebPubSettingsCache = (fontFamily, fontWeight, hyphens, letterSpacing, li
|
|
|
853
708
|
return cache;
|
|
854
709
|
};
|
|
855
710
|
|
|
856
|
-
export {
|
|
857
|
-
//# sourceMappingURL=chunk-
|
|
858
|
-
//# sourceMappingURL=chunk-
|
|
711
|
+
export { useAudioNavigator, useAudioSettingsCache, useDocumentTitle, useEpubNavigator, useEpubSettingsCache, useFullscreen, useIsClient, useLocalStorage, useObservableCondition, usePublicationProgress, useTimelineAdjacency, useWebPubNavigator, useWebPubSettingsCache };
|
|
712
|
+
//# sourceMappingURL=chunk-CXKDZVAV.mjs.map
|
|
713
|
+
//# sourceMappingURL=chunk-CXKDZVAV.mjs.map
|