@openzim/libzim 2.4.4 → 3.1.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/.env +1 -1
- package/.eslintignore +3 -0
- package/.eslintrc.js +39 -0
- package/Changelog +13 -0
- package/README.md +50 -28
- package/binding.gyp +3 -5
- package/bundle-libzim.js +22 -16
- package/dist/index.d.ts +254 -4
- package/dist/index.js +33 -9
- package/download-libzim.js +67 -48
- package/package.json +28 -24
- package/src/archive.h +494 -0
- package/src/blob.h +101 -0
- package/src/common.h +150 -0
- package/src/contentProvider.h +258 -0
- package/src/creator.h +345 -0
- package/src/entry.h +116 -0
- package/src/entryrange.h +106 -0
- package/src/index.d.ts +254 -0
- package/src/index.js +33 -0
- package/src/item.h +152 -0
- package/src/module.cc +42 -6
- package/src/search.h +527 -0
- package/src/suggestion.h +359 -0
- package/src/writerItem.h +462 -0
- package/tsconfig.json +4 -6
- package/dist/ZimCreator.d.ts +0 -34
- package/dist/ZimCreator.js +0 -177
- package/dist/ZimReader.d.ts +0 -13
- package/dist/ZimReader.js +0 -110
- package/dist/zim.d.ts +0 -2
- package/dist/zim.js +0 -11
- package/jest.config.js +0 -18
- package/src/article.cc +0 -228
- package/src/article.h +0 -114
- package/src/reader.cc +0 -110
- package/src/reader.h +0 -31
- package/src/writer.cc +0 -67
- package/src/writer.h +0 -38
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
LIBZIM_VERSION=
|
|
1
|
+
LIBZIM_VERSION=8.2.1
|
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
es6: true,
|
|
4
|
+
node: true,
|
|
5
|
+
},
|
|
6
|
+
rules: {
|
|
7
|
+
"prettier/prettier": "error",
|
|
8
|
+
eqeqeq: "error",
|
|
9
|
+
},
|
|
10
|
+
extends: [
|
|
11
|
+
"eslint:recommended",
|
|
12
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
13
|
+
"plugin:@typescript-eslint/recommended",
|
|
14
|
+
"prettier",
|
|
15
|
+
],
|
|
16
|
+
parser: "@typescript-eslint/parser",
|
|
17
|
+
parserOptions: {
|
|
18
|
+
project: "tsconfig.json",
|
|
19
|
+
sourceType: "module",
|
|
20
|
+
},
|
|
21
|
+
plugins: ["prettier"],
|
|
22
|
+
root: true,
|
|
23
|
+
overrides: [
|
|
24
|
+
{
|
|
25
|
+
files: ["*.ts", "*.js"],
|
|
26
|
+
rules: {
|
|
27
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
28
|
+
"no-import-assign": "off",
|
|
29
|
+
"no-useless-escape": "off",
|
|
30
|
+
},
|
|
31
|
+
parserOptions: {
|
|
32
|
+
sourceType: "module",
|
|
33
|
+
},
|
|
34
|
+
extends: ["plugin:@typescript-eslint/recommended"],
|
|
35
|
+
parser: "@typescript-eslint/parser",
|
|
36
|
+
plugins: ["@typescript-eslint"],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
package/Changelog
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
3.1.0:
|
|
2
|
+
* NEW: Use libzim v8.2.1
|
|
3
|
+
* FIX: Handling of binary data in the creator
|
|
4
|
+
* FIX: Use ESLint instead of TSLint
|
|
5
|
+
* REMOVE: Node.js 16 from the CI
|
|
6
|
+
|
|
7
|
+
3.0.0:
|
|
8
|
+
* NEW: Use libzim v8.2.0
|
|
9
|
+
* NEW: Calling API (to follow libzim changes)
|
|
10
|
+
* NEW: Add support of ARM(64) for both Linux and macOS
|
|
11
|
+
* UPDATE: Most of the dependencies
|
|
12
|
+
* UPDATE: Many improvements around the CI
|
|
13
|
+
|
|
1
14
|
2.4.4:
|
|
2
15
|
* NEW: Use libzim v6.3.2
|
|
3
16
|
|
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@ This is the Node.js binding to the
|
|
|
6
6
|
[ZIM](https://openzim.org) files easily in Javascript.
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/@openzim/libzim)
|
|
9
|
-
[](https://github.com/openzim/node-libzim/actions?query=branch%3Amain)
|
|
10
|
+
[](https://codecov.io/gh/openzim/node-libzim)
|
|
11
11
|
[](https://www.codefactor.io/repository/github/openzim/node-libzim)
|
|
12
12
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
13
13
|
|
|
@@ -22,55 +22,77 @@ here](https://github.com/openzim/libzim/)).
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm i openzim/libzim
|
|
25
|
+
npm i @openzim/libzim
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
### Writing a
|
|
28
|
+
### Writing a ZIM file
|
|
29
29
|
```javascript
|
|
30
30
|
// write.js
|
|
31
|
-
|
|
31
|
+
import { Creator, StringItem } from "@openzim/libzim";
|
|
32
32
|
|
|
33
33
|
(async () => {
|
|
34
|
-
|
|
35
34
|
console.info('Starting');
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const outFile = "./test.zim";
|
|
36
|
+
const creator = new Creator()
|
|
37
|
+
.configNbWorkers(1)
|
|
38
|
+
.configIndexing(true, "en")
|
|
39
|
+
.configClusterSize(2048)
|
|
40
|
+
.startZimCreation(outFile);
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < 100; i++) {
|
|
43
|
+
const item = new StringItem(
|
|
44
|
+
`file${i}`, // path url
|
|
45
|
+
"text/plain", // content-type
|
|
46
|
+
`Title ${i}`, // title
|
|
47
|
+
{FRONT_ARTICLE: 1, COMPRESS: 1}, // hint option flags
|
|
48
|
+
`<h1>Content / Data ${i}</h1>` // content
|
|
49
|
+
);
|
|
50
|
+
await creator.addItem(item);
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
await creator.
|
|
45
|
-
|
|
46
|
-
await creator.finalise();
|
|
53
|
+
creator.setMainPath("file0");
|
|
54
|
+
await creator.finishZimCreation();
|
|
47
55
|
|
|
48
56
|
console.log('Done Writing');
|
|
49
|
-
|
|
50
57
|
})();
|
|
51
58
|
```
|
|
52
59
|
|
|
53
|
-
### Reading a
|
|
60
|
+
### Reading a ZIM file
|
|
54
61
|
```javascript
|
|
55
62
|
// read.js
|
|
56
|
-
|
|
57
|
-
const { ZimArticle, ZimReader } = require("@openzim/libzim");
|
|
63
|
+
import { Archive, SuggestionSearcher, Searcher } from "@openzim/libzim";
|
|
58
64
|
|
|
59
65
|
(async () => {
|
|
66
|
+
const outFile = "./test.zim";
|
|
67
|
+
const archive = new Archive(outFile);
|
|
68
|
+
console.log(`Archive opened: main entry path - ${archive.mainEntry.path}`);
|
|
60
69
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.info(`Suggest Results:`, suggestResults);
|
|
70
|
+
for (const entry of archive.iterByPath()) {
|
|
71
|
+
console.log(`entry: ${entry.path} - ${entry.title}`);
|
|
72
|
+
}
|
|
65
73
|
|
|
66
|
-
const
|
|
67
|
-
|
|
74
|
+
const suggestionSearcher = new SuggestionSearcher(archive);
|
|
75
|
+
const suggestion = suggestionSearcher.suggest('laborum');
|
|
76
|
+
let results = suggestion.getResults(0, 10);
|
|
77
|
+
console.log("Suggestion results:");
|
|
78
|
+
for(const entry of results) {
|
|
79
|
+
console.log(`\t- ${entry.path} - ${entry.title}`);
|
|
80
|
+
}
|
|
68
81
|
|
|
69
|
-
const
|
|
70
|
-
|
|
82
|
+
const searcher = new Searcher(archive);
|
|
83
|
+
const search = searcher.search(new Query('rem'));
|
|
84
|
+
results = search.getResults(0, 10);
|
|
85
|
+
console.log("Search results:");
|
|
86
|
+
for(const entry of results) {
|
|
87
|
+
console.log(`\t- ${entry.path} - ${entry.title}`);
|
|
88
|
+
}
|
|
71
89
|
|
|
72
|
-
await zimFile.destroy();
|
|
73
90
|
|
|
91
|
+
const entry = await archive.getEntryByPath("A/laborum");
|
|
92
|
+
const item = entry.item;
|
|
93
|
+
const blob = item.data;
|
|
94
|
+
console.info(`Entry by url (laborum):`, blob.data);
|
|
95
|
+
delete archive;
|
|
74
96
|
})();
|
|
75
97
|
|
|
76
98
|
```
|
package/binding.gyp
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"libraries": [
|
|
25
25
|
"-Wl,-rpath,'$$ORIGIN'",
|
|
26
26
|
"-L<(libzim_dir)/lib/x86_64-linux-gnu",
|
|
27
|
-
"<(libzim_dir)/lib/x86_64-linux-gnu/libzim.so.
|
|
27
|
+
"<(libzim_dir)/lib/x86_64-linux-gnu/libzim.so.8",
|
|
28
28
|
],
|
|
29
29
|
}],
|
|
30
30
|
["libzim_local!='true' and OS=='mac'", {
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"xcode_settings": {
|
|
34
34
|
"GCC_SYMBOLS_PRIVATE_EXTERN": "YES", # -fvisibility=hidden
|
|
35
35
|
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
|
|
36
|
-
"LD_RUNPATH_SEARCH_PATHS": "@loader_path/"
|
|
36
|
+
"LD_RUNPATH_SEARCH_PATHS": "@loader_path/",
|
|
37
|
+
"OTHER_CFLAGS": [ "-std=c++17", "-fexceptions" ],
|
|
37
38
|
},
|
|
38
39
|
"libraries": ["-Wl,-rpath,@loader_path/", "-L<(libzim_dir)/lib", "-lzim"],
|
|
39
40
|
}],
|
|
@@ -45,9 +46,6 @@
|
|
|
45
46
|
"cflags_cc": [ "-std=c++17", "-fexceptions" ],
|
|
46
47
|
"sources": [
|
|
47
48
|
"src/module.cc",
|
|
48
|
-
"src/article.cc",
|
|
49
|
-
"src/reader.cc",
|
|
50
|
-
"src/writer.cc",
|
|
51
49
|
],
|
|
52
50
|
"include_dirs": [
|
|
53
51
|
"<!@(node -p \"require('node-addon-api').include\")",
|
package/bundle-libzim.js
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
require(
|
|
2
|
-
const mkdirp = require(
|
|
3
|
-
const exec = require(
|
|
4
|
-
const os = require(
|
|
1
|
+
require("dotenv").config();
|
|
2
|
+
const mkdirp = require("mkdirp");
|
|
3
|
+
const exec = require("exec-then");
|
|
4
|
+
const os = require("os");
|
|
5
5
|
|
|
6
|
-
mkdirp.sync(
|
|
6
|
+
mkdirp.sync("./build/Release");
|
|
7
7
|
|
|
8
|
-
const isMacOS = os.type() ===
|
|
9
|
-
const isLinux = os.type() ===
|
|
8
|
+
const isMacOS = os.type() === "Darwin";
|
|
9
|
+
const isLinux = os.type() === "Linux";
|
|
10
10
|
|
|
11
11
|
if (!isMacOS && !isLinux) {
|
|
12
|
-
|
|
12
|
+
console.warn(
|
|
13
|
+
"\x1b[41m\n================================ README \n\nlibzim bundle with prebuilt binaries only available for macOS and Linux:\n\n\thttps://github.com/openzim/libzim/\n\n================================\x1b[0m\n"
|
|
14
|
+
);
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
if (isLinux) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
console.info("Copying libzim.so.8 to build folder");
|
|
19
|
+
exec(
|
|
20
|
+
"cp download/lib/x86_64-linux-gnu/libzim.so.8 build/Release/libzim.so.8"
|
|
21
|
+
);
|
|
22
|
+
exec("ln -sf build/Release/libzim.so.8 build/Release/libzim.so"); // convienience only, not required
|
|
19
23
|
}
|
|
20
24
|
if (isMacOS) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
console.info("Copying libzim.8.dylib to build folder");
|
|
26
|
+
exec("cp download/lib/libzim.8.dylib build/Release/libzim.8.dylib");
|
|
27
|
+
exec("ln -sf build/Release/libzim.8.dylib build/Release/libzim.dylib"); // convienience only, not required
|
|
28
|
+
console.info("Fixing rpath");
|
|
29
|
+
exec(
|
|
30
|
+
"install_name_tool -change libzim.8.dylib @loader_path/libzim.8.dylib build/Release/zim_binding.node"
|
|
31
|
+
);
|
|
26
32
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export class IntegrityCheck {
|
|
2
|
+
static CHECKSUM: symbol;
|
|
3
|
+
static DIRENT_PTRS: symbol;
|
|
4
|
+
static DIRENT_ORDER: symbol;
|
|
5
|
+
static TITLE_INDEX: symbol;
|
|
6
|
+
static CLUSTER_PTRS: symbol;
|
|
7
|
+
static DIRENT_MIMETYPES: symbol;
|
|
8
|
+
static COUNT: symbol; // DO NOT USE THIS. See libzim docs.
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class Compression {
|
|
12
|
+
static None: symbol;
|
|
13
|
+
static Zstd: symbol;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Blob {
|
|
17
|
+
constructor(buf?: ArrayBuffer | Buffer | string);
|
|
18
|
+
get data(): Buffer;
|
|
19
|
+
get size(): number | bigint;
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ContentProvider = {
|
|
24
|
+
size: number | bigint;
|
|
25
|
+
feed(): Blob;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class StringProvider {
|
|
29
|
+
constructor(content: string);
|
|
30
|
+
get size(): number;
|
|
31
|
+
feed(): Blob;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class FileProvider {
|
|
35
|
+
constructor(filepath: string);
|
|
36
|
+
get size(): number | bigint;
|
|
37
|
+
feed(): Blob;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Hint = {
|
|
41
|
+
COMPRESS?: number;
|
|
42
|
+
FRONT_ARTICLE?: number;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export interface IndexData {
|
|
46
|
+
hasIndexData?: boolean;
|
|
47
|
+
title?: string;
|
|
48
|
+
content?: string;
|
|
49
|
+
keywords?: string;
|
|
50
|
+
wordcount?: number;
|
|
51
|
+
position?: [boolean, number, number];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface WriterItem {
|
|
55
|
+
path: string;
|
|
56
|
+
title: string;
|
|
57
|
+
mimeType: string;
|
|
58
|
+
getContentProvider(): ContentProvider;
|
|
59
|
+
hints: Hint;
|
|
60
|
+
getIndexData?: () => IndexData;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class StringItem {
|
|
64
|
+
constructor(
|
|
65
|
+
path: string,
|
|
66
|
+
mimeType: string,
|
|
67
|
+
title: string,
|
|
68
|
+
hint: Hint,
|
|
69
|
+
content: ArrayBuffer | Buffer | string
|
|
70
|
+
);
|
|
71
|
+
readonly path: string;
|
|
72
|
+
readonly title: string;
|
|
73
|
+
readonly mimeType: string;
|
|
74
|
+
getContentProvider(): StringProvider;
|
|
75
|
+
readonly hints: Hint;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class FileItem {
|
|
79
|
+
constructor(
|
|
80
|
+
path: string,
|
|
81
|
+
mimeType: string,
|
|
82
|
+
title: string,
|
|
83
|
+
hints: Hint,
|
|
84
|
+
filePath: string
|
|
85
|
+
);
|
|
86
|
+
readonly path: string;
|
|
87
|
+
readonly title: string;
|
|
88
|
+
readonly mimeType: string;
|
|
89
|
+
getContentProvider(): StringProvider;
|
|
90
|
+
readonly hints: Hint;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class Creator {
|
|
94
|
+
constructor();
|
|
95
|
+
configVerbose(verbose: boolean): this;
|
|
96
|
+
configCompression(value: Compression): this;
|
|
97
|
+
configClusterSize(size: number): this;
|
|
98
|
+
configIndexing(indexing: boolean, language: string): this;
|
|
99
|
+
configNbWorkers(num: number): this;
|
|
100
|
+
startZimCreation(filepath: string): this;
|
|
101
|
+
addItem(item: WriterItem): Promise<void>;
|
|
102
|
+
addMetadata(
|
|
103
|
+
name: string,
|
|
104
|
+
content: string | ContentProvider,
|
|
105
|
+
mimetype?: string
|
|
106
|
+
): void;
|
|
107
|
+
addIllustration(size: number, content: string | ContentProvider): void;
|
|
108
|
+
addRedirection(
|
|
109
|
+
path: string,
|
|
110
|
+
title: string,
|
|
111
|
+
targetPath: string,
|
|
112
|
+
hints?: Hint
|
|
113
|
+
): void;
|
|
114
|
+
setMainPath(mainPath: string): void;
|
|
115
|
+
setUuid(uuid: string): void;
|
|
116
|
+
finishZimCreation(): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class Item {
|
|
120
|
+
get title(): string;
|
|
121
|
+
get path(): string;
|
|
122
|
+
get mimetype(): string;
|
|
123
|
+
get data(): Blob;
|
|
124
|
+
getData(offset?: number | bigint, limit?: number | bigint): Blob;
|
|
125
|
+
get size(): number | bigint;
|
|
126
|
+
get directAccessInformation(): {
|
|
127
|
+
filename: string;
|
|
128
|
+
offset: number;
|
|
129
|
+
};
|
|
130
|
+
get index(): number | bigint;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export class Entry {
|
|
134
|
+
get isRedirect(): boolean;
|
|
135
|
+
get title(): string;
|
|
136
|
+
get path(): string;
|
|
137
|
+
get item(): Item;
|
|
138
|
+
getItem(followRedirect?: boolean): Item;
|
|
139
|
+
get redirect(): Item;
|
|
140
|
+
get redirectEntry(): Entry;
|
|
141
|
+
get index(): number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface EntryRange extends Iterable<Entry> {
|
|
145
|
+
size: number;
|
|
146
|
+
offset(start: number, maxResults: number): EntryRange;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export class Archive {
|
|
150
|
+
constructor(filepath: string);
|
|
151
|
+
get filename(): string;
|
|
152
|
+
get filesize(): number | bigint;
|
|
153
|
+
get allEntryCount(): number;
|
|
154
|
+
get entryCount(): number;
|
|
155
|
+
get articleCount(): number;
|
|
156
|
+
get uuid(): string;
|
|
157
|
+
getMetadata(name: string): string;
|
|
158
|
+
getMetadataItem(name: string): Item;
|
|
159
|
+
get metadataKeys(): string[];
|
|
160
|
+
getIllustrationItem(size: number): Item;
|
|
161
|
+
get illustrationSizes(): Set<number>;
|
|
162
|
+
getEntryByPath(path_or_idx: string | number): Entry;
|
|
163
|
+
getEntryByTitle(title_or_idx: string | number): Entry;
|
|
164
|
+
getEntryByClusterOrder(idx: number): Entry;
|
|
165
|
+
get mainEntry(): Entry;
|
|
166
|
+
get randomEntry(): Entry;
|
|
167
|
+
hasEntryByPath(path: string): boolean;
|
|
168
|
+
hasEntryByTitle(title: string): boolean;
|
|
169
|
+
hasMainEntry(): boolean;
|
|
170
|
+
hasIllustration(size: number): boolean;
|
|
171
|
+
hasFulltextIndex(): boolean;
|
|
172
|
+
hasTitleIndex(): boolean;
|
|
173
|
+
iterByPath(): EntryRange;
|
|
174
|
+
iterByTitle(): EntryRange;
|
|
175
|
+
iterEfficient(): EntryRange;
|
|
176
|
+
findByPath(path: string): EntryRange;
|
|
177
|
+
findByTitle(title: string): EntryRange;
|
|
178
|
+
get hasChecksum(): boolean;
|
|
179
|
+
get checksum(): string;
|
|
180
|
+
check(): boolean;
|
|
181
|
+
checkIntegrity(checkType: symbol): boolean; // one of IntegrityCheck
|
|
182
|
+
get isMultiPart(): boolean;
|
|
183
|
+
get hasNewNamespaceScheme(): boolean;
|
|
184
|
+
|
|
185
|
+
static validate(zimPath: string, checksToRun: symbol[]): boolean; // list of IntegrityCheck
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface Georange {
|
|
189
|
+
latitude: number;
|
|
190
|
+
longitude: number;
|
|
191
|
+
distance: number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export class Query {
|
|
195
|
+
constructor(query: string);
|
|
196
|
+
setQuery(query: string): this;
|
|
197
|
+
setGeorange(latitude: number, longitude: number, distance: number): this;
|
|
198
|
+
get query(): string;
|
|
199
|
+
set query(query: string);
|
|
200
|
+
toString(): string;
|
|
201
|
+
get georange(): Georange;
|
|
202
|
+
set georange(range: Georange);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class SearchIterator {
|
|
206
|
+
get path(): string;
|
|
207
|
+
get title(): string;
|
|
208
|
+
get score(): number;
|
|
209
|
+
get snippet(): string;
|
|
210
|
+
get wordCount(): number;
|
|
211
|
+
get size(): number;
|
|
212
|
+
get fileIndex(): number;
|
|
213
|
+
get zimId(): string;
|
|
214
|
+
get entry(): Entry;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface SearchResultSet extends Iterable<SearchIterator> {
|
|
218
|
+
readonly size: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export class Search {
|
|
222
|
+
getResults(start: number, maxResults: number): SearchResultSet;
|
|
223
|
+
get estimatedMatches(): number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class Searcher {
|
|
227
|
+
constructor(archives: Archive | Archive[]);
|
|
228
|
+
addArchive(archive: Archive): this;
|
|
229
|
+
search(query: string | Query): Search;
|
|
230
|
+
setVerbose(verbose: boolean): this;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export class SuggestionIterator {
|
|
234
|
+
get entry(): Entry;
|
|
235
|
+
get title(): string;
|
|
236
|
+
get path(): string;
|
|
237
|
+
get snippet(): string;
|
|
238
|
+
get hasSnippet(): boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface SuggestionResultSet extends Iterable<SuggestionIterator> {
|
|
242
|
+
readonly size: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export class SuggestionSearch {
|
|
246
|
+
getResults(start: number, maxResults: number): SuggestionResultSet;
|
|
247
|
+
get estimatedMatches(): number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export class SuggestionSearcher {
|
|
251
|
+
constructor(archives: Archive);
|
|
252
|
+
suggest(query: string): SuggestionSearch;
|
|
253
|
+
setVerbose(verbose: boolean): this;
|
|
254
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import bindings from "bindings";
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
Archive,
|
|
5
|
+
Entry,
|
|
6
|
+
IntegrityCheck,
|
|
7
|
+
Compression,
|
|
8
|
+
Blob,
|
|
9
|
+
Searcher,
|
|
10
|
+
Query,
|
|
11
|
+
SuggestionSearcher,
|
|
12
|
+
Creator,
|
|
13
|
+
StringProvider,
|
|
14
|
+
FileProvider,
|
|
15
|
+
StringItem,
|
|
16
|
+
FileItem,
|
|
17
|
+
} = bindings("zim_binding");
|
|
18
|
+
|
|
19
|
+
module.exports = {
|
|
20
|
+
Archive,
|
|
21
|
+
Entry,
|
|
22
|
+
IntegrityCheck,
|
|
23
|
+
Compression,
|
|
24
|
+
Blob,
|
|
25
|
+
Searcher,
|
|
26
|
+
Query,
|
|
27
|
+
SuggestionSearcher,
|
|
28
|
+
Creator,
|
|
29
|
+
StringProvider,
|
|
30
|
+
FileProvider,
|
|
31
|
+
StringItem,
|
|
32
|
+
FileItem,
|
|
33
|
+
};
|