@rspress/plugin-preview 1.40.3-cannary-20250126 → 1.41.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/index.js +7 -6
- package/dist/utils.js +4 -12
- package/package.json +9 -10
package/dist/index.js
CHANGED
@@ -73,6 +73,7 @@ var __webpack_exports__ = {};
|
|
73
73
|
const demoBlockComponentPath = external_node_path_default().join(staticPath, 'global-components', 'DemoBlock.tsx');
|
74
74
|
const virtualDir = external_node_path_default().join(process.cwd(), 'node_modules', shared_namespaceObject.RSPRESS_TEMP_DIR, 'virtual-demo');
|
75
75
|
const external_node_fs_namespaceObject = require("node:fs");
|
76
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
76
77
|
const toValidVarName = (str)=>{
|
77
78
|
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str)) return str;
|
78
79
|
return str.replace(/[^0-9a-zA-Z_$]/g, '_').replace(/^([0-9])/, '_$1');
|
@@ -144,8 +145,6 @@ var __webpack_exports__ = {};
|
|
144
145
|
});
|
145
146
|
return sourceEntry;
|
146
147
|
}
|
147
|
-
const fs_extra_namespaceObject = require("@rspress/shared/fs-extra");
|
148
|
-
var fs_extra_default = /*#__PURE__*/ __webpack_require__.n(fs_extra_namespaceObject);
|
149
148
|
const convert = function(test) {
|
150
149
|
if (null == test) return ok;
|
151
150
|
if ('string' == typeof test) return typeFactory(test);
|
@@ -334,7 +333,9 @@ var __webpack_exports__ = {};
|
|
334
333
|
const remarkPlugin_demos = {};
|
335
334
|
const remarkCodeToDemo = function({ getRouteMeta, previewMode, defaultRenderMode, position, previewLanguages, previewCodeTransform }) {
|
336
335
|
const routeMeta = getRouteMeta();
|
337
|
-
|
336
|
+
external_node_fs_default().mkdirSync(virtualDir, {
|
337
|
+
recursive: true
|
338
|
+
});
|
338
339
|
const data = this.data();
|
339
340
|
return (tree, vfile)=>{
|
340
341
|
const demoMdx = [];
|
@@ -420,11 +421,11 @@ var __webpack_exports__ = {};
|
|
420
421
|
const id = generateId(pageName, index++);
|
421
422
|
const virtualModulePath = (0, external_node_path_namespaceObject.join)(virtualDir, `${id}.tsx`);
|
422
423
|
constructDemoNode(id, virtualModulePath, node, isMobileMode);
|
423
|
-
if (
|
424
|
-
const content =
|
424
|
+
if (external_node_fs_default().existsSync(virtualModulePath)) {
|
425
|
+
const content = external_node_fs_default().readFileSync(virtualModulePath, 'utf-8');
|
425
426
|
if (content === value) return;
|
426
427
|
}
|
427
|
-
|
428
|
+
external_node_fs_default().writeFileSync(virtualModulePath, value);
|
428
429
|
}
|
429
430
|
});
|
430
431
|
tree.children.unshift(...demoMdx);
|
package/dist/utils.js
CHANGED
@@ -26,18 +26,10 @@ var __webpack_require__ = {};
|
|
26
26
|
var __webpack_exports__ = {};
|
27
27
|
__webpack_require__.r(__webpack_exports__);
|
28
28
|
__webpack_require__.d(__webpack_exports__, {
|
29
|
-
generateId:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return injectDemoBlockImport;
|
34
|
-
},
|
35
|
-
normalizeId: function() {
|
36
|
-
return normalizeId;
|
37
|
-
},
|
38
|
-
toValidVarName: function() {
|
39
|
-
return toValidVarName;
|
40
|
-
}
|
29
|
+
generateId: ()=>generateId,
|
30
|
+
injectDemoBlockImport: ()=>injectDemoBlockImport,
|
31
|
+
normalizeId: ()=>normalizeId,
|
32
|
+
toValidVarName: ()=>toValidVarName
|
41
33
|
});
|
42
34
|
const toValidVarName = (str)=>{
|
43
35
|
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(str)) return str;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/plugin-preview",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.41.1",
|
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": {
|
@@ -13,11 +13,10 @@
|
|
13
13
|
"types": "./dist/index.d.ts",
|
14
14
|
"files": [
|
15
15
|
"dist",
|
16
|
-
"static"
|
17
|
-
"mdx-meta-loader.cjs"
|
16
|
+
"static"
|
18
17
|
],
|
19
18
|
"dependencies": {
|
20
|
-
"@rsbuild/core": "1.2.
|
19
|
+
"@rsbuild/core": "1.2.3",
|
21
20
|
"@rsbuild/plugin-babel": "~1.0.3",
|
22
21
|
"@rsbuild/plugin-less": "~1.1.0",
|
23
22
|
"@rsbuild/plugin-react": "~1.1.0",
|
@@ -25,12 +24,12 @@
|
|
25
24
|
"@rsbuild/plugin-solid": "~1.0.4",
|
26
25
|
"lodash": "4.17.21",
|
27
26
|
"qrcode.react": "^3.2.0",
|
28
|
-
"@rspress/shared": "1.
|
29
|
-
"@rspress/theme-default": "1.
|
27
|
+
"@rspress/shared": "1.41.1",
|
28
|
+
"@rspress/theme-default": "1.41.1"
|
30
29
|
},
|
31
30
|
"devDependencies": {
|
32
|
-
"@rslib/core": "0.
|
33
|
-
"@types/lodash": "^4.17.
|
31
|
+
"@rslib/core": "0.4.0",
|
32
|
+
"@types/lodash": "^4.17.15",
|
34
33
|
"@types/mdast": "^3.0.15",
|
35
34
|
"@types/node": "^18.11.17",
|
36
35
|
"@types/react": "^18.3.18",
|
@@ -38,13 +37,13 @@
|
|
38
37
|
"mdast-util-mdxjs-esm": "^1.3.1",
|
39
38
|
"react": "^18.3.1",
|
40
39
|
"react-dom": "^18.3.1",
|
41
|
-
"react-router-dom": "^6.
|
40
|
+
"react-router-dom": "^6.29.0",
|
42
41
|
"typescript": "^5.5.3",
|
43
42
|
"unified": "^10.1.2",
|
44
43
|
"unist-util-visit": "^4.1.2"
|
45
44
|
},
|
46
45
|
"peerDependencies": {
|
47
|
-
"@rspress/core": "^1.
|
46
|
+
"@rspress/core": "^1.41.1",
|
48
47
|
"react": ">=17.0.0",
|
49
48
|
"react-router-dom": "^6.8.1"
|
50
49
|
},
|