@openzim/libzim 3.1.0 → 3.2.1
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/Changelog +12 -0
- package/binding.gyp +1 -1
- package/bundle-libzim.js +12 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/download-libzim.js +12 -8
- package/package.json +2 -1
- package/src/archive.h +9 -0
- package/src/blob.h +6 -3
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/search.h +0 -9
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
LIBZIM_VERSION=
|
|
1
|
+
LIBZIM_VERSION=9.2.1
|
package/Changelog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
3.2.1
|
|
2
|
+
* NEW: Use libzim 9.2.1
|
|
3
|
+
* FIX: Module properly in ESM format
|
|
4
|
+
* FIX: Codecov in the CI
|
|
5
|
+
|
|
6
|
+
3.2.0:
|
|
7
|
+
* NEW: Use libzim v9.0.0
|
|
8
|
+
* NEW: Added mediaCount to Archive
|
|
9
|
+
* FIX: Simplify a lot the CI
|
|
10
|
+
* FIX: Nlob allocation and warning
|
|
11
|
+
* DEL: Deprecated getSize from SearchIterator
|
|
12
|
+
|
|
1
13
|
3.1.0:
|
|
2
14
|
* NEW: Use libzim v8.2.1
|
|
3
15
|
* FIX: Handling of binary data in the creator
|
package/binding.gyp
CHANGED
package/bundle-libzim.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
dotenv.config();
|
|
3
|
+
import mkdirp from "mkdirp";
|
|
4
|
+
import exec from "exec-then";
|
|
5
|
+
import os from "os";
|
|
5
6
|
|
|
6
7
|
mkdirp.sync("./build/Release");
|
|
7
8
|
|
|
@@ -15,18 +16,18 @@ if (!isMacOS && !isLinux) {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
if (isLinux) {
|
|
18
|
-
console.info("Copying libzim.so.
|
|
19
|
+
console.info("Copying libzim.so.9 to build folder");
|
|
19
20
|
exec(
|
|
20
|
-
"cp download/lib/x86_64-linux-gnu/libzim.so.
|
|
21
|
+
"cp download/lib/x86_64-linux-gnu/libzim.so.9 build/Release/libzim.so.9"
|
|
21
22
|
);
|
|
22
|
-
exec("ln -sf build/Release/libzim.so.
|
|
23
|
+
exec("ln -sf build/Release/libzim.so.9 build/Release/libzim.so"); // convienience only, not required
|
|
23
24
|
}
|
|
24
25
|
if (isMacOS) {
|
|
25
|
-
console.info("Copying libzim.
|
|
26
|
-
exec("cp download/lib/libzim.
|
|
27
|
-
exec("ln -sf build/Release/libzim.
|
|
26
|
+
console.info("Copying libzim.9.dylib to build folder");
|
|
27
|
+
exec("cp download/lib/libzim.9.dylib build/Release/libzim.9.dylib");
|
|
28
|
+
exec("ln -sf build/Release/libzim.9.dylib build/Release/libzim.dylib"); // convienience only, not required
|
|
28
29
|
console.info("Fixing rpath");
|
|
29
30
|
exec(
|
|
30
|
-
"install_name_tool -change libzim.
|
|
31
|
+
"install_name_tool -change libzim.9.dylib @loader_path/libzim.9.dylib build/Release/zim_binding.node"
|
|
31
32
|
);
|
|
32
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,7 @@ export class Archive {
|
|
|
153
153
|
get allEntryCount(): number;
|
|
154
154
|
get entryCount(): number;
|
|
155
155
|
get articleCount(): number;
|
|
156
|
+
get mediaCount(): number;
|
|
156
157
|
get uuid(): string;
|
|
157
158
|
getMetadata(name: string): string;
|
|
158
159
|
getMetadataItem(name: string): Item;
|
|
@@ -208,7 +209,6 @@ export class SearchIterator {
|
|
|
208
209
|
get score(): number;
|
|
209
210
|
get snippet(): string;
|
|
210
211
|
get wordCount(): number;
|
|
211
|
-
get size(): number;
|
|
212
212
|
get fileIndex(): number;
|
|
213
213
|
get zimId(): string;
|
|
214
214
|
get entry(): Entry;
|
package/dist/index.js
CHANGED
package/download-libzim.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import dotenv from "dotenv";
|
|
2
|
+
dotenv.config();
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import mkdirp from "mkdirp";
|
|
5
|
+
import exec from "exec-then";
|
|
6
|
+
import os from "os";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import urlParser from "url";
|
|
8
9
|
|
|
9
10
|
mkdirp.sync("./download");
|
|
10
11
|
|
|
12
|
+
console.info("os.type() is:", os.type());
|
|
13
|
+
console.info("os.arch() is:", os.arch());
|
|
11
14
|
const isMacOS = os.type() === "Darwin";
|
|
12
15
|
const isLinux = os.type() === "Linux";
|
|
13
16
|
const rawArch = os.arch();
|
|
17
|
+
|
|
14
18
|
const isAvailableArch =
|
|
15
19
|
rawArch === "x64" || rawArch === "arm" || rawArch === "arm64";
|
|
16
20
|
|
|
@@ -48,7 +52,7 @@ for (let url of urls) {
|
|
|
48
52
|
try {
|
|
49
53
|
fs.statSync(dlFile);
|
|
50
54
|
console.warn(`File [${dlFile}] already exists, not downloading`);
|
|
51
|
-
|
|
55
|
+
break;
|
|
52
56
|
} catch (err) {
|
|
53
57
|
//
|
|
54
58
|
}
|
package/package.json
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"name": "@openzim/libzim",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"types": "dist/index.d.js",
|
|
5
|
-
"version": "3.1
|
|
5
|
+
"version": "3.2.1",
|
|
6
6
|
"description": "Libzim bindings for NodeJS",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
9
|
"clean": "rm -rf dist build/native/build",
|
|
9
10
|
"tsc": "tsc",
|
package/src/archive.h
CHANGED
|
@@ -69,6 +69,14 @@ class Archive : public Napi::ObjectWrap<Archive> {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
Napi::Value getMediaCount(const Napi::CallbackInfo &info) {
|
|
73
|
+
try {
|
|
74
|
+
return Napi::Value::From(info.Env(), archive_->getMediaCount());
|
|
75
|
+
} catch (const std::exception &err) {
|
|
76
|
+
throw Napi::Error::New(info.Env(), err.what());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
Napi::Value getUuid(const Napi::CallbackInfo &info) {
|
|
73
81
|
try {
|
|
74
82
|
// TODO(kelvinhammond): convert this to
|
|
@@ -446,6 +454,7 @@ class Archive : public Napi::ObjectWrap<Archive> {
|
|
|
446
454
|
InstanceAccessor<&Archive::getAllEntryCount>("allEntryCount"),
|
|
447
455
|
InstanceAccessor<&Archive::getEntryCount>("entryCount"),
|
|
448
456
|
InstanceAccessor<&Archive::getArticleCount>("articleCount"),
|
|
457
|
+
InstanceAccessor<&Archive::getMediaCount>("mediaCount"),
|
|
449
458
|
InstanceAccessor<&Archive::getUuid>("uuid"),
|
|
450
459
|
InstanceMethod<&Archive::getMetadata>("getMetadata"),
|
|
451
460
|
InstanceMethod<&Archive::getMetadataItem>("getMetadataItem"),
|
package/src/blob.h
CHANGED
|
@@ -29,17 +29,20 @@ class Blob : public Napi::ObjectWrap<Blob> {
|
|
|
29
29
|
if (info[0].IsArrayBuffer()) { // handle ArrayBuffer
|
|
30
30
|
auto buf = info[0].As<Napi::ArrayBuffer>();
|
|
31
31
|
size = buf.ByteLength();
|
|
32
|
-
data = std::shared_ptr<char>(new char[size]
|
|
32
|
+
data = std::shared_ptr<char>(new char[size],
|
|
33
|
+
std::default_delete<char[]>());
|
|
33
34
|
memcpy(data.get(), buf.Data(), size);
|
|
34
35
|
} else if (info[0].IsBuffer()) { // handle Buffer
|
|
35
36
|
auto buf = info[0].As<Napi::Buffer<char>>();
|
|
36
37
|
size = buf.Length();
|
|
37
|
-
data = std::shared_ptr<char>(new char[size]
|
|
38
|
+
data = std::shared_ptr<char>(new char[size],
|
|
39
|
+
std::default_delete<char[]>());
|
|
38
40
|
memcpy(data.get(), buf.Data(), size);
|
|
39
41
|
} else { // all others toString()
|
|
40
42
|
auto str = info[0].ToString().Utf8Value(); // coerce to string
|
|
41
43
|
size = str.size();
|
|
42
|
-
data = std::shared_ptr<char>(new char[size]
|
|
44
|
+
data = std::shared_ptr<char>(new char[size],
|
|
45
|
+
std::default_delete<char[]>());
|
|
43
46
|
memcpy(data.get(), str.c_str(), size);
|
|
44
47
|
}
|
|
45
48
|
|
package/src/index.d.ts
CHANGED
|
@@ -153,6 +153,7 @@ export class Archive {
|
|
|
153
153
|
get allEntryCount(): number;
|
|
154
154
|
get entryCount(): number;
|
|
155
155
|
get articleCount(): number;
|
|
156
|
+
get mediaCount(): number;
|
|
156
157
|
get uuid(): string;
|
|
157
158
|
getMetadata(name: string): string;
|
|
158
159
|
getMetadataItem(name: string): Item;
|
|
@@ -208,7 +209,6 @@ export class SearchIterator {
|
|
|
208
209
|
get score(): number;
|
|
209
210
|
get snippet(): string;
|
|
210
211
|
get wordCount(): number;
|
|
211
|
-
get size(): number;
|
|
212
212
|
get fileIndex(): number;
|
|
213
213
|
get zimId(): string;
|
|
214
214
|
get entry(): Entry;
|
package/src/index.js
CHANGED
package/src/search.h
CHANGED
|
@@ -200,14 +200,6 @@ class SearchIterator : public Napi::ObjectWrap<SearchIterator> {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
Napi::Value getSize(const Napi::CallbackInfo &info) {
|
|
204
|
-
try {
|
|
205
|
-
return Napi::Value::From(info.Env(), searchIterator_.getSize());
|
|
206
|
-
} catch (const std::exception &err) {
|
|
207
|
-
throw Napi::Error::New(info.Env(), err.what());
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
203
|
Napi::Value getFileIndex(const Napi::CallbackInfo &info) {
|
|
212
204
|
try {
|
|
213
205
|
return Napi::Value::From(info.Env(), searchIterator_.getFileIndex());
|
|
@@ -250,7 +242,6 @@ class SearchIterator : public Napi::ObjectWrap<SearchIterator> {
|
|
|
250
242
|
InstanceAccessor<&SearchIterator::getScore>("score"),
|
|
251
243
|
InstanceAccessor<&SearchIterator::getSnippet>("snippet"),
|
|
252
244
|
InstanceAccessor<&SearchIterator::getWordCount>("wordCount"),
|
|
253
|
-
InstanceAccessor<&SearchIterator::getSize>("size"),
|
|
254
245
|
InstanceAccessor<&SearchIterator::getFileIndex>("fileIndex"),
|
|
255
246
|
InstanceAccessor<&SearchIterator::getZimId>("zimId"),
|
|
256
247
|
InstanceAccessor<&SearchIterator::getEntry>("entry"),
|
|
File without changes
|