umberto 9.3.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 (229) hide show
  1. package/CHANGELOG.md +24 -16
  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 +84 -33
  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 +7 -9
  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 +80 -8
  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 +47 -36
  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 +11 -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/layout/gloria/_api-docs/_mixin/_api-tree-item.pug +18 -1
  142. package/themes/umberto/layout/gloria/_head/head.pug +5 -0
  143. package/themes/umberto/layout/umberto/_partial/head.pug +5 -0
  144. package/themes/umberto/src/gloria/css/components/_api-tree.scss +4 -0
  145. package/themes/umberto/src/gloria/js/app.js +32 -32
  146. package/themes/umberto/src/gloria/js/components/api-nav-tree.js +5 -5
  147. package/themes/umberto/src/gloria/js/components/api-toggle.js +2 -2
  148. package/themes/umberto/src/gloria/js/components/breadcrumbs.js +1 -1
  149. package/themes/umberto/src/gloria/js/components/code-block.js +5 -5
  150. package/themes/umberto/src/gloria/js/components/code-switcher.js +2 -2
  151. package/themes/umberto/src/gloria/js/components/dropdown.js +5 -5
  152. package/themes/umberto/src/gloria/js/components/expandable.js +1 -1
  153. package/themes/umberto/src/gloria/js/components/fake-devtools.js +4 -4
  154. package/themes/umberto/src/gloria/js/components/hash-link.js +2 -2
  155. package/themes/umberto/src/gloria/js/components/heading-link.js +2 -2
  156. package/themes/umberto/src/gloria/js/components/iframe.js +2 -2
  157. package/themes/umberto/src/gloria/js/components/mobile-overlay.js +5 -5
  158. package/themes/umberto/src/gloria/js/components/nav-tree.js +3 -3
  159. package/themes/umberto/src/gloria/js/components/tabs.js +2 -2
  160. package/themes/umberto/src/gloria/js/components/tooltip-popover.js +13 -13
  161. package/themes/umberto/src/gloria/js/helpers/animate-element.js +2 -2
  162. package/themes/umberto/src/gloria/js/helpers/create-anchor-positioning-watcher.js +1 -1
  163. package/themes/umberto/src/gloria/js/helpers/create-keyboard-focus-cycler.js +3 -3
  164. package/themes/umberto/src/gloria/js/helpers/focus-first-interactive.js +2 -2
  165. package/themes/umberto/src/gloria/js/helpers/highlight-code.js +1 -1
  166. package/themes/umberto/src/gloria/js/helpers/scroll-to-hash.js +1 -1
  167. package/themes/umberto/src/gloria/js/helpers/tween.js +2 -2
  168. package/themes/umberto/src/gloria/js/modules/algolia-search.js +4 -4
  169. package/themes/umberto/src/gloria/js/modules/api-filter.js +1 -1
  170. package/themes/umberto/src/gloria/js/modules/header-bar.js +4 -4
  171. package/themes/umberto/src/gloria/js/modules/header.js +2 -2
  172. package/themes/umberto/src/gloria/js/modules/links-prefetch.js +1 -1
  173. package/themes/umberto/src/gloria/js/modules/mobile-nav.js +7 -7
  174. package/themes/umberto/src/gloria/js/modules/sidebar.js +3 -3
  175. package/themes/umberto/src/gloria/js/modules/table-of-contents-api.js +9 -9
  176. package/themes/umberto/src/gloria/js/modules/table-of-contents.js +10 -10
  177. package/themes/umberto/src/gloria/js/public-api.js +15 -15
  178. package/themes/umberto/src/gloria/js/web-components/svg-icon.js +3 -3
  179. package/themes/umberto/src/umberto/js/_apitree.js +1 -1
  180. package/themes/umberto/src/umberto/js/_attachpermalinklistener.js +1 -1
  181. package/themes/umberto/src/umberto/js/_copymobileapinavigation.js +1 -1
  182. package/themes/umberto/src/umberto/js/_imageModal.js +1 -1
  183. package/themes/umberto/src/umberto/js/_pagenavigation.js +1 -1
  184. package/themes/umberto/src/umberto/js/_prism.js +1 -1
  185. package/themes/umberto/src/umberto/js/_samplecode.js +1 -1
  186. package/themes/umberto/src/umberto/js/_sidenavigation.js +1 -1
  187. package/themes/umberto/src/umberto/js/_toc.js +1 -1
  188. package/themes/umberto/src/umberto/js/_warningbanner.js +1 -1
  189. package/themes/umberto/src/umberto/js/app.js +19 -19
  190. package/src/tasks/validate-html-w3c.js +0 -35
  191. /package/scripts/filter/after-post-render/{basepath-replacer.js → basepath-replacer.cjs} +0 -0
  192. /package/scripts/filter/after-post-render/{fix-code-samples.js → fix-code-samples.cjs} +0 -0
  193. /package/scripts/filter/after-post-render/{gather-guides.js → gather-guides.cjs} +0 -0
  194. /package/scripts/filter/after-post-render/{img-linker.js → img-linker.cjs} +0 -0
  195. /package/scripts/filter/after-post-render/{import-guide.js → import-guide.cjs} +0 -0
  196. /package/scripts/filter/after-post-render/{process-variables.js → process-variables.cjs} +0 -0
  197. /package/scripts/filter/after-post-render/{time-end.js → time-end.cjs} +0 -0
  198. /package/scripts/filter/after-post-render/{time-start.js → time-start.cjs} +0 -0
  199. /package/scripts/filter/after-post-render/{validate-after-render.js → validate-after-render.cjs} +0 -0
  200. /package/scripts/filter/before-post-render/{change-output-path.js → change-output-path.cjs} +0 -0
  201. /package/scripts/filter/before-post-render/{set-layout.js → set-layout.cjs} +0 -0
  202. /package/scripts/filter/before-post-render/{validate-page-data.js → validate-page-data.cjs} +0 -0
  203. /package/scripts/helper/{get-pages-for-nav-tree.js → get-pages-for-nav-tree.cjs} +0 -0
  204. /package/scripts/helper/{mark-empty-categories.js → mark-empty-categories.cjs} +0 -0
  205. /package/scripts/helper/{u-extract-and-cache-title.js → u-extract-and-cache-title.cjs} +0 -0
  206. /package/scripts/helper/{u-split-to-title-and-content.js → u-split-to-title-and-content.cjs} +0 -0
  207. /package/scripts/utils/{add-indention.js → add-indention.cjs} +0 -0
  208. /package/scripts/utils/{capitalize.js → capitalize.cjs} +0 -0
  209. /package/scripts/utils/{compose.js → compose.cjs} +0 -0
  210. /package/scripts/utils/{decode-html-entities.js → decode-html-entities.cjs} +0 -0
  211. /package/scripts/utils/{drop-init-slash.js → drop-init-slash.cjs} +0 -0
  212. /package/scripts/utils/{drop-trailing-slash.js → drop-trailing-slash.cjs} +0 -0
  213. /package/scripts/utils/{drop-url-protocol.js → drop-url-protocol.cjs} +0 -0
  214. /package/scripts/utils/{findmaincategorypage.js → findmaincategorypage.cjs} +0 -0
  215. /package/scripts/utils/{getreportissuewidgeturl.js → getreportissuewidgeturl.cjs} +0 -0
  216. /package/scripts/utils/gloria-after-post-render/{apply-design-doc-classes.js → apply-design-doc-classes.cjs} +0 -0
  217. /package/scripts/utils/gloria-after-post-render/{wrap-table-into-wrappers.js → wrap-table-into-wrappers.cjs} +0 -0
  218. /package/scripts/utils/{insertchangelog.js → insertchangelog.cjs} +0 -0
  219. /package/scripts/utils/{measure-call.js → measure-call.cjs} +0 -0
  220. /package/scripts/utils/{normalizebadges.js → normalizebadges.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
@@ -3,8 +3,6 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Extracts longname from strings like 'Array.<module:ui...>'.
10
8
  * @param {String} str
@@ -13,7 +11,7 @@
13
11
  * @returns {Object} result.prefix
14
12
  * @returns {Object} result.suffix
15
13
  */
16
- module.exports = str => {
14
+ export const extractLongname = str => {
17
15
  if ( typeof str !== 'string' ) {
18
16
  return {
19
17
  longnames: [ '' ]
@@ -3,12 +3,10 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import { getShortModulePath } from './get-short-module-path.js';
7
+ import { splitLongname } from './split-longname.js';
7
8
 
8
- const getShortModulePath = require( './get-short-module-path' );
9
- const splitLongname = require( './split-longname' );
10
-
11
- module.exports = ( longname, transformFn ) => {
9
+ export const getApiInfoboxTooltip = ( longname, transformFn ) => {
12
10
  const className = splitLongname( longname ).className;
13
11
  const str = className ? `${ getShortModulePath( longname ) }~${ className }` : getShortModulePath( longname );
14
12
 
@@ -3,18 +3,20 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import lodash from 'lodash';
7
+ import { stringify } from 'javascript-stringify';
8
+ import fs from 'node:fs';
9
+ import upath from 'upath';
7
10
 
8
- const { cloneDeep } = require( 'lodash' );
9
- const { stringify } = require( 'javascript-stringify' );
10
- const fs = require( 'node:fs' );
11
- const upath = require( 'upath' );
11
+ const __dirname = import.meta.dirname;
12
+
13
+ const { cloneDeep } = lodash;
12
14
 
13
15
  const defaultScriptTemplate = fs.readFileSync( upath.join( __dirname, 'templates', 'scripts', 'default.js' ), 'utf-8' );
14
16
  const groupScriptTemplate = fs.readFileSync( upath.join( __dirname, 'templates', 'scripts', 'group.js' ), 'utf-8' );
15
17
  const rootScriptTemplate = fs.readFileSync( upath.join( __dirname, 'templates', 'scripts', 'root.js' ), 'utf-8' );
16
18
 
17
- module.exports = ( searchConfig, {
19
+ export const getDocsearchConfig = ( searchConfig, {
18
20
  groups = [],
19
21
  slug = '',
20
22
  customRanking = []
@@ -3,8 +3,6 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Returns an array containing files to process by Umberto based on the configuration passed to the building task.
10
8
  *
@@ -18,7 +16,7 @@
18
16
  * @param {Boolean} skipGuides
19
17
  * @return {nArray.<String>|null}
20
18
  */
21
- module.exports = function getFilePatternsToProcess( { guides, skipGuides } ) {
19
+ export function getFilePatternsToProcess( { guides, skipGuides } ) {
22
20
  // When called with `--skip-guides`.
23
21
  if ( skipGuides ) {
24
22
  return [
@@ -3,11 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import { splitLongname } from './split-longname.js';
7
7
 
8
- const splitLongname = require( './split-longname' );
9
-
10
- module.exports = longname => {
8
+ export const getShortModulePath = longname => {
11
9
  if ( !longname ) {
12
10
  return '';
13
11
  }
@@ -3,115 +3,108 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { spawnSync } = require( 'node:child_process' );
9
- const upath = require( 'upath' );
6
+ import { spawnSync } from 'node:child_process';
7
+ import upath from 'upath';
10
8
 
11
9
  const cachedGitPaths = new Set();
12
10
  const gitHashCache = new Map();
13
11
 
14
- const utils = {
15
- /**
16
- * Returns a URL where a user will be redirect after clicking a "Report new issue" button.
17
- *
18
- * @param {Object} projectConfig
19
- * @param {String} [projectConfig.issueUrl] An absolute URL for reporting an issue. If specified, it will be used.
20
- * @param {String} [projectConfig.repoUrlDocs] An absolute URL where the repository is located.
21
- * @returns {String}
22
- */
23
- getIssueUrl( projectConfig ) {
24
- const reportIssueRepository = projectConfig.issueUrl || projectConfig.repoUrlDocs;
25
-
26
- if ( !reportIssueRepository ) {
27
- return '';
28
- }
29
-
30
- return `${ reportIssueRepository }/issues/new`;
31
- },
32
-
33
- /**
34
- * Returns a URL where a user will be redirect after clicking a "Contribute to this guide" button.
35
- *
36
- * @param {Object} projectConfig
37
- * @param {String} [projectConfig.contributeUrl] An absolute URL for contributing to the guide.
38
- * @param {String} [projectConfig.repoUrlDocs] An absolute URL where the repository is located.
39
- * @param {Boolean} [projectConfig.doNotAddDocsInPath=false] If set to true, `docs/` part won't be added to the URL.
40
- * @param {String} sourceDirOrPathKey If `pathKey` was passed, `itemName` is not required. The `pathKey` part contains
41
- * the rest of path to the page (including an extension). `sourceDir` is a directory where the entire SDK group is located.
42
- * @param {String|null} [itemName=null] Name of the guide where the URL should be generated. Required if `sourceDirOrPathKey`
43
- * contains the `sourceDir` for specified SDK group. In such case, `itemName` is a name from SDK item that belongs to given group.
44
- * @returns {String}
45
- */
46
- getContributeUrl( projectConfig, sourceDirOrPathKey, itemName = null ) {
47
- const contributeRepository = projectConfig.contributeUrl || projectConfig.repoUrlDocs;
48
-
49
- if ( !contributeRepository ) {
50
- return '';
51
- }
52
-
53
- const urlParts = [
54
- contributeRepository,
55
- 'blob',
56
- 'master'
57
- ];
58
-
59
- if ( !projectConfig.doNotAddDocsInPath ) {
60
- urlParts.push( 'docs' );
61
- }
62
-
63
- urlParts.push( sourceDirOrPathKey.replace( /^\//, '' ) );
64
-
65
- if ( itemName ) {
66
- urlParts.push( itemName + '.html' );
67
- }
68
-
69
- return urlParts.join( '/' );
70
- },
71
-
72
- /**
73
- * Method obtain URL string with repository address including hash of github repository which was used to build given docs files.
74
- *
75
- * @param {String} repoUrl Repository url for which we need to obtain full url to github
76
- * @param {Object} file Object storing details about given documentation entry
77
- * @param {String} file.filePath Path to file where documentation was read
78
- * @param {Number} file.lineNr Line number where documentation starts
79
- * @param {Number} file.len Length of comment
80
- *
81
- * @returns {String/null} String URL to github with specific hash and line numbers to highlight
82
- */
83
- getFullGithubLink( repoUrl, file ) {
84
- const filePath = file.filePath;
85
-
86
- let projectName;
87
-
88
- // TODO: Couldn't be the repository/github link obtained based on the file path?
89
- // We know where the file is saved. Based on that, we could find the repository URL
90
- // and adjust values.
91
- if ( repoUrl.startsWith( '@ckeditor' ) ) {
92
- projectName = filePath.match( /([^(?:/|\\)]+)(?:\/|\\)packages/ )[ 1 ];
93
- } else {
94
- projectName = repoUrl.replace( /\/*$/, '' ).match( /[^/]*$/ )[ 0 ];
95
- }
96
-
97
- const pathSuffix = _getPathSuffix( filePath );
98
-
99
- if ( !pathSuffix ) {
100
- return null;
101
- }
102
-
103
- const gitHash = _getGitHashFromPath( filePath.replace( pathSuffix, '' ) );
104
-
105
- if ( !gitHash ) {
106
- return null;
107
- }
108
-
109
- // eslint-disable-next-line @stylistic/max-len
110
- return `https://github.com/ckeditor/${ projectName }/blob/${ gitHash }${ pathSuffix }#L${ file.lineNr }-L${ file.lineNr + file.len }`;
12
+ /**
13
+ * Returns a URL where a user will be redirect after clicking a "Report new issue" button.
14
+ *
15
+ * @param {Object} projectConfig
16
+ * @param {String} [projectConfig.issueUrl] An absolute URL for reporting an issue. If specified, it will be used.
17
+ * @param {String} [projectConfig.repoUrlDocs] An absolute URL where the repository is located.
18
+ * @returns {String}
19
+ */
20
+ export function getIssueUrl( projectConfig ) {
21
+ const reportIssueRepository = projectConfig.issueUrl || projectConfig.repoUrlDocs;
22
+
23
+ if ( !reportIssueRepository ) {
24
+ return '';
25
+ }
26
+
27
+ return `${ reportIssueRepository }/issues/new`;
28
+ }
29
+
30
+ /**
31
+ * Returns a URL where a user will be redirect after clicking a "Contribute to this guide" button.
32
+ *
33
+ * @param {Object} projectConfig
34
+ * @param {String} [projectConfig.contributeUrl] An absolute URL for contributing to the guide.
35
+ * @param {String} [projectConfig.repoUrlDocs] An absolute URL where the repository is located.
36
+ * @param {Boolean} [projectConfig.doNotAddDocsInPath=false] If set to true, `docs/` part won't be added to the URL.
37
+ * @param {String} sourceDirOrPathKey If `pathKey` was passed, `itemName` is not required. The `pathKey` part contains
38
+ * the rest of path to the page (including an extension). `sourceDir` is a directory where the entire SDK group is located.
39
+ * @param {String|null} [itemName=null] Name of the guide where the URL should be generated. Required if `sourceDirOrPathKey`
40
+ * contains the `sourceDir` for specified SDK group. In such case, `itemName` is a name from SDK item that belongs to given group.
41
+ * @returns {String}
42
+ */
43
+ export function getContributeUrl( projectConfig, sourceDirOrPathKey, itemName = null ) {
44
+ const contributeRepository = projectConfig.contributeUrl || projectConfig.repoUrlDocs;
45
+
46
+ if ( !contributeRepository ) {
47
+ return '';
48
+ }
49
+
50
+ const urlParts = [
51
+ contributeRepository,
52
+ 'blob',
53
+ 'master'
54
+ ];
55
+
56
+ if ( !projectConfig.doNotAddDocsInPath ) {
57
+ urlParts.push( 'docs' );
58
+ }
59
+
60
+ urlParts.push( sourceDirOrPathKey.replace( /^\//, '' ) );
61
+
62
+ if ( itemName ) {
63
+ urlParts.push( itemName + '.html' );
64
+ }
65
+
66
+ return urlParts.join( '/' );
67
+ }
68
+
69
+ /**
70
+ * Method obtain URL string with repository address including hash of github repository which was used to build given docs files.
71
+ *
72
+ * @param {String} repoUrl Repository url for which we need to obtain full url to github
73
+ * @param {Object} file Object storing details about given documentation entry
74
+ * @param {String} file.filePath Path to file where documentation was read
75
+ * @param {Number} file.lineNr Line number where documentation starts
76
+ * @param {Number} file.len Length of comment
77
+ *
78
+ * @returns {String/null} String URL to github with specific hash and line numbers to highlight
79
+ */
80
+ export function getFullGithubLink( repoUrl, file ) {
81
+ const filePath = file.filePath;
82
+
83
+ let projectName;
84
+
85
+ // TODO: Couldn't be the repository/github link obtained based on the file path?
86
+ // We know where the file is saved. Based on that, we could find the repository URL
87
+ // and adjust values.
88
+ if ( repoUrl.startsWith( '@ckeditor' ) ) {
89
+ projectName = filePath.match( /([^(?:/|\\)]+)(?:\/|\\)packages/ )[ 1 ];
90
+ } else {
91
+ projectName = repoUrl.replace( /\/*$/, '' ).match( /[^/]*$/ )[ 0 ];
111
92
  }
112
- };
113
93
 
114
- module.exports = utils;
94
+ const pathSuffix = _getPathSuffix( filePath );
95
+
96
+ if ( !pathSuffix ) {
97
+ return null;
98
+ }
99
+
100
+ const gitHash = _getGitHashFromPath( filePath.replace( pathSuffix, '' ) );
101
+
102
+ if ( !gitHash ) {
103
+ return null;
104
+ }
105
+
106
+ return `https://github.com/ckeditor/${ projectName }/blob/${ gitHash }${ pathSuffix }#L${ file.lineNr }-L${ file.lineNr + file.len }`;
107
+ }
115
108
 
116
109
  function _getPathSuffix( fileInGitRepositoryPath ) {
117
110
  const searchedGitPath = [ ...cachedGitPaths ].find( gitPath => fileInGitRepositoryPath.startsWith( gitPath ) );
@@ -3,9 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const escapeStringRegexp = require( 'escape-string-regexp' );
6
+ import escapeStringRegexp from 'escape-string-regexp';
9
7
 
10
8
  /**
11
9
  * Converts the specified `pattern` to an instance of RegExp.
@@ -13,8 +11,8 @@ const escapeStringRegexp = require( 'escape-string-regexp' );
13
11
  * @param {String} pattern
14
12
  * @return {RegExp}
15
13
  */
16
- module.exports = function globToRegexp( pattern ) {
14
+ export function globToRegexp( pattern ) {
17
15
  return new RegExp(
18
16
  escapeStringRegexp( pattern ).replace( /\\\*/g, '[\\s\\S]*' ).replace( /\//g, '[\\\\/]' )
19
17
  );
20
- };
18
+ }
@@ -3,14 +3,12 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Escapes string
10
8
  * @param str
11
9
  * @returns {String}
12
10
  */
13
- module.exports = str => {
11
+ export const htmlSafe = str => {
14
12
  if ( typeof str !== 'string' ) {
15
13
  str = String( str );
16
14
  }
@@ -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 { pathToFileURL } = require( 'node:url' );
6
+ import upath from 'upath';
7
+ import { pathToFileURL } from 'node:url';
10
8
 
11
9
  /**
12
10
  * Loads the specified module using `import()` call.
@@ -14,7 +12,7 @@ const { pathToFileURL } = require( 'node:url' );
14
12
  * @param {String} modulePath
15
13
  * @returns {Promise.<Function>}
16
14
  */
17
- module.exports = async function importModule( modulePath ) {
15
+ export async function importModule( modulePath ) {
18
16
  const modulePathAsFileURL = getPathAsFileURL( modulePath );
19
17
 
20
18
  return ( await import( modulePathAsFileURL ) ).default;
@@ -3,13 +3,11 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
6
  /**
9
7
  * Checks if value is a non-empty Array.
10
8
  * @param arr
11
9
  * @returns {boolean}
12
10
  */
13
- module.exports = arr => {
11
+ export const isNonEmptyArray = arr => {
14
12
  return Array.isArray( arr ) && arr.length > 0;
15
13
  };
@@ -3,11 +3,9 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import { styleText } from 'node:util';
7
7
 
8
- const { styleText } = require( 'node:util' );
9
-
10
- module.exports = function logWithTime( message ) {
8
+ export function logWithTime( message ) {
11
9
  const lowercase = message.charAt( 0 ).toLowerCase() + message.slice( 1 );
12
10
  const getTime = measureSeconds();
13
11
 
@@ -3,11 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
6
+ import { createRequire } from 'node:module';
7
+
8
+ const require = createRequire( import.meta.url );
7
9
 
8
10
  /**
9
11
  * Wrapper around `require.resolve()` to allow mocking it in tests.
10
12
  */
11
- module.exports = function resolvePath( path, options ) {
13
+ export function resolvePath( path, options ) {
12
14
  return require.resolve( path, options );
13
- };
15
+ }
@@ -3,61 +3,55 @@
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
-
11
- const utils = {
12
- /**
13
- * Checks whether snippets should be built for specified `projectName`.
14
- *
15
- * @param {String} projectName Current parsed project name.
16
- * @param {Object} hexo Options come from Hexo.
17
- * @returns {Boolean}
18
- */
19
- shouldBuildSnippets( projectName, hexo ) {
20
- if ( !hexo.projectGlobals || !hexo.projectGlobals[ projectName ] ) {
21
- return false;
22
- }
23
-
24
- if ( hexo.projectGlobals.common && hexo.projectGlobals.common.skipLiveSnippets ) {
25
- return false;
26
- }
27
-
28
- return true;
29
- },
30
-
31
- /**
32
- * Returns all files that are required for building the snippet.
33
- *
34
- * @param {String} basePath An absolute path where the snippets are saved.
35
- * @param {String} snippetName A name of the snippet which files are being looked for.
36
- * @returns {SnippetSource}
37
- */
38
- getSnippetSourcePaths( basePath, snippetName ) {
39
- const files = {};
40
-
41
- globSync( upath.join( basePath, snippetName + '.*' ) )
42
- .map( path => upath.normalize( path ) )
43
- .forEach( singlePath => {
44
- const fileExtension = upath.extname( singlePath ).slice( 1 );
45
-
46
- files[ fileExtension ] = singlePath;
47
- } );
48
-
49
- return files;
50
- },
51
-
52
- /**
53
- * Returns a HTML Comment Node that will be replaced with the proper snippet later.
54
- *
55
- * @param {String} snippetName
56
- * @returns {String}
57
- */
58
- getSnippetPlaceholder( snippetName ) {
59
- return `<!--UMBERTO: SNIPPET: "${ snippetName }"-->`;
6
+ import upath from 'upath';
7
+ import { globSync } from 'glob';
8
+
9
+ /**
10
+ * Checks whether snippets should be built for specified `projectName`.
11
+ *
12
+ * @param {String} projectName Current parsed project name.
13
+ * @param {Object} hexo Options come from Hexo.
14
+ * @returns {Boolean}
15
+ */
16
+ export function shouldBuildSnippets( projectName, hexo ) {
17
+ if ( !hexo.projectGlobals || !hexo.projectGlobals[ projectName ] ) {
18
+ return false;
60
19
  }
61
- };
62
20
 
63
- module.exports = utils;
21
+ if ( hexo.projectGlobals.common && hexo.projectGlobals.common.skipLiveSnippets ) {
22
+ return false;
23
+ }
24
+
25
+ return true;
26
+ }
27
+
28
+ /**
29
+ * Returns all files that are required for building the snippet.
30
+ *
31
+ * @param {String} basePath An absolute path where the snippets are saved.
32
+ * @param {String} snippetName A name of the snippet which files are being looked for.
33
+ * @returns {SnippetSource}
34
+ */
35
+ export function getSnippetSourcePaths( basePath, snippetName ) {
36
+ const files = {};
37
+
38
+ globSync( upath.join( basePath, snippetName + '.*' ) )
39
+ .map( path => upath.normalize( path ) )
40
+ .forEach( singlePath => {
41
+ const fileExtension = upath.extname( singlePath ).slice( 1 );
42
+
43
+ files[ fileExtension ] = singlePath;
44
+ } );
45
+
46
+ return files;
47
+ }
48
+
49
+ /**
50
+ * Returns a HTML Comment Node that will be replaced with the proper snippet later.
51
+ *
52
+ * @param {String} snippetName
53
+ * @returns {String}
54
+ */
55
+ export function getSnippetPlaceholder( snippetName ) {
56
+ return `<!--UMBERTO: SNIPPET: "${ snippetName }"-->`;
57
+ }
@@ -3,15 +3,13 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- const { MEMBER_NAME_REGEXP, LONG_NAME_LABEL_REGEXP } = require( '../api-builder/utils/utils' );
6
+ import { MEMBER_NAME_REGEXP, LONG_NAME_LABEL_REGEXP } from '../api-builder/utils/utils.js';
9
7
 
10
8
  /**
11
9
  * @param {String} longname
12
10
  * @returns {LongNameParts}
13
11
  */
14
- module.exports = longname => {
12
+ export const splitLongname = longname => {
15
13
  if ( !longname || typeof longname !== 'string' ) {
16
14
  return {};
17
15
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright (c) 2017-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+
6
+ import fs from 'node:fs';
7
+
8
+ const umbertoPackage = JSON.parse( fs.readFileSync( new URL( '../../package.json', import.meta.url ), 'utf8' ) );
9
+
10
+ export const umbertoVersion = umbertoPackage.version;
@@ -3,9 +3,7 @@
3
3
  * For licensing, see LICENSE.md.
4
4
  */
5
5
 
6
- 'use strict';
7
-
8
- module.exports = ( ctx, customConfig ) => {
6
+ export const extendConfig = ( ctx, customConfig ) => {
9
7
  ctx.extend.filter.register( 'after_init', () => {
10
8
  ctx.config = Object.assign( ctx.config, customConfig );
11
9
  // jscs:disable