@prose-reader/enhancer-search 1.185.0 → 1.187.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/package.json +3 -3
- package/src/index.ts +8 -10
- package/src/types.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prose-reader/enhancer-search",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.187.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.umd.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"test": "vitest run --coverage"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@prose-reader/core": "^1.
|
|
20
|
+
"@prose-reader/core": "^1.187.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"rxjs": "*"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "659bb0401d13b671a3002190fbd22f861caf7059"
|
|
26
26
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { defer, forkJoin,
|
|
1
|
+
import { type Reader, deferIdle } from "@prose-reader/core"
|
|
2
|
+
import { defer, forkJoin, of } from "rxjs"
|
|
3
3
|
import { catchError, finalize, map, switchMap } from "rxjs/operators"
|
|
4
|
-
import { searchInDocument, type SearchResult } from "./search"
|
|
5
4
|
import { report } from "./report"
|
|
5
|
+
import { searchInDocument } from "./search"
|
|
6
|
+
import type { SearchEnhancerAPI } from "./types"
|
|
7
|
+
|
|
8
|
+
export type { SearchEnhancerAPI }
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Contract of search enhancer.
|
|
@@ -16,13 +19,7 @@ export const searchEnhancer =
|
|
|
16
19
|
<InheritOptions, InheritOutput extends Reader>(
|
|
17
20
|
next: (options: InheritOptions) => InheritOutput,
|
|
18
21
|
) =>
|
|
19
|
-
(
|
|
20
|
-
options: InheritOptions,
|
|
21
|
-
): InheritOutput & {
|
|
22
|
-
search: {
|
|
23
|
-
search: (text: string) => Observable<SearchResult>
|
|
24
|
-
}
|
|
25
|
-
} => {
|
|
22
|
+
(options: InheritOptions): InheritOutput & SearchEnhancerAPI => {
|
|
26
23
|
const reader = next(options)
|
|
27
24
|
|
|
28
25
|
const searchForItem = (index: number, text: string) => {
|
|
@@ -78,6 +75,7 @@ export const searchEnhancer =
|
|
|
78
75
|
|
|
79
76
|
return {
|
|
80
77
|
...reader,
|
|
78
|
+
__PROSE_READER_ENHANCER_SEARCH: true,
|
|
81
79
|
search: {
|
|
82
80
|
search,
|
|
83
81
|
},
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import type { Observable } from "rxjs"
|
|
2
|
+
import type { SearchResult } from "./search"
|
|
3
|
+
|
|
1
4
|
export type ResultItem = {
|
|
2
5
|
cfi: string
|
|
3
6
|
startCfi?: string
|
|
4
7
|
endCfi?: string
|
|
5
8
|
}
|
|
9
|
+
|
|
10
|
+
export type SearchEnhancerAPI = {
|
|
11
|
+
readonly __PROSE_READER_ENHANCER_SEARCH: boolean
|
|
12
|
+
search: {
|
|
13
|
+
search: (text: string) => Observable<SearchResult>
|
|
14
|
+
}
|
|
15
|
+
}
|