@docusaurus/utils 2.0.0-beta.15a2b59f9 → 2.0.0-beta.17

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 (104) hide show
  1. package/lib/constants.d.ts +20 -0
  2. package/lib/constants.d.ts.map +1 -0
  3. package/lib/constants.js +26 -0
  4. package/lib/constants.js.map +1 -0
  5. package/lib/dataFileUtils.d.ts +24 -0
  6. package/lib/dataFileUtils.d.ts.map +1 -0
  7. package/lib/dataFileUtils.js +65 -0
  8. package/lib/dataFileUtils.js.map +1 -0
  9. package/lib/emitUtils.d.ts +23 -0
  10. package/lib/emitUtils.d.ts.map +1 -0
  11. package/lib/emitUtils.js +90 -0
  12. package/lib/emitUtils.js.map +1 -0
  13. package/lib/gitUtils.d.ts +17 -0
  14. package/lib/gitUtils.d.ts.map +1 -0
  15. package/lib/gitUtils.js +63 -0
  16. package/lib/gitUtils.js.map +1 -0
  17. package/lib/globUtils.d.ts +12 -0
  18. package/lib/globUtils.d.ts.map +1 -0
  19. package/lib/globUtils.js +48 -0
  20. package/lib/globUtils.js.map +1 -0
  21. package/lib/hashUtils.d.ts +1 -0
  22. package/lib/hashUtils.d.ts.map +1 -0
  23. package/lib/hashUtils.js +7 -5
  24. package/lib/hashUtils.js.map +1 -0
  25. package/lib/i18nUtils.d.ts +17 -0
  26. package/lib/i18nUtils.d.ts.map +1 -0
  27. package/lib/i18nUtils.js +40 -0
  28. package/lib/i18nUtils.js.map +1 -0
  29. package/lib/index.d.ts +15 -75
  30. package/lib/index.d.ts.map +1 -0
  31. package/lib/index.js +84 -395
  32. package/lib/index.js.map +1 -0
  33. package/lib/jsUtils.d.ts +17 -0
  34. package/lib/jsUtils.d.ts.map +1 -0
  35. package/lib/jsUtils.js +72 -0
  36. package/lib/jsUtils.js.map +1 -0
  37. package/lib/markdownLinks.d.ts +1 -0
  38. package/lib/markdownLinks.d.ts.map +1 -0
  39. package/lib/markdownLinks.js +36 -11
  40. package/lib/markdownLinks.js.map +1 -0
  41. package/lib/markdownParser.d.ts +5 -3
  42. package/lib/markdownParser.d.ts.map +1 -0
  43. package/lib/markdownParser.js +72 -52
  44. package/lib/markdownParser.js.map +1 -0
  45. package/lib/pathUtils.d.ts +44 -0
  46. package/lib/pathUtils.d.ts.map +1 -0
  47. package/lib/pathUtils.js +88 -10
  48. package/lib/pathUtils.js.map +1 -0
  49. package/lib/slugger.d.ts +14 -0
  50. package/lib/slugger.d.ts.map +1 -0
  51. package/lib/slugger.js +19 -0
  52. package/lib/slugger.js.map +1 -0
  53. package/lib/tags.d.ts +27 -0
  54. package/lib/tags.d.ts.map +1 -0
  55. package/lib/tags.js +76 -0
  56. package/lib/tags.js.map +1 -0
  57. package/lib/urlUtils.d.ts +20 -0
  58. package/lib/urlUtils.d.ts.map +1 -0
  59. package/lib/urlUtils.js +136 -0
  60. package/lib/urlUtils.js.map +1 -0
  61. package/lib/webpackUtils.d.ts +30 -0
  62. package/lib/webpackUtils.d.ts.map +1 -0
  63. package/lib/webpackUtils.js +112 -0
  64. package/lib/webpackUtils.js.map +1 -0
  65. package/package.json +20 -10
  66. package/src/constants.ts +38 -0
  67. package/src/dataFileUtils.ts +90 -0
  68. package/src/deps.d.ts +10 -0
  69. package/src/emitUtils.ts +113 -0
  70. package/src/gitUtils.ts +93 -0
  71. package/src/globUtils.ts +64 -0
  72. package/src/hashUtils.ts +3 -3
  73. package/src/i18nUtils.ts +58 -0
  74. package/src/index.ts +87 -502
  75. package/src/jsUtils.ts +88 -0
  76. package/src/markdownLinks.ts +35 -13
  77. package/src/markdownParser.ts +76 -57
  78. package/src/pathUtils.ts +87 -8
  79. package/src/slugger.ts +24 -0
  80. package/src/tags.ts +105 -0
  81. package/src/urlUtils.ts +149 -0
  82. package/src/webpackUtils.ts +146 -0
  83. package/lib/.tsbuildinfo +0 -1
  84. package/lib/codeTranslationsUtils.d.ts +0 -11
  85. package/lib/codeTranslationsUtils.js +0 -50
  86. package/lib/escapePath.d.ts +0 -17
  87. package/lib/escapePath.js +0 -25
  88. package/lib/posixPath.d.ts +0 -14
  89. package/lib/posixPath.js +0 -28
  90. package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
  91. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
  92. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
  93. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
  94. package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
  95. package/src/__tests__/escapePath.test.ts +0 -25
  96. package/src/__tests__/hashUtils.test.ts +0 -51
  97. package/src/__tests__/index.test.ts +0 -631
  98. package/src/__tests__/markdownParser.test.ts +0 -817
  99. package/src/__tests__/pathUtils.test.ts +0 -63
  100. package/src/__tests__/posixPath.test.ts +0 -25
  101. package/src/codeTranslationsUtils.ts +0 -56
  102. package/src/escapePath.ts +0 -23
  103. package/src/posixPath.ts +0 -27
  104. package/tsconfig.json +0 -9
package/lib/index.d.ts CHANGED
@@ -4,79 +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';
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, STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
8
+ export { generate, genChunkName, readOutputHTMLFile } from './emitUtils';
9
+ export { getFileCommitDate, GitNotFoundError } from './gitUtils';
10
+ export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, } from './i18nUtils';
11
+ export { removeSuffix, removePrefix, getElementsAround, mapAsyncSequential, findAsyncSequential, reportMessage, } from './jsUtils';
12
+ export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, addLeadingSlash, addTrailingSlash, removeTrailingSlash, } from './urlUtils';
13
+ export { type Tag, type FrontMatterTag, type TaggedItemGroup, normalizeFrontMatterTag, normalizeFrontMatterTags, groupTaggedItems, } from './tags';
14
+ export { parseMarkdownHeadingId, createExcerpt, parseFrontMatter, parseMarkdownContentTitle, parseMarkdownString, } from './markdownParser';
15
+ export { type ContentPaths, type BrokenMarkdownLink, type ReplaceMarkdownLinksParams, type ReplaceMarkdownLinksReturn, replaceMarkdownLinks, } from './markdownLinks';
16
+ export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
17
+ export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, escapePath, addTrailingPathSeparator, } from './pathUtils';
14
18
  export { md5Hash, simpleHash, docuHash } from './hashUtils';
15
- export declare function generate(generatedFilesDir: string, file: string, content: string, skipCache?: boolean): Promise<void>;
16
- export declare function objectWithKeySorted<T>(obj: Record<string, T>): Record<string, T>;
17
- /**
18
- * Convert filepath to url path.
19
- * Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
20
- */
21
- export declare function fileToPath(file: string): string;
22
- export declare function encodePath(userpath: string): string;
23
- /**
24
- * Convert first string character to the upper case.
25
- * E.g: docusaurus -> Docusaurus
26
- */
27
- export declare function upperFirst(str: string): string;
28
- /**
29
- * Generate unique React Component Name.
30
- * E.g: /foo-bar -> FooBar096
31
- */
32
- export declare function genComponentName(pagePath: string): string;
33
- export declare function toMessageRelativeFilePath(filePath: string): string;
34
- /**
35
- * Generate unique chunk name given a module path.
36
- */
37
- export declare function genChunkName(modulePath: string, prefix?: string, preferredName?: string, shortId?: boolean): string;
38
- export declare function idx(target: any, keyPaths?: string | (string | number)[]): any;
39
- /**
40
- * Given a filepath and dirpath, get the first directory.
41
- */
42
- export declare function getSubFolder(file: string, refDir: string): string | null;
43
- export declare function normalizeUrl(rawUrls: string[]): string;
44
- /**
45
- * Alias filepath relative to site directory, very useful so that we
46
- * don't expose user's site structure.
47
- * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
48
- */
49
- export declare function aliasedSitePath(filePath: string, siteDir: string): string;
50
- export declare function getEditUrl(fileRelativePath: string, editUrl?: string): string | undefined;
51
- export declare function isValidPathname(str: string): boolean;
52
- export declare function resolvePathname(to: string, from?: string): string;
53
- export declare function addLeadingSlash(str: string): string;
54
- export declare function addTrailingPathSeparator(str: string): string;
55
- export declare function addTrailingSlash(str: string): string;
56
- export declare function removeTrailingSlash(str: string): string;
57
- export declare function removeSuffix(str: string, suffix: string): string;
58
- export declare function removePrefix(str: string, prefix: string): string;
59
- export declare function getElementsAround<T extends unknown>(array: T[], aroundIndex: number): {
60
- next: T | undefined;
61
- previous: T | undefined;
62
- };
63
- export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, // TODO duplicated constant
64
- subPaths, }: {
65
- siteDir: string;
66
- locale: string;
67
- pluginName: string;
68
- pluginId?: string | undefined;
69
- subPaths?: string[];
70
- }): string;
71
- export declare function mapAsyncSequencial<T extends unknown, R extends unknown>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
72
- export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
73
- export declare function findFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string | undefined>;
74
- export declare function getFolderContainingFile(folderPaths: string[], relativeFilePath: string): Promise<string>;
75
- export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void;
76
- export declare function mergeTranslations(contents: TranslationFileContent[]): TranslationFileContent;
77
- export declare function getSwizzledComponent(componentPath: string): string | undefined;
78
- export declare function updateTranslationFileMessages(translationFile: TranslationFile, updateMessage: (message: string) => string): TranslationFile;
79
- export declare function parseMarkdownHeadingId(heading: string): {
80
- text: string;
81
- id?: string;
82
- };
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,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,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,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,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"}
package/lib/index.js CHANGED
@@ -6,398 +6,87 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.parseMarkdownHeadingId = exports.updateTranslationFileMessages = exports.getSwizzledComponent = exports.mergeTranslations = exports.reportMessage = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.findAsyncSequential = exports.mapAsyncSequencial = exports.getPluginI18nPath = exports.getElementsAround = exports.removePrefix = exports.removeSuffix = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addTrailingPathSeparator = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.getEditUrl = exports.aliasedSitePath = exports.normalizeUrl = exports.getSubFolder = exports.idx = exports.genChunkName = exports.toMessageRelativeFilePath = exports.genComponentName = exports.upperFirst = exports.encodePath = exports.fileToPath = exports.objectWithKeySorted = exports.generate = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.posixPath = void 0;
10
- const tslib_1 = require("tslib");
11
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
12
- const path_1 = tslib_1.__importDefault(require("path"));
13
- const crypto_1 = require("crypto");
14
- const lodash_1 = require("lodash");
15
- const escape_string_regexp_1 = tslib_1.__importDefault(require("escape-string-regexp"));
16
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
17
- const url_1 = require("url");
18
- // @ts-expect-error: no typedefs :s
19
- const resolve_pathname_1 = tslib_1.__importDefault(require("resolve-pathname"));
20
- const posixPath_1 = require("./posixPath");
21
- const hashUtils_1 = require("./hashUtils");
22
- exports.posixPath = posixPath_1.posixPath;
23
- tslib_1.__exportStar(require("./codeTranslationsUtils"), exports);
24
- tslib_1.__exportStar(require("./markdownParser"), exports);
25
- tslib_1.__exportStar(require("./markdownLinks"), exports);
26
- tslib_1.__exportStar(require("./escapePath"), exports);
27
- var hashUtils_2 = require("./hashUtils");
28
- Object.defineProperty(exports, "md5Hash", { enumerable: true, get: function () { return hashUtils_2.md5Hash; } });
29
- Object.defineProperty(exports, "simpleHash", { enumerable: true, get: function () { return hashUtils_2.simpleHash; } });
30
- Object.defineProperty(exports, "docuHash", { enumerable: true, get: function () { return hashUtils_2.docuHash; } });
31
- const fileHash = new Map();
32
- async function generate(generatedFilesDir, file, content, skipCache = process.env.NODE_ENV === 'production') {
33
- const filepath = path_1.default.join(generatedFilesDir, file);
34
- if (skipCache) {
35
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
36
- await fs_extra_1.default.writeFile(filepath, content);
37
- return;
38
- }
39
- let lastHash = fileHash.get(filepath);
40
- // If file already exists but its not in runtime cache yet,
41
- // we try to calculate the content hash and then compare
42
- // This is to avoid unnecessary overwriting and we can reuse old file.
43
- if (!lastHash && fs_extra_1.default.existsSync(filepath)) {
44
- const lastContent = await fs_extra_1.default.readFile(filepath, 'utf8');
45
- lastHash = crypto_1.createHash('md5').update(lastContent).digest('hex');
46
- fileHash.set(filepath, lastHash);
47
- }
48
- const currentHash = crypto_1.createHash('md5').update(content).digest('hex');
49
- if (lastHash !== currentHash) {
50
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
51
- await fs_extra_1.default.writeFile(filepath, content);
52
- fileHash.set(filepath, currentHash);
53
- }
54
- }
55
- exports.generate = generate;
56
- function objectWithKeySorted(obj) {
57
- // https://github.com/lodash/lodash/issues/1459#issuecomment-460941233
58
- return Object.keys(obj)
59
- .sort()
60
- .reduce((acc, key) => {
61
- acc[key] = obj[key];
62
- return acc;
63
- }, {});
64
- }
65
- exports.objectWithKeySorted = objectWithKeySorted;
66
- const indexRE = /(^|.*\/)index\.(md|mdx|js|jsx|ts|tsx)$/i;
67
- const extRE = /\.(md|mdx|js|jsx|ts|tsx)$/;
68
- /**
69
- * Convert filepath to url path.
70
- * Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
71
- */
72
- function fileToPath(file) {
73
- if (indexRE.test(file)) {
74
- return file.replace(indexRE, '/$1');
75
- }
76
- return `/${file.replace(extRE, '').replace(/\\/g, '/')}`;
77
- }
78
- exports.fileToPath = fileToPath;
79
- function encodePath(userpath) {
80
- return userpath
81
- .split('/')
82
- .map((item) => encodeURIComponent(item))
83
- .join('/');
84
- }
85
- exports.encodePath = encodePath;
86
- /**
87
- * Convert first string character to the upper case.
88
- * E.g: docusaurus -> Docusaurus
89
- */
90
- function upperFirst(str) {
91
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : '';
92
- }
93
- exports.upperFirst = upperFirst;
94
- /**
95
- * Generate unique React Component Name.
96
- * E.g: /foo-bar -> FooBar096
97
- */
98
- function genComponentName(pagePath) {
99
- if (pagePath === '/') {
100
- return 'index';
101
- }
102
- const pageHash = hashUtils_1.docuHash(pagePath);
103
- return upperFirst(lodash_1.camelCase(pageHash));
104
- }
105
- exports.genComponentName = genComponentName;
106
- // When you want to display a path in a message/warning/error,
107
- // it's more convenient to:
108
- // - make it relative to cwd()
109
- // - convert to posix (ie not using windows \ path separator)
110
- // This way, Jest tests can run more reliably on any computer/CI
111
- // on both Unix/Windows
112
- // For Windows users this is not perfect (as they see / instead of \) but it's probably good enough
113
- function toMessageRelativeFilePath(filePath) {
114
- return exports.posixPath(path_1.default.relative(process.cwd(), filePath));
115
- }
116
- exports.toMessageRelativeFilePath = toMessageRelativeFilePath;
117
- const chunkNameCache = new Map();
118
- /**
119
- * Generate unique chunk name given a module path.
120
- */
121
- function genChunkName(modulePath, prefix, preferredName, shortId = process.env.NODE_ENV === 'production') {
122
- let chunkName = chunkNameCache.get(modulePath);
123
- if (!chunkName) {
124
- if (shortId) {
125
- chunkName = hashUtils_1.simpleHash(modulePath, 8);
126
- }
127
- else {
128
- let str = modulePath;
129
- if (preferredName) {
130
- const shortHash = hashUtils_1.simpleHash(modulePath, 3);
131
- str = `${preferredName}${shortHash}`;
132
- }
133
- const name = str === '/' ? 'index' : hashUtils_1.docuHash(str);
134
- chunkName = prefix ? `${prefix}---${name}` : name;
135
- }
136
- chunkNameCache.set(modulePath, chunkName);
137
- }
138
- return chunkName;
139
- }
140
- exports.genChunkName = genChunkName;
141
- // Too dynamic
142
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
143
- function idx(target, keyPaths) {
144
- return (target &&
145
- keyPaths &&
146
- (Array.isArray(keyPaths)
147
- ? keyPaths.reduce((obj, key) => obj && obj[key], target)
148
- : target[keyPaths]));
149
- }
150
- exports.idx = idx;
151
- /**
152
- * Given a filepath and dirpath, get the first directory.
153
- */
154
- function getSubFolder(file, refDir) {
155
- const separator = escape_string_regexp_1.default(path_1.default.sep);
156
- const baseDir = escape_string_regexp_1.default(path_1.default.basename(refDir));
157
- const regexSubFolder = new RegExp(`${baseDir}${separator}(.*?)${separator}.*`);
158
- const match = regexSubFolder.exec(file);
159
- return match && match[1];
160
- }
161
- exports.getSubFolder = getSubFolder;
162
- function normalizeUrl(rawUrls) {
163
- const urls = [...rawUrls];
164
- const resultArray = [];
165
- let hasStartingSlash = false;
166
- let hasEndingSlash = false;
167
- // If the first part is a plain protocol, we combine it with the next part.
168
- if (urls[0].match(/^[^/:]+:\/*$/) && urls.length > 1) {
169
- const first = urls.shift();
170
- urls[0] = first + urls[0];
171
- }
172
- // There must be two or three slashes in the file protocol,
173
- // two slashes in anything else.
174
- const replacement = urls[0].match(/^file:\/\/\//) ? '$1:///' : '$1://';
175
- urls[0] = urls[0].replace(/^([^/:]+):\/*/, replacement);
176
- // eslint-disable-next-line
177
- for (let i = 0; i < urls.length; i++) {
178
- let component = urls[i];
179
- if (typeof component !== 'string') {
180
- throw new TypeError(`Url must be a string. Received ${typeof component}`);
181
- }
182
- if (component === '') {
183
- if (i === urls.length - 1 && hasEndingSlash) {
184
- resultArray.push('/');
185
- }
186
- // eslint-disable-next-line
187
- continue;
188
- }
189
- if (component !== '/') {
190
- if (i > 0) {
191
- // Removing the starting slashes for each component but the first.
192
- component = component.replace(/^[/]+/,
193
- // Special case where the first element of rawUrls is empty ["", "/hello"] => /hello
194
- component[0] === '/' && !hasStartingSlash ? '/' : '');
195
- }
196
- hasEndingSlash = component[component.length - 1] === '/';
197
- // Removing the ending slashes for each component but the last.
198
- // For the last component we will combine multiple slashes to a single one.
199
- component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
200
- }
201
- hasStartingSlash = true;
202
- resultArray.push(component);
203
- }
204
- let str = resultArray.join('/');
205
- // Each input component is now separated by a single slash
206
- // except the possible first plain protocol part.
207
- // Remove trailing slash before parameters or hash.
208
- str = str.replace(/\/(\?|&|#[^!])/g, '$1');
209
- // Replace ? in parameters with &.
210
- const parts = str.split('?');
211
- str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
212
- // Dedupe forward slashes in the entire path, avoiding protocol slashes.
213
- str = str.replace(/([^:]\/)\/+/g, '$1');
214
- // Dedupe forward slashes at the beginning of the path.
215
- str = str.replace(/^\/+/g, '/');
216
- return str;
217
- }
218
- exports.normalizeUrl = normalizeUrl;
219
- /**
220
- * Alias filepath relative to site directory, very useful so that we
221
- * don't expose user's site structure.
222
- * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
223
- */
224
- function aliasedSitePath(filePath, siteDir) {
225
- const relativePath = exports.posixPath(path_1.default.relative(siteDir, filePath));
226
- // Cannot use path.join() as it resolves '../' and removes
227
- // the '@site'. Let webpack loader resolve it.
228
- return `@site/${relativePath}`;
229
- }
230
- exports.aliasedSitePath = aliasedSitePath;
231
- function getEditUrl(fileRelativePath, editUrl) {
232
- return editUrl
233
- ? normalizeUrl([editUrl, exports.posixPath(fileRelativePath)])
234
- : undefined;
235
- }
236
- exports.getEditUrl = getEditUrl;
237
- function isValidPathname(str) {
238
- if (!str.startsWith('/')) {
239
- return false;
240
- }
241
- try {
242
- // weird, but is there a better way?
243
- const parsedPathname = new url_1.URL(str, 'https://domain.com').pathname;
244
- return parsedPathname === str || parsedPathname === encodeURI(str);
245
- }
246
- catch (e) {
247
- return false;
248
- }
249
- }
250
- exports.isValidPathname = isValidPathname;
251
- // resolve pathname and fail fast if resolution fails
252
- function resolvePathname(to, from) {
253
- return resolve_pathname_1.default(to, from);
254
- }
255
- exports.resolvePathname = resolvePathname;
256
- function addLeadingSlash(str) {
257
- return str.startsWith('/') ? str : `/${str}`;
258
- }
259
- exports.addLeadingSlash = addLeadingSlash;
260
- function addTrailingPathSeparator(str) {
261
- return str.endsWith(path_1.default.sep) ? str : `${str}${path_1.default.sep}`;
262
- }
263
- exports.addTrailingPathSeparator = addTrailingPathSeparator;
264
- // TODO deduplicate: also present in @docusaurus/utils-common
265
- function addTrailingSlash(str) {
266
- return str.endsWith('/') ? str : `${str}/`;
267
- }
268
- exports.addTrailingSlash = addTrailingSlash;
269
- function removeTrailingSlash(str) {
270
- return removeSuffix(str, '/');
271
- }
272
- exports.removeTrailingSlash = removeTrailingSlash;
273
- function removeSuffix(str, suffix) {
274
- if (suffix === '') {
275
- return str; // always returns "" otherwise!
276
- }
277
- return str.endsWith(suffix) ? str.slice(0, -suffix.length) : str;
278
- }
279
- exports.removeSuffix = removeSuffix;
280
- function removePrefix(str, prefix) {
281
- return str.startsWith(prefix) ? str.slice(prefix.length) : str;
282
- }
283
- exports.removePrefix = removePrefix;
284
- function getElementsAround(array, aroundIndex) {
285
- const min = 0;
286
- const max = array.length - 1;
287
- if (aroundIndex < min || aroundIndex > max) {
288
- throw new Error(`Valid "aroundIndex" for array (of size ${array.length}) are between ${min} and ${max}, but you provided ${aroundIndex}.`);
289
- }
290
- const previous = aroundIndex === min ? undefined : array[aroundIndex - 1];
291
- const next = aroundIndex === max ? undefined : array[aroundIndex + 1];
292
- return { previous, next };
293
- }
294
- exports.getElementsAround = getElementsAround;
295
- function getPluginI18nPath({ siteDir, locale, pluginName, pluginId = 'default', // TODO duplicated constant
296
- subPaths = [], }) {
297
- return path_1.default.join(siteDir, 'i18n',
298
- // namespace first by locale: convenient to work in a single folder for a translator
299
- locale,
300
- // Make it convenient to use for single-instance
301
- // ie: return "docs", not "docs-default" nor "docs/default"
302
- `${pluginName}${
303
- // TODO duplicate constant :(
304
- pluginId === 'default' ? '' : `-${pluginId}`}`, ...subPaths);
305
- }
306
- exports.getPluginI18nPath = getPluginI18nPath;
307
- async function mapAsyncSequencial(array, action) {
308
- const results = [];
309
- // eslint-disable-next-line no-restricted-syntax
310
- for (const t of array) {
311
- // eslint-disable-next-line no-await-in-loop
312
- const result = await action(t);
313
- results.push(result);
314
- }
315
- return results;
316
- }
317
- exports.mapAsyncSequencial = mapAsyncSequencial;
318
- async function findAsyncSequential(array, predicate) {
319
- // eslint-disable-next-line no-restricted-syntax
320
- for (const t of array) {
321
- // eslint-disable-next-line no-await-in-loop
322
- if (await predicate(t)) {
323
- return t;
324
- }
325
- }
326
- return undefined;
327
- }
328
- exports.findAsyncSequential = findAsyncSequential;
329
- // return the first folder path in which the file exists in
330
- async function findFolderContainingFile(folderPaths, relativeFilePath) {
331
- return findAsyncSequential(folderPaths, (folderPath) => fs_extra_1.default.pathExists(path_1.default.join(folderPath, relativeFilePath)));
332
- }
333
- exports.findFolderContainingFile = findFolderContainingFile;
334
- async function getFolderContainingFile(folderPaths, relativeFilePath) {
335
- const maybeFolderPath = await findFolderContainingFile(folderPaths, relativeFilePath);
336
- // should never happen, as the source was read from the FS anyway...
337
- if (!maybeFolderPath) {
338
- throw new Error(`File "${relativeFilePath}" does not exist in any of these folders:\n- ${folderPaths.join('\n- ')}]`);
339
- }
340
- return maybeFolderPath;
341
- }
342
- exports.getFolderContainingFile = getFolderContainingFile;
343
- function reportMessage(message, reportingSeverity) {
344
- switch (reportingSeverity) {
345
- case 'ignore':
346
- break;
347
- case 'log':
348
- console.log(chalk_1.default.bold.blue('info ') + chalk_1.default.blue(message));
349
- break;
350
- case 'warn':
351
- console.warn(chalk_1.default.bold.yellow('warn ') + chalk_1.default.yellow(message));
352
- break;
353
- case 'error':
354
- console.error(chalk_1.default.bold.red('error ') + chalk_1.default.red(message));
355
- break;
356
- case 'throw':
357
- throw new Error(message);
358
- default:
359
- throw new Error(`Unexpected "reportingSeverity" value: ${reportingSeverity}.`);
360
- }
361
- }
362
- exports.reportMessage = reportMessage;
363
- function mergeTranslations(contents) {
364
- return contents.reduce((acc, content) => {
365
- return { ...acc, ...content };
366
- }, {});
367
- }
368
- exports.mergeTranslations = mergeTranslations;
369
- function getSwizzledComponent(componentPath) {
370
- const swizzledComponentPath = path_1.default.resolve(process.cwd(), 'src', componentPath);
371
- return fs_extra_1.default.existsSync(swizzledComponentPath)
372
- ? swizzledComponentPath
373
- : undefined;
374
- }
375
- exports.getSwizzledComponent = getSwizzledComponent;
376
- // Useful to update all the messages of a translation file
377
- // Used in tests to simulate translations
378
- function updateTranslationFileMessages(translationFile, updateMessage) {
379
- return {
380
- ...translationFile,
381
- content: lodash_1.mapValues(translationFile.content, (translation) => ({
382
- ...translation,
383
- message: updateMessage(translation.message),
384
- })),
385
- };
386
- }
387
- exports.updateTranslationFileMessages = updateTranslationFileMessages;
388
- // Input: ## Some heading {#some-heading}
389
- // Output: {text: "## Some heading", id: "some-heading"}
390
- function parseMarkdownHeadingId(heading) {
391
- const customHeadingIdRegex = /^(.*?)\s*\{#([\w-]+)\}$/;
392
- const matches = customHeadingIdRegex.exec(heading);
393
- if (matches) {
394
- return {
395
- text: matches[1],
396
- id: matches[2],
397
- };
398
- }
399
- else {
400
- return { text: heading, id: undefined };
401
- }
402
- }
403
- exports.parseMarkdownHeadingId = parseMarkdownHeadingId;
9
+ exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.replaceMarkdownLinks = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.normalizeFrontMatterTag = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.reportMessage = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getElementsAround = exports.removePrefix = exports.removeSuffix = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.genChunkName = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
10
+ exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePath = void 0;
11
+ var constants_1 = require("./constants");
12
+ Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
13
+ Object.defineProperty(exports, "NODE_MINOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MINOR_VERSION; } });
14
+ Object.defineProperty(exports, "DEFAULT_BUILD_DIR_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_BUILD_DIR_NAME; } });
15
+ Object.defineProperty(exports, "DEFAULT_CONFIG_FILE_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_CONFIG_FILE_NAME; } });
16
+ Object.defineProperty(exports, "BABEL_CONFIG_FILE_NAME", { enumerable: true, get: function () { return constants_1.BABEL_CONFIG_FILE_NAME; } });
17
+ Object.defineProperty(exports, "GENERATED_FILES_DIR_NAME", { enumerable: true, get: function () { return constants_1.GENERATED_FILES_DIR_NAME; } });
18
+ Object.defineProperty(exports, "SRC_DIR_NAME", { enumerable: true, get: function () { return constants_1.SRC_DIR_NAME; } });
19
+ Object.defineProperty(exports, "STATIC_DIR_NAME", { enumerable: true, get: function () { return constants_1.STATIC_DIR_NAME; } });
20
+ Object.defineProperty(exports, "OUTPUT_STATIC_ASSETS_DIR_NAME", { enumerable: true, get: function () { return constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME; } });
21
+ Object.defineProperty(exports, "THEME_PATH", { enumerable: true, get: function () { return constants_1.THEME_PATH; } });
22
+ Object.defineProperty(exports, "DEFAULT_PORT", { enumerable: true, get: function () { return constants_1.DEFAULT_PORT; } });
23
+ Object.defineProperty(exports, "DEFAULT_PLUGIN_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_PLUGIN_ID; } });
24
+ Object.defineProperty(exports, "WEBPACK_URL_LOADER_LIMIT", { enumerable: true, get: function () { return constants_1.WEBPACK_URL_LOADER_LIMIT; } });
25
+ var emitUtils_1 = require("./emitUtils");
26
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return emitUtils_1.generate; } });
27
+ Object.defineProperty(exports, "genChunkName", { enumerable: true, get: function () { return emitUtils_1.genChunkName; } });
28
+ Object.defineProperty(exports, "readOutputHTMLFile", { enumerable: true, get: function () { return emitUtils_1.readOutputHTMLFile; } });
29
+ var gitUtils_1 = require("./gitUtils");
30
+ Object.defineProperty(exports, "getFileCommitDate", { enumerable: true, get: function () { return gitUtils_1.getFileCommitDate; } });
31
+ Object.defineProperty(exports, "GitNotFoundError", { enumerable: true, get: function () { return gitUtils_1.GitNotFoundError; } });
32
+ var i18nUtils_1 = require("./i18nUtils");
33
+ Object.defineProperty(exports, "mergeTranslations", { enumerable: true, get: function () { return i18nUtils_1.mergeTranslations; } });
34
+ Object.defineProperty(exports, "updateTranslationFileMessages", { enumerable: true, get: function () { return i18nUtils_1.updateTranslationFileMessages; } });
35
+ Object.defineProperty(exports, "getPluginI18nPath", { enumerable: true, get: function () { return i18nUtils_1.getPluginI18nPath; } });
36
+ var jsUtils_1 = require("./jsUtils");
37
+ Object.defineProperty(exports, "removeSuffix", { enumerable: true, get: function () { return jsUtils_1.removeSuffix; } });
38
+ Object.defineProperty(exports, "removePrefix", { enumerable: true, get: function () { return jsUtils_1.removePrefix; } });
39
+ Object.defineProperty(exports, "getElementsAround", { enumerable: true, get: function () { return jsUtils_1.getElementsAround; } });
40
+ Object.defineProperty(exports, "mapAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.mapAsyncSequential; } });
41
+ Object.defineProperty(exports, "findAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.findAsyncSequential; } });
42
+ Object.defineProperty(exports, "reportMessage", { enumerable: true, get: function () { return jsUtils_1.reportMessage; } });
43
+ var urlUtils_1 = require("./urlUtils");
44
+ Object.defineProperty(exports, "normalizeUrl", { enumerable: true, get: function () { return urlUtils_1.normalizeUrl; } });
45
+ Object.defineProperty(exports, "getEditUrl", { enumerable: true, get: function () { return urlUtils_1.getEditUrl; } });
46
+ Object.defineProperty(exports, "fileToPath", { enumerable: true, get: function () { return urlUtils_1.fileToPath; } });
47
+ Object.defineProperty(exports, "encodePath", { enumerable: true, get: function () { return urlUtils_1.encodePath; } });
48
+ Object.defineProperty(exports, "isValidPathname", { enumerable: true, get: function () { return urlUtils_1.isValidPathname; } });
49
+ Object.defineProperty(exports, "resolvePathname", { enumerable: true, get: function () { return urlUtils_1.resolvePathname; } });
50
+ Object.defineProperty(exports, "addLeadingSlash", { enumerable: true, get: function () { return urlUtils_1.addLeadingSlash; } });
51
+ Object.defineProperty(exports, "addTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.addTrailingSlash; } });
52
+ Object.defineProperty(exports, "removeTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.removeTrailingSlash; } });
53
+ var tags_1 = require("./tags");
54
+ Object.defineProperty(exports, "normalizeFrontMatterTag", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTag; } });
55
+ Object.defineProperty(exports, "normalizeFrontMatterTags", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTags; } });
56
+ Object.defineProperty(exports, "groupTaggedItems", { enumerable: true, get: function () { return tags_1.groupTaggedItems; } });
57
+ var markdownParser_1 = require("./markdownParser");
58
+ Object.defineProperty(exports, "parseMarkdownHeadingId", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownHeadingId; } });
59
+ Object.defineProperty(exports, "createExcerpt", { enumerable: true, get: function () { return markdownParser_1.createExcerpt; } });
60
+ Object.defineProperty(exports, "parseFrontMatter", { enumerable: true, get: function () { return markdownParser_1.parseFrontMatter; } });
61
+ Object.defineProperty(exports, "parseMarkdownContentTitle", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownContentTitle; } });
62
+ Object.defineProperty(exports, "parseMarkdownString", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownString; } });
63
+ var markdownLinks_1 = require("./markdownLinks");
64
+ Object.defineProperty(exports, "replaceMarkdownLinks", { enumerable: true, get: function () { return markdownLinks_1.replaceMarkdownLinks; } });
65
+ var slugger_1 = require("./slugger");
66
+ Object.defineProperty(exports, "createSlugger", { enumerable: true, get: function () { return slugger_1.createSlugger; } });
67
+ var pathUtils_1 = require("./pathUtils");
68
+ Object.defineProperty(exports, "isNameTooLong", { enumerable: true, get: function () { return pathUtils_1.isNameTooLong; } });
69
+ Object.defineProperty(exports, "shortName", { enumerable: true, get: function () { return pathUtils_1.shortName; } });
70
+ Object.defineProperty(exports, "posixPath", { enumerable: true, get: function () { return pathUtils_1.posixPath; } });
71
+ Object.defineProperty(exports, "toMessageRelativeFilePath", { enumerable: true, get: function () { return pathUtils_1.toMessageRelativeFilePath; } });
72
+ Object.defineProperty(exports, "aliasedSitePath", { enumerable: true, get: function () { return pathUtils_1.aliasedSitePath; } });
73
+ Object.defineProperty(exports, "escapePath", { enumerable: true, get: function () { return pathUtils_1.escapePath; } });
74
+ Object.defineProperty(exports, "addTrailingPathSeparator", { enumerable: true, get: function () { return pathUtils_1.addTrailingPathSeparator; } });
75
+ var hashUtils_1 = require("./hashUtils");
76
+ Object.defineProperty(exports, "md5Hash", { enumerable: true, get: function () { return hashUtils_1.md5Hash; } });
77
+ Object.defineProperty(exports, "simpleHash", { enumerable: true, get: function () { return hashUtils_1.simpleHash; } });
78
+ Object.defineProperty(exports, "docuHash", { enumerable: true, get: function () { return hashUtils_1.docuHash; } });
79
+ var globUtils_1 = require("./globUtils");
80
+ Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return globUtils_1.Globby; } });
81
+ Object.defineProperty(exports, "GlobExcludeDefault", { enumerable: true, get: function () { return globUtils_1.GlobExcludeDefault; } });
82
+ Object.defineProperty(exports, "createMatcher", { enumerable: true, get: function () { return globUtils_1.createMatcher; } });
83
+ Object.defineProperty(exports, "createAbsoluteFilePathMatcher", { enumerable: true, get: function () { return globUtils_1.createAbsoluteFilePathMatcher; } });
84
+ var webpackUtils_1 = require("./webpackUtils");
85
+ Object.defineProperty(exports, "getFileLoaderUtils", { enumerable: true, get: function () { return webpackUtils_1.getFileLoaderUtils; } });
86
+ var dataFileUtils_1 = require("./dataFileUtils");
87
+ Object.defineProperty(exports, "getDataFilePath", { enumerable: true, get: function () { return dataFileUtils_1.getDataFilePath; } });
88
+ Object.defineProperty(exports, "getDataFileData", { enumerable: true, get: function () { return dataFileUtils_1.getDataFileData; } });
89
+ Object.defineProperty(exports, "getContentPathList", { enumerable: true, get: function () { return dataFileUtils_1.getContentPathList; } });
90
+ Object.defineProperty(exports, "findFolderContainingFile", { enumerable: true, get: function () { return dataFileUtils_1.findFolderContainingFile; } });
91
+ Object.defineProperty(exports, "getFolderContainingFile", { enumerable: true, get: function () { return dataFileUtils_1.getFolderContainingFile; } });
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAcqB;AAbnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAuE;AAA/D,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAClD,uCAA+D;AAAvD,6GAAA,iBAAiB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAC3C,yCAIqB;AAHnB,8GAAA,iBAAiB,OAAA;AACjB,0HAAA,6BAA6B,OAAA;AAC7B,8GAAA,iBAAiB,OAAA;AAEnB,qCAOmB;AANjB,uGAAA,YAAY,OAAA;AACZ,uGAAA,YAAY,OAAA;AACZ,4GAAA,iBAAiB,OAAA;AACjB,6GAAA,kBAAkB,OAAA;AAClB,8GAAA,mBAAmB,OAAA;AACnB,wGAAA,aAAa,OAAA;AAEf,uCAUoB;AATlB,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AACV,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,4GAAA,gBAAgB,OAAA;AAChB,+GAAA,mBAAmB,OAAA;AAErB,+BAOgB;AAHd,+GAAA,uBAAuB,OAAA;AACvB,gHAAA,wBAAwB,OAAA;AACxB,wGAAA,gBAAgB,OAAA;AAElB,mDAM0B;AALxB,wHAAA,sBAAsB,OAAA;AACtB,+GAAA,aAAa,OAAA;AACb,kHAAA,gBAAgB,OAAA;AAChB,2HAAA,yBAAyB,OAAA;AACzB,qHAAA,mBAAmB,OAAA;AAErB,iDAMyB;AADvB,qHAAA,oBAAoB,OAAA;AAEtB,qCAA2E;AAAhC,wGAAA,aAAa,OAAA;AACxD,yCAQqB;AAPnB,0GAAA,aAAa,OAAA;AACb,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,sHAAA,yBAAyB,OAAA;AACzB,4GAAA,eAAe,OAAA;AACf,uGAAA,UAAU,OAAA;AACV,qHAAA,wBAAwB,OAAA;AAE1B,yCAA0D;AAAlD,oGAAA,OAAO,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,qGAAA,QAAQ,OAAA;AACrC,yCAKqB;AAJnB,mGAAA,MAAM,OAAA;AACN,+GAAA,kBAAkB,OAAA;AAClB,0GAAA,aAAa,OAAA;AACb,0HAAA,6BAA6B,OAAA;AAE/B,+CAAkD;AAA1C,kHAAA,kBAAkB,OAAA;AAC1B,iDAMyB;AALvB,gHAAA,eAAe,OAAA;AACf,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,yHAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA"}
@@ -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
+ import type { ReportingSeverity } from '@docusaurus/types';
8
+ export declare function removeSuffix(str: string, suffix: string): string;
9
+ export declare function removePrefix(str: string, prefix: string): string;
10
+ export declare function getElementsAround<T>(array: T[], aroundIndex: number): {
11
+ next: T | undefined;
12
+ previous: T | undefined;
13
+ };
14
+ export declare function mapAsyncSequential<T, R>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
15
+ export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
16
+ export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void;
17
+ //# sourceMappingURL=jsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../src/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAGzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,CAAC,EAAE,EACV,WAAW,EAAE,MAAM,GAClB;IACD,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC;CACzB,CAWA;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAC3C,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAOd;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAoBN"}