@rspress/plugin-playground 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  exports.ids = [
3
- '301'
3
+ '52'
4
4
  ];
5
5
  exports.modules = {
6
- "../../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
+ "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7
7
  __webpack_require__.d(__webpack_exports__, {
8
8
  visit: ()=>_lib_index_js__WEBPACK_IMPORTED_MODULE_0__.Vn
9
9
  });
10
- var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js");
10
+ var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
11
11
  }
12
12
  };
@@ -6,15 +6,15 @@ var __webpack_modules__ = {
6
6
  "remark-gfm": function(module) {
7
7
  module.exports = import("remark-gfm");
8
8
  },
9
- "../../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__) {
9
+ "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10
10
  __webpack_require__.d(__webpack_exports__, {
11
11
  Vn: ()=>lib_visit
12
12
  });
13
13
  const convert = function(test) {
14
14
  if (null == test) return ok;
15
- if ('string' == typeof test) return typeFactory(test);
16
- if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
17
15
  if ('function' == typeof test) return castFactory(test);
16
+ if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
17
+ if ('string' == typeof test) return typeFactory(test);
18
18
  throw new Error('Expected function, string, or object as test');
19
19
  };
20
20
  function anyFactory(tests) {
@@ -24,15 +24,17 @@ var __webpack_modules__ = {
24
24
  return castFactory(any);
25
25
  function any(...parameters) {
26
26
  let index = -1;
27
- while(++index < checks.length)if (checks[index].call(this, ...parameters)) return true;
27
+ while(++index < checks.length)if (checks[index].apply(this, parameters)) return true;
28
28
  return false;
29
29
  }
30
30
  }
31
31
  function propsFactory(check) {
32
+ const checkAsRecord = check;
32
33
  return castFactory(all);
33
34
  function all(node) {
35
+ const nodeAsRecord = node;
34
36
  let key;
35
- for(key in check)if (node[key] !== check[key]) return false;
37
+ for(key in check)if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
36
38
  return true;
37
39
  }
38
40
  }
@@ -42,28 +44,32 @@ var __webpack_modules__ = {
42
44
  return node && node.type === check;
43
45
  }
44
46
  }
45
- function castFactory(check) {
46
- return assertion;
47
- function assertion(node, ...parameters) {
48
- return Boolean(node && 'object' == typeof node && 'type' in node && Boolean(check.call(this, node, ...parameters)));
47
+ function castFactory(testFunction) {
48
+ return check;
49
+ function check(value, index, parent) {
50
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, 'number' == typeof index ? index : void 0, parent || void 0));
49
51
  }
50
52
  }
51
53
  function ok() {
52
54
  return true;
53
55
  }
56
+ function looksLikeANode(value) {
57
+ return null !== value && 'object' == typeof value && 'type' in value;
58
+ }
54
59
  function color(d) {
55
60
  return '\u001B[33m' + d + '\u001B[39m';
56
61
  }
62
+ const empty = [];
57
63
  const CONTINUE = true;
58
64
  const EXIT = false;
59
65
  const SKIP = 'skip';
60
- const visitParents = function(tree, test, visitor, reverse) {
66
+ function visitParents(tree, test, visitor, reverse) {
67
+ let check;
61
68
  if ('function' == typeof test && 'function' != typeof visitor) {
62
69
  reverse = visitor;
63
70
  visitor = test;
64
- test = null;
65
- }
66
- const is = convert(test);
71
+ } else check = test;
72
+ const is = convert(check);
67
73
  const step = reverse ? -1 : 1;
68
74
  factory(tree, void 0, [])();
69
75
  function factory(node, index, parents) {
@@ -76,49 +82,61 @@ var __webpack_modules__ = {
76
82
  }
77
83
  return visit;
78
84
  function visit() {
79
- let result = [];
85
+ let result = empty;
80
86
  let subresult;
81
87
  let offset;
82
88
  let grandparents;
83
- if (!test || is(node, index, parents[parents.length - 1] || null)) {
89
+ if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
84
90
  result = toResult(visitor(node, parents));
85
91
  if (result[0] === EXIT) return result;
86
92
  }
87
- if (node.children && result[0] !== SKIP) {
88
- offset = (reverse ? node.children.length : -1) + step;
89
- grandparents = parents.concat(node);
90
- while(offset > -1 && offset < node.children.length){
91
- subresult = factory(node.children[offset], offset, grandparents)();
92
- if (subresult[0] === EXIT) return subresult;
93
- offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
93
+ if ('children' in node && node.children) {
94
+ const nodeAsParent = node;
95
+ if (nodeAsParent.children && result[0] !== SKIP) {
96
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
97
+ grandparents = parents.concat(nodeAsParent);
98
+ while(offset > -1 && offset < nodeAsParent.children.length){
99
+ const child = nodeAsParent.children[offset];
100
+ subresult = factory(child, offset, grandparents)();
101
+ if (subresult[0] === EXIT) return subresult;
102
+ offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
103
+ }
94
104
  }
95
105
  }
96
106
  return result;
97
107
  }
98
108
  }
99
- };
109
+ }
100
110
  function toResult(value) {
101
111
  if (Array.isArray(value)) return value;
102
112
  if ('number' == typeof value) return [
103
113
  CONTINUE,
104
114
  value
105
115
  ];
106
- return [
116
+ return null == value ? empty : [
107
117
  value
108
118
  ];
109
119
  }
110
- const lib_visit = function(tree, test, visitor, reverse) {
111
- if ('function' == typeof test && 'function' != typeof visitor) {
112
- reverse = visitor;
113
- visitor = test;
114
- test = null;
120
+ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
121
+ let reverse;
122
+ let test;
123
+ let visitor;
124
+ if ('function' == typeof testOrVisitor && 'function' != typeof visitorOrReverse) {
125
+ test = void 0;
126
+ visitor = testOrVisitor;
127
+ reverse = visitorOrReverse;
128
+ } else {
129
+ test = testOrVisitor;
130
+ visitor = visitorOrReverse;
131
+ reverse = maybeReverse;
115
132
  }
116
133
  visitParents(tree, test, overload, reverse);
117
134
  function overload(node, parents) {
118
135
  const parent = parents[parents.length - 1];
119
- return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
136
+ const index = parent ? parent.children.indexOf(node) : void 0;
137
+ return visitor(node, index, parent);
120
138
  }
121
- };
139
+ }
122
140
  }
123
141
  };
124
142
  var __webpack_module_cache__ = {};
@@ -205,7 +223,7 @@ var __webpack_exports__ = {};
205
223
  return u.replace(/\/\//g, '/');
206
224
  }
207
225
  const staticPath = external_node_path_default().join(__dirname, '../../../static');
208
- var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js");
226
+ var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
209
227
  const napi_namespaceObject = require("@oxidation-compiler/napi");
210
228
  var napi_default = /*#__PURE__*/ __webpack_require__.n(napi_namespaceObject);
211
229
  const parseImports = (code, sourceExt)=>{
@@ -341,7 +359,7 @@ var __webpack_exports__ = {};
341
359
  const isMdxFile = /\.mdx?$/.test(filepath);
342
360
  if (!isMdxFile) return;
343
361
  const { createProcessor } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@mdx-js/mdx"));
344
- const { visit } = await __webpack_require__.e("301").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js"));
362
+ const { visit } = await __webpack_require__.e("52").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js"));
345
363
  const { default: remarkGFM } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "remark-gfm"));
346
364
  try {
347
365
  const processor = createProcessor({
@@ -1,11 +1,11 @@
1
1
  export const __webpack_ids__ = [
2
- '301'
2
+ '52'
3
3
  ];
4
4
  export const __webpack_modules__ = {
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__) {
5
+ "../../node_modules/.pnpm/unist-util-visit@5.0.0/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
8
8
  });
9
- var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js");
9
+ var _lib_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
10
10
  }
11
11
  };
@@ -6,15 +6,15 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from
6
6
  import * as __WEBPACK_EXTERNAL_MODULE_rspack_plugin_virtual_module_609978fd__ from "rspack-plugin-virtual-module";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE__oxidation_compiler_napi_5e24345a__ from "@oxidation-compiler/napi";
8
8
  var __webpack_modules__ = {
9
- "../../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__) {
9
+ "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10
10
  __webpack_require__.d(__webpack_exports__, {
11
11
  Vn: ()=>lib_visit
12
12
  });
13
13
  const convert = function(test) {
14
14
  if (null == test) return ok;
15
- if ('string' == typeof test) return typeFactory(test);
16
- if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
17
15
  if ('function' == typeof test) return castFactory(test);
16
+ if ('object' == typeof test) return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
17
+ if ('string' == typeof test) return typeFactory(test);
18
18
  throw new Error('Expected function, string, or object as test');
19
19
  };
20
20
  function anyFactory(tests) {
@@ -24,15 +24,17 @@ var __webpack_modules__ = {
24
24
  return castFactory(any);
25
25
  function any(...parameters) {
26
26
  let index = -1;
27
- while(++index < checks.length)if (checks[index].call(this, ...parameters)) return true;
27
+ while(++index < checks.length)if (checks[index].apply(this, parameters)) return true;
28
28
  return false;
29
29
  }
30
30
  }
31
31
  function propsFactory(check) {
32
+ const checkAsRecord = check;
32
33
  return castFactory(all);
33
34
  function all(node) {
35
+ const nodeAsRecord = node;
34
36
  let key;
35
- for(key in check)if (node[key] !== check[key]) return false;
37
+ for(key in check)if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
36
38
  return true;
37
39
  }
38
40
  }
@@ -42,28 +44,32 @@ var __webpack_modules__ = {
42
44
  return node && node.type === check;
43
45
  }
44
46
  }
45
- function castFactory(check) {
46
- return assertion;
47
- function assertion(node, ...parameters) {
48
- return Boolean(node && 'object' == typeof node && 'type' in node && Boolean(check.call(this, node, ...parameters)));
47
+ function castFactory(testFunction) {
48
+ return check;
49
+ function check(value, index, parent) {
50
+ return Boolean(looksLikeANode(value) && testFunction.call(this, value, 'number' == typeof index ? index : void 0, parent || void 0));
49
51
  }
50
52
  }
51
53
  function ok() {
52
54
  return true;
53
55
  }
56
+ function looksLikeANode(value) {
57
+ return null !== value && 'object' == typeof value && 'type' in value;
58
+ }
54
59
  function color(d) {
55
60
  return '\u001B[33m' + d + '\u001B[39m';
56
61
  }
62
+ const empty = [];
57
63
  const CONTINUE = true;
58
64
  const EXIT = false;
59
65
  const SKIP = 'skip';
60
- const visitParents = function(tree, test, visitor, reverse) {
66
+ function visitParents(tree, test, visitor, reverse) {
67
+ let check;
61
68
  if ('function' == typeof test && 'function' != typeof visitor) {
62
69
  reverse = visitor;
63
70
  visitor = test;
64
- test = null;
65
- }
66
- const is = convert(test);
71
+ } else check = test;
72
+ const is = convert(check);
67
73
  const step = reverse ? -1 : 1;
68
74
  factory(tree, void 0, [])();
69
75
  function factory(node, index, parents) {
@@ -76,49 +82,61 @@ var __webpack_modules__ = {
76
82
  }
77
83
  return visit;
78
84
  function visit() {
79
- let result = [];
85
+ let result = empty;
80
86
  let subresult;
81
87
  let offset;
82
88
  let grandparents;
83
- if (!test || is(node, index, parents[parents.length - 1] || null)) {
89
+ if (!test || is(node, index, parents[parents.length - 1] || void 0)) {
84
90
  result = toResult(visitor(node, parents));
85
91
  if (result[0] === EXIT) return result;
86
92
  }
87
- if (node.children && result[0] !== SKIP) {
88
- offset = (reverse ? node.children.length : -1) + step;
89
- grandparents = parents.concat(node);
90
- while(offset > -1 && offset < node.children.length){
91
- subresult = factory(node.children[offset], offset, grandparents)();
92
- if (subresult[0] === EXIT) return subresult;
93
- offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
93
+ if ('children' in node && node.children) {
94
+ const nodeAsParent = node;
95
+ if (nodeAsParent.children && result[0] !== SKIP) {
96
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
97
+ grandparents = parents.concat(nodeAsParent);
98
+ while(offset > -1 && offset < nodeAsParent.children.length){
99
+ const child = nodeAsParent.children[offset];
100
+ subresult = factory(child, offset, grandparents)();
101
+ if (subresult[0] === EXIT) return subresult;
102
+ offset = 'number' == typeof subresult[1] ? subresult[1] : offset + step;
103
+ }
94
104
  }
95
105
  }
96
106
  return result;
97
107
  }
98
108
  }
99
- };
109
+ }
100
110
  function toResult(value) {
101
111
  if (Array.isArray(value)) return value;
102
112
  if ('number' == typeof value) return [
103
113
  CONTINUE,
104
114
  value
105
115
  ];
106
- return [
116
+ return null == value ? empty : [
107
117
  value
108
118
  ];
109
119
  }
110
- const lib_visit = function(tree, test, visitor, reverse) {
111
- if ('function' == typeof test && 'function' != typeof visitor) {
112
- reverse = visitor;
113
- visitor = test;
114
- test = null;
120
+ function lib_visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
121
+ let reverse;
122
+ let test;
123
+ let visitor;
124
+ if ('function' == typeof testOrVisitor && 'function' != typeof visitorOrReverse) {
125
+ test = void 0;
126
+ visitor = testOrVisitor;
127
+ reverse = visitorOrReverse;
128
+ } else {
129
+ test = testOrVisitor;
130
+ visitor = visitorOrReverse;
131
+ reverse = maybeReverse;
115
132
  }
116
133
  visitParents(tree, test, overload, reverse);
117
134
  function overload(node, parents) {
118
135
  const parent = parents[parents.length - 1];
119
- return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
136
+ const index = parent ? parent.children.indexOf(node) : void 0;
137
+ return visitor(node, index, parent);
120
138
  }
121
- };
139
+ }
122
140
  }
123
141
  };
124
142
  var __webpack_module_cache__ = {};
@@ -197,7 +215,7 @@ function normalizeUrl(u) {
197
215
  }
198
216
  var constant_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
199
217
  const staticPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(constant_dirname, '../../../static');
200
- var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js");
218
+ var lib = __webpack_require__("../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js");
201
219
  const parseImports = (code, sourceExt)=>{
202
220
  const parsed = __WEBPACK_EXTERNAL_MODULE__oxidation_compiler_napi_5e24345a__["default"].parseSync(code, {
203
221
  sourceType: 'module',
@@ -332,7 +350,7 @@ function pluginPlayground(options) {
332
350
  const isMdxFile = /\.mdx?$/.test(filepath);
333
351
  if (!isMdxFile) return;
334
352
  const { createProcessor } = await import("@mdx-js/mdx");
335
- const { visit } = await __webpack_require__.e("301").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js"));
353
+ const { visit } = await __webpack_require__.e("52").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/unist-util-visit@5.0.0/node_modules/unist-util-visit/index.js"));
336
354
  const { default: remarkGFM } = await import("remark-gfm");
337
355
  try {
338
356
  const processor = createProcessor({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-playground",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
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": {
@@ -29,34 +29,34 @@
29
29
  "static"
30
30
  ],
31
31
  "dependencies": {
32
- "@mdx-js/mdx": "2.3.0",
32
+ "@mdx-js/mdx": "^3.1.0",
33
33
  "@monaco-editor/react": "~4.7.0",
34
34
  "@oxidation-compiler/napi": "^0.2.0",
35
- "remark-gfm": "3.0.1",
35
+ "remark-gfm": "^4.0.1",
36
36
  "rspack-plugin-virtual-module": "0.1.13",
37
- "@rspress/shared": "2.0.0-alpha.8"
37
+ "@rspress/shared": "2.0.0-alpha.9"
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.0",
42
+ "@rslib/core": "0.6.1",
43
43
  "@types/babel__core": "^7.20.5",
44
44
  "@types/babel__standalone": "^7.1.9",
45
45
  "@types/babel__traverse": "^7.20.7",
46
- "@types/mdast": "^3.0.15",
46
+ "@types/mdast": "^4.0.4",
47
47
  "@types/node": "^18.11.17",
48
48
  "@types/react": "^18.3.20",
49
- "@types/react-dom": "^18.3.5",
50
- "mdast-util-mdx-jsx": "^2.1.4",
49
+ "@types/react-dom": "^18.3.6",
50
+ "mdast-util-mdx-jsx": "^3.2.0",
51
51
  "react": "^18.3.1",
52
52
  "react-dom": "^18.3.1",
53
53
  "react-router-dom": "^6.29.0",
54
54
  "typescript": "^5.8.2",
55
- "unified": "^10.1.2",
56
- "unist-util-visit": "^4.1.2"
55
+ "unified": "^11.0.5",
56
+ "unist-util-visit": "^5.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
- "@rspress/core": "^2.0.0-alpha.8",
59
+ "@rspress/core": "^2.0.0-alpha.9",
60
60
  "react": ">=17.0.0",
61
61
  "react-router-dom": "^6.8.1"
62
62
  },