@rspress/plugin-preview 2.0.0-rc.2 → 2.0.0-rc.4
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/index.js +70 -69
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -87,75 +87,6 @@ async function generateEntry_generateEntry(globalDemos, framework, customEntry)
|
|
|
87
87
|
};
|
|
88
88
|
return sourceEntry;
|
|
89
89
|
}
|
|
90
|
-
const getASTNodeImport = (name, from)=>({
|
|
91
|
-
type: 'mdxjsEsm',
|
|
92
|
-
value: `import ${name} from ${JSON.stringify(from)}`,
|
|
93
|
-
data: {
|
|
94
|
-
estree: {
|
|
95
|
-
type: 'Program',
|
|
96
|
-
sourceType: 'module',
|
|
97
|
-
body: [
|
|
98
|
-
{
|
|
99
|
-
type: 'ImportDeclaration',
|
|
100
|
-
specifiers: [
|
|
101
|
-
{
|
|
102
|
-
type: 'ImportDefaultSpecifier',
|
|
103
|
-
local: {
|
|
104
|
-
type: 'Identifier',
|
|
105
|
-
name
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
source: {
|
|
110
|
-
type: 'Literal',
|
|
111
|
-
value: from,
|
|
112
|
-
raw: `${JSON.stringify(from)}`
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
function parsePreviewInfoFromMeta(options) {
|
|
120
|
-
const { meta, defaultPreviewMode, defaultRenderMode } = options;
|
|
121
|
-
const result = {
|
|
122
|
-
isPure: false,
|
|
123
|
-
isPreview: false,
|
|
124
|
-
previewMode: null
|
|
125
|
-
};
|
|
126
|
-
if (!meta) {
|
|
127
|
-
if ('preview' === defaultRenderMode) {
|
|
128
|
-
result.isPreview = true;
|
|
129
|
-
result.previewMode = defaultPreviewMode;
|
|
130
|
-
} else result.isPure = true;
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
if (meta.includes('pure')) {
|
|
134
|
-
result.isPure = true;
|
|
135
|
-
return result;
|
|
136
|
-
}
|
|
137
|
-
const previewMatch = meta.match(/preview(?:="([^"]+)")?/);
|
|
138
|
-
if (previewMatch) {
|
|
139
|
-
result.isPreview = true;
|
|
140
|
-
const explicitMode = previewMatch[1];
|
|
141
|
-
if (explicitMode && [
|
|
142
|
-
'internal',
|
|
143
|
-
'iframe-fixed',
|
|
144
|
-
'iframe-follow'
|
|
145
|
-
].includes(explicitMode)) result.previewMode = explicitMode;
|
|
146
|
-
else result.previewMode = defaultPreviewMode;
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
if (meta.includes('iframe')) logger.warn('The "iframe" meta is deprecated, please use \`\`\`tsx preview="iframe-fixed" or \`\`\`tsx preview="iframe-follow" instead.');
|
|
150
|
-
if ('preview' === defaultRenderMode) {
|
|
151
|
-
result.isPreview = true;
|
|
152
|
-
result.previewMode = defaultPreviewMode;
|
|
153
|
-
} else result.isPure = true;
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
function color(d) {
|
|
157
|
-
return '\u001B[33m' + d + '\u001B[39m';
|
|
158
|
-
}
|
|
159
90
|
const convert = function(test) {
|
|
160
91
|
if (null == test) return ok;
|
|
161
92
|
if ('function' == typeof test) return castFactory(test);
|
|
@@ -202,6 +133,9 @@ function ok() {
|
|
|
202
133
|
function looksLikeANode(value) {
|
|
203
134
|
return null !== value && 'object' == typeof value && 'type' in value;
|
|
204
135
|
}
|
|
136
|
+
function color(d) {
|
|
137
|
+
return '\u001B[33m' + d + '\u001B[39m';
|
|
138
|
+
}
|
|
205
139
|
const empty = [];
|
|
206
140
|
const CONTINUE = true;
|
|
207
141
|
const EXIT = false;
|
|
@@ -280,6 +214,72 @@ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
|
|
|
280
214
|
return visitor(node, index, parent);
|
|
281
215
|
}
|
|
282
216
|
}
|
|
217
|
+
const getASTNodeImport = (name, from)=>({
|
|
218
|
+
type: 'mdxjsEsm',
|
|
219
|
+
value: `import ${name} from ${JSON.stringify(from)}`,
|
|
220
|
+
data: {
|
|
221
|
+
estree: {
|
|
222
|
+
type: 'Program',
|
|
223
|
+
sourceType: 'module',
|
|
224
|
+
body: [
|
|
225
|
+
{
|
|
226
|
+
type: 'ImportDeclaration',
|
|
227
|
+
specifiers: [
|
|
228
|
+
{
|
|
229
|
+
type: 'ImportDefaultSpecifier',
|
|
230
|
+
local: {
|
|
231
|
+
type: 'Identifier',
|
|
232
|
+
name
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
source: {
|
|
237
|
+
type: 'Literal',
|
|
238
|
+
value: from,
|
|
239
|
+
raw: `${JSON.stringify(from)}`
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
function parsePreviewInfoFromMeta(options) {
|
|
247
|
+
const { meta, defaultPreviewMode, defaultRenderMode } = options;
|
|
248
|
+
const result = {
|
|
249
|
+
isPure: false,
|
|
250
|
+
isPreview: false,
|
|
251
|
+
previewMode: null
|
|
252
|
+
};
|
|
253
|
+
if (!meta) {
|
|
254
|
+
if ('preview' === defaultRenderMode) {
|
|
255
|
+
result.isPreview = true;
|
|
256
|
+
result.previewMode = defaultPreviewMode;
|
|
257
|
+
} else result.isPure = true;
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
if (meta.includes('pure')) {
|
|
261
|
+
result.isPure = true;
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
const previewMatch = meta.match(/preview(?:="([^"]+)")?/);
|
|
265
|
+
if (previewMatch) {
|
|
266
|
+
result.isPreview = true;
|
|
267
|
+
const explicitMode = previewMatch[1];
|
|
268
|
+
if (explicitMode && [
|
|
269
|
+
'internal',
|
|
270
|
+
'iframe-fixed',
|
|
271
|
+
'iframe-follow'
|
|
272
|
+
].includes(explicitMode)) result.previewMode = explicitMode;
|
|
273
|
+
else result.previewMode = defaultPreviewMode;
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
if (meta.includes('iframe')) logger.warn('The "iframe" meta is deprecated, please use \`\`\`tsx preview="iframe-fixed" or \`\`\`tsx preview="iframe-follow" instead.');
|
|
277
|
+
if ('preview' === defaultRenderMode) {
|
|
278
|
+
result.isPreview = true;
|
|
279
|
+
result.previewMode = defaultPreviewMode;
|
|
280
|
+
} else result.isPure = true;
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
283
|
const remarkPlugin_globalDemos = {};
|
|
284
284
|
const isDirtyRef = {
|
|
285
285
|
current: false
|
|
@@ -439,6 +439,7 @@ function pluginPreview(options) {
|
|
|
439
439
|
},
|
|
440
440
|
tools: {
|
|
441
441
|
rspack: {
|
|
442
|
+
lazyCompilation: false,
|
|
442
443
|
watchOptions: {
|
|
443
444
|
ignored: /\.git/
|
|
444
445
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-preview",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.4",
|
|
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": {
|
|
@@ -23,34 +23,34 @@
|
|
|
23
23
|
"static"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rsbuild/core": "~1.6.
|
|
26
|
+
"@rsbuild/core": "~1.6.15",
|
|
27
27
|
"@rsbuild/plugin-babel": "~1.0.6",
|
|
28
28
|
"@rsbuild/plugin-react": "~1.4.2",
|
|
29
29
|
"qrcode.react": "^4.2.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@rslib/core": "0.18.
|
|
32
|
+
"@rslib/core": "0.18.6",
|
|
33
33
|
"@types/mdast": "^4.0.4",
|
|
34
34
|
"@types/node": "^22.8.1",
|
|
35
35
|
"@types/react": "^19.2.7",
|
|
36
36
|
"@types/react-dom": "^19.2.3",
|
|
37
37
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
38
38
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
39
|
-
"react": "^19.2.
|
|
40
|
-
"react-dom": "^19.2.
|
|
41
|
-
"react-router-dom": "^7.
|
|
39
|
+
"react": "^19.2.3",
|
|
40
|
+
"react-dom": "^19.2.3",
|
|
41
|
+
"react-router-dom": "^7.11.0",
|
|
42
42
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
43
43
|
"typescript": "^5.8.2",
|
|
44
44
|
"unified": "^11.0.5",
|
|
45
45
|
"unist-util-visit": "^5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@rspress/core": "^2.0.0-rc.
|
|
48
|
+
"@rspress/core": "^2.0.0-rc.4",
|
|
49
49
|
"react": ">=18.0.0",
|
|
50
50
|
"react-router-dom": "^6.8.1"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
|
-
"node": ">=
|
|
53
|
+
"node": ">=20.9.0"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public",
|