@rspress/runtime 1.39.3 → 1.40.0

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/Content.js CHANGED
@@ -2,8 +2,8 @@ import { Fragment, jsx } from "react/jsx-runtime";
2
2
  import { Suspense, memo } from "react";
3
3
  import { matchRoutes, useLocation } from "react-router-dom";
4
4
  import siteData from "virtual-site-data";
5
- import { normalizeRoutePath } from "./utils";
6
5
  import { useViewTransition } from "./hooks";
6
+ import { normalizeRoutePath } from "./utils";
7
7
  const { routes } = process.env.__SSR__ ? require("virtual-routes-ssr") : require("virtual-routes");
8
8
  function TransitionContentImpl(props) {
9
9
  let element = props.el;
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { type ReactElement } from 'react';
2
1
  import type { PageData } from '@rspress/shared';
2
+ import { type ReactElement } from 'react';
3
3
  declare global {
4
4
  interface Window {
5
5
  __MODERN_PAGE_DATA__: any;
package/dist/hooks.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  useLayoutEffect,
6
6
  useState
7
7
  } from "react";
8
- import i18nTextData from "virtual-i18n-text";
9
8
  import { flushSync } from "react-dom";
9
+ import i18nTextData from "virtual-i18n-text";
10
10
  const DataContext = createContext({});
11
11
  const ThemeContext = createContext({});
12
12
  function usePageData() {
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction } from '@rspress/shared';
1
+ import { addLeadingSlash, isProduction, normalizeSlash, removeTrailingSlash } from '@rspress/shared';
2
2
  export declare function normalizeRoutePath(routePath: string): string;
3
3
  export declare function withBase(url?: string): string;
4
4
  export declare function removeBase(url: string): string;
package/dist/utils.js CHANGED
@@ -1,16 +1,16 @@
1
- import siteData from "virtual-site-data";
2
1
  import {
3
2
  addLeadingSlash,
4
- removeTrailingSlash,
5
- normalizeSlash,
3
+ isDataUrl,
4
+ isExternalUrl,
6
5
  isProduction,
7
6
  normalizeHref,
8
- withBase as rawWithBase,
7
+ normalizeSlash,
9
8
  removeBase as rawRemoveBase,
10
- isExternalUrl,
11
- isDataUrl,
12
- removeHash
9
+ withBase as rawWithBase,
10
+ removeHash,
11
+ removeTrailingSlash
13
12
  } from "@rspress/shared";
13
+ import siteData from "virtual-site-data";
14
14
  function normalizeRoutePath(routePath) {
15
15
  return decodeURIComponent(routePath).replace(/\.html$/, "").replace(/\/index$/, "/");
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/runtime",
3
- "version": "1.39.3",
3
+ "version": "1.40.0",
4
4
  "description": "The Runtime of Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -9,9 +9,15 @@
9
9
  "directory": "packages/runtime"
10
10
  },
11
11
  "license": "MIT",
12
- "jsnext:source": "./src/index.ts",
13
- "types": "./dist/index.d.ts",
14
- "main": "./dist/index.js",
12
+ "sideEffects": [
13
+ "*.css",
14
+ "*.less",
15
+ "*.sass",
16
+ "*.scss",
17
+ "**/virtual-global-styles.js",
18
+ "virtual-global-styles",
19
+ "./src/theme-default/styles/index.ts"
20
+ ],
15
21
  "exports": {
16
22
  ".": {
17
23
  "types": "./dist/index.d.ts",
@@ -21,46 +27,40 @@
21
27
  "default": "./server.js"
22
28
  }
23
29
  },
24
- "engines": {
25
- "node": ">=14.17.6"
26
- },
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "files": [
33
+ "dist",
34
+ "src",
35
+ "runtime.ts",
36
+ "server.js"
37
+ ],
27
38
  "dependencies": {
28
39
  "react": "^18.3.1",
29
40
  "react-dom": "^18.3.1",
30
41
  "react-helmet-async": "^1.3.0",
31
42
  "react-router-dom": "^6.28.1",
32
- "@rspress/shared": "1.39.3"
43
+ "@rspress/shared": "1.40.0"
33
44
  },
34
45
  "devDependencies": {
35
- "@modern-js/tsconfig": "2.63.3",
46
+ "@modern-js/tsconfig": "2.63.6",
36
47
  "@types/jest": "~29.5.14",
37
48
  "@types/react": "^18.3.18",
38
49
  "@types/react-dom": "^18.3.5",
39
50
  "typescript": "^5.5.3"
40
51
  },
41
- "sideEffects": [
42
- "*.css",
43
- "*.less",
44
- "*.sass",
45
- "*.scss",
46
- "**/virtual-global-styles.js",
47
- "virtual-global-styles",
48
- "./src/theme-default/styles/index.ts"
49
- ],
50
- "files": [
51
- "dist",
52
- "src",
53
- "runtime.ts",
54
- "server.js"
55
- ],
52
+ "engines": {
53
+ "node": ">=14.17.6"
54
+ },
56
55
  "publishConfig": {
57
56
  "access": "public",
58
57
  "provenance": true,
59
58
  "registry": "https://registry.npmjs.org/"
60
59
  },
60
+ "jsnext:source": "./src/index.ts",
61
61
  "scripts": {
62
- "dev": "modern build -w",
63
62
  "build": "modern build",
63
+ "dev": "modern build -w",
64
64
  "reset": "rimraf ./**/node_modules",
65
65
  "test": "echo nothing"
66
66
  }
package/src/Content.tsx CHANGED
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
2
  /* eslint-disable @typescript-eslint/no-require-imports */
3
- import { type ReactNode, Suspense, memo, type ReactElement } from 'react';
3
+ import { type ReactElement, type ReactNode, Suspense, memo } from 'react';
4
4
  import { matchRoutes, useLocation } from 'react-router-dom';
5
5
  import siteData from 'virtual-site-data';
6
- import { normalizeRoutePath } from './utils';
7
6
  import { useViewTransition } from './hooks';
7
+ import { normalizeRoutePath } from './utils';
8
8
 
9
9
  const { routes } = process.env.__SSR__
10
10
  ? (require('virtual-routes-ssr') as typeof import('virtual-routes-ssr'))
package/src/hooks.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { PageData } from '@rspress/shared';
1
2
  import {
2
3
  type ReactElement,
3
4
  createContext,
@@ -6,9 +7,8 @@ import {
6
7
  useLayoutEffect,
7
8
  useState,
8
9
  } from 'react';
9
- import type { PageData } from '@rspress/shared';
10
- import i18nTextData from 'virtual-i18n-text';
11
10
  import { flushSync } from 'react-dom';
11
+ import i18nTextData from 'virtual-i18n-text';
12
12
 
13
13
  // Type shim for window.__EDEN_PAGE_DATA__
14
14
  declare global {
@@ -65,7 +65,7 @@ declare global {
65
65
 
66
66
  export function useViewTransition(dom: ReactElement) {
67
67
  /**
68
- * use a pesudo element to hold the actual JSX element so we can schedule the
68
+ * use a pseudo element to hold the actual JSX element so we can schedule the
69
69
  * update later in sync
70
70
  */
71
71
  const [element, setElement] = useState(dom);
@@ -102,7 +102,7 @@ export function useViewTransition(dom: ReactElement) {
102
102
  }
103
103
  }, [dom]);
104
104
  /**
105
- * take this element to the actual VDOM tree
105
+ * take this element to the actual V-DOM tree
106
106
  */
107
107
  return element;
108
108
  }
package/src/utils.ts CHANGED
@@ -1,16 +1,16 @@
1
- import siteData from 'virtual-site-data';
2
1
  import {
3
2
  addLeadingSlash,
4
- removeTrailingSlash,
5
- normalizeSlash,
3
+ isDataUrl,
4
+ isExternalUrl,
6
5
  isProduction,
7
6
  normalizeHref,
8
- withBase as rawWithBase,
7
+ normalizeSlash,
9
8
  removeBase as rawRemoveBase,
10
- isExternalUrl,
11
- isDataUrl,
9
+ withBase as rawWithBase,
12
10
  removeHash,
11
+ removeTrailingSlash,
13
12
  } from '@rspress/shared';
13
+ import siteData from 'virtual-site-data';
14
14
 
15
15
  export function normalizeRoutePath(routePath: string) {
16
16
  return decodeURIComponent(routePath)