@openzim/libzim 3.3.0 → 3.4.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/Changelog CHANGED
@@ -1,3 +1,6 @@
1
+ 3.4.0
2
+ * NEW: Add new libzim 9.3.0 APIs around cache management
3
+
1
4
  3.3.0
2
5
  * NEW: Use libzim 9.3.0
3
6
  * UPDATE: Upgrade many dependencies versions
package/dist/index.d.ts CHANGED
@@ -182,6 +182,14 @@ export class Archive {
182
182
  checkIntegrity(checkType: symbol): boolean; // one of IntegrityCheck
183
183
  get isMultiPart(): boolean;
184
184
  get hasNewNamespaceScheme(): boolean;
185
+ getClusterCacheMaxSize(): number;
186
+ getClusterCacheCurrentSize(): number;
187
+ setClusterCacheMaxSize(nbClusters: number): void;
188
+ getDirentCacheMaxSize(): number;
189
+ getDirentCacheCurrentSize(): number;
190
+ setDirentCacheMaxSize(nbDirents: number): void;
191
+ getDirentLookupCacheMaxSize(): number;
192
+ setDirentLookupCacheMaxSize(nbRanges: number): void;
185
193
 
186
194
  static validate(zimPath: string, checksToRun: symbol[]): boolean; // list of IntegrityCheck
187
195
  }
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.3.0",
5
+ "version": "3.4.0",
6
6
  "description": "Libzim bindings for NodeJS",
7
7
  "type": "module",
8
8
  "scripts": {
package/src/archive.h CHANGED
@@ -411,6 +411,85 @@ class Archive : public Napi::ObjectWrap<Archive> {
411
411
  }
412
412
  }
413
413
 
414
+ Napi::Value getClusterCacheMaxSize(const Napi::CallbackInfo &info) {
415
+ try {
416
+ return Napi::Value::From(info.Env(), archive_->getClusterCacheMaxSize());
417
+ } catch (const std::exception &err) {
418
+ throw Napi::Error::New(info.Env(), err.what());
419
+ }
420
+ }
421
+
422
+ Napi::Value getClusterCacheCurrentSize(const Napi::CallbackInfo &info) {
423
+ try {
424
+ return Napi::Value::From(info.Env(),
425
+ archive_->getClusterCacheCurrentSize());
426
+ } catch (const std::exception &err) {
427
+ throw Napi::Error::New(info.Env(), err.what());
428
+ }
429
+ }
430
+
431
+ void setClusterCacheMaxSize(const Napi::CallbackInfo &info) {
432
+ try {
433
+ if (!info[0].IsNumber()) {
434
+ throw Napi::Error::New(info.Env(), "Expected a number");
435
+ }
436
+ auto nbClusters = info[0].As<Napi::Number>().Uint32Value();
437
+ archive_->setClusterCacheMaxSize(nbClusters);
438
+ } catch (const std::exception &err) {
439
+ throw Napi::Error::New(info.Env(), err.what());
440
+ }
441
+ }
442
+
443
+ Napi::Value getDirentCacheMaxSize(const Napi::CallbackInfo &info) {
444
+ try {
445
+ return Napi::Value::From(info.Env(), archive_->getDirentCacheMaxSize());
446
+ } catch (const std::exception &err) {
447
+ throw Napi::Error::New(info.Env(), err.what());
448
+ }
449
+ }
450
+
451
+ Napi::Value getDirentCacheCurrentSize(const Napi::CallbackInfo &info) {
452
+ try {
453
+ return Napi::Value::From(info.Env(),
454
+ archive_->getDirentCacheCurrentSize());
455
+ } catch (const std::exception &err) {
456
+ throw Napi::Error::New(info.Env(), err.what());
457
+ }
458
+ }
459
+
460
+ void setDirentCacheMaxSize(const Napi::CallbackInfo &info) {
461
+ try {
462
+ if (!info[0].IsNumber()) {
463
+ throw Napi::Error::New(info.Env(), "Expected a number");
464
+ }
465
+ auto nbDirents = info[0].As<Napi::Number>().Uint32Value();
466
+ archive_->setDirentCacheMaxSize(nbDirents);
467
+ } catch (const std::exception &err) {
468
+ throw Napi::Error::New(info.Env(), err.what());
469
+ }
470
+ }
471
+
472
+ Napi::Value getDirentLookupCacheMaxSize(const Napi::CallbackInfo &info) {
473
+ try {
474
+ return Napi::Value::From(info.Env(),
475
+ archive_->getDirentLookupCacheMaxSize());
476
+ } catch (const std::exception &err) {
477
+ throw Napi::Error::New(info.Env(), err.what());
478
+ }
479
+ }
480
+
481
+ void setDirentLookupCacheMaxSize(const Napi::CallbackInfo &info) {
482
+ try {
483
+ if (!info[0].IsNumber()) {
484
+ throw Napi::Error::New(info.Env(), "Expected a number");
485
+ }
486
+ auto nbRanges = info[0].As<Napi::Number>().Uint32Value();
487
+ archive_->setDirentLookupCacheMaxSize(nbRanges);
488
+ } catch (const std::exception &err) {
489
+ throw Napi::Error::New(info.Env(), err.what());
490
+ }
491
+ }
492
+
414
493
  static Napi::Value validate(const Napi::CallbackInfo &info) {
415
494
  Napi::Env env = info.Env();
416
495
  Napi::HandleScope scope(env);
@@ -485,6 +564,22 @@ class Archive : public Napi::ObjectWrap<Archive> {
485
564
  InstanceAccessor<&Archive::getChecksum>("checksum"),
486
565
  InstanceMethod<&Archive::check>("check"),
487
566
  InstanceMethod<&Archive::checkIntegrity>("checkIntegrity"),
567
+ InstanceMethod<&Archive::getClusterCacheMaxSize>(
568
+ "getClusterCacheMaxSize"),
569
+ InstanceMethod<&Archive::getClusterCacheCurrentSize>(
570
+ "getClusterCacheCurrentSize"),
571
+ InstanceMethod<&Archive::setClusterCacheMaxSize>(
572
+ "setClusterCacheMaxSize"),
573
+ InstanceMethod<&Archive::getDirentCacheMaxSize>(
574
+ "getDirentCacheMaxSize"),
575
+ InstanceMethod<&Archive::getDirentCacheCurrentSize>(
576
+ "getDirentCacheCurrentSize"),
577
+ InstanceMethod<&Archive::setDirentCacheMaxSize>(
578
+ "setDirentCacheMaxSize"),
579
+ InstanceMethod<&Archive::getDirentLookupCacheMaxSize>(
580
+ "getDirentLookupCacheMaxSize"),
581
+ InstanceMethod<&Archive::setDirentLookupCacheMaxSize>(
582
+ "setDirentLookupCacheMaxSize"),
488
583
  InstanceAccessor<&Archive::isMultiPart>("isMultiPart"),
489
584
  InstanceAccessor<&Archive::hasNewNamespaceScheme>(
490
585
  "hasNewNamespaceScheme"),
package/src/index.d.ts CHANGED
@@ -182,6 +182,14 @@ export class Archive {
182
182
  checkIntegrity(checkType: symbol): boolean; // one of IntegrityCheck
183
183
  get isMultiPart(): boolean;
184
184
  get hasNewNamespaceScheme(): boolean;
185
+ getClusterCacheMaxSize(): number;
186
+ getClusterCacheCurrentSize(): number;
187
+ setClusterCacheMaxSize(nbClusters: number): void;
188
+ getDirentCacheMaxSize(): number;
189
+ getDirentCacheCurrentSize(): number;
190
+ setDirentCacheMaxSize(nbDirents: number): void;
191
+ getDirentLookupCacheMaxSize(): number;
192
+ setDirentLookupCacheMaxSize(nbRanges: number): void;
185
193
 
186
194
  static validate(zimPath: string, checksToRun: symbol[]): boolean; // list of IntegrityCheck
187
195
  }