@rspress/plugin-playground 1.43.13 → 1.45.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 +1 -1
- package/dist/cli/cjs/index.js +29 -31
- package/dist/cli/esm/301.mjs +3 -3
- package/dist/cli/esm/index.mjs +37 -45
- package/dist/web/cjs/index.js +26 -29
- package/dist/web/esm/index.mjs +9 -14
- package/package.json +8 -7
- package/static/global-components/Playground.tsx +7 -0
package/dist/cli/cjs/301.js
CHANGED
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@4.1.2/node_modules/unist-util-visit/lib/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
10
14
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -133,12 +137,8 @@ function __webpack_require__(moduleId) {
|
|
|
133
137
|
}
|
|
134
138
|
__webpack_require__.m = __webpack_modules__;
|
|
135
139
|
(()=>{
|
|
136
|
-
__webpack_require__.n =
|
|
137
|
-
var getter = module && module.__esModule ?
|
|
138
|
-
return module['default'];
|
|
139
|
-
} : function() {
|
|
140
|
-
return module;
|
|
141
|
-
};
|
|
140
|
+
__webpack_require__.n = (module)=>{
|
|
141
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
142
142
|
__webpack_require__.d(getter, {
|
|
143
143
|
a: getter
|
|
144
144
|
});
|
|
@@ -146,7 +146,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
146
146
|
};
|
|
147
147
|
})();
|
|
148
148
|
(()=>{
|
|
149
|
-
__webpack_require__.d =
|
|
149
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
150
150
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
151
151
|
enumerable: true,
|
|
152
152
|
get: definition[key]
|
|
@@ -155,25 +155,19 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
155
155
|
})();
|
|
156
156
|
(()=>{
|
|
157
157
|
__webpack_require__.f = {};
|
|
158
|
-
__webpack_require__.e =
|
|
159
|
-
return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
|
|
158
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
160
159
|
__webpack_require__.f[key](chunkId, promises);
|
|
161
160
|
return promises;
|
|
162
161
|
}, []));
|
|
163
|
-
};
|
|
164
162
|
})();
|
|
165
163
|
(()=>{
|
|
166
|
-
__webpack_require__.u =
|
|
167
|
-
return "" + chunkId + ".js";
|
|
168
|
-
};
|
|
164
|
+
__webpack_require__.u = (chunkId)=>"" + chunkId + ".js";
|
|
169
165
|
})();
|
|
170
166
|
(()=>{
|
|
171
|
-
__webpack_require__.o =
|
|
172
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
173
|
-
};
|
|
167
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
174
168
|
})();
|
|
175
169
|
(()=>{
|
|
176
|
-
__webpack_require__.r =
|
|
170
|
+
__webpack_require__.r = (exports1)=>{
|
|
177
171
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
178
172
|
value: 'Module'
|
|
179
173
|
});
|
|
@@ -186,13 +180,13 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
186
180
|
var installedChunks = {
|
|
187
181
|
980: 1
|
|
188
182
|
};
|
|
189
|
-
var installChunk =
|
|
183
|
+
var installChunk = (chunk)=>{
|
|
190
184
|
var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
|
|
191
185
|
for(var moduleId in moreModules)if (__webpack_require__.o(moreModules, moduleId)) __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
192
186
|
if (runtime) runtime(__webpack_require__);
|
|
193
187
|
for(var i = 0; i < chunkIds.length; i++)installedChunks[chunkIds[i]] = 1;
|
|
194
188
|
};
|
|
195
|
-
__webpack_require__.f.require =
|
|
189
|
+
__webpack_require__.f.require = (chunkId, promises)=>{
|
|
196
190
|
if (!installedChunks[chunkId]) installChunk(require("./" + __webpack_require__.u(chunkId)));
|
|
197
191
|
};
|
|
198
192
|
})();
|
|
@@ -201,7 +195,7 @@ var __webpack_exports__ = {};
|
|
|
201
195
|
__webpack_require__.r(__webpack_exports__);
|
|
202
196
|
__webpack_require__.d(__webpack_exports__, {
|
|
203
197
|
pluginPlayground: ()=>pluginPlayground,
|
|
204
|
-
routeMeta: ()=>
|
|
198
|
+
routeMeta: ()=>cli_routeMeta
|
|
205
199
|
});
|
|
206
200
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
207
201
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -287,8 +281,8 @@ var __webpack_exports__ = {};
|
|
|
287
281
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
288
282
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
289
283
|
var _node_meta, _node_meta1;
|
|
290
|
-
const hasPureMeta = null
|
|
291
|
-
const hasPlaygroundMeta = null
|
|
284
|
+
const hasPureMeta = null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure');
|
|
285
|
+
const hasPlaygroundMeta = null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('playground');
|
|
292
286
|
let noTransform;
|
|
293
287
|
switch(defaultRenderMode){
|
|
294
288
|
case 'pure':
|
|
@@ -324,15 +318,15 @@ var __webpack_exports__ = {};
|
|
|
324
318
|
});
|
|
325
319
|
};
|
|
326
320
|
};
|
|
327
|
-
let
|
|
321
|
+
let cli_routeMeta;
|
|
328
322
|
function pluginPlayground(options) {
|
|
329
323
|
var _monacoLoader_paths;
|
|
330
324
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
331
325
|
const playgroundVirtualModule = new external_rspack_plugin_virtual_module_namespaceObject.RspackVirtualModulePlugin({});
|
|
332
|
-
const getRouteMeta = ()=>
|
|
326
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
333
327
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
334
328
|
const preloads = [];
|
|
335
|
-
const monacoPrefix = (null
|
|
329
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
336
330
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
337
331
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
338
332
|
return {
|
|
@@ -344,7 +338,7 @@ var __webpack_exports__ = {};
|
|
|
344
338
|
return config;
|
|
345
339
|
},
|
|
346
340
|
async routeGenerated (routes) {
|
|
347
|
-
|
|
341
|
+
cli_routeMeta = routes;
|
|
348
342
|
const files = routes.map((route)=>route.absolutePath);
|
|
349
343
|
const imports = {};
|
|
350
344
|
await Promise.all(files.map(async (filepath, _index)=>{
|
|
@@ -480,8 +474,12 @@ var __webpack_exports__ = {};
|
|
|
480
474
|
};
|
|
481
475
|
}
|
|
482
476
|
})();
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
477
|
+
exports.pluginPlayground = __webpack_exports__.pluginPlayground;
|
|
478
|
+
exports.routeMeta = __webpack_exports__.routeMeta;
|
|
479
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
480
|
+
"pluginPlayground",
|
|
481
|
+
"routeMeta"
|
|
482
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
483
|
+
Object.defineProperty(exports, '__esModule', {
|
|
486
484
|
value: true
|
|
487
485
|
});
|
package/dist/cli/esm/301.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
1
|
+
export const __webpack_ids__ = [
|
|
2
|
+
"301"
|
|
3
3
|
];
|
|
4
|
-
export const
|
|
4
|
+
export const __webpack_modules__ = {
|
|
5
5
|
"../../node_modules/.pnpm/unist-util-visit@4.1.2/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
|
package/dist/cli/esm/index.mjs
CHANGED
|
@@ -133,7 +133,7 @@ function __webpack_require__(moduleId) {
|
|
|
133
133
|
}
|
|
134
134
|
__webpack_require__.m = __webpack_modules__;
|
|
135
135
|
(()=>{
|
|
136
|
-
__webpack_require__.d =
|
|
136
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
137
137
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
138
138
|
enumerable: true,
|
|
139
139
|
get: definition[key]
|
|
@@ -142,59 +142,51 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
142
142
|
})();
|
|
143
143
|
(()=>{
|
|
144
144
|
__webpack_require__.f = {};
|
|
145
|
-
__webpack_require__.e =
|
|
146
|
-
return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
|
|
145
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
147
146
|
__webpack_require__.f[key](chunkId, promises);
|
|
148
147
|
return promises;
|
|
149
148
|
}, []));
|
|
150
|
-
};
|
|
151
149
|
})();
|
|
152
150
|
(()=>{
|
|
153
|
-
__webpack_require__.u =
|
|
154
|
-
return "" + chunkId + ".mjs";
|
|
155
|
-
};
|
|
151
|
+
__webpack_require__.u = (chunkId)=>"" + chunkId + ".mjs";
|
|
156
152
|
})();
|
|
157
153
|
(()=>{
|
|
158
|
-
__webpack_require__.o =
|
|
159
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
160
|
-
};
|
|
154
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
161
155
|
})();
|
|
162
156
|
(()=>{
|
|
163
157
|
var installedChunks = {
|
|
164
158
|
980: 0
|
|
165
159
|
};
|
|
166
|
-
var installChunk =
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
var
|
|
160
|
+
var installChunk = (data)=>{
|
|
161
|
+
var __webpack_ids__ = data.__webpack_ids__;
|
|
162
|
+
var __webpack_modules__ = data.__webpack_modules__;
|
|
163
|
+
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
170
164
|
var moduleId, chunkId, i = 0;
|
|
171
|
-
for(moduleId in
|
|
172
|
-
if (
|
|
173
|
-
for(; i <
|
|
174
|
-
chunkId =
|
|
165
|
+
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
166
|
+
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
167
|
+
for(; i < __webpack_ids__.length; i++){
|
|
168
|
+
chunkId = __webpack_ids__[i];
|
|
175
169
|
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
176
|
-
installedChunks[
|
|
170
|
+
installedChunks[__webpack_ids__[i]] = 0;
|
|
177
171
|
}
|
|
178
172
|
};
|
|
179
173
|
__webpack_require__.f.j = function(chunkId, promises) {
|
|
180
174
|
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
181
|
-
if (0 !== installedChunkData)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
promises.push(installedChunkData[1] = promise);
|
|
197
|
-
}
|
|
175
|
+
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
176
|
+
else {
|
|
177
|
+
var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
178
|
+
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
179
|
+
throw e;
|
|
180
|
+
});
|
|
181
|
+
var promise = Promise.race([
|
|
182
|
+
promise,
|
|
183
|
+
new Promise((resolve)=>{
|
|
184
|
+
installedChunkData = installedChunks[chunkId] = [
|
|
185
|
+
resolve
|
|
186
|
+
];
|
|
187
|
+
})
|
|
188
|
+
]);
|
|
189
|
+
promises.push(installedChunkData[1] = promise);
|
|
198
190
|
}
|
|
199
191
|
};
|
|
200
192
|
})();
|
|
@@ -275,8 +267,8 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
275
267
|
(0, lib.Vn)(tree, 'code', (node)=>{
|
|
276
268
|
if ('jsx' === node.lang || 'tsx' === node.lang) {
|
|
277
269
|
var _node_meta, _node_meta1;
|
|
278
|
-
const hasPureMeta = null
|
|
279
|
-
const hasPlaygroundMeta = null
|
|
270
|
+
const hasPureMeta = null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure');
|
|
271
|
+
const hasPlaygroundMeta = null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('playground');
|
|
280
272
|
let noTransform;
|
|
281
273
|
switch(defaultRenderMode){
|
|
282
274
|
case 'pure':
|
|
@@ -312,16 +304,16 @@ const remarkPlugin = ({ getRouteMeta, editorPosition, defaultRenderMode })=>{
|
|
|
312
304
|
});
|
|
313
305
|
};
|
|
314
306
|
};
|
|
315
|
-
var
|
|
316
|
-
let
|
|
307
|
+
var cli_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
308
|
+
let cli_routeMeta;
|
|
317
309
|
function pluginPlayground(options) {
|
|
318
310
|
var _monacoLoader_paths;
|
|
319
311
|
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'playground' } = options || {};
|
|
320
312
|
const playgroundVirtualModule = new __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__.RspackVirtualModulePlugin({});
|
|
321
|
-
const getRouteMeta = ()=>
|
|
313
|
+
const getRouteMeta = ()=>cli_routeMeta;
|
|
322
314
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
323
315
|
const preloads = [];
|
|
324
|
-
const monacoPrefix = (null
|
|
316
|
+
const monacoPrefix = (null == (_monacoLoader_paths = monacoLoader.paths) ? void 0 : _monacoLoader_paths.vs) || DEFAULT_MONACO_URL;
|
|
325
317
|
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
326
318
|
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
327
319
|
return {
|
|
@@ -333,7 +325,7 @@ function pluginPlayground(options) {
|
|
|
333
325
|
return config;
|
|
334
326
|
},
|
|
335
327
|
async routeGenerated (routes) {
|
|
336
|
-
|
|
328
|
+
cli_routeMeta = routes;
|
|
337
329
|
const files = routes.map((route)=>route.absolutePath);
|
|
338
330
|
const imports = {};
|
|
339
331
|
await Promise.all(files.map(async (filepath, _index)=>{
|
|
@@ -428,7 +420,7 @@ function pluginPlayground(options) {
|
|
|
428
420
|
__PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl)
|
|
429
421
|
},
|
|
430
422
|
include: [
|
|
431
|
-
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(
|
|
423
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cli_dirname, '..', '..', '..')
|
|
432
424
|
]
|
|
433
425
|
},
|
|
434
426
|
html: {
|
|
@@ -468,4 +460,4 @@ function pluginPlayground(options) {
|
|
|
468
460
|
globalStyles: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(staticPath, 'global-styles', 'web.css')
|
|
469
461
|
};
|
|
470
462
|
}
|
|
471
|
-
export { pluginPlayground,
|
|
463
|
+
export { pluginPlayground, cli_routeMeta as routeMeta };
|
package/dist/web/cjs/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.n =
|
|
5
|
-
var getter = module && module.__esModule ?
|
|
6
|
-
return module['default'];
|
|
7
|
-
} : function() {
|
|
8
|
-
return module;
|
|
9
|
-
};
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
10
6
|
__webpack_require__.d(getter, {
|
|
11
7
|
a: getter
|
|
12
8
|
});
|
|
@@ -14,7 +10,7 @@ var __webpack_require__ = {};
|
|
|
14
10
|
};
|
|
15
11
|
})();
|
|
16
12
|
(()=>{
|
|
17
|
-
__webpack_require__.d =
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
18
14
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
15
|
enumerable: true,
|
|
20
16
|
get: definition[key]
|
|
@@ -22,12 +18,10 @@ var __webpack_require__ = {};
|
|
|
22
18
|
};
|
|
23
19
|
})();
|
|
24
20
|
(()=>{
|
|
25
|
-
__webpack_require__.o =
|
|
26
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
-
};
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
28
22
|
})();
|
|
29
23
|
(()=>{
|
|
30
|
-
__webpack_require__.r =
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
31
25
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
26
|
value: 'Module'
|
|
33
27
|
});
|
|
@@ -39,8 +33,8 @@ var __webpack_require__ = {};
|
|
|
39
33
|
var __webpack_exports__ = {};
|
|
40
34
|
__webpack_require__.r(__webpack_exports__);
|
|
41
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
-
Editor: ()=>Editor,
|
|
43
36
|
MonacoEditor: ()=>react_default(),
|
|
37
|
+
Editor: ()=>Editor,
|
|
44
38
|
MonacoEditorLoader: ()=>react_namespaceObject.loader,
|
|
45
39
|
Runner: ()=>Runner
|
|
46
40
|
});
|
|
@@ -252,13 +246,11 @@ class Runner extends external_react_namespaceObject.Component {
|
|
|
252
246
|
if ('React' === specifier.local.name) this.hasReactImported = true;
|
|
253
247
|
if ('ImportDefaultSpecifier' === specifier.type) code.push(createVariableDeclaration(specifier.local.name, createGetImport(pkg, true)));
|
|
254
248
|
if ('ImportNamespaceSpecifier' === specifier.type) code.push(createVariableDeclaration(specifier.local.name, createGetImport(pkg)));
|
|
255
|
-
if ('ImportSpecifier' === specifier.type)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
else specifiers.push(specifier.local.name);
|
|
261
|
-
}
|
|
249
|
+
if ('ImportSpecifier' === specifier.type) if ('name' in specifier.imported && specifier.imported.name !== specifier.local.name) specifiers.push([
|
|
250
|
+
specifier.imported.name,
|
|
251
|
+
specifier.local.name
|
|
252
|
+
]);
|
|
253
|
+
else specifiers.push(specifier.local.name);
|
|
262
254
|
}
|
|
263
255
|
if (specifiers.length > 0) code.push(createVariableDeclaration(createObjectPattern(specifiers), createGetImport(pkg)));
|
|
264
256
|
path.replaceWithMultiple(code);
|
|
@@ -274,13 +266,10 @@ class Runner extends external_react_namespaceObject.Component {
|
|
|
274
266
|
const runExports = {};
|
|
275
267
|
const func = new Function('__get_import', 'exports', result.code);
|
|
276
268
|
func(getImport, runExports);
|
|
277
|
-
if (runExports.default) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
269
|
+
if (runExports.default) return void this.setState({
|
|
270
|
+
error: void 0,
|
|
271
|
+
comp: /*#__PURE__*/ external_react_default().createElement(runExports.default)
|
|
272
|
+
});
|
|
284
273
|
this.setState({
|
|
285
274
|
error: new Error('No default export')
|
|
286
275
|
});
|
|
@@ -322,8 +311,16 @@ class Runner extends external_react_namespaceObject.Component {
|
|
|
322
311
|
this.waitCompile = this.waitCompile.bind(this);
|
|
323
312
|
}
|
|
324
313
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
314
|
+
exports.Editor = __webpack_exports__.Editor;
|
|
315
|
+
exports.MonacoEditor = __webpack_exports__.MonacoEditor;
|
|
316
|
+
exports.MonacoEditorLoader = __webpack_exports__.MonacoEditorLoader;
|
|
317
|
+
exports.Runner = __webpack_exports__.Runner;
|
|
318
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
319
|
+
"Editor",
|
|
320
|
+
"MonacoEditor",
|
|
321
|
+
"MonacoEditorLoader",
|
|
322
|
+
"Runner"
|
|
323
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
324
|
+
Object.defineProperty(exports, '__esModule', {
|
|
328
325
|
value: true
|
|
329
326
|
});
|
package/dist/web/esm/index.mjs
CHANGED
|
@@ -206,13 +206,11 @@ class Runner extends __WEBPACK_EXTERNAL_MODULE_react__.Component {
|
|
|
206
206
|
if ('React' === specifier.local.name) this.hasReactImported = true;
|
|
207
207
|
if ('ImportDefaultSpecifier' === specifier.type) code.push(createVariableDeclaration(specifier.local.name, createGetImport(pkg, true)));
|
|
208
208
|
if ('ImportNamespaceSpecifier' === specifier.type) code.push(createVariableDeclaration(specifier.local.name, createGetImport(pkg)));
|
|
209
|
-
if ('ImportSpecifier' === specifier.type)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
else specifiers.push(specifier.local.name);
|
|
215
|
-
}
|
|
209
|
+
if ('ImportSpecifier' === specifier.type) if ('name' in specifier.imported && specifier.imported.name !== specifier.local.name) specifiers.push([
|
|
210
|
+
specifier.imported.name,
|
|
211
|
+
specifier.local.name
|
|
212
|
+
]);
|
|
213
|
+
else specifiers.push(specifier.local.name);
|
|
216
214
|
}
|
|
217
215
|
if (specifiers.length > 0) code.push(createVariableDeclaration(createObjectPattern(specifiers), createGetImport(pkg)));
|
|
218
216
|
path.replaceWithMultiple(code);
|
|
@@ -228,13 +226,10 @@ class Runner extends __WEBPACK_EXTERNAL_MODULE_react__.Component {
|
|
|
228
226
|
const runExports = {};
|
|
229
227
|
const func = new Function('__get_import', 'exports', result.code);
|
|
230
228
|
func(getImport, runExports);
|
|
231
|
-
if (runExports.default) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
229
|
+
if (runExports.default) return void this.setState({
|
|
230
|
+
error: void 0,
|
|
231
|
+
comp: /*#__PURE__*/ __WEBPACK_EXTERNAL_MODULE_react__["default"].createElement(runExports.default)
|
|
232
|
+
});
|
|
238
233
|
this.setState({
|
|
239
234
|
error: new Error('No default export')
|
|
240
235
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-playground",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.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": "3.0.1",
|
|
36
36
|
"rspack-plugin-virtual-module": "0.1.13",
|
|
37
|
-
"@rspress/shared": "1.
|
|
37
|
+
"@rspress/shared": "1.45.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@babel/types": "^7.
|
|
41
|
-
"@rsbuild/plugin-react": "~1.1
|
|
42
|
-
"@rslib/core": "0.
|
|
40
|
+
"@babel/types": "^7.27.1",
|
|
41
|
+
"@rsbuild/plugin-react": "~1.3.1",
|
|
42
|
+
"@rslib/core": "~0.6.9",
|
|
43
43
|
"@types/babel__core": "^7.20.5",
|
|
44
44
|
"@types/babel__standalone": "^7.1.9",
|
|
45
45
|
"@types/babel__traverse": "^7.20.6",
|
|
@@ -53,10 +53,11 @@
|
|
|
53
53
|
"react-router-dom": "^6.29.0",
|
|
54
54
|
"typescript": "^5.5.3",
|
|
55
55
|
"unified": "^10.1.2",
|
|
56
|
-
"unist-util-visit": "^4.1.2"
|
|
56
|
+
"unist-util-visit": "^4.1.2",
|
|
57
|
+
"@rspress/plugin-playground": "1.45.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
59
|
-
"@rspress/core": "^1.
|
|
60
|
+
"@rspress/core": "^1.45.0",
|
|
60
61
|
"react": ">=17.0.0",
|
|
61
62
|
"react-router-dom": "^6.8.1"
|
|
62
63
|
},
|
|
@@ -92,6 +92,13 @@ export default function Playground(props: PlaygroundProps) {
|
|
|
92
92
|
value={code}
|
|
93
93
|
onChange={handleCodeChange}
|
|
94
94
|
language={monacoLanguage}
|
|
95
|
+
beforeMount={monaco => {
|
|
96
|
+
monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
|
|
97
|
+
noSemanticValidation: true,
|
|
98
|
+
noSyntaxValidation: true,
|
|
99
|
+
noSuggestionDiagnostics: true,
|
|
100
|
+
});
|
|
101
|
+
}}
|
|
95
102
|
/>
|
|
96
103
|
{renderChildren?.(props, code, direction)}
|
|
97
104
|
</div>
|