@rspress/plugin-playground 2.0.0-alpha.10 → 2.0.0-alpha.12

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.
@@ -209,7 +209,7 @@ var __webpack_exports__ = {};
209
209
  __webpack_require__.r(__webpack_exports__);
210
210
  __webpack_require__.d(__webpack_exports__, {
211
211
  pluginPlayground: ()=>pluginPlayground,
212
- routeMeta: ()=>cli_rslib_entry_routeMeta
212
+ routeMeta: ()=>cli_routeMeta
213
213
  });
214
214
  const external_node_fs_namespaceObject = require("node:fs");
215
215
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -295,8 +295,8 @@ var __webpack_exports__ = {};
295
295
  (0, lib.Vn)(tree, 'code', (node)=>{
296
296
  if ('jsx' === node.lang || 'tsx' === node.lang) {
297
297
  var _node_meta, _node_meta1;
298
- const hasPureMeta = null === (_node_meta = node.meta) || void 0 === _node_meta ? void 0 : _node_meta.includes('pure');
299
- const hasPlaygroundMeta = null === (_node_meta1 = node.meta) || void 0 === _node_meta1 ? void 0 : _node_meta1.includes('playground');
298
+ const hasPureMeta = null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure');
299
+ const hasPlaygroundMeta = null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('playground');
300
300
  let noTransform;
301
301
  switch(defaultRenderMode){
302
302
  case 'pure':
@@ -332,15 +332,15 @@ var __webpack_exports__ = {};
332
332
  });
333
333
  };
334
334
  };
335
- let cli_rslib_entry_routeMeta;
335
+ let cli_routeMeta;
336
336
  function pluginPlayground(options) {
337
337
  var _monacoLoader_paths;
338
338
  const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
339
339
  const playgroundVirtualModule = new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({});
340
- const getRouteMeta = ()=>cli_rslib_entry_routeMeta;
340
+ const getRouteMeta = ()=>cli_routeMeta;
341
341
  if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
342
342
  const preloads = [];
343
- const monacoPrefix = (null === (_monacoLoader_paths = monacoLoader.paths) || void 0 === _monacoLoader_paths ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
343
+ const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
344
344
  preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
345
345
  preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
346
346
  return {
@@ -352,7 +352,7 @@ var __webpack_exports__ = {};
352
352
  return config;
353
353
  },
354
354
  async routeGenerated (routes) {
355
- cli_rslib_entry_routeMeta = routes;
355
+ cli_routeMeta = routes;
356
356
  const files = routes.map((route)=>route.absolutePath);
357
357
  const imports = {};
358
358
  await Promise.all(files.map(async (filepath, _index)=>{
@@ -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 === (_node_meta = node.meta) || void 0 === _node_meta ? void 0 : _node_meta.includes('pure');
289
- const hasPlaygroundMeta = null === (_node_meta1 = node.meta) || void 0 === _node_meta1 ? void 0 : _node_meta1.includes('playground');
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 cli_rslib_entry_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
326
- let cli_rslib_entry_routeMeta;
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 = ()=>cli_rslib_entry_routeMeta;
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 === (_monacoLoader_paths = monacoLoader.paths) || void 0 === _monacoLoader_paths ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
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
- cli_rslib_entry_routeMeta = routes;
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)(cli_rslib_entry_dirname, '..', '..', '..')
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, cli_rslib_entry_routeMeta as routeMeta };
481
+ export { pluginPlayground, cli_routeMeta as routeMeta };
@@ -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
- this.setState({
271
- error: void 0,
272
- comp: /*#__PURE__*/ external_react_default().createElement(runExports.default)
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
  });
@@ -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
- this.setState({
231
- error: void 0,
232
- comp: /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(runExports.default)
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-alpha.10",
3
+ "version": "2.0.0-alpha.12",
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-alpha.10"
37
+ "@rspress/shared": "2.0.0-alpha.12"
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.1",
42
+ "@rslib/core": "0.6.3",
43
43
  "@types/babel__core": "^7.20.5",
44
44
  "@types/babel__standalone": "^7.1.9",
45
45
  "@types/babel__traverse": "^7.20.7",
@@ -56,7 +56,7 @@
56
56
  "unist-util-visit": "^5.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@rspress/core": "^2.0.0-alpha.10",
59
+ "@rspress/core": "^2.0.0-alpha.12",
60
60
  "react": ">=17.0.0",
61
61
  "react-router-dom": "^6.8.1"
62
62
  },