vigor-moon 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/node/dev.ts","../src/node/plugin/indexHtml.ts","../src/node/constants/index.ts","../src/node/plugin/config.ts","../src/node/plugin/plugin-mdx/pluginMdxRollup.ts","../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/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@4.1.2/node_modules/unist-util-visit/lib/index.js","../src/node/plugin/plugin-mdx/rehypePlugins/preWrapper.ts","../src/node/plugin/plugin-mdx/rehypePlugins/shiki.ts","../src/node/plugin/plugin-mdx/remarkPlugins/toc.ts","../src/node/plugin/plugin-mdx/index.ts","../src/node/plugin/plugin-routes/RouteService.ts","../src/node/plugin/plugin-routes/index.ts","../src/node/unocssOptions.ts"],"names":["join","index","is","visit","pluginMdx","path","options"],"mappings":";;;;;AAAA,SAAS,gBAAgB,2BAA2B;;;ACApD,SAAS,gBAAgB;;;ACAzB,SAAS,YAAY;AAGd,IAAM,eAAe,KAAK,WAAW,IAAI;AAGzC,IAAM,oBAAoB,KAAK,cAAc,eAAe;AAG5D,IAAM,oBAAoB,KAAK,cAAc,OAAO,WAAW,kBAAkB;AAEjF,IAAM,oBAAoB,KAAK,cAAc,OAAO,WAAW,eAAe;;;ADP9E,SAAS,kBAA0B;AACxC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,OAAO;AAAA,IACP,mBAAmB,MAAM;AACvB,aAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,UACJ;AAAA,YACE,KAAK;AAAA,YACL,OAAO;AAAA,cACL,MAAM;AAAA,cACN,KAAK,QAAQ;AAAA,YACf;AAAA,Y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B,QAAQ,CAAC;AAAA,MACjE,aAAa,MAAM;AAAA,MACnB,aAAa,EAAE,MAAM,OAAO,MAAM,MAAM,CAAC;AAAA,MACzC,MAAMF,WAAU;AAAA,IAClB;AAAA;AAAA,IAEA,QAAQ;AAAA,MACN,IAAI;AAAA,QACF,OAAO,CAAC,YAAY;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH","sourcesContent":["import { createServer as createViteDevServer } from \"vite\";\r\nimport { pluginIndexHtml } from \"./plugin/indexHtml\";\r\nimport pluginReact from \"@vitejs/plugin-react\";\r\nimport { PACKAGE_ROOT } from \"./constants/index\";\r\nimport { resolveConfig } from \"./config\";\r\nimport { pluginConfig } from \"./plugin/config\";\r\nimport { pluginMdx } from \"./plugin/plugin-mdx/index\";\r\nimport { pluginRoutes } from \"./plugin/plugin-routes\";\r\n\r\n// Unocss适配\r\nimport pluginUnocss from \"unocss/vite\";\r\nimport unocssOptions from \"./unocssOptions\";\r\n\r\nexport async function createDevServer(root: string, isSSR: boolean = false) {\r\n // 拿到配置文件的解析路径和文件经过解析后的内容\r\n const config = await resolveConfig(root, \"serve\", \"development\");\r\n\r\n // vite服务器\r\n return createViteDevServer({\r\n root: PACKAGE_ROOT,\r\n // 插件注册\r\n plugins: [\r\n pluginUnocss(unocssOptions),\r\n pluginIndexHtml(),\r\n pluginReact({ jsxRuntime: \"automatic\", jsxImportSource: \"react\" }),\r\n pluginConfig(config),\r\n pluginRoutes({ root: config.root, isSSR }),\r\n await pluginMdx(),\r\n ],\r\n // 配置e2e的服务器检索目录外的项目的合法性\r\n server: {\r\n fs: {\r\n allow: [PACKAGE_ROOT],\r\n },\r\n },\r\n });\r\n}\r\n","import { readFile } from \"fs/promises\";\r\nimport { Plugin } from \"vite\";\r\nimport { DEFAULT_HTML_PATH, CLIENT_ENTRY_PATH } from \"../constants\";\r\n\r\nexport function pluginIndexHtml(): Plugin {\r\n return {\r\n name: \"vigor: index-html\",\r\n apply: \"serve\",\r\n transformIndexHtml(html) {\r\n return {\r\n html,\r\n tags: [\r\n {\r\n tag: \"script\",\r\n attrs: {\r\n type: \"module\",\r\n src: `/@fs/${CLIENT_ENTRY_PATH}`,\r\n },\r\n injectTo: \"body\",\r\n },\r\n ],\r\n };\r\n },\r\n configureServer(server) {\r\n return () => {\r\n server.middlewares.use(async (req, res, next) => {\r\n let html = await readFile(DEFAULT_HTML_PATH, \"utf-8\");\r\n try {\r\n html = await server.transformIndexHtml(req.url, html, req.originalUrl);\r\n res.statusCode = 200;\r\n res.setHeader(\"Content-Type\", \"text/html\");\r\n res.end(html);\r\n } catch (error) {\r\n return next(error);\r\n }\r\n });\r\n };\r\n },\r\n };\r\n}\r\n","import { join } from \"path\";\r\n\r\n// 包根地址\r\nexport const PACKAGE_ROOT = join(__dirname, \"..\");\r\n\r\n// html模板地址\r\nexport const DEFAULT_HTML_PATH = join(PACKAGE_ROOT, \"template.html\");\r\n\r\n// 客户端入口地址\r\nexport const CLIENT_ENTRY_PATH = join(PACKAGE_ROOT, \"src\", \"runtime\", \"client-entry.tsx\");\r\n// 服务端入口地址\r\nexport const SERVER_ENTRY_PATH = join(PACKAGE_ROOT, \"src\", \"runtime\", \"ssr-entry.tsx\");\r\n","import { PACKAGE_ROOT } from \"node/constants\";\r\nimport { join } from \"path\";\r\nimport { SiteConfig } from \"types/index\";\r\nimport { Plugin } from \"vite\";\r\nimport sirv from \"sirv\";\r\nimport path from \"path\";\r\nimport fs from \"fs-extra\";\r\n\r\nconst SITE_DATA_ID = \"vigor:site-data\";\r\n\r\nexport function pluginConfig(config: SiteConfig): Plugin {\r\n return {\r\n name: \"vigor:site-data\",\r\n resolveId(id) {\r\n if (id === SITE_DATA_ID) {\r\n // 在vite中一个虚拟模块会在前面加一个'\\0',这算是一个约定\r\n return \"\\0\" + SITE_DATA_ID;\r\n }\r\n },\r\n load(id) {\r\n if (id === \"\\0\" + SITE_DATA_ID) {\r\n return `export default ${JSON.stringify(config.siteData)}`;\r\n }\r\n },\r\n // 通过config钩子设置别名,此处设置的别名会自动与vite配置中的别名呼应\r\n config() {\r\n return {\r\n root: PACKAGE_ROOT,\r\n resolve: {\r\n alias: {\r\n \"@runtime\": join(PACKAGE_ROOT, \"src\", \"runtime\", \"index.ts\"),\r\n \"@constants\": join(PACKAGE_ROOT, \"src\", \"node\", \"constants\", \"index.ts\"),\r\n \"@types\": join(PACKAGE_ROOT, \"src\", \"types\", \"index.ts\"),\r\n },\r\n },\r\n css: {\r\n // 在scss中定义类名的时候使用 '-' 格式可以转换为小驼峰形式进行使用\r\n // 比如:\r\n // scss: .main-bg\r\n // tsx: mainBg\r\n modules: {\r\n localsConvention: \"camelCaseOnly\",\r\n },\r\n },\r\n };\r\n },\r\n // 构建一个配置服务器来加载docs文件夹下public中的静态资源\r\n // sirv 是一个优化过的轻量级中间件,用来处理静态资源请求\r\n configureServer(server) {\r\n const publicDir = path.join(config.root, \"public\");\r\n if (fs.existsSync(publicDir)) {\r\n server.middlewares.use(sirv(publicDir));\r\n }\r\n },\r\n // 一个学习的内容,本身未实现,比较复杂的一个逻辑。\r\n // 钩子函数:当配置文件发生改变时,达到热更新的效果\r\n // async handleHotUpdate(ctx) {\r\n // const customWatchedFiles = [config.configPath];\r\n // const include = (id: string) => customWatchedFiles.some((file) => id.includes(file));\r\n // if (include(ctx.file)) {\r\n // `\\n${relative(config.root, ctx.file)} has changed, restarting server...`;\r\n // // 重启Dev Server的方案\r\n // // 手动调用dev.ts中的createServer方法\r\n // }\r\n // },\r\n };\r\n}\r\n","import pluginMdx from \"@mdx-js/rollup\";\r\nimport { Plugin } from \"vite\";\r\n// github的markdown语法标准\r\nimport remarkGFM from \"remark-gfm\";\r\n\r\n// 以下两个插件是用来将标题设置锚点的,通过以下两个插件设置的锚点,可以将标题赋上链接,然后就可以通过点击前往相应位置\r\nimport rehypePluginAutoLinkHeadings from \"rehype-autolink-headings\";\r\nimport rehypePluginSlug from \"rehype-slug\";\r\n\r\n// 解析md文件的元信息\r\nimport remarkPluginFrontmatter from \"remark-frontmatter\";\r\nimport remarkPluginMDXFrontmatter from \"remark-mdx-frontmatter\";\r\n\r\n// 为md文件元信息优化为更优良的结构的插件 -> 外包一层div并添加一个span作为标题\r\nimport { preWrapperPlugin } from \"./rehypePlugins/preWrapper\";\r\n\r\n// 代码高亮插件\r\nimport { shikiPlugin } from \"./rehypePlugins/shiki\";\r\nimport shiki from \"shiki\";\r\n\r\n// TOC解析插件\r\nimport { TOCPlugin } from \"./remarkPlugins/toc\";\r\n\r\nexport async function pluginMdxRollup(): Promise<Plugin> {\r\n return pluginMdx({\r\n // 添加github的markdown标准-GFM语法\r\n remarkPlugins: [\r\n remarkGFM,\r\n remarkPluginFrontmatter,\r\n [remarkPluginMDXFrontmatter, { name: \"frontmatter\" }],\r\n TOCPlugin,\r\n ],\r\n // md文件解析插件\r\n rehypePlugins: [\r\n rehypePluginSlug,\r\n [\r\n rehypePluginAutoLinkHeadings,\r\n {\r\n properties: {\r\n class: \"header-anchor\",\r\n },\r\n content: {\r\n type: \"text\",\r\n value: \"#\",\r\n },\r\n },\r\n ],\r\n preWrapperPlugin,\r\n [shikiPlugin, { highlighter: await shiki.getHighlighter({ theme: \"nord\" }) }],\r\n ],\r\n }) as unknown as Plugin;\r\n}\r\n","/**\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 * @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","/**\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","import { Plugin } from \"unified\";\r\nimport { visit } from \"unist-util-visit\";\r\nimport { Root, Element } from \"hast\";\r\n\r\nexport const preWrapperPlugin: Plugin<[], Root> = () => {\r\n return (tree) => {\r\n visit(tree, \"element\", (node) => {\r\n // 代码块生成的默认结构\r\n // \"<pre><code class=\\\\\"language-js\\\\\">console.log(123);</code></pre>\"\r\n // 1.先找到pre元素\r\n if (\r\n node.tagName === \"pre\" &&\r\n node.children[0]?.type === \"element\" &&\r\n node.children[0].tagName === \"code\" &&\r\n !node.data?.isVisited\r\n ) {\r\n const codeNode = node.children[0];\r\n const codeClassName = codeNode.properties?.className?.toString() || \"\";\r\n // language\r\n const lang = codeClassName.split(\"-\")[1];\r\n\r\n const nodeClone: Element = {\r\n type: \"element\",\r\n tagName: \"pre\",\r\n children: node.children,\r\n data: {\r\n isVisited: true,\r\n },\r\n };\r\n\r\n // 在pre外层包裹一层div,并且给代码块设定一个span标签作为标题,注明使用的语言\r\n node.tagName = \"div\";\r\n node.properties = node.properties || {};\r\n node.properties.className = codeClassName;\r\n\r\n node.children = [\r\n {\r\n type: \"element\",\r\n tagName: \"span\",\r\n properties: {\r\n className: \"lang\",\r\n },\r\n children: [\r\n {\r\n type: \"text\",\r\n value: lang,\r\n },\r\n ],\r\n },\r\n nodeClone,\r\n ];\r\n }\r\n });\r\n };\r\n};\r\n","import { Plugin } from \"unified\";\r\nimport { Root, Text } from \"hast\";\r\nimport { visit } from \"unist-util-visit\";\r\nimport { fromHtml } from \"hast-util-from-html\";\r\nimport shiki from \"shiki\";\r\n\r\ninterface Options {\r\n highlighter: shiki.Highlighter;\r\n}\r\n\r\nexport const shikiPlugin: Plugin<[Options], Root> = ({ highlighter }) => {\r\n return (tree) => {\r\n // 使用unist-util-visit工具遍历结构树\r\n visit(tree, \"element\", (node, index, parent) => {\r\n // 找到目标位置(元素)\r\n if (\r\n node.tagName === \"pre\" &&\r\n node.children[0]?.type === \"element\" &&\r\n node.children[0]?.tagName === \"code\"\r\n ) {\r\n const codeNode = node.children[0];\r\n const codeContent = (codeNode.children[0] as Text).value;\r\n const codeClassName = codeNode.properties?.className?.toString() || \"\";\r\n const lang = codeClassName.split(\"-\")[1];\r\n\r\n if (!lang) return;\r\n\r\n // 实现高亮\r\n const highlightCode = highlighter.codeToHtml(codeContent, { lang });\r\n const fragmentAST = fromHtml(highlightCode, { fragment: true });\r\n parent.children.splice(index, 1, ...fragmentAST.children);\r\n }\r\n });\r\n };\r\n};\r\n","import type { Plugin } from \"unified\";\r\nimport { Root } from \"mdast\";\r\nimport { visit } from \"unist-util-visit\";\r\nimport Slugger from \"github-slugger\";\r\nimport { parse } from \"acorn\";\r\nimport type { MdxjsEsm } from \"mdast-util-mdxjs-esm\";\r\nimport type { Program } from \"estree-jsx\";\r\n\r\ninterface TocItem {\r\n id: string;\r\n text: string;\r\n depth: number;\r\n}\r\n\r\ninterface ChildNode {\r\n type: \"link\" | \"text\" | \"inlineCode\";\r\n value: string;\r\n children?: ChildNode[];\r\n}\r\n\r\nexport const TOCPlugin: Plugin<[], Root> = () => {\r\n return (tree) => {\r\n // 初始化toc数组\r\n const tocTree: TocItem[] = [];\r\n // 初始化slugger\r\n const slugger = new Slugger();\r\n let title = \"\";\r\n visit(tree, \"heading\", (node) => {\r\n if (!node.depth || !node.children) {\r\n return;\r\n }\r\n if (node.depth === 1) {\r\n title = (node.children[0] as ChildNode).value;\r\n }\r\n\r\n if (node.depth > 1 && node.depth < 5) {\r\n // 解析h2~h5\r\n // node.children 是一个数组,包含几种情况:\r\n // 1. 文本节点,如 '## title'\r\n // 结构如下:\r\n // {\r\n // type: 'text',\r\n // value: 'title'\r\n // }\r\n // 2. 链接节点,如 '## [title](/path)'\r\n // 结构如下:\r\n // {\r\n // type: 'link',\r\n // {\r\n // type: 'text',\r\n // value: 'title'\r\n // }\r\n // ]\r\n // }\r\n // 3. 内联代码节点,如 '## `title`'\r\n // 结构如下:\r\n // {\r\n // type: 'inlineCode',\r\n // value: 'title'\r\n // }\r\n const originText = (node.children as ChildNode[])\r\n .map((child) => {\r\n switch (child.type) {\r\n case \"link\":\r\n return child.children?.map((c) => c.value).join(\"\") || \"\";\r\n default:\r\n return child.value;\r\n }\r\n })\r\n .join(\"\");\r\n const id = slugger.slug(originText);\r\n tocTree.push({\r\n id,\r\n text: originText,\r\n depth: node.depth,\r\n });\r\n }\r\n });\r\n const insertCode = `export const toc = ${JSON.stringify(tocTree, null, 2)};`;\r\n\r\n tree.children.push({\r\n type: \"mdxjsEsm\",\r\n value: insertCode,\r\n data: {\r\n estree: parse(insertCode, {\r\n ecmaVersion: 2020,\r\n sourceType: \"module\",\r\n }) as unknown as Program,\r\n },\r\n } as MdxjsEsm);\r\n\r\n if (title) {\r\n const insertTitle = `export const title = \"${title}\";`;\r\n\r\n tree.children.push({\r\n type: \"mdxjsEsm\",\r\n value: insertTitle,\r\n data: {\r\n estree: parse(insertTitle, {\r\n ecmaVersion: 2020,\r\n sourceType: \"module\",\r\n }) as unknown as Program,\r\n },\r\n } as MdxjsEsm);\r\n }\r\n };\r\n};\r\n","import { pluginMdxRollup } from \"./pluginMdxRollup\";\r\nimport { Plugin } from \"vite\";\r\n\r\nexport async function pluginMdx(): Promise<Plugin[]> {\r\n return [await pluginMdxRollup()];\r\n}\r\n","import fastGlob from \"fast-glob\";\r\nimport path from \"path\";\r\nimport { normalizePath } from \"vite\";\r\n\r\ninterface RouteData {\r\n routePath: string;\r\n absolutePath: string;\r\n}\r\n\r\nexport class RouteService {\r\n // #scanDir是定义一个私有变量\r\n #scanDir: string;\r\n // 路由信息数组\r\n #routeData: RouteData[] = [];\r\n\r\n constructor(scanDir: string) {\r\n this.#scanDir = scanDir;\r\n }\r\n\r\n async init() {\r\n // 从产物目录中获取对应文件,然后对对应文件进行排序\r\n const files = fastGlob\r\n .sync([\"**/*.{js,jsx,ts,tsx,md,mdx}\"], {\r\n cwd: this.#scanDir,\r\n absolute: true,\r\n ignore: [\"**/build/**\", \"**/.vigor/**\", \"config.ts\", \"tsconfig.json\"],\r\n })\r\n .sort();\r\n\r\n files.forEach((file) => {\r\n // 拿到文件相对路径(从A到B的)\r\n // normalizePath是对路径进行windows规范化\r\n const fileRelativePath = normalizePath(path.relative(this.#scanDir, file));\r\n\r\n // 生成路径路由\r\n const routePath = this.getRoutePath(fileRelativePath);\r\n this.#routeData.push({\r\n routePath,\r\n absolutePath: file,\r\n });\r\n });\r\n }\r\n\r\n // 得到路由路径\r\n getRoutePath(fileRelativePath: string) {\r\n const routePath = fileRelativePath.replace(/\\.(.*)?$/, \"\").replace(/index$/, \"\");\r\n // 路由路径必须以'/'作为开头\r\n return routePath.startsWith(\"/\") ? routePath : `/${routePath}`;\r\n }\r\n\r\n // 生成路由页面代码\r\n generateRoutesPath(ssr: boolean) {\r\n return `\r\n import React from 'react';\r\n ${ssr ? \"\" : 'import loadable from \"@loadable/component\";'}\r\n ${this.#routeData\r\n .map((route, index) => {\r\n // 动态加载路由信息(按需加载)\r\n // 在生产环境下,如果是ssr产物,则使用多路由打包\r\n return ssr\r\n ? `import Route${index} from \"${normalizePath(route.absolutePath)}\";`\r\n : `const Route${index} = loadable(() => import('${normalizePath(\r\n route.absolutePath\r\n )}')); `;\r\n\r\n // 静态加载路由信息\r\n // return `import Route${index} from '${normalizePath(route.absolutePath)}'`;\r\n })\r\n .join(\"\\n\")}\r\n \r\n export const routes = [\r\n ${this.#routeData\r\n .map((route, index) => {\r\n return `{ path: '${normalizePath(\r\n route.routePath\r\n )}', element: React.createElement(Route${index}), preload: () => import('${normalizePath(\r\n route.absolutePath\r\n )}') },`;\r\n })\r\n .join(\"\\n\")}\r\n ]\r\n `;\r\n }\r\n\r\n // 设定一个访问私有变量的api,用来单元测试\r\n getRouteData(): RouteData[] {\r\n return this.#routeData;\r\n }\r\n}\r\n","import { Plugin } from \"vite\";\r\nimport { RouteService } from \"./RouteService\";\r\nimport { Element } from \"hast\";\r\nimport react, { ComponentType } from \"react\";\r\nimport { Frontmatter } from \"../../../types/index\";\r\n\r\nexport interface PageModule {\r\n default: ComponentType;\r\n frontmatter?: Frontmatter;\r\n [key: string]: unknown;\r\n title?: string;\r\n}\r\nexport interface Route {\r\n path: string;\r\n element: react.ReactElement;\r\n filePath: string;\r\n preload: () => Promise<PageModule>;\r\n}\r\ninterface PluginRoutes {\r\n root: string;\r\n isSSR: boolean;\r\n}\r\n\r\nexport const CONVENTIONAL_ROUTE_ID = \"vigor:routes\";\r\n\r\nexport function pluginRoutes(options: PluginRoutes): Plugin {\r\n const rootService = new RouteService(options.root);\r\n return {\r\n name: \"vigor:routes\",\r\n async configResolved() {\r\n await rootService.init();\r\n },\r\n resolveId(id: string) {\r\n if (id === CONVENTIONAL_ROUTE_ID) {\r\n return \"\\0\" + id;\r\n }\r\n },\r\n load(id: string) {\r\n if (id === \"\\0\" + CONVENTIONAL_ROUTE_ID) {\r\n return rootService.generateRoutesPath(options.isSSR || false);\r\n }\r\n },\r\n };\r\n}\r\n","import { VitePluginConfig } from \"unocss/vite\";\r\nimport { presetAttributify, presetIcons, presetWind } from \"unocss\";\r\n\r\nconst options: VitePluginConfig = {\r\n presets: [presetAttributify(), presetIcons(), presetWind({})],\r\n rules: [\r\n // 下面这种写法和此种写法是一样的,只不过用正则会更加灵活\r\n // [\r\n // \"divider-bottom\",\r\n // {\r\n // \"border-bottom\": \"1px solid var(--vigor-c-divider-light)\"\r\n // }\r\n // ]\r\n [\r\n /^divider-(\\w+)$/,\r\n ([, w]) => ({\r\n [`border-${w}`]: \"1px solid var(--vigor-c-divider-light)\",\r\n }),\r\n ],\r\n ],\r\n shortcuts: {\r\n \"flex-center\": \"flex justify-center items-center\",\r\n },\r\n};\r\n\r\nexport default options;\r\n"]}