mwoffliner 1.11.11 → 1.12.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/README.md +5 -16
- package/jest.config.cjs +18 -0
- package/lib/DOMUtils.js +1 -3
- package/lib/DOMUtils.js.map +1 -1
- package/lib/Downloader.d.ts +8 -13
- package/lib/Downloader.js +420 -523
- package/lib/Downloader.js.map +1 -1
- package/lib/Dump.d.ts +3 -2
- package/lib/Dump.js +68 -87
- package/lib/Dump.js.map +1 -1
- package/lib/Logger.js +6 -5
- package/lib/Logger.js.map +1 -1
- package/lib/MediaWiki.d.ts +3 -3
- package/lib/MediaWiki.js +188 -241
- package/lib/MediaWiki.js.map +1 -1
- package/lib/RedisStore.d.ts +302 -0
- package/lib/RedisStore.js +119 -0
- package/lib/RedisStore.js.map +1 -0
- package/lib/S3.d.ts +1 -1
- package/lib/S3.js +67 -87
- package/lib/S3.js.map +1 -1
- package/lib/Templates.js +27 -36
- package/lib/Templates.js.map +1 -1
- package/lib/cli.d.ts +1 -1
- package/lib/cli.js +15 -38
- package/lib/cli.js.map +1 -1
- package/lib/config.d.ts +3 -6
- package/lib/config.js +37 -20
- package/lib/config.js.map +1 -1
- package/lib/mwoffliner.lib.d.ts +2 -2
- package/lib/mwoffliner.lib.js +487 -508
- package/lib/mwoffliner.lib.js.map +1 -1
- package/lib/parameterList.d.ts +2 -3
- package/lib/parameterList.js +9 -13
- package/lib/parameterList.js.map +1 -1
- package/lib/sanitize-argument.d.ts +2 -1
- package/lib/sanitize-argument.js +97 -146
- package/lib/sanitize-argument.js.map +1 -1
- package/lib/util/RedisKvs.d.ts +19 -24
- package/lib/util/RedisKvs.js +130 -197
- package/lib/util/RedisKvs.js.map +1 -1
- package/lib/util/Timer.d.ts +10 -0
- package/lib/util/Timer.js +29 -0
- package/lib/util/Timer.js.map +1 -0
- package/lib/util/articleListMainPage.d.ts +1 -1
- package/lib/util/articleListMainPage.js +6 -12
- package/lib/util/articleListMainPage.js.map +1 -1
- package/lib/util/articleRenderers.d.ts +3 -3
- package/lib/util/articleRenderers.js +30 -49
- package/lib/util/articleRenderers.js.map +1 -1
- package/lib/util/categories.d.ts +4 -6
- package/lib/util/categories.js +169 -192
- package/lib/util/categories.js.map +1 -1
- package/lib/util/const.d.ts +2 -1
- package/lib/util/const.js +20 -22
- package/lib/util/const.js.map +1 -1
- package/lib/util/dump.d.ts +4 -4
- package/lib/util/dump.js +136 -170
- package/lib/util/dump.js.map +1 -1
- package/lib/util/index.d.ts +6 -6
- package/lib/util/index.js +6 -18
- package/lib/util/index.js.map +1 -1
- package/lib/util/misc.d.ts +11 -9
- package/lib/util/misc.js +138 -150
- package/lib/util/misc.js.map +1 -1
- package/lib/util/mw-api.d.ts +3 -3
- package/lib/util/mw-api.js +170 -91
- package/lib/util/mw-api.js.map +1 -1
- package/lib/util/redirects.d.ts +3 -3
- package/lib/util/redirects.js +14 -32
- package/lib/util/redirects.js.map +1 -1
- package/lib/util/rewriteUrls.d.ts +7 -4
- package/lib/util/rewriteUrls.js +215 -203
- package/lib/util/rewriteUrls.js.map +1 -1
- package/lib/util/saveArticles.d.ts +6 -15
- package/lib/util/saveArticles.js +620 -613
- package/lib/util/saveArticles.js.map +1 -1
- package/package.json +68 -68
- package/res/content.parsoid.css +24 -3
- package/res/script.js +4 -0
- package/res/templates/article_list_home.html +0 -3
- package/res/templates/page.html +0 -4
- package/translation/ru.json +6 -0
- package/jest.config.js +0 -18
- package/lib/Redis.d.ts +0 -5
- package/lib/Redis.js +0 -18
- package/lib/Redis.js.map +0 -1
- package/lib/stores.d.ts +0 -23
- package/lib/stores.js +0 -45
- package/lib/stores.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,8 +16,8 @@ MWoffliner development.
|
|
|
16
16
|
|
|
17
17
|
[](https://www.npmjs.com/package/mwoffliner)
|
|
18
18
|
[](https://hub.docker.com/r/openzim/mwoffliner)
|
|
19
|
-
[](https://github.com/openzim/mwoffliner/actions/workflows/ci.yml?query=branch%3Amain)
|
|
20
|
+
[](https://codecov.io/gh/openzim/mwoffliner)
|
|
21
21
|
[](https://www.codefactor.io/repository/github/openzim/mwoffliner)
|
|
22
22
|
[](LICENSE)
|
|
23
23
|
|
|
@@ -36,10 +36,10 @@ Run `mwoffliner --help` to get all the possible options.
|
|
|
36
36
|
|
|
37
37
|
- *NIX Operating System (GNU/Linux, macOS, ...)
|
|
38
38
|
- [Redis](https://redis.io/)
|
|
39
|
-
- [NodeJS](https://nodejs.org/en/) version
|
|
39
|
+
- [NodeJS](https://nodejs.org/en/) version 16 or greater
|
|
40
40
|
- [Libzim](https://github.com/openzim/libzim) (On GNU/Linux & macOS we automatically download it)
|
|
41
41
|
- Various build tools which are probably already installed on your
|
|
42
|
-
machine (packages `libjpeg-dev`, `autoconf`, `automake`, `gcc` on
|
|
42
|
+
machine (packages `libjpeg-dev`, `libglu1`, `autoconf`, `automake`, `gcc` on
|
|
43
43
|
Debian/Ubuntu)
|
|
44
44
|
|
|
45
45
|
... and an online Mediawiki with its API available.
|
|
@@ -95,22 +95,11 @@ Complementary information about MWoffliner:
|
|
|
95
95
|
* Wikitext is the name of the markup language that MediaWiki uses.
|
|
96
96
|
* MediaWiki includes a parser for WikiText into HTML, and this
|
|
97
97
|
parser creates the HTML pages displayed in your browser.
|
|
98
|
-
* There is another WikiText parser, called Parsoid, implemented in
|
|
99
|
-
Javascript/NodeJS. MWoffliner uses Parsoid.
|
|
100
|
-
* Parsoid is planned to eventually become the main parser for
|
|
101
|
-
MediaWiki.
|
|
102
|
-
* MWoffliner calls Parsoid and then post-processes the results for
|
|
103
|
-
offline format.
|
|
104
98
|
|
|
105
99
|
### GNU/Linux - Debian based distributions
|
|
106
100
|
|
|
107
101
|
Install NodeJS:
|
|
108
|
-
|
|
109
|
-
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash && \
|
|
110
|
-
source ~/.bashrc && \
|
|
111
|
-
nvm install stable && \
|
|
112
|
-
node --version
|
|
113
|
-
```
|
|
102
|
+
Read https://nodejs.org/en/download/current/
|
|
114
103
|
|
|
115
104
|
Install Redis:
|
|
116
105
|
```bash
|
package/jest.config.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extensionsToTreatAsEsm: ['.ts'],
|
|
3
|
+
moduleNameMapper: {
|
|
4
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
5
|
+
},
|
|
6
|
+
moduleFileExtensions: ["ts", "js"],
|
|
7
|
+
collectCoverage: false,
|
|
8
|
+
verbose: true,
|
|
9
|
+
transform: {
|
|
10
|
+
'^.+\\.ts?$': [
|
|
11
|
+
'ts-jest',
|
|
12
|
+
{
|
|
13
|
+
useESM: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
package/lib/DOMUtils.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const DOMUtils = {
|
|
4
2
|
deleteNode(node) {
|
|
5
3
|
if (node.parentNode) {
|
|
@@ -23,5 +21,5 @@ const DOMUtils = {
|
|
|
23
21
|
return sibling;
|
|
24
22
|
},
|
|
25
23
|
};
|
|
26
|
-
|
|
24
|
+
export default DOMUtils;
|
|
27
25
|
//# sourceMappingURL=DOMUtils.js.map
|
package/lib/DOMUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DOMUtils.js","sourceRoot":"","sources":["../src/DOMUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DOMUtils.js","sourceRoot":"","sources":["../src/DOMUtils.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG;IACf,UAAU,CAAC,IAAmB;QAC5B,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;SAClC;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;SACpB;QACD,IAAI,GAAG,SAAS,CAAA;IAClB,CAAC;IAED,YAAY,CAAC,IAAmB,EAAE,IAAY,EAAE,GAAQ;QACtD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;QAClD,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,QAAe,CAAC,CAAA;IAC1C,CAAC;IAED,kBAAkB,CAAC,IAAmB;QACpC,IAAI,OAAO,GAAG,IAAI,CAAC,WAAW,CAAA;QAC9B,OAAO,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAC,kBAAkB,EAAE;YAC3D,OAAO,GAAG,OAAO,CAAC,WAAW,CAAA;SAC9B;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF,CAAA;AAED,eAAe,QAAQ,CAAA"}
|
package/lib/Downloader.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { BackoffStrategy } from 'backoff';
|
|
3
3
|
import { AxiosRequestConfig } from 'axios';
|
|
4
|
-
import S3 from './S3';
|
|
5
|
-
import { Dump } from './Dump';
|
|
6
|
-
import MediaWiki from './MediaWiki';
|
|
4
|
+
import S3 from './S3.js';
|
|
5
|
+
import { Dump } from './Dump.js';
|
|
6
|
+
import MediaWiki from './MediaWiki.js';
|
|
7
7
|
interface DownloaderOpts {
|
|
8
8
|
mw: MediaWiki;
|
|
9
9
|
uaString: string;
|
|
10
10
|
speed: number;
|
|
11
11
|
reqTimeout: number;
|
|
12
|
-
noLocalParserFallback: boolean;
|
|
13
|
-
forceLocalParser: boolean;
|
|
14
12
|
optimisationCacheUrl: string;
|
|
15
13
|
s3?: S3;
|
|
16
14
|
webp: boolean;
|
|
@@ -37,12 +35,10 @@ declare class Downloader {
|
|
|
37
35
|
baseUrlForMainPage: string;
|
|
38
36
|
cssDependenceUrls: KVS<boolean>;
|
|
39
37
|
readonly webp: boolean;
|
|
38
|
+
readonly requestTimeout: number;
|
|
40
39
|
private readonly uaString;
|
|
41
40
|
private activeRequests;
|
|
42
41
|
private maxActiveRequests;
|
|
43
|
-
private readonly requestTimeout;
|
|
44
|
-
private readonly noLocalParserFallback;
|
|
45
|
-
private readonly forceLocalParser;
|
|
46
42
|
private readonly urlPartCache;
|
|
47
43
|
private readonly backoffOptions;
|
|
48
44
|
private readonly optimisationCacheUrl;
|
|
@@ -51,23 +47,22 @@ declare class Downloader {
|
|
|
51
47
|
arrayBufferRequestOptions: AxiosRequestConfig;
|
|
52
48
|
jsonRequestOptions: AxiosRequestConfig;
|
|
53
49
|
streamRequestOptions: AxiosRequestConfig;
|
|
54
|
-
constructor({ mw, uaString, speed, reqTimeout,
|
|
50
|
+
constructor({ mw, uaString, speed, reqTimeout, optimisationCacheUrl, s3, webp, backoffOptions }: DownloaderOpts);
|
|
55
51
|
serializeUrl(url: string): string;
|
|
56
52
|
deserializeUrl(url: string): string;
|
|
57
53
|
setBaseUrls(): Promise<void>;
|
|
58
54
|
checkApiAvailabilty(url: string): Promise<boolean>;
|
|
59
55
|
checkCapabilities(testArticleId?: string): Promise<void>;
|
|
60
56
|
removeEtagWeakPrefix(etag: string): string;
|
|
61
|
-
initLocalServices(): Promise<void>;
|
|
62
57
|
query(query: string): KVS<any>;
|
|
63
58
|
getArticleDetailsIds(articleIds: string[], shouldGetThumbnail?: boolean): Promise<QueryMwRet>;
|
|
64
59
|
getArticleDetailsNS(ns: number, gapcontinue?: string): Promise<{
|
|
65
60
|
gapContinue: string;
|
|
66
61
|
articleDetails: QueryMwRet;
|
|
67
62
|
}>;
|
|
68
|
-
getArticle(articleId: string, dump: Dump): Promise<RenderedArticle[]>;
|
|
63
|
+
getArticle(articleId: string, dump: Dump, articleDetailXId: RKVS<ArticleDetail>, articleDetail?: ArticleDetail): Promise<RenderedArticle[]>;
|
|
69
64
|
getJSON<T>(_url: string): Promise<T>;
|
|
70
|
-
downloadContent(_url: string): Promise<{
|
|
65
|
+
downloadContent(_url: string, retry?: boolean): Promise<{
|
|
71
66
|
content: Buffer | string;
|
|
72
67
|
responseHeaders: any;
|
|
73
68
|
}>;
|