@rspress/plugin-preview 2.0.11 → 2.0.13
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 +9 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -382,6 +382,7 @@ const remarkWriteCodeFile = function({ getRouteMeta, defaultPreviewMode, default
|
|
|
382
382
|
if (demosInCurrPage[pageName].some((i)=>'iframe-fixed' === i.previewMode)) data.pageMeta.haveIframeFixedDemos = true;
|
|
383
383
|
if (!isDeepStrictEqual(remarkPlugin_globalDemos[pageName] ?? [], demosInCurrPage[pageName])) isDirtyRef.current = true;
|
|
384
384
|
if (0 !== demosInCurrPage[pageName].length) remarkPlugin_globalDemos[pageName] = demosInCurrPage[pageName];
|
|
385
|
+
else delete remarkPlugin_globalDemos[pageName];
|
|
385
386
|
};
|
|
386
387
|
};
|
|
387
388
|
let src_routeMeta;
|
|
@@ -395,6 +396,7 @@ function pluginPreview(options) {
|
|
|
395
396
|
let devServer;
|
|
396
397
|
let clientConfig;
|
|
397
398
|
let port = devPort;
|
|
399
|
+
const hasIframeDemos = ()=>Object.values(remarkPlugin_globalDemos).some((demos)=>demos.length > 0);
|
|
398
400
|
async function createDemoRsbuild() {
|
|
399
401
|
const distPath = clientConfig?.output?.distPath;
|
|
400
402
|
const distRoot = 'string' == typeof distPath ? distPath : distPath?.root ?? 'doc_build';
|
|
@@ -464,10 +466,17 @@ function pluginPreview(options) {
|
|
|
464
466
|
return rsbuildInstance;
|
|
465
467
|
}
|
|
466
468
|
async function buildDemo() {
|
|
469
|
+
if (!hasIframeDemos()) return;
|
|
467
470
|
const rsbuildInstance = await createDemoRsbuild();
|
|
468
471
|
await rsbuildInstance.build();
|
|
469
472
|
}
|
|
470
473
|
async function startDemoServer() {
|
|
474
|
+
if (!hasIframeDemos()) {
|
|
475
|
+
await devServer?.server.close();
|
|
476
|
+
devServer = void 0;
|
|
477
|
+
isDirtyRef.current = false;
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
471
480
|
if (devServer && !isDirtyRef.current) return;
|
|
472
481
|
if (devServer) {
|
|
473
482
|
await devServer.server.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-preview",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
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": {
|
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
"static"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rsbuild/core": "^2.0.
|
|
26
|
+
"@rsbuild/core": "^2.0.7",
|
|
27
27
|
"@rsbuild/plugin-babel": "~1.1.2",
|
|
28
28
|
"@rsbuild/plugin-react": "~2.0.0",
|
|
29
29
|
"picocolors": "^1.1.1",
|
|
30
30
|
"qrcode.react": "^4.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@rslib/core": "0.21.
|
|
33
|
+
"@rslib/core": "0.21.5",
|
|
34
34
|
"@types/mdast": "^4.0.4",
|
|
35
35
|
"@types/node": "^22.8.1",
|
|
36
|
-
"@types/react": "^19.2.
|
|
36
|
+
"@types/react": "^19.2.15",
|
|
37
37
|
"@types/react-dom": "^19.2.3",
|
|
38
38
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
39
39
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
40
40
|
"react": "^19.2.6",
|
|
41
41
|
"react-dom": "^19.2.6",
|
|
42
42
|
"rsbuild-plugin-publint": "^0.3.4",
|
|
43
|
-
"typescript": "^
|
|
43
|
+
"typescript": "^6.0.3",
|
|
44
44
|
"unified": "^11.0.5",
|
|
45
45
|
"unist-util-visit": "^5.1.0"
|
|
46
46
|
},
|