@docusaurus/utils 2.0.0-beta.14 → 2.0.0-beta.15
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.
- package/lib/dataFileUtils.d.ts +24 -0
- package/lib/dataFileUtils.d.ts.map +1 -0
- package/lib/dataFileUtils.js +65 -0
- package/lib/dataFileUtils.js.map +1 -0
- package/lib/globUtils.d.ts.map +1 -1
- package/lib/globUtils.js +2 -2
- package/lib/globUtils.js.map +1 -1
- package/lib/index.d.ts +18 -41
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +40 -139
- package/lib/index.js.map +1 -1
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +12 -4
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownParser.d.ts +4 -3
- package/lib/markdownParser.d.ts.map +1 -1
- package/lib/markdownParser.js +30 -18
- package/lib/markdownParser.js.map +1 -1
- package/lib/pathUtils.d.ts +29 -0
- package/lib/pathUtils.d.ts.map +1 -1
- package/lib/pathUtils.js +69 -5
- package/lib/pathUtils.js.map +1 -1
- package/lib/tags.d.ts +1 -1
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +4 -5
- package/lib/tags.js.map +1 -1
- package/lib/{normalizeUrl.d.ts → urlUtils.d.ts} +2 -1
- package/lib/urlUtils.d.ts.map +1 -0
- package/lib/{normalizeUrl.js → urlUtils.js} +17 -4
- package/lib/{normalizeUrl.js.map → urlUtils.js.map} +1 -1
- package/lib/webpackUtils.js +3 -3
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +6 -5
- package/src/dataFileUtils.ts +90 -0
- package/src/globUtils.ts +2 -1
- package/src/index.ts +48 -173
- package/src/markdownLinks.ts +10 -3
- package/src/markdownParser.ts +32 -20
- package/src/pathUtils.ts +70 -4
- package/src/tags.ts +5 -4
- package/src/{normalizeUrl.ts → urlUtils.ts} +17 -2
- package/src/webpackUtils.ts +4 -4
- package/lib/escapePath.d.ts +0 -18
- package/lib/escapePath.d.ts.map +0 -1
- package/lib/escapePath.js +0 -26
- package/lib/escapePath.js.map +0 -1
- package/lib/mdxUtils.d.ts +0 -17
- package/lib/mdxUtils.d.ts.map +0 -1
- package/lib/mdxUtils.js +0 -31
- package/lib/mdxUtils.js.map +0 -1
- package/lib/normalizeUrl.d.ts.map +0 -1
- package/lib/posixPath.d.ts +0 -15
- package/lib/posixPath.d.ts.map +0 -1
- package/lib/posixPath.js +0 -29
- package/lib/posixPath.js.map +0 -1
- package/src/escapePath.ts +0 -23
- package/src/mdxUtils.ts +0 -32
- package/src/posixPath.ts +0 -27
package/lib/mdxUtils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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.mdxToHtml = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const react_1 = (0, tslib_1.__importDefault)(require("react"));
|
|
12
|
-
const server_1 = (0, tslib_1.__importDefault)(require("react-dom/server"));
|
|
13
|
-
const runtime_1 = (0, tslib_1.__importDefault)(require("@mdx-js/runtime"));
|
|
14
|
-
const remark_mdx_remove_imports_1 = (0, tslib_1.__importDefault)(require("remark-mdx-remove-imports"));
|
|
15
|
-
const remark_mdx_remove_exports_1 = (0, tslib_1.__importDefault)(require("remark-mdx-remove-exports"));
|
|
16
|
-
/**
|
|
17
|
-
* Transform mdx text to plain html text
|
|
18
|
-
* Initially created to convert MDX blog posts to HTML for the RSS feed
|
|
19
|
-
* without import/export nodes
|
|
20
|
-
*
|
|
21
|
-
* TODO not ideal implementation, won't work well with MDX elements!
|
|
22
|
-
* TODO theme+global site config should be able to declare MDX comps in scope for rendering the RSS feeds
|
|
23
|
-
* see also https://github.com/facebook/docusaurus/issues/4625
|
|
24
|
-
*/
|
|
25
|
-
function mdxToHtml(mdxStr) {
|
|
26
|
-
return server_1.default.renderToString(react_1.default.createElement(runtime_1.default, { remarkPlugins: [remark_mdx_remove_imports_1.default, remark_mdx_remove_exports_1.default] }, [
|
|
27
|
-
mdxStr,
|
|
28
|
-
]));
|
|
29
|
-
}
|
|
30
|
-
exports.mdxToHtml = mdxToHtml;
|
|
31
|
-
//# sourceMappingURL=mdxUtils.js.map
|
package/lib/mdxUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mdxUtils.js","sourceRoot":"","sources":["../src/mdxUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,+DAA0B;AAC1B,2EAA8C;AAC9C,2EAAkC;AAClC,uGAAsD;AACtD,uGAAsD;AAEtD;;;;;;;;GAQG;AACH,SAAgB,SAAS,CACvB,MAAc;IAGd,OAAO,gBAAc,CAAC,cAAc,CAClC,eAAK,CAAC,aAAa,CAAC,iBAAG,EAAE,EAAC,aAAa,EAAE,CAAC,mCAAa,EAAE,mCAAa,CAAC,EAAC,EAAE;QACxE,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC;AATD,8BASC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeUrl.d.ts","sourceRoot":"","sources":["../src/normalizeUrl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAwEtD"}
|
package/lib/posixPath.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
/**
|
|
8
|
-
* Convert Windows backslash paths to posix style paths.
|
|
9
|
-
* E.g: endi\\lie -> endi/lie
|
|
10
|
-
*
|
|
11
|
-
* Looks like this code was originally copied from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare function posixPath(str: string): string;
|
|
15
|
-
//# sourceMappingURL=posixPath.d.ts.map
|
package/lib/posixPath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posixPath.d.ts","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAY7C"}
|
package/lib/posixPath.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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.posixPath = void 0;
|
|
10
|
-
/**
|
|
11
|
-
* Convert Windows backslash paths to posix style paths.
|
|
12
|
-
* E.g: endi\\lie -> endi/lie
|
|
13
|
-
*
|
|
14
|
-
* Looks like this code was originally copied from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
function posixPath(str) {
|
|
18
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
19
|
-
// TODO not sure why we need this
|
|
20
|
-
// See https://github.com/sindresorhus/slash/pull/16#issuecomment-833528479
|
|
21
|
-
// See https://github.com/facebook/docusaurus/issues/4730#issuecomment-833530370
|
|
22
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(str); // eslint-disable-line
|
|
23
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
24
|
-
return str;
|
|
25
|
-
}
|
|
26
|
-
return str.replace(/\\/g, '/');
|
|
27
|
-
}
|
|
28
|
-
exports.posixPath = posixPath;
|
|
29
|
-
//# sourceMappingURL=posixPath.js.map
|
package/lib/posixPath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posixPath.js","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,MAAM,oBAAoB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEnD,iCAAiC;IACjC,2EAA2E;IAC3E,gFAAgF;IAChF,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,sBAAsB;IAEzE,IAAI,oBAAoB,IAAI,WAAW,EAAE;QACvC,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAZD,8BAYC"}
|
package/src/escapePath.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
/**
|
|
9
|
-
* When you have a path like C:\X\Y
|
|
10
|
-
* It is not safe to use directly when generating code
|
|
11
|
-
* For example, this would fail due to unescaped \: `<img src={require('${filePath}')} />`
|
|
12
|
-
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
13
|
-
*
|
|
14
|
-
* Workaround for issue in posixPath, maybe we won't need it anymore soon?
|
|
15
|
-
* https://github.com/facebook/docusaurus/issues/4730#issuecomment-833530370
|
|
16
|
-
* https://github.com/sindresorhus/slash/pull/16#issuecomment-833528479
|
|
17
|
-
*/
|
|
18
|
-
export function escapePath(str: string): string {
|
|
19
|
-
const escaped = JSON.stringify(str);
|
|
20
|
-
|
|
21
|
-
// Remove the " around the json string;
|
|
22
|
-
return escaped.substring(1, escaped.length - 1);
|
|
23
|
-
}
|
package/src/mdxUtils.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import ReactDOMServer from 'react-dom/server';
|
|
10
|
-
import MDX from '@mdx-js/runtime';
|
|
11
|
-
import removeImports from 'remark-mdx-remove-imports';
|
|
12
|
-
import removeExports from 'remark-mdx-remove-exports';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Transform mdx text to plain html text
|
|
16
|
-
* Initially created to convert MDX blog posts to HTML for the RSS feed
|
|
17
|
-
* without import/export nodes
|
|
18
|
-
*
|
|
19
|
-
* TODO not ideal implementation, won't work well with MDX elements!
|
|
20
|
-
* TODO theme+global site config should be able to declare MDX comps in scope for rendering the RSS feeds
|
|
21
|
-
* see also https://github.com/facebook/docusaurus/issues/4625
|
|
22
|
-
*/
|
|
23
|
-
export function mdxToHtml(
|
|
24
|
-
mdxStr: string,
|
|
25
|
-
// TODO allow providing components/scope here, see https://github.com/mdx-js/mdx/tree/v1.6.13/packages/runtime
|
|
26
|
-
): string {
|
|
27
|
-
return ReactDOMServer.renderToString(
|
|
28
|
-
React.createElement(MDX, {remarkPlugins: [removeImports, removeExports]}, [
|
|
29
|
-
mdxStr,
|
|
30
|
-
]),
|
|
31
|
-
);
|
|
32
|
-
}
|
package/src/posixPath.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Convert Windows backslash paths to posix style paths.
|
|
10
|
-
* E.g: endi\\lie -> endi/lie
|
|
11
|
-
*
|
|
12
|
-
* Looks like this code was originally copied from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export function posixPath(str: string): string {
|
|
16
|
-
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
17
|
-
|
|
18
|
-
// TODO not sure why we need this
|
|
19
|
-
// See https://github.com/sindresorhus/slash/pull/16#issuecomment-833528479
|
|
20
|
-
// See https://github.com/facebook/docusaurus/issues/4730#issuecomment-833530370
|
|
21
|
-
const hasNonAscii = /[^\u0000-\u0080]+/.test(str); // eslint-disable-line
|
|
22
|
-
|
|
23
|
-
if (isExtendedLengthPath || hasNonAscii) {
|
|
24
|
-
return str;
|
|
25
|
-
}
|
|
26
|
-
return str.replace(/\\/g, '/');
|
|
27
|
-
}
|