@docusaurus/utils 2.0.0-beta.15d451942 → 2.0.0-beta.18

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 (106) hide show
  1. package/README.md +1 -1
  2. package/lib/constants.d.ts +68 -0
  3. package/lib/constants.d.ts.map +1 -0
  4. package/lib/constants.js +71 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/dataFileUtils.d.ts +60 -0
  7. package/lib/dataFileUtils.d.ts.map +1 -0
  8. package/lib/dataFileUtils.js +91 -0
  9. package/lib/dataFileUtils.js.map +1 -0
  10. package/lib/emitUtils.d.ts +35 -0
  11. package/lib/emitUtils.d.ts.map +1 -0
  12. package/lib/emitUtils.js +107 -0
  13. package/lib/emitUtils.js.map +1 -0
  14. package/lib/gitUtils.d.ts +66 -0
  15. package/lib/gitUtils.d.ts.map +1 -0
  16. package/lib/gitUtils.js +66 -0
  17. package/lib/gitUtils.js.map +1 -0
  18. package/lib/globUtils.d.ts +39 -0
  19. package/lib/globUtils.d.ts.map +1 -0
  20. package/lib/globUtils.js +66 -0
  21. package/lib/globUtils.js.map +1 -0
  22. package/lib/hashUtils.d.ts +17 -0
  23. package/lib/hashUtils.d.ts.map +1 -0
  24. package/lib/hashUtils.js +42 -0
  25. package/lib/hashUtils.js.map +1 -0
  26. package/lib/i18nUtils.d.ts +28 -0
  27. package/lib/i18nUtils.d.ts.map +1 -0
  28. package/lib/i18nUtils.js +49 -0
  29. package/lib/i18nUtils.js.map +1 -0
  30. package/lib/index.d.ts +16 -82
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +89 -411
  33. package/lib/index.js.map +1 -0
  34. package/lib/jsUtils.d.ts +45 -0
  35. package/lib/jsUtils.d.ts.map +1 -0
  36. package/lib/jsUtils.js +94 -0
  37. package/lib/jsUtils.js.map +1 -0
  38. package/lib/markdownLinks.d.ts +49 -5
  39. package/lib/markdownLinks.d.ts.map +1 -0
  40. package/lib/markdownLinks.js +48 -13
  41. package/lib/markdownLinks.js.map +1 -0
  42. package/lib/markdownUtils.d.ts +112 -0
  43. package/lib/markdownUtils.d.ts.map +1 -0
  44. package/lib/markdownUtils.js +271 -0
  45. package/lib/markdownUtils.js.map +1 -0
  46. package/lib/pathUtils.d.ts +52 -0
  47. package/lib/pathUtils.d.ts.map +1 -0
  48. package/lib/pathUtils.js +113 -0
  49. package/lib/pathUtils.js.map +1 -0
  50. package/lib/slugger.d.ts +24 -0
  51. package/lib/slugger.d.ts.map +1 -0
  52. package/lib/slugger.js +23 -0
  53. package/lib/slugger.js.map +1 -0
  54. package/lib/tags.d.ts +48 -0
  55. package/lib/tags.d.ts.map +1 -0
  56. package/lib/tags.js +91 -0
  57. package/lib/tags.js.map +1 -0
  58. package/lib/urlUtils.d.ts +66 -0
  59. package/lib/urlUtils.d.ts.map +1 -0
  60. package/lib/urlUtils.js +208 -0
  61. package/lib/urlUtils.js.map +1 -0
  62. package/lib/webpackUtils.d.ts +35 -0
  63. package/lib/webpackUtils.d.ts.map +1 -0
  64. package/lib/webpackUtils.js +116 -0
  65. package/lib/webpackUtils.js.map +1 -0
  66. package/package.json +20 -10
  67. package/src/constants.ts +90 -0
  68. package/src/dataFileUtils.ts +122 -0
  69. package/src/deps.d.ts +10 -0
  70. package/src/emitUtils.ts +130 -0
  71. package/src/gitUtils.ts +153 -0
  72. package/src/globUtils.ts +80 -0
  73. package/src/hashUtils.ts +38 -0
  74. package/src/i18nUtils.ts +67 -0
  75. package/src/index.ts +94 -521
  76. package/src/jsUtils.ts +102 -0
  77. package/src/markdownLinks.ts +89 -30
  78. package/src/markdownUtils.ts +354 -0
  79. package/src/pathUtils.ts +121 -0
  80. package/src/slugger.ts +36 -0
  81. package/src/tags.ts +117 -0
  82. package/src/urlUtils.ts +235 -0
  83. package/src/webpackUtils.ts +154 -0
  84. package/lib/.tsbuildinfo +0 -3972
  85. package/lib/codeTranslationsUtils.d.ts +0 -11
  86. package/lib/codeTranslationsUtils.js +0 -50
  87. package/lib/escapePath.d.ts +0 -17
  88. package/lib/escapePath.js +0 -25
  89. package/lib/markdownParser.d.ts +0 -28
  90. package/lib/markdownParser.js +0 -132
  91. package/lib/posixPath.d.ts +0 -14
  92. package/lib/posixPath.js +0 -28
  93. package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
  94. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
  95. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
  96. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
  97. package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
  98. package/src/__tests__/escapePath.test.ts +0 -25
  99. package/src/__tests__/index.test.ts +0 -681
  100. package/src/__tests__/markdownParser.test.ts +0 -772
  101. package/src/__tests__/posixPath.test.ts +0 -25
  102. package/src/codeTranslationsUtils.ts +0 -56
  103. package/src/escapePath.ts +0 -23
  104. package/src/markdownParser.ts +0 -177
  105. package/src/posixPath.ts +0 -27
  106. package/tsconfig.json +0 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globUtils.d.ts","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,0CAA0C;AAC1C,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,QAAQ,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,aAAK,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAKzD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAmBT"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = void 0;
10
+ const tslib_1 = require("tslib");
11
+ // Globby/Micromatch are the 2 libs we use in Docusaurus consistently
12
+ const micromatch_1 = tslib_1.__importDefault(require("micromatch")); // Note: Micromatch is used by Globby
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
+ /** A re-export of the globby instance. */
15
+ var globby_1 = require("globby");
16
+ Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return tslib_1.__importDefault(globby_1).default; } });
17
+ /**
18
+ * The default glob patterns we ignore when sourcing content.
19
+ * - Ignore files and folders starting with `_` recursively
20
+ * - Ignore tests
21
+ */
22
+ exports.GlobExcludeDefault = [
23
+ '**/_*.{js,jsx,ts,tsx,md,mdx}',
24
+ '**/_*/**',
25
+ '**/*.test.{js,jsx,ts,tsx}',
26
+ '**/__tests__/**',
27
+ ];
28
+ /**
29
+ * A very thin wrapper around `Micromatch.makeRe`.
30
+ *
31
+ * @see {@link createAbsoluteFilePathMatcher}
32
+ * @param patterns A list of glob patterns.
33
+ * @returns A matcher handle that tells if a file path is matched by any of the
34
+ * patterns.
35
+ */
36
+ function createMatcher(patterns) {
37
+ const regexp = new RegExp(patterns.map((pattern) => micromatch_1.default.makeRe(pattern).source).join('|'));
38
+ return (str) => regexp.test(str);
39
+ }
40
+ exports.createMatcher = createMatcher;
41
+ /**
42
+ * We use match patterns like `"** /_* /**"` (ignore the spaces), where `"_*"`
43
+ * should only be matched within a subfolder. This function would:
44
+ * - Match `/user/sebastien/website/docs/_partials/xyz.md`
45
+ * - Ignore `/user/_sebastien/website/docs/partials/xyz.md`
46
+ *
47
+ * @param patterns A list of glob patterns.
48
+ * @param rootFolders A list of root folders to resolve the glob from.
49
+ * @returns A matcher handle that tells if a file path is matched by any of the
50
+ * patterns, resolved from the first root folder that contains the path.
51
+ * @throws Throws when the returned matcher receives a path that doesn't belong
52
+ * to any of the `rootFolders`.
53
+ */
54
+ function createAbsoluteFilePathMatcher(patterns, rootFolders) {
55
+ const matcher = createMatcher(patterns);
56
+ function getRelativeFilePath(absoluteFilePath) {
57
+ const rootFolder = rootFolders.find((folderPath) => absoluteFilePath.startsWith(folderPath));
58
+ if (!rootFolder) {
59
+ throw new Error(`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders: ${rootFolders.join(', ')}`);
60
+ }
61
+ return path_1.default.relative(rootFolder, absoluteFilePath);
62
+ }
63
+ return (absoluteFilePath) => matcher(getRelativeFilePath(absoluteFilePath));
64
+ }
65
+ exports.createAbsoluteFilePathMatcher = createAbsoluteFilePathMatcher;
66
+ //# sourceMappingURL=globUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globUtils.js","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,qEAAqE;AAErE,oEAAoC,CAAC,qCAAqC;AAC1E,wDAAwB;AAExB,0CAA0C;AAC1C,iCAAyC;AAAjC,yHAAA,OAAO,OAAU;AAEzB;;;;GAIG;AACU,QAAA,kBAAkB,GAAG;IAChC,8BAA8B;IAC9B,UAAU;IACV,2BAA2B;IAC3B,iBAAiB;CAClB,CAAC;AAIF;;;;;;;GAOG;AACH,SAAgB,aAAa,CAAC,QAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACvE,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AALD,sCAKC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,6BAA6B,CAC3C,QAAkB,EAClB,WAAqB;IAErB,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAExC,SAAS,mBAAmB,CAAC,gBAAwB;QACnD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACjD,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CACxC,CAAC;QACF,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CACb,oEAAoE,gBAAgB,kDAAkD,WAAW,CAAC,IAAI,CACpJ,IAAI,CACL,EAAE,CACJ,CAAC;SACH;QACD,OAAO,cAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,gBAAwB,EAAE,EAAE,CAClC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACnD,CAAC;AAtBD,sEAsBC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /** Thin wrapper around `crypto.createHash("md5")`. */
8
+ export declare function md5Hash(str: string): string;
9
+ /** Creates an MD5 hash and truncates it to the given length. */
10
+ export declare function simpleHash(str: string, length: number): string;
11
+ /**
12
+ * Given an input string, convert to kebab-case and append a hash, avoiding name
13
+ * collision. Also removes part of the string if its larger than the allowed
14
+ * filename per OS, avoiding `ERRNAMETOOLONG` error.
15
+ */
16
+ export declare function docuHash(str: string): string;
17
+ //# sourceMappingURL=hashUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashUtils.d.ts","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,sDAAsD;AACtD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D;AAGD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU5C"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.docuHash = exports.simpleHash = exports.md5Hash = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const crypto_1 = require("crypto");
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
+ const pathUtils_1 = require("./pathUtils");
14
+ /** Thin wrapper around `crypto.createHash("md5")`. */
15
+ function md5Hash(str) {
16
+ return (0, crypto_1.createHash)('md5').update(str).digest('hex');
17
+ }
18
+ exports.md5Hash = md5Hash;
19
+ /** Creates an MD5 hash and truncates it to the given length. */
20
+ function simpleHash(str, length) {
21
+ return md5Hash(str).substring(0, length);
22
+ }
23
+ exports.simpleHash = simpleHash;
24
+ // Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
25
+ /**
26
+ * Given an input string, convert to kebab-case and append a hash, avoiding name
27
+ * collision. Also removes part of the string if its larger than the allowed
28
+ * filename per OS, avoiding `ERRNAMETOOLONG` error.
29
+ */
30
+ function docuHash(str) {
31
+ if (str === '/') {
32
+ return 'index';
33
+ }
34
+ const shortHash = simpleHash(str, 3);
35
+ const parsedPath = `${lodash_1.default.kebabCase(str)}-${shortHash}`;
36
+ if ((0, pathUtils_1.isNameTooLong)(parsedPath)) {
37
+ return `${(0, pathUtils_1.shortName)(lodash_1.default.kebabCase(str))}-${shortHash}`;
38
+ }
39
+ return parsedPath;
40
+ }
41
+ exports.docuHash = docuHash;
42
+ //# sourceMappingURL=hashUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,mCAAkC;AAClC,4DAAuB;AACvB,2CAAqD;AAErD,sDAAsD;AACtD,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC;AAED,gEAAgE;AAChE,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAc;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,+DAA+D;AAC/D;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,IAAI,GAAG,KAAK,GAAG,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IACtD,IAAI,IAAA,yBAAa,EAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,GAAG,IAAA,qBAAS,EAAC,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;KACtD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAVD,4BAUC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { TranslationFileContent, TranslationFile } from '@docusaurus/types';
8
+ /**
9
+ * Takes a list of translation file contents, and shallow-merges them into one.
10
+ */
11
+ export declare function mergeTranslations(contents: TranslationFileContent[]): TranslationFileContent;
12
+ /**
13
+ * Useful to update all the messages of a translation file. Used in tests to
14
+ * simulate translations.
15
+ */
16
+ export declare function updateTranslationFileMessages(translationFile: TranslationFile, updateMessage: (message: string) => string): TranslationFile;
17
+ /**
18
+ * Takes everything needed and constructs a plugin i18n path. Plugins should
19
+ * expect everything it needs for translations to be found under this path.
20
+ */
21
+ export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, subPaths, }: {
22
+ siteDir: string;
23
+ locale: string;
24
+ pluginName: string;
25
+ pluginId?: string | undefined;
26
+ subPaths?: string[];
27
+ }): string;
28
+ //# sourceMappingURL=i18nUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAG/E;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,sBAAsB,EAAE,GACjC,sBAAsB,CAExB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACzC,eAAe,CAQjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAA4B,EAC5B,QAAa,GACd,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,MAAM,CAYT"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
+ const constants_1 = require("./constants");
14
+ /**
15
+ * Takes a list of translation file contents, and shallow-merges them into one.
16
+ */
17
+ function mergeTranslations(contents) {
18
+ return contents.reduce((acc, content) => ({ ...acc, ...content }), {});
19
+ }
20
+ exports.mergeTranslations = mergeTranslations;
21
+ /**
22
+ * Useful to update all the messages of a translation file. Used in tests to
23
+ * simulate translations.
24
+ */
25
+ function updateTranslationFileMessages(translationFile, updateMessage) {
26
+ return {
27
+ ...translationFile,
28
+ content: lodash_1.default.mapValues(translationFile.content, (translation) => ({
29
+ ...translation,
30
+ message: updateMessage(translation.message),
31
+ })),
32
+ };
33
+ }
34
+ exports.updateTranslationFileMessages = updateTranslationFileMessages;
35
+ /**
36
+ * Takes everything needed and constructs a plugin i18n path. Plugins should
37
+ * expect everything it needs for translations to be found under this path.
38
+ */
39
+ function getPluginI18nPath({ siteDir, locale, pluginName, pluginId = constants_1.DEFAULT_PLUGIN_ID, subPaths = [], }) {
40
+ return path_1.default.join(siteDir, constants_1.I18N_DIR_NAME,
41
+ // namespace first by locale: convenient to work in a single folder for a
42
+ // translator
43
+ locale,
44
+ // Make it convenient to use for single-instance
45
+ // ie: return "docs", not "docs-default" nor "docs/default"
46
+ `${pluginName}${pluginId === constants_1.DEFAULT_PLUGIN_ID ? '' : `-${pluginId}`}`, ...subPaths);
47
+ }
48
+ exports.getPluginI18nPath = getPluginI18nPath;
49
+ //# sourceMappingURL=i18nUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,4DAAuB;AAEvB,2CAA6D;AAE7D;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,QAAkC;IAElC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,OAAO,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAJD,8CAIC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,eAAgC,EAChC,aAA0C;IAE1C,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,gBAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,WAAW;YACd,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAXD,sEAWC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAAQ,GAAG,6BAAiB,EAC5B,QAAQ,GAAG,EAAE,GAOd;IACC,OAAO,cAAI,CAAC,IAAI,CACd,OAAO,EACP,yBAAa;IACb,yEAAyE;IACzE,aAAa;IACb,MAAM;IACN,gDAAgD;IAChD,2DAA2D;IAC3D,GAAG,UAAU,GAAG,QAAQ,KAAK,6BAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,EAAE,EACtE,GAAG,QAAQ,CACZ,CAAC;AACJ,CAAC;AAxBD,8CAwBC"}
package/lib/index.d.ts CHANGED
@@ -4,85 +4,19 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { ReportingSeverity, TranslationFileContent, TranslationFile } from '@docusaurus/types';
8
- import { posixPath as posixPathImport } from './posixPath';
9
- export declare const posixPath: typeof posixPathImport;
10
- export * from './codeTranslationsUtils';
11
- export * from './markdownParser';
12
- export * from './markdownLinks';
13
- export * from './escapePath';
14
- export declare function generate(generatedFilesDir: string, file: string, content: string, skipCache?: boolean): Promise<void>;
15
- export declare function objectWithKeySorted<T>(obj: Record<string, T>): Record<string, T>;
16
- /**
17
- * Convert filepath to url path.
18
- * Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
19
- */
20
- export declare function fileToPath(file: string): string;
21
- export declare function encodePath(userpath: string): string;
22
- export declare function simpleHash(str: string, length: number): string;
23
- /**
24
- * Given an input string, convert to kebab-case and append a hash.
25
- * Avoid str collision.
26
- */
27
- export declare function docuHash(str: string): string;
28
- /**
29
- * Convert first string character to the upper case.
30
- * E.g: docusaurus -> Docusaurus
31
- */
32
- export declare function upperFirst(str: string): string;
33
- /**
34
- * Generate unique React Component Name.
35
- * E.g: /foo-bar -> FooBar096
36
- */
37
- export declare function genComponentName(pagePath: string): string;
38
- export declare function toMessageRelativeFilePath(filePath: string): string;
39
- /**
40
- * Generate unique chunk name given a module path.
41
- */
42
- export declare function genChunkName(modulePath: string, prefix?: string, preferredName?: string, shortId?: boolean): string;
43
- export declare function idx(target: any, keyPaths?: string | (string | number)[]): any;
44
- /**
45
- * Given a filepath and dirpath, get the first directory.
46
- */
47
- export declare function getSubFolder(file: string, refDir: string): string | null;
48
- export declare function normalizeUrl(rawUrls: string[]): string;
49
- /**
50
- * Alias filepath relative to site directory, very useful so that we
51
- * don't expose user's site structure.
52
- * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
53
- */
54
- export declare function aliasedSitePath(filePath: string, siteDir: string): string;
55
- export declare function getEditUrl(fileRelativePath: string, editUrl?: string): string | undefined;
56
- export declare function isValidPathname(str: string): boolean;
57
- export declare function resolvePathname(to: string, from?: string): string;
58
- export declare function addLeadingSlash(str: string): string;
59
- export declare function addTrailingSlash(str: string): string;
60
- export declare function addTrailingPathSeparator(str: string): string;
61
- export declare function removeTrailingSlash(str: string): string;
62
- export declare function removeSuffix(str: string, suffix: string): string;
63
- export declare function removePrefix(str: string, prefix: string): string;
64
- export declare function getFilePathForRoutePath(routePath: string): string;
65
- export declare function getElementsAround<T extends unknown>(array: T[], aroundIndex: number): {
66
- next: T | undefined;
67
- previous: T | undefined;
68
- };
69
- export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, // TODO duplicated constant
70
- subPaths, }: {
71
- siteDir: string;
72
- locale: string;
73
- pluginName: string;
74
- pluginId?: string | undefined;
75
- subPaths?: string[];
76
- }): string;
77
- export declare function mapAsyncSequencial<T extends unknown, R extends unknown>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
78
- export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
79
- export declare function findFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string | undefined>;
80
- export declare function getFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string>;
81
- export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void;
82
- export declare function mergeTranslations(contents: TranslationFileContent[]): TranslationFileContent;
83
- export declare function getSwizzledComponent(componentPath: string): string | undefined;
84
- export declare function updateTranslationFileMessages(translationFile: TranslationFile, updateMessage: (message: string) => string): TranslationFile;
85
- export declare function parseMarkdownHeadingId(heading: string): {
86
- text: string;
87
- id?: string;
88
- };
7
+ export { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, DEFAULT_STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, I18N_DIR_NAME, CODE_TRANSLATIONS_FILE_NAME, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
8
+ export { generate, genChunkName, readOutputHTMLFile } from './emitUtils';
9
+ export { getFileCommitDate, FileNotTrackedError, GitNotFoundError, } from './gitUtils';
10
+ export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, } from './i18nUtils';
11
+ export { removeSuffix, removePrefix, mapAsyncSequential, findAsyncSequential, reportMessage, } from './jsUtils';
12
+ export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, addLeadingSlash, addTrailingSlash, removeTrailingSlash, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
13
+ export { type Tag, type FrontMatterTag, normalizeFrontMatterTags, groupTaggedItems, } from './tags';
14
+ export { parseMarkdownHeadingId, createExcerpt, parseFrontMatter, parseMarkdownContentTitle, parseMarkdownString, writeMarkdownHeadingId, type WriteHeadingIDOptions, } from './markdownUtils';
15
+ export { type ContentPaths, type BrokenMarkdownLink, replaceMarkdownLinks, } from './markdownLinks';
16
+ export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
17
+ export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, escapePath, addTrailingPathSeparator, } from './pathUtils';
18
+ export { md5Hash, simpleHash, docuHash } from './hashUtils';
19
+ export { Globby, GlobExcludeDefault, createMatcher, createAbsoluteFilePathMatcher, } from './globUtils';
20
+ export { getFileLoaderUtils } from './webpackUtils';
21
+ export { getDataFilePath, getDataFileData, getContentPathList, findFolderContainingFile, getFolderContainingFile, } from './dataFileUtils';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,aAAa,EACb,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}