@rspress/plugin-playground 2.0.0-beta.20 → 2.0.0-beta.22
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/cli/index.d.ts +2 -2
- package/dist/cli/index.js +3 -34
- package/package.json +7 -8
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EditorProps } from '@monaco-editor/react';
|
|
2
2
|
import type { loader } from '@monaco-editor/react';
|
|
3
|
-
import type { RouteMeta } from '@rspress/
|
|
4
|
-
import type { RspressPlugin } from '@rspress/
|
|
3
|
+
import type { RouteMeta } from '@rspress/core';
|
|
4
|
+
import type { RspressPlugin } from '@rspress/core';
|
|
5
5
|
|
|
6
6
|
declare interface PlaygroundOptions {
|
|
7
7
|
render: string;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
2
2
|
import { dirname as __webpack_dirname__ } from "node:path";
|
|
3
3
|
import node_fs from "node:fs";
|
|
4
|
-
import node_path, {
|
|
5
|
-
import { getNodeAttribute } from "@rspress/
|
|
4
|
+
import node_path, { join, resolve } from "node:path";
|
|
5
|
+
import { getNodeAttribute } from "@rspress/core";
|
|
6
6
|
import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
|
|
7
7
|
import { visit as external_unist_util_visit_visit } from "unist-util-visit";
|
|
8
8
|
import napi from "@oxidation-compiler/napi";
|
|
@@ -27,7 +27,7 @@ const getNodeMeta = (node, metaName)=>{
|
|
|
27
27
|
if (!node.meta) return;
|
|
28
28
|
const meta = node.meta.split(' ');
|
|
29
29
|
const item = meta.find((x)=>x.startsWith(metaName));
|
|
30
|
-
if (item?.startsWith(`${metaName}=`)) return item.slice(metaName.length + 1);
|
|
30
|
+
if (item?.startsWith(`${metaName}=`)) return item.slice(metaName.length + 1).replace(/'"`/g, '');
|
|
31
31
|
return item;
|
|
32
32
|
};
|
|
33
33
|
function createPlaygroundNode(currentNode, attrs) {
|
|
@@ -46,37 +46,6 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
46
46
|
return (tree, vfile)=>{
|
|
47
47
|
const route = routeMeta.find((meta)=>resolve(meta.absolutePath) === resolve(vfile.path || vfile.history[0]));
|
|
48
48
|
if (!route) return;
|
|
49
|
-
external_unist_util_visit_visit(tree, 'mdxJsxFlowElement', (node)=>{
|
|
50
|
-
if ('code' === node.name) {
|
|
51
|
-
const src = getNodeAttribute(node, 'src');
|
|
52
|
-
if ('string' != typeof src) return;
|
|
53
|
-
const demoPath = join(dirname(route.absolutePath), src);
|
|
54
|
-
if (!node_fs.existsSync(demoPath)) return;
|
|
55
|
-
const direction = getNodeAttribute(node, 'direction') || '';
|
|
56
|
-
const code = node_fs.readFileSync(demoPath, {
|
|
57
|
-
encoding: 'utf8'
|
|
58
|
-
});
|
|
59
|
-
const language = src.slice(src.lastIndexOf('.') + 1);
|
|
60
|
-
createPlaygroundNode(node, [
|
|
61
|
-
[
|
|
62
|
-
'code',
|
|
63
|
-
code
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
'language',
|
|
67
|
-
language
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
'direction',
|
|
71
|
-
direction
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
'editorPosition',
|
|
75
|
-
editorPosition
|
|
76
|
-
]
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
49
|
external_unist_util_visit_visit(tree, 'code', (node)=>{
|
|
81
50
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
82
51
|
const hasPureMeta = node.meta?.includes('pure');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-playground",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.22",
|
|
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": {
|
|
@@ -32,13 +32,12 @@
|
|
|
32
32
|
"@oxidation-compiler/napi": "^0.2.0",
|
|
33
33
|
"remark-gfm": "^4.0.1",
|
|
34
34
|
"rspack-plugin-virtual-module": "1.0.1",
|
|
35
|
-
"unist-util-visit": "^5.0.0"
|
|
36
|
-
"@rspress/shared": "2.0.0-beta.20"
|
|
35
|
+
"unist-util-visit": "^5.0.0"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
|
-
"@babel/types": "^7.28.
|
|
40
|
-
"@rsbuild/plugin-react": "~1.3.
|
|
41
|
-
"@rslib/core": "0.10.
|
|
38
|
+
"@babel/types": "^7.28.1",
|
|
39
|
+
"@rsbuild/plugin-react": "~1.3.4",
|
|
40
|
+
"@rslib/core": "0.10.6",
|
|
42
41
|
"@types/babel__core": "^7.20.5",
|
|
43
42
|
"@types/babel__standalone": "^7.1.9",
|
|
44
43
|
"@types/babel__traverse": "^7.20.7",
|
|
@@ -53,10 +52,10 @@
|
|
|
53
52
|
"rsbuild-plugin-publint": "^0.3.2",
|
|
54
53
|
"typescript": "^5.8.2",
|
|
55
54
|
"unified": "^11.0.5",
|
|
56
|
-
"@rspress/plugin-playground": "2.0.0-beta.
|
|
55
|
+
"@rspress/plugin-playground": "2.0.0-beta.22"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
|
-
"@rspress/core": "^2.0.0-beta.
|
|
58
|
+
"@rspress/core": "^2.0.0-beta.22",
|
|
60
59
|
"react": ">=18.0.0",
|
|
61
60
|
"react-router-dom": "^6.8.1"
|
|
62
61
|
},
|