@rspress/plugin-preview 2.0.0-alpha.6 → 2.0.0-alpha.8

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/index.js CHANGED
@@ -590,8 +590,10 @@ var __webpack_exports__ = {};
590
590
  };
591
591
  }
592
592
  })();
593
- var __webpack_export_target__ = exports;
594
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
595
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
593
+ exports.pluginPreview = __webpack_exports__.pluginPreview;
594
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
595
+ "pluginPreview"
596
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
597
+ Object.defineProperty(exports, '__esModule', {
596
598
  value: true
597
599
  });
package/dist/utils.js CHANGED
@@ -42,8 +42,16 @@ const injectDemoBlockImport = (str, path)=>`
42
42
  import DemoBlock from ${JSON.stringify(path)};
43
43
  ${str}
44
44
  `;
45
- var __webpack_export_target__ = exports;
46
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
47
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
45
+ exports.generateId = __webpack_exports__.generateId;
46
+ exports.injectDemoBlockImport = __webpack_exports__.injectDemoBlockImport;
47
+ exports.normalizeId = __webpack_exports__.normalizeId;
48
+ exports.toValidVarName = __webpack_exports__.toValidVarName;
49
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
50
+ "generateId",
51
+ "injectDemoBlockImport",
52
+ "normalizeId",
53
+ "toValidVarName"
54
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
55
+ Object.defineProperty(exports, '__esModule', {
48
56
  value: true
49
57
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-preview",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.8",
4
4
  "description": "A plugin for rspress to preview the code block in markdown/mdx file.",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -17,23 +17,23 @@
17
17
  "static"
18
18
  ],
19
19
  "dependencies": {
20
- "@rsbuild/core": "1.2.19",
20
+ "@rsbuild/core": "1.3.0",
21
21
  "@rsbuild/plugin-babel": "~1.0.4",
22
- "@rsbuild/plugin-less": "~1.1.1",
22
+ "@rsbuild/plugin-less": "~1.2.1",
23
23
  "@rsbuild/plugin-react": "~1.1.1",
24
- "@rsbuild/plugin-sass": "~1.2.2",
24
+ "@rsbuild/plugin-sass": "~1.3.1",
25
25
  "@rsbuild/plugin-solid": "~1.0.5",
26
26
  "lodash": "4.17.21",
27
27
  "qrcode.react": "^4.2.0",
28
- "@rspress/theme-default": "2.0.0-alpha.6",
29
- "@rspress/shared": "2.0.0-alpha.6"
28
+ "@rspress/shared": "2.0.0-alpha.8",
29
+ "@rspress/theme-default": "2.0.0-alpha.8"
30
30
  },
31
31
  "devDependencies": {
32
- "@rslib/core": "0.5.5",
32
+ "@rslib/core": "0.6.0",
33
33
  "@types/lodash": "^4.17.16",
34
34
  "@types/mdast": "^3.0.15",
35
35
  "@types/node": "^18.11.17",
36
- "@types/react": "^18.3.19",
36
+ "@types/react": "^18.3.20",
37
37
  "@types/react-dom": "^18.3.5",
38
38
  "mdast-util-mdx-jsx": "^2.1.4",
39
39
  "mdast-util-mdxjs-esm": "^1.3.1",
@@ -45,7 +45,7 @@
45
45
  "unist-util-visit": "^4.1.2"
46
46
  },
47
47
  "peerDependencies": {
48
- "@rspress/core": "^2.0.0-alpha.6",
48
+ "@rspress/core": "^2.0.0-alpha.8",
49
49
  "react": ">=17.0.0",
50
50
  "react-router-dom": "^6.8.1"
51
51
  },
@@ -1,4 +1,9 @@
1
- import { NoSSR, usePageData, withBase } from '@rspress/core/runtime';
1
+ import {
2
+ NoSSR,
3
+ usePageData,
4
+ useWindowSize,
5
+ withBase,
6
+ } from '@rspress/core/runtime';
2
7
  import { useCallback, useEffect, useState } from 'react';
3
8
  // @ts-ignore
4
9
  import { normalizeId } from '../../dist/utils';
@@ -22,10 +27,8 @@ export default () => {
22
27
  // Do nothing in ssr
23
28
  return '';
24
29
  };
25
- const initialInnerWidth =
26
- typeof window !== 'undefined' ? window.innerWidth : 0;
27
30
  const [asideWidth, setAsideWidth] = useState('0px');
28
- const [innerWidth, setInnerWidth] = useState(initialInnerWidth);
31
+ const { width: innerWidth } = useWindowSize();
29
32
  const [iframeKey, setIframeKey] = useState(0);
30
33
  const refresh = useCallback(() => {
31
34
  setIframeKey(Math.random());
@@ -40,11 +43,6 @@ export default () => {
40
43
  getComputedStyle(root).getPropertyValue('--rp-aside-width');
41
44
  setAsideWidth(defaultAsideWidth);
42
45
  }
43
- const handleResize = () => {
44
- setInnerWidth(window.innerWidth);
45
- };
46
- window.addEventListener('resize', handleResize);
47
- return () => window.removeEventListener('resize', handleResize);
48
46
  }, []);
49
47
 
50
48
  useEffect(() => {