@rspress/runtime 1.7.5 → 1.8.1
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.d.ts +3 -5
- package/dist/NoSSR.d.ts +2 -2
- package/dist/hooks.d.ts +11 -11
- package/dist/index.d.ts +3 -3
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -1
- package/package.json +4 -4
- package/src/utils.ts +5 -1
package/dist/Content.d.ts
CHANGED
package/dist/NoSSR.d.ts
CHANGED
package/dist/hooks.d.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
import { ReactElement } from 'react';
|
2
2
|
import { PageData } from '@rspress/shared';
|
3
3
|
declare global {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
interface Window {
|
5
|
+
__MODERN_PAGE_DATA__: any;
|
6
|
+
}
|
7
7
|
}
|
8
8
|
interface IDataContext {
|
9
|
-
|
10
|
-
|
9
|
+
data: PageData;
|
10
|
+
setData?: (data: PageData) => void;
|
11
11
|
}
|
12
12
|
interface IThemeContext {
|
13
|
-
|
14
|
-
|
13
|
+
theme: 'light' | 'dark';
|
14
|
+
setTheme?: (theme: 'light' | 'dark') => void;
|
15
15
|
}
|
16
16
|
export declare const DataContext: import("react").Context<IDataContext>;
|
17
17
|
export declare const ThemeContext: import("react").Context<IThemeContext>;
|
@@ -21,9 +21,9 @@ export declare function useVersion(): string;
|
|
21
21
|
export declare function useDark(): boolean;
|
22
22
|
export declare function useI18n<T = Record<string, Record<string, string>>>(): (key: keyof T) => any;
|
23
23
|
declare global {
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
interface Document {
|
25
|
+
startViewTransition: (callback: () => void) => void;
|
26
|
+
}
|
27
27
|
}
|
28
28
|
export declare function useViewTransition(dom: ReactElement): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
29
|
-
export {};
|
29
|
+
export {};
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export * from './hooks';
|
2
2
|
export * from './Content';
|
3
|
-
export { normalizeHrefInRuntime, normalizeImagePath, withBase, removeBase, addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction, normalizeRoutePath, isEqualPath } from './utils';
|
4
|
-
export { useLocation, useNavigate, matchRoutes, BrowserRouter } from 'react-router-dom';
|
3
|
+
export { normalizeHrefInRuntime, normalizeImagePath, withBase, removeBase, addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction, normalizeRoutePath, isEqualPath, } from './utils';
|
4
|
+
export { useLocation, useNavigate, matchRoutes, BrowserRouter, } from 'react-router-dom';
|
5
5
|
export { Helmet } from 'react-helmet-async';
|
6
|
-
export { NoSSR } from './NoSSR';
|
6
|
+
export { NoSSR } from './NoSSR';
|
package/dist/utils.d.ts
CHANGED
@@ -5,4 +5,4 @@ export declare function removeBase(url: string): string;
|
|
5
5
|
export declare function isEqualPath(a: string, b: string): boolean;
|
6
6
|
export declare function normalizeHrefInRuntime(a: string): string;
|
7
7
|
export declare function normalizeImagePath(imagePath: string): string;
|
8
|
-
export { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction };
|
8
|
+
export { addLeadingSlash, removeTrailingSlash, normalizeSlash, isProduction };
|
package/dist/utils.js
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
withBase as rawWithBase,
|
9
9
|
removeBase as rawRemoveBase,
|
10
10
|
isExternalUrl,
|
11
|
+
isDataUrl,
|
11
12
|
removeHash
|
12
13
|
} from "@rspress/shared";
|
13
14
|
function normalizeRoutePath(routePath) {
|
@@ -28,7 +29,10 @@ function normalizeHrefInRuntime(a) {
|
|
28
29
|
}
|
29
30
|
function normalizeImagePath(imagePath) {
|
30
31
|
const isProd = isProduction();
|
31
|
-
if (
|
32
|
+
if (!isProd) {
|
33
|
+
return imagePath;
|
34
|
+
}
|
35
|
+
if (isExternalUrl(imagePath) || isDataUrl(imagePath)) {
|
32
36
|
return imagePath;
|
33
37
|
}
|
34
38
|
return withBase(imagePath);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/runtime",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.8.1",
|
4
4
|
"description": "The Runtime of Rspress Documentation Framework",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
@@ -34,11 +34,11 @@
|
|
34
34
|
"react-dom": "^18.2.0",
|
35
35
|
"react-helmet-async": "^1.3.0",
|
36
36
|
"react-router-dom": "^6.8.1",
|
37
|
-
"@rspress/shared": "1.
|
37
|
+
"@rspress/shared": "1.8.1"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
|
-
"@modern-js/tsconfig": "2.
|
41
|
-
"@modern-js/types": "2.
|
40
|
+
"@modern-js/tsconfig": "2.42.0",
|
41
|
+
"@modern-js/types": "2.42.0",
|
42
42
|
"@types/jest": "^26.0.9",
|
43
43
|
"@types/react": "^18",
|
44
44
|
"@types/react-dom": "^18",
|
package/src/utils.ts
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
withBase as rawWithBase,
|
9
9
|
removeBase as rawRemoveBase,
|
10
10
|
isExternalUrl,
|
11
|
+
isDataUrl,
|
11
12
|
removeHash,
|
12
13
|
} from '@rspress/shared';
|
13
14
|
|
@@ -39,7 +40,10 @@ export function normalizeHrefInRuntime(a: string) {
|
|
39
40
|
|
40
41
|
export function normalizeImagePath(imagePath: string) {
|
41
42
|
const isProd = isProduction();
|
42
|
-
if (
|
43
|
+
if (!isProd) {
|
44
|
+
return imagePath;
|
45
|
+
}
|
46
|
+
if (isExternalUrl(imagePath) || isDataUrl(imagePath)) {
|
43
47
|
return imagePath;
|
44
48
|
}
|
45
49
|
|