honkit 3.7.0 → 3.7.3

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 (177) hide show
  1. package/lib/__tests__/init.js +1 -1
  2. package/lib/__tests__/snapshot-honkit.js +1 -1
  3. package/lib/api/decodeGlobal.js +1 -1
  4. package/lib/api/encodeConfig.js +0 -4
  5. package/lib/api/encodeGlobal.js +9 -9
  6. package/lib/api/encodeNavigation.js +0 -4
  7. package/lib/api/encodePage.js +1 -5
  8. package/lib/api/encodeProgress.js +1 -6
  9. package/lib/api/encodeSummary.js +3 -5
  10. package/lib/bin.js +1 -1
  11. package/lib/cli/build.js +3 -3
  12. package/lib/cli/buildEbook.js +2 -2
  13. package/lib/cli/getBook.js +1 -1
  14. package/lib/cli/index.js +1 -1
  15. package/lib/cli/init.js +1 -1
  16. package/lib/cli/parse.js +1 -1
  17. package/lib/cli/serve.js +7 -7
  18. package/lib/cli/server.js +3 -3
  19. package/lib/constants/__tests__/configSchema.js +7 -7
  20. package/lib/constants/configDefault.js +1 -1
  21. package/lib/constants/defaultFilters.js +2 -2
  22. package/lib/constants/defaultPlugins.js +1 -2
  23. package/lib/fs/__tests__/mock.js +1 -1
  24. package/lib/index.js +1 -1
  25. package/lib/init.js +1 -1
  26. package/lib/json/encodeBook.js +5 -5
  27. package/lib/json/encodeBookWithPage.js +3 -3
  28. package/lib/json/encodeGlossary.js +1 -1
  29. package/lib/json/encodeLanguages.js +1 -1
  30. package/lib/json/encodeOutput.js +1 -1
  31. package/lib/json/encodeOutputWithPage.js +3 -3
  32. package/lib/json/encodePage.js +9 -8
  33. package/lib/json/encodeReadme.js +1 -1
  34. package/lib/json/encodeSummary.js +1 -1
  35. package/lib/json/encodeSummaryArticle.js +8 -1
  36. package/lib/json/encodeSummaryArticleWithCache.js +36 -0
  37. package/lib/models/__tests__/plugin.js +24 -0
  38. package/lib/models/__tests__/summaryArticle.js +55 -0
  39. package/lib/models/__tests__/templateBlock.js +2 -2
  40. package/lib/models/book.js +1 -1
  41. package/lib/models/config.js +1 -1
  42. package/lib/models/fs.js +5 -5
  43. package/lib/models/glossaryEntry.js +1 -1
  44. package/lib/models/ignore.js +2 -2
  45. package/lib/models/output.js +1 -1
  46. package/lib/models/page.js +1 -1
  47. package/lib/models/parser.js +11 -11
  48. package/lib/models/plugin.js +7 -4
  49. package/lib/models/pluginDependency.js +1 -18
  50. package/lib/models/templateBlock.js +3 -3
  51. package/lib/modifiers/config/__tests__/addPlugin.js +1 -1
  52. package/lib/modifiers/config/__tests__/removePlugin.js +3 -3
  53. package/lib/modifiers/config/__tests__/togglePlugin.js +2 -2
  54. package/lib/modifiers/config/addPlugin.js +2 -3
  55. package/lib/modifiers/config/isDefaultPlugin.js +1 -1
  56. package/lib/modifiers/config/removePlugin.js +2 -2
  57. package/lib/modifiers/config/togglePlugin.js +1 -1
  58. package/lib/modifiers/summary/__tests__/editPartTitle.js +3 -3
  59. package/lib/modifiers/summary/__tests__/insertArticle.js +2 -2
  60. package/lib/modifiers/summary/__tests__/insertPart.js +2 -2
  61. package/lib/modifiers/summary/__tests__/mergeAtLevel.js +2 -2
  62. package/lib/modifiers/summary/__tests__/moveArticle.js +3 -3
  63. package/lib/modifiers/summary/__tests__/moveArticleAfter.js +5 -5
  64. package/lib/modifiers/summary/__tests__/removeArticle.js +1 -1
  65. package/lib/modifiers/summary/editArticleRef.js +1 -1
  66. package/lib/modifiers/summary/editArticleTitle.js +1 -1
  67. package/lib/modifiers/summary/indexPartLevels.js +1 -1
  68. package/lib/modifiers/summary/insertArticle.js +2 -2
  69. package/lib/modifiers/summary/insertPart.js +1 -1
  70. package/lib/modifiers/summary/moveArticle.js +2 -2
  71. package/lib/modifiers/summary/moveArticleAfter.js +4 -4
  72. package/lib/modifiers/summary/removeArticle.js +2 -2
  73. package/lib/modifiers/summary/removePart.js +1 -1
  74. package/lib/modifiers/summary/unshiftArticle.js +1 -1
  75. package/lib/output/Generator.js +2 -0
  76. package/lib/output/__tests__/ebook.js +1 -1
  77. package/lib/output/__tests__/json.js +3 -3
  78. package/lib/output/__tests__/plugin-hooks.js +3 -3
  79. package/lib/output/__tests__/website.js +8 -8
  80. package/lib/output/callHook.js +1 -1
  81. package/lib/output/callPageHook.js +1 -1
  82. package/lib/output/createTemplateEngine.js +1 -0
  83. package/lib/output/ebook/getConvertOptions.js +8 -8
  84. package/lib/output/ebook/getPDFTemplate.js +3 -1
  85. package/lib/output/ebook/index.js +1 -1
  86. package/lib/output/ebook/onFinish.js +3 -3
  87. package/lib/output/generateAssets.js +1 -1
  88. package/lib/output/generateBook.js +54 -46
  89. package/lib/output/generatePage.js +5 -5
  90. package/lib/output/generatePages.js +3 -3
  91. package/lib/output/getModifiers.js +2 -2
  92. package/lib/output/helper/fileToURL.js +1 -1
  93. package/lib/output/helper/resolveFileToURL.js +1 -1
  94. package/lib/output/index.js +0 -2
  95. package/lib/output/json/onFinish.js +1 -1
  96. package/lib/output/json/onPage.js +2 -2
  97. package/lib/output/modifiers/__tests__/addHeadingId.js +2 -2
  98. package/lib/output/modifiers/__tests__/annotateText.js +3 -3
  99. package/lib/output/modifiers/__tests__/fetchRemoteImages.js +2 -2
  100. package/lib/output/modifiers/__tests__/highlightCode.js +5 -5
  101. package/lib/output/modifiers/__tests__/inlinePng.js +1 -1
  102. package/lib/output/modifiers/__tests__/inlineSvg.js +2 -2
  103. package/lib/output/modifiers/__tests__/resolveImages.js +3 -3
  104. package/lib/output/modifiers/__tests__/resolveLinks.js +7 -7
  105. package/lib/output/modifiers/__tests__/svgToImg.js +2 -2
  106. package/lib/output/modifiers/addHeadingId.js +2 -2
  107. package/lib/output/modifiers/annotateText.js +1 -1
  108. package/lib/output/modifiers/fetchRemoteImages.js +1 -1
  109. package/lib/output/modifiers/highlightCode.js +2 -2
  110. package/lib/output/modifiers/inlineAssets.js +1 -1
  111. package/lib/output/modifiers/inlinePng.js +1 -1
  112. package/lib/output/modifiers/inlineSvg.js +1 -1
  113. package/lib/output/modifiers/resolveImages.js +1 -1
  114. package/lib/output/modifiers/resolveLinks.js +1 -1
  115. package/lib/output/modifiers/svgToImg.js +2 -2
  116. package/lib/output/preparePages.js +1 -1
  117. package/lib/output/preparePlugins.js +1 -1
  118. package/lib/output/testing/createMock.js +2 -2
  119. package/lib/output/testing/generateMock.js +3 -3
  120. package/lib/output/website/__tests__/i18n.js +6 -6
  121. package/lib/output/website/copyPluginAssets.js +4 -6
  122. package/lib/output/website/createTemplateEngine.js +7 -8
  123. package/lib/output/website/onFinish.js +3 -3
  124. package/lib/output/website/onInit.js +1 -1
  125. package/lib/output/website/onPage.js +5 -5
  126. package/lib/output/website/prepareI18n.js +2 -2
  127. package/lib/output/website/prepareResources.js +2 -2
  128. package/lib/output/website/state.js +1 -1
  129. package/lib/parse/__tests__/listAssets.js +6 -6
  130. package/lib/parse/__tests__/parseBook.js +6 -6
  131. package/lib/parse/__tests__/parseGlossary.js +4 -4
  132. package/lib/parse/__tests__/parseIgnore.js +2 -2
  133. package/lib/parse/__tests__/parsePageFromString.js +3 -3
  134. package/lib/parse/__tests__/parseReadme.js +5 -5
  135. package/lib/parse/__tests__/parseSummary.js +4 -4
  136. package/lib/parse/lookupStructureFile.js +1 -1
  137. package/lib/parse/parseBook.js +3 -3
  138. package/lib/parse/parseConfig.js +2 -2
  139. package/lib/parse/parseGlossary.js +1 -1
  140. package/lib/parse/parseIgnore.js +1 -1
  141. package/lib/parse/parseLanguages.js +1 -1
  142. package/lib/parse/parsePage.js +1 -1
  143. package/lib/parse/parsePageFromString.js +2 -2
  144. package/lib/parse/parsePagesList.js +2 -2
  145. package/lib/parse/parseReadme.js +1 -1
  146. package/lib/parse/parseStructureFile.js +1 -1
  147. package/lib/parse/parseSummary.js +1 -1
  148. package/lib/parse/validateConfig.js +2 -2
  149. package/lib/parse/walkSummary.js +1 -1
  150. package/lib/plugins/PluginResolver.js +5 -5
  151. package/lib/plugins/__tests__/listDependencies.js +6 -6
  152. package/lib/plugins/__tests__/sortDependencies.js +4 -4
  153. package/lib/plugins/__tests__/validatePlugin.js +3 -3
  154. package/lib/plugins/listDependencies.js +1 -1
  155. package/lib/plugins/listDepsForBook.js +1 -1
  156. package/lib/plugins/listResources.js +0 -3
  157. package/lib/plugins/loadForBook.js +2 -2
  158. package/lib/plugins/loadPlugin.js +2 -2
  159. package/lib/plugins/validateConfig.js +2 -2
  160. package/lib/plugins/validatePlugin.js +1 -1
  161. package/lib/templating/__tests__/conrefsLoader.js +11 -8
  162. package/lib/templating/__tests__/postRender.js +4 -4
  163. package/lib/templating/__tests__/replaceShortcuts.js +2 -2
  164. package/lib/templating/conrefsLoader.js +1 -1
  165. package/lib/templating/render.js +1 -1
  166. package/lib/templating/renderFile.js +2 -2
  167. package/lib/templating/replaceShortcuts.js +2 -2
  168. package/lib/templating/themesLoader.js +1 -1
  169. package/lib/utils/command.js +1 -33
  170. package/lib/utils/error.js +10 -10
  171. package/lib/utils/fs.js +6 -6
  172. package/lib/utils/git.js +4 -4
  173. package/lib/utils/promise.js +6 -6
  174. package/package.json +9 -8
  175. package/CHANGELOG.md +0 -448
  176. package/lib/plugins/__tests__/findInstalled.js +0 -25
  177. package/lib/plugins/findInstalled.js +0 -87
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ Encode a SummaryArticle to JSON
4
+
5
+ @param {SummaryArticle}
6
+ @return {Object}
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const lru_map_1 = require("lru_map");
10
+ const LRU_MAP_LIMIT = 1000;
11
+ const articleCacheMap = new lru_map_1.LRUMap(LRU_MAP_LIMIT);
12
+ function encodeSummaryArticleWithCache(article, recursive) {
13
+ if (articleCacheMap.has(article)) {
14
+ return articleCacheMap.get(article);
15
+ }
16
+ let articles = undefined;
17
+ if (recursive !== false) {
18
+ articles = article
19
+ .getArticles()
20
+ .map((article) => encodeSummaryArticleWithCache(article))
21
+ .toJS();
22
+ }
23
+ const encodedArticle = {
24
+ title: article.getTitle(),
25
+ level: article.getLevel(),
26
+ depth: article.getDepth(),
27
+ anchor: article.getAnchor(),
28
+ url: article.getUrl(),
29
+ path: article.getPath(),
30
+ ref: article.getRef(),
31
+ articles: articles,
32
+ };
33
+ articleCacheMap.set(article, encodedArticle);
34
+ return encodedArticle;
35
+ }
36
+ exports.default = encodeSummaryArticleWithCache;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const plugin_1 = __importDefault(require("../plugin"));
7
+ const immutable_1 = __importDefault(require("immutable"));
7
8
  describe("Plugin", () => {
8
9
  describe("createFromString", () => {
9
10
  test("must parse name", () => {
@@ -17,6 +18,29 @@ describe("Plugin", () => {
17
18
  expect(plugin.getVersion()).toBe("1.0.0");
18
19
  });
19
20
  });
21
+ describe("getNpmId", () => {
22
+ it("should return package's name", () => {
23
+ const plugin = new plugin_1.default({
24
+ name: "testplugin",
25
+ version: "*",
26
+ path: "test.js",
27
+ package: immutable_1.default.fromJS({
28
+ name: "testplugin-name"
29
+ }),
30
+ content: immutable_1.default.fromJS({
31
+ hooks: {
32
+ "page:before": function (page) {
33
+ return page;
34
+ },
35
+ page: function (page) {
36
+ return page;
37
+ }
38
+ }
39
+ })
40
+ });
41
+ expect(plugin.getNpmID()).toBe("testplugin-name");
42
+ });
43
+ });
20
44
  describe("isLoaded", () => {
21
45
  test("must return false for empty plugin", () => {
22
46
  const plugin = plugin_1.default.createFromString("hello");
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const summaryArticle_1 = __importDefault(require("../summaryArticle"));
7
7
  const file_1 = __importDefault(require("../file"));
8
+ const encodeSummaryArticleWithCache_1 = __importDefault(require("../../json/encodeSummaryArticleWithCache"));
9
+ const encodeSummaryArticle_1 = __importDefault(require("../../json/encodeSummaryArticle"));
8
10
  describe("SummaryArticle", () => {
9
11
  describe("createChildLevel", () => {
10
12
  test("must create the right level", () => {
@@ -59,4 +61,57 @@ describe("SummaryArticle", () => {
59
61
  expect(article.hasAnchor()).toBe(true);
60
62
  });
61
63
  });
64
+ describe("withCache", function () {
65
+ it("encodeSummaryArticle (non cached) should return an object", function () {
66
+ var article = summaryArticle_1.default.create({
67
+ ref: "1-1.md",
68
+ }, "1.1");
69
+ expect((0, encodeSummaryArticle_1.default)(article)).toBeInstanceOf(Object);
70
+ });
71
+ it("encodeSummaryArticleWithCache (cached) should return an object", function () {
72
+ var article = summaryArticle_1.default.create({
73
+ ref: "1-1.md",
74
+ }, "1.1");
75
+ expect((0, encodeSummaryArticleWithCache_1.default)(article)).toBeInstanceOf(Object);
76
+ });
77
+ it("encodeSummaryArticle (non cached) should return different object when pass difference SummaryArticle", function () {
78
+ var article_1 = summaryArticle_1.default.create({
79
+ ref: "1-1.md"
80
+ }, "1.1");
81
+ var article_2 = summaryArticle_1.default.create({
82
+ ref: "1-2.md"
83
+ }, "1.2");
84
+ expect((0, encodeSummaryArticle_1.default)(article_1)).not.toStrictEqual((0, encodeSummaryArticle_1.default)(article_2));
85
+ });
86
+ it("encodeSummaryArticle (non cached) should return same object when pass same SummaryArticle", function () {
87
+ var article = summaryArticle_1.default.create({
88
+ ref: "1-1.md"
89
+ }, "1.1");
90
+ expect((0, encodeSummaryArticle_1.default)(article)).toStrictEqual((0, encodeSummaryArticle_1.default)(article));
91
+ });
92
+ it("encodeSummaryArticleWithCache (cached) should return different object when pass difference SummaryArticle", function () {
93
+ var article_1 = summaryArticle_1.default.create({
94
+ ref: "1-1.md"
95
+ }, "1.1");
96
+ var article_2 = summaryArticle_1.default.create({
97
+ ref: "1-2.md"
98
+ }, "1.2");
99
+ expect((0, encodeSummaryArticle_1.default)(article_1)).not.toStrictEqual((0, encodeSummaryArticleWithCache_1.default)(article_2));
100
+ });
101
+ it("encodeSummaryArticleWithCache (cached) should return same object when pass same SummaryArticle", function () {
102
+ var article = summaryArticle_1.default.create({
103
+ ref: "1-1.md"
104
+ }, "1.1");
105
+ expect((0, encodeSummaryArticle_1.default)(article)).toStrictEqual((0, encodeSummaryArticle_1.default)(article));
106
+ });
107
+ it("encodeSummaryArticle (non cached) and encodeSummaryArticleWithCache (cached) should return same object when pass same SummaryArticle", function () {
108
+ var article = summaryArticle_1.default.create({
109
+ ref: "1-1.md",
110
+ articles: [summaryArticle_1.default.create({
111
+ ref: "2-1.md",
112
+ }, "2.1")]
113
+ }, "1.1");
114
+ expect((0, encodeSummaryArticle_1.default)(article)).toStrictEqual((0, encodeSummaryArticleWithCache_1.default)(article));
115
+ });
116
+ });
62
117
  });
@@ -22,7 +22,7 @@ describe("TemplateBlock", () => {
22
22
  expect(templateBlock.getBlocks().size).toBe(0);
23
23
  expect(templateBlock.getExtensionName()).toBe("BlocksayhelloExtension");
24
24
  // Check result of applying block
25
- return promise_1.default()
25
+ return (0, promise_1.default)()
26
26
  .then(() => {
27
27
  return templateBlock.applyBlock();
28
28
  })
@@ -122,7 +122,7 @@ describe("TemplateBlock", () => {
122
122
  });
123
123
  test("must accept an async function", () => {
124
124
  const templateBlock = templateBlock_1.default.create("sayhello", (block) => {
125
- return promise_1.default().then(() => {
125
+ return (0, promise_1.default)().then(() => {
126
126
  return {
127
127
  body: `Hello ${block.body}`,
128
128
  parse: true,
@@ -16,7 +16,7 @@ const ignore_1 = __importDefault(require("./ignore"));
16
16
  class Book extends immutable_1.default.Record({
17
17
  // Logger for outptu message
18
18
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 0.
19
- logger: logger_1.default(),
19
+ logger: (0, logger_1.default)(),
20
20
  // Filesystem binded to the book scope to read files/directories
21
21
  fs: new fs_1.default(),
22
22
  // Ignore files parser
@@ -24,7 +24,7 @@ class Config extends immutable_1.default.Record({
24
24
  * @return {Map}
25
25
  */
26
26
  toReducedVersion() {
27
- return reducedObject_1.default(configDefault_1.default, this.getValues());
27
+ return (0, reducedObject_1.default)(configDefault_1.default, this.getValues());
28
28
  }
29
29
  /**
30
30
  * Render config as text
package/lib/models/fs.js CHANGED
@@ -62,7 +62,7 @@ class FS extends immutable_1.default.Record({
62
62
  */
63
63
  exists(filename) {
64
64
  const that = this;
65
- return promise_1.default().then(() => {
65
+ return (0, promise_1.default)().then(() => {
66
66
  filename = that.resolve(filename);
67
67
  const exists = that.get("fsExists");
68
68
  return exists(filename);
@@ -76,7 +76,7 @@ class FS extends immutable_1.default.Record({
76
76
  */
77
77
  read(filename) {
78
78
  const that = this;
79
- return promise_1.default().then(() => {
79
+ return (0, promise_1.default)().then(() => {
80
80
  filename = that.resolve(filename);
81
81
  const read = that.get("fsReadFile");
82
82
  return read(filename);
@@ -102,7 +102,7 @@ class FS extends immutable_1.default.Record({
102
102
  const filepath = that.resolve(filename);
103
103
  const fsReadAsStream = this.get("fsReadAsStream");
104
104
  if (fsReadAsStream) {
105
- return promise_1.default(fsReadAsStream(filepath));
105
+ return (0, promise_1.default)(fsReadAsStream(filepath));
106
106
  }
107
107
  return this.read(filename).then((buf) => {
108
108
  const bufferStream = new stream_1.default.PassThrough();
@@ -118,7 +118,7 @@ class FS extends immutable_1.default.Record({
118
118
  */
119
119
  statFile(filename) {
120
120
  const that = this;
121
- return promise_1.default()
121
+ return (0, promise_1.default)()
122
122
  .then(() => {
123
123
  const filepath = that.resolve(filename);
124
124
  const stat = that.get("fsStatFile");
@@ -137,7 +137,7 @@ class FS extends immutable_1.default.Record({
137
137
  */
138
138
  readDir(dirname) {
139
139
  const that = this;
140
- return promise_1.default()
140
+ return (0, promise_1.default)()
141
141
  .then(() => {
142
142
  const dirpath = that.resolve(dirname);
143
143
  const readDir = that.get("fsReadDir");
@@ -28,7 +28,7 @@ class GlossaryEntry extends immutable_1.default.Record({
28
28
  Normalize a glossary entry name into a unique id
29
29
  */
30
30
  static nameToID(name) {
31
- return github_slugid_1.default(name);
31
+ return (0, github_slugid_1.default)(name);
32
32
  }
33
33
  }
34
34
  exports.default = GlossaryEntry;
@@ -9,7 +9,7 @@ const ignore_1 = __importDefault(require("ignore"));
9
9
  Immutable version of node-ignore
10
10
  */
11
11
  class Ignore extends immutable_1.default.Record({
12
- ignore: ignore_1.default(),
12
+ ignore: (0, ignore_1.default)(),
13
13
  }, "Ignore") {
14
14
  getIgnore() {
15
15
  return this.get("ignore");
@@ -31,7 +31,7 @@ class Ignore extends immutable_1.default.Record({
31
31
  */
32
32
  add(rule) {
33
33
  const ignore = this.getIgnore();
34
- const newIgnore = ignore_1.default();
34
+ const newIgnore = (0, ignore_1.default)();
35
35
  newIgnore.add(ignore);
36
36
  newIgnore.add(rule);
37
37
  return this.set("ignore", newIgnore);
@@ -66,7 +66,7 @@ class Output extends immutable_1.default.Record({
66
66
  if (!page) {
67
67
  return this;
68
68
  }
69
- const newPage = parsePageFromString_1.default(page, fs_1.default.readFileSync(filePath, "utf-8"));
69
+ const newPage = (0, parsePageFromString_1.default)(page, fs_1.default.readFileSync(filePath, "utf-8"));
70
70
  return this.merge({
71
71
  pages: pages.set(relativePath, newPage),
72
72
  });
@@ -85,7 +85,7 @@ class Page extends immutable_1.default.Record({
85
85
  return page.toJS();
86
86
  }
87
87
  hash() {
88
- return hash_1.hashString(JSON.stringify(this.toJS()));
88
+ return (0, hash_1.hashString)(JSON.stringify(this.toJS()));
89
89
  }
90
90
  }
91
91
  exports.default = Page;
@@ -26,47 +26,47 @@ class Parser extends immutable_1.default.Record({
26
26
  // PARSE
27
27
  parseReadme(content) {
28
28
  const readme = this.get("readme");
29
- return promise_1.default(readme(content));
29
+ return (0, promise_1.default)(readme(content));
30
30
  }
31
31
  parseSummary(content) {
32
32
  const summary = this.get("summary");
33
- return promise_1.default(summary(content));
33
+ return (0, promise_1.default)(summary(content));
34
34
  }
35
35
  parseGlossary(content) {
36
36
  const glossary = this.get("glossary");
37
- return promise_1.default(glossary(content));
37
+ return (0, promise_1.default)(glossary(content));
38
38
  }
39
39
  preparePage(content) {
40
40
  const page = this.get("page");
41
41
  if (!page.prepare) {
42
- return promise_1.default(content);
42
+ return (0, promise_1.default)(content);
43
43
  }
44
- return promise_1.default(page.prepare(content));
44
+ return (0, promise_1.default)(page.prepare(content));
45
45
  }
46
46
  parsePage(content) {
47
47
  const page = this.get("page");
48
- return promise_1.default(page(content));
48
+ return (0, promise_1.default)(page(content));
49
49
  }
50
50
  parseInline(content) {
51
51
  const inline = this.get("inline");
52
- return promise_1.default(inline(content));
52
+ return (0, promise_1.default)(inline(content));
53
53
  }
54
54
  parseLanguages(content) {
55
55
  const langs = this.get("langs");
56
- return promise_1.default(langs(content));
56
+ return (0, promise_1.default)(langs(content));
57
57
  }
58
58
  // TO TEXT
59
59
  renderLanguages(content) {
60
60
  const langs = this.get("langs");
61
- return promise_1.default(langs.toText(content));
61
+ return (0, promise_1.default)(langs.toText(content));
62
62
  }
63
63
  renderSummary(content) {
64
64
  const summary = this.get("summary");
65
- return promise_1.default(summary.toText(content));
65
+ return (0, promise_1.default)(summary.toText(content));
66
66
  }
67
67
  renderGlossary(content) {
68
68
  const glossary = this.get("glossary");
69
- return promise_1.default(glossary.toText(content));
69
+ return (0, promise_1.default)(glossary.toText(content));
70
70
  }
71
71
  /**
72
72
  Test if this parser matches an extension
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const immutable_1 = __importDefault(require("immutable"));
7
7
  const templateBlock_1 = __importDefault(require("./templateBlock"));
8
- const pluginDependency_1 = __importDefault(require("./pluginDependency"));
9
8
  const themePrefix_1 = __importDefault(require("../constants/themePrefix"));
10
9
  const DEFAULT_VERSION = "*";
11
10
  class Plugin extends immutable_1.default.Record({
@@ -46,10 +45,15 @@ class Plugin extends immutable_1.default.Record({
46
45
  }
47
46
  /**
48
47
  * Return the ID on NPM for this plugin
48
+ * return package.json's name
49
49
  * @return {string}
50
50
  */
51
51
  getNpmID() {
52
- return pluginDependency_1.default.nameToNpmID(this.getName());
52
+ const pkg = this.getPackage().toJS();
53
+ if ("name" in pkg) {
54
+ return pkg["name"];
55
+ }
56
+ throw new Error(`${this.getName()} plugin's package.json does not have "name" fields.`);
53
57
  }
54
58
  /**
55
59
  * Check if a plugin is loaded
@@ -112,8 +116,8 @@ class Plugin extends immutable_1.default.Record({
112
116
  }
113
117
  /**
114
118
  * Create a plugin from a string
115
- * @param {string}
116
119
  * @return {Plugin}
120
+ * @param s
117
121
  */
118
122
  static createFromString(s) {
119
123
  const parts = s.split("@");
@@ -135,5 +139,4 @@ class Plugin extends immutable_1.default.Record({
135
139
  });
136
140
  }
137
141
  }
138
- Plugin.nameToNpmID = pluginDependency_1.default.nameToNpmID;
139
142
  exports.default = Plugin;
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const is_1 = __importDefault(require("is"));
7
7
  const semver_1 = __importDefault(require("semver"));
8
8
  const immutable_1 = __importDefault(require("immutable"));
9
- const pluginPrefix_1 = __importDefault(require("../constants/pluginPrefix"));
10
9
  const DEFAULT_VERSION = "*";
11
10
  /*
12
- * PluginDependency represents the informations about a plugin
11
+ * PluginDependency represents the information about a plugin
13
12
  * stored in config.plugins
14
13
  */
15
14
  class PluginDependency extends immutable_1.default.Record({
@@ -43,13 +42,6 @@ class PluginDependency extends immutable_1.default.Record({
43
42
  }
44
43
  return this.set("enabled", state);
45
44
  }
46
- /**
47
- * Return NPM ID for the dependency
48
- * @return {string}
49
- */
50
- getNpmID() {
51
- return PluginDependency.nameToNpmID(this.getName());
52
- }
53
45
  /**
54
46
  * Is the plugin using a git dependency
55
47
  * @return {boolean}
@@ -59,7 +51,6 @@ class PluginDependency extends immutable_1.default.Record({
59
51
  }
60
52
  /**
61
53
  * Create a plugin with a name and a plugin
62
- * @param {string}
63
54
  * @return {Plugin|undefined}
64
55
  */
65
56
  static create(name, version, enabled) {
@@ -180,13 +171,5 @@ class PluginDependency extends immutable_1.default.Record({
180
171
  })
181
172
  .toJS();
182
173
  }
183
- /**
184
- * Return NPM id for a plugin name
185
- * @param {string}
186
- * @return {string}
187
- */
188
- static nameToNpmID(s) {
189
- return pluginPrefix_1.default + s;
190
- }
191
174
  }
192
175
  exports.default = PluginDependency;
@@ -132,9 +132,9 @@ class TemplateBlock extends immutable_1.default.Record({
132
132
  });
133
133
  const mainBlock = blocks.shift();
134
134
  mainBlock.blocks = blocks;
135
- promise_1.default()
135
+ (0, promise_1.default)()
136
136
  .then(() => {
137
- const ctx = extend_1.default({
137
+ const ctx = (0, extend_1.default)({
138
138
  ctx: context,
139
139
  }, mainContext || {});
140
140
  return that.applyBlock(mainBlock, ctx);
@@ -190,7 +190,7 @@ class TemplateBlock extends immutable_1.default.Record({
190
190
  let indexedKey;
191
191
  const toIndex = !result.parse || result.post !== undefined;
192
192
  if (toIndex) {
193
- indexedKey = genKey_1.default();
193
+ indexedKey = (0, genKey_1.default)();
194
194
  blocksOutput[indexedKey] = result;
195
195
  }
196
196
  // Parsable block, just return it
@@ -17,7 +17,7 @@ describe("addPlugin", () => {
17
17
  });
18
18
  test("should add the plugin to the list", () => {
19
19
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
20
- const newConfig = addPlugin_1.default(config, "test");
20
+ const newConfig = (0, addPlugin_1.default)(config, "test");
21
21
  const testDep = newConfig.getPluginDependency("test");
22
22
  expect(testDep).toBeDefined();
23
23
  expect(testDep.getVersion()).toEqual("*");
@@ -10,17 +10,17 @@ describe("removePlugin", () => {
10
10
  plugins: ["hello", "world", "-disabled"],
11
11
  });
12
12
  test("should remove the plugin from the list", () => {
13
- const newConfig = removePlugin_1.default(config, "hello");
13
+ const newConfig = (0, removePlugin_1.default)(config, "hello");
14
14
  const testDep = newConfig.getPluginDependency("hello");
15
15
  expect(testDep).toBeUndefined();
16
16
  });
17
17
  test("should remove the disabled plugin from the list", () => {
18
- const newConfig = removePlugin_1.default(config, "disabled");
18
+ const newConfig = (0, removePlugin_1.default)(config, "disabled");
19
19
  const testDep = newConfig.getPluginDependency("disabled");
20
20
  expect(testDep).toBeUndefined();
21
21
  });
22
22
  test("should disable default plugin", () => {
23
- const newConfig = removePlugin_1.default(config, "search");
23
+ const newConfig = (0, removePlugin_1.default)(config, "search");
24
24
  const disabledDep = newConfig.getPluginDependency("search");
25
25
  expect(disabledDep).toBeDefined();
26
26
  expect(disabledDep.getVersion()).toEqual("*");
@@ -11,7 +11,7 @@ describe("togglePlugin", () => {
11
11
  });
12
12
  test("should enable plugin", () => {
13
13
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
14
- const newConfig = togglePlugin_1.default(config, "disabled");
14
+ const newConfig = (0, togglePlugin_1.default)(config, "disabled");
15
15
  const testDep = newConfig.getPluginDependency("disabled");
16
16
  expect(testDep).toBeDefined();
17
17
  expect(testDep.getVersion()).toEqual("*");
@@ -19,7 +19,7 @@ describe("togglePlugin", () => {
19
19
  });
20
20
  test("should disable plugin", () => {
21
21
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
22
- const newConfig = togglePlugin_1.default(config, "world");
22
+ const newConfig = (0, togglePlugin_1.default)(config, "world");
23
23
  const testDep = newConfig.getPluginDependency("world");
24
24
  expect(testDep).toBeDefined();
25
25
  expect(testDep.getVersion()).toEqual("*");
@@ -15,11 +15,10 @@ const isDefaultPlugin_1 = __importDefault(require("./isDefaultPlugin"));
15
15
  */
16
16
  function addPlugin(config, pluginName, version) {
17
17
  // For default plugin, we only ensure it is enabled
18
- if (isDefaultPlugin_1.default(pluginName, version)) {
19
- return togglePlugin_1.default(config, pluginName, true);
18
+ if ((0, isDefaultPlugin_1.default)(pluginName, version)) {
19
+ return (0, togglePlugin_1.default)(config, pluginName, true);
20
20
  }
21
21
  let deps = config.getPluginDependencies();
22
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'create' does not exist on type 'Class'.
23
22
  const dep = pluginDependency_1.default.create(pluginName, version);
24
23
  deps = deps.push(dep);
25
24
  return config.setPluginDependencies(deps);
@@ -12,6 +12,6 @@ const hasPlugin_1 = __importDefault(require("./hasPlugin"));
12
12
  * @return {boolean}
13
13
  */
14
14
  function isDefaultPlugin(pluginName, version) {
15
- return hasPlugin_1.default(defaultPlugins_1.default, pluginName, version);
15
+ return (0, hasPlugin_1.default)(defaultPlugins_1.default, pluginName, version);
16
16
  }
17
17
  exports.default = isDefaultPlugin;
@@ -15,8 +15,8 @@ function removePlugin(config, pluginName) {
15
15
  let deps = config.getPluginDependencies();
16
16
  // For default plugin, we have to disable it instead of removing from the list
17
17
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
18
- if (isDefaultPlugin_1.default(pluginName)) {
19
- return togglePlugin_1.default(config, pluginName, false);
18
+ if ((0, isDefaultPlugin_1.default)(pluginName)) {
19
+ return (0, togglePlugin_1.default)(config, pluginName, false);
20
20
  }
21
21
  // Remove the dependency from the list
22
22
  deps = deps.filterNot((dep) => {
@@ -17,7 +17,7 @@ function togglePlugin(config, pluginName, state) {
17
17
  let deps = config.getPluginDependencies();
18
18
  // For default plugin, we should ensure it's listed first
19
19
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
20
- if (isDefaultPlugin_1.default(pluginName) && !hasPlugin_1.default(deps, pluginName)) {
20
+ if ((0, isDefaultPlugin_1.default)(pluginName) && !(0, hasPlugin_1.default)(deps, pluginName)) {
21
21
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'create' does not exist on type 'Class'.
22
22
  deps = deps.push(pluginDependency_1.default.create(pluginName));
23
23
  }
@@ -25,17 +25,17 @@ describe("editPartTitle", () => {
25
25
  },
26
26
  ]);
27
27
  test("should correctly set title of first part", () => {
28
- const newSummary = editPartTitle_1.default(summary, 0, "Hello World");
28
+ const newSummary = (0, editPartTitle_1.default)(summary, 0, "Hello World");
29
29
  const part = newSummary.getPart(0);
30
30
  expect(part.getTitle()).toBe("Hello World");
31
31
  });
32
32
  test("should correctly set title of second part", () => {
33
- const newSummary = editPartTitle_1.default(summary, 1, "Hello");
33
+ const newSummary = (0, editPartTitle_1.default)(summary, 1, "Hello");
34
34
  const part = newSummary.getPart(1);
35
35
  expect(part.getTitle()).toBe("Hello");
36
36
  });
37
37
  test("should not fail if part doesn't exist", () => {
38
- const newSummary = editPartTitle_1.default(summary, 3, "Hello");
38
+ const newSummary = (0, editPartTitle_1.default)(summary, 3, "Hello");
39
39
  expect(newSummary.getParts().size).toBe(2);
40
40
  });
41
41
  });
@@ -49,7 +49,7 @@ describe("insertArticle", () => {
49
49
  const article = summaryArticle_1.default.create({
50
50
  title: "Inserted",
51
51
  }, "fake.level");
52
- const newSummary = insertArticle_1.default(summary, article, "2.1.1");
52
+ const newSummary = (0, insertArticle_1.default)(summary, article, "2.1.1");
53
53
  const inserted = newSummary.getByLevel("2.1.1");
54
54
  const nextOne = newSummary.getByLevel("2.1.2");
55
55
  expect(inserted.getTitle()).toBe("Inserted");
@@ -61,7 +61,7 @@ describe("insertArticle", () => {
61
61
  const article = summaryArticle_1.default.create({
62
62
  title: "Inserted",
63
63
  }, "fake.level");
64
- const newSummary = insertArticle_1.default(summary, article, "2.2");
64
+ const newSummary = (0, insertArticle_1.default)(summary, article, "2.2");
65
65
  const inserted = newSummary.getByLevel("2.2");
66
66
  const previousOne = newSummary.getByLevel("2.1");
67
67
  expect(inserted.getTitle()).toBe("Inserted");
@@ -36,7 +36,7 @@ describe("insertPart", () => {
36
36
  const part = summaryPart_1.default.create({
37
37
  title: "Inserted",
38
38
  }, "meaningless.level");
39
- const newSummary = insertPart_1.default(summary, part, 1);
39
+ const newSummary = (0, insertPart_1.default)(summary, part, 1);
40
40
  const inserted = newSummary.getPart(1);
41
41
  expect(inserted.getTitle()).toBe("Inserted");
42
42
  expect(newSummary.getParts().count()).toBe(3);
@@ -48,7 +48,7 @@ describe("insertPart", () => {
48
48
  const part = summaryPart_1.default.create({
49
49
  title: "Inserted",
50
50
  }, "meaningless.level");
51
- const newSummary = insertPart_1.default(summary, part, 2);
51
+ const newSummary = (0, insertPart_1.default)(summary, part, 2);
52
52
  const inserted = newSummary.getPart(2);
53
53
  expect(inserted.getTitle()).toBe("Inserted");
54
54
  expect(newSummary.getParts().count()).toBe(3);
@@ -28,7 +28,7 @@ describe("mergeAtLevel", () => {
28
28
  ]);
29
29
  test("should edit a part", () => {
30
30
  const beforeChildren = summary.getByLevel("1").getArticles();
31
- const newSummary = mergeAtLevel_1.default(summary, "1", { title: "Part O" });
31
+ const newSummary = (0, mergeAtLevel_1.default)(summary, "1", { title: "Part O" });
32
32
  const edited = newSummary.getByLevel("1");
33
33
  expect(edited.getTitle()).toBe("Part O");
34
34
  // Same children
@@ -36,7 +36,7 @@ describe("mergeAtLevel", () => {
36
36
  });
37
37
  test("should edit a part", () => {
38
38
  const beforePath = summary.getByLevel("1.2").getPath();
39
- const newSummary = mergeAtLevel_1.default(summary, "1.2", { title: "Renamed article" });
39
+ const newSummary = (0, mergeAtLevel_1.default)(summary, "1.2", { title: "Renamed article" });
40
40
  const edited = newSummary.getByLevel("1.2");
41
41
  expect(edited.getTitle()).toBe("Renamed article");
42
42
  // Same children
@@ -46,18 +46,18 @@ describe("moveArticle", () => {
46
46
  },
47
47
  ]);
48
48
  test("should move an article to the same place", () => {
49
- const newSummary = moveArticle_1.default(summary, "2.1", "2.1");
49
+ const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.1");
50
50
  expect(immutable_1.default.is(summary, newSummary)).toBe(true);
51
51
  });
52
52
  test("should move an article to an previous level", () => {
53
- const newSummary = moveArticle_1.default(summary, "2.2", "2.1");
53
+ const newSummary = (0, moveArticle_1.default)(summary, "2.2", "2.1");
54
54
  const moved = newSummary.getByLevel("2.1");
55
55
  const other = newSummary.getByLevel("2.2");
56
56
  expect(moved.getTitle()).toBe("2.2");
57
57
  expect(other.getTitle()).toBe("2.1");
58
58
  });
59
59
  test("should move an article to a next level", () => {
60
- const newSummary = moveArticle_1.default(summary, "2.1", "2.2");
60
+ const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.2");
61
61
  const moved = newSummary.getByLevel("2.1");
62
62
  const other = newSummary.getByLevel("2.2");
63
63
  expect(moved.getTitle()).toBe("2.2");