umberto 9.4.0 → 10.1.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 (229) hide show
  1. package/CHANGELOG.md +20 -20
  2. package/LICENSE.md +0 -44
  3. package/README.md +0 -1
  4. package/hexo-config.json +2 -1
  5. package/hexo-shim.js +2 -2
  6. package/package.json +4 -11
  7. package/scripts/filter/after-post-render/{gloria.js → gloria.cjs} +3 -3
  8. package/scripts/filter/after-post-render/{insert-error-codes.js → insert-error-codes.cjs} +1 -1
  9. package/scripts/filter/after-post-render/{linker.js → linker.cjs} +1 -1
  10. package/scripts/filter/after-post-render/{parseicontag.js → parseicontag.cjs} +1 -1
  11. package/scripts/filter/after-post-render/{snippets.js → snippets.cjs} +2 -2
  12. package/scripts/filter/after-render/{process-svg.js → process-svg.cjs} +3 -3
  13. package/scripts/filter/before-post-render/{add-project-info-to-page.js → add-project-info-to-page.cjs} +2 -2
  14. package/scripts/filter/before-post-render/{add-repo-url.js → add-repo-url.cjs} +4 -4
  15. package/scripts/filter/before-post-render/{code-switcher.js → code-switcher.cjs} +1 -1
  16. package/scripts/filter/before-post-render/{execute-and-insert-function-results.js → execute-and-insert-function-results.cjs} +1 -1
  17. package/scripts/filter/before-post-render/gloria/{add-breadcrumbs-data-to-page.js → add-breadcrumbs-data-to-page.cjs} +4 -4
  18. package/scripts/filter/before-post-render/gloria/{prerender-admonitions.js → prerender-admonitions.cjs} +1 -1
  19. package/scripts/filter/before-post-render/gloria/{prerender-xml-pug-components.js → prerender-xml-pug-components.cjs} +7 -6
  20. package/scripts/filter/before-post-render/gloria/{render-post-render-pug-components.js → render-post-render-pug-components.cjs} +1 -1
  21. package/scripts/filter/before-post-render/{has-own-favicons.js → has-own-favicons.cjs} +1 -1
  22. package/scripts/filter/before-post-render/{infobox.js → infobox.cjs} +1 -1
  23. package/scripts/filter/before-post-render/{insertchangelog.js → insertchangelog.cjs} +1 -1
  24. package/scripts/filter/before-post-render/{replace-macros.js → replace-macros.cjs} +1 -1
  25. package/scripts/helper/{find-main-category-page.js → find-main-category-page.cjs} +1 -1
  26. package/scripts/helper/{normalize-badges.js → normalize-badges.cjs} +1 -1
  27. package/scripts/helper/{parse-href.js → parse-href.cjs} +1 -1
  28. package/scripts/helper/{u-capitalize.js → u-capitalize.cjs} +1 -1
  29. package/scripts/helper/{u-random-id.js → u-random-id.cjs} +1 -1
  30. package/scripts/helper/{u-remove-indentation.js → u-remove-indentation.cjs} +1 -1
  31. package/scripts/helper/{u-toc.js → u-toc.cjs} +1 -1
  32. package/scripts/utils/{concat-url-parts.js → concat-url-parts.cjs} +3 -3
  33. package/scripts/utils/{execute-and-insert-function-results.js → execute-and-insert-function-results.cjs} +7 -0
  34. package/scripts/utils/gloria-after-post-render/{append-copy-heading-buttons.js → append-copy-heading-buttons.cjs} +33 -16
  35. package/scripts/utils/{has-own-favicons.js → has-own-favicons.cjs} +6 -0
  36. package/scripts/utils/{inline-svg.js → inline-svg.cjs} +2 -2
  37. package/scripts/utils/{logcrossprojectreference.js → logcrossprojectreference.cjs} +6 -0
  38. package/scripts/utils/{normalizebadges.js → normalizebadges.cjs} +4 -0
  39. package/scripts/utils/{parse-href.js → parse-href.cjs} +1 -1
  40. package/scripts/utils/{parseicontag.js → parseicontag.cjs} +7 -1
  41. package/scripts/utils/{parselinks.js → parselinks.cjs} +14 -6
  42. package/scripts/utils/pug-renderer/{create-prerender-pug-template.js → create-prerender-pug-template.cjs} +3 -3
  43. package/scripts/utils/pug-renderer/{render-pug-component.js → render-pug-component.cjs} +4 -4
  44. package/scripts/utils/pug-to-xml-binding/parser/{xml-components-parser.js → xml-components-parser.cjs} +2 -2
  45. package/scripts/utils/pug-to-xml-binding/{render-xml-pug-components-in-markdown.js → render-xml-pug-components-in-markdown.cjs} +3 -3
  46. package/scripts/utils/pug-to-xml-binding/{transform-xml-tree-to-pug.js → transform-xml-tree-to-pug.cjs} +1 -1
  47. package/scripts/utils/{spritesheet-svg.js → spritesheet-svg.cjs} +2 -2
  48. package/scripts/utils/{transform-markdown-admonitions.js → transform-markdown-admonitions.cjs} +1 -1
  49. package/src/api-builder/api-builder.js +28 -30
  50. package/src/api-builder/build-page-worker.js +9 -9
  51. package/src/api-builder/classes/description-parser.js +12 -14
  52. package/src/api-builder/classes/doc-data-factory.js +3 -5
  53. package/src/api-builder/classes/file-name-manager.js +2 -4
  54. package/src/api-builder/classes/html-file.js +2 -4
  55. package/src/api-builder/classes/navigation-tree.js +6 -8
  56. package/src/api-builder/classes/tree-node.js +1 -3
  57. package/src/api-builder/utils/findtargetdoclet.js +1 -3
  58. package/src/api-builder/utils/utils.js +19 -26
  59. package/src/data-converter/converters/jsdoc2umberto.js +2 -4
  60. package/src/data-converter/converters/jsduck2umberto.js +5 -7
  61. package/src/data-converter/converters/typedoc/abstractparser.js +3 -5
  62. package/src/data-converter/converters/typedoc/accessorparser.js +3 -5
  63. package/src/data-converter/converters/typedoc/classparser.js +3 -5
  64. package/src/data-converter/converters/typedoc/computedpropertyparser.js +3 -5
  65. package/src/data-converter/converters/typedoc/constantparser.js +3 -5
  66. package/src/data-converter/converters/typedoc/constructorparser.js +3 -5
  67. package/src/data-converter/converters/typedoc/errorparser.js +2 -4
  68. package/src/data-converter/converters/typedoc/eventparser.js +2 -4
  69. package/src/data-converter/converters/typedoc/functionparser.js +3 -5
  70. package/src/data-converter/converters/typedoc/interfaceparser.js +3 -5
  71. package/src/data-converter/converters/typedoc/methodparser.js +3 -5
  72. package/src/data-converter/converters/typedoc/moduleparser.js +3 -5
  73. package/src/data-converter/converters/typedoc/propertyparser.js +3 -5
  74. package/src/data-converter/converters/typedoc/referenceparser.js +3 -5
  75. package/src/data-converter/converters/typedoc/reflectionkind.js +24 -26
  76. package/src/data-converter/converters/typedoc/typedocconverter.js +3 -7
  77. package/src/data-converter/converters/typedoc/typeparser.js +3 -5
  78. package/src/data-converter/converters/typedoc2umberto.js +17 -19
  79. package/src/data-converter/data-collection.js +2 -5
  80. package/src/data-converter/data-provider.js +6 -8
  81. package/src/data-converter/doclet-collection.js +1 -4
  82. package/src/data-converter/middlewares/relation-fixer.js +3 -5
  83. package/src/helpers/capitalize.js +1 -3
  84. package/src/helpers/create-filtering-data-attribs.js +1 -3
  85. package/src/helpers/doc-formats.js +1 -3
  86. package/src/helpers/escape-longname.js +1 -3
  87. package/src/helpers/extract-longname.js +1 -3
  88. package/src/helpers/get-api-infobox-tooltip.js +3 -5
  89. package/src/helpers/get-docsearch-config.js +8 -6
  90. package/src/helpers/get-file-patterns-to-process.js +1 -3
  91. package/src/helpers/get-short-module-path.js +2 -4
  92. package/src/helpers/github-url.js +96 -103
  93. package/src/helpers/glob-to-regexp.js +3 -5
  94. package/src/helpers/html-safe.js +1 -3
  95. package/src/helpers/import-module.js +3 -5
  96. package/src/helpers/is-non-empty-array.js +1 -3
  97. package/src/helpers/log-with-time.js +2 -4
  98. package/src/helpers/resolve-path.js +5 -3
  99. package/src/helpers/snippets.js +50 -56
  100. package/src/helpers/split-longname.js +2 -4
  101. package/src/helpers/umberto-version.js +10 -0
  102. package/src/hexo/filter/extend-config.js +1 -3
  103. package/src/hexo/filter/project-locals.js +5 -7
  104. package/src/hexo/get-repo-urls.js +5 -6
  105. package/src/hexo/helper/get-page-group.js +1 -3
  106. package/src/hexo/project-globals.js +4 -6
  107. package/src/hexo-manager.js +12 -13
  108. package/src/index.js +28 -32
  109. package/src/sdk-builder/get-sdk-sources.js +11 -13
  110. package/src/sdk-builder/sdk-builder.js +11 -11
  111. package/src/tasks/build-api-docs.js +7 -9
  112. package/src/tasks/build-documentation.js +30 -31
  113. package/src/tasks/build-sdk.js +5 -5
  114. package/src/tasks/build-snippets.js +3 -5
  115. package/src/tasks/cache-files.js +4 -6
  116. package/src/tasks/compile-sass.js +8 -9
  117. package/src/tasks/copy-assets.js +3 -5
  118. package/src/tasks/copy-files.js +5 -7
  119. package/src/tasks/copy-project-docs.js +5 -7
  120. package/src/tasks/copy-project-icons.js +5 -7
  121. package/src/tasks/create-redirect-page.js +3 -5
  122. package/src/tasks/create-sitemap-index.js +3 -3
  123. package/src/tasks/create-sitemap-step.js +4 -4
  124. package/src/tasks/create-sitemap.js +6 -8
  125. package/src/tasks/create-sym-links.js +5 -7
  126. package/src/tasks/execute-hooks.js +3 -5
  127. package/src/tasks/get-extra-files.js +3 -5
  128. package/src/tasks/get-hexo-config.js +4 -4
  129. package/src/tasks/get-main-config.js +3 -5
  130. package/src/tasks/get-project-config.js +6 -8
  131. package/src/tasks/macro-replacer.js +1 -3
  132. package/src/tasks/minify-html-worker.js +5 -5
  133. package/src/tasks/minify-html.js +8 -10
  134. package/src/tasks/overwrite-api-guides.js +4 -6
  135. package/src/tasks/read-doc-sources.js +5 -7
  136. package/src/tasks/run-webpack.js +8 -6
  137. package/src/tasks/validate-links-collect-worker.js +6 -6
  138. package/src/tasks/validate-links-worker.js +6 -6
  139. package/src/tasks/validate-links.js +9 -11
  140. package/src/tasks/watcher.js +5 -7
  141. package/src/tasks/write-html-files.js +3 -5
  142. package/src/template/template-collection.js +13 -15
  143. package/themes/umberto/layout/gloria/_components/callout/_style.scss +4 -0
  144. package/themes/umberto/layout/gloria/_components/callout/index.pug +6 -0
  145. package/themes/umberto/src/gloria/css/a11y/_mixins.scss +5 -1
  146. package/themes/umberto/src/gloria/js/app.js +32 -32
  147. package/themes/umberto/src/gloria/js/components/api-nav-tree.js +4 -4
  148. package/themes/umberto/src/gloria/js/components/api-toggle.js +2 -2
  149. package/themes/umberto/src/gloria/js/components/breadcrumbs.js +1 -1
  150. package/themes/umberto/src/gloria/js/components/code-block.js +5 -5
  151. package/themes/umberto/src/gloria/js/components/code-switcher.js +2 -2
  152. package/themes/umberto/src/gloria/js/components/dropdown.js +5 -5
  153. package/themes/umberto/src/gloria/js/components/expandable.js +1 -1
  154. package/themes/umberto/src/gloria/js/components/fake-devtools.js +4 -4
  155. package/themes/umberto/src/gloria/js/components/hash-link.js +2 -2
  156. package/themes/umberto/src/gloria/js/components/heading-link.js +2 -2
  157. package/themes/umberto/src/gloria/js/components/iframe.js +2 -2
  158. package/themes/umberto/src/gloria/js/components/mobile-overlay.js +5 -5
  159. package/themes/umberto/src/gloria/js/components/nav-tree.js +3 -3
  160. package/themes/umberto/src/gloria/js/components/tabs.js +2 -2
  161. package/themes/umberto/src/gloria/js/components/tooltip-popover.js +13 -13
  162. package/themes/umberto/src/gloria/js/helpers/animate-element.js +2 -2
  163. package/themes/umberto/src/gloria/js/helpers/create-anchor-positioning-watcher.js +1 -1
  164. package/themes/umberto/src/gloria/js/helpers/create-keyboard-focus-cycler.js +3 -3
  165. package/themes/umberto/src/gloria/js/helpers/focus-first-interactive.js +2 -2
  166. package/themes/umberto/src/gloria/js/helpers/highlight-code.js +1 -1
  167. package/themes/umberto/src/gloria/js/helpers/scroll-to-hash.js +1 -1
  168. package/themes/umberto/src/gloria/js/helpers/tween.js +2 -2
  169. package/themes/umberto/src/gloria/js/modules/algolia-search.js +4 -4
  170. package/themes/umberto/src/gloria/js/modules/api-filter.js +1 -1
  171. package/themes/umberto/src/gloria/js/modules/header-bar.js +4 -4
  172. package/themes/umberto/src/gloria/js/modules/header.js +2 -2
  173. package/themes/umberto/src/gloria/js/modules/links-prefetch.js +1 -1
  174. package/themes/umberto/src/gloria/js/modules/mobile-nav.js +7 -7
  175. package/themes/umberto/src/gloria/js/modules/sidebar.js +3 -3
  176. package/themes/umberto/src/gloria/js/modules/table-of-contents-api.js +9 -9
  177. package/themes/umberto/src/gloria/js/modules/table-of-contents.js +10 -10
  178. package/themes/umberto/src/gloria/js/public-api.js +15 -15
  179. package/themes/umberto/src/gloria/js/web-components/svg-icon.js +3 -3
  180. package/themes/umberto/src/umberto/js/_apitree.js +1 -1
  181. package/themes/umberto/src/umberto/js/_attachpermalinklistener.js +1 -1
  182. package/themes/umberto/src/umberto/js/_copymobileapinavigation.js +1 -1
  183. package/themes/umberto/src/umberto/js/_imageModal.js +1 -1
  184. package/themes/umberto/src/umberto/js/_pagenavigation.js +1 -1
  185. package/themes/umberto/src/umberto/js/_prism.js +1 -1
  186. package/themes/umberto/src/umberto/js/_samplecode.js +1 -1
  187. package/themes/umberto/src/umberto/js/_sidenavigation.js +1 -1
  188. package/themes/umberto/src/umberto/js/_toc.js +1 -1
  189. package/themes/umberto/src/umberto/js/_warningbanner.js +1 -1
  190. package/themes/umberto/src/umberto/js/app.js +19 -19
  191. package/src/tasks/validate-html-w3c.js +0 -35
  192. /package/scripts/filter/after-post-render/{basepath-replacer.js → basepath-replacer.cjs} +0 -0
  193. /package/scripts/filter/after-post-render/{fix-code-samples.js → fix-code-samples.cjs} +0 -0
  194. /package/scripts/filter/after-post-render/{gather-guides.js → gather-guides.cjs} +0 -0
  195. /package/scripts/filter/after-post-render/{img-linker.js → img-linker.cjs} +0 -0
  196. /package/scripts/filter/after-post-render/{import-guide.js → import-guide.cjs} +0 -0
  197. /package/scripts/filter/after-post-render/{process-variables.js → process-variables.cjs} +0 -0
  198. /package/scripts/filter/after-post-render/{time-end.js → time-end.cjs} +0 -0
  199. /package/scripts/filter/after-post-render/{time-start.js → time-start.cjs} +0 -0
  200. /package/scripts/filter/after-post-render/{validate-after-render.js → validate-after-render.cjs} +0 -0
  201. /package/scripts/filter/before-post-render/{change-output-path.js → change-output-path.cjs} +0 -0
  202. /package/scripts/filter/before-post-render/{set-layout.js → set-layout.cjs} +0 -0
  203. /package/scripts/filter/before-post-render/{validate-page-data.js → validate-page-data.cjs} +0 -0
  204. /package/scripts/helper/{get-pages-for-nav-tree.js → get-pages-for-nav-tree.cjs} +0 -0
  205. /package/scripts/helper/{mark-empty-categories.js → mark-empty-categories.cjs} +0 -0
  206. /package/scripts/helper/{u-extract-and-cache-title.js → u-extract-and-cache-title.cjs} +0 -0
  207. /package/scripts/helper/{u-split-to-title-and-content.js → u-split-to-title-and-content.cjs} +0 -0
  208. /package/scripts/utils/{add-indention.js → add-indention.cjs} +0 -0
  209. /package/scripts/utils/{capitalize.js → capitalize.cjs} +0 -0
  210. /package/scripts/utils/{compose.js → compose.cjs} +0 -0
  211. /package/scripts/utils/{decode-html-entities.js → decode-html-entities.cjs} +0 -0
  212. /package/scripts/utils/{drop-init-slash.js → drop-init-slash.cjs} +0 -0
  213. /package/scripts/utils/{drop-trailing-slash.js → drop-trailing-slash.cjs} +0 -0
  214. /package/scripts/utils/{drop-url-protocol.js → drop-url-protocol.cjs} +0 -0
  215. /package/scripts/utils/{findmaincategorypage.js → findmaincategorypage.cjs} +0 -0
  216. /package/scripts/utils/{getreportissuewidgeturl.js → getreportissuewidgeturl.cjs} +0 -0
  217. /package/scripts/utils/gloria-after-post-render/{apply-design-doc-classes.js → apply-design-doc-classes.cjs} +0 -0
  218. /package/scripts/utils/gloria-after-post-render/{wrap-table-into-wrappers.js → wrap-table-into-wrappers.cjs} +0 -0
  219. /package/scripts/utils/{insertchangelog.js → insertchangelog.cjs} +0 -0
  220. /package/scripts/utils/{measure-call.js → measure-call.cjs} +0 -0
  221. /package/scripts/utils/{parser-cursor.js → parser-cursor.cjs} +0 -0
  222. /package/scripts/utils/pug-to-xml-binding/parser/{walk-xml-tree.js → walk-xml-tree.cjs} +0 -0
  223. /package/scripts/utils/{random-id.js → random-id.cjs} +0 -0
  224. /package/scripts/utils/{remove-indentation.js → remove-indentation.cjs} +0 -0
  225. /package/scripts/utils/{shoulddisplaynewindicator.js → shoulddisplaynewindicator.cjs} +0 -0
  226. /package/scripts/utils/{toc.js → toc.cjs} +0 -0
  227. /package/scripts/utils/{transformcodeswitcher.js → transformcodeswitcher.cjs} +0 -0
  228. /package/scripts/utils/{transforminfobox.js → transforminfobox.cjs} +0 -0
  229. /package/scripts/utils/{uniq-by-last.js → uniq-by-last.cjs} +0 -0
@@ -6,7 +6,7 @@
6
6
  'use strict';
7
7
 
8
8
  const fs = require( 'node:fs' );
9
- const path = require( 'node:path' );
9
+ const upath = require( 'upath' );
10
10
  const { parseDocument } = require( 'htmlparser2' );
11
11
  const { Element, Text } = require( 'domhandler' );
12
12
  const { selectAll, selectOne } = require( 'css-select' );
@@ -21,7 +21,7 @@ module.exports = function inlineSvg( doc, themeDir ) {
21
21
 
22
22
  // Construct the absolute path to the SVG file.
23
23
  // Assuming the path is relative to the Hexo root.
24
- const absolutePath = path.join( themeDir, svgPath );
24
+ const absolutePath = upath.join( themeDir, svgPath );
25
25
 
26
26
  // Read the SVG file content
27
27
  if ( !fs.existsSync( absolutePath ) ) {
@@ -17,6 +17,8 @@ const { styleText } = require( 'node:util' );
17
17
  * @returns {String}
18
18
  */
19
19
  module.exports = function logCrossProjectReference( { expression, source } ) {
20
+ const { styleText } = module.exports._dependencies;
21
+
20
22
  process.exitCode = 1;
21
23
 
22
24
  const message = `${ styleText( 'red', 'Error:' ) } Failed while convert ${ styleText( 'cyanBright', expression ) } tag`;
@@ -27,3 +29,7 @@ module.exports = function logCrossProjectReference( { expression, source } ) {
27
29
 
28
30
  return expression;
29
31
  };
32
+
33
+ module.exports._dependencies = {
34
+ styleText
35
+ };
@@ -9,6 +9,10 @@ const KNOWN_BADGES = {
9
9
  premium: {
10
10
  name: 'premium',
11
11
  label: 'Premium feature'
12
+ },
13
+ experimental: {
14
+ name: 'experiment',
15
+ label: 'Experimental feature'
12
16
  }
13
17
  };
14
18
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const { linkToApi, linkToSdk, linkToGuide } = require( './parselinks' );
8
+ const { linkToApi, linkToSdk, linkToGuide } = require( './parselinks.cjs' );
9
9
 
10
10
  /**
11
11
  * Parses an href link from a string and returns the appropriate URL.
@@ -7,7 +7,7 @@
7
7
 
8
8
  const crypto = require( 'node:crypto' );
9
9
  const upath = require( 'upath' );
10
- const logCrossProjectReference = require( './logcrossprojectreference' );
10
+ const logCrossProjectReference = require( './logcrossprojectreference.cjs' );
11
11
 
12
12
  const ICON_REGEXP = /\\?{@icon(?:\s+@(\w+))?\s+([^}\s]+)\s*([^}]*)\\?}/g;
13
13
 
@@ -21,6 +21,8 @@ const ICON_REGEXP = /\\?{@icon(?:\s+@(\w+))?\s+([^}\s]+)\s*([^}]*)\\?}/g;
21
21
  * @returns {Object}
22
22
  */
23
23
  module.exports = function parseIconTag( page, hexo ) {
24
+ const { logCrossProjectReference } = module.exports._dependencies;
25
+
24
26
  const relativeUrlHelper = hexo.extend.helper.store.relative_url;
25
27
 
26
28
  page.content = page.content.replace( ICON_REGEXP, ( match, iconProject, iconPath, alternativeText ) => {
@@ -57,6 +59,10 @@ module.exports = function parseIconTag( page, hexo ) {
57
59
  return page;
58
60
  };
59
61
 
62
+ module.exports._dependencies = {
63
+ logCrossProjectReference
64
+ };
65
+
60
66
  /**
61
67
  * @param {String} value
62
68
  * @return {String}
@@ -7,14 +7,13 @@
7
7
 
8
8
  const { styleText } = require( 'node:util' );
9
9
  const upath = require( 'upath' );
10
- const splitLongname = require( '../../src/helpers/split-longname' );
10
+ const { splitLongname } = require( '../../src/helpers/split-longname.js' );
11
+ const { findTargetDoclet } = require( '../../src/api-builder/utils/findtargetdoclet.js' );
12
+ const { hasDedicatedApiPages, LONG_NAME_LABEL_REGEXP } = require( '../../src/api-builder/utils/utils.js' );
13
+ const logCrossProjectReference = require( './logcrossprojectreference.cjs' );
11
14
 
12
15
  const LINK_REGEXP = /\\?{(?:@linkapi|@link|@linksdk|@linkexample)\s+[^{]+?({[^}]+})?[^{}]*\\?}/g;
13
16
 
14
- const findTargetDoclet = require( '../../src/api-builder/utils/findtargetdoclet' );
15
- const { hasDedicatedApiPages, LONG_NAME_LABEL_REGEXP } = require( '../../src/api-builder/utils/utils' );
16
- const logCrossProjectReference = require( './logcrossprojectreference' );
17
-
18
17
  /**
19
18
  * Converts @link or @linkapi tags into working links to guides or API docs.
20
19
  *
@@ -40,7 +39,7 @@ function parseLinks( page, hexo ) {
40
39
  } );
41
40
 
42
41
  return page;
43
- };
42
+ }
44
43
 
45
44
  /**
46
45
  * @param {String} str
@@ -51,6 +50,7 @@ function parseLinks( page, hexo ) {
51
50
  * @param {Boolean} options.isSilentError
52
51
  */
53
52
  function linkToApi( str, data, hexo, { relativeUrlHelper, isSilentError }, onlyHref = false ) {
53
+ const { logCrossProjectReference } = module.exports._dependencies;
54
54
  const linkMatchResult = str.match( /^{((?:@linkapi|@link)[\s\S]+)}$/ );
55
55
 
56
56
  if ( !linkMatchResult ) {
@@ -236,6 +236,7 @@ function getOutputLink( href, description, isCustomDescription ) {
236
236
  * @param {Boolean} options.isSilentError
237
237
  */
238
238
  function linkToSdk( str, data, hexo, { relativeUrlHelper, isSilentError }, onlyHref = false ) {
239
+ const { logCrossProjectReference } = module.exports._dependencies;
239
240
  const regExp = /(?:@linksdk|@linkexample) (?:@(\w+) )?(\w+)(?:\.html)?(#\S+)? ([^}]+)/;
240
241
  const match = regExp.exec( str );
241
242
 
@@ -278,6 +279,7 @@ function linkToSdk( str, data, hexo, { relativeUrlHelper, isSilentError }, onlyH
278
279
  * @param {Boolean} options.isSilentError
279
280
  */
280
281
  function linkToGuide( str, data, hexo, { relativeUrlHelper, isSilentError }, onlyHref = false ) {
282
+ const { logCrossProjectReference } = module.exports._dependencies;
281
283
  const rgxp = /@link(?:\s+@(\w+))?\s+([^}\s]+)\s*([^}]*)}/;
282
284
  const match = rgxp.exec( str );
283
285
 
@@ -354,6 +356,7 @@ function linkToGuide( str, data, hexo, { relativeUrlHelper, isSilentError }, onl
354
356
  * @return {String}
355
357
  */
356
358
  function onError( { value, source, isSilent, description } ) {
359
+ const { styleText } = module.exports._dependencies;
357
360
  if ( !isSilent ) {
358
361
  process.exitCode = 1;
359
362
 
@@ -392,3 +395,8 @@ module.exports = {
392
395
  linkToSdk,
393
396
  linkToGuide
394
397
  };
398
+
399
+ module.exports._dependencies = {
400
+ logCrossProjectReference,
401
+ styleText
402
+ };
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const { randomId, regenerateRandomIds } = require( '../random-id' );
9
- const renderPugComponent = require( './render-pug-component' );
8
+ const { randomId, regenerateRandomIds } = require( '../random-id.cjs' );
9
+ const renderPugComponent = require( './render-pug-component.cjs' );
10
10
 
11
11
  /**
12
12
  * Creates a template function for a Pug component with a built-in caching mechanism.
@@ -28,7 +28,7 @@ const renderPugComponent = require( './render-pug-component' );
28
28
  * such as code in a code block.
29
29
  *
30
30
  * @example
31
- * const createPrerenderPugTemplate = require( './create-prerender-pug-template' );
31
+ * const createPrerenderPugTemplate = require( './create-prerender-pug-template.cjs' );
32
32
  *
33
33
  * // Creates a template for the 'code-block' component.
34
34
  * const codeBlockTemplate = createPrerenderPugTemplate( {
@@ -5,8 +5,8 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const path = require( 'node:path' );
9
- const hexoManager = require( '../../../src/hexo-manager' );
8
+ const upath = require( 'upath' );
9
+ const { hexoManager } = require( '../../../src/hexo-manager.js' );
10
10
 
11
11
  /**
12
12
  * Renders a Pug component with specified includes and parameters.
@@ -35,8 +35,8 @@ module.exports = function renderPugComponent(
35
35
  // Default base path is the components directory in the theme
36
36
  // Handle case where hexo.theme_dir might be undefined
37
37
  const resolvedHexo = hexo || hexoManager.hexo;
38
- const themeDir = resolvedHexo && resolvedHexo.theme_dir || path.join( __dirname, '../../themes/umberto' );
39
- const componentsPath = basePath || path.join( themeDir, 'layout', 'gloria', '_components' );
38
+ const themeDir = resolvedHexo && resolvedHexo.theme_dir || upath.join( __dirname, '../../themes/umberto' );
39
+ const componentsPath = basePath || upath.join( themeDir, 'layout', 'gloria', '_components' );
40
40
 
41
41
  // Prepare includes statements
42
42
  const includeStatements = requires.map( include => `include ${ include }` );
@@ -7,8 +7,8 @@
7
7
 
8
8
  const { inspect } = require( 'node:util' );
9
9
 
10
- const removeIndentation = require( '../../remove-indentation.js' );
11
- const ParserCursor = require( '../../parser-cursor.js' );
10
+ const removeIndentation = require( '../../remove-indentation.cjs' );
11
+ const ParserCursor = require( '../../parser-cursor.cjs' );
12
12
 
13
13
  /**
14
14
  * A parser for converting markdown containing HTML-like markup into a tree structure.
@@ -5,9 +5,9 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const transformXMLTreeToPug = require( './transform-xml-tree-to-pug.js' );
9
- const XMLComponentsParser = require( './parser/xml-components-parser.js' );
10
- const { walkXMLTree, TreeWalkActions } = require( './parser/walk-xml-tree.js' );
8
+ const transformXMLTreeToPug = require( './transform-xml-tree-to-pug.cjs' );
9
+ const XMLComponentsParser = require( './parser/xml-components-parser.cjs' );
10
+ const { walkXMLTree, TreeWalkActions } = require( './parser/walk-xml-tree.cjs' );
11
11
 
12
12
  /**
13
13
  * Slices XML components from Markdown content and transforms them to Pug format.
@@ -10,7 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const { TreeWalkActions, walkXMLTree } = require( './parser/walk-xml-tree' );
13
+ const { TreeWalkActions, walkXMLTree } = require( './parser/walk-xml-tree.cjs' );
14
14
 
15
15
  /**
16
16
  * Transforms an XML tree structure into Pug mixin syntax.
@@ -6,7 +6,7 @@
6
6
  'use strict';
7
7
 
8
8
  const fs = require( 'node:fs' );
9
- const path = require( 'node:path' );
9
+ const upath = require( 'upath' );
10
10
  const { parseDocument } = require( 'htmlparser2' );
11
11
  const { Element, cloneNode } = require( 'domhandler' );
12
12
  const { selectAll, selectOne } = require( 'css-select' );
@@ -84,7 +84,7 @@ function createSpritesheet( svgFiles, themeDir ) {
84
84
  const iconViewBoxes = new Map();
85
85
 
86
86
  for ( const [ iconId, svgPath ] of svgFiles.entries() ) {
87
- const absolutePath = path.join( themeDir, svgPath );
87
+ const absolutePath = upath.join( themeDir, svgPath );
88
88
 
89
89
  if ( !fs.existsSync( absolutePath ) ) {
90
90
  console.warn( `SVG file not found: ${ absolutePath }` );
@@ -5,7 +5,7 @@
5
5
 
6
6
  'use strict';
7
7
 
8
- const ParserCursor = require( './parser-cursor' );
8
+ const ParserCursor = require( './parser-cursor.cjs' );
9
9
 
10
10
  /**
11
11
  * Transforms Github style admonitions in markdown to a rendered callouts.
@@ -3,38 +3,36 @@
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' );
10
- const { parseDocument } = require( 'htmlparser2' );
11
- const { selectAll } = require( 'css-select' );
12
- const { textContent, removeElement } = require( 'domutils' );
13
- const { default: TinyPool } = require( 'tinypool' );
14
- const FileNameManager = require( './classes/file-name-manager' );
15
- const HtmlFile = require( './classes/html-file' );
16
- const DocDataFactory = require( './classes/doc-data-factory' );
17
- const DescriptionParser = require( './classes/description-parser' );
18
- const NavigationTree = require( './classes/navigation-tree' );
19
- const capitalize = require( '../helpers/capitalize' );
20
- const getShortModulePath = require( '../helpers/get-short-module-path' );
21
- const getDocSearchConfig = require( '../helpers/get-docsearch-config' );
22
- const splitLongname = require( '../helpers/split-longname' );
23
- const githubUrlUtils = require( '../helpers/github-url' );
24
- const getReportIssueWidgetUrl = require( '../../scripts/utils/getreportissuewidgeturl' );
25
- const getPageGroupHelper = require( '../../src/hexo/helper/get-page-group' );
26
- const findTargetDoclet = require( './utils/findtargetdoclet' );
27
-
28
- const { randomId } = require( '../../scripts/utils/random-id' );
29
- const parseHref = require( '../../scripts/utils/parse-href' );
30
- const hexoManager = require( '../hexo-manager' );
6
+ import upath from 'upath';
7
+ import fs from 'fs-extra';
8
+ import { parseDocument } from 'htmlparser2';
9
+ import { selectAll } from 'css-select';
10
+ import { textContent, removeElement } from 'domutils';
11
+ import TinyPool from 'tinypool';
12
+ import { FileNameManager } from './classes/file-name-manager.js';
13
+ import { HtmlFile } from './classes/html-file.js';
14
+ import { DocDataFactory } from './classes/doc-data-factory.js';
15
+ import { DescriptionParser } from './classes/description-parser.js';
16
+ import { NavigationTree } from './classes/navigation-tree.js';
17
+ import { capitalize } from '../helpers/capitalize.js';
18
+ import { getShortModulePath } from '../helpers/get-short-module-path.js';
19
+ import { getDocsearchConfig as getDocSearchConfig } from '../helpers/get-docsearch-config.js';
20
+ import { splitLongname } from '../helpers/split-longname.js';
21
+ import { getIssueUrl, getFullGithubLink } from '../helpers/github-url.js';
22
+ import getReportIssueWidgetUrl from '../../scripts/utils/getreportissuewidgeturl.cjs';
23
+ import { randomId } from '../../scripts/utils/random-id.cjs';
24
+ import parseHref from '../../scripts/utils/parse-href.cjs';
25
+ import { getPageGroup as getPageGroupHelper } from '../hexo/helper/get-page-group.js';
26
+
27
+ import { hexoManager } from '../hexo-manager.js';
28
+ import { findTargetDoclet } from './utils/findtargetdoclet.js';
31
29
 
32
30
  /**
33
31
  * Renders HTML for every module, class, mixin etc.
34
32
  *
35
33
  * @type {module.ApiBuilder}
36
34
  */
37
- module.exports = class ApiBuilder {
35
+ export class ApiBuilder {
38
36
  /**
39
37
  * @param templateCollection
40
38
  * @param dataCollection
@@ -206,7 +204,7 @@ module.exports = class ApiBuilder {
206
204
  this._filterHtml = this._tmplCol.renderTemplate( '_partial/filter' );
207
205
 
208
206
  const pool = new TinyPool( {
209
- filename: require.resolve( './build-page-worker.js' )
207
+ filename: new URL( './build-page-worker.js', import.meta.url ).pathname
210
208
  } );
211
209
 
212
210
  await this._getPages( pool, modulesData, 'module' );
@@ -505,7 +503,7 @@ module.exports = class ApiBuilder {
505
503
  realImportPath,
506
504
  shortHiddenPath: splitParts.length > 0 ? splitParts.join( '/' ) : '',
507
505
  isApi: true,
508
- issuesUrl: githubUrlUtils.getIssueUrl( this._projectConfig ),
506
+ issuesUrl: getIssueUrl( this._projectConfig ),
509
507
  startPage: this._projectConfig.startPage ? '/' + this._projectConfig.startPage : '/index.html',
510
508
  canonicalUrlBeginning: this.canonicalUrlBeginning,
511
509
  'meta-description': trimDescription( { min: 155, max: 300, text: metaDescription } ),
@@ -514,7 +512,7 @@ module.exports = class ApiBuilder {
514
512
  'dc-description': trimDescription( { min: 300, max: 600, text: metaDescription } )
515
513
  };
516
514
 
517
- // This line needs to be sync with the `scripts/filter/before-post-render/add-project-info-to-page.js` file.
515
+ // This line needs to be sync with the `scripts/filter/before-post-render/add-project-info-to-page.cjs` file.
518
516
  page.reportIssueWidget = getReportIssueWidgetUrl( page, this._projectConfig );
519
517
 
520
518
  // More locals to be used in templates. Matching locals used by hexo.
@@ -522,7 +520,7 @@ module.exports = class ApiBuilder {
522
520
  latestBasePath: upath.join( this._projectSlug, 'latest' ),
523
521
  groups,
524
522
  seeSourceRepositoryUrl: this._projectConfig.github !== undefined ? this._projectConfig.github.url : realImportPath,
525
- getLinkToSource: githubUrlUtils.getFullGithubLink.bind( this ),
523
+ getLinkToSource: getFullGithubLink.bind( this ),
526
524
  docSearchConfig: getDocSearchConfig( this._docSearch, {
527
525
  groups: this._groups,
528
526
  slug: this._projectSlug,
@@ -3,16 +3,14 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import fs from 'node:fs';
7
+ import upath from 'upath';
8
+ import { parseDocument } from 'htmlparser2';
9
+ import render from 'dom-serializer';
10
+ import inlineSvg from '../../scripts/utils/inline-svg.cjs';
11
+ import spritesheetSvg from '../../scripts/utils/spritesheet-svg.cjs';
7
12
 
8
- const fs = require( 'node:fs' );
9
- const upath = require( 'upath' );
10
- const { parseDocument } = require( 'htmlparser2' );
11
- const { default: render } = require( 'dom-serializer' );
12
- const inlineSvg = require( '../../scripts/utils/inline-svg' );
13
- const spritesheetSvg = require( '../../scripts/utils/spritesheet-svg' );
14
-
15
- module.exports = function( {
13
+ export const buildPageWorker = function( {
16
14
  content,
17
15
  navTreeHtml,
18
16
  outputPath,
@@ -33,3 +31,5 @@ module.exports = function( {
33
31
 
34
32
  fs.writeFileSync( outputPath, content, 'utf-8' );
35
33
  };
34
+
35
+ export default buildPageWorker;
@@ -3,19 +3,17 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { styleText } = require( 'node:util' );
9
- const { parseDocument } = require( 'htmlparser2' );
10
- const { default: render } = require( 'dom-serializer' );
11
- const { selectAll, selectOne } = require( 'css-select' );
12
- const { replaceElement, removeElement, appendChild } = require( 'domutils' );
13
- const splitLongname = require( '../../helpers/split-longname' );
14
- const macroReplacer = require( '../../tasks/macro-replacer' );
15
- const findTargetDoclet = require( '../utils/findtargetdoclet' );
16
- const { hasDedicatedApiPages, LONG_NAME_LABEL_REGEXP, LONG_NAME_MEMBER_SEPARATOR_REGEXP } = require( '../utils/utils' );
17
- const logCrossProjectReference = require( '../../../scripts/utils/logcrossprojectreference' );
18
- const createPrerenderPugTemplate = require( '../../../scripts/utils/pug-renderer/create-prerender-pug-template' );
6
+ import { styleText } from 'node:util';
7
+ import { parseDocument } from 'htmlparser2';
8
+ import render from 'dom-serializer';
9
+ import { selectAll, selectOne } from 'css-select';
10
+ import { replaceElement, removeElement, appendChild } from 'domutils';
11
+ import { splitLongname } from '../../helpers/split-longname.js';
12
+ import { macroReplacer } from '../../tasks/macro-replacer.js';
13
+ import { findTargetDoclet } from '../utils/findtargetdoclet.js';
14
+ import { hasDedicatedApiPages, LONG_NAME_LABEL_REGEXP, LONG_NAME_MEMBER_SEPARATOR_REGEXP } from '../utils/utils.js';
15
+ import logCrossProjectReference from '../../../scripts/utils/logcrossprojectreference.cjs';
16
+ import createPrerenderPugTemplate from '../../../scripts/utils/pug-renderer/create-prerender-pug-template.cjs';
19
17
 
20
18
  const renderCodeBlockPug = createPrerenderPugTemplate( {
21
19
  requires: [
@@ -39,7 +37,7 @@ const renderCodeBlockPug = createPrerenderPugTemplate( {
39
37
  * Class responsible for parsing doc descriptions.
40
38
  * @type {DescriptionParser}
41
39
  */
42
- module.exports = class DescriptionParser {
40
+ export class DescriptionParser {
43
41
  constructor( fileNameManager, dataCollection, { macrosVariables } = {} ) {
44
42
  this._fileNameManager = fileNameManager;
45
43
  this._dataCollection = dataCollection;
@@ -3,10 +3,8 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const isNonEmptyArray = require( '../../helpers/is-non-empty-array' );
9
- const splitLongname = require( '../../helpers/split-longname' );
6
+ import { isNonEmptyArray } from '../../helpers/is-non-empty-array.js';
7
+ import { splitLongname } from '../../helpers/split-longname.js';
10
8
 
11
9
  /**
12
10
  * Factory creating docs data to be used in templates.
@@ -14,7 +12,7 @@ const splitLongname = require( '../../helpers/split-longname' );
14
12
  * For example data of a class has to include all properties, methods, etc.
15
13
  * @type {DocDataFactory}
16
14
  */
17
- module.exports = class DocDataFactory {
15
+ export class DocDataFactory {
18
16
  /**
19
17
  * @param dataCollection
20
18
  * @param descriptionParser
@@ -3,15 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const escapeLongname = require( '../../helpers/escape-longname' );
6
+ import { escapeLongname } from '../../helpers/escape-longname.js';
9
7
 
10
8
  /**
11
9
  * Handles filenames of various entities. Makes sure filenames are unique and do not contain forbidden characters.
12
10
  * Allows to get a filename for a doclet's longname.
13
11
  */
14
- module.exports = class FileNameManager {
12
+ export class FileNameManager {
15
13
  constructor() {
16
14
  this.longnameToUrl = new Map();
17
15
  this.fileNames = new Set();
@@ -3,15 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
6
+ import upath from 'upath';
9
7
 
10
8
  /**
11
9
  * Stores HTML rendered by a pug template.
12
10
  * @type {module.HtmlFile}
13
11
  */
14
- module.exports = class HtmlFile {
12
+ export class HtmlFile {
15
13
  /**
16
14
  * @param {String} content Content of the file.
17
15
  * @param {String} pathToFile Path to the file.
@@ -3,13 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const upath = require( 'upath' );
9
- const isNonEmptyArray = require( '../../helpers/is-non-empty-array' );
10
- const TreeModel = require( 'tree-model' );
11
- const Node = require( './tree-node' );
12
- const fs = require( 'fs-extra' );
6
+ import upath from 'upath';
7
+ import { isNonEmptyArray } from '../../helpers/is-non-empty-array.js';
8
+ import TreeModel from 'tree-model';
9
+ import { Node } from './tree-node.js';
10
+ import fs from 'fs-extra';
13
11
 
14
12
  const NODE_TYPES = {
15
13
  ROOT: 'root',
@@ -38,7 +36,7 @@ const NODE_ORDER = {
38
36
  * Creates a data structure representing API navigation tree.
39
37
  * @type {module.NavigationTree}
40
38
  */
41
- module.exports = class NavigationTree {
39
+ export class NavigationTree {
42
40
  /**
43
41
  * @param {String} rootPath Path of the root node.
44
42
  * @param {Function} longnameToUrl Function returning a filename for a given longname.
@@ -3,13 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Tree node used by API navigation tree.
10
8
  * @type {module.Node}
11
9
  */
12
- module.exports = class Node {
10
+ export class Node {
13
11
  /**
14
12
  * @param {NODE_TYPES} type
15
13
  * @param {String} name Name of the node. The name will be displayed to the user in a nav tree.
@@ -3,8 +3,6 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * A helper function used for searching for a proper doclet structure when creating a link
10
8
  * from a guide or an API page.
@@ -22,7 +20,7 @@
22
20
  * @param {Boolean} [options.query.memberOnly=false]
23
21
  * @returns {Object|null}
24
22
  */
25
- module.exports = function findTargetDoclet( docletCollection, options ) {
23
+ export function findTargetDoclet( docletCollection, options ) {
26
24
  const { module, structure, member, label, query } = options;
27
25
  const { skipModule, memberOnly } = ( query || {} );
28
26
 
@@ -3,8 +3,6 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  const DEDICATED_PAGE_DOCLET_KINDS = [
9
7
  'module', 'class', 'typedef', 'mixin', 'interface', 'namespace'
10
8
  ];
@@ -12,30 +10,25 @@ const DEDICATED_PAGE_DOCLET_KINDS = [
12
10
  /**
13
11
  * Set of utils used in helpers to generate links to API definitions.
14
12
  */
15
- module.exports = {
16
- /**
17
- * A regular expression used for extracting a member name from doclet full name, member of or just a name.
18
- */
19
- MEMBER_NAME_REGEXP: /([{}\-\w$]+)(?::([A-Z0-9a-z_:{}]+))?$/,
20
- // ^ Sync with the `LONG_NAME_LABEL_REGEXP` value.
13
+ export const MEMBER_NAME_REGEXP = /([{}\-\w$]+)(?::([A-Z0-9a-z_:{}]+))?$/;
14
+ // ^ Sync with the `LONG_NAME_LABEL_REGEXP` value.
21
15
 
22
- /**
23
- * A regular expression used for removing a label (if specified) from a member name.
24
- * The regexp is used in `MEMBER_NAME_REGEXP` as a group, so the particular group should be synced.
25
- */
26
- LONG_NAME_LABEL_REGEXP: /(?::([A-Z0-9a-z_:{}]+))?$/,
16
+ /**
17
+ * A regular expression used for removing a label (if specified) from a member name.
18
+ * The regexp is used in `MEMBER_NAME_REGEXP` as a group, so the particular group should be synced.
19
+ */
20
+ export const LONG_NAME_LABEL_REGEXP = /(?::([A-Z0-9a-z_:{}]+))?$/;
27
21
 
28
- /**
29
- * A regular expression used for separating a definition (a class, an interface, etc.) and a member name.
30
- */
31
- LONG_NAME_MEMBER_SEPARATOR_REGEXP: /[#.]/,
22
+ /**
23
+ * A regular expression used for separating a definition (a class, an interface, etc.) and a member name.
24
+ */
25
+ export const LONG_NAME_MEMBER_SEPARATOR_REGEXP = /[#.]/;
32
26
 
33
- /**
34
- * @param {Object} doclet
35
- * @param {String} doclet.kind
36
- * @returns {Boolean}
37
- */
38
- hasDedicatedApiPages( doclet ) {
39
- return DEDICATED_PAGE_DOCLET_KINDS.includes( doclet.kind );
40
- }
41
- };
27
+ /**
28
+ * @param {Object} doclet
29
+ * @param {String} doclet.kind
30
+ * @returns {Boolean}
31
+ */
32
+ export function hasDedicatedApiPages( doclet ) {
33
+ return DEDICATED_PAGE_DOCLET_KINDS.includes( doclet.kind );
34
+ }
@@ -3,11 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import upath from 'upath';
7
7
 
8
- const upath = require( 'upath' );
9
-
10
- module.exports = data => {
8
+ export const jsdoc2umberto = data => {
11
9
  const parsed = JSON.parse( data ).doclets;
12
10
 
13
11
  if ( !parsed ) {