@caipira/vue-reader 0.0.2 → 0.0.4
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 +38 -24
- package/dist/src/composables/useEpubReader.d.ts +5 -27786
- package/dist/src/composables/useEpubReader.js +218 -4
- package/dist/src/composables/useEpubReaderLogging.d.ts +5 -0
- package/dist/src/composables/useEpubReaderLogging.js +27 -0
- package/dist/src/composables/useEpubReaderNavigation.d.ts +3 -3
- package/dist/src/composables/useEpubReaderNavigation.js +8 -15
- package/dist/src/composables/useEpubReaderState.d.ts +27794 -20
- package/dist/src/composables/useEpubReaderState.js +31 -21
- package/dist/{composables → src/composables}/useEpubReaderStrategy.d.ts +1 -1
- package/dist/src/composables/useEpubReaderWasm.d.ts +2 -0
- package/dist/{composables → src/composables}/useEpubReaderWasm.js +5 -5
- package/dist/src/composables/useEpubReaderZipFetcher.d.ts +2 -0
- package/dist/{composables → src/composables}/useEpubReaderZipFetcher.js +5 -5
- package/dist/src/composables/useReaderColors.d.ts +10 -0
- package/dist/src/composables/useReaderColors.js +38 -0
- package/dist/src/composables/useReaderSettings.d.ts +24 -13
- package/dist/src/composables/useReaderSettings.js +97 -38
- package/dist/src/index.d.ts +6 -9
- package/dist/src/index.js +5 -8
- package/dist/{services → src/services}/browser/epub.d.ts +1 -1
- package/dist/{services → src/services}/browser/manifest.d.ts +1 -1
- package/dist/{services → src/services}/browser/manifest.js +1 -1
- package/dist/{services → src/services}/browser/url-rewrite.d.ts +1 -1
- package/dist/{services → src/services}/browser/url-rewrite.js +1 -1
- package/dist/{services → src/services}/browser/zip-fetcher.d.ts +1 -1
- package/dist/{services → src/services}/browser/zip-fetcher.js +2 -2
- package/dist/{services → src/services}/common/progression.d.ts +3 -11
- package/dist/{services → src/services}/common/progression.js +1 -32
- package/dist/src/{core → services/common}/storage.d.ts +1 -1
- package/dist/src/{core → services/common}/storage.js +1 -2
- package/dist/{services → src/services}/common/title.d.ts +1 -1
- package/dist/{services → src/services}/common/word-decorations.d.ts +1 -1
- package/dist/{services → src/services}/common/word-decorations.js +2 -2
- package/dist/{services → src/services}/common/word-lookup.js +1 -1
- package/dist/{types → src/types}/common.d.ts +36 -1
- package/package.json +1 -1
- package/dist/composables/useEpubReaderWasm.d.ts +0 -2
- package/dist/composables/useEpubReaderZipFetcher.d.ts +0 -2
- package/dist/src/composables/useEpubReaderController.d.ts +0 -27787
- package/dist/src/composables/useEpubReaderController.js +0 -23
- package/dist/src/composables/useEpubReaderSettings.d.ts +0 -15
- package/dist/src/composables/useEpubReaderSettings.js +0 -8
- package/dist/src/composables/utils.d.ts +0 -2
- package/dist/src/composables/utils.js +0 -1
- package/dist/src/core/controller.d.ts +0 -27789
- package/dist/src/core/controller.js +0 -262
- package/dist/src/core/settings-store.d.ts +0 -16
- package/dist/src/core/settings-store.js +0 -58
- package/dist/src/settings/options.d.ts +0 -20
- package/dist/src/settings/options.js +0 -27
- package/dist/src/types.d.ts +0 -40
- package/dist/src/types.js +0 -1
- /package/dist/{composables → src/composables}/useEpubReaderStrategy.js +0 -0
- /package/dist/{services → src/services}/browser/epub.js +0 -0
- /package/dist/{services → src/services}/browser/url.d.ts +0 -0
- /package/dist/{services → src/services}/browser/url.js +0 -0
- /package/dist/src/{core → services/common}/fonts.d.ts +0 -0
- /package/dist/src/{core → services/common}/fonts.js +0 -0
- /package/dist/{services → src/services}/common/title.js +0 -0
- /package/dist/{services → src/services}/common/word-lookup.d.ts +0 -0
- /package/dist/{services → src/services}/wasm/frame-document-bridge.d.ts +0 -0
- /package/dist/{services → src/services}/wasm/frame-document-bridge.js +0 -0
- /package/dist/{services → src/services}/wasm/wasm-streamer.d.ts +0 -0
- /package/dist/{services → src/services}/wasm/wasm-streamer.js +0 -0
- /package/dist/{types → src/types}/browser.d.ts +0 -0
- /package/dist/{types → src/types}/browser.js +0 -0
- /package/dist/{types → src/types}/common.js +0 -0
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# @caipira/vue-reader
|
|
2
2
|
|
|
3
|
-
Headless
|
|
3
|
+
Headless reader toolkit for Vue 3.
|
|
4
4
|
|
|
5
|
-
This package provides a
|
|
5
|
+
This package provides a set of tools for creating your own custom reader. It currently supports:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- Raw text
|
|
8
|
+
- EPUB
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
- Vue composables (`useEpubReader`, state/navigation/settings helpers)
|
|
11
|
-
- Reader settings helpers (`useReaderSettings`, `setReaderColors`)
|
|
12
|
-
- Dictionary integration hooks (`setReaderDictionary`, `ReaderDictionaryApi`)
|
|
10
|
+
## What is included
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
- Headless epub reader via `useEpubReader`, `useEpubReaderState` and `useEpubReaderNavigation`
|
|
13
|
+
- Colors hook `setReaderColors`
|
|
14
|
+
- Dictionary integration hook `setReaderDictionary`
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
@@ -19,17 +19,20 @@ The default loading strategy is `zip-fetcher` and should be used for production
|
|
|
19
19
|
npm install @caipira/vue-reader
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Script:
|
|
23
25
|
|
|
24
26
|
```ts
|
|
25
27
|
import { useTemplateRef } from 'vue';
|
|
26
28
|
import {
|
|
27
29
|
useEpubReader,
|
|
30
|
+
setReaderColors,
|
|
28
31
|
useEpubReaderState,
|
|
29
32
|
useEpubReaderNavigation,
|
|
30
|
-
setReaderColors,
|
|
31
33
|
} from '@caipira/vue-reader';
|
|
32
34
|
|
|
35
|
+
const epubSrc = 'https://example.com/book.epub';
|
|
33
36
|
const containerRef = useTemplateRef<HTMLDivElement>('containerRef');
|
|
34
37
|
|
|
35
38
|
setReaderColors({
|
|
@@ -38,14 +41,30 @@ setReaderColors({
|
|
|
38
41
|
highlight: '#facc15',
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
const reader = useEpubReader(() =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
44
|
+
const reader = useEpubReader(() => epubSrc, containerRef);
|
|
45
|
+
const { error, loading } = useEpubReaderState();
|
|
46
|
+
const { goForward, goBackward } = useEpubReaderNavigation();
|
|
47
|
+
```
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
### Template:
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<section class="w-full flex justify-between">
|
|
53
|
+
<button
|
|
54
|
+
icon="chevron-left"
|
|
55
|
+
@click="goBackward"
|
|
56
|
+
/>
|
|
57
|
+
<button
|
|
58
|
+
icon="chevron-right"
|
|
59
|
+
@click="goForward"
|
|
60
|
+
/>
|
|
61
|
+
</section>
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
ref="containerRef"
|
|
65
|
+
class="h-full w-full overflow-hidden"
|
|
66
|
+
:class="{ 'opacity-0': loading || error }"
|
|
67
|
+
/>
|
|
49
68
|
```
|
|
50
69
|
|
|
51
70
|
## Dictionary API
|
|
@@ -123,14 +142,9 @@ The `context` value contains nearby text around the clicked word, useful for dis
|
|
|
123
142
|
|
|
124
143
|
## Public API
|
|
125
144
|
|
|
126
|
-
- `createEpubReaderController(srcRef, containerRef, options)`
|
|
127
|
-
- `useEpubReaderController(src, containerRef, options)`
|
|
128
145
|
- `useEpubReader(src, containerRef, options)`
|
|
129
|
-
- `useEpubReaderState(
|
|
130
|
-
- `useEpubReaderNavigation(
|
|
131
|
-
- `useEpubReaderSettings(controller)`
|
|
132
|
-
- `useEpubReaderControllerRef()`
|
|
133
|
-
- `setEpubReaderController(controller)`
|
|
146
|
+
- `useEpubReaderState()`
|
|
147
|
+
- `useEpubReaderNavigation()`
|
|
134
148
|
- `setReaderColors({ background, text, highlight })`
|
|
135
149
|
- `setReaderDictionary(dictionary)`
|
|
136
150
|
- `useReaderDictionary()`
|