umberto 9.4.0 → 10.0.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 (225) hide show
  1. package/CHANGELOG.md +8 -9
  2. package/LICENSE.md +0 -44
  3. package/README.md +0 -1
  4. package/hexo-shim.js +2 -2
  5. package/package.json +2 -9
  6. package/scripts/filter/after-post-render/{gloria.js → gloria.cjs} +3 -3
  7. package/scripts/filter/after-post-render/{insert-error-codes.js → insert-error-codes.cjs} +1 -1
  8. package/scripts/filter/after-post-render/{linker.js → linker.cjs} +1 -1
  9. package/scripts/filter/after-post-render/{parseicontag.js → parseicontag.cjs} +1 -1
  10. package/scripts/filter/after-post-render/{snippets.js → snippets.cjs} +2 -2
  11. package/scripts/filter/after-render/{process-svg.js → process-svg.cjs} +3 -3
  12. package/scripts/filter/before-post-render/{add-project-info-to-page.js → add-project-info-to-page.cjs} +2 -2
  13. package/scripts/filter/before-post-render/{add-repo-url.js → add-repo-url.cjs} +4 -4
  14. package/scripts/filter/before-post-render/{code-switcher.js → code-switcher.cjs} +1 -1
  15. package/scripts/filter/before-post-render/{execute-and-insert-function-results.js → execute-and-insert-function-results.cjs} +1 -1
  16. package/scripts/filter/before-post-render/gloria/{add-breadcrumbs-data-to-page.js → add-breadcrumbs-data-to-page.cjs} +4 -4
  17. package/scripts/filter/before-post-render/gloria/{prerender-admonitions.js → prerender-admonitions.cjs} +1 -1
  18. package/scripts/filter/before-post-render/gloria/{prerender-xml-pug-components.js → prerender-xml-pug-components.cjs} +5 -5
  19. package/scripts/filter/before-post-render/gloria/{render-post-render-pug-components.js → render-post-render-pug-components.cjs} +1 -1
  20. package/scripts/filter/before-post-render/{has-own-favicons.js → has-own-favicons.cjs} +1 -1
  21. package/scripts/filter/before-post-render/{infobox.js → infobox.cjs} +1 -1
  22. package/scripts/filter/before-post-render/{insertchangelog.js → insertchangelog.cjs} +1 -1
  23. package/scripts/filter/before-post-render/{replace-macros.js → replace-macros.cjs} +1 -1
  24. package/scripts/helper/{find-main-category-page.js → find-main-category-page.cjs} +1 -1
  25. package/scripts/helper/{normalize-badges.js → normalize-badges.cjs} +1 -1
  26. package/scripts/helper/{parse-href.js → parse-href.cjs} +1 -1
  27. package/scripts/helper/{u-capitalize.js → u-capitalize.cjs} +1 -1
  28. package/scripts/helper/{u-random-id.js → u-random-id.cjs} +1 -1
  29. package/scripts/helper/{u-remove-indentation.js → u-remove-indentation.cjs} +1 -1
  30. package/scripts/helper/{u-toc.js → u-toc.cjs} +1 -1
  31. package/scripts/utils/{concat-url-parts.js → concat-url-parts.cjs} +3 -3
  32. package/scripts/utils/{execute-and-insert-function-results.js → execute-and-insert-function-results.cjs} +7 -0
  33. package/scripts/utils/gloria-after-post-render/{append-copy-heading-buttons.js → append-copy-heading-buttons.cjs} +33 -16
  34. package/scripts/utils/{has-own-favicons.js → has-own-favicons.cjs} +6 -0
  35. package/scripts/utils/{inline-svg.js → inline-svg.cjs} +2 -2
  36. package/scripts/utils/{logcrossprojectreference.js → logcrossprojectreference.cjs} +6 -0
  37. package/scripts/utils/{parse-href.js → parse-href.cjs} +1 -1
  38. package/scripts/utils/{parseicontag.js → parseicontag.cjs} +7 -1
  39. package/scripts/utils/{parselinks.js → parselinks.cjs} +14 -6
  40. package/scripts/utils/pug-renderer/{create-prerender-pug-template.js → create-prerender-pug-template.cjs} +3 -3
  41. package/scripts/utils/pug-renderer/{render-pug-component.js → render-pug-component.cjs} +4 -4
  42. package/scripts/utils/pug-to-xml-binding/parser/{xml-components-parser.js → xml-components-parser.cjs} +2 -2
  43. package/scripts/utils/pug-to-xml-binding/{render-xml-pug-components-in-markdown.js → render-xml-pug-components-in-markdown.cjs} +3 -3
  44. package/scripts/utils/pug-to-xml-binding/{transform-xml-tree-to-pug.js → transform-xml-tree-to-pug.cjs} +1 -1
  45. package/scripts/utils/{spritesheet-svg.js → spritesheet-svg.cjs} +2 -2
  46. package/scripts/utils/{transform-markdown-admonitions.js → transform-markdown-admonitions.cjs} +1 -1
  47. package/src/api-builder/api-builder.js +28 -30
  48. package/src/api-builder/build-page-worker.js +9 -9
  49. package/src/api-builder/classes/description-parser.js +12 -14
  50. package/src/api-builder/classes/doc-data-factory.js +3 -5
  51. package/src/api-builder/classes/file-name-manager.js +2 -4
  52. package/src/api-builder/classes/html-file.js +2 -4
  53. package/src/api-builder/classes/navigation-tree.js +6 -8
  54. package/src/api-builder/classes/tree-node.js +1 -3
  55. package/src/api-builder/utils/findtargetdoclet.js +1 -3
  56. package/src/api-builder/utils/utils.js +19 -26
  57. package/src/data-converter/converters/jsdoc2umberto.js +2 -4
  58. package/src/data-converter/converters/jsduck2umberto.js +5 -7
  59. package/src/data-converter/converters/typedoc/abstractparser.js +3 -5
  60. package/src/data-converter/converters/typedoc/accessorparser.js +3 -5
  61. package/src/data-converter/converters/typedoc/classparser.js +3 -5
  62. package/src/data-converter/converters/typedoc/computedpropertyparser.js +3 -5
  63. package/src/data-converter/converters/typedoc/constantparser.js +3 -5
  64. package/src/data-converter/converters/typedoc/constructorparser.js +3 -5
  65. package/src/data-converter/converters/typedoc/errorparser.js +2 -4
  66. package/src/data-converter/converters/typedoc/eventparser.js +2 -4
  67. package/src/data-converter/converters/typedoc/functionparser.js +3 -5
  68. package/src/data-converter/converters/typedoc/interfaceparser.js +3 -5
  69. package/src/data-converter/converters/typedoc/methodparser.js +3 -5
  70. package/src/data-converter/converters/typedoc/moduleparser.js +3 -5
  71. package/src/data-converter/converters/typedoc/propertyparser.js +3 -5
  72. package/src/data-converter/converters/typedoc/referenceparser.js +3 -5
  73. package/src/data-converter/converters/typedoc/reflectionkind.js +24 -26
  74. package/src/data-converter/converters/typedoc/typedocconverter.js +3 -7
  75. package/src/data-converter/converters/typedoc/typeparser.js +3 -5
  76. package/src/data-converter/converters/typedoc2umberto.js +17 -19
  77. package/src/data-converter/data-collection.js +2 -5
  78. package/src/data-converter/data-provider.js +6 -8
  79. package/src/data-converter/doclet-collection.js +1 -4
  80. package/src/data-converter/middlewares/relation-fixer.js +3 -5
  81. package/src/helpers/capitalize.js +1 -3
  82. package/src/helpers/create-filtering-data-attribs.js +1 -3
  83. package/src/helpers/doc-formats.js +1 -3
  84. package/src/helpers/escape-longname.js +1 -3
  85. package/src/helpers/extract-longname.js +1 -3
  86. package/src/helpers/get-api-infobox-tooltip.js +3 -5
  87. package/src/helpers/get-docsearch-config.js +8 -6
  88. package/src/helpers/get-file-patterns-to-process.js +1 -3
  89. package/src/helpers/get-short-module-path.js +2 -4
  90. package/src/helpers/github-url.js +96 -103
  91. package/src/helpers/glob-to-regexp.js +3 -5
  92. package/src/helpers/html-safe.js +1 -3
  93. package/src/helpers/import-module.js +3 -5
  94. package/src/helpers/is-non-empty-array.js +1 -3
  95. package/src/helpers/log-with-time.js +2 -4
  96. package/src/helpers/resolve-path.js +5 -3
  97. package/src/helpers/snippets.js +50 -56
  98. package/src/helpers/split-longname.js +2 -4
  99. package/src/helpers/umberto-version.js +10 -0
  100. package/src/hexo/filter/extend-config.js +1 -3
  101. package/src/hexo/filter/project-locals.js +5 -7
  102. package/src/hexo/get-repo-urls.js +5 -6
  103. package/src/hexo/helper/get-page-group.js +1 -3
  104. package/src/hexo/project-globals.js +4 -6
  105. package/src/hexo-manager.js +12 -13
  106. package/src/index.js +28 -32
  107. package/src/sdk-builder/get-sdk-sources.js +11 -13
  108. package/src/sdk-builder/sdk-builder.js +11 -11
  109. package/src/tasks/build-api-docs.js +7 -9
  110. package/src/tasks/build-documentation.js +30 -31
  111. package/src/tasks/build-sdk.js +5 -5
  112. package/src/tasks/build-snippets.js +3 -5
  113. package/src/tasks/cache-files.js +4 -6
  114. package/src/tasks/compile-sass.js +8 -9
  115. package/src/tasks/copy-assets.js +3 -5
  116. package/src/tasks/copy-files.js +5 -7
  117. package/src/tasks/copy-project-docs.js +5 -7
  118. package/src/tasks/copy-project-icons.js +5 -7
  119. package/src/tasks/create-redirect-page.js +3 -5
  120. package/src/tasks/create-sitemap-index.js +3 -3
  121. package/src/tasks/create-sitemap-step.js +4 -4
  122. package/src/tasks/create-sitemap.js +6 -8
  123. package/src/tasks/create-sym-links.js +5 -7
  124. package/src/tasks/execute-hooks.js +3 -5
  125. package/src/tasks/get-extra-files.js +3 -5
  126. package/src/tasks/get-hexo-config.js +4 -4
  127. package/src/tasks/get-main-config.js +3 -5
  128. package/src/tasks/get-project-config.js +6 -8
  129. package/src/tasks/macro-replacer.js +1 -3
  130. package/src/tasks/minify-html-worker.js +5 -5
  131. package/src/tasks/minify-html.js +8 -10
  132. package/src/tasks/overwrite-api-guides.js +4 -6
  133. package/src/tasks/read-doc-sources.js +5 -7
  134. package/src/tasks/run-webpack.js +8 -6
  135. package/src/tasks/validate-links-collect-worker.js +6 -6
  136. package/src/tasks/validate-links-worker.js +6 -6
  137. package/src/tasks/validate-links.js +9 -11
  138. package/src/tasks/watcher.js +5 -7
  139. package/src/tasks/write-html-files.js +3 -5
  140. package/src/template/template-collection.js +13 -15
  141. package/themes/umberto/src/gloria/js/app.js +32 -32
  142. package/themes/umberto/src/gloria/js/components/api-nav-tree.js +4 -4
  143. package/themes/umberto/src/gloria/js/components/api-toggle.js +2 -2
  144. package/themes/umberto/src/gloria/js/components/breadcrumbs.js +1 -1
  145. package/themes/umberto/src/gloria/js/components/code-block.js +5 -5
  146. package/themes/umberto/src/gloria/js/components/code-switcher.js +2 -2
  147. package/themes/umberto/src/gloria/js/components/dropdown.js +5 -5
  148. package/themes/umberto/src/gloria/js/components/expandable.js +1 -1
  149. package/themes/umberto/src/gloria/js/components/fake-devtools.js +4 -4
  150. package/themes/umberto/src/gloria/js/components/hash-link.js +2 -2
  151. package/themes/umberto/src/gloria/js/components/heading-link.js +2 -2
  152. package/themes/umberto/src/gloria/js/components/iframe.js +2 -2
  153. package/themes/umberto/src/gloria/js/components/mobile-overlay.js +5 -5
  154. package/themes/umberto/src/gloria/js/components/nav-tree.js +3 -3
  155. package/themes/umberto/src/gloria/js/components/tabs.js +2 -2
  156. package/themes/umberto/src/gloria/js/components/tooltip-popover.js +13 -13
  157. package/themes/umberto/src/gloria/js/helpers/animate-element.js +2 -2
  158. package/themes/umberto/src/gloria/js/helpers/create-anchor-positioning-watcher.js +1 -1
  159. package/themes/umberto/src/gloria/js/helpers/create-keyboard-focus-cycler.js +3 -3
  160. package/themes/umberto/src/gloria/js/helpers/focus-first-interactive.js +2 -2
  161. package/themes/umberto/src/gloria/js/helpers/highlight-code.js +1 -1
  162. package/themes/umberto/src/gloria/js/helpers/scroll-to-hash.js +1 -1
  163. package/themes/umberto/src/gloria/js/helpers/tween.js +2 -2
  164. package/themes/umberto/src/gloria/js/modules/algolia-search.js +4 -4
  165. package/themes/umberto/src/gloria/js/modules/api-filter.js +1 -1
  166. package/themes/umberto/src/gloria/js/modules/header-bar.js +4 -4
  167. package/themes/umberto/src/gloria/js/modules/header.js +2 -2
  168. package/themes/umberto/src/gloria/js/modules/links-prefetch.js +1 -1
  169. package/themes/umberto/src/gloria/js/modules/mobile-nav.js +7 -7
  170. package/themes/umberto/src/gloria/js/modules/sidebar.js +3 -3
  171. package/themes/umberto/src/gloria/js/modules/table-of-contents-api.js +9 -9
  172. package/themes/umberto/src/gloria/js/modules/table-of-contents.js +10 -10
  173. package/themes/umberto/src/gloria/js/public-api.js +15 -15
  174. package/themes/umberto/src/gloria/js/web-components/svg-icon.js +3 -3
  175. package/themes/umberto/src/umberto/js/_apitree.js +1 -1
  176. package/themes/umberto/src/umberto/js/_attachpermalinklistener.js +1 -1
  177. package/themes/umberto/src/umberto/js/_copymobileapinavigation.js +1 -1
  178. package/themes/umberto/src/umberto/js/_imageModal.js +1 -1
  179. package/themes/umberto/src/umberto/js/_pagenavigation.js +1 -1
  180. package/themes/umberto/src/umberto/js/_prism.js +1 -1
  181. package/themes/umberto/src/umberto/js/_samplecode.js +1 -1
  182. package/themes/umberto/src/umberto/js/_sidenavigation.js +1 -1
  183. package/themes/umberto/src/umberto/js/_toc.js +1 -1
  184. package/themes/umberto/src/umberto/js/_warningbanner.js +1 -1
  185. package/themes/umberto/src/umberto/js/app.js +19 -19
  186. package/src/tasks/validate-html-w3c.js +0 -35
  187. /package/scripts/filter/after-post-render/{basepath-replacer.js → basepath-replacer.cjs} +0 -0
  188. /package/scripts/filter/after-post-render/{fix-code-samples.js → fix-code-samples.cjs} +0 -0
  189. /package/scripts/filter/after-post-render/{gather-guides.js → gather-guides.cjs} +0 -0
  190. /package/scripts/filter/after-post-render/{img-linker.js → img-linker.cjs} +0 -0
  191. /package/scripts/filter/after-post-render/{import-guide.js → import-guide.cjs} +0 -0
  192. /package/scripts/filter/after-post-render/{process-variables.js → process-variables.cjs} +0 -0
  193. /package/scripts/filter/after-post-render/{time-end.js → time-end.cjs} +0 -0
  194. /package/scripts/filter/after-post-render/{time-start.js → time-start.cjs} +0 -0
  195. /package/scripts/filter/after-post-render/{validate-after-render.js → validate-after-render.cjs} +0 -0
  196. /package/scripts/filter/before-post-render/{change-output-path.js → change-output-path.cjs} +0 -0
  197. /package/scripts/filter/before-post-render/{set-layout.js → set-layout.cjs} +0 -0
  198. /package/scripts/filter/before-post-render/{validate-page-data.js → validate-page-data.cjs} +0 -0
  199. /package/scripts/helper/{get-pages-for-nav-tree.js → get-pages-for-nav-tree.cjs} +0 -0
  200. /package/scripts/helper/{mark-empty-categories.js → mark-empty-categories.cjs} +0 -0
  201. /package/scripts/helper/{u-extract-and-cache-title.js → u-extract-and-cache-title.cjs} +0 -0
  202. /package/scripts/helper/{u-split-to-title-and-content.js → u-split-to-title-and-content.cjs} +0 -0
  203. /package/scripts/utils/{add-indention.js → add-indention.cjs} +0 -0
  204. /package/scripts/utils/{capitalize.js → capitalize.cjs} +0 -0
  205. /package/scripts/utils/{compose.js → compose.cjs} +0 -0
  206. /package/scripts/utils/{decode-html-entities.js → decode-html-entities.cjs} +0 -0
  207. /package/scripts/utils/{drop-init-slash.js → drop-init-slash.cjs} +0 -0
  208. /package/scripts/utils/{drop-trailing-slash.js → drop-trailing-slash.cjs} +0 -0
  209. /package/scripts/utils/{drop-url-protocol.js → drop-url-protocol.cjs} +0 -0
  210. /package/scripts/utils/{findmaincategorypage.js → findmaincategorypage.cjs} +0 -0
  211. /package/scripts/utils/{getreportissuewidgeturl.js → getreportissuewidgeturl.cjs} +0 -0
  212. /package/scripts/utils/gloria-after-post-render/{apply-design-doc-classes.js → apply-design-doc-classes.cjs} +0 -0
  213. /package/scripts/utils/gloria-after-post-render/{wrap-table-into-wrappers.js → wrap-table-into-wrappers.cjs} +0 -0
  214. /package/scripts/utils/{insertchangelog.js → insertchangelog.cjs} +0 -0
  215. /package/scripts/utils/{measure-call.js → measure-call.cjs} +0 -0
  216. /package/scripts/utils/{normalizebadges.js → normalizebadges.cjs} +0 -0
  217. /package/scripts/utils/{parser-cursor.js → parser-cursor.cjs} +0 -0
  218. /package/scripts/utils/pug-to-xml-binding/parser/{walk-xml-tree.js → walk-xml-tree.cjs} +0 -0
  219. /package/scripts/utils/{random-id.js → random-id.cjs} +0 -0
  220. /package/scripts/utils/{remove-indentation.js → remove-indentation.cjs} +0 -0
  221. /package/scripts/utils/{shoulddisplaynewindicator.js → shoulddisplaynewindicator.cjs} +0 -0
  222. /package/scripts/utils/{toc.js → toc.cjs} +0 -0
  223. /package/scripts/utils/{transformcodeswitcher.js → transformcodeswitcher.cjs} +0 -0
  224. /package/scripts/utils/{transforminfobox.js → transforminfobox.cjs} +0 -0
  225. /package/scripts/utils/{uniq-by-last.js → uniq-by-last.cjs} +0 -0
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const importModule = require( '../helpers/import-module' );
6
+ import upath from 'upath';
7
+ import { importModule } from '../helpers/import-module.js';
10
8
 
11
9
  /**
12
10
  * This function executes all hooks of the specified type for each config passed in the configs array.
@@ -26,7 +24,7 @@ const importModule = require( '../helpers/import-module' );
26
24
  * @param {'beforeHexo'|'afterHexo'} hookName Name of a hook to execute.
27
25
  * @returns {Promise}
28
26
  */
29
- module.exports = async function executeHooks( configs, hookName ) {
27
+ export async function executeHooks( configs, hookName ) {
30
28
  try {
31
29
  for ( const config of configs ) {
32
30
  if ( !config.hooks || !config.hooks[ hookName ] ) {
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const fs = require( 'fs-extra' );
6
+ import upath from 'upath';
7
+ import fs from 'fs-extra';
10
8
 
11
9
  /**
12
10
  * @param rootPath
@@ -14,7 +12,7 @@ const fs = require( 'fs-extra' );
14
12
  * @param {String|Array} files
15
13
  * @returns {Array}
16
14
  */
17
- module.exports = ( rootPath, dst, files ) => {
15
+ export const getExtraFiles = ( rootPath, dst, files ) => {
18
16
  const filePaths = getFilePaths( files );
19
17
 
20
18
  return filePaths
@@ -3,17 +3,17 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import upath from 'upath';
7
+ import fs from 'node:fs';
7
8
 
8
- const upath = require( 'upath' );
9
- const fs = require( 'node:fs' );
9
+ const __dirname = import.meta.dirname;
10
10
 
11
11
  /**
12
12
  * Reads Umberto's hexo config file.
13
13
  *
14
14
  * @returns {Object}
15
15
  */
16
- module.exports = () => {
16
+ export const getHexoConfig = () => {
17
17
  const defaultConfigPath = upath.join( __dirname, '../../hexo-config.json' );
18
18
  let defaultConfig;
19
19
 
@@ -3,12 +3,10 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import upath from 'upath';
7
+ import fs from 'node:fs';
7
8
 
8
- const upath = require( 'upath' );
9
- const fs = require( 'node:fs' );
10
-
11
- module.exports = rootPath => {
9
+ export const getMainConfig = rootPath => {
12
10
  const configPath = upath.join( rootPath, 'umberto-main.json' );
13
11
  let config;
14
12
 
@@ -3,12 +3,10 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const fs = require( 'node:fs' );
10
- const { globSync } = require( 'glob' );
11
- const importModule = require( '../helpers/import-module' );
6
+ import fs from 'node:fs';
7
+ import upath from 'upath';
8
+ import { globSync } from 'glob';
9
+ import { importModule } from '../helpers/import-module.js';
12
10
 
13
11
  const cache = new Map();
14
12
 
@@ -21,7 +19,7 @@ const cache = new Map();
21
19
  * @param {Boolean} [options.shouldInjectNoIndexMeta] Whether the "do not index" header for bots should be included.
22
20
  * @returns {Promise}
23
21
  */
24
- module.exports = async ( rootPath, options = {} ) => {
22
+ export const getProjectConfig = async ( rootPath, options = {} ) => {
25
23
  // Let's normalize the root path to fix mixed slashes and backslashes. Root path should contain only slashes.
26
24
  rootPath = rootPath.split( /[\\/]/g ).join( '/' );
27
25
 
@@ -333,7 +331,7 @@ function getRepositoryUrl( rootPath ) {
333
331
  */
334
332
  function getPackageJson( rootPath ) {
335
333
  try {
336
- return require( upath.join( rootPath, 'package.json' ) );
334
+ return JSON.parse( fs.readFileSync( upath.join( rootPath, 'package.json' ), 'utf8' ) );
337
335
  } catch {
338
336
  return null;
339
337
  }
@@ -3,9 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- module.exports = ( { fullText, variables, pagePath } = {} ) => {
6
+ export const macroReplacer = ( { fullText, variables, pagePath } = {} ) => {
9
7
  const macros = new Set( fullText.match( /\{%\s?[A-Z_0-9]+?\s?%\}/g ) );
10
8
  let outputText = fullText;
11
9
  if ( !macros.size ) {
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { readFileSync, writeFileSync } = require( 'node:fs' );
9
- const minifier = require( '@minify-html/node' );
6
+ import { readFileSync, writeFileSync } from 'node:fs';
7
+ import minifier from '@minify-html/node';
10
8
 
11
9
  /**
12
10
  * Minifies HTML content.
@@ -14,7 +12,7 @@ const minifier = require( '@minify-html/node' );
14
12
  * @param {string} file - Path to the HTML file to minify.
15
13
  * @returns {void}
16
14
  */
17
- module.exports = function( file ) {
15
+ export const minifyHtmlWorker = function( file ) {
18
16
  const html = readFileSync( file );
19
17
 
20
18
  const minified = minifier.minify( html, {
@@ -31,3 +29,5 @@ module.exports = function( file ) {
31
29
 
32
30
  writeFileSync( file, minified );
33
31
  };
32
+
33
+ export default minifyHtmlWorker;
@@ -3,26 +3,24 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { join } = require( 'node:path' );
9
- const { globSync } = require( 'node:fs' );
10
- const { styleText } = require( 'node:util' );
11
- const { default: TinyPool } = require( 'tinypool' );
12
- const logWithTime = require( '../helpers/log-with-time' );
6
+ import upath from 'upath';
7
+ import { globSync } from 'node:fs';
8
+ import { styleText } from 'node:util';
9
+ import TinyPool from 'tinypool';
10
+ import { logWithTime } from '../helpers/log-with-time.js';
13
11
 
14
12
  /**
15
13
  * Minifies all HTML files under outputDir in parallel using tinypool.
16
14
  *
17
15
  * @param {string} outputDir - base directory to search for *.html files
18
16
  */
19
- module.exports = async function minifyHtml( outputDir ) {
17
+ export async function minifyHtml( outputDir ) {
20
18
  const logTime = logWithTime( 'Minifying HTML' );
21
- const files = globSync( join( outputDir, '**', 'api', '**', '*.html' ) );
19
+ const files = globSync( upath.join( outputDir, '**', 'api', '**', '*.html' ) );
22
20
 
23
21
  const pool = new TinyPool( {
24
22
  runtime: 'child_process',
25
- filename: require.resolve( './minify-html-worker.js' )
23
+ filename: new URL( './minify-html-worker.js', import.meta.url ).pathname
26
24
  } );
27
25
 
28
26
  try {
@@ -3,11 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const { globSync } = require( 'glob' );
10
- const fs = require( 'fs-extra' );
6
+ import upath from 'upath';
7
+ import { globSync } from 'glob';
8
+ import fs from 'fs-extra';
11
9
 
12
10
  /**
13
11
  * Replaces dst files with src files. Used to replace API guides with their cached versions.
@@ -16,7 +14,7 @@ const fs = require( 'fs-extra' );
16
14
  * @param src
17
15
  * @param dst
18
16
  */
19
- module.exports = ( src, dst ) => {
17
+ export const overwriteApiGuides = ( src, dst ) => {
20
18
  const sourcePaths = globSync( upath.join( src, '**', '*' ) ).map( path => upath.normalize( path ) );
21
19
 
22
20
  for ( const p of sourcePaths ) {
@@ -3,12 +3,10 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const fs = require( 'node:fs' );
10
- const { globSync } = require( 'glob' );
11
- const DOC_FORMATS = require( '../helpers/doc-formats' );
6
+ import upath from 'upath';
7
+ import fs from 'node:fs';
8
+ import { globSync } from 'glob';
9
+ import { docFormats as DOC_FORMATS } from '../helpers/doc-formats.js';
12
10
 
13
11
  /**
14
12
  * Reads API data (usually generated by JSDoc) from given sourcePath. This data is used by DataProvider and ApiBuilder.
@@ -17,7 +15,7 @@ const DOC_FORMATS = require( '../helpers/doc-formats' );
17
15
  * @param type
18
16
  * @returns {Array}
19
17
  */
20
- module.exports = ( sourcePath, type ) => {
18
+ export const readDocSources = ( sourcePath, type ) => {
21
19
  const fileNames = globSync( upath.join( sourcePath, `**/*.${ DOC_FORMATS[ type ] }` ) ).map( path => upath.normalize( path ) );
22
20
  const files = [];
23
21
 
@@ -3,12 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import upath from 'upath';
7
+ import { createRequire } from 'node:module';
8
+ import webpack from 'webpack';
7
9
 
8
- const path = require( 'node:path' );
9
- const webpack = require( 'webpack' );
10
+ const require = createRequire( import.meta.url );
10
11
 
11
- module.exports = ( sourceFile, destinationFile, {
12
+ export const runWebpack = ( sourceFile, destinationFile, {
12
13
  minify = true,
13
14
  outputFileName = 'app.js',
14
15
  umbertoDir,
@@ -20,11 +21,11 @@ module.exports = ( sourceFile, destinationFile, {
20
21
 
21
22
  mode: minify ? 'production' : 'development',
22
23
 
23
- entry: path.resolve( sourceFile ),
24
+ entry: upath.resolve( sourceFile ),
24
25
 
25
26
  output: {
26
27
  filename: outputFileName,
27
- path: path.resolve( destinationFile )
28
+ path: upath.resolve( destinationFile )
28
29
  },
29
30
 
30
31
  target: 'web',
@@ -57,6 +58,7 @@ module.exports = ( sourceFile, destinationFile, {
57
58
  presets: [
58
59
  require.resolve( '@babel/preset-env' )
59
60
  ]
61
+
60
62
  }
61
63
  }
62
64
  }
@@ -3,13 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import fs from 'fs-extra';
7
+ import upath from 'upath';
8
+ import { isMaskedID } from '../../scripts/utils/random-id.cjs';
7
9
 
8
- const fs = require( 'fs-extra' );
9
- const upath = require( 'upath' );
10
- const { isMaskedID } = require( '../../scripts/utils/random-id' );
11
-
12
- module.exports = function( { chunk } ) {
10
+ export const validateLinksCollectWorker = function( { chunk } ) {
13
11
  const links = [];
14
12
 
15
13
  for ( const filePath of chunk ) {
@@ -32,3 +30,5 @@ module.exports = function( { chunk } ) {
32
30
 
33
31
  return links;
34
32
  };
33
+
34
+ export default validateLinksCollectWorker;
@@ -3,11 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const fs = require( 'fs-extra' );
9
- const upath = require( 'upath' );
10
- const { parseDocument } = require( 'htmlparser2' );
6
+ import fs from 'fs-extra';
7
+ import upath from 'upath';
8
+ import { parseDocument } from 'htmlparser2';
11
9
 
12
10
  /**
13
11
  * Validates links in the given chunk of files.
@@ -20,7 +18,7 @@ const { parseDocument } = require( 'htmlparser2' );
20
18
  * @param {Object} params.options Validation options.
21
19
  * @returns {Array<Object>}
22
20
  */
23
- module.exports = function( { chunk, links, options } ) {
21
+ export const validateLinksWorker = function( { chunk, links, options } ) {
24
22
  const errors = [];
25
23
 
26
24
  for ( const filePath of chunk ) {
@@ -72,6 +70,8 @@ module.exports = function( { chunk, links, options } ) {
72
70
  return errors;
73
71
  };
74
72
 
73
+ export default validateLinksWorker;
74
+
75
75
  /**
76
76
  * Resolves the target path for the given href relative to the file and public directory.
77
77
  *
@@ -3,20 +3,18 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Script for validating links in generated HTML files.
10
8
  * Uses multiple threads (worker_threads) for parallel analysis, significantly speeding up the build process,
11
9
  * especially for API documentation where the number of links can reach thousands.
12
10
  */
13
11
 
14
- const { styleText } = require( 'node:util' );
15
- const fs = require( 'fs-extra' );
16
- const upath = require( 'upath' );
17
- const { globSync } = require( 'glob' );
18
- const { default: TinyPool } = require( 'tinypool' );
19
- const logWithTime = require( '../helpers/log-with-time' );
12
+ import { styleText } from 'node:util';
13
+ import fs from 'fs-extra';
14
+ import upath from 'upath';
15
+ import { globSync } from 'glob';
16
+ import TinyPool from 'tinypool';
17
+ import { logWithTime } from '../helpers/log-with-time.js';
20
18
 
21
19
  /**
22
20
  * Collects all links from the provided HTML files.
@@ -55,7 +53,7 @@ async function collectLinks( pattern, options ) {
55
53
  } );
56
54
 
57
55
  const pool = new TinyPool( {
58
- filename: require.resolve( './validate-links-collect-worker.js' )
56
+ filename: new URL( './validate-links-collect-worker.js', import.meta.url ).pathname
59
57
  } );
60
58
 
61
59
  try {
@@ -82,12 +80,12 @@ async function collectLinks( pattern, options ) {
82
80
  * @param {Object} [options={}] Validation options.
83
81
  * @returns {Promise<boolean>} True if no errors were found, false otherwise.
84
82
  */
85
- module.exports = async function validateLinks( buildPath, options = {} ) {
83
+ export async function validateLinks( buildPath, options = {} ) {
86
84
  const logGatheringTime = logWithTime( 'Gathering links to validate' );
87
85
 
88
86
  const { links, pathsToFiles } = await collectLinks( upath.join( buildPath, '**', '*' ), options );
89
87
  const pool = new TinyPool( {
90
- filename: require.resolve( './validate-links-worker.js' )
88
+ filename: new URL( './validate-links-worker.js', import.meta.url ).pathname
91
89
  } );
92
90
 
93
91
  logGatheringTime();
@@ -3,14 +3,12 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import { styleText } from 'node:util';
7
+ import upath from 'upath';
8
+ import chokidar from 'chokidar';
9
+ import { copy } from 'fs-extra';
7
10
 
8
- const { styleText } = require( 'node:util' );
9
- const upath = require( 'upath' );
10
- const chokidar = require( 'chokidar' );
11
- const { copy } = require( 'fs-extra' );
12
-
13
- module.exports = function watchMd( hexoManager ) {
11
+ export function watchMd( hexoManager ) {
14
12
  console.log( styleText( 'yellow', 'Umberto is in watch mode – press CTRL+C to exit.' ) );
15
13
 
16
14
  for ( const { originPath, dstPath } of hexoManager.getOriginPaths() ) {
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const fs = require( 'fs-extra' );
9
- const upath = require( 'upath' );
6
+ import fs from 'fs-extra';
7
+ import upath from 'upath';
10
8
 
11
9
  /**
12
10
  * Saves .html files to file system.
@@ -15,7 +13,7 @@ const upath = require( 'upath' );
15
13
  * @param {String} destinationDir Additional destination path. Additional because files already have its own path.
16
14
  * @returns {Promise<void>}
17
15
  */
18
- module.exports = async ( files, destinationDir = '.' ) => {
16
+ export const writeHtmlFiles = async ( files, destinationDir = '.' ) => {
19
17
  const writePromises = files.map( file =>
20
18
  fs.outputFile(
21
19
  upath.join( destinationDir, file.dirname, file.basename ),
@@ -3,24 +3,22 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const pug = require( 'pug' );
9
- const fs = require( 'node:fs' );
10
- const upath = require( 'upath' );
11
- const isNonEmptyArray = require( '../helpers/is-non-empty-array' );
12
- const createFilterAttribs = require( '../helpers/create-filtering-data-attribs' );
13
- const htmlsafe = require( '../helpers/html-safe' );
14
- const splitLongname = require( '../helpers/split-longname' );
15
- const extractLongname = require( '../helpers/extract-longname' );
16
- const getApiInfoboxTooltip = require( '../helpers/get-api-infobox-tooltip' );
17
- const capitalize = require( '../helpers/capitalize' );
18
- const relative_url = require( 'hexo/dist/plugins/helper/relative_url' ); // eslint-disable-line camelcase
6
+ import pug from 'pug';
7
+ import fs from 'node:fs';
8
+ import upath from 'upath';
9
+ import { isNonEmptyArray } from '../helpers/is-non-empty-array.js';
10
+ import { createFilteringDataAttribs as createFilterAttribs } from '../helpers/create-filtering-data-attribs.js';
11
+ import { htmlSafe as htmlsafe } from '../helpers/html-safe.js';
12
+ import { splitLongname } from '../helpers/split-longname.js';
13
+ import { extractLongname } from '../helpers/extract-longname.js';
14
+ import { getApiInfoboxTooltip } from '../helpers/get-api-infobox-tooltip.js';
15
+ import { capitalize } from '../helpers/capitalize.js';
16
+ import relativeUrl from 'hexo/dist/plugins/helper/relative_url.js';
19
17
 
20
18
  /**
21
19
  * Provides pug templates and adds various helpers to them.
22
20
  */
23
- module.exports = class TemplateCollection {
21
+ export class TemplateCollection {
24
22
  /**
25
23
  * @param {String} templatePath Path to template files.
26
24
  * @param {Boolean} pretty Whether to prettify template output or not.
@@ -96,7 +94,7 @@ module.exports = class TemplateCollection {
96
94
  extractLongname,
97
95
  getApiInfoboxTooltip,
98
96
  capitalize,
99
- relative_url // eslint-disable-line camelcase
97
+ relative_url: relativeUrl
100
98
  },
101
99
  this._helpers,
102
100
  this._locals
@@ -3,38 +3,38 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { afterDomReady } from './helpers/after-dom-ready';
7
-
8
- import { Dropdown } from './components/dropdown';
9
- import { MobileOverlay } from './components/mobile-overlay';
10
- import { TableOfContents } from './modules/table-of-contents';
11
- import { ApiTableOfContents } from './modules/table-of-contents-api';
12
- import { ApiFilter } from './modules/api-filter';
13
- import { MobileNav } from './modules/mobile-nav';
14
- import { LinksPrefetch } from './modules/links-prefetch';
15
- import { Header } from './modules/header';
16
- import { HeaderBar } from './modules/header-bar';
17
- import { HashLink } from './components/hash-link';
18
- import { Sidebar } from './modules/sidebar';
19
- import { NavTree } from './components/nav-tree';
20
- import { ApiNavTree } from './components/api-nav-tree';
21
- import { ApiToggle } from './components/api-toggle';
22
- import { Tabs } from './components/tabs';
23
- import { Breadcrumbs } from './components/breadcrumbs';
24
- import { AlgoliaSearch } from './modules/algolia-search';
25
- import { HeadingLink } from './components/heading-link';
26
- import { TooltipPopover } from './components/tooltip-popover';
27
- import { imageZoom } from './components/image-zoom';
28
- import { Expandable } from './components/expandable';
29
- import { CodeSwitcher } from './components/code-switcher';
30
- import { CodeBlock } from './components/code-block';
31
- import { FakeDevtools } from './components/fake-devtools';
32
- import { IFrame } from './components/iframe';
33
-
34
- import { isMobile } from './helpers/is-mobile';
35
-
36
- import './web-components/svg-icon';
37
- import './public-api';
6
+ import { afterDomReady } from './helpers/after-dom-ready.js';
7
+
8
+ import { Dropdown } from './components/dropdown.js';
9
+ import { MobileOverlay } from './components/mobile-overlay.js';
10
+ import { TableOfContents } from './modules/table-of-contents.js';
11
+ import { ApiTableOfContents } from './modules/table-of-contents-api.js';
12
+ import { ApiFilter } from './modules/api-filter.js';
13
+ import { MobileNav } from './modules/mobile-nav.js';
14
+ import { LinksPrefetch } from './modules/links-prefetch.js';
15
+ import { Header } from './modules/header.js';
16
+ import { HeaderBar } from './modules/header-bar.js';
17
+ import { HashLink } from './components/hash-link.js';
18
+ import { Sidebar } from './modules/sidebar.js';
19
+ import { NavTree } from './components/nav-tree.js';
20
+ import { ApiNavTree } from './components/api-nav-tree.js';
21
+ import { ApiToggle } from './components/api-toggle.js';
22
+ import { Tabs } from './components/tabs.js';
23
+ import { Breadcrumbs } from './components/breadcrumbs.js';
24
+ import { AlgoliaSearch } from './modules/algolia-search.js';
25
+ import { HeadingLink } from './components/heading-link.js';
26
+ import { TooltipPopover } from './components/tooltip-popover.js';
27
+ import { imageZoom } from './components/image-zoom.js';
28
+ import { Expandable } from './components/expandable.js';
29
+ import { CodeSwitcher } from './components/code-switcher.js';
30
+ import { CodeBlock } from './components/code-block.js';
31
+ import { FakeDevtools } from './components/fake-devtools.js';
32
+ import { IFrame } from './components/iframe.js';
33
+
34
+ import { isMobile } from './helpers/is-mobile.js';
35
+
36
+ import './web-components/svg-icon.js';
37
+ import './public-api.js';
38
38
 
39
39
  const safeAttach = ( component, name ) => {
40
40
  try {
@@ -3,10 +3,10 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from '../components/base-component';
7
- import { toggleHeight } from '../helpers/toggle-height';
8
- import { getParentsUntil } from '../helpers/get-parents-until';
9
- import { onMobileOverlayStateChange } from '../components/mobile-overlay';
6
+ import { BaseComponent } from '../components/base-component.js';
7
+ import { toggleHeight } from '../helpers/toggle-height.js';
8
+ import { getParentsUntil } from '../helpers/get-parents-until.js';
9
+ import { onMobileOverlayStateChange } from '../components/mobile-overlay.js';
10
10
 
11
11
  export class ApiNavTree extends BaseComponent {
12
12
  /**
@@ -3,8 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from './base-component';
7
- import { toggleHeight } from '../helpers/toggle-height';
6
+ import { BaseComponent } from './base-component.js';
7
+ import { toggleHeight } from '../helpers/toggle-height.js';
8
8
 
9
9
  // .js-api-collapsing-button
10
10
 
@@ -3,7 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from './base-component';
6
+ import { BaseComponent } from './base-component.js';
7
7
 
8
8
  /**
9
9
  * Component responsible for handling breadcrumbs overflow and scroll behavior.
@@ -3,11 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from './base-component';
7
- import { highlightCode } from '../helpers/highlight-code';
8
- import { findCodeLang } from '../helpers/find-code-lang';
9
- import { copyToClipboard } from '../helpers/copy-to-clipboard';
10
- import { decodeHtmlEntities } from '../helpers/decode-html-entities';
6
+ import { BaseComponent } from './base-component.js';
7
+ import { highlightCode } from '../helpers/highlight-code.js';
8
+ import { findCodeLang } from '../helpers/find-code-lang.js';
9
+ import { copyToClipboard } from '../helpers/copy-to-clipboard.js';
10
+ import { decodeHtmlEntities } from '../helpers/decode-html-entities.js';
11
11
 
12
12
  /**
13
13
  * Component for managing code block highlighting.
@@ -3,8 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from './base-component';
7
- import { onTabActivation, activateTab } from './tabs';
6
+ import { BaseComponent } from './base-component.js';
7
+ import { onTabActivation, activateTab } from './tabs.js';
8
8
 
9
9
  /**
10
10
  * A component that handles switching between different installation code examples.
@@ -3,11 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- import { BaseComponent } from './base-component';
7
- import { createOutsideClickWatcher } from '../helpers/create-outside-click-watcher';
8
- import { createKeyboardFocusCycler, getVerticalKeysMap } from '../helpers/create-keyboard-focus-cycler';
9
- import { createKeyboardBlurWatcher } from '../helpers/create-keyboard-blur-watcher';
10
- import { onEscapeKeyPress } from '../helpers/escape-handler';
6
+ import { BaseComponent } from './base-component.js';
7
+ import { createOutsideClickWatcher } from '../helpers/create-outside-click-watcher.js';
8
+ import { createKeyboardFocusCycler, getVerticalKeysMap } from '../helpers/create-keyboard-focus-cycler.js';
9
+ import { createKeyboardBlurWatcher } from '../helpers/create-keyboard-blur-watcher.js';
10
+ import { onEscapeKeyPress } from '../helpers/escape-handler.js';
11
11
 
12
12
  /**
13
13
  * A dropdown component that manages togglable dropdown menus with automatic positioning.