@openzim/libzim 4.1.0 → 4.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=9.5.1
1
+ LIBZIM_VERSION=9.7.0
package/Changelog CHANGED
@@ -1,4 +1,9 @@
1
- Unreleased
1
+ 4.2.0
2
+ * NEW: Use libzim 9.7.0
3
+ * NEW: Add addAlias method to Creator
4
+ * UPDATE: Change EditorConfig cpp spacing to 2 spaces
5
+
6
+ 4.1.0
2
7
  * NEW: Use libzim 9.5.1
3
8
  * FIX: Fix lib directories for aarch64
4
9
  * FIX: Update Node.JS dependencies
package/README.md CHANGED
@@ -61,7 +61,7 @@ import { Creator, StringItem } from "@openzim/libzim";
61
61
  ### Reading a ZIM file
62
62
  ```javascript
63
63
  // read.js
64
- import { Archive, SuggestionSearcher, Searcher } from "@openzim/libzim";
64
+ import { Archive, Query, SuggestionSearcher, Searcher } from "@openzim/libzim";
65
65
 
66
66
  (async () => {
67
67
  const outFile = "./test.zim";
@@ -89,12 +89,12 @@ import { Archive, SuggestionSearcher, Searcher } from "@openzim/libzim";
89
89
  }
90
90
 
91
91
 
92
- const entry = await archive.getEntryByPath("A/laborum");
92
+ const entry = archive.getEntryByPath("A/laborum");
93
93
  const item = entry.item;
94
94
  const blob = item.data;
95
95
  console.info(`Entry by url (laborum):`, blob.data);
96
- delete archive;
97
96
  })();
97
+ ```
98
98
 
99
99
  ## Local Development
100
100
 
package/dist/index.d.ts CHANGED
@@ -118,6 +118,7 @@ export class Creator {
118
118
  targetPath: string,
119
119
  hints?: Hint,
120
120
  ): void;
121
+ addAlias(path: string, title: string, targetPath: string, hints?: Hint): void;
121
122
  setMainPath(mainPath: string): void;
122
123
  setUuid(uuid: string): void;
123
124
  finishZimCreation(): Promise<void>;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@openzim/libzim",
3
3
  "main": "dist/index.js",
4
- "types": "dist/index.d.js",
5
- "version": "4.1.0",
4
+ "types": "dist/index.d.ts",
5
+ "version": "4.2.0",
6
6
  "description": "Libzim bindings for NodeJS",
7
7
  "type": "module",
8
8
  "scripts": {
package/src/creator.h CHANGED
@@ -342,6 +342,29 @@ class Creator : public Napi::ObjectWrap<Creator> {
342
342
  }
343
343
  }
344
344
 
345
+ void addAlias(const Napi::CallbackInfo &info) {
346
+ try {
347
+ auto env = info.Env();
348
+ if (info.Length() < 3) {
349
+ throw Napi::Error::New(env,
350
+ "addAlias requires arguments: path, title, "
351
+ "targetPath, [hints]");
352
+ }
353
+
354
+ auto path = info[0].As<Napi::String>().Utf8Value();
355
+ auto title = info[1].As<Napi::String>().Utf8Value();
356
+ auto targetPath = info[2].As<Napi::String>().Utf8Value();
357
+ if (info[3].IsObject()) {
358
+ auto hints = Object2Hints(info[3].ToObject());
359
+ creator_->addAlias(path, title, targetPath, hints);
360
+ } else {
361
+ creator_->addAlias(path, title, targetPath);
362
+ }
363
+ } catch (const std::exception &err) {
364
+ throw Napi::Error::New(info.Env(), err.what());
365
+ }
366
+ }
367
+
345
368
  void setMainPath(const Napi::CallbackInfo &info) {
346
369
  try {
347
370
  auto env = info.Env();
@@ -387,6 +410,7 @@ class Creator : public Napi::ObjectWrap<Creator> {
387
410
  InstanceMethod<&Creator::addMetadata>("addMetadata"),
388
411
  InstanceMethod<&Creator::addIllustration>("addIllustration"),
389
412
  InstanceMethod<&Creator::addRedirection>("addRedirection"),
413
+ InstanceMethod<&Creator::addAlias>("addAlias"),
390
414
  InstanceMethod<&Creator::setMainPath>("setMainPath"),
391
415
  InstanceMethod<&Creator::setUuid>("setUuid"),
392
416
 
package/src/index.d.ts CHANGED
@@ -118,6 +118,7 @@ export class Creator {
118
118
  targetPath: string,
119
119
  hints?: Hint,
120
120
  ): void;
121
+ addAlias(path: string, title: string, targetPath: string, hints?: Hint): void;
121
122
  setMainPath(mainPath: string): void;
122
123
  setUuid(uuid: string): void;
123
124
  finishZimCreation(): Promise<void>;