@docusaurus/core 4.0.0-canary-6888 → 4.0.0-canary-6891

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.
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.buildLocale = buildLocale;
10
10
  const tslib_1 = require("tslib");
11
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
13
  const bundler_1 = require("@docusaurus/bundler");
15
14
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
15
+ const fs_1 = require("@docusaurus/fs");
16
16
  const site_1 = require("../../server/site");
17
17
  const brokenLinks_1 = require("../../server/brokenLinks");
18
18
  const client_1 = require("../../webpack/client");
@@ -164,7 +164,7 @@ async function cleanupServerBundle(serverBundlePath) {
164
164
  await logger_1.PerfLogger.async('Deleting server bundle', async () => {
165
165
  // For now we assume server entry is at the root of the server out dir
166
166
  const serverDir = node_path_1.default.dirname(serverBundlePath);
167
- await promises_1.default.rm(serverDir, { recursive: true, force: true });
167
+ await fs_1.fs.rm(serverDir, { recursive: true, force: true });
168
168
  });
169
169
  }
170
170
  }
@@ -8,7 +8,6 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.deploy = deploy;
10
10
  const tslib_1 = require("tslib");
11
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -147,7 +146,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
147
146
  const runDeploy = async (outputDirectory) => {
148
147
  const targetDirectory = cliOptions.targetDir ?? '.';
149
148
  const fromPath = outputDirectory;
150
- const toPath = await promises_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
149
+ const toPath = await fs_1.fs.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
151
150
  process.chdir(toPath);
152
151
  // Clones the repo into the temp folder and checks out the target branch.
153
152
  // If the branch doesn't exist, it creates a new one based on the
@@ -170,7 +169,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
170
169
  const targetPath = node_path_1.default.join(toPath, targetDirectory);
171
170
  try {
172
171
  // verbatimSymlinks: keep relative symlinks relative
173
- await promises_1.default.cp(fromPath, targetPath, {
172
+ await fs_1.fs.cp(fromPath, targetPath, {
174
173
  recursive: true,
175
174
  verbatimSymlinks: true,
176
175
  });
@@ -11,7 +11,6 @@ exports.getAction = getAction;
11
11
  exports.eject = eject;
12
12
  exports.wrap = wrap;
13
13
  const tslib_1 = require("tslib");
14
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -30,7 +29,7 @@ async function getAction(componentConfig, options) {
30
29
  return (0, prompts_1.askSwizzleAction)(componentConfig);
31
30
  }
32
31
  async function isDir(dirPath) {
33
- return (await (0, fs_1.pathExists)(dirPath)) && (await promises_1.default.stat(dirPath)).isDirectory();
32
+ return (await (0, fs_1.pathExists)(dirPath)) && (await fs_1.fs.stat(dirPath)).isDirectory();
34
33
  }
35
34
  async function eject({ siteDir, themePath, componentName, typescript, }) {
36
35
  const fromPath = node_path_1.default.join(themePath, componentName);
@@ -59,11 +58,11 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
59
58
  throw new Error(logger_1.default.interpolate `No files to copy from path=${fromPath} with glob code=${globPatternPosix}`);
60
59
  }
61
60
  const toPath = node_path_1.default.join(siteDir, utils_1.THEME_PATH);
62
- await promises_1.default.mkdir(toPath, { recursive: true });
61
+ await fs_1.fs.mkdir(toPath, { recursive: true });
63
62
  const createdFiles = await Promise.all(filesToCopy.map(async (sourceFile) => {
64
63
  const targetFile = node_path_1.default.join(toPath, node_path_1.default.relative(themePath, sourceFile));
65
64
  try {
66
- const fileContents = await promises_1.default.readFile(sourceFile, 'utf-8');
65
+ const fileContents = await fs_1.fs.readFile(sourceFile, 'utf-8');
67
66
  await (0, fs_1.outputFile)(targetFile, fileContents.trimStart().replace(/^\/\*.+?\*\/\s*/ms, ''));
68
67
  }
69
68
  catch (err) {
@@ -80,7 +79,7 @@ async function wrap({ siteDir, themePath, componentName: themeComponentName, typ
80
79
  const componentName = lodash_1.default.last(themeComponentName.split('/'));
81
80
  const wrapperComponentName = `${componentName}Wrapper`;
82
81
  const wrapperFileName = `${themeComponentName}${isDirectory ? '/index' : ''}${typescript ? '.tsx' : '.js'}`;
83
- await promises_1.default.mkdir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH), { recursive: true });
82
+ await fs_1.fs.mkdir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH), { recursive: true });
84
83
  const toPath = node_path_1.default.resolve(siteDir, utils_1.THEME_PATH, wrapperFileName);
85
84
  const content = typescript
86
85
  ? `import type {ReactNode} from 'react';
@@ -11,7 +11,6 @@ exports.readComponentNames = readComponentNames;
11
11
  exports.getThemeComponents = getThemeComponents;
12
12
  exports.getComponentName = getComponentName;
13
13
  const tslib_1 = require("tslib");
14
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -47,9 +46,9 @@ async function readComponentNames(themePath) {
47
46
  return [];
48
47
  }
49
48
  async function walk(dir) {
50
- const files = await Promise.all((await promises_1.default.readdir(dir)).flatMap(async (file) => {
49
+ const files = await Promise.all((await fs_1.fs.readdir(dir)).flatMap(async (file) => {
51
50
  const fullPath = node_path_1.default.join(dir, file);
52
- const stat = await promises_1.default.stat(fullPath);
51
+ const stat = await fs_1.fs.stat(fullPath);
53
52
  const isDir = stat.isDirectory();
54
53
  return { file, fullPath, isDir };
55
54
  }));
@@ -9,13 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.default = clearPath;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
12
- const promises_1 = require("node:fs/promises");
13
12
  const logger_1 = require("@docusaurus/logger");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  /**
15
15
  * @param pathToClear
16
16
  */
17
17
  async function clearPath(pathToClear) {
18
18
  return logger_1.PerfLogger.async(`clearPath ${node_path_1.default.relative(process.cwd(), pathToClear)}`, async () => {
19
- await (0, promises_1.rm)(pathToClear, { recursive: true, force: true });
19
+ await fs_1.fs.rm(pathToClear, { recursive: true, force: true });
20
20
  });
21
21
  }
@@ -8,7 +8,6 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.writeHeadingIds = writeHeadingIds;
10
10
  const tslib_1 = require("tslib");
11
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
12
  const utils_1 = require("@docusaurus/utils");
14
13
  const glob_1 = require("@docusaurus/glob");
@@ -28,14 +27,14 @@ function getHeadingIdSyntax(filepath, options) {
28
27
  return options?.syntax ?? inferFallbackSyntax(filepath);
29
28
  }
30
29
  async function transformMarkdownFile(filepath, options) {
31
- const content = await promises_1.default.readFile(filepath, 'utf8');
30
+ const content = await fs_1.fs.readFile(filepath, 'utf8');
32
31
  const syntax = getHeadingIdSyntax(filepath, options);
33
32
  const updatedContent = (0, utils_1.writeMarkdownHeadingId)(content, {
34
33
  ...options,
35
34
  syntax,
36
35
  });
37
36
  if (content !== updatedContent) {
38
- await promises_1.default.writeFile(filepath, updatedContent);
37
+ await fs_1.fs.writeFile(filepath, updatedContent);
39
38
  return filepath;
40
39
  }
41
40
  return undefined;
@@ -74,7 +73,7 @@ async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
74
73
  logger_1.default.warn `No markdown files found in siteDir path=${siteDir} for patterns: ${patterns}`;
75
74
  return;
76
75
  }
77
- const result = await Promise.all(markdownFiles.map((p) => (0, fs_1.queueFileOperation)(() => transformMarkdownFile(p, options))));
76
+ const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
78
77
  const pathsModified = result.filter(Boolean);
79
78
  if (pathsModified.length) {
80
79
  logger_1.default.success `Heading ids added to Markdown files (number=${`${pathsModified.length}/${markdownFiles.length}`} files): ${pathsModified}`;
@@ -10,7 +10,6 @@ exports.tryLoadSitePackageJson = tryLoadSitePackageJson;
10
10
  exports.loadPluginVersion = loadPluginVersion;
11
11
  exports.createSiteMetadata = createSiteMetadata;
12
12
  const tslib_1 = require("tslib");
13
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
14
13
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
15
14
  const utils_1 = require("@docusaurus/utils");
16
15
  const fs_1 = require("@docusaurus/fs");
@@ -35,7 +34,7 @@ async function loadPluginVersion(pluginPath, siteDir) {
35
34
  while (potentialPluginPackageJsonDirectory !== '/') {
36
35
  const packageJsonPath = node_path_1.default.join(potentialPluginPackageJsonDirectory, 'package.json');
37
36
  if ((await (0, fs_1.pathExists)(packageJsonPath)) &&
38
- (await promises_1.default.lstat(packageJsonPath)).isFile()) {
37
+ (await fs_1.fs.lstat(packageJsonPath)).isFile()) {
39
38
  if (potentialPluginPackageJsonDirectory === siteDir) {
40
39
  // If the plugin belongs to the same docusaurus project, we classify it
41
40
  // as local plugin.
@@ -11,10 +11,10 @@ const tslib_1 = require("tslib");
11
11
  const node_module_1 = require("node:module");
12
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
13
  const node_vm_1 = require("node:vm");
14
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
14
  const p_map_1 = tslib_1.__importDefault(require("p-map"));
16
15
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
17
16
  const bundler_1 = require("@docusaurus/bundler");
17
+ const fs_1 = require("@docusaurus/fs");
18
18
  const ssgTemplate_1 = require("./ssgTemplate");
19
19
  const ssgEnv_1 = require("./ssgEnv");
20
20
  const ssgUtils_1 = require("./ssgUtils");
@@ -29,7 +29,7 @@ function evaluateServerBundle({ source, serverBundlePath, }) {
29
29
  return module.exports;
30
30
  }
31
31
  async function loadAppRenderer({ serverBundlePath, }) {
32
- const source = await logger_1.PerfLogger.async(`Load server bundle`, () => promises_1.default.readFile(serverBundlePath, 'utf8'));
32
+ const source = await logger_1.PerfLogger.async(`Load server bundle`, () => fs_1.fs.readFile(serverBundlePath, 'utf8'));
33
33
  const serverEntry = await logger_1.PerfLogger.async(`Evaluate server bundle`, () => evaluateServerBundle({ source, serverBundlePath }));
34
34
  if (!serverEntry?.default || typeof serverEntry.default !== 'function') {
35
35
  throw new Error(`Docusaurus Bug: server bundle export from "${serverBundlePath}" must be a function that renders the Docusaurus React app, not ${typeof serverEntry?.default}`);
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
10
10
  exports.writeStaticFile = writeStaticFile;
11
11
  const tslib_1 = require("tslib");
12
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
13
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  function pathnameToFilename({ pathname, trailingSlash, }) {
15
15
  const outputFileName = pathname.replace(/^[/\\]/, ''); // Remove leading slashes for webpack-dev-server
16
16
  // Paths ending with .html are left untouched
@@ -44,6 +44,6 @@ async function writeStaticFile({ content, pathname, params, }) {
44
44
  trailingSlash: params.trailingSlash,
45
45
  });
46
46
  const filePath = node_path_1.default.join(params.outDir, filename);
47
- await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
48
- await promises_1.default.writeFile(filePath, content);
47
+ await fs_1.fs.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
48
+ await fs_1.fs.writeFile(filePath, content);
49
49
  }
@@ -11,7 +11,6 @@ exports.createAliasesForTheme = createAliasesForTheme;
11
11
  exports.loadThemeAliases = loadThemeAliases;
12
12
  exports.loadDocusaurusAliases = loadDocusaurusAliases;
13
13
  const tslib_1 = require("tslib");
14
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const utils_1 = require("@docusaurus/utils");
@@ -103,7 +102,7 @@ async function loadDocusaurusAliases() {
103
102
  const dirPath = node_path_1.default.resolve(__dirname, '../../client/exports');
104
103
  const extensions = ['.js', '.ts', '.tsx'];
105
104
  const aliases = {};
106
- (await promises_1.default.readdir(dirPath))
105
+ (await fs_1.fs.readdir(dirPath))
107
106
  .filter((fileName) => extensions.includes(node_path_1.default.extname(fileName)))
108
107
  .forEach((fileName) => {
109
108
  const fileNameWithoutExtension = node_path_1.default.basename(fileName, node_path_1.default.extname(fileName));
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.BundlerCPUProfilerPlugin = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_inspector_1 = tslib_1.__importDefault(require("node:inspector"));
12
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
+ const fs_1 = require("@docusaurus/fs");
13
13
  // Bundle CPU profiling plugin, contributed by the Rspack team
14
14
  // Can be opened in https://www.speedscope.app/
15
15
  // See also https://github.com/jerrykingxyz/docusaurus/pull/1
@@ -33,7 +33,7 @@ class BundlerCPUProfilerPlugin {
33
33
  console.error('Failed to generate JS CPU profile:', error);
34
34
  return;
35
35
  }
36
- promises_1.default.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
36
+ fs_1.fs.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
37
37
  });
38
38
  });
39
39
  }
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
12
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
13
12
  const bundler_1 = require("@docusaurus/bundler");
14
13
  const fs_1 = require("@docusaurus/fs");
15
14
  async function createStaticDirectoriesCopyPlugin({ props, }) {
@@ -24,7 +23,7 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
24
23
  const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
25
24
  const staticDir = node_path_1.default.resolve(siteDir, dir);
26
25
  if ((await (0, fs_1.pathExists)(staticDir)) &&
27
- (await promises_1.default.readdir(staticDir)).length > 0) {
26
+ (await fs_1.fs.readdir(staticDir)).length > 0) {
28
27
  return staticDir;
29
28
  }
30
29
  return '';
@@ -8,7 +8,6 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.default = getHttpsConfig;
10
10
  const tslib_1 = require("tslib");
11
- const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
@@ -55,7 +54,7 @@ async function readCryptoFile(filepath, source) {
55
54
  return {
56
55
  path: filepath,
57
56
  source,
58
- content: await promises_1.default.readFile(filepath),
57
+ content: await fs_1.fs.readFile(filepath),
59
58
  };
60
59
  }
61
60
  catch (error) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "4.0.0-canary-6888",
4
+ "version": "4.0.0-canary-6891",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,15 +33,15 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "4.0.0-canary-6888",
37
- "@docusaurus/bundler": "4.0.0-canary-6888",
38
- "@docusaurus/fs": "4.0.0-canary-6888",
39
- "@docusaurus/glob": "4.0.0-canary-6888",
40
- "@docusaurus/logger": "4.0.0-canary-6888",
41
- "@docusaurus/mdx-loader": "4.0.0-canary-6888",
42
- "@docusaurus/utils": "4.0.0-canary-6888",
43
- "@docusaurus/utils-common": "4.0.0-canary-6888",
44
- "@docusaurus/utils-validation": "4.0.0-canary-6888",
36
+ "@docusaurus/babel": "4.0.0-canary-6891",
37
+ "@docusaurus/bundler": "4.0.0-canary-6891",
38
+ "@docusaurus/fs": "4.0.0-canary-6891",
39
+ "@docusaurus/glob": "4.0.0-canary-6891",
40
+ "@docusaurus/logger": "4.0.0-canary-6891",
41
+ "@docusaurus/mdx-loader": "4.0.0-canary-6891",
42
+ "@docusaurus/utils": "4.0.0-canary-6891",
43
+ "@docusaurus/utils-common": "4.0.0-canary-6891",
44
+ "@docusaurus/utils-validation": "4.0.0-canary-6891",
45
45
  "boxen": "^9.0.0",
46
46
  "cli-table3": "^0.6.5",
47
47
  "combine-promises": "^1.2.0",
@@ -72,8 +72,8 @@
72
72
  "webpack-merge": "^6.0.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@docusaurus/module-type-aliases": "4.0.0-canary-6888",
76
- "@docusaurus/types": "4.0.0-canary-6888",
75
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6891",
76
+ "@docusaurus/types": "4.0.0-canary-6891",
77
77
  "@total-typescript/shoehorn": "^0.1.2",
78
78
  "@types/escape-html": "^1.0.4",
79
79
  "@types/history": "^4.7.11",
@@ -87,7 +87,7 @@
87
87
  "utility-types": "^3.11.0"
88
88
  },
89
89
  "peerDependencies": {
90
- "@docusaurus/faster": "4.0.0-canary-6888",
90
+ "@docusaurus/faster": "4.0.0-canary-6891",
91
91
  "@mdx-js/react": "^3.1.1",
92
92
  "react": "^19.3.0",
93
93
  "react-dom": "^19.3.0"
@@ -100,5 +100,5 @@
100
100
  "engines": {
101
101
  "node": ">=24.21"
102
102
  },
103
- "gitHead": "5019a662590dcb2722926890c1ade27194bc3b70"
103
+ "gitHead": "f276aff972dcc432c037123c6d522e6c50881e79"
104
104
  }