@openzim/libzim 3.1.0 → 3.2.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 CHANGED
@@ -1 +1 @@
1
- LIBZIM_VERSION=8.2.1
1
+ LIBZIM_VERSION=9.0.0
package/Changelog CHANGED
@@ -1,3 +1,10 @@
1
+ 3.2.0:
2
+ * NEW: Use libzim v9.0.0
3
+ * NEW: Added mediaCount to Archive
4
+ * FIX: Simplify a lot the CI
5
+ * FIX: Nlob allocation and warning
6
+ * DEL: Deprecated getSize from SearchIterator
7
+
1
8
  3.1.0:
2
9
  * NEW: Use libzim v8.2.1
3
10
  * FIX: Handling of binary data in the creator
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.8",
27
+ "<(libzim_dir)/lib/x86_64-linux-gnu/libzim.so.9",
28
28
  ],
29
29
  }],
30
30
  ["libzim_local!='true' and OS=='mac'", {
package/bundle-libzim.js CHANGED
@@ -15,18 +15,18 @@ if (!isMacOS && !isLinux) {
15
15
  }
16
16
 
17
17
  if (isLinux) {
18
- console.info("Copying libzim.so.8 to build folder");
18
+ console.info("Copying libzim.so.9 to build folder");
19
19
  exec(
20
- "cp download/lib/x86_64-linux-gnu/libzim.so.8 build/Release/libzim.so.8"
20
+ "cp download/lib/x86_64-linux-gnu/libzim.so.9 build/Release/libzim.so.9"
21
21
  );
22
- exec("ln -sf build/Release/libzim.so.8 build/Release/libzim.so"); // convienience only, not required
22
+ exec("ln -sf build/Release/libzim.so.9 build/Release/libzim.so"); // convienience only, not required
23
23
  }
24
24
  if (isMacOS) {
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
25
+ console.info("Copying libzim.9.dylib to build folder");
26
+ exec("cp download/lib/libzim.9.dylib build/Release/libzim.9.dylib");
27
+ exec("ln -sf build/Release/libzim.9.dylib build/Release/libzim.dylib"); // convienience only, not required
28
28
  console.info("Fixing rpath");
29
29
  exec(
30
- "install_name_tool -change libzim.8.dylib @loader_path/libzim.8.dylib build/Release/zim_binding.node"
30
+ "install_name_tool -change libzim.9.dylib @loader_path/libzim.9.dylib build/Release/zim_binding.node"
31
31
  );
32
32
  }
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;
@@ -8,9 +8,12 @@ const urlParser = require("url");
8
8
 
9
9
  mkdirp.sync("./download");
10
10
 
11
+ console.info("os.type() is:", os.type());
12
+ console.info("os.arch() is:", os.arch());
11
13
  const isMacOS = os.type() === "Darwin";
12
14
  const isLinux = os.type() === "Linux";
13
15
  const rawArch = os.arch();
16
+
14
17
  const isAvailableArch =
15
18
  rawArch === "x64" || rawArch === "arm" || rawArch === "arm64";
16
19
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@openzim/libzim",
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.js",
5
- "version": "3.1.0",
5
+ "version": "3.2.0",
6
6
  "description": "Libzim bindings for NodeJS",
7
7
  "scripts": {
8
8
  "clean": "rm -rf dist build/native/build",
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/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"),