@rspress/runtime 0.0.0-nightly-20231030160438 → 0.0.0-nightly-20231101160508
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/{runtime/NoSSR.d.ts → NoSSR.d.ts} +1 -1
- package/dist/{runtime/hooks.d.ts → hooks.d.ts} +2 -12
- package/dist/{runtime/hooks.js → hooks.js} +6 -1
- package/dist/{runtime/utils.js → utils.js} +2 -1
- package/package.json +8 -8
- package/src/{runtime/hooks.ts → hooks.ts} +8 -12
- package/src/{runtime/utils.ts → utils.ts} +2 -1
- package/dist/runtime/tsconfig.json +0 -10
- package/src/runtime/tsconfig.json +0 -10
- /package/dist/{runtime/Content.d.ts → Content.d.ts} +0 -0
- /package/dist/{runtime/Content.js → Content.js} +0 -0
- /package/dist/{runtime/NoSSR.js → NoSSR.js} +0 -0
- /package/dist/{runtime/index.d.ts → index.d.ts} +0 -0
- /package/dist/{runtime/index.js → index.js} +0 -0
- /package/dist/{runtime/utils.d.ts → utils.d.ts} +0 -0
- /package/src/{runtime/Content.tsx → Content.tsx} +0 -0
- /package/src/{runtime/NoSSR.tsx → NoSSR.tsx} +0 -0
- /package/src/{runtime/global.d.ts → global.d.ts} +0 -0
- /package/src/{runtime/index.ts → index.ts} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { ReactElement } from 'react';
|
2
2
|
import { PageData } from '@rspress/shared';
|
3
3
|
declare global {
|
4
4
|
interface Window {
|
@@ -25,15 +25,5 @@ declare global {
|
|
25
25
|
startViewTransition: (callback: () => void) => void;
|
26
26
|
}
|
27
27
|
}
|
28
|
-
|
29
|
-
* There is a pitfall.
|
30
|
-
* I was working on the navigation between pages with hash. eg. from `guide/start` -> `config/repress#nav`
|
31
|
-
* I need a time to dispatch an event so that the sideEffect.ts would know that
|
32
|
-
* the dom is attached to the browser. Otherwise the scroll position and the
|
33
|
-
* animation would be incorrect. You can search for `RspressReloadContent` in this codebase
|
34
|
-
* to findout the logic that are consuming the event.
|
35
|
-
* The reason I didn't write it here is that I hope the logic of handling scroll and position
|
36
|
-
* could be in one place so that people wouldn't be confused.
|
37
|
-
*/
|
38
|
-
export declare function useViewTransition(dom: any): any;
|
28
|
+
export declare function useViewTransition(dom: ReactElement): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
39
29
|
export {};
|
@@ -1,4 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
createContext,
|
3
|
+
useContext,
|
4
|
+
useLayoutEffect,
|
5
|
+
useState
|
6
|
+
} from "react";
|
2
7
|
import i18nTextData from "virtual-i18n-text";
|
3
8
|
import { flushSync } from "react-dom";
|
4
9
|
const DataContext = createContext({});
|
@@ -26,7 +26,8 @@ function normalizeHrefInRuntime(a) {
|
|
26
26
|
return normalizeHref(a, cleanUrls);
|
27
27
|
}
|
28
28
|
function normalizeImagePath(imagePath) {
|
29
|
-
|
29
|
+
const isProd = isProduction();
|
30
|
+
if (isExternalUrl(imagePath) || !isProd) {
|
30
31
|
return imagePath;
|
31
32
|
}
|
32
33
|
return withBase(imagePath);
|
package/package.json
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/runtime",
|
3
|
-
"version": "0.0.0-nightly-
|
3
|
+
"version": "0.0.0-nightly-20231101160508",
|
4
4
|
"description": "The Runtime of Rspress Documentation Framework",
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
6
6
|
"repository": {
|
7
7
|
"type": "git",
|
8
8
|
"url": "https://github.com/web-infra-dev/rspress",
|
9
|
-
"directory": "packages/
|
9
|
+
"directory": "packages/runtime"
|
10
10
|
},
|
11
11
|
"license": "MIT",
|
12
12
|
"type": "module",
|
13
|
-
"jsnext:source": "./src/
|
14
|
-
"types": "./dist/
|
15
|
-
"main": "./dist/
|
13
|
+
"jsnext:source": "./src/index.ts",
|
14
|
+
"types": "./dist/index.d.ts",
|
15
|
+
"main": "./dist/index.js",
|
16
16
|
"exports": {
|
17
17
|
".": {
|
18
|
-
"types": "./dist/
|
19
|
-
"default": "./dist/
|
18
|
+
"types": "./dist/index.d.ts",
|
19
|
+
"default": "./dist/index.js"
|
20
20
|
},
|
21
21
|
"./server": {
|
22
22
|
"default": "./server.js"
|
@@ -34,7 +34,7 @@
|
|
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": "0.0.0-nightly-
|
37
|
+
"@rspress/shared": "0.0.0-nightly-20231101160508"
|
38
38
|
},
|
39
39
|
"devDependencies": {
|
40
40
|
"@modern-js/tsconfig": "2.39.0",
|
@@ -1,4 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
ReactElement,
|
3
|
+
createContext,
|
4
|
+
useContext,
|
5
|
+
useLayoutEffect,
|
6
|
+
useState,
|
7
|
+
} from 'react';
|
2
8
|
import { PageData } from '@rspress/shared';
|
3
9
|
import i18nTextData from 'virtual-i18n-text';
|
4
10
|
import { flushSync } from 'react-dom';
|
@@ -55,17 +61,7 @@ declare global {
|
|
55
61
|
}
|
56
62
|
}
|
57
63
|
|
58
|
-
|
59
|
-
* There is a pitfall.
|
60
|
-
* I was working on the navigation between pages with hash. eg. from `guide/start` -> `config/repress#nav`
|
61
|
-
* I need a time to dispatch an event so that the sideEffect.ts would know that
|
62
|
-
* the dom is attached to the browser. Otherwise the scroll position and the
|
63
|
-
* animation would be incorrect. You can search for `RspressReloadContent` in this codebase
|
64
|
-
* to findout the logic that are consuming the event.
|
65
|
-
* The reason I didn't write it here is that I hope the logic of handling scroll and position
|
66
|
-
* could be in one place so that people wouldn't be confused.
|
67
|
-
*/
|
68
|
-
export function useViewTransition(dom) {
|
64
|
+
export function useViewTransition(dom: ReactElement) {
|
69
65
|
/**
|
70
66
|
* use a pesudo element to hold the actual JSX element so we can schedule the
|
71
67
|
* update later in sync
|
@@ -36,7 +36,8 @@ export function normalizeHrefInRuntime(a: string) {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
export function normalizeImagePath(imagePath: string) {
|
39
|
-
|
39
|
+
const isProd = isProduction();
|
40
|
+
if (isExternalUrl(imagePath) || !isProd) {
|
40
41
|
return imagePath;
|
41
42
|
}
|
42
43
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|