@rspress/shared 2.0.19 → 2.0.21

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/dist/91.js ADDED
@@ -0,0 +1 @@
1
+ export { logger } from "@rsbuild/core";
@@ -2042,7 +2042,7 @@ __webpack_require__.add({
2042
2042
  digits = [];
2043
2043
  if ('+-'.indexOf(value[0]) >= 0) value = value.slice(1);
2044
2044
  if ('.inf' === value) return 1 === sign ? 1 / 0 : -1 / 0;
2045
- if ('.nan' === value) return NaN;
2045
+ if ('.nan' === value) return 0 / 0;
2046
2046
  if (value.indexOf(':') >= 0) {
2047
2047
  value.split(':').forEach(function(v) {
2048
2048
  digits.unshift(parseFloat(v, 10));
package/dist/index.d.ts CHANGED
@@ -714,6 +714,17 @@ export declare interface RouteOptions {
714
714
  * @default false
715
715
  */
716
716
  cleanUrls?: boolean;
717
+ /**
718
+ * Normalize non-canonical browser URLs to the format selected by `cleanUrls`
719
+ * with the History API.
720
+ *
721
+ * When `cleanUrls` is enabled, regular page routes omit the trailing slash
722
+ * while directory index routes retain it. Otherwise, routes use `.html`
723
+ * URLs. This client-side fallback does not replace server-side 301/308
724
+ * redirects.
725
+ * @default true
726
+ */
727
+ cleanUrlsRedirect?: boolean;
717
728
  /**
718
729
  * How to redirect first-time visitors to the closest configured locale
719
730
  * based on their browser language.
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ function normalizePosixPath(id) {
35
35
  if (isAbsolutePath) normalizedPath = `/${normalizedPath}`;
36
36
  return normalizedPath;
37
37
  }
38
- const inBrowser = ()=>false;
38
+ const inBrowser = ()=>!import.meta.env.SSR;
39
39
  function addLeadingSlash(url) {
40
40
  return '/' === url.charAt(0) || isExternalUrl(url) ? url : `/${url}`;
41
41
  }
@@ -62,14 +62,13 @@ function replaceLang(rawUrl, lang, version, base = '', cleanUrls = false, isPage
62
62
  if (url.endsWith('/')) url += cleanUrls ? '/index' : '/index.html';
63
63
  let versionPart = '';
64
64
  let langPart = '';
65
- let purePathPart = '';
66
65
  const parts = url.split('/').filter(Boolean);
67
66
  if (version.current && version.current !== version.default) versionPart = parts.shift() || '';
68
67
  if (lang.target !== lang.default) {
69
68
  langPart = lang.target;
70
69
  if (lang.current !== lang.default) parts.shift();
71
70
  } else parts.shift();
72
- purePathPart = parts.join('/') || '';
71
+ let purePathPart = parts.join('/') || '';
73
72
  if ((versionPart || langPart) && !purePathPart) purePathPart = cleanUrls ? 'index' : 'index.html';
74
73
  return addLeadingSlash([
75
74
  versionPart,
package/dist/logger.js CHANGED
@@ -1 +1 @@
1
- export { logger } from "@rsbuild/core";
1
+ export { logger } from "./91.js";
@@ -588,6 +588,17 @@ declare interface RouteOptions {
588
588
  * @default false
589
589
  */
590
590
  cleanUrls?: boolean;
591
+ /**
592
+ * Normalize non-canonical browser URLs to the format selected by `cleanUrls`
593
+ * with the History API.
594
+ *
595
+ * When `cleanUrls` is enabled, regular page routes omit the trailing slash
596
+ * while directory index routes retain it. Otherwise, routes use `.html`
597
+ * URLs. This client-side fallback does not replace server-side 301/308
598
+ * redirects.
599
+ * @default true
600
+ */
601
+ cleanUrlsRedirect?: boolean;
591
602
  /**
592
603
  * How to redirect first-time visitors to the closest configured locale
593
604
  * based on their browser language.
@@ -1,7 +1,7 @@
1
1
  import node_path from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { grayMatter } from "./gray-matter.js";
4
- import { logger } from "./logger.js";
4
+ import { logger } from "./91.js";
5
5
  import { mergeWith as lodash_es_mergeWith } from "./584.js";
6
6
  const extractTextAndId = (title)=>{
7
7
  if (!title) return [
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@rspress/shared",
3
- "version": "2.0.19",
3
+ "version": "2.0.21",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/web-infra-dev/rspress.git",
7
7
  "directory": "packages/shared"
8
8
  },
9
9
  "license": "MIT",
10
+ "sideEffects": false,
10
11
  "type": "module",
11
12
  "exports": {
12
13
  ".": {
@@ -44,14 +45,14 @@
44
45
  "dist"
45
46
  ],
46
47
  "dependencies": {
47
- "@rsbuild/core": "^2.1.8",
48
+ "@rsbuild/core": "^2.1.13",
48
49
  "@shikijs/rehype": "^4.2.0",
49
- "@types/react": "^19.2.17",
50
+ "@types/react": "^19.2.18",
50
51
  "mdast-util-mdx-jsx": "^3.2.0",
51
52
  "unified": "^11.0.5"
52
53
  },
53
54
  "devDependencies": {
54
- "@rslib/core": "1.0.0-beta.1",
55
+ "@rslib/core": "1.0.0-rc.0",
55
56
  "@types/lodash-es": "^4.17.12",
56
57
  "@types/node": "^22.8.1",
57
58
  "github-slugger": "^2.0.0",
@@ -60,7 +61,8 @@
60
61
  "medium-zoom": "1.1.0",
61
62
  "rimraf": "^6.1.3",
62
63
  "rsbuild-plugin-publint": "^1.0.0",
63
- "typescript": "^6.0.3"
64
+ "typescript": "^6.0.3",
65
+ "@rspress/config": "1.0.0"
64
66
  },
65
67
  "publishConfig": {
66
68
  "access": "public",