@rspress/plugin-playground 2.0.0-alpha.8 → 2.0.0-beta.0
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/cjs/{301.js → 52.js} +3 -3
- package/dist/cli/cjs/index.js +64 -42
- package/dist/cli/esm/{301.mjs → 52.mjs} +3 -3
- package/dist/cli/esm/index.mjs +60 -42
- package/dist/web/cjs/index.js +4 -7
- package/dist/web/esm/index.mjs +4 -7
- package/package.json +13 -13
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
exports.ids = [
|
|
3
|
-
'
|
|
3
|
+
'52'
|
|
4
4
|
];
|
|
5
5
|
exports.modules = {
|
|
6
|
-
"../../node_modules/.pnpm/unist-util-visit@
|
|
6
|
+
"../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
7
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
8
|
visit: ()=>_lib_index_js__WEBPACK_IMPORTED_MODULE_0__.Vn
|
|
9
9
|
});
|
|
10
|
-
var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@
|
|
10
|
+
var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
|
|
11
11
|
}
|
|
12
12
|
};
|
package/dist/cli/cjs/index.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
3
|
"@mdx-js/mdx": function(module) {
|
|
4
|
-
module.exports = import("@mdx-js/mdx")
|
|
4
|
+
module.exports = import("@mdx-js/mdx").then(function(module) {
|
|
5
|
+
return module;
|
|
6
|
+
});
|
|
5
7
|
},
|
|
6
8
|
"remark-gfm": function(module) {
|
|
7
|
-
module.exports = import("remark-gfm")
|
|
9
|
+
module.exports = import("remark-gfm").then(function(module) {
|
|
10
|
+
return module;
|
|
11
|
+
});
|
|
8
12
|
},
|
|
9
|
-
"../../node_modules/.pnpm/unist-util-visit@
|
|
13
|
+
"../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
10
14
|
__webpack_require__.d(__webpack_exports__, {
|
|
11
15
|
Vn: ()=>lib_visit
|
|
12
16
|
});
|
|
13
17
|
const convert = function(test) {
|
|
14
18
|
if (null == test) return ok;
|
|
15
|
-
if ('string' == typeof test) return typeFactory(test);
|
|
16
|
-
if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
17
19
|
if ('function' == typeof test) return castFactory(test);
|
|
20
|
+
if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
21
|
+
if ('string' == typeof test) return typeFactory(test);
|
|
18
22
|
throw new Error('Expected function, string, or object as test');
|
|
19
23
|
};
|
|
20
24
|
function anyFactory(tests) {
|
|
@@ -24,15 +28,17 @@ var __webpack_modules__ = {
|
|
|
24
28
|
return castFactory(any);
|
|
25
29
|
function any(...parameters) {
|
|
26
30
|
let index = -1;
|
|
27
|
-
while(++index < checks.length)if (checks[index].
|
|
31
|
+
while(++index < checks.length)if (checks[index].apply(this, parameters)) return true;
|
|
28
32
|
return false;
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
function propsFactory(check) {
|
|
36
|
+
const checkAsRecord = check;
|
|
32
37
|
return castFactory(all);
|
|
33
38
|
function all(node) {
|
|
39
|
+
const nodeAsRecord = node;
|
|
34
40
|
let key;
|
|
35
|
-
for(key in check)if (
|
|
41
|
+
for(key in check)if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
36
42
|
return true;
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -42,28 +48,32 @@ var __webpack_modules__ = {
|
|
|
42
48
|
return node && node.type === check;
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
|
-
function castFactory(
|
|
46
|
-
return
|
|
47
|
-
function
|
|
48
|
-
return Boolean(
|
|
51
|
+
function castFactory(testFunction) {
|
|
52
|
+
return check;
|
|
53
|
+
function check(value, index, parent) {
|
|
54
|
+
return Boolean(looksLikeANode(value) && testFunction.call(this, value, 'number' == typeof index ? index : void 0, parent || void 0));
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
function ok() {
|
|
52
58
|
return true;
|
|
53
59
|
}
|
|
60
|
+
function looksLikeANode(value) {
|
|
61
|
+
return null !== value && 'object' == typeof value && 'type' in value;
|
|
62
|
+
}
|
|
54
63
|
function color(d) {
|
|
55
64
|
return '\u001B[33m' + d + '\u001B[39m';
|
|
56
65
|
}
|
|
66
|
+
const empty = [];
|
|
57
67
|
const CONTINUE = true;
|
|
58
68
|
const EXIT = false;
|
|
59
69
|
const SKIP = 'skip';
|
|
60
|
-
|
|
70
|
+
function visitParents(tree, test, visitor, reverse) {
|
|
71
|
+
let check;
|
|
61
72
|
if ('function' == typeof test && 'function' != typeof visitor) {
|
|
62
73
|
reverse = visitor;
|
|
63
74
|
visitor = test;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const is = convert(test);
|
|
75
|
+
} else check = test;
|
|
76
|
+
const is = convert(check);
|
|
67
77
|
const step = reverse ? -1 : 1;
|
|
68
78
|
factory(tree, void 0, [])();
|
|
69
79
|
function factory(node, index, parents) {
|
|
@@ -76,49 +86,61 @@ var __webpack_modules__ = {
|
|
|
76
86
|
}
|
|
77
87
|
return visit;
|
|
78
88
|
function visit() {
|
|
79
|
-
let result =
|
|
89
|
+
let result = empty;
|
|
80
90
|
let subresult;
|
|
81
91
|
let offset;
|
|
82
92
|
let grandparents;
|
|
83
|
-
if (!test || is(node, index, parents[parents.length - 1] ||
|
|
93
|
+
if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
|
|
84
94
|
result = toResult(visitor(node, parents));
|
|
85
95
|
if (result[0] === EXIT) return result;
|
|
86
96
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
if ('children' in node && node.children) {
|
|
98
|
+
const nodeAsParent = node;
|
|
99
|
+
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
100
|
+
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
101
|
+
grandparents = parents.concat(nodeAsParent);
|
|
102
|
+
while(offset > -1 && offset < nodeAsParent.children.length){
|
|
103
|
+
const child = nodeAsParent.children[offset];
|
|
104
|
+
subresult = factory(child, offset, grandparents)();
|
|
105
|
+
if (subresult[0] === EXIT) return subresult;
|
|
106
|
+
offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
return result;
|
|
97
111
|
}
|
|
98
112
|
}
|
|
99
|
-
}
|
|
113
|
+
}
|
|
100
114
|
function toResult(value) {
|
|
101
115
|
if (Array.isArray(value)) return value;
|
|
102
116
|
if ('number' == typeof value) return [
|
|
103
117
|
CONTINUE,
|
|
104
118
|
value
|
|
105
119
|
];
|
|
106
|
-
return [
|
|
120
|
+
return null == value ? empty : [
|
|
107
121
|
value
|
|
108
122
|
];
|
|
109
123
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
125
|
+
let reverse;
|
|
126
|
+
let test;
|
|
127
|
+
let visitor;
|
|
128
|
+
if ('function' == typeof testOrVisitor && 'function' != typeof visitorOrReverse) {
|
|
129
|
+
test = void 0;
|
|
130
|
+
visitor = testOrVisitor;
|
|
131
|
+
reverse = visitorOrReverse;
|
|
132
|
+
} else {
|
|
133
|
+
test = testOrVisitor;
|
|
134
|
+
visitor = visitorOrReverse;
|
|
135
|
+
reverse = maybeReverse;
|
|
115
136
|
}
|
|
116
137
|
visitParents(tree, test, overload, reverse);
|
|
117
138
|
function overload(node, parents) {
|
|
118
139
|
const parent = parents[parents.length - 1];
|
|
119
|
-
|
|
140
|
+
const index = parent ? parent.children.indexOf(node) : void 0;
|
|
141
|
+
return visitor(node, index, parent);
|
|
120
142
|
}
|
|
121
|
-
}
|
|
143
|
+
}
|
|
122
144
|
}
|
|
123
145
|
};
|
|
124
146
|
var __webpack_module_cache__ = {};
|
|
@@ -191,7 +213,7 @@ var __webpack_exports__ = {};
|
|
|
191
213
|
__webpack_require__.r(__webpack_exports__);
|
|
192
214
|
__webpack_require__.d(__webpack_exports__, {
|
|
193
215
|
pluginPlayground: ()=>pluginPlayground,
|
|
194
|
-
routeMeta: ()=>
|
|
216
|
+
routeMeta: ()=>cli_routeMeta
|
|
195
217
|
});
|
|
196
218
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
197
219
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -205,7 +227,7 @@ var __webpack_exports__ = {};
|
|
|
205
227
|
return u.replace(/\/\//g, '/');
|
|
206
228
|
}
|
|
207
229
|
const staticPath = external_node_path_default().join(__dirname, '../../../static');
|
|
208
|
-
var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@
|
|
230
|
+
var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
|
|
209
231
|
const napi_namespaceObject = require("@oxidation-compiler/napi");
|
|
210
232
|
var napi_default = /*#__PURE__*/ __webpack_require__.n(napi_namespaceObject);
|
|
211
233
|
const parseImports = (code, sourceExt)=>{
|
|
@@ -277,8 +299,8 @@ var __webpack_exports__ = {};
|
|
|
277
299
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
278
300
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
279
301
|
var _node_meta, _node_meta1;
|
|
280
|
-
const hasPureMeta = null
|
|
281
|
-
const hasPlaygroundMeta = null
|
|
302
|
+
const hasPureMeta = null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure');
|
|
303
|
+
const hasPlaygroundMeta = null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('playground');
|
|
282
304
|
let noTransform;
|
|
283
305
|
switch(defaultRenderMode){
|
|
284
306
|
case 'pure':
|
|
@@ -314,15 +336,15 @@ var __webpack_exports__ = {};
|
|
|
314
336
|
});
|
|
315
337
|
};
|
|
316
338
|
};
|
|
317
|
-
let
|
|
339
|
+
let cli_routeMeta;
|
|
318
340
|
function pluginPlayground(options) {
|
|
319
341
|
var _monacoLoader_paths;
|
|
320
342
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
321
343
|
const playgroundVirtualModule = new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({});
|
|
322
|
-
const getRouteMeta = ()=>
|
|
344
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
323
345
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
324
346
|
const preloads = [];
|
|
325
|
-
const monacoPrefix = (null
|
|
347
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
326
348
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
327
349
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
328
350
|
return {
|
|
@@ -334,14 +356,14 @@ var __webpack_exports__ = {};
|
|
|
334
356
|
return config;
|
|
335
357
|
},
|
|
336
358
|
async routeGenerated (routes) {
|
|
337
|
-
|
|
359
|
+
cli_routeMeta = routes;
|
|
338
360
|
const files = routes.map((route)=>route.absolutePath);
|
|
339
361
|
const imports = {};
|
|
340
362
|
await Promise.all(files.map(async (filepath, _index)=>{
|
|
341
363
|
const isMdxFile = /\.mdx?$/.test(filepath);
|
|
342
364
|
if (!isMdxFile) return;
|
|
343
365
|
const { createProcessor } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@mdx-js/mdx"));
|
|
344
|
-
const { visit } = await __webpack_require__.e("
|
|
366
|
+
const { visit } = await __webpack_require__.e("52").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js"));
|
|
345
367
|
const { default: remarkGFM } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "remark-gfm"));
|
|
346
368
|
try {
|
|
347
369
|
const processor = createProcessor({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
'
|
|
2
|
+
'52'
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
|
-
"../../node_modules/.pnpm/unist-util-visit@
|
|
5
|
+
"../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
6
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
7
7
|
visit: ()=>_lib_index_js__WEBPACK_IMPORTED_MODULE_0__.Vn
|
|
8
8
|
});
|
|
9
|
-
var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@
|
|
9
|
+
var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
|
|
10
10
|
}
|
|
11
11
|
};
|
package/dist/cli/esm/index.mjs
CHANGED
|
@@ -6,15 +6,15 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from
|
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__oxidation_compiler_napi_5e24345a__ from "@oxidation-compiler/napi";
|
|
8
8
|
var __webpack_modules__ = {
|
|
9
|
-
"../../node_modules/.pnpm/unist-util-visit@
|
|
9
|
+
"../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
10
10
|
__webpack_require__.d(__webpack_exports__, {
|
|
11
11
|
Vn: ()=>lib_visit
|
|
12
12
|
});
|
|
13
13
|
const convert = function(test) {
|
|
14
14
|
if (null == test) return ok;
|
|
15
|
-
if ('string' == typeof test) return typeFactory(test);
|
|
16
|
-
if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
17
15
|
if ('function' == typeof test) return castFactory(test);
|
|
16
|
+
if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
|
|
17
|
+
if ('string' == typeof test) return typeFactory(test);
|
|
18
18
|
throw new Error('Expected function, string, or object as test');
|
|
19
19
|
};
|
|
20
20
|
function anyFactory(tests) {
|
|
@@ -24,15 +24,17 @@ var __webpack_modules__ = {
|
|
|
24
24
|
return castFactory(any);
|
|
25
25
|
function any(...parameters) {
|
|
26
26
|
let index = -1;
|
|
27
|
-
while(++index < checks.length)if (checks[index].
|
|
27
|
+
while(++index < checks.length)if (checks[index].apply(this, parameters)) return true;
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
function propsFactory(check) {
|
|
32
|
+
const checkAsRecord = check;
|
|
32
33
|
return castFactory(all);
|
|
33
34
|
function all(node) {
|
|
35
|
+
const nodeAsRecord = node;
|
|
34
36
|
let key;
|
|
35
|
-
for(key in check)if (
|
|
37
|
+
for(key in check)if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
|
|
36
38
|
return true;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -42,28 +44,32 @@ var __webpack_modules__ = {
|
|
|
42
44
|
return node && node.type === check;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
|
-
function castFactory(
|
|
46
|
-
return
|
|
47
|
-
function
|
|
48
|
-
return Boolean(
|
|
47
|
+
function castFactory(testFunction) {
|
|
48
|
+
return check;
|
|
49
|
+
function check(value, index, parent) {
|
|
50
|
+
return Boolean(looksLikeANode(value) && testFunction.call(this, value, 'number' == typeof index ? index : void 0, parent || void 0));
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
function ok() {
|
|
52
54
|
return true;
|
|
53
55
|
}
|
|
56
|
+
function looksLikeANode(value) {
|
|
57
|
+
return null !== value && 'object' == typeof value && 'type' in value;
|
|
58
|
+
}
|
|
54
59
|
function color(d) {
|
|
55
60
|
return '\u001B[33m' + d + '\u001B[39m';
|
|
56
61
|
}
|
|
62
|
+
const empty = [];
|
|
57
63
|
const CONTINUE = true;
|
|
58
64
|
const EXIT = false;
|
|
59
65
|
const SKIP = 'skip';
|
|
60
|
-
|
|
66
|
+
function visitParents(tree, test, visitor, reverse) {
|
|
67
|
+
let check;
|
|
61
68
|
if ('function' == typeof test && 'function' != typeof visitor) {
|
|
62
69
|
reverse = visitor;
|
|
63
70
|
visitor = test;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const is = convert(test);
|
|
71
|
+
} else check = test;
|
|
72
|
+
const is = convert(check);
|
|
67
73
|
const step = reverse ? -1 : 1;
|
|
68
74
|
factory(tree, void 0, [])();
|
|
69
75
|
function factory(node, index, parents) {
|
|
@@ -76,49 +82,61 @@ var __webpack_modules__ = {
|
|
|
76
82
|
}
|
|
77
83
|
return visit;
|
|
78
84
|
function visit() {
|
|
79
|
-
let result =
|
|
85
|
+
let result = empty;
|
|
80
86
|
let subresult;
|
|
81
87
|
let offset;
|
|
82
88
|
let grandparents;
|
|
83
|
-
if (!test || is(node, index, parents[parents.length - 1] ||
|
|
89
|
+
if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
|
|
84
90
|
result = toResult(visitor(node, parents));
|
|
85
91
|
if (result[0] === EXIT) return result;
|
|
86
92
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
if ('children' in node && node.children) {
|
|
94
|
+
const nodeAsParent = node;
|
|
95
|
+
if (nodeAsParent.children && result[0] !== SKIP) {
|
|
96
|
+
offset = (reverse ? nodeAsParent.children.length : -1) + step;
|
|
97
|
+
grandparents = parents.concat(nodeAsParent);
|
|
98
|
+
while(offset > -1 && offset < nodeAsParent.children.length){
|
|
99
|
+
const child = nodeAsParent.children[offset];
|
|
100
|
+
subresult = factory(child, offset, grandparents)();
|
|
101
|
+
if (subresult[0] === EXIT) return subresult;
|
|
102
|
+
offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
|
|
103
|
+
}
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
return result;
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
|
-
}
|
|
109
|
+
}
|
|
100
110
|
function toResult(value) {
|
|
101
111
|
if (Array.isArray(value)) return value;
|
|
102
112
|
if ('number' == typeof value) return [
|
|
103
113
|
CONTINUE,
|
|
104
114
|
value
|
|
105
115
|
];
|
|
106
|
-
return [
|
|
116
|
+
return null == value ? empty : [
|
|
107
117
|
value
|
|
108
118
|
];
|
|
109
119
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
121
|
+
let reverse;
|
|
122
|
+
let test;
|
|
123
|
+
let visitor;
|
|
124
|
+
if ('function' == typeof testOrVisitor && 'function' != typeof visitorOrReverse) {
|
|
125
|
+
test = void 0;
|
|
126
|
+
visitor = testOrVisitor;
|
|
127
|
+
reverse = visitorOrReverse;
|
|
128
|
+
} else {
|
|
129
|
+
test = testOrVisitor;
|
|
130
|
+
visitor = visitorOrReverse;
|
|
131
|
+
reverse = maybeReverse;
|
|
115
132
|
}
|
|
116
133
|
visitParents(tree, test, overload, reverse);
|
|
117
134
|
function overload(node, parents) {
|
|
118
135
|
const parent = parents[parents.length - 1];
|
|
119
|
-
|
|
136
|
+
const index = parent ? parent.children.indexOf(node) : void 0;
|
|
137
|
+
return visitor(node, index, parent);
|
|
120
138
|
}
|
|
121
|
-
}
|
|
139
|
+
}
|
|
122
140
|
}
|
|
123
141
|
};
|
|
124
142
|
var __webpack_module_cache__ = {};
|
|
@@ -197,7 +215,7 @@ function normalizeUrl(u) {
|
|
|
197
215
|
}
|
|
198
216
|
var constant_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
199
217
|
const staticPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(constant_dirname, '../../../static');
|
|
200
|
-
var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@
|
|
218
|
+
var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
|
|
201
219
|
const parseImports = (code, sourceExt)=>{
|
|
202
220
|
const parsed = __WEBPACK_EXTERNAL_MODULE__oxidation_compiler_napi_5e24345a__["default"].parseSync(code, {
|
|
203
221
|
sourceType: 'module',
|
|
@@ -267,8 +285,8 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
267
285
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
268
286
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
269
287
|
var _node_meta, _node_meta1;
|
|
270
|
-
const hasPureMeta = null
|
|
271
|
-
const hasPlaygroundMeta = null
|
|
288
|
+
const hasPureMeta = null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure');
|
|
289
|
+
const hasPlaygroundMeta = null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('playground');
|
|
272
290
|
let noTransform;
|
|
273
291
|
switch(defaultRenderMode){
|
|
274
292
|
case 'pure':
|
|
@@ -304,16 +322,16 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
304
322
|
});
|
|
305
323
|
};
|
|
306
324
|
};
|
|
307
|
-
var
|
|
308
|
-
let
|
|
325
|
+
var cli_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
326
|
+
let cli_routeMeta;
|
|
309
327
|
function pluginPlayground(options) {
|
|
310
328
|
var _monacoLoader_paths;
|
|
311
329
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
312
330
|
const playgroundVirtualModule = new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin({});
|
|
313
|
-
const getRouteMeta = ()=>
|
|
331
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
314
332
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
315
333
|
const preloads = [];
|
|
316
|
-
const monacoPrefix = (null
|
|
334
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
317
335
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
318
336
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
319
337
|
return {
|
|
@@ -325,14 +343,14 @@ function pluginPlayground(options) {
|
|
|
325
343
|
return config;
|
|
326
344
|
},
|
|
327
345
|
async routeGenerated (routes) {
|
|
328
|
-
|
|
346
|
+
cli_routeMeta = routes;
|
|
329
347
|
const files = routes.map((route)=>route.absolutePath);
|
|
330
348
|
const imports = {};
|
|
331
349
|
await Promise.all(files.map(async (filepath, _index)=>{
|
|
332
350
|
const isMdxFile = /\.mdx?$/.test(filepath);
|
|
333
351
|
if (!isMdxFile) return;
|
|
334
352
|
const { createProcessor } = await import("@mdx-js/mdx");
|
|
335
|
-
const { visit } = await __webpack_require__.e("
|
|
353
|
+
const { visit } = await __webpack_require__.e("52").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js"));
|
|
336
354
|
const { default: remarkGFM } = await import("remark-gfm");
|
|
337
355
|
try {
|
|
338
356
|
const processor = createProcessor({
|
|
@@ -420,7 +438,7 @@ function pluginPlayground(options) {
|
|
|
420
438
|
__PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl)
|
|
421
439
|
},
|
|
422
440
|
include: [
|
|
423
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(
|
|
441
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cli_dirname, '..', '..', '..')
|
|
424
442
|
]
|
|
425
443
|
},
|
|
426
444
|
html: {
|
|
@@ -460,4 +478,4 @@ function pluginPlayground(options) {
|
|
|
460
478
|
globalStyles: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(staticPath, 'global-styles', 'web.css')
|
|
461
479
|
};
|
|
462
480
|
}
|
|
463
|
-
export { pluginPlayground,
|
|
481
|
+
export { pluginPlayground, cli_routeMeta as routeMeta };
|
package/dist/web/cjs/index.js
CHANGED
|
@@ -266,13 +266,10 @@ class Runner extends external_react_namespaceObject.Component {
|
|
|
266
266
|
const runExports = {};
|
|
267
267
|
const func = new Function('__get_import', 'exports', result.code);
|
|
268
268
|
func(getImport, runExports);
|
|
269
|
-
if (runExports.default) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
});
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
269
|
+
if (runExports.default) return void this.setState({
|
|
270
|
+
error: void 0,
|
|
271
|
+
comp: /*#__PURE__*/ external_react_default().createElement(runExports.default)
|
|
272
|
+
});
|
|
276
273
|
this.setState({
|
|
277
274
|
error: new Error('No default export')
|
|
278
275
|
});
|
package/dist/web/esm/index.mjs
CHANGED
|
@@ -226,13 +226,10 @@ class Runner extends __WEBPACK_EXTERNAL_MODULE_react__.Component {
|
|
|
226
226
|
const runExports = {};
|
|
227
227
|
const func = new Function('__get_import', 'exports', result.code);
|
|
228
228
|
func(getImport, runExports);
|
|
229
|
-
if (runExports.default) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
229
|
+
if (runExports.default) return void this.setState({
|
|
230
|
+
error: void 0,
|
|
231
|
+
comp: /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(runExports.default)
|
|
232
|
+
});
|
|
236
233
|
this.setState({
|
|
237
234
|
error: new Error('No default export')
|
|
238
235
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-playground",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
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": {
|
|
@@ -29,34 +29,34 @@
|
|
|
29
29
|
"static"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mdx-js/mdx": "
|
|
32
|
+
"@mdx-js/mdx": "^3.1.0",
|
|
33
33
|
"@monaco-editor/react": "~4.7.0",
|
|
34
34
|
"@oxidation-compiler/napi": "^0.2.0",
|
|
35
|
-
"remark-gfm": "
|
|
35
|
+
"remark-gfm": "^4.0.1",
|
|
36
36
|
"rspack-plugin-virtual-module": "0.1.13",
|
|
37
|
-
"@rspress/shared": "2.0.0-
|
|
37
|
+
"@rspress/shared": "2.0.0-beta.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/types": "^7.27.0",
|
|
41
41
|
"@rsbuild/plugin-react": "~1.1.1",
|
|
42
|
-
"@rslib/core": "0.6.
|
|
42
|
+
"@rslib/core": "0.6.5",
|
|
43
43
|
"@types/babel__core": "^7.20.5",
|
|
44
44
|
"@types/babel__standalone": "^7.1.9",
|
|
45
45
|
"@types/babel__traverse": "^7.20.7",
|
|
46
|
-
"@types/mdast": "^
|
|
46
|
+
"@types/mdast": "^4.0.4",
|
|
47
47
|
"@types/node": "^18.11.17",
|
|
48
48
|
"@types/react": "^18.3.20",
|
|
49
|
-
"@types/react-dom": "^18.3.
|
|
50
|
-
"mdast-util-mdx-jsx": "^2.
|
|
51
|
-
"react": "^
|
|
52
|
-
"react-dom": "^
|
|
49
|
+
"@types/react-dom": "^18.3.6",
|
|
50
|
+
"mdast-util-mdx-jsx": "^3.2.0",
|
|
51
|
+
"react": "^19.1.0",
|
|
52
|
+
"react-dom": "^19.1.0",
|
|
53
53
|
"react-router-dom": "^6.29.0",
|
|
54
54
|
"typescript": "^5.8.2",
|
|
55
|
-
"unified": "^
|
|
56
|
-
"unist-util-visit": "^
|
|
55
|
+
"unified": "^11.0.5",
|
|
56
|
+
"unist-util-visit": "^5.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@rspress/core": "^2.0.0-
|
|
59
|
+
"@rspress/core": "^2.0.0-beta.0",
|
|
60
60
|
"react": ">=17.0.0",
|
|
61
61
|
"react-router-dom": "^6.8.1"
|
|
62
62
|
},
|