@rspress/core 2.0.9 → 2.0.10

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 (74) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/{740.js → 2287.js} +127 -139
  3. package/dist/8006.js +1 -1
  4. package/dist/8857.js +2 -3
  5. package/dist/cli/index.js +7 -4
  6. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
  7. package/dist/eject-theme/components/DocContent/doc.scss +14 -41
  8. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +13 -6
  9. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
  10. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +7 -3
  11. package/dist/eject-theme/components/Outline/index.scss +1 -1
  12. package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
  13. package/dist/eject-theme/components/Prompt/index.scss +478 -0
  14. package/dist/eject-theme/components/Prompt/index.tsx +335 -0
  15. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
  16. package/dist/node/PluginDriver.js +1 -1
  17. package/dist/node/auto-nav-sidebar/index.js +1 -1
  18. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  19. package/dist/node/auto-nav-sidebar/normalize.js +2 -2
  20. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  21. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  22. package/dist/node/eject.js +1 -0
  23. package/dist/node/initRsbuild.js +1 -1
  24. package/dist/node/route/RoutePage.js +1 -1
  25. package/dist/node/route/RouteService.js +1 -1
  26. package/dist/node/route/extractPageData.js +1 -1
  27. package/dist/node/route/normalizeRoutePath.js +1 -1
  28. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
  29. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
  30. package/dist/node/runtimeModule/i18n.js +1 -1
  31. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  32. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  33. package/dist/node/runtimeModule/searchHooks.js +1 -1
  34. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  35. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  36. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  37. package/dist/node/serve.js +1 -1
  38. package/dist/node/ssg/renderPages.js +1 -1
  39. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  40. package/dist/node/ssg/ssgEnv.js +1 -1
  41. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  42. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  43. package/dist/node/ssg-md/renderPage.js +1 -1
  44. package/dist/node/ssg-md/renderPages.js +1 -1
  45. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  46. package/dist/node/utils/checkLanguageParity.js +1 -1
  47. package/dist/node/utils/createHash.js +1 -1
  48. package/dist/node/utils/flattenMdxContent.js +1 -1
  49. package/dist/node/utils/getPageKey.js +1 -1
  50. package/dist/node/utils/reactAlias.js +1 -1
  51. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
  52. package/dist/theme/components/DocContent/doc.css +13 -21
  53. package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
  54. package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
  55. package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
  56. package/dist/theme/components/Outline/index.css +1 -1
  57. package/dist/theme/components/Prompt/icons.d.ts +10 -0
  58. package/dist/theme/components/Prompt/icons.js +64 -0
  59. package/dist/theme/components/Prompt/index.css +352 -0
  60. package/dist/theme/components/Prompt/index.d.ts +33 -0
  61. package/dist/theme/components/Prompt/index.js +262 -0
  62. package/dist/theme/components/SidebarMenu/index.js +2 -1
  63. package/dist/theme/index.d.ts +3 -0
  64. package/dist/theme/index.js +3 -0
  65. package/dist/theme/layout/DocLayout/index.css +5 -1
  66. package/dist/theme/layout/DocLayout/index.js +8 -4
  67. package/dist/theme/logic/copyToClipboard.d.ts +1 -0
  68. package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
  69. package/dist/theme/logic/getCopyableText.d.ts +5 -0
  70. package/dist/theme/logic/getCopyableText.js +52 -0
  71. package/dist/theme/styles/vars/base-vars.css +4 -4
  72. package/package.json +13 -13
  73. package/dist/eject-theme/components/Llms/copy.ts +0 -12
  74. package/dist/theme/components/Llms/copy.d.ts +0 -1
package/dist/0~execa.js CHANGED
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
8
8
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
9
9
  import { debuglog } from "node:util";
10
10
  import { __webpack_require__ } from "./0~rslib-runtime.js";
11
- import "./740.js";
11
+ import "./2287.js";
12
12
  __webpack_require__.add({
13
13
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
14
14
  const cp = __webpack_require__("child_process");
@@ -2,8 +2,9 @@ import node_path, { extname, join, relative as external_node_path_relative } fro
2
2
  import { __webpack_require__ } from "./0~rslib-runtime.js";
3
3
  import { fileURLToPath } from "url";
4
4
  import { createRequire } from "module";
5
- import fs_0, * as __rspack_external_fs from "fs";
6
- import path_0, { basename, dirname, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
5
+ import * as __rspack_external_fs from "fs";
6
+ import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
7
+ import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
7
8
  import { createRequire as __rspack_createRequire } from "node:module";
8
9
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
9
10
  __webpack_require__.add({
@@ -2126,36 +2127,36 @@ var Builder = class {
2126
2127
  };
2127
2128
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
2128
2129
  const isReadonlyArray = Array.isArray;
2130
+ const BACKSLASHES = /\\/g;
2129
2131
  const isWin = "win32" === process.platform;
2130
2132
  const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2131
2133
  function getPartialMatcher(patterns, options = {}) {
2132
2134
  const patternsCount = patterns.length;
2133
2135
  const patternsParts = Array(patternsCount);
2134
2136
  const matchers = Array(patternsCount);
2135
- const globstarEnabled = !options.noglobstar;
2136
- for(let i = 0; i < patternsCount; i++){
2137
+ let i, j;
2138
+ for(i = 0; i < patternsCount; i++){
2137
2139
  const parts = splitPattern(patterns[i]);
2138
2140
  patternsParts[i] = parts;
2139
2141
  const partsCount = parts.length;
2140
2142
  const partMatchers = Array(partsCount);
2141
- for(let j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
2143
+ for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
2142
2144
  matchers[i] = partMatchers;
2143
2145
  }
2144
2146
  return (input)=>{
2145
2147
  const inputParts = input.split("/");
2146
2148
  if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
2147
- for(let i = 0; i < patterns.length; i++){
2149
+ for(i = 0; i < patternsCount; i++){
2148
2150
  const patternParts = patternsParts[i];
2149
2151
  const matcher = matchers[i];
2150
2152
  const inputPatternCount = inputParts.length;
2151
2153
  const minParts = Math.min(inputPatternCount, patternParts.length);
2152
- let j = 0;
2154
+ j = 0;
2153
2155
  while(j < minParts){
2154
2156
  const part = patternParts[j];
2155
2157
  if (part.includes("/")) return true;
2156
- const match = matcher[j](inputParts[j]);
2157
- if (!match) break;
2158
- if (globstarEnabled && "**" === part) return true;
2158
+ if (!matcher[j](inputParts[j])) break;
2159
+ if (!options.noglobstar && "**" === part) return true;
2159
2160
  j++;
2160
2161
  }
2161
2162
  if (j === inputPatternCount) return true;
@@ -2168,7 +2169,7 @@ const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
2168
2169
  function buildFormat(cwd, root, absolute) {
2169
2170
  if (cwd === root || root.startsWith(`${cwd}/`)) {
2170
2171
  if (absolute) {
2171
- const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
2172
+ const start = cwd.length + +!isRoot(cwd);
2172
2173
  return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
2173
2174
  }
2174
2175
  const prefix = root.slice(cwd.length + 1);
@@ -2189,24 +2190,23 @@ function buildRelative(cwd, root) {
2189
2190
  }
2190
2191
  return (p)=>{
2191
2192
  const result = posix.relative(cwd, `${root}/${p}`);
2192
- if (p.endsWith("/") && "" !== result) return `${result}/`;
2193
- return result || ".";
2193
+ return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
2194
2194
  };
2195
2195
  }
2196
2196
  const splitPatternOptions = {
2197
2197
  parts: true
2198
2198
  };
2199
- function splitPattern(path$1) {
2199
+ function splitPattern(path) {
2200
2200
  var _result$parts;
2201
- const result = picomatch.scan(path$1, splitPatternOptions);
2201
+ const result = picomatch.scan(path, splitPatternOptions);
2202
2202
  return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
2203
- path$1
2203
+ path
2204
2204
  ];
2205
2205
  }
2206
2206
  const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2207
2207
  const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
2208
- const escapePosixPath = (path$1)=>path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2209
- const escapeWin32Path = (path$1)=>path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2208
+ const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2209
+ const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2210
2210
  const escapePath = isWin ? escapeWin32Path : escapePosixPath;
2211
2211
  function isDynamicPattern(pattern, options) {
2212
2212
  if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
@@ -2216,27 +2216,33 @@ function isDynamicPattern(pattern, options) {
2216
2216
  function log(...tasks) {
2217
2217
  console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
2218
2218
  }
2219
+ function ensureStringArray(value) {
2220
+ return "string" == typeof value ? [
2221
+ value
2222
+ ] : null != value ? value : [];
2223
+ }
2219
2224
  const PARENT_DIRECTORY = /^(\/?\.\.)+/;
2220
2225
  const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2221
- const BACKSLASHES = /\\/g;
2222
- function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
2226
+ function normalizePattern(pattern, opts, props, isIgnore) {
2227
+ var _PARENT_DIRECTORY$exe;
2228
+ const cwd = opts.cwd;
2223
2229
  let result = pattern;
2224
- if (pattern.endsWith("/")) result = pattern.slice(0, -1);
2225
- if (!result.endsWith("*") && expandDirectories) result += "/**";
2230
+ if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
2231
+ if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
2226
2232
  const escapedCwd = escapePath(cwd);
2227
- result = path_0.isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
2228
- const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
2233
+ result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
2234
+ const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
2229
2235
  const parts = splitPattern(result);
2230
- if (null == parentDirectoryMatch ? void 0 : parentDirectoryMatch[0]) {
2231
- const n = (parentDirectoryMatch[0].length + 1) / 3;
2236
+ if (parentDir) {
2237
+ const n = (parentDir.length + 1) / 3;
2232
2238
  let i = 0;
2233
2239
  const cwdParts = escapedCwd.split("/");
2234
2240
  while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
2235
2241
  result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
2236
2242
  i++;
2237
2243
  }
2238
- const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(3 * i));
2239
- if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
2244
+ const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
2245
+ if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
2240
2246
  props.root = potentialRoot;
2241
2247
  props.depthOffset = -n + i;
2242
2248
  }
@@ -2251,7 +2257,7 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
2251
2257
  newCommonPath.pop();
2252
2258
  break;
2253
2259
  }
2254
- if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
2260
+ if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
2255
2261
  newCommonPath.push(part);
2256
2262
  }
2257
2263
  props.depthOffset = newCommonPath.length;
@@ -2260,147 +2266,129 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
2260
2266
  }
2261
2267
  return result;
2262
2268
  }
2263
- function processPatterns({ patterns = [
2264
- "**/*"
2265
- ], ignore = [], expandDirectories = true }, cwd, props) {
2266
- if ("string" == typeof patterns) patterns = [
2267
- patterns
2268
- ];
2269
- if ("string" == typeof ignore) ignore = [
2270
- ignore
2271
- ];
2269
+ function processPatterns(options, patterns, props) {
2272
2270
  const matchPatterns = [];
2273
2271
  const ignorePatterns = [];
2274
- for (const pattern of ignore)if (pattern) {
2275
- if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
2272
+ for (const pattern of options.ignore)if (pattern) {
2273
+ if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
2276
2274
  }
2277
2275
  for (const pattern of patterns)if (pattern) {
2278
- if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
2279
- else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
2276
+ if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
2277
+ else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
2280
2278
  }
2281
2279
  return {
2282
2280
  match: matchPatterns,
2283
2281
  ignore: ignorePatterns
2284
2282
  };
2285
2283
  }
2286
- function formatPaths(paths, relative) {
2287
- for(let i = paths.length - 1; i >= 0; i--){
2288
- const path$1 = paths[i];
2289
- paths[i] = relative(path$1);
2290
- }
2291
- return paths;
2292
- }
2293
- function normalizeCwd(cwd) {
2294
- if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
2295
- if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
2296
- return path_0.resolve(cwd).replace(BACKSLASHES, "/");
2297
- }
2298
- function getCrawler(patterns, inputOptions = {}) {
2299
- const options = process.env.TINYGLOBBY_DEBUG ? {
2300
- ...inputOptions,
2301
- debug: true
2302
- } : inputOptions;
2303
- const cwd = normalizeCwd(options.cwd);
2304
- if (options.debug) log("globbing with:", {
2305
- patterns,
2306
- options,
2307
- cwd
2308
- });
2309
- if (Array.isArray(patterns) && 0 === patterns.length) return [
2310
- {
2311
- sync: ()=>[],
2312
- withPromise: async ()=>[]
2313
- },
2314
- false
2315
- ];
2284
+ function buildCrawler(options, patterns) {
2285
+ const cwd = options.cwd;
2316
2286
  const props = {
2317
2287
  root: cwd,
2318
- commonPath: null,
2319
2288
  depthOffset: 0
2320
2289
  };
2321
- const processed = processPatterns({
2322
- ...options,
2323
- patterns
2324
- }, cwd, props);
2290
+ const processed = processPatterns(options, patterns, props);
2325
2291
  if (options.debug) log("internal processing patterns:", processed);
2292
+ const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
2293
+ const root = props.root.replace(BACKSLASHES, "");
2326
2294
  const matchOptions = {
2327
- dot: options.dot,
2295
+ dot,
2328
2296
  nobrace: false === options.braceExpansion,
2329
- nocase: false === options.caseSensitiveMatch,
2297
+ nocase: !caseSensitiveMatch,
2330
2298
  noextglob: false === options.extglob,
2331
2299
  noglobstar: false === options.globstar,
2332
2300
  posix: true
2333
2301
  };
2334
- const matcher = picomatch(processed.match, {
2335
- ...matchOptions,
2336
- ignore: processed.ignore
2337
- });
2302
+ const matcher = picomatch(processed.match, matchOptions);
2338
2303
  const ignore = picomatch(processed.ignore, matchOptions);
2339
2304
  const partialMatcher = getPartialMatcher(processed.match, matchOptions);
2340
- const format = buildFormat(cwd, props.root, options.absolute);
2341
- const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
2342
- const fdirOptions = {
2305
+ const format = buildFormat(cwd, root, absolute);
2306
+ const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
2307
+ const excludePredicate = (_, p)=>{
2308
+ const relativePath = excludeFormatter(p, true);
2309
+ return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2310
+ };
2311
+ let maxDepth;
2312
+ if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
2313
+ const crawler = new Builder({
2343
2314
  filters: [
2344
- options.debug ? (p, isDirectory)=>{
2345
- const path$1 = format(p, isDirectory);
2346
- const matches = matcher(path$1);
2347
- if (matches) log(`matched ${path$1}`);
2315
+ debug ? (p, isDirectory)=>{
2316
+ const path = format(p, isDirectory);
2317
+ const matches = matcher(path) && !ignore(path);
2318
+ if (matches) log(`matched ${path}`);
2348
2319
  return matches;
2349
- } : (p, isDirectory)=>matcher(format(p, isDirectory))
2320
+ } : (p, isDirectory)=>{
2321
+ const path = format(p, isDirectory);
2322
+ return matcher(path) && !ignore(path);
2323
+ }
2350
2324
  ],
2351
- exclude: options.debug ? (_, p)=>{
2352
- const relativePath = formatExclude(p, true);
2353
- const skipped = "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2354
- skipped ? log(`skipped ${p}`) : log(`crawling ${p}`);
2325
+ exclude: debug ? (_, p)=>{
2326
+ const skipped = excludePredicate(_, p);
2327
+ log(`${skipped ? "skipped" : "crawling"} ${p}`);
2355
2328
  return skipped;
2356
- } : (_, p)=>{
2357
- const relativePath = formatExclude(p, true);
2358
- return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2359
- },
2360
- fs: options.fs ? {
2361
- readdir: options.fs.readdir || fs_0.readdir,
2362
- readdirSync: options.fs.readdirSync || fs_0.readdirSync,
2363
- realpath: options.fs.realpath || fs_0.realpath,
2364
- realpathSync: options.fs.realpathSync || fs_0.realpathSync,
2365
- stat: options.fs.stat || fs_0.stat,
2366
- statSync: options.fs.statSync || fs_0.statSync
2367
- } : void 0,
2329
+ } : excludePredicate,
2330
+ fs: options.fs,
2368
2331
  pathSeparator: "/",
2369
- relativePaths: true,
2370
- resolveSymlinks: true,
2332
+ relativePaths: !absolute,
2333
+ resolvePaths: absolute,
2334
+ includeBasePath: absolute,
2335
+ resolveSymlinks: followSymbolicLinks,
2336
+ excludeSymlinks: !followSymbolicLinks,
2337
+ excludeFiles: onlyDirectories,
2338
+ includeDirs: onlyDirectories || !options.onlyFiles,
2339
+ maxDepth,
2371
2340
  signal: options.signal
2372
- };
2373
- if (void 0 !== options.deep) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
2374
- if (options.absolute) {
2375
- fdirOptions.relativePaths = false;
2376
- fdirOptions.resolvePaths = true;
2377
- fdirOptions.includeBasePath = true;
2378
- }
2379
- if (false === options.followSymbolicLinks) {
2380
- fdirOptions.resolveSymlinks = false;
2381
- fdirOptions.excludeSymlinks = true;
2382
- }
2383
- if (options.onlyDirectories) {
2384
- fdirOptions.excludeFiles = true;
2385
- fdirOptions.includeDirs = true;
2386
- } else if (false === options.onlyFiles) fdirOptions.includeDirs = true;
2387
- props.root = props.root.replace(BACKSLASHES, "");
2388
- const root = props.root;
2389
- if (options.debug) log("internal properties:", props);
2390
- const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
2341
+ }).crawl(root);
2342
+ if (options.debug) log("internal properties:", {
2343
+ ...props,
2344
+ root
2345
+ });
2391
2346
  return [
2392
- new Builder(fdirOptions).crawl(root),
2393
- relative
2347
+ crawler,
2348
+ cwd !== root && !absolute && buildRelative(cwd, root)
2394
2349
  ];
2395
2350
  }
2396
- async function glob(patternsOrOptions, options) {
2397
- if (patternsOrOptions && (null == options ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2398
- const isModern = isReadonlyArray(patternsOrOptions) || "string" == typeof patternsOrOptions;
2399
- const opts = isModern ? options : patternsOrOptions;
2400
- const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
2401
- const [crawler, relative] = getCrawler(patterns, opts);
2402
- if (!relative) return crawler.withPromise();
2403
- return formatPaths(await crawler.withPromise(), relative);
2351
+ function formatPaths(paths, mapper) {
2352
+ if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
2353
+ return paths;
2354
+ }
2355
+ const defaultOptions = {
2356
+ caseSensitiveMatch: true,
2357
+ cwd: process.cwd(),
2358
+ debug: !!process.env.TINYGLOBBY_DEBUG,
2359
+ expandDirectories: true,
2360
+ followSymbolicLinks: true,
2361
+ onlyFiles: true
2362
+ };
2363
+ function getOptions(options) {
2364
+ const opts = {
2365
+ ...defaultOptions,
2366
+ ...options
2367
+ };
2368
+ opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd)).replace(BACKSLASHES, "/");
2369
+ opts.ignore = ensureStringArray(opts.ignore);
2370
+ opts.fs && (opts.fs = {
2371
+ readdir: opts.fs.readdir || readdir,
2372
+ readdirSync: opts.fs.readdirSync || readdirSync,
2373
+ realpath: opts.fs.realpath || realpath,
2374
+ realpathSync: opts.fs.realpathSync || realpathSync,
2375
+ stat: opts.fs.stat || external_fs_stat,
2376
+ statSync: opts.fs.statSync || statSync
2377
+ });
2378
+ if (opts.debug) log("globbing with options:", opts);
2379
+ return opts;
2380
+ }
2381
+ function getCrawler(globInput, inputOptions = {}) {
2382
+ var _ref;
2383
+ if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2384
+ const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
2385
+ const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
2386
+ const options = getOptions(isModern ? inputOptions : globInput);
2387
+ return patterns.length > 0 ? buildCrawler(options, patterns) : [];
2388
+ }
2389
+ async function glob(globInput, options) {
2390
+ const [crawler, relative] = getCrawler(globInput, options);
2391
+ return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
2404
2392
  }
2405
2393
  const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
2406
2394
  const pluginVirtualModule = (pluginOptions = {})=>({
@@ -2447,7 +2435,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
2447
2435
  }
2448
2436
  });
2449
2437
  export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
2450
- export { default as promises, mkdir, readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2438
+ export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2451
2439
  export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2452
2440
  export { logger } from "@rspress/shared/logger";
2453
2441
  export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
package/dist/8006.js CHANGED
@@ -68,7 +68,7 @@ __webpack_require__.add({
68
68
  }
69
69
  });
70
70
  var package_namespaceObject = {
71
- rE: "2.0.9"
71
+ rE: "2.0.10"
72
72
  };
73
73
  export { default as promises, readFile } from "node:fs/promises";
74
74
  export { default as node_path, join, relative } from "node:path";
package/dist/8857.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! LICENSE: 8857.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "./0~rslib-runtime.js";
3
- import "./740.js";
3
+ import "./2287.js";
4
4
  import { createRequire as __rspack_createRequire } from "node:module";
5
5
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
6
6
  __webpack_require__.add({
@@ -1153,13 +1153,12 @@ __webpack_require__.add({
1153
1153
  return stream;
1154
1154
  }
1155
1155
  }
1156
- exports.FSWatcher = FSWatcher;
1157
1156
  const watch = (paths, options)=>{
1158
1157
  const watcher = new FSWatcher(options);
1159
1158
  watcher.add(paths);
1160
1159
  return watcher;
1161
1160
  };
1162
- exports.watch = watch;
1161
+ exports.w = watch;
1163
1162
  },
1164
1163
  "../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/constants.js" (__unused_rspack_module, exports, __webpack_require__) {
1165
1164
  const { sep } = __webpack_require__("path?aeb1");
package/dist/cli/index.js CHANGED
@@ -21,7 +21,7 @@ const setNodeEnv = (env)=>{
21
21
  process.env.NODE_ENV = env;
22
22
  };
23
23
  cli.option('-c,--config [config]', 'Specify the path to the config file');
24
- cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
24
+ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
25
25
  setNodeEnv('development');
26
26
  let isRestarting = false;
27
27
  const cwd = process.cwd();
@@ -31,6 +31,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
31
31
  const { port, host } = options || {};
32
32
  const { config, configFilePath } = await loadConfigFile(options?.config);
33
33
  config.root = resolveDocRoot(cwd, root, config.root);
34
+ if (options?.base) config.base = options.base;
34
35
  const docDirectory = config.root;
35
36
  devServer = await dev({
36
37
  appDirectory: cwd,
@@ -44,7 +45,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
44
45
  }
45
46
  }
46
47
  });
47
- cliWatcher = chokidar.watch([
48
+ cliWatcher = chokidar.w([
48
49
  configFilePath,
49
50
  docDirectory
50
51
  ], {
@@ -82,11 +83,12 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
82
83
  process.on('SIGINT', exitProcess);
83
84
  process.on('SIGTERM', exitProcess);
84
85
  });
85
- cli.command('build [root]').action(async (root, options)=>{
86
+ cli.command('build [root]').option('--base <base>', 'deployment base path').action(async (root, options)=>{
86
87
  setNodeEnv('production');
87
88
  const cwd = process.cwd();
88
89
  const { config, configFilePath } = await loadConfigFile(options.config);
89
90
  config.root = resolveDocRoot(cwd, root, config.root);
91
+ if (options.base) config.base = options.base;
90
92
  const docDirectory = config.root;
91
93
  try {
92
94
  await build({
@@ -99,12 +101,13 @@ cli.command('build [root]').action(async (root, options)=>{
99
101
  process.exit(1);
100
102
  }
101
103
  });
102
- cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').action(async (root, options)=>{
104
+ cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
103
105
  setNodeEnv('production');
104
106
  const cwd = process.cwd();
105
107
  const { port, host } = options || {};
106
108
  const { config, configFilePath } = await loadConfigFile(options?.config);
107
109
  config.root = resolveDocRoot(cwd, root, config.root);
110
+ if (options?.base) config.base = options.base;
108
111
  await serve({
109
112
  config,
110
113
  host,
@@ -1,5 +1,10 @@
1
- import { IconCopy, IconSuccess, SvgWrapper } from '@rspress/core/theme';
2
- import copy from 'copy-to-clipboard';
1
+ import {
2
+ copyToClipboard,
3
+ getCopyableText,
4
+ IconCopy,
5
+ IconSuccess,
6
+ SvgWrapper,
7
+ } from '@rspress/core/theme';
3
8
  import { useRef } from 'react';
4
9
  import './CopyCodeButton.scss';
5
10
  import { useI18n } from '@rspress/core/runtime';
@@ -7,31 +12,20 @@ import { useI18n } from '@rspress/core/runtime';
7
12
  const timeoutIdMap: Map<HTMLElement, NodeJS.Timeout> = new Map();
8
13
  const COPIED_CLASS = 'rp-code-copy-button--copied';
9
14
 
10
- function copyCode(
15
+ async function copyCode(
11
16
  codeBlockElement: HTMLElement | null,
12
17
  copyButtonElement: HTMLButtonElement | null,
13
18
  ) {
14
- let text = '';
15
19
  if (!codeBlockElement) {
16
20
  return;
17
21
  }
18
- const walk = document.createTreeWalker(
19
- codeBlockElement,
20
- NodeFilter.SHOW_TEXT,
21
- null,
22
- );
23
- let node = walk.nextNode();
24
- while (node) {
25
- if (
26
- !node.parentElement!.classList.contains('linenumber') &&
27
- !node.parentElement!.closest('.rp-copy-ignore')
28
- ) {
29
- text += node.nodeValue;
30
- }
31
- node = walk.nextNode();
32
- }
33
22
 
34
- const isCopied = copy(text);
23
+ const text = getCopyableText(codeBlockElement, {
24
+ ignoreClasses: ['linenumber'],
25
+ ignoreSelectors: ['.rp-copy-ignore'],
26
+ });
27
+
28
+ const isCopied = await copyToClipboard(text);
35
29
 
36
30
  if (isCopied && copyButtonElement) {
37
31
  copyButtonElement.classList.add(COPIED_CLASS);
@@ -56,7 +50,9 @@ export function CopyCodeButton({
56
50
  return (
57
51
  <button
58
52
  className="rp-code-button-group__button rp-code-copy-button"
59
- onClick={() => copyCode(codeBlockRef.current, copyButtonRef.current!)}
53
+ onClick={() => {
54
+ void copyCode(codeBlockRef.current, copyButtonRef.current);
55
+ }}
60
56
  ref={copyButtonRef}
61
57
  title={t('codeButtonGroupCopyButtonText')}
62
58
  >
@@ -177,30 +177,24 @@
177
177
  /* table */
178
178
  /* #region */
179
179
  &:where(.rp-table-scroll-container) {
180
+ margin: 1.5rem 0;
180
181
  overflow-x: auto;
182
+ overscroll-behavior-x: contain;
181
183
  }
184
+
182
185
  &:where(table) {
183
186
  width: 100%;
184
-
187
+ min-width: 100%;
185
188
  table-layout: auto;
186
189
  border-collapse: separate;
187
190
  border-spacing: 0;
188
-
189
191
  border: var(--rp-code-block-border);
190
192
  border-radius: var(--rp-radius);
191
193
  overflow: hidden;
194
+ }
192
195
 
193
- &::-webkit-scrollbar {
194
- height: 5px;
195
- width: 5px;
196
- }
197
- &::-webkit-scrollbar-corner {
198
- display: none;
199
- }
200
- &::-webkit-scrollbar-thumb {
201
- background-color: rgba(0, 0, 0, 0.05);
202
- border-radius: 10px;
203
- }
196
+ &:where(table:not(.rp-table-scroll-container > table)) {
197
+ margin: 1.5rem 0;
204
198
  }
205
199
 
206
200
  /* thead */
@@ -210,7 +204,8 @@
210
204
  }
211
205
 
212
206
  &:where(th) {
213
- padding: 0.75rem 1.25rem;
207
+ min-width: 8rem;
208
+ padding: 0.75rem 1rem;
214
209
  font-weight: 600;
215
210
  font-size: 0.875rem;
216
211
  text-align: left;
@@ -224,14 +219,15 @@
224
219
  }
225
220
 
226
221
  &:where(td) {
227
- padding: 0.75rem 1.25rem;
222
+ min-width: 8rem;
223
+ padding: 0.75rem 1rem;
228
224
  border-bottom: 1px solid var(--rp-c-divider-light);
229
-
230
225
  font-size: 0.875rem;
226
+ color: var(--rp-c-text-1);
231
227
  }
232
228
 
233
- &:where(tr) {
234
- transition: background-color 0.2s ease;
229
+ &:where(tbody tr) {
230
+ transition: background-color 0.2s ease-out;
235
231
 
236
232
  &:hover {
237
233
  background: var(--rp-c-bg-soft);
@@ -282,26 +278,3 @@
282
278
  }
283
279
  }
284
280
  }
285
-
286
- /* Dark mode styles */
287
- :where(.rp-dark) .rp-doc {
288
- :not(:where(.rp-not-doc, .rp-not-doc *)) {
289
- /* table */
290
- /* #region */
291
- &:where(table) {
292
- border-color: var(--rp-c-divider);
293
- }
294
-
295
- &:where(table tr) {
296
- border-color: var(--rp-c-divider);
297
- }
298
-
299
- &:where(table td) {
300
- border-color: var(--rp-c-divider);
301
- }
302
-
303
- &:where(table th) {
304
- border-color: var(--rp-c-divider);
305
- }
306
- }
307
- }