@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/src/writer.cc
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#include "writer.h"
|
|
2
|
-
|
|
3
|
-
#include <napi.h>
|
|
4
|
-
|
|
5
|
-
Napi::FunctionReference ZimCreatorWrapper::constructor;
|
|
6
|
-
|
|
7
|
-
ZimCreatorWrapper::ZimCreatorWrapper(const Napi::CallbackInfo& info)
|
|
8
|
-
: Napi::ObjectWrap<ZimCreatorWrapper>(info) {
|
|
9
|
-
Napi::Env env = info.Env();
|
|
10
|
-
Napi::HandleScope scope(env);
|
|
11
|
-
|
|
12
|
-
if (!info[0].IsObject()) {
|
|
13
|
-
throw Napi::Error::New(
|
|
14
|
-
env, "first argument must be an object with at least fileName");
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
auto opts = info[0].ToObject();
|
|
18
|
-
std::string fileName = opts.Get("fileName").ToString();
|
|
19
|
-
std::string mainPage =
|
|
20
|
-
opts.Has("mainPage") ? std::string(opts.Get("mainPage").ToString()) : "";
|
|
21
|
-
std::string fullTextIndexLanguage =
|
|
22
|
-
opts.Has("fullTextIndexLanguage")
|
|
23
|
-
? std::string(opts.Get("fullTextIndexLanguage").ToString())
|
|
24
|
-
: "";
|
|
25
|
-
int minChunkSize = opts.Has("minChunkSize")
|
|
26
|
-
? opts.Get("minChunkSize").ToNumber().Int32Value()
|
|
27
|
-
: 2048;
|
|
28
|
-
|
|
29
|
-
zim::CompressionType comp = zim::zimcompLzma;
|
|
30
|
-
if (opts.Has("compression")) {
|
|
31
|
-
std::string comp_str = std::string(opts.Get("compression").ToString());
|
|
32
|
-
if (comp_str == "lzma") { comp = zim::zimcompLzma; }
|
|
33
|
-
if (comp_str == "zstd") { comp = zim::zimcompZstd; }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
creator_ = std::make_shared<OverriddenZimCreator>(mainPage, comp);
|
|
37
|
-
creator_->setIndexing(!fullTextIndexLanguage.empty(), fullTextIndexLanguage);
|
|
38
|
-
creator_->setMinChunkSize(minChunkSize);
|
|
39
|
-
creator_->startZimCreation(fileName);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
void ZimCreatorWrapper::addArticle(const Napi::CallbackInfo& info) {
|
|
43
|
-
Article* article =
|
|
44
|
-
Napi::ObjectWrap<Article>::Unwrap(info[0].As<Napi::Object>());
|
|
45
|
-
creator_->addArticle(article->getArticle());
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
void ZimCreatorWrapper::finalise(const Napi::CallbackInfo& info) {
|
|
49
|
-
creator_->finishZimCreation();
|
|
50
|
-
creator_ = nullptr;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
void ZimCreatorWrapper::Init(Napi::Env env, Napi::Object exports) {
|
|
54
|
-
Napi::HandleScope scope(env);
|
|
55
|
-
Napi::Function func = DefineClass(
|
|
56
|
-
env, "ZimCreatorWrapper",
|
|
57
|
-
{
|
|
58
|
-
InstanceMethod("addArticle", &ZimCreatorWrapper::addArticle),
|
|
59
|
-
InstanceMethod("finalise", &ZimCreatorWrapper::finalise),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
constructor = Napi::Persistent(func);
|
|
63
|
-
constructor.SuppressDestruct();
|
|
64
|
-
|
|
65
|
-
exports.Set("ZimCreatorWrapper", func);
|
|
66
|
-
}
|
|
67
|
-
|
package/src/writer.h
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#include <napi.h>
|
|
3
|
-
#include <zim/writer/creator.h>
|
|
4
|
-
|
|
5
|
-
#include <map>
|
|
6
|
-
#include <memory>
|
|
7
|
-
#include <string>
|
|
8
|
-
|
|
9
|
-
#include "article.h"
|
|
10
|
-
|
|
11
|
-
class OverriddenZimCreator : public zim::writer::Creator {
|
|
12
|
-
public:
|
|
13
|
-
explicit OverriddenZimCreator(std::string mainPage,
|
|
14
|
-
zim::CompressionType comp = zim::zimcompLzma)
|
|
15
|
-
: zim::writer::Creator(true, comp), mainPage(mainPage) {}
|
|
16
|
-
|
|
17
|
-
virtual zim::writer::Url getMainUrl() const {
|
|
18
|
-
return zim::writer::Url('A', mainPage);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
std::string mainPage;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
class ZimCreatorWrapper : public Napi::ObjectWrap<ZimCreatorWrapper> {
|
|
25
|
-
public:
|
|
26
|
-
static void Init(Napi::Env env, Napi::Object exports);
|
|
27
|
-
explicit ZimCreatorWrapper(const Napi::CallbackInfo& info);
|
|
28
|
-
void addArticle(const Napi::CallbackInfo& info);
|
|
29
|
-
void finalise(const Napi::CallbackInfo& info);
|
|
30
|
-
|
|
31
|
-
private:
|
|
32
|
-
static Napi::FunctionReference constructor;
|
|
33
|
-
std::shared_ptr<OverriddenZimCreator> creator_;
|
|
34
|
-
std::string tmpDir_;
|
|
35
|
-
std::string fileName_;
|
|
36
|
-
std::map<std::string, uint64_t> articleCounter_;
|
|
37
|
-
};
|
|
38
|
-
|