@rspress/plugin-playground 0.0.0-nightly-20230920160336 → 0.1.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 +27 -0
- package/dist/cli/cjs/index.js.map +1 -1
- package/dist/cli/esm/index.d.ts +1 -0
- package/dist/cli/esm/index.js +27 -1
- package/dist/cli/esm/index.js.map +1 -1
- package/dist/web/cjs/index.js +44 -3
- package/dist/web/cjs/index.js.map +1 -1
- package/dist/web/esm/index.d.ts +1 -1
- package/dist/web/esm/index.js +42 -3
- package/dist/web/esm/index.js.map +1 -1
- package/package.json +4 -5
package/dist/cli/cjs/index.js
CHANGED
|
@@ -2876,6 +2876,15 @@ var remarkPlugin = ({
|
|
|
2876
2876
|
};
|
|
2877
2877
|
};
|
|
2878
2878
|
|
|
2879
|
+
// src/web/constant.ts
|
|
2880
|
+
var DEFAULT_BABEL_URL = "https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.22.20/babel.min.js";
|
|
2881
|
+
var DEFAULT_MONACO_URL = "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs";
|
|
2882
|
+
|
|
2883
|
+
// src/web/utils.ts
|
|
2884
|
+
function normalizeUrl(u) {
|
|
2885
|
+
return u.replace(/\/\//g, "/");
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2879
2888
|
// src/cli/index.ts
|
|
2880
2889
|
var routeMeta;
|
|
2881
2890
|
function pluginPlayground(options) {
|
|
@@ -2884,6 +2893,7 @@ function pluginPlayground(options) {
|
|
|
2884
2893
|
include,
|
|
2885
2894
|
defaultDirection = "horizontal",
|
|
2886
2895
|
editorPosition = "left",
|
|
2896
|
+
babelUrl = "",
|
|
2887
2897
|
monacoLoader = {},
|
|
2888
2898
|
monacoOptions = {}
|
|
2889
2899
|
} = options || {};
|
|
@@ -2894,6 +2904,11 @@ function pluginPlayground(options) {
|
|
|
2894
2904
|
"[Playground]: render should ends with Playground.(jsx?|tsx?)"
|
|
2895
2905
|
);
|
|
2896
2906
|
}
|
|
2907
|
+
const preloads = [];
|
|
2908
|
+
preloads.push(babelUrl || DEFAULT_BABEL_URL);
|
|
2909
|
+
const monacoPrefix = monacoLoader.paths?.vs || DEFAULT_MONACO_URL;
|
|
2910
|
+
preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));
|
|
2911
|
+
preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));
|
|
2897
2912
|
return {
|
|
2898
2913
|
name: "@rspress/plugin-playground",
|
|
2899
2914
|
async routeGenerated(routes) {
|
|
@@ -2993,10 +3008,22 @@ function pluginPlayground(options) {
|
|
|
2993
3008
|
builderConfig: {
|
|
2994
3009
|
source: {
|
|
2995
3010
|
define: {
|
|
3011
|
+
__PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl),
|
|
2996
3012
|
__PLAYGROUND_MONACO_LOADER__: JSON.stringify(monacoLoader),
|
|
2997
3013
|
__PLAYGROUND_MONACO_OPTIONS__: JSON.stringify(monacoOptions)
|
|
2998
3014
|
}
|
|
2999
3015
|
},
|
|
3016
|
+
html: {
|
|
3017
|
+
tags: preloads.map((url) => ({
|
|
3018
|
+
tag: "link",
|
|
3019
|
+
head: true,
|
|
3020
|
+
attrs: {
|
|
3021
|
+
rel: "preload",
|
|
3022
|
+
href: url,
|
|
3023
|
+
as: "script"
|
|
3024
|
+
}
|
|
3025
|
+
}))
|
|
3026
|
+
},
|
|
3000
3027
|
tools: {
|
|
3001
3028
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
|
|
3002
3029
|
// @ts-ignore
|