@rspress/plugin-preview 2.0.0-beta.0 → 2.0.0-beta.10

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/utils.js CHANGED
@@ -1,35 +1,3 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- generateId: ()=>generateId,
28
- getLangFileExt: ()=>getLangFileExt,
29
- injectDemoBlockImport: ()=>injectDemoBlockImport,
30
- normalizeId: ()=>normalizeId,
31
- toValidVarName: ()=>toValidVarName
32
- });
33
1
  const toValidVarName = (str)=>{
34
2
  if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str)) return str;
35
3
  return str.replace(/[^0-9a-zA-Z_$]/g, '_').replace(/^([0-9])/, '_$1');
@@ -54,18 +22,4 @@ const getLangFileExt = (lang)=>{
54
22
  return lang;
55
23
  }
56
24
  };
57
- exports.generateId = __webpack_exports__.generateId;
58
- exports.getLangFileExt = __webpack_exports__.getLangFileExt;
59
- exports.injectDemoBlockImport = __webpack_exports__.injectDemoBlockImport;
60
- exports.normalizeId = __webpack_exports__.normalizeId;
61
- exports.toValidVarName = __webpack_exports__.toValidVarName;
62
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
63
- "generateId",
64
- "getLangFileExt",
65
- "injectDemoBlockImport",
66
- "normalizeId",
67
- "toValidVarName"
68
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
69
- Object.defineProperty(exports, '__esModule', {
70
- value: true
71
- });
25
+ export { generateId, getLangFileExt, injectDemoBlockImport, normalizeId, toValidVarName };
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@rspress/plugin-preview",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.10",
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": {
7
7
  "type": "git",
8
- "url": "https://github.com/web-infra-dev/rspress",
8
+ "url": "git+https://github.com/web-infra-dev/rspress.git",
9
9
  "directory": "packages/plugin-preview"
10
10
  },
11
11
  "license": "MIT",
12
- "main": "./dist/index.js",
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
13
19
  "types": "./index.d.ts",
14
20
  "files": [
15
21
  "index.d.ts",
@@ -17,40 +23,41 @@
17
23
  "static"
18
24
  ],
19
25
  "dependencies": {
20
- "@rsbuild/core": "1.3.9",
26
+ "@rsbuild/core": "~1.3.21",
21
27
  "@rsbuild/plugin-babel": "~1.0.5",
22
- "@rsbuild/plugin-less": "~1.2.2",
23
- "@rsbuild/plugin-react": "~1.1.1",
28
+ "@rsbuild/plugin-less": "~1.2.4",
29
+ "@rsbuild/plugin-react": "~1.3.1",
24
30
  "@rsbuild/plugin-sass": "~1.3.1",
25
31
  "@rsbuild/plugin-solid": "~1.0.5",
26
32
  "lodash": "4.17.21",
27
33
  "qrcode.react": "^4.2.0",
28
- "@rspress/shared": "2.0.0-beta.0",
29
- "@rspress/theme-default": "2.0.0-beta.0"
34
+ "@rspress/theme-default": "2.0.0-beta.10",
35
+ "@rspress/shared": "2.0.0-beta.10"
30
36
  },
31
37
  "devDependencies": {
32
- "@rslib/core": "0.6.5",
33
- "@types/lodash": "^4.17.16",
38
+ "@rslib/core": "0.8.0",
39
+ "@types/lodash": "^4.17.17",
34
40
  "@types/mdast": "^4.0.4",
35
- "@types/node": "^18.11.17",
36
- "@types/react": "^18.3.20",
37
- "@types/react-dom": "^18.3.6",
41
+ "@types/node": "^22.8.1",
42
+ "@types/react": "^18.3.22",
43
+ "@types/react-dom": "^18.3.7",
38
44
  "mdast-util-mdx-jsx": "^3.2.0",
39
45
  "mdast-util-mdxjs-esm": "^2.0.1",
40
46
  "react": "^19.1.0",
41
47
  "react-dom": "^19.1.0",
42
48
  "react-router-dom": "^6.29.0",
49
+ "rsbuild-plugin-publint": "^0.3.2",
43
50
  "typescript": "^5.8.2",
44
51
  "unified": "^11.0.5",
45
52
  "unist-util-visit": "^5.0.0"
46
53
  },
47
54
  "peerDependencies": {
48
- "@rspress/core": "^2.0.0-beta.0",
49
- "react": ">=17.0.0",
55
+ "@rspress/core": "^2.0.0-beta.10",
56
+ "react": ">=18.0.0",
50
57
  "react-router-dom": "^6.8.1"
51
58
  },
52
59
  "engines": {
53
- "node": ">=14.17.6"
60
+ "node": ">=18.0.0"
54
61
  },
55
62
  "publishConfig": {
56
63
  "access": "public",
@@ -45,7 +45,7 @@ const Container: React.FC<ContainerProps> = props => {
45
45
  <NoSSR>
46
46
  <div className="rspress-preview">
47
47
  {isMobile === 'true' ? (
48
- <div className="rspress-preview-wrapper flex">
48
+ <div className="rspress-preview-wrapper rp-flex">
49
49
  <div className="rspress-preview-code">{children?.[0]}</div>
50
50
  <div className="rspress-preview-device">
51
51
  <iframe src={getPageUrl()} key={iframeKey}></iframe>
@@ -1,12 +1,29 @@
1
- @import url(@rspress/theme-default/bundle.css);
2
-
3
1
  :root {
4
- --rp-iframe-bg: var(--rp-code-block-bg);
2
+ --rp-iframe-bg: #f6f8fa;
3
+ --rp-iframe-nav-bg: #ffffff;
5
4
  }
6
5
 
6
+ /* TODO: support dark mode */
7
+ /* .dark {
8
+ --rp-iframe-bg: #242424;
9
+ --rp-iframe-nav-bg: #191d24;
10
+ } */
11
+
7
12
  body {
8
- background-color: var(--rp-iframe-bg);
13
+ background-color: var(--rp-iframe-bg) !important;
14
+ margin: 0px; /* copied from preflight.css */
15
+ }
16
+
17
+ /* #region copied from preflight.css */
18
+ *,
19
+ ::before,
20
+ ::after {
21
+ box-sizing: border-box; /* 1 */
22
+ border-width: 0; /* 2 */
23
+ border-style: solid; /* 2 */
24
+ border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
9
25
  }
26
+ /* #endregion copied from preflight.css */
10
27
 
11
28
  .preview-nav {
12
29
  position: relative;
@@ -14,7 +31,7 @@ body {
14
31
  align-items: center;
15
32
  justify-content: center;
16
33
  height: 56px;
17
- background-color: var(--rp-c-bg);
34
+ background-color: var(--rp-iframe-nav-bg) !important;
18
35
  font-weight: 600;
19
36
  font-size: 17px;
20
37
  }