mwoffliner 1.13.0 → 1.14.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 +9 -3
- package/lib/Downloader.d.ts +27 -26
- package/lib/Downloader.js +182 -143
- package/lib/Downloader.js.map +1 -1
- package/lib/Dump.js +4 -1
- package/lib/Dump.js.map +1 -1
- package/lib/MediaWiki.d.ts +61 -28
- package/lib/MediaWiki.js +235 -81
- 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 +8 -2
- package/lib/S3.js +73 -42
- 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 +13 -6
- package/lib/config.js.map +1 -1
- package/lib/mwoffliner.lib.js +65 -52
- 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 +82 -0
- package/lib/renderers/abstract.renderer.js +588 -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 +6 -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 +58 -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 +71 -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 +223 -0
- package/lib/renderers/wikimedia-mobile.renderer.js.map +1 -0
- package/lib/sanitize-argument.d.ts +3 -0
- package/lib/sanitize-argument.js +44 -4
- package/lib/sanitize-argument.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 -1
- package/lib/util/const.js +8 -1
- package/lib/util/const.js.map +1 -1
- package/lib/util/dump.d.ts +2 -3
- package/lib/util/dump.js +24 -7
- 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 +11 -1
- package/lib/util/misc.js +36 -27
- package/lib/util/misc.js.map +1 -1
- package/lib/util/mw-api.d.ts +13 -2
- package/lib/util/mw-api.js +56 -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 +72 -613
- 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/package.json +9 -7
- 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
|
@@ -3,9 +3,7 @@ import type { BackoffStrategy } from 'backoff';
|
|
|
3
3
|
import { AxiosRequestConfig } 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,55 +20,50 @@ interface BackoffOptions {
|
|
|
20
20
|
retryIf: (error?: any) => boolean;
|
|
21
21
|
backoffHandler: (number: number, delay: number, error?: any) => void;
|
|
22
22
|
}
|
|
23
|
-
export interface MWCapabilities {
|
|
24
|
-
apiAvailable: boolean;
|
|
25
|
-
veApiAvailable: boolean;
|
|
26
|
-
coordinatesAvailable: boolean;
|
|
27
|
-
desktopRestApiAvailable: boolean;
|
|
28
|
-
mobileRestApiAvailable: boolean;
|
|
29
|
-
}
|
|
30
23
|
export declare const defaultStreamRequestOptions: AxiosRequestConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Downloader is a class providing content retrieval functionalities for both Mediawiki and S3 remote instances.
|
|
26
|
+
*/
|
|
31
27
|
declare class Downloader {
|
|
32
|
-
readonly mw: MediaWiki;
|
|
33
28
|
loginCookie: string;
|
|
34
29
|
readonly speed: number;
|
|
35
|
-
baseUrl: string;
|
|
36
|
-
baseUrlForMainPage: string;
|
|
37
30
|
cssDependenceUrls: KVS<boolean>;
|
|
38
31
|
readonly webp: boolean;
|
|
39
32
|
readonly requestTimeout: number;
|
|
33
|
+
arrayBufferRequestOptions: AxiosRequestConfig;
|
|
34
|
+
jsonRequestOptions: AxiosRequestConfig;
|
|
35
|
+
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
|
downloadContent(_url: string, retry?: boolean): Promise<{
|
|
67
63
|
content: Buffer | string;
|
|
68
64
|
responseHeaders: any;
|
|
69
65
|
}>;
|
|
70
66
|
canGetUrl(url: string): Promise<boolean>;
|
|
71
|
-
private getArticleUrl;
|
|
72
67
|
private static handleMWWarningsAndErrors;
|
|
73
68
|
private getArticleQueryOpts;
|
|
74
69
|
private setArticleSubCategories;
|
|
@@ -81,5 +76,11 @@ declare class Downloader {
|
|
|
81
76
|
private errHandler;
|
|
82
77
|
private getSubCategories;
|
|
83
78
|
private backoffCall;
|
|
79
|
+
getModuleDependencies(title: string): Promise<{
|
|
80
|
+
jsConfigVars: string;
|
|
81
|
+
jsDependenciesList: string[];
|
|
82
|
+
styleDependenciesList: string[];
|
|
83
|
+
}>;
|
|
84
|
+
private streamToBuffer;
|
|
84
85
|
}
|
|
85
86
|
export default Downloader;
|