@rspress/runtime 1.8.0 → 1.8.2

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 CHANGED
@@ -1,6 +1,4 @@
1
1
  import { ReactNode } from 'react';
2
- export declare const Content: ({
3
- fallback
4
- }: {
5
- fallback?: ReactNode;
6
- }) => any;
2
+ export declare const Content: ({ fallback }: {
3
+ fallback?: ReactNode;
4
+ }) => any;
package/dist/NoSSR.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare function NoSSR(props: {
3
- children: React.ReactNode;
4
- }): JSX.Element | null;
3
+ children: React.ReactNode;
4
+ }): JSX.Element | null;
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
- interface Window {
5
- __MODERN_PAGE_DATA__: any;
6
- }
4
+ interface Window {
5
+ __MODERN_PAGE_DATA__: any;
6
+ }
7
7
  }
8
8
  interface IDataContext {
9
- data: PageData;
10
- setData?: (data: PageData) => void;
9
+ data: PageData;
10
+ setData?: (data: PageData) => void;
11
11
  }
12
12
  interface IThemeContext {
13
- theme: 'light' | 'dark';
14
- setTheme?: (theme: 'light' | 'dark') => void;
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
- interface Document {
25
- startViewTransition: (callback: () => void) => void;
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 (isExternalUrl(imagePath) || !isProd) {
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.8.0",
3
+ "version": "1.8.2",
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.8.0"
37
+ "@rspress/shared": "1.8.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@modern-js/tsconfig": "2.41.0",
41
- "@modern-js/types": "2.41.0",
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 (isExternalUrl(imagePath) || !isProd) {
43
+ if (!isProd) {
44
+ return imagePath;
45
+ }
46
+ if (isExternalUrl(imagePath) || isDataUrl(imagePath)) {
43
47
  return imagePath;
44
48
  }
45
49