@docusaurus/core 0.0.0-4255 → 0.0.0-4261

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,13 +8,13 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getPluginNames = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const chalk = require("chalk");
11
+ const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
14
14
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
15
15
  const leven_1 = (0, tslib_1.__importDefault)(require("leven"));
16
16
  const lodash_1 = require("lodash");
17
- const constants_1 = require("../constants");
17
+ const utils_1 = require("@docusaurus/utils");
18
18
  const server_1 = require("../server");
19
19
  const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
20
20
  const utils_validation_1 = require("@docusaurus/utils-validation");
@@ -82,13 +82,13 @@ function getComponentName(themePath, plugin, danger) {
82
82
  function themeComponents(themePath, plugin) {
83
83
  const components = colorCode(themePath, plugin);
84
84
  if (components.length === 0) {
85
- return `${chalk.red('No component to swizzle.')}`;
85
+ return `${chalk_1.default.red('No component to swizzle.')}`;
86
86
  }
87
87
  return `
88
- ${chalk.cyan('Theme components available for swizzle.')}
88
+ ${chalk_1.default.cyan('Theme components available for swizzle.')}
89
89
 
90
- ${chalk.green('green =>')} safe: lower breaking change risk
91
- ${chalk.red('red =>')} unsafe: higher breaking change risk
90
+ ${chalk_1.default.green('green =>')} safe: lower breaking change risk
91
+ ${chalk_1.default.red('red =>')} unsafe: higher breaking change risk
92
92
 
93
93
  ${components.join('\n')}
94
94
  `;
@@ -106,8 +106,8 @@ function colorCode(themePath, plugin) {
106
106
  : [];
107
107
  const [greenComponents, redComponents] = (0, lodash_1.partition)(components, (comp) => allowedComponent.includes(comp));
108
108
  return [
109
- ...greenComponents.map((component) => chalk.green(`safe: ${component}`)),
110
- ...redComponents.map((component) => chalk.red(`unsafe: ${component}`)),
109
+ ...greenComponents.map((component) => chalk_1.default.green(`safe: ${component}`)),
110
+ ...redComponents.map((component) => chalk_1.default.red(`unsafe: ${component}`)),
111
111
  ];
112
112
  }
113
113
  async function swizzle(siteDir, themeName, componentName, typescript, danger) {
@@ -137,7 +137,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
137
137
  suggestion = name;
138
138
  }
139
139
  });
140
- chalk.red(`Theme ${themeName} not found. ${suggestion
140
+ chalk_1.default.red(`Theme ${themeName} not found. ${suggestion
141
141
  ? `Did you mean "${suggestion}" ?`
142
142
  : formattedThemeNames(themeNames)}`);
143
143
  process.exit(1);
@@ -171,7 +171,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
171
171
  ? (_d = pluginInstance.getTypeScriptThemePath) === null || _d === void 0 ? void 0 : _d.call(pluginInstance)
172
172
  : (_e = pluginInstance.getThemePath) === null || _e === void 0 ? void 0 : _e.call(pluginInstance);
173
173
  if (!themePath) {
174
- console.warn(chalk.yellow(typescript
174
+ console.warn(chalk_1.default.yellow(typescript
175
175
  ? `${themeName} does not provide TypeScript theme code via "getTypeScriptThemePath()".`
176
176
  : `${themeName} does not provide any theme code.`));
177
177
  process.exit(1);
@@ -199,11 +199,11 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
199
199
  });
200
200
  if (mostSuitableMatch !== componentName) {
201
201
  mostSuitableComponent = mostSuitableMatch;
202
- console.log(chalk.red(`Component "${componentName}" doesn't exist.`), chalk.yellow(`"${mostSuitableComponent}" is swizzled instead of "${componentName}".`));
202
+ console.log(chalk_1.default.red(`Component "${componentName}" doesn't exist.`), chalk_1.default.yellow(`"${mostSuitableComponent}" is swizzled instead of "${componentName}".`));
203
203
  }
204
204
  }
205
205
  let fromPath = path_1.default.join(themePath, mostSuitableComponent);
206
- let toPath = path_1.default.resolve(siteDir, constants_1.THEME_PATH, mostSuitableComponent);
206
+ let toPath = path_1.default.resolve(siteDir, utils_1.THEME_PATH, mostSuitableComponent);
207
207
  // Handle single TypeScript/JavaScript file only.
208
208
  // E.g: if <fromPath> does not exist, we try to swizzle <fromPath>.(ts|tsx|js) instead
209
209
  if (!fs_extra_1.default.existsSync(fromPath)) {
@@ -223,7 +223,7 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
223
223
  suggestion = name;
224
224
  }
225
225
  });
226
- console.warn(chalk.red(`Component ${mostSuitableComponent} not found.`));
226
+ console.warn(chalk_1.default.red(`Component ${mostSuitableComponent} not found.`));
227
227
  console.warn(suggestion
228
228
  ? `Did you mean "${suggestion}"?`
229
229
  : `${themeComponents(themePath, pluginModule)}`);
@@ -231,15 +231,15 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
231
231
  }
232
232
  }
233
233
  if (!components.includes(mostSuitableComponent) && !danger) {
234
- console.warn(chalk.red(`${mostSuitableComponent} is an internal component and has a higher breaking change probability. If you want to swizzle it, use the "--danger" flag.`));
234
+ console.warn(chalk_1.default.red(`${mostSuitableComponent} is an internal component and has a higher breaking change probability. If you want to swizzle it, use the "--danger" flag.`));
235
235
  process.exit(1);
236
236
  }
237
237
  await fs_extra_1.default.copy(fromPath, toPath);
238
238
  const relativeDir = path_1.default.relative(process.cwd(), toPath);
239
- const fromMsg = chalk.blue(mostSuitableComponent
240
- ? `${themeName} ${chalk.yellow(mostSuitableComponent)}`
239
+ const fromMsg = chalk_1.default.blue(mostSuitableComponent
240
+ ? `${themeName} ${chalk_1.default.yellow(mostSuitableComponent)}`
241
241
  : themeName);
242
- const toMsg = chalk.cyan(relativeDir);
243
- console.log(`\n${chalk.green('Success!')} Copied ${fromMsg} to ${toMsg}.\n`);
242
+ const toMsg = chalk_1.default.cyan(relativeDir);
243
+ console.log(`\n${chalk_1.default.green('Success!')} Copied ${fromMsg} to ${toMsg}.\n`);
244
244
  }
245
245
  exports.default = swizzle;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateConfig = exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
10
- const constants_1 = require("../constants");
10
+ const utils_1 = require("@docusaurus/utils");
11
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
12
  const DEFAULT_I18N_LOCALE = 'en';
13
13
  exports.DEFAULT_I18N_CONFIG = {
@@ -28,7 +28,7 @@ exports.DEFAULT_CONFIG = {
28
28
  titleDelimiter: '|',
29
29
  noIndex: false,
30
30
  baseUrlIssueBanner: true,
31
- staticDirectories: [constants_1.STATIC_DIR_NAME],
31
+ staticDirectories: [utils_1.STATIC_DIR_NAME],
32
32
  };
33
33
  const PluginSchema = utils_validation_1.Joi.alternatives()
34
34
  .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array().ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required()), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
@@ -160,7 +160,7 @@ function validateConfig(config) {
160
160
  ? `${accumulatedErr}${err.message}\n`
161
161
  : accumulatedErr, '');
162
162
  formattedError = unknownFields
163
- ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${constants_1.DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields`
163
+ ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${utils_1.DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields`
164
164
  : formattedError;
165
165
  throw new Error(formattedError);
166
166
  }
@@ -5,13 +5,14 @@ const tslib_1 = require("tslib");
5
5
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
6
  const utils_1 = require("@docusaurus/utils");
7
7
  const rtl_detect_1 = require("rtl-detect");
8
- const constants_1 = require("../constants");
9
8
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
10
9
  function getDefaultLocaleLabel(locale) {
11
10
  // Intl.DisplayNames is ES2021 - Node14+
12
11
  // https://v8.dev/features/intl-displaynames
13
12
  if (typeof Intl.DisplayNames !== 'undefined') {
14
- return new Intl.DisplayNames([locale], { type: 'language' }).of(locale);
13
+ const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
14
+ return (languageName.charAt(0).toLocaleUpperCase(locale) +
15
+ languageName.substring(1));
15
16
  }
16
17
  return locale;
17
18
  }
@@ -39,8 +40,8 @@ Note: Docusaurus only support running one locale at a time.`));
39
40
  const locales = i18nConfig.locales.includes(currentLocale)
40
41
  ? i18nConfig.locales
41
42
  : i18nConfig.locales.concat(currentLocale);
42
- if (shouldWarnAboutNodeVersion(constants_1.NODE_MAJOR_VERSION, locales)) {
43
- console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use Node.js 14 or later (instead of ${constants_1.NODE_MAJOR_VERSION}).`));
43
+ if (shouldWarnAboutNodeVersion(utils_1.NODE_MAJOR_VERSION, locales)) {
44
+ console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use Node.js 14 or later (instead of ${utils_1.NODE_MAJOR_VERSION}).`));
44
45
  }
45
46
  function getLocaleConfig(locale) {
46
47
  return {
@@ -12,7 +12,6 @@ const utils_1 = require("@docusaurus/utils");
12
12
  const path_1 = (0, tslib_1.__importStar)(require("path"));
13
13
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
14
14
  const ssr_html_template_1 = (0, tslib_1.__importDefault)(require("../client/templates/ssr.html.template"));
15
- const constants_1 = require("../constants");
16
15
  const client_modules_1 = (0, tslib_1.__importDefault)(require("./client-modules"));
17
16
  const config_1 = (0, tslib_1.__importDefault)(require("./config"));
18
17
  const plugins_1 = require("./plugins");
@@ -28,7 +27,7 @@ const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admoni
28
27
  const module_1 = require("module");
29
28
  const moduleShorthand_1 = require("./moduleShorthand");
30
29
  async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
31
- const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath : constants_1.DEFAULT_CONFIG_FILE_NAME;
30
+ const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath : utils_1.DEFAULT_CONFIG_FILE_NAME;
32
31
  const siteConfigPath = path_1.default.isAbsolute(siteConfigPathUnresolved)
33
32
  ? siteConfigPathUnresolved
34
33
  : path_1.default.resolve(siteDir, siteConfigPathUnresolved);
@@ -39,9 +38,9 @@ exports.loadSiteConfig = loadSiteConfig;
39
38
  async function loadContext(siteDir, options = {}) {
40
39
  var _a;
41
40
  const { customOutDir, locale, customConfigFilePath } = options;
42
- const generatedFilesDir = path_1.default.isAbsolute(constants_1.GENERATED_FILES_DIR_NAME)
43
- ? constants_1.GENERATED_FILES_DIR_NAME
44
- : path_1.default.resolve(siteDir, constants_1.GENERATED_FILES_DIR_NAME);
41
+ const generatedFilesDir = path_1.default.isAbsolute(utils_1.GENERATED_FILES_DIR_NAME)
42
+ ? utils_1.GENERATED_FILES_DIR_NAME
43
+ : path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
45
44
  const { siteConfig: initialSiteConfig, siteConfigPath } = await loadSiteConfig({
46
45
  siteDir,
47
46
  customConfigFilePath,
@@ -49,7 +48,7 @@ async function loadContext(siteDir, options = {}) {
49
48
  const { ssrTemplate } = initialSiteConfig;
50
49
  const baseOutDir = customOutDir
51
50
  ? path_1.default.resolve(customOutDir)
52
- : path_1.default.resolve(siteDir, constants_1.DEFAULT_BUILD_DIR_NAME);
51
+ : path_1.default.resolve(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME);
53
52
  const i18n = await (0, i18n_1.loadI18n)(initialSiteConfig, { locale });
54
53
  const baseUrl = (0, i18n_1.localizePath)({
55
54
  path: initialSiteConfig.baseUrl,
@@ -211,7 +210,7 @@ async function load(siteDir, options = {}) {
211
210
  (0, duplicateRoutes_1.handleDuplicateRoutes)(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
212
211
  // Site config must be generated after plugins
213
212
  // We want the generated config to have been normalized by the plugins!
214
- const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, constants_1.DEFAULT_CONFIG_FILE_NAME, `export default ${JSON.stringify(siteConfig, null, 2)};`);
213
+ const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, utils_1.DEFAULT_CONFIG_FILE_NAME, `export default ${JSON.stringify(siteConfig, null, 2)};`);
215
214
  plugins.push(createBootstrapPlugin({ siteConfig }));
216
215
  plugins.push(createMDXFallbackPlugin({ siteDir, siteConfig }));
217
216
  // Load client modules.
@@ -13,7 +13,6 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const init_1 = (0, tslib_1.__importDefault)(require("./init"));
15
15
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
16
- const constants_1 = require("../../constants");
17
16
  const lodash_1 = require("lodash");
18
17
  const translations_1 = require("../translations/translations");
19
18
  const applyRouteTrailingSlash_1 = (0, tslib_1.__importDefault)(require("./applyRouteTrailingSlash"));
@@ -84,7 +83,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
84
83
  const allContent = (0, lodash_1.chain)(loadedPlugins)
85
84
  .groupBy((item) => item.name)
86
85
  .mapValues((nameItems) => (0, lodash_1.chain)(nameItems)
87
- .groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; })
86
+ .groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; })
88
87
  .mapValues((idItems) => idItems[0].content)
89
88
  .value())
90
89
  .value();
@@ -96,7 +95,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
96
95
  if (!plugin.contentLoaded) {
97
96
  return;
98
97
  }
99
- const pluginId = (_a = plugin.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID;
98
+ const pluginId = (_a = plugin.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID;
100
99
  // plugins data files are namespaced by pluginName/pluginId
101
100
  const dataDirRoot = path_1.default.join(context.generatedFilesDir, plugin.name);
102
101
  const dataDir = path_1.default.join(dataDirRoot, pluginId);
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const module_1 = require("module");
11
11
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
12
- const constants_1 = require("../../constants");
12
+ const utils_1 = require("@docusaurus/utils");
13
13
  const versions_1 = require("../versions");
14
14
  const pluginIds_1 = require("./pluginIds");
15
15
  const utils_validation_1 = require("@docusaurus/utils-validation");
@@ -126,7 +126,7 @@ function initPlugins({ pluginConfigs, context, }) {
126
126
  // as we don't go through the Joi schema that adds it
127
127
  return {
128
128
  ...normalizedPluginConfig.options,
129
- id: (_a = normalizedPluginConfig.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID,
129
+ id: (_a = normalizedPluginConfig.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID,
130
130
  };
131
131
  }
132
132
  }
@@ -8,17 +8,17 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ensureUniquePluginInstanceIds = void 0;
10
10
  const lodash_1 = require("lodash");
11
- const constants_1 = require("../../constants");
11
+ const utils_1 = require("@docusaurus/utils");
12
12
  // It is forbidden to have 2 plugins of the same name sharing the same id
13
13
  // this is required to support multi-instance plugins without conflict
14
14
  function ensureUniquePluginInstanceIds(plugins) {
15
15
  const pluginsByName = (0, lodash_1.groupBy)(plugins, (p) => p.name);
16
16
  Object.entries(pluginsByName).forEach(([pluginName, pluginInstances]) => {
17
- const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PLUGIN_ID; });
17
+ const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; });
18
18
  Object.entries(pluginInstancesById).forEach(([pluginId, pluginInstancesWithId]) => {
19
19
  if (pluginInstancesWithId.length !== 1) {
20
- throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${pluginId === constants_1.DEFAULT_PLUGIN_ID
21
- ? `\n\nThe plugin ID is "${constants_1.DEFAULT_PLUGIN_ID}" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances).`
20
+ throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${pluginId === utils_1.DEFAULT_PLUGIN_ID
21
+ ? `\n\nThe plugin ID is "${utils_1.DEFAULT_PLUGIN_ID}" by default. It's possible that the preset you are using already includes a plugin instance, in which case you either want to disable the plugin in the preset (to use a single instance), or assign another ID to your extra plugin instance (to use multiple instances).`
22
22
  : ''}`);
23
23
  }
24
24
  });
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadPluginsThemeAliases = exports.loadThemeAliases = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const constants_1 = require("../../constants");
12
+ const utils_1 = require("@docusaurus/utils");
13
13
  const alias_1 = (0, tslib_1.__importStar)(require("./alias"));
14
14
  const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
15
15
  function loadThemeAliases(themePaths, userThemePaths) {
@@ -40,7 +40,7 @@ function loadPluginsThemeAliases({ siteDir, plugins, }) {
40
40
  const pluginThemes = plugins
41
41
  .map((plugin) => (plugin.getThemePath ? plugin.getThemePath() : undefined))
42
42
  .filter((x) => Boolean(x));
43
- const userTheme = path_1.default.resolve(siteDir, constants_1.THEME_PATH);
43
+ const userTheme = path_1.default.resolve(siteDir, utils_1.THEME_PATH);
44
44
  return loadThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
45
45
  }
46
46
  exports.loadPluginsThemeAliases = loadPluginsThemeAliases;
@@ -14,8 +14,8 @@ const generator_1 = (0, tslib_1.__importDefault)(require("@babel/generator"));
14
14
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
15
15
  const core_1 = require("@babel/core");
16
16
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
- const constants_1 = require("../../constants");
18
- const utils_1 = require("../utils");
17
+ const utils_1 = require("@docusaurus/utils");
18
+ const utils_2 = require("../utils");
19
19
  // We only support extracting source code translations from these kind of files
20
20
  const TranslatableSourceCodeExtension = new Set([
21
21
  '.js',
@@ -31,7 +31,7 @@ function isTranslatableSourceCodePath(filePath) {
31
31
  return TranslatableSourceCodeExtension.has(path_1.default.extname(filePath));
32
32
  }
33
33
  function getSiteSourceCodeFilePaths(siteDir) {
34
- return [path_1.default.join(siteDir, constants_1.SRC_DIR_NAME)];
34
+ return [path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
35
35
  }
36
36
  function getPluginSourceCodeFilePaths(plugin) {
37
37
  var _a, _b, _c;
@@ -47,7 +47,7 @@ function getPluginSourceCodeFilePaths(plugin) {
47
47
  return codePaths;
48
48
  }
49
49
  async function globSourceCodeFilePaths(dirPaths) {
50
- const filePaths = await (0, utils_1.safeGlobby)(dirPaths);
50
+ const filePaths = await (0, utils_2.safeGlobby)(dirPaths);
51
51
  return filePaths.filter(isTranslatableSourceCodePath);
52
52
  }
53
53
  exports.globSourceCodeFilePaths = globSourceCodeFilePaths;
@@ -53,7 +53,7 @@ function createBaseConfig(props, isServer, minify = true) {
53
53
  const isProd = process.env.NODE_ENV === 'production';
54
54
  const minimizeEnabled = minify && isProd && !isServer;
55
55
  const useSimpleCssMinifier = process.env.USE_SIMPLE_CSS_MINIFIER === 'true';
56
- const fileLoaderUtils = (0, utils_1.getFileLoaderUtils)();
56
+ const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
57
57
  const name = isServer ? 'server' : 'client';
58
58
  const mode = isProd ? 'production' : 'development';
59
59
  const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
@@ -12,7 +12,7 @@ const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
12
12
  const base_1 = require("./base");
13
13
  const WaitPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/WaitPlugin"));
14
14
  const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
15
- const constants_1 = require("../constants");
15
+ const utils_1 = require("@docusaurus/utils");
16
16
  // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
17
17
  const static_site_generator_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("@slorber/static-site-generator-webpack-plugin"));
18
18
  function createServerConfig({ props, onLinksCollected = () => { }, }) {
@@ -26,7 +26,7 @@ function createServerConfig({ props, onLinksCollected = () => { }, }) {
26
26
  return ssgPath;
27
27
  });
28
28
  const serverConfig = (0, webpack_merge_1.default)(config, {
29
- target: `node${constants_1.NODE_MAJOR_VERSION}.${constants_1.NODE_MINOR_VERSION}`,
29
+ target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
30
30
  entry: {
31
31
  main: path_1.default.resolve(__dirname, '../client/serverEntry.js'),
32
32
  },
@@ -32,30 +32,8 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
32
32
  export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
33
33
  export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
34
34
  export declare function compile(config: Configuration[]): Promise<void>;
35
- declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
36
- declare type FileLoaderUtils = {
37
- loaders: {
38
- file: (options: {
39
- folder: AssetFolder;
40
- }) => RuleSetRule;
41
- url: (options: {
42
- folder: AssetFolder;
43
- }) => RuleSetRule;
44
- inlineMarkdownImageFileLoader: string;
45
- inlineMarkdownLinkFileLoader: string;
46
- };
47
- rules: {
48
- images: () => RuleSetRule;
49
- fonts: () => RuleSetRule;
50
- media: () => RuleSetRule;
51
- svg: () => RuleSetRule;
52
- otherAssets: () => RuleSetRule;
53
- };
54
- };
55
- export declare function getFileLoaderUtils(): FileLoaderUtils;
56
35
  export declare function getHttpsConfig(): boolean | {
57
36
  cert: Buffer;
58
37
  key: Buffer;
59
38
  };
60
39
  export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
61
- export {};
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getMinimizer = exports.getHttpsConfig = exports.getFileLoaderUtils = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
9
+ exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
12
12
  const webpack_merge_1 = require("webpack-merge");
@@ -17,7 +17,7 @@ const css_minimizer_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("css
17
17
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
18
  const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
19
19
  const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
20
- const constants_1 = require("../constants");
20
+ const utils_1 = require("@docusaurus/utils");
21
21
  const lodash_1 = require("lodash");
22
22
  // Utility method to get style loaders
23
23
  function getStyleLoaders(isServer, cssOptions = {}) {
@@ -76,7 +76,7 @@ function getStyleLoaders(isServer, cssOptions = {}) {
76
76
  }
77
77
  exports.getStyleLoaders = getStyleLoaders;
78
78
  function getCustomBabelConfigFilePath(siteDir) {
79
- const customBabelConfigurationPath = path_1.default.join(siteDir, constants_1.BABEL_CONFIG_FILE_NAME);
79
+ const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
80
80
  return fs_extra_1.default.existsSync(customBabelConfigurationPath)
81
81
  ? customBabelConfigurationPath
82
82
  : undefined;
@@ -221,102 +221,6 @@ function compile(config) {
221
221
  });
222
222
  }
223
223
  exports.compile = compile;
224
- // Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
225
- function getFileLoaderUtils() {
226
- // files/images < urlLoaderLimit will be inlined as base64 strings directly in the html
227
- const urlLoaderLimit = constants_1.WEBPACK_URL_LOADER_LIMIT;
228
- // defines the path/pattern of the assets handled by webpack
229
- const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
230
- const loaders = {
231
- file: (options) => ({
232
- loader: require.resolve(`file-loader`),
233
- options: {
234
- name: fileLoaderFileName(options.folder),
235
- },
236
- }),
237
- url: (options) => ({
238
- loader: require.resolve(`url-loader`),
239
- options: {
240
- limit: urlLoaderLimit,
241
- name: fileLoaderFileName(options.folder),
242
- fallback: require.resolve(`file-loader`),
243
- },
244
- }),
245
- // TODO find a better solution to avoid conflicts with the ideal-image plugin
246
- // TODO this may require a little breaking change for ideal-image users?
247
- // Maybe with the ideal image plugin, all md images should be "ideal"?
248
- // This is used to force url-loader+file-loader on markdown images
249
- // https://webpack.js.org/concepts/loaders/#inline
250
- inlineMarkdownImageFileLoader: `!url-loader?limit=${urlLoaderLimit}&name=${fileLoaderFileName('images')}&fallback=file-loader!`,
251
- inlineMarkdownLinkFileLoader: `!file-loader?name=${fileLoaderFileName('files')}!`,
252
- };
253
- const rules = {
254
- /**
255
- * Loads image assets, inlines images via a data URI if they are below
256
- * the size threshold
257
- */
258
- images: () => ({
259
- use: [loaders.url({ folder: 'images' })],
260
- test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
261
- }),
262
- fonts: () => ({
263
- use: [loaders.url({ folder: 'fonts' })],
264
- test: /\.(woff|woff2|eot|ttf|otf)$/,
265
- }),
266
- /**
267
- * Loads audio and video and inlines them via a data URI if they are below
268
- * the size threshold
269
- */
270
- media: () => ({
271
- use: [loaders.url({ folder: 'medias' })],
272
- test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
273
- }),
274
- svg: () => ({
275
- test: /\.svg?$/,
276
- oneOf: [
277
- {
278
- use: [
279
- {
280
- loader: '@svgr/webpack',
281
- options: {
282
- prettier: false,
283
- svgo: true,
284
- svgoConfig: {
285
- plugins: [
286
- {
287
- name: 'preset-default',
288
- params: {
289
- overrides: {
290
- removeViewBox: false,
291
- },
292
- },
293
- },
294
- ],
295
- },
296
- titleProp: true,
297
- ref: ![path_1.default],
298
- },
299
- },
300
- ],
301
- // We don't want to use SVGR loader for non-React source code
302
- // ie we don't want to use SVGR for CSS files...
303
- issuer: {
304
- and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
305
- },
306
- },
307
- {
308
- use: [loaders.url({ folder: 'images' })],
309
- },
310
- ],
311
- }),
312
- otherAssets: () => ({
313
- use: [loaders.file({ folder: 'files' })],
314
- test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
315
- }),
316
- };
317
- return { loaders, rules };
318
- }
319
- exports.getFileLoaderUtils = getFileLoaderUtils;
320
224
  // Ensure the certificate and key provided are valid and if not
321
225
  // throw an easy to debug error
322
226
  function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
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": "0.0.0-4255",
4
+ "version": "0.0.0-4261",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,11 +41,12 @@
41
41
  "@babel/runtime": "^7.16.3",
42
42
  "@babel/runtime-corejs3": "^7.16.3",
43
43
  "@babel/traverse": "^7.16.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4255",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4261",
45
+ "@docusaurus/mdx-loader": "0.0.0-4261",
45
46
  "@docusaurus/react-loadable": "5.5.2",
46
- "@docusaurus/utils": "0.0.0-4255",
47
- "@docusaurus/utils-common": "0.0.0-4255",
48
- "@docusaurus/utils-validation": "0.0.0-4255",
47
+ "@docusaurus/utils": "0.0.0-4261",
48
+ "@docusaurus/utils-common": "0.0.0-4261",
49
+ "@docusaurus/utils-validation": "0.0.0-4261",
49
50
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
50
51
  "@svgr/webpack": "^6.0.0",
51
52
  "autoprefixer": "^10.3.5",
@@ -107,8 +108,8 @@
107
108
  "webpackbar": "^5.0.0-3"
108
109
  },
109
110
  "devDependencies": {
110
- "@docusaurus/module-type-aliases": "0.0.0-4255",
111
- "@docusaurus/types": "0.0.0-4255",
111
+ "@docusaurus/module-type-aliases": "0.0.0-4261",
112
+ "@docusaurus/types": "0.0.0-4261",
112
113
  "@types/copy-webpack-plugin": "^8.0.1",
113
114
  "@types/css-minimizer-webpack-plugin": "^3.0.2",
114
115
  "@types/detect-port": "^1.3.0",
@@ -127,5 +128,5 @@
127
128
  "engines": {
128
129
  "node": ">=14"
129
130
  },
130
- "gitHead": "8908b0cf1a155265ee3f2e46478c2697cd057280"
131
+ "gitHead": "ed9b25260e929a057df10621409f2e599f0c9a6a"
131
132
  }
@@ -1,19 +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
- export declare const NODE_MAJOR_VERSION: number;
8
- export declare const NODE_MINOR_VERSION: number;
9
- export declare const DEFAULT_BUILD_DIR_NAME = "build";
10
- export declare const DEFAULT_CONFIG_FILE_NAME = "docusaurus.config.js";
11
- export declare const BABEL_CONFIG_FILE_NAME: string;
12
- export declare const GENERATED_FILES_DIR_NAME: string;
13
- export declare const SRC_DIR_NAME = "src";
14
- export declare const STATIC_DIR_NAME = "static";
15
- export declare const OUTPUT_STATIC_ASSETS_DIR_NAME = "assets";
16
- export declare const THEME_PATH: string;
17
- export declare const DEFAULT_PORT = 3000;
18
- export declare const DEFAULT_PLUGIN_ID = "default";
19
- export declare const WEBPACK_URL_LOADER_LIMIT: string | number;
package/lib/constants.js DELETED
@@ -1,26 +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
- var _a;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- 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;
11
- exports.NODE_MAJOR_VERSION = parseInt(process.versions.node.split('.')[0], 10);
12
- exports.NODE_MINOR_VERSION = parseInt(process.versions.node.split('.')[1], 10);
13
- // Can be overridden with cli option --out-dir
14
- exports.DEFAULT_BUILD_DIR_NAME = 'build';
15
- // Can be overridden with cli option --config
16
- exports.DEFAULT_CONFIG_FILE_NAME = 'docusaurus.config.js';
17
- exports.BABEL_CONFIG_FILE_NAME = process.env.DOCUSAURUS_BABEL_CONFIG_FILE_NAME || 'babel.config.js';
18
- exports.GENERATED_FILES_DIR_NAME = process.env.DOCUSAURUS_GENERATED_FILES_DIR_NAME || '.docusaurus';
19
- exports.SRC_DIR_NAME = 'src';
20
- exports.STATIC_DIR_NAME = 'static';
21
- exports.OUTPUT_STATIC_ASSETS_DIR_NAME = 'assets'; // files handled by webpack, hashed (can be cached aggressively)
22
- exports.THEME_PATH = `${exports.SRC_DIR_NAME}/theme`;
23
- exports.DEFAULT_PORT = 3000;
24
- exports.DEFAULT_PLUGIN_ID = 'default';
25
- // Temporary fix for https://github.com/facebook/docusaurus/issues/5493
26
- exports.WEBPACK_URL_LOADER_LIMIT = (_a = process.env.WEBPACK_URL_LOADER_LIMIT) !== null && _a !== void 0 ? _a : 10000;