@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/download-libzim.js
CHANGED
|
@@ -1,59 +1,78 @@
|
|
|
1
|
-
require(
|
|
2
|
-
const axios = require(
|
|
3
|
-
const mkdirp = require(
|
|
4
|
-
const exec = require(
|
|
5
|
-
const os = require(
|
|
6
|
-
const fs = require(
|
|
7
|
-
const urlParser = require(
|
|
1
|
+
require("dotenv").config();
|
|
2
|
+
const axios = require("axios");
|
|
3
|
+
const mkdirp = require("mkdirp");
|
|
4
|
+
const exec = require("exec-then");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const urlParser = require("url");
|
|
8
8
|
|
|
9
|
-
mkdirp.sync(
|
|
9
|
+
mkdirp.sync("./download");
|
|
10
10
|
|
|
11
|
-
const isMacOS = os.type() ===
|
|
12
|
-
const isLinux = os.type() ===
|
|
11
|
+
const isMacOS = os.type() === "Darwin";
|
|
12
|
+
const isLinux = os.type() === "Linux";
|
|
13
|
+
const rawArch = os.arch();
|
|
14
|
+
const isAvailableArch =
|
|
15
|
+
rawArch === "x64" || rawArch === "arm" || rawArch === "arm64";
|
|
13
16
|
|
|
14
17
|
if (!isMacOS && !isLinux) {
|
|
15
|
-
|
|
18
|
+
console.warn(
|
|
19
|
+
`\x1b[41m\n================================ README \n\nPre-built binaries only available on Linux and MacOS for now...\nPlease ensure you have libzim installed globally on this machine:\n\n\thttps://github.com/openzim/libzim/\n\n================================\x1b[0m\n`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (!isAvailableArch) {
|
|
23
|
+
console.warn(
|
|
24
|
+
`\x1b[41m\n================================ README \n\nPre-built binaries only available on x86_64, arm and arm64 for now...\nPlease ensure you have libzim installed globally on this machine:\n\n\thttps://github.com/openzim/libzim/\n\n================================\x1b[0m\n`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let osPrefix = isMacOS ? "macos" : "linux";
|
|
29
|
+
let osArch = isLinux ? "x86_64-bionic" : "x86_64";
|
|
30
|
+
|
|
31
|
+
if (rawArch !== "x64") {
|
|
32
|
+
if (isLinux) {
|
|
33
|
+
osArch = rawArch === "arm64" ? "aarch64-bionic" : "armhf";
|
|
34
|
+
} else {
|
|
35
|
+
osArch = rawArch;
|
|
36
|
+
}
|
|
16
37
|
}
|
|
17
38
|
|
|
18
|
-
let osPrefix = (isMacOS) ? 'macos' : 'linux';
|
|
19
39
|
const urls = [
|
|
20
|
-
|
|
21
|
-
].filter(a => a);
|
|
40
|
+
`https://download.openzim.org/release/libzim/libzim_${osPrefix}-${osArch}-${process.env.LIBZIM_VERSION}.tar.gz`,
|
|
41
|
+
].filter((a) => a);
|
|
22
42
|
|
|
23
43
|
for (let url of urls) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
console.info(`Downloading Libzim from: `, url);
|
|
45
|
+
const filename = urlParser.parse(url).pathname.split("/").slice(-1)[0];
|
|
46
|
+
const dlFile = `./download/${filename}`;
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
fs.statSync(dlFile);
|
|
50
|
+
console.warn(`File [${dlFile}] already exists, not downloading`);
|
|
51
|
+
return;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
//
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
axios({
|
|
57
|
+
url,
|
|
58
|
+
method: "get",
|
|
59
|
+
responseType: "stream",
|
|
60
|
+
})
|
|
61
|
+
.then(function (response) {
|
|
62
|
+
const ws = fs.createWriteStream(dlFile);
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
response.data.pipe(ws).on("error", reject).on("close", resolve);
|
|
65
|
+
});
|
|
66
|
+
})
|
|
67
|
+
.then(() => {
|
|
68
|
+
const cmd = `tar --strip-components 1 -xf ${dlFile} -C ./download`;
|
|
69
|
+
console.log(`Running Extract:`, `[${cmd}]`);
|
|
70
|
+
return exec(cmd);
|
|
71
|
+
})
|
|
72
|
+
.then(() => {
|
|
73
|
+
console.info(`Successfully downloaded and extracted file`);
|
|
38
74
|
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
response.data
|
|
43
|
-
.pipe(ws)
|
|
44
|
-
.on('error', reject)
|
|
45
|
-
.on('close', resolve);
|
|
46
|
-
});
|
|
47
|
-
})
|
|
48
|
-
.then(() => {
|
|
49
|
-
const cmd = `tar --strip-components 1 -xf ${dlFile} -C ./download`;
|
|
50
|
-
console.log(`Running Extract:`, `[${cmd}]`);
|
|
51
|
-
return exec(cmd);
|
|
52
|
-
})
|
|
53
|
-
.then(() => {
|
|
54
|
-
console.info(`Successfully downloaded and extracted file`);
|
|
55
|
-
})
|
|
56
|
-
.catch(err => {
|
|
57
|
-
console.error(`Failed to download and extract file:`, err);
|
|
58
|
-
});
|
|
75
|
+
.catch((err) => {
|
|
76
|
+
console.error(`Failed to download and extract file:`, err);
|
|
77
|
+
});
|
|
59
78
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzim/libzim",
|
|
3
|
-
"
|
|
3
|
+
"main": "dist/index.js",
|
|
4
|
+
"types": "dist/index.d.js",
|
|
5
|
+
"version": "3.1.0",
|
|
4
6
|
"description": "Libzim bindings for NodeJS",
|
|
5
7
|
"scripts": {
|
|
6
8
|
"clean": "rm -rf dist build/native/build",
|
|
7
9
|
"tsc": "tsc",
|
|
8
|
-
"prepare": "
|
|
10
|
+
"prepare": "mkdir -p dist/ && cp -v src/index.js src/index.d.ts dist/",
|
|
9
11
|
"codecov": "nyc --reporter=lcov npm t",
|
|
10
12
|
"install": "npm run download && node-gyp rebuild -v && npm run bundle",
|
|
13
|
+
"build": "node-gyp rebuild -v && npm run bundle",
|
|
11
14
|
"download": "node ./download-libzim.js",
|
|
12
15
|
"bundle": "node ./bundle-libzim.js",
|
|
13
16
|
"test": "jest",
|
|
14
|
-
"test-mem-leak": "node -r ts-node/register test/makeLargeZim.ts"
|
|
17
|
+
"test-mem-leak": "node -r ts-node/register test/makeLargeZim.ts",
|
|
18
|
+
"lint": "npx eslint .",
|
|
19
|
+
"lint:fix": "npx eslint . --fix"
|
|
15
20
|
},
|
|
16
21
|
"nyc": {
|
|
17
22
|
"extension": [
|
|
@@ -22,7 +27,6 @@
|
|
|
22
27
|
"node_modules"
|
|
23
28
|
]
|
|
24
29
|
},
|
|
25
|
-
"main": "dist/index.js",
|
|
26
30
|
"author": "Joseph Reeve",
|
|
27
31
|
"license": "GPL-3.0",
|
|
28
32
|
"repository": {
|
|
@@ -35,32 +39,32 @@
|
|
|
35
39
|
"homepage": "https://github.com/openzim/node-libzim#readme",
|
|
36
40
|
"gypfile": true,
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"@types/bindings": "^1.5.
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/
|
|
41
|
-
"
|
|
42
|
-
"@types/node": "^13.13.52",
|
|
43
|
-
"@types/rimraf": "^3.0.0",
|
|
44
|
-
"axios": "^0.21.1",
|
|
42
|
+
"@types/bindings": "^1.5.1",
|
|
43
|
+
"@types/jest": "^28.1.6",
|
|
44
|
+
"@types/node": "^18.0.6",
|
|
45
|
+
"axios": "^1.6.0",
|
|
45
46
|
"bindings": "^1.5.0",
|
|
46
|
-
"dotenv": "^
|
|
47
|
+
"dotenv": "^16.0.1",
|
|
47
48
|
"exec-then": "^1.3.1",
|
|
48
|
-
"faker": "^4.1.0",
|
|
49
|
-
"jest": "^25.5.4",
|
|
50
|
-
"mime": "^2.5.2",
|
|
51
|
-
"minimist": "^1.2.5",
|
|
52
49
|
"mkdirp": "^1.0.4",
|
|
53
|
-
"node-addon-api": "^
|
|
54
|
-
"node-gyp": "^
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"ts-node": "^8.10.2",
|
|
59
|
-
"tsconfig-paths": "^3.9.0"
|
|
50
|
+
"node-addon-api": "^5.0.0",
|
|
51
|
+
"node-gyp": "^9.3.1",
|
|
52
|
+
"tqdm": "^2.0.3",
|
|
53
|
+
"ts-node": "^10.9.1",
|
|
54
|
+
"tsconfig-paths": "^4.0.0"
|
|
60
55
|
},
|
|
61
56
|
"devDependencies": {
|
|
57
|
+
"@faker-js/faker": "^7.6.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
59
|
+
"@typescript-eslint/parser": "^5.59.2",
|
|
60
|
+
"eslint": "^8.39.0",
|
|
61
|
+
"eslint-config-prettier": "^8.8.0",
|
|
62
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
63
|
+
"jest": "^28.1.3",
|
|
62
64
|
"nyc": "^15.1.0",
|
|
63
|
-
"
|
|
65
|
+
"prettier": "^2.8.8",
|
|
66
|
+
"ts-jest": "^28.0.7",
|
|
67
|
+
"typescript": "^4.7.4"
|
|
64
68
|
},
|
|
65
69
|
"jest": {
|
|
66
70
|
"preset": "ts-jest/presets/js-with-ts"
|