@rspress/plugin-preview 1.43.11 → 2.0.0-alpha-canary-202504162001

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.d.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import type { RsbuildConfig } from '@rsbuild/core';
2
2
  import { RspressPlugin } from '@rspress/shared';
3
3
 
4
+ declare interface CustomEntry {
5
+ entryCssPath: string;
6
+ demoPath: string;
7
+ }
8
+
4
9
  declare type IframeOptions = {
5
10
  /**
6
11
  * framework in the iframe
@@ -18,6 +23,10 @@ declare type IframeOptions = {
18
23
  */
19
24
  devPort?: number;
20
25
  builderConfig?: RsbuildConfig;
26
+ /**
27
+ * custom support for other web frameworks
28
+ */
29
+ customEntry?: (meta: CustomEntry) => string;
21
30
  };
22
31
 
23
32
  export declare type Options = {
package/dist/index.js CHANGED
@@ -18,12 +18,8 @@ function __webpack_require__(moduleId) {
18
18
  return module.exports;
19
19
  }
20
20
  (()=>{
21
- __webpack_require__.n = function(module) {
22
- var getter = module && module.__esModule ? function() {
23
- return module['default'];
24
- } : function() {
25
- return module;
26
- };
21
+ __webpack_require__.n = (module)=>{
22
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
27
23
  __webpack_require__.d(getter, {
28
24
  a: getter
29
25
  });
@@ -31,7 +27,7 @@ function __webpack_require__(moduleId) {
31
27
  };
32
28
  })();
33
29
  (()=>{
34
- __webpack_require__.d = function(exports1, definition) {
30
+ __webpack_require__.d = (exports1, definition)=>{
35
31
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
36
32
  enumerable: true,
37
33
  get: definition[key]
@@ -39,12 +35,10 @@ function __webpack_require__(moduleId) {
39
35
  };
40
36
  })();
41
37
  (()=>{
42
- __webpack_require__.o = function(obj, prop) {
43
- return Object.prototype.hasOwnProperty.call(obj, prop);
44
- };
38
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
45
39
  })();
46
40
  (()=>{
47
- __webpack_require__.r = function(exports1) {
41
+ __webpack_require__.r = (exports1)=>{
48
42
  if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
49
43
  value: 'Module'
50
44
  });
@@ -83,7 +77,18 @@ var __webpack_exports__ = {};
83
77
  import DemoBlock from ${JSON.stringify(path)};
84
78
  ${str}
85
79
  `;
86
- function generateEntry(demos, framework, position) {
80
+ const getLangFileExt = (lang)=>{
81
+ switch(lang){
82
+ case 'jsx':
83
+ case 'tsx':
84
+ return 'tsx';
85
+ case 'json':
86
+ return 'tsx';
87
+ default:
88
+ return lang;
89
+ }
90
+ };
91
+ function generateEntry(demos, framework, position, customEntry) {
87
92
  const sourceEntry = {};
88
93
  const entryCssPath = (0, external_node_path_namespaceObject.join)(staticPath, 'global-styles', 'entry.css');
89
94
  if ('follow' === position) Object.values(demos).forEach((routes)=>{
@@ -102,7 +107,10 @@ var __webpack_exports__ = {};
102
107
  import Demo from ${JSON.stringify(demoPath)};
103
108
  render(<Demo />, document.getElementById('root'));
104
109
  `;
105
- const entryContent = 'react' === framework ? reactEntry : solidEntry;
110
+ const entryContent = customEntry ? customEntry({
111
+ entryCssPath,
112
+ demoPath
113
+ }) : 'react' === framework ? reactEntry : solidEntry;
106
114
  (0, external_node_fs_namespaceObject.writeFileSync)(entry, entryContent);
107
115
  sourceEntry[id] = entry;
108
116
  });
@@ -148,9 +156,9 @@ var __webpack_exports__ = {};
148
156
  const node_utils_namespaceObject = require("@rspress/shared/node-utils");
149
157
  const convert = function(test) {
150
158
  if (null == test) return ok;
151
- if ('string' == typeof test) return typeFactory(test);
152
- if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
153
159
  if ('function' == typeof test) return castFactory(test);
160
+ if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
161
+ if ('string' == typeof test) return typeFactory(test);
154
162
  throw new Error('Expected function, string, or object as test');
155
163
  };
156
164
  function anyFactory(tests) {
@@ -160,15 +168,17 @@ var __webpack_exports__ = {};
160
168
  return castFactory(any);
161
169
  function any(...parameters) {
162
170
  let index = -1;
163
- while(++index < checks.length)if (checks[index].call(this, ...parameters)) return true;
171
+ while(++index < checks.length)if (checks[index].apply(this, parameters)) return true;
164
172
  return false;
165
173
  }
166
174
  }
167
175
  function propsFactory(check) {
176
+ const checkAsRecord = check;
168
177
  return castFactory(all);
169
178
  function all(node) {
179
+ const nodeAsRecord = node;
170
180
  let key;
171
- for(key in check)if (node[key] !== check[key]) return false;
181
+ for(key in check)if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
172
182
  return true;
173
183
  }
174
184
  }
@@ -178,28 +188,32 @@ var __webpack_exports__ = {};
178
188
  return node && node.type === check;
179
189
  }
180
190
  }
181
- function castFactory(check) {
182
- return assertion;
183
- function assertion(node, ...parameters) {
184
- return Boolean(node && 'object' == typeof node && 'type' in node && Boolean(check.call(this, node, ...parameters)));
191
+ function castFactory(testFunction) {
192
+ return check;
193
+ function check(value, index, parent) {
194
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, 'number' == typeof index ? index : void 0, parent || void 0));
185
195
  }
186
196
  }
187
197
  function ok() {
188
198
  return true;
189
199
  }
200
+ function looksLikeANode(value) {
201
+ return null !== value && 'object' == typeof value && 'type' in value;
202
+ }
190
203
  function color(d) {
191
204
  return '\u001B[33m' + d + '\u001B[39m';
192
205
  }
206
+ const empty = [];
193
207
  const CONTINUE = true;
194
208
  const EXIT = false;
195
209
  const SKIP = 'skip';
196
- const visitParents = function(tree, test, visitor, reverse) {
210
+ function visitParents(tree, test, visitor, reverse) {
211
+ let check;
197
212
  if ('function' == typeof test && 'function' != typeof visitor) {
198
213
  reverse = visitor;
199
214
  visitor = test;
200
- test = null;
201
- }
202
- const is = convert(test);
215
+ } else check = test;
216
+ const is = convert(check);
203
217
  const step = reverse ? -1 : 1;
204
218
  factory(tree, void 0, [])();
205
219
  function factory(node, index, parents) {
@@ -212,49 +226,61 @@ var __webpack_exports__ = {};
212
226
  }
213
227
  return visit;
214
228
  function visit() {
215
- let result = [];
229
+ let result = empty;
216
230
  let subresult;
217
231
  let offset;
218
232
  let grandparents;
219
- if (!test || is(node, index, parents[parents.length - 1] || null)) {
233
+ if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
220
234
  result = toResult(visitor(node, parents));
221
235
  if (result[0] === EXIT) return result;
222
236
  }
223
- if (node.children && result[0] !== SKIP) {
224
- offset = (reverse ? node.children.length : -1) + step;
225
- grandparents = parents.concat(node);
226
- while(offset > -1 && offset < node.children.length){
227
- subresult = factory(node.children[offset], offset, grandparents)();
228
- if (subresult[0] === EXIT) return subresult;
229
- offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
237
+ if ('children' in node && node.children) {
238
+ const nodeAsParent = node;
239
+ if (nodeAsParent.children && result[0] !== SKIP) {
240
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
241
+ grandparents = parents.concat(nodeAsParent);
242
+ while(offset > -1 && offset < nodeAsParent.children.length){
243
+ const child = nodeAsParent.children[offset];
244
+ subresult = factory(child, offset, grandparents)();
245
+ if (subresult[0] === EXIT) return subresult;
246
+ offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
247
+ }
230
248
  }
231
249
  }
232
250
  return result;
233
251
  }
234
252
  }
235
- };
253
+ }
236
254
  function toResult(value) {
237
255
  if (Array.isArray(value)) return value;
238
256
  if ('number' == typeof value) return [
239
257
  CONTINUE,
240
258
  value
241
259
  ];
242
- return [
260
+ return null == value ? empty : [
243
261
  value
244
262
  ];
245
263
  }
246
- const lib_visit = function(tree, test, visitor, reverse) {
247
- if ('function' == typeof test && 'function' != typeof visitor) {
248
- reverse = visitor;
249
- visitor = test;
250
- test = null;
264
+ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
265
+ let reverse;
266
+ let test;
267
+ let visitor;
268
+ if ('function' == typeof testOrVisitor && 'function' != typeof visitorOrReverse) {
269
+ test = void 0;
270
+ visitor = testOrVisitor;
271
+ reverse = visitorOrReverse;
272
+ } else {
273
+ test = testOrVisitor;
274
+ visitor = visitorOrReverse;
275
+ reverse = maybeReverse;
251
276
  }
252
277
  visitParents(tree, test, overload, reverse);
253
278
  function overload(node, parents) {
254
279
  const parent = parents[parents.length - 1];
255
- return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
280
+ const index = parent ? parent.children.indexOf(node) : void 0;
281
+ return visitor(node, index, parent);
256
282
  }
257
- };
283
+ }
258
284
  const getASTNodeImport = (name, from)=>({
259
285
  type: 'mdxjsEsm',
260
286
  value: `import ${name} from ${JSON.stringify(from)}`,
@@ -411,14 +437,18 @@ var __webpack_exports__ = {};
411
437
  if ('hasVisited' in node) return;
412
438
  if (node.lang && previewLanguages.includes(node.lang)) {
413
439
  var _node_meta, _node_meta1, _node_meta2, _node_meta3, _node_meta4, _node_meta5;
414
- if ((null === (_node_meta = node.meta) || void 0 === _node_meta ? void 0 : _node_meta.includes('pure')) || !(null === (_node_meta1 = node.meta) || void 0 === _node_meta1 ? void 0 : _node_meta1.includes('preview')) && 'pure' === defaultRenderMode) return;
415
- const value = injectDemoBlockImport(previewCodeTransform({
440
+ if ((null == (_node_meta = node.meta) ? void 0 : _node_meta.includes('pure')) || !(null == (_node_meta1 = node.meta) ? void 0 : _node_meta1.includes('preview')) && 'pure' === defaultRenderMode) return;
441
+ const isJsx = 'jsx' === node.lang || 'tsx' === node.lang;
442
+ const value = isJsx ? injectDemoBlockImport(previewCodeTransform({
416
443
  language: node.lang,
417
444
  code: node.value
418
- }), demoBlockComponentPath);
419
- const isMobileMode = (null === (_node_meta2 = node.meta) || void 0 === _node_meta2 ? void 0 : _node_meta2.includes('mobile')) || (null === (_node_meta3 = node.meta) || void 0 === _node_meta3 ? void 0 : _node_meta3.includes('iframe')) || !(null === (_node_meta4 = node.meta) || void 0 === _node_meta4 ? void 0 : _node_meta4.includes('web')) && !(null === (_node_meta5 = node.meta) || void 0 === _node_meta5 ? void 0 : _node_meta5.includes('internal')) && 'iframe' === previewMode;
445
+ }), demoBlockComponentPath) : previewCodeTransform({
446
+ language: node.lang,
447
+ code: node.value
448
+ });
449
+ const isMobileMode = (null == (_node_meta2 = node.meta) ? void 0 : _node_meta2.includes('mobile')) || (null == (_node_meta3 = node.meta) ? void 0 : _node_meta3.includes('iframe')) || !(null == (_node_meta4 = node.meta) ? void 0 : _node_meta4.includes('web')) && !(null == (_node_meta5 = node.meta) ? void 0 : _node_meta5.includes('internal')) && 'iframe' === previewMode;
420
450
  const id = generateId(pageName, index++);
421
- const virtualModulePath = (0, external_node_path_namespaceObject.join)(virtualDir, `${id}.tsx`);
451
+ const virtualModulePath = (0, external_node_path_namespaceObject.join)(virtualDir, `${id}.${getLangFileExt(node.lang)}`);
422
452
  constructDemoNode(id, virtualModulePath, node, isMobileMode);
423
453
  if (external_node_fs_default().existsSync(virtualModulePath)) {
424
454
  const content = external_node_fs_default().readFileSync(virtualModulePath, 'utf-8');
@@ -431,7 +461,7 @@ var __webpack_exports__ = {};
431
461
  if (remarkPlugin_demos[pageName].length > 0) data.pageMeta.haveDemos = true;
432
462
  };
433
463
  };
434
- let src_rslib_entry_routeMeta;
464
+ let src_routeMeta;
435
465
  const DEFAULT_PREVIEW_LANGUAGES = [
436
466
  'jsx',
437
467
  'tsx'
@@ -439,11 +469,11 @@ var __webpack_exports__ = {};
439
469
  function pluginPreview(options) {
440
470
  const { isMobile = false, iframeOptions = {}, iframePosition = 'follow', defaultRenderMode = 'preview', previewLanguages = DEFAULT_PREVIEW_LANGUAGES, previewCodeTransform = ({ code })=>code } = options ?? {};
441
471
  const previewMode = (null == options ? void 0 : options.previewMode) ?? (isMobile ? 'iframe' : 'internal');
442
- const { devPort = 7890, framework = 'react', position = iframePosition, builderConfig = {} } = iframeOptions;
472
+ const { devPort = 7890, framework = 'react', position = iframePosition, builderConfig = {}, customEntry } = iframeOptions;
443
473
  const globalUIComponents = 'fixed' === position ? [
444
474
  (0, external_node_path_namespaceObject.join)(staticPath, 'global-components', 'Device.tsx')
445
475
  ] : [];
446
- const getRouteMeta = ()=>src_rslib_entry_routeMeta;
476
+ const getRouteMeta = ()=>src_routeMeta;
447
477
  let lastDemos;
448
478
  let devServer;
449
479
  let clientConfig;
@@ -456,7 +486,7 @@ var __webpack_exports__ = {};
456
486
  return config;
457
487
  },
458
488
  routeGenerated (routes) {
459
- src_rslib_entry_routeMeta = routes;
489
+ src_routeMeta = routes;
460
490
  },
461
491
  async beforeBuild (_, isProd) {
462
492
  if (!isProd) try {
@@ -480,9 +510,9 @@ var __webpack_exports__ = {};
480
510
  var _devServer_server;
481
511
  if ((0, external_lodash_namespaceObject.isEqual)(remarkPlugin_demos, lastDemos)) return;
482
512
  lastDemos = (0, external_lodash_namespaceObject.cloneDeep)(remarkPlugin_demos);
483
- await (null == devServer ? void 0 : null === (_devServer_server = devServer.server) || void 0 === _devServer_server ? void 0 : _devServer_server.close());
513
+ await (null == devServer ? void 0 : null == (_devServer_server = devServer.server) ? void 0 : _devServer_server.close());
484
514
  devServer = void 0;
485
- const sourceEntry = generateEntry(remarkPlugin_demos, framework, position);
515
+ const sourceEntry = generateEntry(remarkPlugin_demos, framework, position, customEntry);
486
516
  const outDir = (0, external_node_path_namespaceObject.join)(config.outDir ?? 'doc_build', '~demo');
487
517
  if (0 === Object.keys(sourceEntry).length) return;
488
518
  const { html, source, output, performance } = clientConfig ?? {};
@@ -558,11 +588,11 @@ var __webpack_exports__ = {};
558
588
  setup: (api)=>{
559
589
  api.modifyRsbuildConfig((config)=>{
560
590
  var _config_output;
561
- if ((null === (_config_output = config.output) || void 0 === _config_output ? void 0 : _config_output.target) === 'web') clientConfig = config;
591
+ if ((null == (_config_output = config.output) ? void 0 : _config_output.target) === 'web') clientConfig = config;
562
592
  });
563
593
  api.onCloseDevServer(async ()=>{
564
594
  var _devServer_server;
565
- await (null == devServer ? void 0 : null === (_devServer_server = devServer.server) || void 0 === _devServer_server ? void 0 : _devServer_server.close());
595
+ await (null == devServer ? void 0 : null == (_devServer_server = devServer.server) ? void 0 : _devServer_server.close());
566
596
  devServer = void 0;
567
597
  });
568
598
  }
@@ -596,8 +626,10 @@ var __webpack_exports__ = {};
596
626
  };
597
627
  }
598
628
  })();
599
- var __webpack_export_target__ = exports;
600
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
601
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
629
+ exports.pluginPreview = __webpack_exports__.pluginPreview;
630
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
631
+ "pluginPreview"
632
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
633
+ Object.defineProperty(exports, '__esModule', {
602
634
  value: true
603
635
  });
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export declare const generateId: (pageName: string, index: number) => string;
2
2
 
3
+ export declare const getLangFileExt: (lang: string) => string;
4
+
3
5
  export declare const injectDemoBlockImport: (str: string, path: string) => string;
4
6
 
5
7
  /**
package/dist/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
4
+ __webpack_require__.d = (exports1, definition)=>{
5
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
6
  enumerable: true,
7
7
  get: definition[key]
@@ -9,12 +9,10 @@ var __webpack_require__ = {};
9
9
  };
10
10
  })();
11
11
  (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
15
13
  })();
16
14
  (()=>{
17
- __webpack_require__.r = function(exports1) {
15
+ __webpack_require__.r = (exports1)=>{
18
16
  if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
17
  value: 'Module'
20
18
  });
@@ -27,6 +25,7 @@ var __webpack_exports__ = {};
27
25
  __webpack_require__.r(__webpack_exports__);
28
26
  __webpack_require__.d(__webpack_exports__, {
29
27
  generateId: ()=>generateId,
28
+ getLangFileExt: ()=>getLangFileExt,
30
29
  injectDemoBlockImport: ()=>injectDemoBlockImport,
31
30
  normalizeId: ()=>normalizeId,
32
31
  toValidVarName: ()=>toValidVarName
@@ -44,8 +43,29 @@ const injectDemoBlockImport = (str, path)=>`
44
43
  import DemoBlock from ${JSON.stringify(path)};
45
44
  ${str}
46
45
  `;
47
- var __webpack_export_target__ = exports;
48
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
49
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
46
+ const getLangFileExt = (lang)=>{
47
+ switch(lang){
48
+ case 'jsx':
49
+ case 'tsx':
50
+ return 'tsx';
51
+ case 'json':
52
+ return 'tsx';
53
+ default:
54
+ return lang;
55
+ }
56
+ };
57
+ exports.generateId = __webpack_exports__.generateId;
58
+ exports.getLangFileExt = __webpack_exports__.getLangFileExt;
59
+ exports.injectDemoBlockImport = __webpack_exports__.injectDemoBlockImport;
60
+ exports.normalizeId = __webpack_exports__.normalizeId;
61
+ exports.toValidVarName = __webpack_exports__.toValidVarName;
62
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
63
+ "generateId",
64
+ "getLangFileExt",
65
+ "injectDemoBlockImport",
66
+ "normalizeId",
67
+ "toValidVarName"
68
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
69
+ Object.defineProperty(exports, '__esModule', {
50
70
  value: true
51
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-preview",
3
- "version": "1.43.11",
3
+ "version": "2.0.0-alpha-canary-202504162001",
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": {
@@ -17,35 +17,35 @@
17
17
  "static"
18
18
  ],
19
19
  "dependencies": {
20
- "@rsbuild/core": "1.2.3",
21
- "@rsbuild/plugin-babel": "~1.0.3",
22
- "@rsbuild/plugin-less": "~1.1.0",
23
- "@rsbuild/plugin-react": "~1.1.0",
24
- "@rsbuild/plugin-sass": "~1.2.0",
25
- "@rsbuild/plugin-solid": "~1.0.4",
20
+ "@rsbuild/core": "1.3.6",
21
+ "@rsbuild/plugin-babel": "~1.0.5",
22
+ "@rsbuild/plugin-less": "~1.2.2",
23
+ "@rsbuild/plugin-react": "~1.1.1",
24
+ "@rsbuild/plugin-sass": "~1.3.1",
25
+ "@rsbuild/plugin-solid": "~1.0.5",
26
26
  "lodash": "4.17.21",
27
- "qrcode.react": "^3.2.0",
28
- "@rspress/shared": "1.43.11",
29
- "@rspress/theme-default": "1.43.11"
27
+ "qrcode.react": "^4.2.0",
28
+ "@rspress/shared": "2.0.0-alpha-canary-202504162001",
29
+ "@rspress/theme-default": "2.0.0-alpha-canary-202504162001"
30
30
  },
31
31
  "devDependencies": {
32
- "@rslib/core": "0.5.2",
33
- "@types/lodash": "^4.17.15",
34
- "@types/mdast": "^3.0.15",
32
+ "@rslib/core": "0.6.3",
33
+ "@types/lodash": "^4.17.16",
34
+ "@types/mdast": "^4.0.4",
35
35
  "@types/node": "^18.11.17",
36
- "@types/react": "^18.3.18",
37
- "@types/react-dom": "^18.3.5",
38
- "mdast-util-mdx-jsx": "^2.1.4",
39
- "mdast-util-mdxjs-esm": "^1.3.1",
36
+ "@types/react": "^18.3.20",
37
+ "@types/react-dom": "^18.3.6",
38
+ "mdast-util-mdx-jsx": "^3.2.0",
39
+ "mdast-util-mdxjs-esm": "^2.0.1",
40
40
  "react": "^18.3.1",
41
41
  "react-dom": "^18.3.1",
42
42
  "react-router-dom": "^6.29.0",
43
- "typescript": "^5.5.3",
44
- "unified": "^10.1.2",
45
- "unist-util-visit": "^4.1.2"
43
+ "typescript": "^5.8.2",
44
+ "unified": "^11.0.5",
45
+ "unist-util-visit": "^5.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@rspress/core": "^1.43.11",
48
+ "@rspress/core": "^2.0.0-alpha-canary-202504162001",
49
49
  "react": ">=17.0.0",
50
50
  "react-router-dom": "^6.8.1"
51
51
  },
@@ -9,13 +9,15 @@
9
9
  .rspress-demo-block {
10
10
  padding-bottom: 12px;
11
11
  background-color: var(--rp-demo-block-bg);
12
- &-title {
13
- padding: 12px 12px 8px;
14
- color: #697b8c;
15
- font-size: 14px;
16
- }
17
- &-main {
18
- border-right: none;
19
- border-left: none;
20
- }
12
+ }
13
+
14
+ .rspress-demo-block-title {
15
+ padding: 12px 12px 8px;
16
+ color: #697b8c;
17
+ font-size: 14px;
18
+ }
19
+
20
+ .rspress-demo-block-main {
21
+ border-right: none;
22
+ border-left: none;
21
23
  }
@@ -1,4 +1,4 @@
1
- import './DemoBlock.scss';
1
+ import './DemoBlock.css';
2
2
 
3
3
  interface Props {
4
4
  title: string;
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useState } from 'react';
8
8
  // @ts-ignore
9
9
  import { normalizeId } from '../../dist/utils';
10
10
  import MobileOperation from './common/mobile-operation';
11
- import './Device.scss';
11
+ import './Device.css';
12
12
 
13
13
  export default () => {
14
14
  const { page } = usePageData();
@@ -0,0 +1,103 @@
1
+ :root {
2
+ --rp-preview-button-hover-bg: #e5e6eb;
3
+ --rp-preview-button-bg: #e5e6eb;
4
+ }
5
+
6
+ .dark {
7
+ --rp-preview-button-hover-bg: #c5c5c5;
8
+ --rp-preview-button-bg: #c5c5c5;
9
+ }
10
+
11
+ .rspress-preview {
12
+ padding: 16px 0;
13
+ }
14
+
15
+ .rspress-preview-wrapper {
16
+ border: 1px solid var(--rp-container-details-border);
17
+ border-radius: var(--rp-radius-small);
18
+ }
19
+
20
+ .rspress-preview-card {
21
+ padding: 16px;
22
+ position: relative;
23
+ border: 1px solid var(--rp-container-details-border);
24
+ border-radius: var(--rp-radius-small);
25
+ display: flex;
26
+ }
27
+
28
+ .rspress-preview-qrcode {
29
+ background-color: #fff;
30
+ width: 120px;
31
+ height: 120px;
32
+ position: absolute;
33
+ top: -132px;
34
+ right: -46px;
35
+ padding: 12px;
36
+ }
37
+
38
+ .rspress-preview-code {
39
+ position: relative;
40
+ overflow: hidden;
41
+ flex: 1 1;
42
+ max-height: 700px;
43
+ }
44
+
45
+ .rspress-preview-code-hide {
46
+ position: relative;
47
+ overflow: hidden;
48
+ display: none;
49
+ }
50
+
51
+ .rspress-preview-code-show {
52
+ margin-top: 16px;
53
+ display: block;
54
+ }
55
+
56
+ .rspress-preview-device {
57
+ position: relative;
58
+ flex: 0 0;
59
+ border-left: 1px solid #e6e6e6;
60
+ display: flex;
61
+ flex-direction: column;
62
+ }
63
+
64
+ .rspress-preview-device iframe {
65
+ border-bottom: 1px solid #e6e6e6;
66
+ width: 360px;
67
+ height: 100%;
68
+ flex: auto;
69
+ }
70
+
71
+ .rspress-preview-operations button {
72
+ width: 28px;
73
+ height: 28px;
74
+ padding: 0;
75
+ text-align: center;
76
+ border-radius: 50%;
77
+ border: 1px solid transparent;
78
+ background-color: var(--rp-c-bg-soft);
79
+ margin-left: 14px;
80
+ }
81
+
82
+ .rspress-preview-operations button:hover {
83
+ background-color: var(--rp-preview-button-hover-bg);
84
+ }
85
+
86
+ .rspress-preview-operations svg {
87
+ display: inline-block;
88
+ vertical-align: -2px;
89
+ }
90
+
91
+ .rspress-preview-operations.mobile {
92
+ display: flex;
93
+ justify-content: flex-end;
94
+ width: 100%;
95
+ padding: 6px;
96
+ }
97
+
98
+ .rspress-preview-operations.web {
99
+ display: flex;
100
+ justify-content: center;
101
+ align-items: center;
102
+ flex: none;
103
+ }
@@ -10,7 +10,7 @@ import {
10
10
  import IconLaunch from '../icons/Launch';
11
11
  import IconQrcode from '../icons/Qrcode';
12
12
  import IconRefresh from '../icons/Refresh';
13
- import './index.scss';
13
+ import './index.css';
14
14
 
15
15
  const locales = {
16
16
  zh: {
@@ -1,104 +0,0 @@
1
- :root {
2
- --rp-preview-button-hover-bg: #e5e6eb;
3
- --rp-preview-button-bg: #e5e6eb;
4
- }
5
-
6
- .dark {
7
- --rp-preview-button-hover-bg: #c5c5c5;
8
- --rp-preview-button-bg: #c5c5c5;
9
- }
10
-
11
- .rspress-preview {
12
- padding: 16px 0;
13
-
14
- &-wrapper {
15
- border: 1px solid var(--rp-container-details-border);
16
- border-radius: var(--rp-radius-small);
17
- }
18
-
19
- &-card {
20
- padding: 16px;
21
- position: relative;
22
- border: 1px solid var(--rp-container-details-border);
23
- border-radius: var(--rp-radius-small);
24
- display: flex;
25
- }
26
-
27
- &-qrcode {
28
- background-color: #fff;
29
- width: 120px;
30
- height: 120px;
31
- position: absolute;
32
- top: -132px;
33
- right: -46px;
34
- padding: 12px;
35
- }
36
-
37
- &-code {
38
- position: relative;
39
- overflow: hidden;
40
- flex: 1 1;
41
- max-height: 700px;
42
- }
43
-
44
- &-code-hide {
45
- position: relative;
46
- overflow: hidden;
47
- display: none;
48
- }
49
-
50
- &-code-show {
51
- margin-top: 16px;
52
- display: block;
53
- }
54
-
55
- &-device {
56
- position: relative;
57
- flex: 0 0;
58
- border-left: 1px solid #e6e6e6;
59
- display: flex;
60
- flex-direction: column;
61
- iframe {
62
- border-bottom: 1px solid #e6e6e6;
63
- width: 360px;
64
- height: 100%;
65
- flex: auto;
66
- }
67
- }
68
-
69
- &-operations {
70
- button {
71
- width: 28px;
72
- height: 28px;
73
- padding: 0;
74
- text-align: center;
75
- border-radius: 50%;
76
- border: 1px solid transparent;
77
- background-color: var(--rp-c-bg-soft);
78
- margin-left: 14px;
79
-
80
- &:hover {
81
- background-color: var(--rp-preview-button-hover-bg);
82
- }
83
- }
84
-
85
- svg {
86
- display: inline-block;
87
- vertical-align: -2px;
88
- }
89
-
90
- &.mobile {
91
- display: flex;
92
- justify-content: flex-end;
93
- width: 100%;
94
- padding: 6px;
95
- }
96
-
97
- &.web {
98
- display: flex;
99
- justify-content: center;
100
- align-items: center;
101
- flex: none;
102
- }
103
- }
104
- }