mwoffliner 1.13.0 → 1.14.1
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 +9 -3
- package/lib/Downloader.d.ts +34 -30
- package/lib/Downloader.js +292 -230
- package/lib/Downloader.js.map +1 -1
- package/lib/Dump.js +5 -2
- package/lib/Dump.js.map +1 -1
- package/lib/MediaWiki.d.ts +62 -29
- package/lib/MediaWiki.js +240 -85
- package/lib/MediaWiki.js.map +1 -1
- package/lib/RedisStore.d.ts +13 -13
- package/lib/RedisStore.js +66 -53
- package/lib/RedisStore.js.map +1 -1
- package/lib/S3.d.ts +11 -4
- package/lib/S3.js +88 -54
- package/lib/S3.js.map +1 -1
- package/lib/Templates.d.ts +3 -2
- package/lib/Templates.js +6 -13
- package/lib/Templates.js.map +1 -1
- package/lib/cli.js +3 -8
- package/lib/cli.js.map +1 -1
- package/lib/config.d.ts +7 -2
- package/lib/config.js +15 -7
- package/lib/config.js.map +1 -1
- package/lib/mwoffliner.lib.js +79 -64
- package/lib/mwoffliner.lib.js.map +1 -1
- package/lib/parameterList.d.ts +3 -3
- package/lib/parameterList.js +29 -28
- package/lib/parameterList.js.map +1 -1
- package/lib/renderers/abstract.renderer.d.ts +93 -0
- package/lib/renderers/abstract.renderer.js +601 -0
- package/lib/renderers/abstract.renderer.js.map +1 -0
- package/lib/renderers/abstractDesktop.render.d.ts +11 -0
- package/lib/renderers/abstractDesktop.render.js +47 -0
- package/lib/renderers/abstractDesktop.render.js.map +1 -0
- package/lib/renderers/abstractMobile.render.d.ts +12 -0
- package/lib/renderers/abstractMobile.render.js +45 -0
- package/lib/renderers/abstractMobile.render.js.map +1 -0
- package/lib/renderers/renderer.builder.d.ts +7 -0
- package/lib/renderers/renderer.builder.js +95 -0
- package/lib/renderers/renderer.builder.js.map +1 -0
- package/lib/renderers/rest-api.renderer.d.ts +7 -0
- package/lib/renderers/rest-api.renderer.js +60 -0
- package/lib/renderers/rest-api.renderer.js.map +1 -0
- package/lib/renderers/visual-editor.renderer.d.ts +7 -0
- package/lib/renderers/visual-editor.renderer.js +73 -0
- package/lib/renderers/visual-editor.renderer.js.map +1 -0
- package/lib/renderers/wikimedia-desktop.renderer.d.ts +4 -0
- package/lib/renderers/wikimedia-desktop.renderer.js +7 -0
- package/lib/renderers/wikimedia-desktop.renderer.js.map +1 -0
- package/lib/renderers/wikimedia-mobile.renderer.d.ts +18 -0
- package/lib/renderers/wikimedia-mobile.renderer.js +229 -0
- package/lib/renderers/wikimedia-mobile.renderer.js.map +1 -0
- package/lib/sanitize-argument.d.ts +3 -0
- package/lib/sanitize-argument.js +45 -5
- package/lib/sanitize-argument.js.map +1 -1
- package/lib/util/articleListMainPage.d.ts +1 -1
- package/lib/util/articleListMainPage.js +3 -3
- package/lib/util/articleListMainPage.js.map +1 -1
- package/lib/util/builders/url/api.director.d.ts +14 -0
- package/lib/util/builders/url/api.director.js +53 -0
- package/lib/util/builders/url/api.director.js.map +1 -0
- package/lib/util/builders/url/base.director.d.ts +13 -0
- package/lib/util/builders/url/base.director.js +45 -0
- package/lib/util/builders/url/base.director.js.map +1 -0
- package/lib/util/builders/url/basic.director.d.ts +13 -0
- package/lib/util/builders/url/basic.director.js +22 -0
- package/lib/util/builders/url/basic.director.js.map +1 -0
- package/lib/util/builders/url/desktop.director.d.ts +8 -0
- package/lib/util/builders/url/desktop.director.js +14 -0
- package/lib/util/builders/url/desktop.director.js.map +1 -0
- package/lib/util/builders/url/mobile.director.d.ts +8 -0
- package/lib/util/builders/url/mobile.director.js +14 -0
- package/lib/util/builders/url/mobile.director.js.map +1 -0
- package/lib/util/builders/url/rest-api.director.d.ts +8 -0
- package/lib/util/builders/url/rest-api.director.js +17 -0
- package/lib/util/builders/url/rest-api.director.js.map +1 -0
- package/lib/util/builders/url/url.builder.d.ts +39 -0
- package/lib/util/builders/url/url.builder.js +68 -0
- package/lib/util/builders/url/url.builder.js.map +1 -0
- package/lib/util/builders/url/visual-editor.director.d.ts +9 -0
- package/lib/util/builders/url/visual-editor.director.js +17 -0
- package/lib/util/builders/url/visual-editor.director.js.map +1 -0
- package/lib/util/builders/url/web.director.d.ts +8 -0
- package/lib/util/builders/url/web.director.js +17 -0
- package/lib/util/builders/url/web.director.js.map +1 -0
- package/lib/util/categories.d.ts +3 -3
- package/lib/util/categories.js +10 -9
- package/lib/util/categories.js.map +1 -1
- package/lib/util/const.d.ts +4 -2
- package/lib/util/const.js +8 -2
- package/lib/util/const.js.map +1 -1
- package/lib/util/dump.d.ts +3 -4
- package/lib/util/dump.js +29 -19
- package/lib/util/dump.js.map +1 -1
- package/lib/util/index.d.ts +0 -1
- package/lib/util/index.js +0 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/metaData.js +16 -3
- package/lib/util/metaData.js.map +1 -1
- package/lib/util/misc.d.ts +14 -5
- package/lib/util/misc.js +43 -80
- package/lib/util/misc.js.map +1 -1
- package/lib/util/mw-api.d.ts +14 -2
- package/lib/util/mw-api.js +58 -4
- package/lib/util/mw-api.js.map +1 -1
- package/lib/util/rewriteUrls.d.ts +2 -3
- package/lib/util/rewriteUrls.js +15 -13
- package/lib/util/rewriteUrls.js.map +1 -1
- package/lib/util/saveArticles.d.ts +2 -18
- package/lib/util/saveArticles.js +115 -620
- package/lib/util/saveArticles.js.map +1 -1
- package/lib/util/url.helper.d.ts +7 -0
- package/lib/util/url.helper.js +30 -0
- package/lib/util/url.helper.js.map +1 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/package.json +10 -8
- package/res/templates/pageWikimediaDesktop.html +24 -0
- package/res/templates/pageWikimediaMobile.html +24 -0
- package/res/wm_mobile_override_script.js +15 -0
- package/res/wm_mobile_override_style.css +20 -0
- package/translation/ar.json +11 -0
- package/translation/dag.json +9 -0
- package/translation/de.json +11 -0
- package/translation/ha.json +11 -0
- package/translation/hi.json +10 -0
- package/translation/id.json +10 -0
- package/translation/ig.json +11 -0
- package/translation/kaa.json +10 -0
- package/translation/ko.json +10 -0
- package/translation/lb.json +8 -0
- package/translation/nb.json +10 -0
- package/translation/or.json +10 -0
- package/translation/pt-br.json +11 -0
- package/translation/pt.json +10 -0
- package/translation/sq.json +10 -0
- package/translation/sw.json +10 -0
- package/translation/te.json +10 -0
- package/translation/tn.json +10 -0
- package/translation/tr.json +10 -0
- package/translation/zh-hans.json +10 -0
- package/lib/util/articleRenderers.d.ts +0 -4
- package/lib/util/articleRenderers.js +0 -182
- package/lib/util/articleRenderers.js.map +0 -1
- package/lib/util/redirects.d.ts +0 -3
- package/lib/util/redirects.js +0 -16
- package/lib/util/redirects.js.map +0 -1
- package/res/templates/page.html +0 -31
package/README.md
CHANGED
|
@@ -12,14 +12,19 @@ any recent MediaWiki.
|
|
|
12
12
|
Read [CONTRIBUTING.md](./CONTRIBUTING.md) to know more about
|
|
13
13
|
MWoffliner development.
|
|
14
14
|
|
|
15
|
+
User Help is available in the for a a
|
|
16
|
+
[FAQ](https://github.com/openzim/mwoffliner/wiki/Frequently-Asked-Questions).
|
|
17
|
+
|
|
15
18
|
[](https://www.npmjs.com/package/mwoffliner)
|
|
16
19
|
|
|
17
20
|
[](https://www.npmjs.com/package/mwoffliner)
|
|
18
|
-
[](https://www.npmjs.com/package/mwoffliner)
|
|
22
|
+
[](https://ghcr.io/openzim/mwoffliner)
|
|
19
23
|
[](https://github.com/openzim/mwoffliner/actions/workflows/ci.yml?query=branch%3Amain)
|
|
20
24
|
[](https://codecov.io/gh/openzim/mwoffliner)
|
|
21
25
|
[](https://www.codefactor.io/repository/github/openzim/mwoffliner)
|
|
22
26
|
[](LICENSE)
|
|
27
|
+
[](https://slack.kiwix.org)
|
|
23
28
|
|
|
24
29
|
## Features
|
|
25
30
|
|
|
@@ -78,9 +83,10 @@ this:
|
|
|
78
83
|
## API
|
|
79
84
|
|
|
80
85
|
MWoffliner provides also an API and therefore can be used as a NodeJS
|
|
81
|
-
library. Here a stub example:
|
|
86
|
+
library. Here a stub example that could go in your index.mjs file:
|
|
82
87
|
```javascript
|
|
83
|
-
|
|
88
|
+
import * as mwoffliner from 'mwoffliner';
|
|
89
|
+
|
|
84
90
|
const parameters = {
|
|
85
91
|
mwUrl: "https://es.wikipedia.org",
|
|
86
92
|
adminEmail: "foo@bar.net",
|
package/lib/Downloader.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { BackoffStrategy } from 'backoff';
|
|
3
|
-
import { AxiosRequestConfig } from 'axios';
|
|
3
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
4
4
|
import S3 from './S3.js';
|
|
5
5
|
import { Dump } from './Dump.js';
|
|
6
|
-
import MediaWiki from './MediaWiki.js';
|
|
7
6
|
interface DownloaderOpts {
|
|
8
|
-
mw: MediaWiki;
|
|
9
7
|
uaString: string;
|
|
10
8
|
speed: number;
|
|
11
9
|
reqTimeout: number;
|
|
@@ -13,6 +11,8 @@ interface DownloaderOpts {
|
|
|
13
11
|
s3?: S3;
|
|
14
12
|
webp: boolean;
|
|
15
13
|
backoffOptions?: BackoffOptions;
|
|
14
|
+
mwWikiPath?: string;
|
|
15
|
+
insecure?: boolean;
|
|
16
16
|
}
|
|
17
17
|
interface BackoffOptions {
|
|
18
18
|
strategy: BackoffStrategy;
|
|
@@ -20,66 +20,70 @@ interface BackoffOptions {
|
|
|
20
20
|
retryIf: (error?: any) => boolean;
|
|
21
21
|
backoffHandler: (number: number, delay: number, error?: any) => void;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
coordinatesAvailable: boolean;
|
|
27
|
-
desktopRestApiAvailable: boolean;
|
|
28
|
-
mobileRestApiAvailable: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare const defaultStreamRequestOptions: AxiosRequestConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Downloader is a class providing content retrieval functionalities for both Mediawiki and S3 remote instances.
|
|
25
|
+
*/
|
|
31
26
|
declare class Downloader {
|
|
32
|
-
readonly mw: MediaWiki;
|
|
33
27
|
loginCookie: string;
|
|
34
28
|
readonly speed: number;
|
|
35
|
-
baseUrl: string;
|
|
36
|
-
baseUrlForMainPage: string;
|
|
37
29
|
cssDependenceUrls: KVS<boolean>;
|
|
38
30
|
readonly webp: boolean;
|
|
39
31
|
readonly requestTimeout: number;
|
|
32
|
+
readonly basicRequestOptions: AxiosRequestConfig;
|
|
33
|
+
readonly arrayBufferRequestOptions: AxiosRequestConfig;
|
|
34
|
+
readonly jsonRequestOptions: AxiosRequestConfig;
|
|
35
|
+
readonly streamRequestOptions: AxiosRequestConfig;
|
|
36
|
+
wikimediaMobileJsDependenciesList: string[];
|
|
37
|
+
wikimediaMobileStyleDependenciesList: string[];
|
|
40
38
|
private readonly uaString;
|
|
41
39
|
private activeRequests;
|
|
42
40
|
private maxActiveRequests;
|
|
43
|
-
private readonly urlPartCache;
|
|
44
41
|
private readonly backoffOptions;
|
|
45
42
|
private readonly optimisationCacheUrl;
|
|
46
43
|
private s3;
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
constructor({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
checkCapabilities(testArticleId?: string): Promise<void>;
|
|
44
|
+
private apiUrlDirector;
|
|
45
|
+
private articleUrlDirector;
|
|
46
|
+
private mainPageUrlDirector;
|
|
47
|
+
private readonly insecure;
|
|
48
|
+
constructor({ uaString, speed, reqTimeout, optimisationCacheUrl, s3, webp, backoffOptions, insecure }: DownloaderOpts);
|
|
49
|
+
private getUrlDirector;
|
|
50
|
+
setUrlsDirectors(mainPageRenderer: any, articlesRenderer: any): void;
|
|
51
|
+
getArticleUrl(articleId: string): string;
|
|
52
|
+
getMainPageUrl(articleId: string): string;
|
|
57
53
|
removeEtagWeakPrefix(etag: string): string;
|
|
58
|
-
query(
|
|
54
|
+
query(): KVS<any>;
|
|
59
55
|
getArticleDetailsIds(articleIds: string[], shouldGetThumbnail?: boolean): Promise<QueryMwRet>;
|
|
60
56
|
getArticleDetailsNS(ns: number, gapcontinue?: string): Promise<{
|
|
61
57
|
gapContinue: string;
|
|
62
58
|
articleDetails: QueryMwRet;
|
|
63
59
|
}>;
|
|
64
|
-
getArticle(
|
|
60
|
+
getArticle(webp: boolean, _moduleDependencies: any, articleId: string, articleDetailXId: RKVS<ArticleDetail>, articleRenderer: any, articleUrl: any, dump: Dump, articleDetail?: ArticleDetail, isMainPage?: boolean): Promise<any>;
|
|
65
61
|
getJSON<T>(_url: string): Promise<T>;
|
|
66
|
-
|
|
62
|
+
request<T = any, R extends AxiosResponse<T> = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
63
|
+
downloadContent(_url: string, kind: DonwloadKind, retry?: boolean): Promise<{
|
|
67
64
|
content: Buffer | string;
|
|
68
|
-
|
|
65
|
+
contentType: string;
|
|
66
|
+
setCookie: string | null;
|
|
69
67
|
}>;
|
|
70
68
|
canGetUrl(url: string): Promise<boolean>;
|
|
71
|
-
private getArticleUrl;
|
|
72
69
|
private static handleMWWarningsAndErrors;
|
|
73
70
|
private getArticleQueryOpts;
|
|
74
71
|
private setArticleSubCategories;
|
|
75
72
|
private claimRequest;
|
|
76
73
|
private releaseRequest;
|
|
77
74
|
private getJSONCb;
|
|
75
|
+
private getImageMimeType;
|
|
78
76
|
private getCompressedBody;
|
|
79
77
|
private getContentCb;
|
|
80
78
|
private downloadImage;
|
|
81
79
|
private errHandler;
|
|
82
80
|
private getSubCategories;
|
|
83
81
|
private backoffCall;
|
|
82
|
+
getModuleDependencies(title: string): Promise<{
|
|
83
|
+
jsConfigVars: string;
|
|
84
|
+
jsDependenciesList: string[];
|
|
85
|
+
styleDependenciesList: string[];
|
|
86
|
+
}>;
|
|
87
|
+
private streamToBuffer;
|
|
84
88
|
}
|
|
85
89
|
export default Downloader;
|