honkit 3.6.21 → 3.7.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.
Files changed (167) 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/configDefault.js +1 -1
  20. package/lib/constants/defaultFilters.js +2 -2
  21. package/lib/fs/__tests__/mock.js +1 -1
  22. package/lib/index.js +1 -1
  23. package/lib/init.js +1 -1
  24. package/lib/json/encodeBook.js +5 -5
  25. package/lib/json/encodeBookWithPage.js +3 -3
  26. package/lib/json/encodeGlossary.js +1 -1
  27. package/lib/json/encodeLanguages.js +1 -1
  28. package/lib/json/encodeOutput.js +1 -1
  29. package/lib/json/encodeOutputWithPage.js +3 -3
  30. package/lib/json/encodePage.js +9 -8
  31. package/lib/json/encodeReadme.js +1 -1
  32. package/lib/json/encodeSummary.js +1 -1
  33. package/lib/json/encodeSummaryArticle.js +8 -1
  34. package/lib/json/encodeSummaryArticleWithCache.js +36 -0
  35. package/lib/models/__tests__/summaryArticle.js +55 -0
  36. package/lib/models/__tests__/templateBlock.js +2 -2
  37. package/lib/models/book.js +1 -1
  38. package/lib/models/config.js +1 -1
  39. package/lib/models/fs.js +5 -5
  40. package/lib/models/glossaryEntry.js +1 -1
  41. package/lib/models/ignore.js +2 -2
  42. package/lib/models/output.js +1 -1
  43. package/lib/models/page.js +1 -1
  44. package/lib/models/parser.js +11 -11
  45. package/lib/models/templateBlock.js +3 -3
  46. package/lib/modifiers/config/__tests__/addPlugin.js +1 -1
  47. package/lib/modifiers/config/__tests__/removePlugin.js +3 -3
  48. package/lib/modifiers/config/__tests__/togglePlugin.js +2 -2
  49. package/lib/modifiers/config/addPlugin.js +2 -2
  50. package/lib/modifiers/config/isDefaultPlugin.js +1 -1
  51. package/lib/modifiers/config/removePlugin.js +2 -2
  52. package/lib/modifiers/config/togglePlugin.js +1 -1
  53. package/lib/modifiers/summary/__tests__/editPartTitle.js +3 -3
  54. package/lib/modifiers/summary/__tests__/insertArticle.js +2 -2
  55. package/lib/modifiers/summary/__tests__/insertPart.js +2 -2
  56. package/lib/modifiers/summary/__tests__/mergeAtLevel.js +2 -2
  57. package/lib/modifiers/summary/__tests__/moveArticle.js +3 -3
  58. package/lib/modifiers/summary/__tests__/moveArticleAfter.js +5 -5
  59. package/lib/modifiers/summary/__tests__/removeArticle.js +1 -1
  60. package/lib/modifiers/summary/editArticleRef.js +1 -1
  61. package/lib/modifiers/summary/editArticleTitle.js +1 -1
  62. package/lib/modifiers/summary/indexPartLevels.js +1 -1
  63. package/lib/modifiers/summary/insertArticle.js +2 -2
  64. package/lib/modifiers/summary/insertPart.js +1 -1
  65. package/lib/modifiers/summary/moveArticle.js +2 -2
  66. package/lib/modifiers/summary/moveArticleAfter.js +4 -4
  67. package/lib/modifiers/summary/removeArticle.js +2 -2
  68. package/lib/modifiers/summary/removePart.js +1 -1
  69. package/lib/modifiers/summary/unshiftArticle.js +1 -1
  70. package/lib/output/Generator.js +2 -0
  71. package/lib/output/__tests__/ebook.js +1 -1
  72. package/lib/output/__tests__/json.js +3 -3
  73. package/lib/output/__tests__/plugin-hooks.js +3 -3
  74. package/lib/output/__tests__/website.js +8 -8
  75. package/lib/output/callHook.js +1 -1
  76. package/lib/output/callPageHook.js +1 -1
  77. package/lib/output/ebook/getConvertOptions.js +4 -4
  78. package/lib/output/ebook/getPDFTemplate.js +3 -1
  79. package/lib/output/ebook/index.js +1 -1
  80. package/lib/output/ebook/onFinish.js +3 -3
  81. package/lib/output/generateAssets.js +1 -1
  82. package/lib/output/generateBook.js +54 -46
  83. package/lib/output/generatePage.js +5 -5
  84. package/lib/output/generatePages.js +3 -3
  85. package/lib/output/getModifiers.js +2 -2
  86. package/lib/output/helper/fileToURL.js +1 -1
  87. package/lib/output/helper/resolveFileToURL.js +1 -1
  88. package/lib/output/index.js +0 -2
  89. package/lib/output/json/onFinish.js +1 -1
  90. package/lib/output/json/onPage.js +2 -2
  91. package/lib/output/modifiers/__tests__/addHeadingId.js +2 -2
  92. package/lib/output/modifiers/__tests__/annotateText.js +3 -3
  93. package/lib/output/modifiers/__tests__/fetchRemoteImages.js +2 -2
  94. package/lib/output/modifiers/__tests__/highlightCode.js +5 -5
  95. package/lib/output/modifiers/__tests__/inlinePng.js +1 -1
  96. package/lib/output/modifiers/__tests__/inlineSvg.js +2 -2
  97. package/lib/output/modifiers/__tests__/resolveImages.js +3 -3
  98. package/lib/output/modifiers/__tests__/resolveLinks.js +7 -7
  99. package/lib/output/modifiers/__tests__/svgToImg.js +2 -2
  100. package/lib/output/modifiers/addHeadingId.js +2 -2
  101. package/lib/output/modifiers/annotateText.js +1 -1
  102. package/lib/output/modifiers/fetchRemoteImages.js +1 -1
  103. package/lib/output/modifiers/highlightCode.js +2 -2
  104. package/lib/output/modifiers/inlineAssets.js +1 -1
  105. package/lib/output/modifiers/inlinePng.js +1 -1
  106. package/lib/output/modifiers/inlineSvg.js +1 -1
  107. package/lib/output/modifiers/resolveImages.js +1 -1
  108. package/lib/output/modifiers/resolveLinks.js +1 -1
  109. package/lib/output/modifiers/svgToImg.js +2 -2
  110. package/lib/output/preparePages.js +1 -1
  111. package/lib/output/preparePlugins.js +1 -1
  112. package/lib/output/testing/createMock.js +2 -2
  113. package/lib/output/testing/generateMock.js +3 -3
  114. package/lib/output/website/__tests__/i18n.js +6 -6
  115. package/lib/output/website/copyPluginAssets.js +4 -4
  116. package/lib/output/website/createTemplateEngine.js +6 -7
  117. package/lib/output/website/onFinish.js +3 -3
  118. package/lib/output/website/onInit.js +1 -1
  119. package/lib/output/website/onPage.js +5 -5
  120. package/lib/output/website/prepareI18n.js +2 -2
  121. package/lib/output/website/prepareResources.js +2 -2
  122. package/lib/output/website/state.js +1 -1
  123. package/lib/parse/__tests__/listAssets.js +6 -6
  124. package/lib/parse/__tests__/parseBook.js +6 -6
  125. package/lib/parse/__tests__/parseGlossary.js +4 -4
  126. package/lib/parse/__tests__/parseIgnore.js +2 -2
  127. package/lib/parse/__tests__/parsePageFromString.js +3 -3
  128. package/lib/parse/__tests__/parseReadme.js +5 -5
  129. package/lib/parse/__tests__/parseSummary.js +4 -4
  130. package/lib/parse/lookupStructureFile.js +1 -1
  131. package/lib/parse/parseBook.js +3 -3
  132. package/lib/parse/parseConfig.js +2 -2
  133. package/lib/parse/parseGlossary.js +1 -1
  134. package/lib/parse/parseIgnore.js +1 -1
  135. package/lib/parse/parseLanguages.js +1 -1
  136. package/lib/parse/parsePage.js +1 -1
  137. package/lib/parse/parsePageFromString.js +2 -2
  138. package/lib/parse/parsePagesList.js +2 -2
  139. package/lib/parse/parseReadme.js +1 -1
  140. package/lib/parse/parseStructureFile.js +1 -1
  141. package/lib/parse/parseSummary.js +1 -1
  142. package/lib/parse/validateConfig.js +2 -2
  143. package/lib/parse/walkSummary.js +1 -1
  144. package/lib/plugins/PluginResolver.js +4 -4
  145. package/lib/plugins/__tests__/findInstalled.js +1 -1
  146. package/lib/plugins/__tests__/listDependencies.js +6 -6
  147. package/lib/plugins/__tests__/sortDependencies.js +4 -4
  148. package/lib/plugins/__tests__/validatePlugin.js +3 -3
  149. package/lib/plugins/findInstalled.js +2 -2
  150. package/lib/plugins/listDependencies.js +1 -1
  151. package/lib/plugins/listDepsForBook.js +1 -1
  152. package/lib/plugins/loadForBook.js +2 -2
  153. package/lib/plugins/loadPlugin.js +2 -2
  154. package/lib/plugins/validateConfig.js +2 -2
  155. package/lib/plugins/validatePlugin.js +1 -1
  156. package/lib/templating/__tests__/conrefsLoader.js +8 -8
  157. package/lib/templating/__tests__/postRender.js +4 -4
  158. package/lib/templating/__tests__/replaceShortcuts.js +2 -2
  159. package/lib/templating/render.js +1 -1
  160. package/lib/templating/renderFile.js +2 -2
  161. package/lib/templating/replaceShortcuts.js +2 -2
  162. package/lib/utils/command.js +1 -33
  163. package/lib/utils/error.js +10 -10
  164. package/lib/utils/fs.js +6 -6
  165. package/lib/utils/git.js +4 -4
  166. package/lib/utils/promise.js +6 -6
  167. package/package.json +4 -3
@@ -11,7 +11,7 @@ describe("initBook", () => {
11
11
  dir = tmp_1.default.dirSync();
12
12
  });
13
13
  test("should create a README and SUMMARY for empty book", () => {
14
- return init_1.default(dir.name).then(() => {
14
+ return (0, init_1.default)(dir.name).then(() => {
15
15
  expect(dir.name).toHaveFile("README.md");
16
16
  expect(dir.name).toHaveFile("SUMMARY.md");
17
17
  });
@@ -35,7 +35,7 @@ it("HonKit snapshots", async () => {
35
35
  .replace(/gitbook\.page\.hasChanged\(.*\);/g, ``)
36
36
  .replace(/<meta name="generator" content="HonKit .*">/g, "");
37
37
  };
38
- for await (const item of internal_test_utils_1.iterateDirectoryContents({
38
+ for await (const item of (0, internal_test_utils_1.iterateDirectoryContents)({
39
39
  baseDir: outputDir,
40
40
  allowExtensions: [".html"],
41
41
  maskContent
@@ -14,7 +14,7 @@ function decodeGlobal(output, result) {
14
14
  let book = output.getBook();
15
15
  let config = book.getConfig();
16
16
  // Update config
17
- config = decodeConfig_1.decodeConfig(config, result.config);
17
+ config = (0, decodeConfig_1.decodeConfig)(config, result.config);
18
18
  book = book.set("config", config);
19
19
  return output.set("book", book);
20
20
  }
@@ -7,10 +7,6 @@ const object_path_1 = __importDefault(require("object-path"));
7
7
  const deprecate_1 = __importDefault(require("./deprecate"));
8
8
  /**
9
9
  Encode a config object into a JS config api
10
-
11
- @param {Output} output
12
- @param {Config} config
13
- @return {Object}
14
10
  */
15
11
  function encodeConfig(output, config) {
16
12
  const result = {
@@ -33,8 +33,8 @@ function encodeGlobal(output) {
33
33
  const blocks = plugins_1.default.listBlocks(plugins);
34
34
  const result = {
35
35
  log: logger,
36
- config: encodeConfig_1.default(output, book.getConfig()),
37
- summary: encodeSummary_1.default(output, book.getSummary()),
36
+ config: (0, encodeConfig_1.default)(output, book.getConfig()),
37
+ summary: (0, encodeSummary_1.default)(output, book.getSummary()),
38
38
  /**
39
39
  Check if the book is a multilingual book
40
40
 
@@ -88,7 +88,7 @@ function encodeGlobal(output) {
88
88
  const page = output.getPage(filePath);
89
89
  if (!page)
90
90
  return undefined;
91
- return encodePage_1.default(output, page);
91
+ return (0, encodePage_1.default)(output, page);
92
92
  },
93
93
  /**
94
94
  Render a block of text (markdown/asciidoc)
@@ -122,7 +122,7 @@ function encodeGlobal(output) {
122
122
  */
123
123
  applyBlock: function (name, blockData) {
124
124
  const block = blocks.get(name) || defaultBlocks_1.default.get(name);
125
- return promise_1.default(block.applyBlock(blockData, result));
125
+ return (0, promise_1.default)(block.applyBlock(blockData, result));
126
126
  },
127
127
  },
128
128
  output: {
@@ -152,7 +152,7 @@ function encodeGlobal(output) {
152
152
  @return {string}
153
153
  */
154
154
  toURL: function (filePath) {
155
- return fileToURL_1.default(output, filePath);
155
+ return (0, fileToURL_1.default)(output, filePath);
156
156
  },
157
157
  /**
158
158
  Check that a file exists.
@@ -161,7 +161,7 @@ function encodeGlobal(output) {
161
161
  @return {Promise}
162
162
  */
163
163
  hasFile: function (fileName, content) {
164
- return promise_1.default().then(() => {
164
+ return (0, promise_1.default)().then(() => {
165
165
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
166
166
  const filePath = path_2.default.resolveInRoot(outputFolder, fileName);
167
167
  return fs_1.default.exists(filePath);
@@ -176,7 +176,7 @@ function encodeGlobal(output) {
176
176
  @return {Promise}
177
177
  */
178
178
  writeFile: function (fileName, content) {
179
- return promise_1.default().then(() => {
179
+ return (0, promise_1.default)().then(() => {
180
180
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
181
181
  const filePath = path_2.default.resolveInRoot(outputFolder, fileName);
182
182
  return fs_1.default.ensureFile(filePath).then(() => {
@@ -194,7 +194,7 @@ function encodeGlobal(output) {
194
194
  @return {Promise}
195
195
  */
196
196
  copyFile: function (inputFile, outputFile, content) {
197
- return promise_1.default().then(() => {
197
+ return (0, promise_1.default)().then(() => {
198
198
  // @ts-expect-error ts-migrate(2554) FIXME: Expected 1 arguments, but got 2.
199
199
  const outputFilePath = path_2.default.resolveInRoot(outputFolder, outputFile);
200
200
  return fs_1.default.ensureFile(outputFilePath).then(() => {
@@ -217,7 +217,7 @@ function encodeGlobal(output) {
217
217
  deprecate_1.default.renamedMethod(output, "this.contentLink", result, "contentLink", "output.toURL");
218
218
  deprecate_1.default.field(output, "this.generator", result, "generator", output.getGenerator(), '"this.generator" property is deprecated, use "this.output.name" instead');
219
219
  deprecate_1.default.field(output, "this.navigation", result, "navigation", () => {
220
- return encodeNavigation_1.default(output);
220
+ return (0, encodeNavigation_1.default)(output);
221
221
  }, '"navigation" property is deprecated');
222
222
  deprecate_1.default.field(output, "this.book", result, "book", result, '"book" property is deprecated, use "this" directly instead');
223
223
  deprecate_1.default.field(output, "this.options", result, "options", result.config.values, '"options" property is deprecated, use config.get(key) instead');
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const immutable_1 = __importDefault(require("immutable"));
7
7
  /**
8
8
  Encode an article for next/prev
9
-
10
- @param {Map<String:Page>}
11
- @param {Article}
12
9
  @return {Object}
13
10
  */
14
11
  function encodeArticle(pages, article) {
@@ -24,7 +21,6 @@ function encodeArticle(pages, article) {
24
21
  /**
25
22
  this.navigation is a deprecated property from GitBook v2
26
23
 
27
- @param {Output}
28
24
  @return {Object}
29
25
  */
30
26
  function encodeNavigation(output) {
@@ -8,10 +8,6 @@ const deprecate_1 = __importDefault(require("./deprecate"));
8
8
  const encodeProgress_1 = __importDefault(require("./encodeProgress"));
9
9
  /**
10
10
  Encode a page in a context to a JS API
11
-
12
- @param {Output} output
13
- @param {Page} page
14
- @return {Object}
15
11
  */
16
12
  function encodePage(output, page) {
17
13
  const book = output.getBook();
@@ -24,7 +20,7 @@ function encodePage(output, page) {
24
20
  result.path = file.getPath();
25
21
  result.rawPath = fs.resolve(result.path);
26
22
  deprecate_1.default.field(output, "page.progress", result, "progress", () => {
27
- return encodeProgress_1.default(output, page);
23
+ return (0, encodeProgress_1.default)(output, page);
28
24
  }, '"page.progress" property is deprecated');
29
25
  deprecate_1.default.field(output, "page.sections", result, "sections", [
30
26
  {
@@ -7,15 +7,10 @@ const immutable_1 = __importDefault(require("immutable"));
7
7
  const encodeNavigation_1 = __importDefault(require("./encodeNavigation"));
8
8
  /**
9
9
  page.progress is a deprecated property from GitBook v2
10
-
11
- @param {Output}
12
- @param {Page}
13
- @return {Object}
14
10
  */
15
11
  function encodeProgress(output, page) {
16
12
  const current = page.getPath();
17
- let navigation = encodeNavigation_1.default(output);
18
- navigation = immutable_1.default.Map(navigation);
13
+ const navigation = immutable_1.default.Map((0, encodeNavigation_1.default)(output));
19
14
  const n = navigation.size;
20
15
  let percent = 0, prevPercent = 0, currentChapter = null;
21
16
  let done = true;
@@ -20,7 +20,7 @@ function encodeSummary(output, summary) {
20
20
  */
21
21
  walk: function (iter) {
22
22
  summary.getArticle((article) => {
23
- const jsonArticle = encodeSummaryArticle_1.default(article, false);
23
+ const jsonArticle = (0, encodeSummaryArticle_1.default)(article, false);
24
24
  return iter(jsonArticle);
25
25
  });
26
26
  },
@@ -32,8 +32,7 @@ function encodeSummary(output, summary) {
32
32
  */
33
33
  getArticleByLevel: function (level) {
34
34
  const article = summary.getByLevel(level);
35
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
36
- return article ? encodeSummaryArticle_1.default(article) : undefined;
35
+ return article ? (0, encodeSummaryArticle_1.default)(article) : undefined;
37
36
  },
38
37
  /**
39
38
  Get an article by its path
@@ -43,8 +42,7 @@ function encodeSummary(output, summary) {
43
42
  */
44
43
  getArticleByPath: function (level) {
45
44
  const article = summary.getByPath(level);
46
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
47
- return article ? encodeSummaryArticle_1.default(article) : undefined;
45
+ return article ? (0, encodeSummaryArticle_1.default)(article) : undefined;
48
46
  },
49
47
  };
50
48
  return result;
package/lib/bin.js CHANGED
@@ -20,7 +20,7 @@ const run = (argv = process.argv) => {
20
20
  const template = `--${spec.name} <${spec.name}>`;
21
21
  const description = `${spec.description} (${spec.values.map(JSON.stringify).join(", ")})`;
22
22
  subcommand = subcommand.option(template, description, (value, _dummyPrevious) => {
23
- assert_1.default(spec.values.includes(value), `Invalid value ${value} for ${spec.name}`);
23
+ (0, assert_1.default)(spec.values.includes(value), `Invalid value ${value} for ${spec.name}`);
24
24
  return value;
25
25
  }, spec.defaults);
26
26
  }
package/lib/cli/build.js CHANGED
@@ -15,12 +15,12 @@ exports.default = {
15
15
  description: "build a book",
16
16
  options: [options_1.default.log, options_1.default.format, options_1.default.timing, options_1.default.reload],
17
17
  exec: function (args, kwargs) {
18
- const book = getBook_1.default(args, kwargs);
19
- const outputFolder = getOutputFolder_1.default(args);
18
+ const book = (0, getBook_1.default)(args, kwargs);
19
+ const outputFolder = (0, getOutputFolder_1.default)(args);
20
20
  const Generator = output_1.default.getGenerator(kwargs.format);
21
21
  if (kwargs.reload) {
22
22
  book.getLogger().info.ok(`Clear cache`);
23
- page_cache_1.clearCache();
23
+ (0, page_cache_1.clearCache)();
24
24
  }
25
25
  return parse_1.default.parseBook(book)
26
26
  .then((resultBook) => {
@@ -23,11 +23,11 @@ function default_1(format) {
23
23
  const outputFile = args[1] || `book${extension}`;
24
24
  // Create temporary directory
25
25
  const outputFolder = tmp_1.default.dirSync().name;
26
- const book = getBook_1.default(args, kwargs);
26
+ const book = (0, getBook_1.default)(args, kwargs);
27
27
  const logger = book.getLogger();
28
28
  const Generator = output_1.default.getGenerator("ebook");
29
29
  if (kwargs.reload) {
30
- page_cache_1.clearCache();
30
+ (0, page_cache_1.clearCache)();
31
31
  }
32
32
  return (parse_1.default.parseBook(book)
33
33
  .then((resultBook) => {
@@ -17,7 +17,7 @@ const node_1 = __importDefault(require("../fs/node"));
17
17
  function getBook(args, kwargs) {
18
18
  const input = path_1.default.resolve(args[0] || process.cwd());
19
19
  const logLevel = kwargs.log;
20
- const fs = node_1.default(input);
20
+ const fs = (0, node_1.default)(input);
21
21
  const book = book_1.default.createForFS(fs);
22
22
  return book.setLogLevel(logLevel);
23
23
  }
package/lib/cli/index.js CHANGED
@@ -8,4 +8,4 @@ const build_1 = __importDefault(require("./build"));
8
8
  const serve_1 = __importDefault(require("./serve"));
9
9
  const parse_1 = __importDefault(require("./parse"));
10
10
  const init_1 = __importDefault(require("./init"));
11
- exports.default = [build_1.default, serve_1.default, parse_1.default, init_1.default, buildEbook_1.default("pdf"), buildEbook_1.default("epub"), buildEbook_1.default("mobi")];
11
+ exports.default = [build_1.default, serve_1.default, parse_1.default, init_1.default, (0, buildEbook_1.default)("pdf"), (0, buildEbook_1.default)("epub"), (0, buildEbook_1.default)("mobi")];
package/lib/cli/init.js CHANGED
@@ -12,6 +12,6 @@ exports.default = {
12
12
  options: [options_1.default.log],
13
13
  exec: function (args, kwargs) {
14
14
  const bookRoot = path_1.default.resolve(process.cwd(), args[0] || "./");
15
- return init_1.default(bookRoot);
15
+ return (0, init_1.default)(bookRoot);
16
16
  },
17
17
  };
package/lib/cli/parse.js CHANGED
@@ -45,7 +45,7 @@ exports.default = {
45
45
  description: "parse and print debug information about a book",
46
46
  options: [options_1.default.log],
47
47
  exec: function (args, kwargs) {
48
- const book = getBook_1.default(args, kwargs);
48
+ const book = (0, getBook_1.default)(args, kwargs);
49
49
  const logger = book.getLogger();
50
50
  return parse_1.default.parseBook(book).then((resultBook) => {
51
51
  const rootFolder = book.getRoot();
package/lib/cli/serve.js CHANGED
@@ -25,10 +25,10 @@ function waitForCtrlC() {
25
25
  return d.promise;
26
26
  }
27
27
  function startServer(args, kwargs) {
28
- const outputFolder = getOutputFolder_1.default(args);
28
+ const outputFolder = (0, getOutputFolder_1.default)(args);
29
29
  const port = kwargs.port;
30
30
  const browser = kwargs["browser"];
31
- const book = getBook_1.default(args, kwargs);
31
+ const book = (0, getBook_1.default)(args, kwargs);
32
32
  const hasWatch = kwargs["watch"];
33
33
  const hasOpen = kwargs["open"];
34
34
  const hasLiveReloading = kwargs["live"];
@@ -52,7 +52,7 @@ function startServer(args, kwargs) {
52
52
  .then(() => {
53
53
  console.log(`Serving book on http://localhost:${port}`);
54
54
  if (hasOpen) {
55
- open_1.default(`http://localhost:${port}`, { app: browser });
55
+ (0, open_1.default)(`http://localhost:${port}`, { app: browser });
56
56
  }
57
57
  })
58
58
  .then(() => {
@@ -60,7 +60,7 @@ function startServer(args, kwargs) {
60
60
  return waitForCtrlC();
61
61
  }
62
62
  // update book immutably. does not use book again
63
- return watch_1.default(book.getRoot(), (error, filepath) => {
63
+ return (0, watch_1.default)(book.getRoot(), (error, filepath) => {
64
64
  if (error) {
65
65
  console.error(error);
66
66
  return;
@@ -105,7 +105,7 @@ function generateBook({ book, outputFolder, hasLiveReloading, Generator, reload
105
105
  // Stop server if running
106
106
  if (reload) {
107
107
  book.getLogger().info.ok(`Clear cache`);
108
- page_cache_1.clearCache();
108
+ (0, page_cache_1.clearCache)();
109
109
  }
110
110
  return parse_1.default.parseBook(book).then((resultBook) => {
111
111
  if (hasLiveReloading) {
@@ -165,12 +165,12 @@ exports.default = {
165
165
  server = new server_1.default();
166
166
  const hasWatch = kwargs["watch"];
167
167
  const hasLiveReloading = kwargs["live"];
168
- return promise_1.default()
168
+ return (0, promise_1.default)()
169
169
  .then(() => {
170
170
  if (!hasWatch || !hasLiveReloading) {
171
171
  return;
172
172
  }
173
- lrServer = tiny_lr_1.default({});
173
+ lrServer = (0, tiny_lr_1.default)({});
174
174
  return promise_1.default.nfcall(lrServer.listen.bind(lrServer), kwargs.lrport).then(() => {
175
175
  console.log("Live reload server started on port:", kwargs.lrport);
176
176
  console.log("Press CTRL+C to quit ...");
package/lib/cli/server.js CHANGED
@@ -32,7 +32,7 @@ class Server extends events_1.default.EventEmitter {
32
32
  stop() {
33
33
  const that = this;
34
34
  if (!this.isRunning())
35
- return promise_1.default();
35
+ return (0, promise_1.default)();
36
36
  const d = promise_1.default.defer();
37
37
  this.running.close((err) => {
38
38
  that.running = null;
@@ -54,7 +54,7 @@ class Server extends events_1.default.EventEmitter {
54
54
  */
55
55
  start(dir, port) {
56
56
  const that = this;
57
- let pre = promise_1.default();
57
+ let pre = (0, promise_1.default)();
58
58
  port = port || 8004;
59
59
  if (that.isRunning())
60
60
  pre = this.stop();
@@ -78,7 +78,7 @@ class Server extends events_1.default.EventEmitter {
78
78
  }
79
79
  res.setHeader("X-Current-Location", req.url);
80
80
  // Send file
81
- send_1.default(req, url_1.default.parse(req.url).pathname, {
81
+ (0, send_1.default)(req, url_1.default.parse(req.url).pathname, {
82
82
  root: dir,
83
83
  })
84
84
  .on("error", error)
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const configSchema_1 = __importDefault(require("./configSchema"));
7
7
  const immutable_1 = __importDefault(require("immutable"));
8
8
  const json_schema_defaults_1 = __importDefault(require("json-schema-defaults"));
9
- exports.default = immutable_1.default.fromJS(json_schema_defaults_1.default(configSchema_1.default));
9
+ exports.default = immutable_1.default.fromJS((0, json_schema_defaults_1.default)(configSchema_1.default));
@@ -9,10 +9,10 @@ exports.default = immutable_1.default.Map({
9
9
  // Format a date
10
10
  // ex: 'MMMM Do YYYY, h:mm:ss a
11
11
  date: function (time, format) {
12
- return moment_1.default(time).format(format);
12
+ return (0, moment_1.default)(time).format(format);
13
13
  },
14
14
  // Relative Time
15
15
  dateFromNow: function (time) {
16
- return moment_1.default(time).fromNow();
16
+ return (0, moment_1.default)(time).fromNow();
17
17
  },
18
18
  });
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const mock_1 = __importDefault(require("../mock"));
7
7
  describe("MockFS", () => {
8
- const fs = mock_1.default({
8
+ const fs = (0, mock_1.default)({
9
9
  "README.md": "Hello World",
10
10
  "SUMMARY.md": "# Summary",
11
11
  folder: {
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ const init_1 = __importDefault(require("./init"));
9
9
  const node_1 = __importDefault(require("./fs/node"));
10
10
  const output_1 = __importDefault(require("./output"));
11
11
  const cli_1 = __importDefault(require("./cli"));
12
- exports.default = extend_1.default({
12
+ exports.default = (0, extend_1.default)({
13
13
  initBook: init_1.default,
14
14
  createNodeFS: node_1.default,
15
15
  Output: output_1.default,
package/lib/init.js CHANGED
@@ -25,7 +25,7 @@ function initBook(rootFolder) {
25
25
  .mkdirp(rootFolder)
26
26
  // Parse the summary and readme
27
27
  .then(() => {
28
- const fs = node_1.default(rootFolder);
28
+ const fs = (0, node_1.default)(rootFolder);
29
29
  const book = book_1.default.createForFS(fs);
30
30
  return (parse_1.default.parseReadme(book)
31
31
  // Setup default readme if doesn't found one
@@ -20,11 +20,11 @@ function encodeBookToJson(book) {
20
20
  const language = book.getLanguage();
21
21
  const variables = config.getValue("variables", {});
22
22
  return {
23
- summary: encodeSummary_1.default(book.getSummary()),
24
- glossary: encodeGlossary_1.default(book.getGlossary()),
25
- readme: encodeReadme_1.default(book.getReadme()),
23
+ summary: (0, encodeSummary_1.default)(book.getSummary()),
24
+ glossary: (0, encodeGlossary_1.default)(book.getGlossary()),
25
+ readme: (0, encodeReadme_1.default)(book.getReadme()),
26
26
  config: book.getConfig().getValues().toJS(),
27
- languages: book.isMultilingual() ? encodeLanguages_1.default(book.getLanguages()) : undefined,
27
+ languages: book.isMultilingual() ? (0, encodeLanguages_1.default)(book.getLanguages()) : undefined,
28
28
  gitbook: {
29
29
  version: honkit_1.default.version,
30
30
  time: honkit_1.default.START_TIME,
@@ -33,7 +33,7 @@ function encodeBookToJson(book) {
33
33
  version: honkit_1.default.version,
34
34
  time: honkit_1.default.START_TIME,
35
35
  },
36
- book: extend_1.default({
36
+ book: (0, extend_1.default)({
37
37
  language: language ? language : undefined,
38
38
  }, variables.toJS()),
39
39
  };
@@ -15,11 +15,11 @@ const encodeFile_1 = __importDefault(require("./encodeFile"));
15
15
  */
16
16
  function encodeBookWithPage(book, page) {
17
17
  const file = page.getFile();
18
- const result = encodeBook_1.default(book);
18
+ const result = (0, encodeBook_1.default)(book);
19
19
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'page' does not exist on type '{ summary:... Remove this comment to see the full error message
20
- result.page = encodePage_1.default(page, book.getSummary());
20
+ result.page = (0, encodePage_1.default)(page, book.getSummary());
21
21
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'file' does not exist on type '{ summary:... Remove this comment to see the full error message
22
- result.file = encodeFile_1.default(file);
22
+ result.file = (0, encodeFile_1.default)(file);
23
23
  return result;
24
24
  }
25
25
  exports.default = encodeBookWithPage;
@@ -15,7 +15,7 @@ function encodeGlossary(glossary) {
15
15
  const file = glossary.getFile();
16
16
  const entries = glossary.getEntries();
17
17
  return {
18
- file: encodeFile_1.default(file),
18
+ file: (0, encodeFile_1.default)(file),
19
19
  entries: entries.map(encodeGlossaryEntry_1.default).toJS(),
20
20
  };
21
21
  }
@@ -14,7 +14,7 @@ function encodeLanguages(languages) {
14
14
  const file = languages.getFile();
15
15
  const list = languages.getList();
16
16
  return {
17
- file: encodeFile_1.default(file),
17
+ file: (0, encodeFile_1.default)(file),
18
18
  list: list
19
19
  .valueSeq()
20
20
  .map((lang) => {
@@ -14,7 +14,7 @@ function encodeOutputToJson(output) {
14
14
  const book = output.getBook();
15
15
  const generator = output.getGenerator();
16
16
  const options = output.getOptions();
17
- const result = encodeBook_1.default(book);
17
+ const result = (0, encodeBook_1.default)(book);
18
18
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'output' does not exist on type '{ summar... Remove this comment to see the full error message
19
19
  result.output = {
20
20
  name: generator,
@@ -16,11 +16,11 @@ const encodeFile_1 = __importDefault(require("./encodeFile"));
16
16
  function encodeOutputWithPage(output, page) {
17
17
  const file = page.getFile();
18
18
  const book = output.getBook();
19
- const result = encodeOutput_1.default(output);
19
+ const result = (0, encodeOutput_1.default)(output);
20
20
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'page' does not exist on type '{ summary:... Remove this comment to see the full error message
21
- result.page = encodePage_1.default(page, book.getSummary());
21
+ result.page = (0, encodePage_1.default)(page, book.getSummary());
22
22
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'file' does not exist on type '{ summary:... Remove this comment to see the full error message
23
- result.file = encodeFile_1.default(file);
23
+ result.file = (0, encodeFile_1.default)(file);
24
24
  return result;
25
25
  }
26
26
  exports.default = encodeOutputWithPage;
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const encodeSummaryArticle_1 = __importDefault(require("./encodeSummaryArticle"));
7
7
  /**
8
8
  Return a JSON representation of a page
9
-
10
- @param {Page} page
11
- @param {Summary} summary
12
- @return {Object}
13
9
  */
14
10
  function encodePage(page, summary) {
15
11
  const file = page.getFile();
@@ -22,13 +18,18 @@ function encodePage(page, summary) {
22
18
  result.depth = article.getDepth();
23
19
  const nextArticle = summary.getNextArticle(article);
24
20
  if (nextArticle) {
25
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
26
- result.next = encodeSummaryArticle_1.default(nextArticle);
21
+ result.next = (0, encodeSummaryArticle_1.default)(nextArticle);
27
22
  }
28
23
  const prevArticle = summary.getPrevArticle(article);
29
24
  if (prevArticle) {
30
- // @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
31
- result.previous = encodeSummaryArticle_1.default(prevArticle);
25
+ result.previous = (0, encodeSummaryArticle_1.default)(prevArticle);
26
+ }
27
+ const articles = article
28
+ .getArticles()
29
+ .map((article) => (0, encodeSummaryArticle_1.default)(article))
30
+ .toJS();
31
+ if (articles.length > 0) {
32
+ result.articles = articles;
32
33
  }
33
34
  }
34
35
  result.content = page.getContent();
@@ -13,7 +13,7 @@ const encodeFile_1 = __importDefault(require("./encodeFile"));
13
13
  function encodeReadme(readme) {
14
14
  const file = readme.getFile();
15
15
  return {
16
- file: encodeFile_1.default(file),
16
+ file: (0, encodeFile_1.default)(file),
17
17
  };
18
18
  }
19
19
  exports.default = encodeReadme;
@@ -15,7 +15,7 @@ function encodeSummary(summary) {
15
15
  const file = summary.getFile();
16
16
  const parts = summary.getParts();
17
17
  return {
18
- file: encodeFile_1.default(file),
18
+ file: (0, encodeFile_1.default)(file),
19
19
  parts: parts.map(encodeSummaryPart_1.default).toJS(),
20
20
  };
21
21
  }
@@ -5,11 +5,18 @@
5
5
  @param {SummaryArticle}
6
6
  @return {Object}
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const encodeSummaryArticleWithCache_1 = __importDefault(require("./encodeSummaryArticleWithCache"));
9
13
  function encodeSummaryArticle(article, recursive) {
10
14
  let articles = undefined;
11
15
  if (recursive !== false) {
12
- articles = article.getArticles().map(encodeSummaryArticle).toJS();
16
+ articles = article
17
+ .getArticles()
18
+ .map((article) => (0, encodeSummaryArticleWithCache_1.default)(article))
19
+ .toJS();
13
20
  }
14
21
  return {
15
22
  title: article.getTitle(),
@@ -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;