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.
Files changed (90) hide show
  1. package/README.md +5 -16
  2. package/jest.config.cjs +18 -0
  3. package/lib/DOMUtils.js +1 -3
  4. package/lib/DOMUtils.js.map +1 -1
  5. package/lib/Downloader.d.ts +8 -13
  6. package/lib/Downloader.js +420 -523
  7. package/lib/Downloader.js.map +1 -1
  8. package/lib/Dump.d.ts +3 -2
  9. package/lib/Dump.js +68 -87
  10. package/lib/Dump.js.map +1 -1
  11. package/lib/Logger.js +6 -5
  12. package/lib/Logger.js.map +1 -1
  13. package/lib/MediaWiki.d.ts +3 -3
  14. package/lib/MediaWiki.js +188 -241
  15. package/lib/MediaWiki.js.map +1 -1
  16. package/lib/RedisStore.d.ts +302 -0
  17. package/lib/RedisStore.js +119 -0
  18. package/lib/RedisStore.js.map +1 -0
  19. package/lib/S3.d.ts +1 -1
  20. package/lib/S3.js +67 -87
  21. package/lib/S3.js.map +1 -1
  22. package/lib/Templates.js +27 -36
  23. package/lib/Templates.js.map +1 -1
  24. package/lib/cli.d.ts +1 -1
  25. package/lib/cli.js +15 -38
  26. package/lib/cli.js.map +1 -1
  27. package/lib/config.d.ts +3 -6
  28. package/lib/config.js +37 -20
  29. package/lib/config.js.map +1 -1
  30. package/lib/mwoffliner.lib.d.ts +2 -2
  31. package/lib/mwoffliner.lib.js +487 -508
  32. package/lib/mwoffliner.lib.js.map +1 -1
  33. package/lib/parameterList.d.ts +2 -3
  34. package/lib/parameterList.js +9 -13
  35. package/lib/parameterList.js.map +1 -1
  36. package/lib/sanitize-argument.d.ts +2 -1
  37. package/lib/sanitize-argument.js +97 -146
  38. package/lib/sanitize-argument.js.map +1 -1
  39. package/lib/util/RedisKvs.d.ts +19 -24
  40. package/lib/util/RedisKvs.js +130 -197
  41. package/lib/util/RedisKvs.js.map +1 -1
  42. package/lib/util/Timer.d.ts +10 -0
  43. package/lib/util/Timer.js +29 -0
  44. package/lib/util/Timer.js.map +1 -0
  45. package/lib/util/articleListMainPage.d.ts +1 -1
  46. package/lib/util/articleListMainPage.js +6 -12
  47. package/lib/util/articleListMainPage.js.map +1 -1
  48. package/lib/util/articleRenderers.d.ts +3 -3
  49. package/lib/util/articleRenderers.js +30 -49
  50. package/lib/util/articleRenderers.js.map +1 -1
  51. package/lib/util/categories.d.ts +4 -6
  52. package/lib/util/categories.js +169 -192
  53. package/lib/util/categories.js.map +1 -1
  54. package/lib/util/const.d.ts +2 -1
  55. package/lib/util/const.js +20 -22
  56. package/lib/util/const.js.map +1 -1
  57. package/lib/util/dump.d.ts +4 -4
  58. package/lib/util/dump.js +136 -170
  59. package/lib/util/dump.js.map +1 -1
  60. package/lib/util/index.d.ts +6 -6
  61. package/lib/util/index.js +6 -18
  62. package/lib/util/index.js.map +1 -1
  63. package/lib/util/misc.d.ts +11 -9
  64. package/lib/util/misc.js +138 -150
  65. package/lib/util/misc.js.map +1 -1
  66. package/lib/util/mw-api.d.ts +3 -3
  67. package/lib/util/mw-api.js +170 -91
  68. package/lib/util/mw-api.js.map +1 -1
  69. package/lib/util/redirects.d.ts +3 -3
  70. package/lib/util/redirects.js +14 -32
  71. package/lib/util/redirects.js.map +1 -1
  72. package/lib/util/rewriteUrls.d.ts +7 -4
  73. package/lib/util/rewriteUrls.js +215 -203
  74. package/lib/util/rewriteUrls.js.map +1 -1
  75. package/lib/util/saveArticles.d.ts +6 -15
  76. package/lib/util/saveArticles.js +620 -613
  77. package/lib/util/saveArticles.js.map +1 -1
  78. package/package.json +68 -68
  79. package/res/content.parsoid.css +24 -3
  80. package/res/script.js +4 -0
  81. package/res/templates/article_list_home.html +0 -3
  82. package/res/templates/page.html +0 -4
  83. package/translation/ru.json +6 -0
  84. package/jest.config.js +0 -18
  85. package/lib/Redis.d.ts +0 -5
  86. package/lib/Redis.js +0 -18
  87. package/lib/Redis.js.map +0 -1
  88. package/lib/stores.d.ts +0 -23
  89. package/lib/stores.js +0 -45
  90. package/lib/stores.js.map +0 -1
package/README.md CHANGED
@@ -16,8 +16,8 @@ MWoffliner development.
16
16
 
17
17
  [![npm](https://img.shields.io/npm/v/mwoffliner.svg)](https://www.npmjs.com/package/mwoffliner)
18
18
  [![Docker Image](https://img.shields.io/docker/v/openzim/mwoffliner?arch=amd64&label=docker&sort=semver)](https://hub.docker.com/r/openzim/mwoffliner)
19
- [![Build Status](https://github.com/openzim/mwoffliner/workflows/CI/badge.svg?query=branch%3Amaster)](https://github.com/openzim/mwoffliner/actions/workflows/ci.yml?query=branch%3Amaster)
20
- [![codecov](https://codecov.io/gh/openzim/mwoffliner/branch/master/graph/badge.svg)](https://codecov.io/gh/openzim/mwoffliner)
19
+ [![Build Status](https://github.com/openzim/mwoffliner/workflows/CI/badge.svg?query=branch%3Amain)](https://github.com/openzim/mwoffliner/actions/workflows/ci.yml?query=branch%3Amain)
20
+ [![codecov](https://codecov.io/gh/openzim/mwoffliner/branch/main/graph/badge.svg)](https://codecov.io/gh/openzim/mwoffliner)
21
21
  [![CodeFactor](https://www.codefactor.io/repository/github/openzim/mwoffliner/badge)](https://www.codefactor.io/repository/github/openzim/mwoffliner)
22
22
  [![License](https://img.shields.io/npm/l/mwoffliner.svg)](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 12 or greater
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
- ```bash
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
@@ -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
- exports.default = DOMUtils;
24
+ export default DOMUtils;
27
25
  //# sourceMappingURL=DOMUtils.js.map
@@ -1 +1 @@
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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,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"}
@@ -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, noLocalParserFallback, forceLocalParser: forceLocalParser, optimisationCacheUrl, s3, webp, backoffOptions }: DownloaderOpts);
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
  }>;