@rspress/plugin-playground 1.29.0 → 1.31.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.
@@ -219,31 +219,25 @@ var init_unist_util_visit_parents = __esm({
219
219
  }
220
220
  });
221
221
 
222
- // ../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js
223
- var unist_util_visit_exports = {};
224
- __export(unist_util_visit_exports, {
225
- CONTINUE: () => CONTINUE,
226
- EXIT: () => EXIT,
227
- SKIP: () => SKIP,
228
- visit: () => visit
229
- });
222
+ // ../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js
230
223
  var visit;
231
- var init_unist_util_visit = __esm({
232
- "../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js"() {
224
+ var init_lib3 = __esm({
225
+ "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js"() {
233
226
  "use strict";
234
227
  init_unist_util_visit_parents();
235
228
  init_unist_util_visit_parents();
236
229
  visit = /**
237
230
  * @type {(
238
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types.js').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &
239
- * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types.js').BuildVisitor<Tree>, reverse?: boolean) => void)
231
+ * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
232
+ * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
240
233
  * )}
241
234
  */
242
235
  /**
243
236
  * @param {Node} tree
244
237
  * @param {Test} test
245
- * @param {import('./complex-types.js').Visitor} visitor
246
- * @param {boolean} [reverse]
238
+ * @param {Visitor} visitor
239
+ * @param {boolean | null | undefined} [reverse]
240
+ * @returns {void}
247
241
  */
248
242
  function(tree, test, visitor, reverse) {
249
243
  if (typeof test === "function" && typeof visitor !== "function") {
@@ -264,6 +258,21 @@ var init_unist_util_visit = __esm({
264
258
  }
265
259
  });
266
260
 
261
+ // ../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js
262
+ var unist_util_visit_exports = {};
263
+ __export(unist_util_visit_exports, {
264
+ CONTINUE: () => CONTINUE,
265
+ EXIT: () => EXIT,
266
+ SKIP: () => SKIP,
267
+ visit: () => visit
268
+ });
269
+ var init_unist_util_visit = __esm({
270
+ "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js"() {
271
+ "use strict";
272
+ init_lib3();
273
+ }
274
+ });
275
+
267
276
  // src/cli/index.ts
268
277
  var cli_exports = {};
269
278
  __export(cli_exports, {
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0MA,SAAS,WAAW,OAAO;AAEzB,QAAM,SAAS,CAAC;AAChB,MAAI,QAAQ;AAEZ,SAAO,EAAE,QAAQ,MAAM,QAAQ;AAC7B,WAAO,KAAK,IAAI,QAAQ,MAAM,KAAK,CAAC;AAAA,EACtC;AAEA,SAAO,YAAY,GAAG;AAOtB,WAAS,OAAO,YAAY;AAC1B,QAAIA,SAAQ;AAEZ,WAAO,EAAEA,SAAQ,OAAO,QAAQ;AAC9B,UAAI,OAAOA,MAAK,EAAE,KAAK,MAAM,GAAG,UAAU;AAAG,eAAO;AAAA,IACtD;AAEA,WAAO;AAAA,EACT;AACF;AAQA,SAAS,aAAa,OAAO;AAC3B,SAAO,YAAY,GAAG;AAMtB,WAAS,IAAI,MAAM;AAEjB,QAAI;AAEJ,SAAK,OAAO,OAAO;AAEjB,UAAI,KAAK,GAAG,MAAM,MAAM,GAAG;AAAG,eAAO;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;AAQA,SAAS,YAAY,OAAO;AAC1B,SAAO,YAAY,IAAI;AAKvB,WAAS,KAAK,MA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AA+B,KAAK,UAAU,aAAa;AAAA,UAC3D,0BAA0B,KAAK,UAAU,QAAQ;AAAA,QACnD;AAAA,QACA,SAAS,KAAC,wBAAK,WAAW,MAAM,MAAM,IAAI,CAAC;AAAA,MAC7C;AAAA,MACA,MAAM;AAAA,QACJ,MAAM,SAAS,IAAI,UAAQ;AAAA,UACzB,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,YACL,KAAK;AAAA,YACL,MAAM;AAAA,YACN,IAAI;AAAA,UACN;AAAA,QACF,EAAE;AAAA,MACJ;AAAA,MACA,OAAO;AAAA;AAAA;AAAA,QAGL,QAAQ;AAAA,UACN,SAAS,CAAC,uBAAuB;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,QACb,CAAC,cAAc,EAAE,cAAc,gBAAgB,kBAAkB,CAAC;AAAA,MACpE;AAAA,MACA,kBAAkB;AAAA,QAChB,SACI,SACA,kBAAAE,QAAK,KAAK,YAAY,qBAAqB,gBAAgB;AAAA,MACjE;AAAA,IACF;AAAA,IACA,cAAc,kBAAAA,QAAK,KAAK,YAAY,iBAAiB,SAAS;AAAA,EAChE;AACF","names":["index","init_lib","is","visit","import_node_path","path","oxc","routeMeta","fs","code"],"ignoreList":[],"sources":["../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js","../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js","../../../src/cli/index.ts","../../../src/cli/constant.ts","../../../src/cli/utils.ts","../../../src/cli/remarkPlugin.ts","../../../src/web/constant.ts","../../../src/web/utils.ts"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @typedef {Record<string, unknown>} Props\n * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test\n * Check for an arbitrary node, unaware of TypeScript inferral.\n *\n * @callback TestFunctionAnything\n * Check if a node passes a test, unaware of TypeScript inferral.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | void}\n * Whether this node passes the test.\n */\n\n/**\n * @template {Node} Kind\n * Node type.\n * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest\n * Check for a node that can be inferred by TypeScript.\n */\n\n/**\n * Check if a node passes a certain test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback TestFunctionPredicate\n * Complex test function for a node that can be inferred by TypeScript.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this node passes the test.\n */\n\n/**\n * @callback AssertAnything\n * Check that an arbitrary value is a node, unaware of TypeScript inferral.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if a node is a node and passes a certain node test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback AssertPredicate\n * Check that an arbitrary value is a specific node, aware of TypeScript.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param node\n * Thing to check, typically `Node`.\n * @param test\n * A check for a specific node.\n * @param index\n * The node’s position in its parent.\n * @param parent\n * The node’s parent.\n * @returns\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n /**\n * @type {(\n * (() => false) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &\n * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &\n * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function is(node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n // @ts-expect-error Looks like a node.\n return node && node.type && typeof node.type === 'string'\n ? Boolean(check.call(context, node, index, parent))\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns\n * An assertion.\n */\nexport const convert =\n /**\n * @type {(\n * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &\n * ((test?: Test) => AssertAnything)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {AssertAnything}\n */\n function (test) {\n if (test === undefined || test === null) {\n return ok\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<string | Props | TestFunctionAnything>} tests\n * @returns {AssertAnything}\n */\nfunction anyFactory(tests) {\n /** @type {Array<AssertAnything>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].call(this, ...parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {AssertAnything}\n */\nfunction propsFactory(check) {\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n /** @type {string} */\n let key\n\n for (key in check) {\n // @ts-expect-error: hush, it sure works as an index.\n if (node[key] !== check[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {AssertAnything}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunctionAnything} check\n * @returns {AssertAnything}\n */\nfunction castFactory(check) {\n return assertion\n\n /**\n * @this {unknown}\n * @param {unknown} node\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function assertion(node, ...parameters) {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n // @ts-expect-error: fine.\n Boolean(check.call(this, node, ...parameters))\n )\n }\n}\n\nfunction ok() {\n return true\n}\n","/**\n * @typedef {import('./lib/index.js').Test} Test\n * @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything\n * @typedef {import('./lib/index.js').AssertAnything} AssertAnything\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate\n */\n\nexport {is, convert} from './lib/index.js'\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return '\\u001B[33m' + d + '\\u001B[39m'\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visitParents} from './lib/index.js'\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n * @typedef {import('./complex-types.js').Visitor} Visitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit children of tree which pass test.\n *\n * @param tree\n * Tree to walk\n * @param [test]\n * `unist-util-is`-compatible test\n * @param visitor\n * Function called for nodes that pass `test`.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of preorder (NLR) (default).\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types.js').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types.js').BuildVisitor<Tree>, reverse?: boolean) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {import('./complex-types.js').Visitor} visitor\n * @param {boolean} [reverse]\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n","import path, { join } from 'node:path';\nimport type { RouteMeta, RspressPlugin } from '@rspress/shared';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport type {\n loader,\n EditorProps as MonacoEditorProps,\n} from '@monaco-editor/react';\nimport type { Code } from 'mdast';\nimport { staticPath } from './constant';\nimport { getNodeAttribute, parseImports } from './utils';\nimport { remarkPlugin } from './remarkPlugin';\nimport { DEFAULT_BABEL_URL, DEFAULT_MONACO_URL } from '@/web/constant';\nimport { normalizeUrl } from '@/web/utils';\n\ninterface PlaygroundOptions {\n render: string;\n include: Array<string | [string, string]>;\n\n defaultDirection: 'horizontal' | 'vertical';\n editorPosition: 'left' | 'right';\n\n babelUrl: string;\n\n monacoLoader: Parameters<typeof loader.config>[0];\n monacoOptions: MonacoEditorProps['options'];\n /**\n * determine how to handle a internal code block without meta\n * @default 'playground'\n */\n defaultRenderMode?: 'pure' | 'playground';\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeMeta: RouteMeta[];\n\n/**\n * The plugin is used to preview component.\n */\nexport function pluginPlayground(\n options?: Partial<PlaygroundOptions>,\n): RspressPlugin {\n const {\n render = '',\n include,\n defaultDirection = 'horizontal',\n editorPosition = 'left',\n babelUrl = DEFAULT_BABEL_URL,\n monacoLoader = {},\n monacoOptions = {},\n defaultRenderMode = 'playground',\n } = options || {};\n\n const playgroundVirtualModule = new RspackVirtualModulePlugin({});\n const getRouteMeta = () => routeMeta;\n\n if (render && !/Playground\\.(jsx?|tsx?)$/.test(render)) {\n throw new Error(\n '[Playground]: render should ends with Playground.(jsx?|tsx?)',\n );\n }\n\n const preloads: string[] = [];\n const monacoPrefix = monacoLoader.paths?.vs || DEFAULT_MONACO_URL;\n preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));\n preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));\n\n return {\n name: '@rspress/plugin-playground',\n config(config, { removePlugin }) {\n config.markdown = config.markdown || {};\n config.markdown.mdxRs = false;\n // The preview and playground plugin are mutually conflicting.\n removePlugin('@rspress/plugin-preview');\n return config;\n },\n async routeGenerated(routes: RouteMeta[]) {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n\n // init routeMeta\n routeMeta = routes;\n\n const files = routes.map(route => route.absolutePath);\n\n const imports: Record<string, string> = {};\n\n // scan all demos, and generate imports\n await Promise.all(\n files.map(async (filepath, _index) => {\n const isMdxFile = /\\.mdx?$/.test(filepath);\n if (!isMdxFile) {\n return;\n }\n const { createProcessor } = await import('@mdx-js/mdx');\n const { visit } = await import('unist-util-visit');\n const { default: remarkGFM } = await import('remark-gfm');\n try {\n const processor = createProcessor({\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [remarkGFM],\n });\n const source = await fs.readFile(filepath, 'utf-8');\n const ast = processor.parse(source);\n\n visit(ast, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(path.dirname(filepath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n\n const thisImports = parseImports(code, path.extname(demoPath));\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n\n visit(ast, 'code', (node: Code) => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const { value, meta } = node;\n const hasPureMeta = meta?.includes('pure');\n const hasPlaygroundMeta = meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const thisImports = parseImports(value, node.lang);\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n } catch (e) {\n console.error(e);\n throw e;\n }\n }),\n );\n\n if (include) {\n include.forEach(item => {\n if (typeof item === 'string') {\n imports[item] = item;\n } else {\n imports[item[0]] = item[1];\n }\n });\n }\n\n if (!('react' in imports)) {\n imports.react = 'react';\n }\n\n const importKeys = Object.keys(imports);\n const code = [\n ...importKeys.map(\n (x, index) => `import * as i_${index} from '${imports[x]}';`,\n ),\n 'const imports = new Map();',\n ...importKeys.map((x, index) => `imports.set('${x}', i_${index});`),\n 'function getImport(name, getDefault) {',\n ' if (!imports.has(name)) {',\n ' throw new Error(\"Module \" + name + \" not found\");',\n ' }',\n ' const result = imports.get(name);',\n ' if (getDefault && typeof result === \"object\") {',\n ' return result.default || result;',\n ' }',\n ' return result;',\n '}',\n 'export { imports };',\n 'export default getImport;',\n ].join('\\n');\n\n // console.log('playground-imports', code);\n\n playgroundVirtualModule.writeModule('_rspress_playground_imports', code);\n },\n builderConfig: {\n source: {\n define: {\n __PLAYGROUND_DIRECTION__: JSON.stringify(defaultDirection),\n __PLAYGROUND_MONACO_LOADER__: JSON.stringify(monacoLoader),\n __PLAYGROUND_MONACO_OPTIONS__: JSON.stringify(monacoOptions),\n __PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl),\n },\n include: [join(__dirname, '..', '..', '..')],\n },\n html: {\n tags: preloads.map(url => ({\n tag: 'link',\n head: true,\n attrs: {\n rel: 'preload',\n href: url,\n as: 'script',\n },\n })),\n },\n tools: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore\n rspack: {\n plugins: [playgroundVirtualModule],\n },\n },\n },\n markdown: {\n remarkPlugins: [\n [remarkPlugin, { getRouteMeta, editorPosition, defaultRenderMode }],\n ],\n globalComponents: [\n render\n ? render\n : path.join(staticPath, 'global-components', 'Playground.tsx'),\n ],\n },\n globalStyles: path.join(staticPath, 'global-styles', 'web.css'),\n };\n}\n","import path from 'node:path';\n\nexport const staticPath = path.join(__dirname, '../../../static');\n","/* eslint-disable consistent-return */\nimport type { Program } from '@babel/types';\nimport oxc from '@oxidation-compiler/napi';\n\nexport const parseImports = (code: string, sourceExt: string) => {\n const parsed = oxc.parseSync(code, {\n sourceType: 'module',\n sourceFilename: `index.${sourceExt}`,\n });\n\n const ast = JSON.parse(parsed.program) as Program;\n\n const result: string[] = [];\n\n // oxc didn't have \"traverse\", so it currently only scans the first level\n // (generally, demos are not too complicated, right?)\n ast.body.forEach(statement => {\n if (statement.type === 'ImportDeclaration') {\n result.push(statement.source.value);\n }\n });\n\n return result;\n};\n\nexport const getNodeAttribute = (\n node: any,\n attrName: string,\n): string | undefined => {\n return node.attributes.find(\n (attr: { name: string; value: string }) => attr.name === attrName,\n )?.value;\n};\n\nexport const getNodeMeta = (\n node: any,\n metaName: string,\n): string | undefined => {\n if (!node.meta) {\n return;\n }\n const meta: string[] = node.meta.split(' ');\n const item: string | undefined = meta.find((x: string) =>\n x.startsWith(metaName),\n );\n if (item?.startsWith(`${metaName}=`)) {\n return item.substring(metaName.length + 1);\n }\n return item;\n};\n","import { dirname, join, resolve } from 'node:path';\nimport { visit } from 'unist-util-visit';\nimport fs from '@rspress/shared/fs-extra';\nimport type { RouteMeta } from '@rspress/shared';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport { getNodeAttribute, getNodeMeta } from './utils';\n\nfunction createPlaygroundNode(\n currentNode: any,\n attrs: Array<[string, string]>,\n) {\n Object.assign(currentNode, {\n type: 'mdxJsxFlowElement',\n name: 'Playground',\n attributes: attrs.map(it => ({\n type: 'mdxJsxAttribute',\n name: it[0],\n value: it[1],\n })),\n });\n}\n\ninterface RemarkPluginProps {\n getRouteMeta: () => RouteMeta[];\n editorPosition: 'left' | 'right';\n defaultRenderMode: 'pure' | 'playground';\n}\n\n/**\n * remark plugin to transform code to demo\n */\nexport const remarkPlugin: Plugin<[RemarkPluginProps], Root> = ({\n getRouteMeta,\n editorPosition,\n defaultRenderMode,\n}) => {\n const routeMeta = getRouteMeta();\n\n return (tree, vfile) => {\n const route = routeMeta.find(\n meta =>\n resolve(meta.absolutePath) === resolve(vfile.path || vfile.history[0]),\n );\n if (!route) {\n return;\n }\n\n // 1. External demo , use <code src=\"foo\" /> to declare demo\n visit(tree, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(dirname(route.absolutePath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n const direction = getNodeAttribute(node, 'direction') || '';\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n const language = src.substr(src.lastIndexOf('.') + 1);\n createPlaygroundNode(node, [\n ['code', code],\n ['language', language],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n\n // 2. Internal demo, use ```j/tsx to declare demo\n visit(tree, 'code', node => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const hasPureMeta = node?.meta?.includes('pure');\n const hasPlaygroundMeta = node?.meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const direction = getNodeMeta(node, 'direction') || '';\n\n createPlaygroundNode(node, [\n ['code', node.value],\n ['language', node.lang],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n };\n};\n","export const DEFAULT_BABEL_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.22.20/babel.min.js';\n\nexport const DEFAULT_MONACO_URL =\n 'https://cdnjs.cloudflare.com/ajax/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A,OAAO;AAAA;AAAA;AAAA,QAGL,QAAQ;AAAA,UACN,SAAS,CAAC,uBAAuB;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,QACb,CAAC,cAAc,EAAE,cAAc,gBAAgB,kBAAkB,CAAC;AAAA,MACpE;AAAA,MACA,kBAAkB;AAAA,QAChB,SACI,SACA,kBAAAE,QAAK,KAAK,YAAY,qBAAqB,gBAAgB;AAAA,MACjE;AAAA,IACF;AAAA,IACA,cAAc,kBAAAA,QAAK,KAAK,YAAY,iBAAiB,SAAS;AAAA,EAChE;AACF","names":["index","init_lib","is","visit","import_node_path","path","oxc","routeMeta","fs","code"],"ignoreList":[],"sources":["../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js","../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js","../../../src/cli/index.ts","../../../src/cli/constant.ts","../../../src/cli/utils.ts","../../../src/cli/remarkPlugin.ts","../../../src/web/constant.ts","../../../src/web/utils.ts"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @typedef {Record<string, unknown>} Props\n * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test\n * Check for an arbitrary node, unaware of TypeScript inferral.\n *\n * @callback TestFunctionAnything\n * Check if a node passes a test, unaware of TypeScript inferral.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | void}\n * Whether this node passes the test.\n */\n\n/**\n * @template {Node} Kind\n * Node type.\n * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest\n * Check for a node that can be inferred by TypeScript.\n */\n\n/**\n * Check if a node passes a certain test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback TestFunctionPredicate\n * Complex test function for a node that can be inferred by TypeScript.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this node passes the test.\n */\n\n/**\n * @callback AssertAnything\n * Check that an arbitrary value is a node, unaware of TypeScript inferral.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if a node is a node and passes a certain node test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback AssertPredicate\n * Check that an arbitrary value is a specific node, aware of TypeScript.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param node\n * Thing to check, typically `Node`.\n * @param test\n * A check for a specific node.\n * @param index\n * The node’s position in its parent.\n * @param parent\n * The node’s parent.\n * @returns\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n /**\n * @type {(\n * (() => false) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &\n * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &\n * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function is(node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n // @ts-expect-error Looks like a node.\n return node && node.type && typeof node.type === 'string'\n ? Boolean(check.call(context, node, index, parent))\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns\n * An assertion.\n */\nexport const convert =\n /**\n * @type {(\n * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &\n * ((test?: Test) => AssertAnything)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {AssertAnything}\n */\n function (test) {\n if (test === undefined || test === null) {\n return ok\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<string | Props | TestFunctionAnything>} tests\n * @returns {AssertAnything}\n */\nfunction anyFactory(tests) {\n /** @type {Array<AssertAnything>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].call(this, ...parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {AssertAnything}\n */\nfunction propsFactory(check) {\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n /** @type {string} */\n let key\n\n for (key in check) {\n // @ts-expect-error: hush, it sure works as an index.\n if (node[key] !== check[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {AssertAnything}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunctionAnything} check\n * @returns {AssertAnything}\n */\nfunction castFactory(check) {\n return assertion\n\n /**\n * @this {unknown}\n * @param {unknown} node\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function assertion(node, ...parameters) {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n // @ts-expect-error: fine.\n Boolean(check.call(this, node, ...parameters))\n )\n }\n}\n\nfunction ok() {\n return true\n}\n","/**\n * @typedef {import('./lib/index.js').Test} Test\n * @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything\n * @typedef {import('./lib/index.js').AssertAnything} AssertAnything\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate\n */\n\nexport {is, convert} from './lib/index.js'\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return '\\u001B[33m' + d + '\\u001B[39m'\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visitParents} from './lib/index.js'\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * Check if `Child` can be a child of `Ancestor`.\n *\n * Returns the ancestor when `Child` can be a child of `Ancestor`, or returns\n * `never`.\n *\n * @template {Node} Ancestor\n * Node type.\n * @template {Node} Child\n * Node type.\n * @typedef {(\n * Ancestor extends Parent\n * ? Child extends Ancestor['children'][number]\n * ? Ancestor\n * : never\n * : never\n * )} ParentsOf\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends Node ? number | null : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends Node ? Ancestor | null : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Visited\n * Node type.\n * @template {Parent} Ancestor\n * Parent type.\n * @typedef {Visitor<Visited, ParentsOf<Ancestor, Visited>>} BuildVisitorFromMatch\n */\n\n/**\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n * @typedef {(\n * BuildVisitorFromMatch<\n * import('unist-util-visit-parents/complex-types.js').Matches<Descendant, Check>,\n * Extract<Descendant, Parent>\n * >\n * )} BuildVisitorFromDescendants\n */\n\n/**\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} [Tree=Node]\n * Node type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {(\n * BuildVisitorFromDescendants<\n * import('unist-util-visit-parents/complex-types.js').InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'\n","import path, { join } from 'node:path';\nimport type { RouteMeta, RspressPlugin } from '@rspress/shared';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport type {\n loader,\n EditorProps as MonacoEditorProps,\n} from '@monaco-editor/react';\nimport type { Code } from 'mdast';\nimport { staticPath } from './constant';\nimport { getNodeAttribute, parseImports } from './utils';\nimport { remarkPlugin } from './remarkPlugin';\nimport { DEFAULT_BABEL_URL, DEFAULT_MONACO_URL } from '@/web/constant';\nimport { normalizeUrl } from '@/web/utils';\n\ninterface PlaygroundOptions {\n render: string;\n include: Array<string | [string, string]>;\n\n defaultDirection: 'horizontal' | 'vertical';\n editorPosition: 'left' | 'right';\n\n babelUrl: string;\n\n monacoLoader: Parameters<typeof loader.config>[0];\n monacoOptions: MonacoEditorProps['options'];\n /**\n * determine how to handle a internal code block without meta\n * @default 'playground'\n */\n defaultRenderMode?: 'pure' | 'playground';\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeMeta: RouteMeta[];\n\n/**\n * The plugin is used to preview component.\n */\nexport function pluginPlayground(\n options?: Partial<PlaygroundOptions>,\n): RspressPlugin {\n const {\n render = '',\n include,\n defaultDirection = 'horizontal',\n editorPosition = 'left',\n babelUrl = DEFAULT_BABEL_URL,\n monacoLoader = {},\n monacoOptions = {},\n defaultRenderMode = 'playground',\n } = options || {};\n\n const playgroundVirtualModule = new RspackVirtualModulePlugin({});\n const getRouteMeta = () => routeMeta;\n\n if (render && !/Playground\\.(jsx?|tsx?)$/.test(render)) {\n throw new Error(\n '[Playground]: render should ends with Playground.(jsx?|tsx?)',\n );\n }\n\n const preloads: string[] = [];\n const monacoPrefix = monacoLoader.paths?.vs || DEFAULT_MONACO_URL;\n preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));\n preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));\n\n return {\n name: '@rspress/plugin-playground',\n config(config, { removePlugin }) {\n config.markdown = config.markdown || {};\n config.markdown.mdxRs = false;\n // The preview and playground plugin are mutually conflicting.\n removePlugin('@rspress/plugin-preview');\n return config;\n },\n async routeGenerated(routes: RouteMeta[]) {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n\n // init routeMeta\n routeMeta = routes;\n\n const files = routes.map(route => route.absolutePath);\n\n const imports: Record<string, string> = {};\n\n // scan all demos, and generate imports\n await Promise.all(\n files.map(async (filepath, _index) => {\n const isMdxFile = /\\.mdx?$/.test(filepath);\n if (!isMdxFile) {\n return;\n }\n const { createProcessor } = await import('@mdx-js/mdx');\n const { visit } = await import('unist-util-visit');\n const { default: remarkGFM } = await import('remark-gfm');\n try {\n const processor = createProcessor({\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [remarkGFM],\n });\n const source = await fs.readFile(filepath, 'utf-8');\n const ast = processor.parse(source);\n\n visit(ast, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(path.dirname(filepath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n\n const thisImports = parseImports(code, path.extname(demoPath));\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n\n visit(ast, 'code', (node: Code) => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const { value, meta } = node;\n const hasPureMeta = meta?.includes('pure');\n const hasPlaygroundMeta = meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const thisImports = parseImports(value, node.lang);\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n } catch (e) {\n console.error(e);\n throw e;\n }\n }),\n );\n\n if (include) {\n include.forEach(item => {\n if (typeof item === 'string') {\n imports[item] = item;\n } else {\n imports[item[0]] = item[1];\n }\n });\n }\n\n if (!('react' in imports)) {\n imports.react = 'react';\n }\n\n const importKeys = Object.keys(imports);\n const code = [\n ...importKeys.map(\n (x, index) => `import * as i_${index} from '${imports[x]}';`,\n ),\n 'const imports = new Map();',\n ...importKeys.map((x, index) => `imports.set('${x}', i_${index});`),\n 'function getImport(name, getDefault) {',\n ' if (!imports.has(name)) {',\n ' throw new Error(\"Module \" + name + \" not found\");',\n ' }',\n ' const result = imports.get(name);',\n ' if (getDefault && typeof result === \"object\") {',\n ' return result.default || result;',\n ' }',\n ' return result;',\n '}',\n 'export { imports };',\n 'export default getImport;',\n ].join('\\n');\n\n // console.log('playground-imports', code);\n\n playgroundVirtualModule.writeModule('_rspress_playground_imports', code);\n },\n builderConfig: {\n source: {\n define: {\n __PLAYGROUND_DIRECTION__: JSON.stringify(defaultDirection),\n __PLAYGROUND_MONACO_LOADER__: JSON.stringify(monacoLoader),\n __PLAYGROUND_MONACO_OPTIONS__: JSON.stringify(monacoOptions),\n __PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl),\n },\n include: [join(__dirname, '..', '..', '..')],\n },\n html: {\n tags: preloads.map(url => ({\n tag: 'link',\n head: true,\n attrs: {\n rel: 'preload',\n href: url,\n as: 'script',\n },\n })),\n },\n tools: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore\n rspack: {\n plugins: [playgroundVirtualModule],\n },\n },\n },\n markdown: {\n remarkPlugins: [\n [remarkPlugin, { getRouteMeta, editorPosition, defaultRenderMode }],\n ],\n globalComponents: [\n render\n ? render\n : path.join(staticPath, 'global-components', 'Playground.tsx'),\n ],\n },\n globalStyles: path.join(staticPath, 'global-styles', 'web.css'),\n };\n}\n","import path from 'node:path';\n\nexport const staticPath = path.join(__dirname, '../../../static');\n","/* eslint-disable consistent-return */\nimport type { Program } from '@babel/types';\nimport oxc from '@oxidation-compiler/napi';\n\nexport const parseImports = (code: string, sourceExt: string) => {\n const parsed = oxc.parseSync(code, {\n sourceType: 'module',\n sourceFilename: `index.${sourceExt}`,\n });\n\n const ast = JSON.parse(parsed.program) as Program;\n\n const result: string[] = [];\n\n // oxc didn't have \"traverse\", so it currently only scans the first level\n // (generally, demos are not too complicated, right?)\n ast.body.forEach(statement => {\n if (statement.type === 'ImportDeclaration') {\n result.push(statement.source.value);\n }\n });\n\n return result;\n};\n\nexport const getNodeAttribute = (\n node: any,\n attrName: string,\n): string | undefined => {\n return node.attributes.find(\n (attr: { name: string; value: string }) => attr.name === attrName,\n )?.value;\n};\n\nexport const getNodeMeta = (\n node: any,\n metaName: string,\n): string | undefined => {\n if (!node.meta) {\n return;\n }\n const meta: string[] = node.meta.split(' ');\n const item: string | undefined = meta.find((x: string) =>\n x.startsWith(metaName),\n );\n if (item?.startsWith(`${metaName}=`)) {\n return item.substring(metaName.length + 1);\n }\n return item;\n};\n","import { dirname, join, resolve } from 'node:path';\nimport { visit } from 'unist-util-visit';\nimport fs from '@rspress/shared/fs-extra';\nimport type { RouteMeta } from '@rspress/shared';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport { getNodeAttribute, getNodeMeta } from './utils';\n\nfunction createPlaygroundNode(\n currentNode: any,\n attrs: Array<[string, string]>,\n) {\n Object.assign(currentNode, {\n type: 'mdxJsxFlowElement',\n name: 'Playground',\n attributes: attrs.map(it => ({\n type: 'mdxJsxAttribute',\n name: it[0],\n value: it[1],\n })),\n });\n}\n\ninterface RemarkPluginProps {\n getRouteMeta: () => RouteMeta[];\n editorPosition: 'left' | 'right';\n defaultRenderMode: 'pure' | 'playground';\n}\n\n/**\n * remark plugin to transform code to demo\n */\nexport const remarkPlugin: Plugin<[RemarkPluginProps], Root> = ({\n getRouteMeta,\n editorPosition,\n defaultRenderMode,\n}) => {\n const routeMeta = getRouteMeta();\n\n return (tree, vfile) => {\n const route = routeMeta.find(\n meta =>\n resolve(meta.absolutePath) === resolve(vfile.path || vfile.history[0]),\n );\n if (!route) {\n return;\n }\n\n // 1. External demo , use <code src=\"foo\" /> to declare demo\n visit(tree, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(dirname(route.absolutePath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n const direction = getNodeAttribute(node, 'direction') || '';\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n const language = src.substr(src.lastIndexOf('.') + 1);\n createPlaygroundNode(node, [\n ['code', code],\n ['language', language],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n\n // 2. Internal demo, use ```j/tsx to declare demo\n visit(tree, 'code', node => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const hasPureMeta = node?.meta?.includes('pure');\n const hasPlaygroundMeta = node?.meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const direction = getNodeMeta(node, 'direction') || '';\n\n createPlaygroundNode(node, [\n ['code', node.value],\n ['language', node.lang],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n };\n};\n","export const DEFAULT_BABEL_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.22.20/babel.min.js';\n\nexport const DEFAULT_MONACO_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs';\n","export function normalizeUrl(u: string) {\n return u.replace(/\\/\\//g, '/');\n}\n"]}
@@ -197,31 +197,25 @@ var init_unist_util_visit_parents = __esm({
197
197
  }
198
198
  });
199
199
 
200
- // ../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js
201
- var unist_util_visit_exports = {};
202
- __export(unist_util_visit_exports, {
203
- CONTINUE: () => CONTINUE,
204
- EXIT: () => EXIT,
205
- SKIP: () => SKIP,
206
- visit: () => visit
207
- });
200
+ // ../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js
208
201
  var visit;
209
- var init_unist_util_visit = __esm({
210
- "../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js"() {
202
+ var init_lib3 = __esm({
203
+ "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js"() {
211
204
  "use strict";
212
205
  init_unist_util_visit_parents();
213
206
  init_unist_util_visit_parents();
214
207
  visit = /**
215
208
  * @type {(
216
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types.js').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &
217
- * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types.js').BuildVisitor<Tree>, reverse?: boolean) => void)
209
+ * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
210
+ * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
218
211
  * )}
219
212
  */
220
213
  /**
221
214
  * @param {Node} tree
222
215
  * @param {Test} test
223
- * @param {import('./complex-types.js').Visitor} visitor
224
- * @param {boolean} [reverse]
216
+ * @param {Visitor} visitor
217
+ * @param {boolean | null | undefined} [reverse]
218
+ * @returns {void}
225
219
  */
226
220
  function(tree, test, visitor, reverse) {
227
221
  if (typeof test === "function" && typeof visitor !== "function") {
@@ -242,6 +236,21 @@ var init_unist_util_visit = __esm({
242
236
  }
243
237
  });
244
238
 
239
+ // ../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js
240
+ var unist_util_visit_exports = {};
241
+ __export(unist_util_visit_exports, {
242
+ CONTINUE: () => CONTINUE,
243
+ EXIT: () => EXIT,
244
+ SKIP: () => SKIP,
245
+ visit: () => visit
246
+ });
247
+ var init_unist_util_visit = __esm({
248
+ "../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js"() {
249
+ "use strict";
250
+ init_lib3();
251
+ }
252
+ });
253
+
245
254
  // src/cli/index.ts
246
255
  import path2, { join as join2 } from "path";
247
256
  import { RspackVirtualModulePlugin } from "rspack-plugin-virtual-module";
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;AA0MA,SAAS,WAAW,OAAO;AAEzB,QAAM,SAAS,CAAC;AAChB,MAAI,QAAQ;AAEZ,SAAO,EAAE,QAAQ,MAAM,QAAQ;AAC7B,WAAO,KAAK,IAAI,QAAQ,MAAM,KAAK,CAAC;AAAA,EACtC;AAEA,SAAO,YAAY,GAAG;AAOtB,WAAS,OAAO,YAAY;AAC1B,QAAIA,SAAQ;AAEZ,WAAO,EAAEA,SAAQ,OAAO,QAAQ;AAC9B,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A,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,EAAE,KAAK,IAAI;AAIX,8BAAwB,YAAY,+BAA+B,IAAI;AAAA,IACzE;AAAA,IACA,eAAe;AAAA,MACb,QAAQ;AAAA,QACN,QAAQ;AAAA,UACN,0BAA0B,KAAK,UAAU,gBAAgB;AAAA,UACzD,8BAA8B,KAAK,UAAU,YAAY;AAAA,UACzD,+BAA+B,KAAK,UAAU,aAAa;AAAA,UAC3D,0BAA0B,KAAK,UAAU,QAAQ;AAAA,QACnD;AAAA,QACA,SAAS,CAACE,MAAK,WAAW,MAAM,MAAM,IAAI,CAAC;AAAA,MAC7C;AAAA,MACA,MAAM;AAAA,QACJ,MAAM,SAAS,IAAI,UAAQ;AAAA,UACzB,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,YACL,KAAK;AAAA,YACL,MAAM;AAAA,YACN,IAAI;AAAA,UACN;AAAA,QACF,EAAE;AAAA,MACJ;AAAA,MACA,OAAO;AAAA;AAAA;AAAA,QAGL,QAAQ;AAAA,UACN,SAAS,CAAC,uBAAuB;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,QACb,CAAC,cAAc,EAAE,cAAc,gBAAgB,kBAAkB,CAAC;AAAA,MACpE;AAAA,MACA,kBAAkB;AAAA,QAChB,SACI,SACAD,MAAK,KAAK,YAAY,qBAAqB,gBAAgB;AAAA,MACjE;AAAA,IACF;AAAA,IACA,cAAcA,MAAK,KAAK,YAAY,iBAAiB,SAAS;AAAA,EAChE;AACF","names":["index","init_lib","is","visit","path","join","routeMeta","fs","code"],"ignoreList":[],"sources":["../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js","../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js","../../../src/cli/index.ts","../../../src/cli/constant.ts","../../../src/cli/utils.ts","../../../src/cli/remarkPlugin.ts","../../../src/web/constant.ts","../../../src/web/utils.ts"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @typedef {Record<string, unknown>} Props\n * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test\n * Check for an arbitrary node, unaware of TypeScript inferral.\n *\n * @callback TestFunctionAnything\n * Check if a node passes a test, unaware of TypeScript inferral.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | void}\n * Whether this node passes the test.\n */\n\n/**\n * @template {Node} Kind\n * Node type.\n * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest\n * Check for a node that can be inferred by TypeScript.\n */\n\n/**\n * Check if a node passes a certain test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback TestFunctionPredicate\n * Complex test function for a node that can be inferred by TypeScript.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this node passes the test.\n */\n\n/**\n * @callback AssertAnything\n * Check that an arbitrary value is a node, unaware of TypeScript inferral.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if a node is a node and passes a certain node test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback AssertPredicate\n * Check that an arbitrary value is a specific node, aware of TypeScript.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param node\n * Thing to check, typically `Node`.\n * @param test\n * A check for a specific node.\n * @param index\n * The node’s position in its parent.\n * @param parent\n * The node’s parent.\n * @returns\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n /**\n * @type {(\n * (() => false) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &\n * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &\n * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function is(node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n // @ts-expect-error Looks like a node.\n return node && node.type && typeof node.type === 'string'\n ? Boolean(check.call(context, node, index, parent))\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns\n * An assertion.\n */\nexport const convert =\n /**\n * @type {(\n * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &\n * ((test?: Test) => AssertAnything)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {AssertAnything}\n */\n function (test) {\n if (test === undefined || test === null) {\n return ok\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<string | Props | TestFunctionAnything>} tests\n * @returns {AssertAnything}\n */\nfunction anyFactory(tests) {\n /** @type {Array<AssertAnything>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].call(this, ...parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {AssertAnything}\n */\nfunction propsFactory(check) {\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n /** @type {string} */\n let key\n\n for (key in check) {\n // @ts-expect-error: hush, it sure works as an index.\n if (node[key] !== check[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {AssertAnything}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunctionAnything} check\n * @returns {AssertAnything}\n */\nfunction castFactory(check) {\n return assertion\n\n /**\n * @this {unknown}\n * @param {unknown} node\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function assertion(node, ...parameters) {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n // @ts-expect-error: fine.\n Boolean(check.call(this, node, ...parameters))\n )\n }\n}\n\nfunction ok() {\n return true\n}\n","/**\n * @typedef {import('./lib/index.js').Test} Test\n * @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything\n * @typedef {import('./lib/index.js').AssertAnything} AssertAnything\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate\n */\n\nexport {is, convert} from './lib/index.js'\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return '\\u001B[33m' + d + '\\u001B[39m'\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visitParents} from './lib/index.js'\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n * @typedef {import('./complex-types.js').Visitor} Visitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit children of tree which pass test.\n *\n * @param tree\n * Tree to walk\n * @param [test]\n * `unist-util-is`-compatible test\n * @param visitor\n * Function called for nodes that pass `test`.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of preorder (NLR) (default).\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types.js').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types.js').BuildVisitor<Tree>, reverse?: boolean) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {import('./complex-types.js').Visitor} visitor\n * @param {boolean} [reverse]\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n","import path, { join } from 'node:path';\nimport type { RouteMeta, RspressPlugin } from '@rspress/shared';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport type {\n loader,\n EditorProps as MonacoEditorProps,\n} from '@monaco-editor/react';\nimport type { Code } from 'mdast';\nimport { staticPath } from './constant';\nimport { getNodeAttribute, parseImports } from './utils';\nimport { remarkPlugin } from './remarkPlugin';\nimport { DEFAULT_BABEL_URL, DEFAULT_MONACO_URL } from '@/web/constant';\nimport { normalizeUrl } from '@/web/utils';\n\ninterface PlaygroundOptions {\n render: string;\n include: Array<string | [string, string]>;\n\n defaultDirection: 'horizontal' | 'vertical';\n editorPosition: 'left' | 'right';\n\n babelUrl: string;\n\n monacoLoader: Parameters<typeof loader.config>[0];\n monacoOptions: MonacoEditorProps['options'];\n /**\n * determine how to handle a internal code block without meta\n * @default 'playground'\n */\n defaultRenderMode?: 'pure' | 'playground';\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeMeta: RouteMeta[];\n\n/**\n * The plugin is used to preview component.\n */\nexport function pluginPlayground(\n options?: Partial<PlaygroundOptions>,\n): RspressPlugin {\n const {\n render = '',\n include,\n defaultDirection = 'horizontal',\n editorPosition = 'left',\n babelUrl = DEFAULT_BABEL_URL,\n monacoLoader = {},\n monacoOptions = {},\n defaultRenderMode = 'playground',\n } = options || {};\n\n const playgroundVirtualModule = new RspackVirtualModulePlugin({});\n const getRouteMeta = () => routeMeta;\n\n if (render && !/Playground\\.(jsx?|tsx?)$/.test(render)) {\n throw new Error(\n '[Playground]: render should ends with Playground.(jsx?|tsx?)',\n );\n }\n\n const preloads: string[] = [];\n const monacoPrefix = monacoLoader.paths?.vs || DEFAULT_MONACO_URL;\n preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));\n preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));\n\n return {\n name: '@rspress/plugin-playground',\n config(config, { removePlugin }) {\n config.markdown = config.markdown || {};\n config.markdown.mdxRs = false;\n // The preview and playground plugin are mutually conflicting.\n removePlugin('@rspress/plugin-preview');\n return config;\n },\n async routeGenerated(routes: RouteMeta[]) {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n\n // init routeMeta\n routeMeta = routes;\n\n const files = routes.map(route => route.absolutePath);\n\n const imports: Record<string, string> = {};\n\n // scan all demos, and generate imports\n await Promise.all(\n files.map(async (filepath, _index) => {\n const isMdxFile = /\\.mdx?$/.test(filepath);\n if (!isMdxFile) {\n return;\n }\n const { createProcessor } = await import('@mdx-js/mdx');\n const { visit } = await import('unist-util-visit');\n const { default: remarkGFM } = await import('remark-gfm');\n try {\n const processor = createProcessor({\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [remarkGFM],\n });\n const source = await fs.readFile(filepath, 'utf-8');\n const ast = processor.parse(source);\n\n visit(ast, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(path.dirname(filepath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n\n const thisImports = parseImports(code, path.extname(demoPath));\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n\n visit(ast, 'code', (node: Code) => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const { value, meta } = node;\n const hasPureMeta = meta?.includes('pure');\n const hasPlaygroundMeta = meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const thisImports = parseImports(value, node.lang);\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n } catch (e) {\n console.error(e);\n throw e;\n }\n }),\n );\n\n if (include) {\n include.forEach(item => {\n if (typeof item === 'string') {\n imports[item] = item;\n } else {\n imports[item[0]] = item[1];\n }\n });\n }\n\n if (!('react' in imports)) {\n imports.react = 'react';\n }\n\n const importKeys = Object.keys(imports);\n const code = [\n ...importKeys.map(\n (x, index) => `import * as i_${index} from '${imports[x]}';`,\n ),\n 'const imports = new Map();',\n ...importKeys.map((x, index) => `imports.set('${x}', i_${index});`),\n 'function getImport(name, getDefault) {',\n ' if (!imports.has(name)) {',\n ' throw new Error(\"Module \" + name + \" not found\");',\n ' }',\n ' const result = imports.get(name);',\n ' if (getDefault && typeof result === \"object\") {',\n ' return result.default || result;',\n ' }',\n ' return result;',\n '}',\n 'export { imports };',\n 'export default getImport;',\n ].join('\\n');\n\n // console.log('playground-imports', code);\n\n playgroundVirtualModule.writeModule('_rspress_playground_imports', code);\n },\n builderConfig: {\n source: {\n define: {\n __PLAYGROUND_DIRECTION__: JSON.stringify(defaultDirection),\n __PLAYGROUND_MONACO_LOADER__: JSON.stringify(monacoLoader),\n __PLAYGROUND_MONACO_OPTIONS__: JSON.stringify(monacoOptions),\n __PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl),\n },\n include: [join(__dirname, '..', '..', '..')],\n },\n html: {\n tags: preloads.map(url => ({\n tag: 'link',\n head: true,\n attrs: {\n rel: 'preload',\n href: url,\n as: 'script',\n },\n })),\n },\n tools: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore\n rspack: {\n plugins: [playgroundVirtualModule],\n },\n },\n },\n markdown: {\n remarkPlugins: [\n [remarkPlugin, { getRouteMeta, editorPosition, defaultRenderMode }],\n ],\n globalComponents: [\n render\n ? render\n : path.join(staticPath, 'global-components', 'Playground.tsx'),\n ],\n },\n globalStyles: path.join(staticPath, 'global-styles', 'web.css'),\n };\n}\n","import path from 'node:path';\n\nexport const staticPath = path.join(__dirname, '../../../static');\n","/* eslint-disable consistent-return */\nimport type { Program } from '@babel/types';\nimport oxc from '@oxidation-compiler/napi';\n\nexport const parseImports = (code: string, sourceExt: string) => {\n const parsed = oxc.parseSync(code, {\n sourceType: 'module',\n sourceFilename: `index.${sourceExt}`,\n });\n\n const ast = JSON.parse(parsed.program) as Program;\n\n const result: string[] = [];\n\n // oxc didn't have \"traverse\", so it currently only scans the first level\n // (generally, demos are not too complicated, right?)\n ast.body.forEach(statement => {\n if (statement.type === 'ImportDeclaration') {\n result.push(statement.source.value);\n }\n });\n\n return result;\n};\n\nexport const getNodeAttribute = (\n node: any,\n attrName: string,\n): string | undefined => {\n return node.attributes.find(\n (attr: { name: string; value: string }) => attr.name === attrName,\n )?.value;\n};\n\nexport const getNodeMeta = (\n node: any,\n metaName: string,\n): string | undefined => {\n if (!node.meta) {\n return;\n }\n const meta: string[] = node.meta.split(' ');\n const item: string | undefined = meta.find((x: string) =>\n x.startsWith(metaName),\n );\n if (item?.startsWith(`${metaName}=`)) {\n return item.substring(metaName.length + 1);\n }\n return item;\n};\n","import { dirname, join, resolve } from 'node:path';\nimport { visit } from 'unist-util-visit';\nimport fs from '@rspress/shared/fs-extra';\nimport type { RouteMeta } from '@rspress/shared';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport { getNodeAttribute, getNodeMeta } from './utils';\n\nfunction createPlaygroundNode(\n currentNode: any,\n attrs: Array<[string, string]>,\n) {\n Object.assign(currentNode, {\n type: 'mdxJsxFlowElement',\n name: 'Playground',\n attributes: attrs.map(it => ({\n type: 'mdxJsxAttribute',\n name: it[0],\n value: it[1],\n })),\n });\n}\n\ninterface RemarkPluginProps {\n getRouteMeta: () => RouteMeta[];\n editorPosition: 'left' | 'right';\n defaultRenderMode: 'pure' | 'playground';\n}\n\n/**\n * remark plugin to transform code to demo\n */\nexport const remarkPlugin: Plugin<[RemarkPluginProps], Root> = ({\n getRouteMeta,\n editorPosition,\n defaultRenderMode,\n}) => {\n const routeMeta = getRouteMeta();\n\n return (tree, vfile) => {\n const route = routeMeta.find(\n meta =>\n resolve(meta.absolutePath) === resolve(vfile.path || vfile.history[0]),\n );\n if (!route) {\n return;\n }\n\n // 1. External demo , use <code src=\"foo\" /> to declare demo\n visit(tree, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(dirname(route.absolutePath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n const direction = getNodeAttribute(node, 'direction') || '';\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n const language = src.substr(src.lastIndexOf('.') + 1);\n createPlaygroundNode(node, [\n ['code', code],\n ['language', language],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n\n // 2. Internal demo, use ```j/tsx to declare demo\n visit(tree, 'code', node => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const hasPureMeta = node?.meta?.includes('pure');\n const hasPlaygroundMeta = node?.meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const direction = getNodeMeta(node, 'direction') || '';\n\n createPlaygroundNode(node, [\n ['code', node.value],\n ['language', node.lang],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n };\n};\n","export const DEFAULT_BABEL_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.22.20/babel.min.js';\n\nexport const DEFAULT_MONACO_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs';\n","export function normalizeUrl(u: string) {\n return u.replace(/\\/\\//g, '/');\n}\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;AA0MA,SAAS,WAAW,OAAO;AAEzB,QAAM,SAAS,CAAC;AAChB,MAAI,QAAQ;AAEZ,SAAO,EAAE,QAAQ,MAAM,QAAQ;AAC7B,WAAO,KAAK,IAAI,QAAQ,MAAM,KAAK,CAAC;AAAA,EACtC;AAEA,SAAO,YAAY,GAAG;AAOtB,WAAS,OAAO,YAAY;AAC1B,QAAIA,SAAQ;AAEZ,WAAO,EAAEA,SAAQ,OAAO,QAAQ;AAC9B,UAAI,OAAOA,MAAK,EAAE,KAAK,MAAM,GAAG,UAAU;AAAG,eAAO;AAAA,IACtD;AAEA,WAAO;AAAA,EACT;AACF;AAQA,SAAS,aAAa,OAAO;AAC3B,SAAO,YAAY,GAAG;AAMtB,WAAS,IAAI,MAAM;AAEjB,QAAI;AAEJ,SAAK,OAAO,OAAO;AAEjB,UAAI,KAAK,GAAG,MAAM,MAAM,GAAG;AAAG,eAAO;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AACF;AAQA,SAAS,YAAY,OAAO;AAC1B,SAAO,YAAY,IAAI;AAKvB,WAAS,KAAK,MAAM;AAClB,WAAO,QAAQ,KAAK,SAAS;AAAA,EAC/B;AACF;AAQA,SAAS,YAAY,OAAO;AAC1B,SAAO;AAQP,WAAS,UAAU,SAAS,YAAY;AACtC,WAAO;AAAA,MACL,QACE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;AAAA,MAC7C;AAAA,MACA,MAAM;AAAA,QACJ,MAAM,SAAS,IAAI,UAAQ;AAAA,UACzB,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,YACL,KAAK;AAAA,YACL,MAAM;AAAA,YACN,IAAI;AAAA,UACN;AAAA,QACF,EAAE;AAAA,MACJ;AAAA,MACA,OAAO;AAAA;AAAA;AAAA,QAGL,QAAQ;AAAA,UACN,SAAS,CAAC,uBAAuB;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,IACA,UAAU;AAAA,MACR,eAAe;AAAA,QACb,CAAC,cAAc,EAAE,cAAc,gBAAgB,kBAAkB,CAAC;AAAA,MACpE;AAAA,MACA,kBAAkB;AAAA,QAChB,SACI,SACAD,MAAK,KAAK,YAAY,qBAAqB,gBAAgB;AAAA,MACjE;AAAA,IACF;AAAA,IACA,cAAcA,MAAK,KAAK,YAAY,iBAAiB,SAAS;AAAA,EAChE;AACF","names":["index","init_lib","is","visit","path","join","routeMeta","fs","code"],"ignoreList":[],"sources":["../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js","../../../../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js","../../../../../node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/index.js","../../../src/cli/index.ts","../../../src/cli/constant.ts","../../../src/cli/utils.ts","../../../src/cli/remarkPlugin.ts","../../../src/web/constant.ts","../../../src/web/utils.ts"],"sourcesContent":["/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n */\n\n/**\n * @typedef {Record<string, unknown>} Props\n * @typedef {null | undefined | string | Props | TestFunctionAnything | Array<string | Props | TestFunctionAnything>} Test\n * Check for an arbitrary node, unaware of TypeScript inferral.\n *\n * @callback TestFunctionAnything\n * Check if a node passes a test, unaware of TypeScript inferral.\n * @param {unknown} this\n * The given context.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean | void}\n * Whether this node passes the test.\n */\n\n/**\n * @template {Node} Kind\n * Node type.\n * @typedef {Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind> | Array<Kind['type'] | Partial<Kind> | TestFunctionPredicate<Kind>>} PredicateTest\n * Check for a node that can be inferred by TypeScript.\n */\n\n/**\n * Check if a node passes a certain test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback TestFunctionPredicate\n * Complex test function for a node that can be inferred by TypeScript.\n * @param {Node} node\n * A node.\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this node passes the test.\n */\n\n/**\n * @callback AssertAnything\n * Check that an arbitrary value is a node, unaware of TypeScript inferral.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {boolean}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if a node is a node and passes a certain node test.\n *\n * @template {Node} Kind\n * Node type.\n * @callback AssertPredicate\n * Check that an arbitrary value is a specific node, aware of TypeScript.\n * @param {unknown} [node]\n * Anything (typically a node).\n * @param {number | null | undefined} [index]\n * The node’s position in its parent.\n * @param {Parent | null | undefined} [parent]\n * The node’s parent.\n * @returns {node is Kind}\n * Whether this is a node and passes a test.\n */\n\n/**\n * Check if `node` is a `Node` and whether it passes the given test.\n *\n * @param node\n * Thing to check, typically `Node`.\n * @param test\n * A check for a specific node.\n * @param index\n * The node’s position in its parent.\n * @param parent\n * The node’s parent.\n * @returns\n * Whether `node` is a node and passes a test.\n */\nexport const is =\n /**\n * @type {(\n * (() => false) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index: number, parent: Parent, context?: unknown) => node is Kind) &\n * (<Kind extends Node = Node>(node: unknown, test: PredicateTest<Kind>, index?: null | undefined, parent?: null | undefined, context?: unknown) => node is Kind) &\n * ((node: unknown, test: Test, index: number, parent: Parent, context?: unknown) => boolean) &\n * ((node: unknown, test?: Test, index?: null | undefined, parent?: null | undefined, context?: unknown) => boolean)\n * )}\n */\n (\n /**\n * @param {unknown} [node]\n * @param {Test} [test]\n * @param {number | null | undefined} [index]\n * @param {Parent | null | undefined} [parent]\n * @param {unknown} [context]\n * @returns {boolean}\n */\n // eslint-disable-next-line max-params\n function is(node, test, index, parent, context) {\n const check = convert(test)\n\n if (\n index !== undefined &&\n index !== null &&\n (typeof index !== 'number' ||\n index < 0 ||\n index === Number.POSITIVE_INFINITY)\n ) {\n throw new Error('Expected positive finite index')\n }\n\n if (\n parent !== undefined &&\n parent !== null &&\n (!is(parent) || !parent.children)\n ) {\n throw new Error('Expected parent node')\n }\n\n if (\n (parent === undefined || parent === null) !==\n (index === undefined || index === null)\n ) {\n throw new Error('Expected both parent and index')\n }\n\n // @ts-expect-error Looks like a node.\n return node && node.type && typeof node.type === 'string'\n ? Boolean(check.call(context, node, index, parent))\n : false\n }\n )\n\n/**\n * Generate an assertion from a test.\n *\n * Useful if you’re going to test many nodes, for example when creating a\n * utility where something else passes a compatible test.\n *\n * The created function is a bit faster because it expects valid input only:\n * a `node`, `index`, and `parent`.\n *\n * @param test\n * * when nullish, checks if `node` is a `Node`.\n * * when `string`, works like passing `(node) => node.type === test`.\n * * when `function` checks if function passed the node is true.\n * * when `object`, checks that all keys in test are in node, and that they have (strictly) equal values.\n * * when `array`, checks if any one of the subtests pass.\n * @returns\n * An assertion.\n */\nexport const convert =\n /**\n * @type {(\n * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &\n * ((test?: Test) => AssertAnything)\n * )}\n */\n (\n /**\n * @param {Test} [test]\n * @returns {AssertAnything}\n */\n function (test) {\n if (test === undefined || test === null) {\n return ok\n }\n\n if (typeof test === 'string') {\n return typeFactory(test)\n }\n\n if (typeof test === 'object') {\n return Array.isArray(test) ? anyFactory(test) : propsFactory(test)\n }\n\n if (typeof test === 'function') {\n return castFactory(test)\n }\n\n throw new Error('Expected function, string, or object as test')\n }\n )\n\n/**\n * @param {Array<string | Props | TestFunctionAnything>} tests\n * @returns {AssertAnything}\n */\nfunction anyFactory(tests) {\n /** @type {Array<AssertAnything>} */\n const checks = []\n let index = -1\n\n while (++index < tests.length) {\n checks[index] = convert(tests[index])\n }\n\n return castFactory(any)\n\n /**\n * @this {unknown}\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function any(...parameters) {\n let index = -1\n\n while (++index < checks.length) {\n if (checks[index].call(this, ...parameters)) return true\n }\n\n return false\n }\n}\n\n/**\n * Turn an object into a test for a node with a certain fields.\n *\n * @param {Props} check\n * @returns {AssertAnything}\n */\nfunction propsFactory(check) {\n return castFactory(all)\n\n /**\n * @param {Node} node\n * @returns {boolean}\n */\n function all(node) {\n /** @type {string} */\n let key\n\n for (key in check) {\n // @ts-expect-error: hush, it sure works as an index.\n if (node[key] !== check[key]) return false\n }\n\n return true\n }\n}\n\n/**\n * Turn a string into a test for a node with a certain type.\n *\n * @param {string} check\n * @returns {AssertAnything}\n */\nfunction typeFactory(check) {\n return castFactory(type)\n\n /**\n * @param {Node} node\n */\n function type(node) {\n return node && node.type === check\n }\n}\n\n/**\n * Turn a custom test into a test for a node that passes that test.\n *\n * @param {TestFunctionAnything} check\n * @returns {AssertAnything}\n */\nfunction castFactory(check) {\n return assertion\n\n /**\n * @this {unknown}\n * @param {unknown} node\n * @param {Array<unknown>} parameters\n * @returns {boolean}\n */\n function assertion(node, ...parameters) {\n return Boolean(\n node &&\n typeof node === 'object' &&\n 'type' in node &&\n // @ts-expect-error: fine.\n Boolean(check.call(this, node, ...parameters))\n )\n }\n}\n\nfunction ok() {\n return true\n}\n","/**\n * @typedef {import('./lib/index.js').Test} Test\n * @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything\n * @typedef {import('./lib/index.js').AssertAnything} AssertAnything\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate\n */\n\n/**\n * @template {import('unist').Node} Kind\n * @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate\n */\n\nexport {is, convert} from './lib/index.js'\n","/**\n * @param {string} d\n * @returns {string}\n */\nexport function color(d) {\n return '\\u001B[33m' + d + '\\u001B[39m'\n}\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * @typedef {boolean | 'skip'} Action\n * Union of the action types.\n *\n * @typedef {number} Index\n * Move to the sibling at `index` next (after node itself is completely\n * traversed).\n *\n * Useful if mutating the tree, such as removing the node the visitor is\n * currently on, or any of its previous siblings.\n * Results less than 0 or greater than or equal to `children.length` stop\n * traversing the parent.\n *\n * @typedef {[(Action | null | undefined | void)?, (Index | null | undefined)?]} ActionTuple\n * List with one or two values, the first an action, the second an index.\n *\n * @typedef {Action | ActionTuple | Index | null | undefined | void} VisitorResult\n * Any value that can be returned from a visitor.\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform the parent of node (the last of `ancestors`).\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of an ancestor still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Array<Ancestor>} ancestors\n * Ancestors of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * @template {Node} [Tree=Node]\n * Tree type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {Visitor<import('./complex-types.js').Matches<import('./complex-types.js').InclusiveDescendant<Tree>, Check>, Extract<import('./complex-types.js').InclusiveDescendant<Tree>, Parent>>} BuildVisitor\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parents`.\n */\n\nimport {convert} from 'unist-util-is'\nimport {color} from './color.js'\n\n/**\n * Continue traversing as normal.\n */\nexport const CONTINUE = true\n\n/**\n * Stop traversing immediately.\n */\nexport const EXIT = false\n\n/**\n * Do not traverse this node’s children.\n */\nexport const SKIP = 'skip'\n\n/**\n * Visit nodes, with ancestral information.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visitParents =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor<Node>} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n // @ts-expect-error no visitor given, so `visitor` is test.\n visitor = test\n test = null\n }\n\n const is = convert(test)\n const step = reverse ? -1 : 1\n\n factory(tree, undefined, [])()\n\n /**\n * @param {Node} node\n * @param {number | undefined} index\n * @param {Array<Parent>} parents\n */\n function factory(node, index, parents) {\n /** @type {Record<string, unknown>} */\n // @ts-expect-error: hush\n const value = node && typeof node === 'object' ? node : {}\n\n if (typeof value.type === 'string') {\n const name =\n // `hast`\n typeof value.tagName === 'string'\n ? value.tagName\n : // `xast`\n typeof value.name === 'string'\n ? value.name\n : undefined\n\n Object.defineProperty(visit, 'name', {\n value:\n 'node (' + color(node.type + (name ? '<' + name + '>' : '')) + ')'\n })\n }\n\n return visit\n\n function visit() {\n /** @type {ActionTuple} */\n let result = []\n /** @type {ActionTuple} */\n let subresult\n /** @type {number} */\n let offset\n /** @type {Array<Parent>} */\n let grandparents\n\n if (!test || is(node, index, parents[parents.length - 1] || null)) {\n result = toResult(visitor(node, parents))\n\n if (result[0] === EXIT) {\n return result\n }\n }\n\n // @ts-expect-error looks like a parent.\n if (node.children && result[0] !== SKIP) {\n // @ts-expect-error looks like a parent.\n offset = (reverse ? node.children.length : -1) + step\n // @ts-expect-error looks like a parent.\n grandparents = parents.concat(node)\n\n // @ts-expect-error looks like a parent.\n while (offset > -1 && offset < node.children.length) {\n // @ts-expect-error looks like a parent.\n subresult = factory(node.children[offset], offset, grandparents)()\n\n if (subresult[0] === EXIT) {\n return subresult\n }\n\n offset =\n typeof subresult[1] === 'number' ? subresult[1] : offset + step\n }\n }\n\n return result\n }\n }\n }\n )\n\n/**\n * Turn a return value into a clean result.\n *\n * @param {VisitorResult} value\n * Valid return values from visitors.\n * @returns {ActionTuple}\n * Clean result.\n */\nfunction toResult(value) {\n if (Array.isArray(value)) {\n return value\n }\n\n if (typeof value === 'number') {\n return [CONTINUE, value]\n }\n\n return [value]\n}\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visitParents} from './lib/index.js'\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult\n */\n\n/**\n * Check if `Child` can be a child of `Ancestor`.\n *\n * Returns the ancestor when `Child` can be a child of `Ancestor`, or returns\n * `never`.\n *\n * @template {Node} Ancestor\n * Node type.\n * @template {Node} Child\n * Node type.\n * @typedef {(\n * Ancestor extends Parent\n * ? Child extends Ancestor['children'][number]\n * ? Ancestor\n * : never\n * : never\n * )} ParentsOf\n */\n\n/**\n * @template {Node} [Visited=Node]\n * Visited node type.\n * @template {Parent} [Ancestor=Parent]\n * Ancestor type.\n * @callback Visitor\n * Handle a node (matching `test`, if given).\n *\n * Visitors are free to transform `node`.\n * They can also transform `parent`.\n *\n * Replacing `node` itself, if `SKIP` is not returned, still causes its\n * descendants to be walked (which is a bug).\n *\n * When adding or removing previous siblings of `node` (or next siblings, in\n * case of reverse), the `Visitor` should return a new `Index` to specify the\n * sibling to traverse after `node` is traversed.\n * Adding or removing next siblings of `node` (or previous siblings, in case\n * of reverse) is handled as expected without needing to return a new `Index`.\n *\n * Removing the children property of `parent` still results in them being\n * traversed.\n * @param {Visited} node\n * Found node.\n * @param {Visited extends Node ? number | null : never} index\n * Index of `node` in `parent`.\n * @param {Ancestor extends Node ? Ancestor | null : never} parent\n * Parent of `node`.\n * @returns {VisitorResult}\n * What to do next.\n *\n * An `Index` is treated as a tuple of `[CONTINUE, Index]`.\n * An `Action` is treated as a tuple of `[Action]`.\n *\n * Passing a tuple back only makes sense if the `Action` is `SKIP`.\n * When the `Action` is `EXIT`, that action can be returned.\n * When the `Action` is `CONTINUE`, `Index` can be returned.\n */\n\n/**\n * Build a typed `Visitor` function from a node and all possible parents.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Visited\n * Node type.\n * @template {Parent} Ancestor\n * Parent type.\n * @typedef {Visitor<Visited, ParentsOf<Ancestor, Visited>>} BuildVisitorFromMatch\n */\n\n/**\n * Build a typed `Visitor` function from a list of descendants and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} Descendant\n * Node type.\n * @template {Test} Check\n * Test type.\n * @typedef {(\n * BuildVisitorFromMatch<\n * import('unist-util-visit-parents/complex-types.js').Matches<Descendant, Check>,\n * Extract<Descendant, Parent>\n * >\n * )} BuildVisitorFromDescendants\n */\n\n/**\n * Build a typed `Visitor` function from a tree and a test.\n *\n * It will infer which values are passed as `node` and which as `parent`.\n *\n * @template {Node} [Tree=Node]\n * Node type.\n * @template {Test} [Check=string]\n * Test type.\n * @typedef {(\n * BuildVisitorFromDescendants<\n * import('unist-util-visit-parents/complex-types.js').InclusiveDescendant<Tree>,\n * Check\n * >\n * )} BuildVisitor\n */\n\nimport {visitParents} from 'unist-util-visit-parents'\n\n/**\n * Visit nodes.\n *\n * This algorithm performs *depth-first* *tree traversal* in *preorder*\n * (**NLR**) or if `reverse` is given, in *reverse preorder* (**NRL**).\n *\n * You can choose for which nodes `visitor` is called by passing a `test`.\n * For complex tests, you should test yourself in `visitor`, as it will be\n * faster and will have improved type information.\n *\n * Walking the tree is an intensive task.\n * Make use of the return values of the visitor when possible.\n * Instead of walking a tree multiple times, walk it once, use `unist-util-is`\n * to check if a node matches, and then perform different operations.\n *\n * You can change the tree.\n * See `Visitor` for more info.\n *\n * @param tree\n * Tree to traverse.\n * @param test\n * `unist-util-is`-compatible test\n * @param visitor\n * Handle each node.\n * @param reverse\n * Traverse in reverse preorder (NRL) instead of the default preorder (NLR).\n * @returns\n * Nothing.\n */\nexport const visit =\n /**\n * @type {(\n * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &\n * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)\n * )}\n */\n (\n /**\n * @param {Node} tree\n * @param {Test} test\n * @param {Visitor} visitor\n * @param {boolean | null | undefined} [reverse]\n * @returns {void}\n */\n function (tree, test, visitor, reverse) {\n if (typeof test === 'function' && typeof visitor !== 'function') {\n reverse = visitor\n visitor = test\n test = null\n }\n\n visitParents(tree, test, overload, reverse)\n\n /**\n * @param {Node} node\n * @param {Array<Parent>} parents\n */\n function overload(node, parents) {\n const parent = parents[parents.length - 1]\n return visitor(\n node,\n parent ? parent.children.indexOf(node) : null,\n parent\n )\n }\n }\n )\n\nexport {CONTINUE, EXIT, SKIP} from 'unist-util-visit-parents'\n","// Note: types exported from `index.d.ts`\nexport {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'\n","import path, { join } from 'node:path';\nimport type { RouteMeta, RspressPlugin } from '@rspress/shared';\nimport { RspackVirtualModulePlugin } from 'rspack-plugin-virtual-module';\nimport type {\n loader,\n EditorProps as MonacoEditorProps,\n} from '@monaco-editor/react';\nimport type { Code } from 'mdast';\nimport { staticPath } from './constant';\nimport { getNodeAttribute, parseImports } from './utils';\nimport { remarkPlugin } from './remarkPlugin';\nimport { DEFAULT_BABEL_URL, DEFAULT_MONACO_URL } from '@/web/constant';\nimport { normalizeUrl } from '@/web/utils';\n\ninterface PlaygroundOptions {\n render: string;\n include: Array<string | [string, string]>;\n\n defaultDirection: 'horizontal' | 'vertical';\n editorPosition: 'left' | 'right';\n\n babelUrl: string;\n\n monacoLoader: Parameters<typeof loader.config>[0];\n monacoOptions: MonacoEditorProps['options'];\n /**\n * determine how to handle a internal code block without meta\n * @default 'playground'\n */\n defaultRenderMode?: 'pure' | 'playground';\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let routeMeta: RouteMeta[];\n\n/**\n * The plugin is used to preview component.\n */\nexport function pluginPlayground(\n options?: Partial<PlaygroundOptions>,\n): RspressPlugin {\n const {\n render = '',\n include,\n defaultDirection = 'horizontal',\n editorPosition = 'left',\n babelUrl = DEFAULT_BABEL_URL,\n monacoLoader = {},\n monacoOptions = {},\n defaultRenderMode = 'playground',\n } = options || {};\n\n const playgroundVirtualModule = new RspackVirtualModulePlugin({});\n const getRouteMeta = () => routeMeta;\n\n if (render && !/Playground\\.(jsx?|tsx?)$/.test(render)) {\n throw new Error(\n '[Playground]: render should ends with Playground.(jsx?|tsx?)',\n );\n }\n\n const preloads: string[] = [];\n const monacoPrefix = monacoLoader.paths?.vs || DEFAULT_MONACO_URL;\n preloads.push(normalizeUrl(`${monacoPrefix}/loader.js`));\n preloads.push(normalizeUrl(`${monacoPrefix}/editor/editor.main.js`));\n\n return {\n name: '@rspress/plugin-playground',\n config(config, { removePlugin }) {\n config.markdown = config.markdown || {};\n config.markdown.mdxRs = false;\n // The preview and playground plugin are mutually conflicting.\n removePlugin('@rspress/plugin-preview');\n return config;\n },\n async routeGenerated(routes: RouteMeta[]) {\n const { default: fs } = await import('@rspress/shared/fs-extra');\n\n // init routeMeta\n routeMeta = routes;\n\n const files = routes.map(route => route.absolutePath);\n\n const imports: Record<string, string> = {};\n\n // scan all demos, and generate imports\n await Promise.all(\n files.map(async (filepath, _index) => {\n const isMdxFile = /\\.mdx?$/.test(filepath);\n if (!isMdxFile) {\n return;\n }\n const { createProcessor } = await import('@mdx-js/mdx');\n const { visit } = await import('unist-util-visit');\n const { default: remarkGFM } = await import('remark-gfm');\n try {\n const processor = createProcessor({\n format: path.extname(filepath).slice(1) as 'mdx' | 'md',\n remarkPlugins: [remarkGFM],\n });\n const source = await fs.readFile(filepath, 'utf-8');\n const ast = processor.parse(source);\n\n visit(ast, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(path.dirname(filepath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n\n const thisImports = parseImports(code, path.extname(demoPath));\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n\n visit(ast, 'code', (node: Code) => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const { value, meta } = node;\n const hasPureMeta = meta?.includes('pure');\n const hasPlaygroundMeta = meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const thisImports = parseImports(value, node.lang);\n thisImports.forEach(x => {\n if (typeof imports[x] === 'undefined') {\n imports[x] = x;\n }\n });\n }\n });\n } catch (e) {\n console.error(e);\n throw e;\n }\n }),\n );\n\n if (include) {\n include.forEach(item => {\n if (typeof item === 'string') {\n imports[item] = item;\n } else {\n imports[item[0]] = item[1];\n }\n });\n }\n\n if (!('react' in imports)) {\n imports.react = 'react';\n }\n\n const importKeys = Object.keys(imports);\n const code = [\n ...importKeys.map(\n (x, index) => `import * as i_${index} from '${imports[x]}';`,\n ),\n 'const imports = new Map();',\n ...importKeys.map((x, index) => `imports.set('${x}', i_${index});`),\n 'function getImport(name, getDefault) {',\n ' if (!imports.has(name)) {',\n ' throw new Error(\"Module \" + name + \" not found\");',\n ' }',\n ' const result = imports.get(name);',\n ' if (getDefault && typeof result === \"object\") {',\n ' return result.default || result;',\n ' }',\n ' return result;',\n '}',\n 'export { imports };',\n 'export default getImport;',\n ].join('\\n');\n\n // console.log('playground-imports', code);\n\n playgroundVirtualModule.writeModule('_rspress_playground_imports', code);\n },\n builderConfig: {\n source: {\n define: {\n __PLAYGROUND_DIRECTION__: JSON.stringify(defaultDirection),\n __PLAYGROUND_MONACO_LOADER__: JSON.stringify(monacoLoader),\n __PLAYGROUND_MONACO_OPTIONS__: JSON.stringify(monacoOptions),\n __PLAYGROUND_BABEL_URL__: JSON.stringify(babelUrl),\n },\n include: [join(__dirname, '..', '..', '..')],\n },\n html: {\n tags: preloads.map(url => ({\n tag: 'link',\n head: true,\n attrs: {\n rel: 'preload',\n href: url,\n as: 'script',\n },\n })),\n },\n tools: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error\n // @ts-ignore\n rspack: {\n plugins: [playgroundVirtualModule],\n },\n },\n },\n markdown: {\n remarkPlugins: [\n [remarkPlugin, { getRouteMeta, editorPosition, defaultRenderMode }],\n ],\n globalComponents: [\n render\n ? render\n : path.join(staticPath, 'global-components', 'Playground.tsx'),\n ],\n },\n globalStyles: path.join(staticPath, 'global-styles', 'web.css'),\n };\n}\n","import path from 'node:path';\n\nexport const staticPath = path.join(__dirname, '../../../static');\n","/* eslint-disable consistent-return */\nimport type { Program } from '@babel/types';\nimport oxc from '@oxidation-compiler/napi';\n\nexport const parseImports = (code: string, sourceExt: string) => {\n const parsed = oxc.parseSync(code, {\n sourceType: 'module',\n sourceFilename: `index.${sourceExt}`,\n });\n\n const ast = JSON.parse(parsed.program) as Program;\n\n const result: string[] = [];\n\n // oxc didn't have \"traverse\", so it currently only scans the first level\n // (generally, demos are not too complicated, right?)\n ast.body.forEach(statement => {\n if (statement.type === 'ImportDeclaration') {\n result.push(statement.source.value);\n }\n });\n\n return result;\n};\n\nexport const getNodeAttribute = (\n node: any,\n attrName: string,\n): string | undefined => {\n return node.attributes.find(\n (attr: { name: string; value: string }) => attr.name === attrName,\n )?.value;\n};\n\nexport const getNodeMeta = (\n node: any,\n metaName: string,\n): string | undefined => {\n if (!node.meta) {\n return;\n }\n const meta: string[] = node.meta.split(' ');\n const item: string | undefined = meta.find((x: string) =>\n x.startsWith(metaName),\n );\n if (item?.startsWith(`${metaName}=`)) {\n return item.substring(metaName.length + 1);\n }\n return item;\n};\n","import { dirname, join, resolve } from 'node:path';\nimport { visit } from 'unist-util-visit';\nimport fs from '@rspress/shared/fs-extra';\nimport type { RouteMeta } from '@rspress/shared';\nimport type { Plugin } from 'unified';\nimport type { Root } from 'mdast';\nimport { getNodeAttribute, getNodeMeta } from './utils';\n\nfunction createPlaygroundNode(\n currentNode: any,\n attrs: Array<[string, string]>,\n) {\n Object.assign(currentNode, {\n type: 'mdxJsxFlowElement',\n name: 'Playground',\n attributes: attrs.map(it => ({\n type: 'mdxJsxAttribute',\n name: it[0],\n value: it[1],\n })),\n });\n}\n\ninterface RemarkPluginProps {\n getRouteMeta: () => RouteMeta[];\n editorPosition: 'left' | 'right';\n defaultRenderMode: 'pure' | 'playground';\n}\n\n/**\n * remark plugin to transform code to demo\n */\nexport const remarkPlugin: Plugin<[RemarkPluginProps], Root> = ({\n getRouteMeta,\n editorPosition,\n defaultRenderMode,\n}) => {\n const routeMeta = getRouteMeta();\n\n return (tree, vfile) => {\n const route = routeMeta.find(\n meta =>\n resolve(meta.absolutePath) === resolve(vfile.path || vfile.history[0]),\n );\n if (!route) {\n return;\n }\n\n // 1. External demo , use <code src=\"foo\" /> to declare demo\n visit(tree, 'mdxJsxFlowElement', (node: any) => {\n if (node.name === 'code') {\n const src = getNodeAttribute(node, 'src');\n if (!src) {\n return;\n }\n const demoPath = join(dirname(route.absolutePath), src);\n if (!fs.existsSync(demoPath)) {\n return;\n }\n const direction = getNodeAttribute(node, 'direction') || '';\n const code = fs.readFileSync(demoPath, {\n encoding: 'utf8',\n });\n const language = src.substr(src.lastIndexOf('.') + 1);\n createPlaygroundNode(node, [\n ['code', code],\n ['language', language],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n\n // 2. Internal demo, use ```j/tsx to declare demo\n visit(tree, 'code', node => {\n if (node.lang === 'jsx' || node.lang === 'tsx') {\n const hasPureMeta = node?.meta?.includes('pure');\n const hasPlaygroundMeta = node?.meta?.includes('playground');\n\n let noTransform;\n switch (defaultRenderMode) {\n case 'pure':\n noTransform = !hasPlaygroundMeta;\n break;\n case 'playground':\n noTransform = hasPureMeta;\n break;\n default:\n break;\n }\n\n // do not anything for pure mode\n if (noTransform) {\n return;\n }\n\n const direction = getNodeMeta(node, 'direction') || '';\n\n createPlaygroundNode(node, [\n ['code', node.value],\n ['language', node.lang],\n ['direction', direction],\n ['editorPosition', editorPosition],\n ]);\n }\n });\n };\n};\n","export const DEFAULT_BABEL_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.22.20/babel.min.js';\n\nexport const DEFAULT_MONACO_URL =\n 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.43.0/min/vs';\n","export function normalizeUrl(u: string) {\n return u.replace(/\\/\\//g, '/');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-playground",
3
- "version": "1.29.0",
3
+ "version": "1.31.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": {
@@ -32,28 +32,28 @@
32
32
  "@monaco-editor/react": "~4.6.0",
33
33
  "@oxidation-compiler/napi": "^0.2.0",
34
34
  "remark-gfm": "3.0.1",
35
- "rspack-plugin-virtual-module": "0.1.12",
36
- "@rspress/shared": "1.29.0"
35
+ "rspack-plugin-virtual-module": "0.1.13",
36
+ "@rspress/shared": "1.31.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/types": "^7.25.0",
40
- "@types/babel__core": "^7.20.1",
41
- "@types/babel__standalone": "^7.1.4",
42
- "@types/babel__traverse": "^7.20.1",
43
- "@types/mdast": "^3.0.10",
39
+ "@babel/types": "^7.25.6",
40
+ "@types/babel__core": "^7.20.5",
41
+ "@types/babel__standalone": "^7.1.7",
42
+ "@types/babel__traverse": "^7.20.6",
43
+ "@types/mdast": "^3.0.15",
44
44
  "@types/node": "^18.11.17",
45
- "@types/react": "^18.3.3",
45
+ "@types/react": "^18.3.5",
46
46
  "@types/react-dom": "^18.3.0",
47
- "mdast-util-mdxjs-esm": "^1.3.0",
47
+ "mdast-util-mdxjs-esm": "^1.3.1",
48
48
  "react": "^18.3.1",
49
49
  "react-dom": "^18.3.1",
50
50
  "react-router-dom": "^6.8.1",
51
51
  "typescript": "^5.5.3",
52
52
  "unified": "^10.1.2",
53
- "unist-util-visit": "^4.1.1"
53
+ "unist-util-visit": "^4.1.2"
54
54
  },
55
55
  "peerDependencies": {
56
- "@rspress/core": "^1.29.0",
56
+ "@rspress/core": "^1.31.0",
57
57
  "react": ">=17.0.0",
58
58
  "react-router-dom": "^6.8.1"
59
59
  },