@prose-reader/react-reader 1.117.0
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/README.md +50 -0
- package/package.json +36 -0
- package/src/common/useFullscreen.ts +44 -0
- package/src/components/ui/avatar.tsx +74 -0
- package/src/components/ui/checkbox.tsx +25 -0
- package/src/components/ui/close-button.tsx +17 -0
- package/src/components/ui/color-mode.tsx +75 -0
- package/src/components/ui/dialog.tsx +62 -0
- package/src/components/ui/drawer.tsx +52 -0
- package/src/components/ui/field.tsx +33 -0
- package/src/components/ui/input-group.tsx +53 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/progress.tsx +34 -0
- package/src/components/ui/provider.tsx +12 -0
- package/src/components/ui/radio.tsx +24 -0
- package/src/components/ui/slider.tsx +82 -0
- package/src/components/ui/toggle-tip.tsx +70 -0
- package/src/components/ui/tooltip.tsx +46 -0
- package/src/context/ReactReaderProvider.tsx +14 -0
- package/src/context/context.ts +6 -0
- package/src/context/useReader.ts +9 -0
- package/src/index.ts +2 -0
- package/src/navigation/QuickMenu/BottomBar.tsx +65 -0
- package/src/navigation/QuickMenu/PaginationInfoSection.tsx +62 -0
- package/src/navigation/QuickMenu/QuickBar.tsx +40 -0
- package/src/navigation/QuickMenu/QuickMenu.tsx +22 -0
- package/src/navigation/QuickMenu/Scrubber.tsx +138 -0
- package/src/navigation/QuickMenu/TimeIndicator.tsx +29 -0
- package/src/navigation/QuickMenu/TopBar.tsx +72 -0
- package/src/navigation/useNavigationContext.ts +46 -0
- package/src/pagination/usePagination.ts +29 -0
- package/src/settings/useSettings.ts +9 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +22 -0
- package/vite.config.ts +32 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { usePagination } from "../pagination/usePagination"
|
|
2
|
+
|
|
3
|
+
export const useNavigationContext = () => {
|
|
4
|
+
const pagination = usePagination()
|
|
5
|
+
const hasOnlyOnePage = pagination?.numberOfTotalPages === 1
|
|
6
|
+
|
|
7
|
+
const isBeginWithinChapter =
|
|
8
|
+
(pagination?.beginNumberOfPagesInSpineItem ?? 0) > 1
|
|
9
|
+
|
|
10
|
+
const isEndWithinChapter = (pagination?.endNumberOfPagesInSpineItem ?? 0) > 1
|
|
11
|
+
|
|
12
|
+
const beginPageIndex =
|
|
13
|
+
(pagination?.hasChapters
|
|
14
|
+
? pagination?.beginPageIndexInSpineItem
|
|
15
|
+
: pagination?.beginAbsolutePageIndex) ?? 0
|
|
16
|
+
const endPageIndex =
|
|
17
|
+
(pagination?.hasChapters
|
|
18
|
+
? pagination?.endPageIndexInSpineItem
|
|
19
|
+
: pagination?.endAbsolutePageIndex) ?? 0
|
|
20
|
+
|
|
21
|
+
const [leftPageIndex = 0, rightPageIndex = 0] = [
|
|
22
|
+
beginPageIndex,
|
|
23
|
+
endPageIndex,
|
|
24
|
+
].sort((a, b) => a - b)
|
|
25
|
+
|
|
26
|
+
const beginAndEndAreDifferent =
|
|
27
|
+
pagination?.beginPageIndexInSpineItem !==
|
|
28
|
+
pagination?.endPageIndexInSpineItem ||
|
|
29
|
+
pagination?.beginSpineItemIndex !== pagination?.endSpineItemIndex
|
|
30
|
+
|
|
31
|
+
const totalApproximatePages = pagination?.hasChapters
|
|
32
|
+
? pagination?.beginNumberOfPagesInSpineItem
|
|
33
|
+
: pagination?.numberOfTotalPages
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
hasOnlyOnePage,
|
|
37
|
+
beginPageIndex,
|
|
38
|
+
endPageIndex,
|
|
39
|
+
isBeginWithinChapter,
|
|
40
|
+
isEndWithinChapter,
|
|
41
|
+
beginAndEndAreDifferent,
|
|
42
|
+
totalApproximatePages,
|
|
43
|
+
leftPageIndex,
|
|
44
|
+
rightPageIndex,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Reader } from "@prose-reader/core"
|
|
2
|
+
import { useObserve } from "reactjrx"
|
|
3
|
+
import { NEVER, combineLatest, map } from "rxjs"
|
|
4
|
+
import { useReader } from "../context/useReader"
|
|
5
|
+
|
|
6
|
+
export const usePagination = ():
|
|
7
|
+
| (Reader["pagination"]["state"] & { hasChapters: boolean })
|
|
8
|
+
| undefined => {
|
|
9
|
+
const reader = useReader()
|
|
10
|
+
|
|
11
|
+
return useObserve(
|
|
12
|
+
() =>
|
|
13
|
+
!reader
|
|
14
|
+
? NEVER
|
|
15
|
+
: combineLatest([reader.pagination.state$, reader.context.state$]).pipe(
|
|
16
|
+
map(([state, context]) => {
|
|
17
|
+
const isOnlyImages = context.manifest?.spineItems.every((item) =>
|
|
18
|
+
item.mediaType?.startsWith("image/"),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
...state,
|
|
23
|
+
hasChapters: !context.isFullyPrePaginated && !isOnlyImages,
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
[reader],
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Reader } from "@prose-reader/core"
|
|
2
|
+
import { useObserve } from "reactjrx"
|
|
3
|
+
import { useReader } from "../context/useReader"
|
|
4
|
+
|
|
5
|
+
export const useSettings = (): Reader["settings"]["values"] | undefined => {
|
|
6
|
+
const reader = useReader()
|
|
7
|
+
|
|
8
|
+
return useObserve(() => reader?.settings.values$, [reader])
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
"declaration": false,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
"outDir": "dist",
|
|
17
|
+
"noUncheckedIndexedAccess": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"noUncheckedSideEffectImports": true,
|
|
23
|
+
"esModuleInterop": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"]
|
|
26
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
|
|
15
|
+
"strict": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
|
19
|
+
"noUncheckedSideEffectImports": true
|
|
20
|
+
},
|
|
21
|
+
"include": ["vite.config.ts"]
|
|
22
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { resolve } from "node:path"
|
|
2
|
+
import react from "@vitejs/plugin-react"
|
|
3
|
+
import externals from "rollup-plugin-node-externals"
|
|
4
|
+
import { defineConfig } from "vite"
|
|
5
|
+
import dts from "vite-plugin-dts"
|
|
6
|
+
|
|
7
|
+
// https://vite.dev/config/
|
|
8
|
+
export default defineConfig(({ mode }) => ({
|
|
9
|
+
build: {
|
|
10
|
+
lib: {
|
|
11
|
+
entry: resolve(__dirname, "src/index.ts"),
|
|
12
|
+
name: "prose-react-reader",
|
|
13
|
+
fileName: `index`,
|
|
14
|
+
},
|
|
15
|
+
emptyOutDir: mode !== "development",
|
|
16
|
+
sourcemap: true,
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
{
|
|
20
|
+
enforce: `pre`,
|
|
21
|
+
...externals({
|
|
22
|
+
peerDeps: true,
|
|
23
|
+
deps: true,
|
|
24
|
+
devDeps: true,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
react(),
|
|
28
|
+
dts({
|
|
29
|
+
tsconfigPath: "./tsconfig.app.json",
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
}))
|