@rspress/plugin-playground 2.0.0-alpha.9 → 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/index.js +13 -9
- package/dist/cli/esm/index.mjs +9 -9
- package/dist/web/cjs/index.js +4 -7
- package/dist/web/esm/index.mjs +4 -7
- package/package.json +6 -6
package/dist/cli/cjs/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
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
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__, {
|
|
@@ -209,7 +213,7 @@ var __webpack_exports__ = {};
|
|
|
209
213
|
__webpack_require__.r(__webpack_exports__);
|
|
210
214
|
__webpack_require__.d(__webpack_exports__, {
|
|
211
215
|
pluginPlayground: ()=>pluginPlayground,
|
|
212
|
-
routeMeta: ()=>
|
|
216
|
+
routeMeta: ()=>cli_routeMeta
|
|
213
217
|
});
|
|
214
218
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
215
219
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -295,8 +299,8 @@ var __webpack_exports__ = {};
|
|
|
295
299
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
296
300
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
297
301
|
var _node_meta, _node_meta1;
|
|
298
|
-
const hasPureMeta = null
|
|
299
|
-
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');
|
|
300
304
|
let noTransform;
|
|
301
305
|
switch(defaultRenderMode){
|
|
302
306
|
case 'pure':
|
|
@@ -332,15 +336,15 @@ var __webpack_exports__ = {};
|
|
|
332
336
|
});
|
|
333
337
|
};
|
|
334
338
|
};
|
|
335
|
-
let
|
|
339
|
+
let cli_routeMeta;
|
|
336
340
|
function pluginPlayground(options) {
|
|
337
341
|
var _monacoLoader_paths;
|
|
338
342
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
339
343
|
const playgroundVirtualModule = new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({});
|
|
340
|
-
const getRouteMeta = ()=>
|
|
344
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
341
345
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
342
346
|
const preloads = [];
|
|
343
|
-
const monacoPrefix = (null
|
|
347
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
344
348
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
345
349
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
346
350
|
return {
|
|
@@ -352,7 +356,7 @@ var __webpack_exports__ = {};
|
|
|
352
356
|
return config;
|
|
353
357
|
},
|
|
354
358
|
async routeGenerated (routes) {
|
|
355
|
-
|
|
359
|
+
cli_routeMeta = routes;
|
|
356
360
|
const files = routes.map((route)=>route.absolutePath);
|
|
357
361
|
const imports = {};
|
|
358
362
|
await Promise.all(files.map(async (filepath, _index)=>{
|
package/dist/cli/esm/index.mjs
CHANGED
|
@@ -285,8 +285,8 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
285
285
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
286
286
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
287
287
|
var _node_meta, _node_meta1;
|
|
288
|
-
const hasPureMeta = null
|
|
289
|
-
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');
|
|
290
290
|
let noTransform;
|
|
291
291
|
switch(defaultRenderMode){
|
|
292
292
|
case 'pure':
|
|
@@ -322,16 +322,16 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
322
322
|
});
|
|
323
323
|
};
|
|
324
324
|
};
|
|
325
|
-
var
|
|
326
|
-
let
|
|
325
|
+
var cli_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
326
|
+
let cli_routeMeta;
|
|
327
327
|
function pluginPlayground(options) {
|
|
328
328
|
var _monacoLoader_paths;
|
|
329
329
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
330
330
|
const playgroundVirtualModule = new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin({});
|
|
331
|
-
const getRouteMeta = ()=>
|
|
331
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
332
332
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
333
333
|
const preloads = [];
|
|
334
|
-
const monacoPrefix = (null
|
|
334
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
335
335
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
336
336
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
337
337
|
return {
|
|
@@ -343,7 +343,7 @@ function pluginPlayground(options) {
|
|
|
343
343
|
return config;
|
|
344
344
|
},
|
|
345
345
|
async routeGenerated (routes) {
|
|
346
|
-
|
|
346
|
+
cli_routeMeta = routes;
|
|
347
347
|
const files = routes.map((route)=>route.absolutePath);
|
|
348
348
|
const imports = {};
|
|
349
349
|
await Promise.all(files.map(async (filepath, _index)=>{
|
|
@@ -438,7 +438,7 @@ function pluginPlayground(options) {
|
|
|
438
438
|
__PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl)
|
|
439
439
|
},
|
|
440
440
|
include: [
|
|
441
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(
|
|
441
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cli_dirname, '..', '..', '..')
|
|
442
442
|
]
|
|
443
443
|
},
|
|
444
444
|
html: {
|
|
@@ -478,4 +478,4 @@ function pluginPlayground(options) {
|
|
|
478
478
|
globalStyles: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(staticPath, 'global-styles', 'web.css')
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
|
-
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": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"@oxidation-compiler/napi": "^0.2.0",
|
|
35
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",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"@types/react": "^18.3.20",
|
|
49
49
|
"@types/react-dom": "^18.3.6",
|
|
50
50
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
51
|
-
"react": "^
|
|
52
|
-
"react-dom": "^
|
|
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
55
|
"unified": "^11.0.5",
|
|
56
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
|
},
|