vigor-moon 1.0.0 → 1.0.1

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.
Files changed (49) hide show
  1. package/dist/cli.js +5 -3
  2. package/dist/cli.mjs +5 -3
  3. package/package.json +4 -2
  4. package/dist/chunk-2M2XJKGT.js +0 -607
  5. package/dist/chunk-3EAR5BNQ.js +0 -610
  6. package/dist/chunk-3ZCIQMBL.js +0 -608
  7. package/dist/chunk-6SPQ2G5U.js +0 -611
  8. package/dist/chunk-7V4TYSIZ.mjs +0 -619
  9. package/dist/chunk-AT54N5D7.js +0 -611
  10. package/dist/chunk-BBRRUMIN.js +0 -616
  11. package/dist/chunk-BE2AQAQS.mjs +0 -608
  12. package/dist/chunk-BS6X4ZCI.js +0 -608
  13. package/dist/chunk-D2WJMNSR.js +0 -618
  14. package/dist/chunk-DTA4ZJEQ.mjs +0 -606
  15. package/dist/chunk-ECPJL6H6.js +0 -618
  16. package/dist/chunk-EU5K7BUZ.mjs +0 -612
  17. package/dist/chunk-FAELXJ3Z.mjs +0 -605
  18. package/dist/chunk-GBGTGHKN.js +0 -621
  19. package/dist/chunk-HW7CAZGA.js +0 -611
  20. package/dist/chunk-IDQ7PFDG.mjs +0 -619
  21. package/dist/chunk-IPVDS3I7.mjs +0 -609
  22. package/dist/chunk-JHZIOXVJ.js +0 -605
  23. package/dist/chunk-KRBN43PO.js +0 -606
  24. package/dist/chunk-KTIICQHT.mjs +0 -622
  25. package/dist/chunk-KZQIA6WA.js +0 -604
  26. package/dist/chunk-L4MZ52TR.mjs +0 -609
  27. package/dist/chunk-LEOZIK2T.mjs +0 -607
  28. package/dist/chunk-MHZT64KI.mjs +0 -605
  29. package/dist/chunk-NTJI6VKJ.mjs +0 -619
  30. package/dist/chunk-NWZZITYZ.mjs +0 -606
  31. package/dist/chunk-OS3F7QDD.js +0 -606
  32. package/dist/chunk-PJPXX4UA.mjs +0 -605
  33. package/dist/chunk-PW73M55D.mjs +0 -611
  34. package/dist/chunk-R6L6GYA4.mjs +0 -607
  35. package/dist/chunk-RNUPZ4CR.mjs +0 -612
  36. package/dist/chunk-SEIXDGYJ.mjs +0 -615
  37. package/dist/chunk-SYCZ35ZW.js +0 -604
  38. package/dist/chunk-THZGRR4I.js +0 -611
  39. package/dist/chunk-TJ5NMLCW.js +0 -614
  40. package/dist/chunk-TYBNSCBA.mjs +0 -611
  41. package/dist/chunk-UGBCHWPA.js +0 -621
  42. package/dist/chunk-VD42YO6T.mjs +0 -622
  43. package/dist/chunk-VMNTKZYD.js +0 -604
  44. package/dist/chunk-W6MHPTGR.js +0 -605
  45. package/dist/chunk-WBSL45KV.mjs +0 -617
  46. package/dist/chunk-XFGBQ3QD.mjs +0 -612
  47. package/dist/chunk-ZBAZASII.js +0 -618
  48. package/dist/chunk-ZGLENLKC.js +0 -610
  49. package/dist/chunk-ZN4CSBNG.mjs +0 -612
@@ -1,621 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkLS3TOABUjs = require('./chunk-LS3TOABU.js');
4
-
5
- // src/node/dev.ts
6
- var _vite = require('vite');
7
-
8
- // src/node/plugin/indexHtml.ts
9
- var _promises = require('fs/promises');
10
-
11
- // src/node/constants/index.ts
12
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
13
- var PACKAGE_ROOT = _path.join.call(void 0, __dirname, "..");
14
- var DEFAULT_HTML_PATH = _path.join.call(void 0, PACKAGE_ROOT, "template.html");
15
- var CLIENT_ENTRY_PATH = _path.join.call(void 0, PACKAGE_ROOT, "src", "runtime", "client-entry.tsx");
16
- var SERVER_ENTRY_PATH = _path.join.call(void 0, PACKAGE_ROOT, "src", "runtime", "ssr-entry.tsx");
17
-
18
- // src/node/plugin/indexHtml.ts
19
- function pluginIndexHtml() {
20
- return {
21
- name: "vigor: index-html",
22
- apply: "serve",
23
- transformIndexHtml(html) {
24
- return {
25
- html,
26
- tags: [
27
- {
28
- tag: "script",
29
- attrs: {
30
- type: "module",
31
- src: `/@fs/${CLIENT_ENTRY_PATH}`
32
- },
33
- injectTo: "body"
34
- }
35
- ]
36
- };
37
- },
38
- configureServer(server) {
39
- return () => {
40
- server.middlewares.use(async (req, res, next) => {
41
- let html = await _promises.readFile.call(void 0, DEFAULT_HTML_PATH, "utf-8");
42
- try {
43
- html = await server.transformIndexHtml(req.url, html, req.originalUrl);
44
- res.statusCode = 200;
45
- res.setHeader("Content-Type", "text/html");
46
- res.end(html);
47
- } catch (error) {
48
- return next(error);
49
- }
50
- });
51
- };
52
- }
53
- };
54
- }
55
-
56
- // src/node/dev.ts
57
- var _pluginreact = require('@vitejs/plugin-react'); var _pluginreact2 = _interopRequireDefault(_pluginreact);
58
-
59
- // src/node/plugin/config.ts
60
-
61
- var _sirv = require('sirv'); var _sirv2 = _interopRequireDefault(_sirv);
62
-
63
- var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
64
- var SITE_DATA_ID = "vigor:site-data";
65
- function pluginConfig(config) {
66
- return {
67
- name: "vigor:site-data",
68
- resolveId(id) {
69
- if (id === SITE_DATA_ID) {
70
- return "\0" + SITE_DATA_ID;
71
- }
72
- },
73
- load(id) {
74
- if (id === "\0" + SITE_DATA_ID) {
75
- return `export default ${JSON.stringify(config.siteData)}`;
76
- }
77
- },
78
- // 通过config钩子设置别名,此处设置的别名会自动与vite配置中的别名呼应
79
- config() {
80
- return {
81
- root: PACKAGE_ROOT,
82
- resolve: {
83
- alias: {
84
- "@runtime": _path.join.call(void 0, PACKAGE_ROOT, "src", "runtime", "index.ts"),
85
- "@constants": _path.join.call(void 0, PACKAGE_ROOT, "src", "node", "constants", "index.ts"),
86
- "@types": _path.join.call(void 0, PACKAGE_ROOT, "src", "types", "index.ts")
87
- }
88
- },
89
- css: {
90
- // 在scss中定义类名的时候使用 '-' 格式可以转换为小驼峰形式进行使用
91
- // 比如:
92
- // scss: .main-bg
93
- // tsx: mainBg
94
- modules: {
95
- localsConvention: "camelCaseOnly"
96
- }
97
- }
98
- };
99
- },
100
- // 构建一个配置服务器来加载docs文件夹下public中的静态资源
101
- // sirv 是一个优化过的轻量级中间件,用来处理静态资源请求
102
- configureServer(server) {
103
- const publicDir = _path2.default.join(config.root, "public");
104
- if (_fsextra2.default.existsSync(publicDir)) {
105
- server.middlewares.use(_sirv2.default.call(void 0, publicDir));
106
- }
107
- }
108
- // 一个学习的内容,本身未实现,比较复杂的一个逻辑。
109
- // 钩子函数:当配置文件发生改变时,达到热更新的效果
110
- // async handleHotUpdate(ctx) {
111
- // const customWatchedFiles = [config.configPath];
112
- // const include = (id: string) => customWatchedFiles.some((file) => id.includes(file));
113
- // if (include(ctx.file)) {
114
- // `\n${relative(config.root, ctx.file)} has changed, restarting server...`;
115
- // // 重启Dev Server的方案
116
- // // 手动调用dev.ts中的createServer方法
117
- // }
118
- // },
119
- };
120
- }
121
-
122
- // src/node/plugin/plugin-mdx/pluginMdxRollup.ts
123
- var _rollup = require('@mdx-js/rollup'); var _rollup2 = _interopRequireDefault(_rollup);
124
- var _remarkgfm = require('remark-gfm'); var _remarkgfm2 = _interopRequireDefault(_remarkgfm);
125
- var _rehypeautolinkheadings = require('rehype-autolink-headings'); var _rehypeautolinkheadings2 = _interopRequireDefault(_rehypeautolinkheadings);
126
- var _rehypeslug = require('rehype-slug'); var _rehypeslug2 = _interopRequireDefault(_rehypeslug);
127
- var _remarkfrontmatter = require('remark-frontmatter'); var _remarkfrontmatter2 = _interopRequireDefault(_remarkfrontmatter);
128
- var _remarkmdxfrontmatter = require('remark-mdx-frontmatter'); var _remarkmdxfrontmatter2 = _interopRequireDefault(_remarkmdxfrontmatter);
129
-
130
- // node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js
131
- var convert = (
132
- /**
133
- * @type {(
134
- * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &
135
- * ((test?: Test) => AssertAnything)
136
- * )}
137
- */
138
- /**
139
- * @param {Test} [test]
140
- * @returns {AssertAnything}
141
- */
142
- function(test) {
143
- if (test === void 0 || test === null) {
144
- return ok;
145
- }
146
- if (typeof test === "string") {
147
- return typeFactory(test);
148
- }
149
- if (typeof test === "object") {
150
- return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
151
- }
152
- if (typeof test === "function") {
153
- return castFactory(test);
154
- }
155
- throw new Error("Expected function, string, or object as test");
156
- }
157
- );
158
- function anyFactory(tests) {
159
- const checks = [];
160
- let index = -1;
161
- while (++index < tests.length) {
162
- checks[index] = convert(tests[index]);
163
- }
164
- return castFactory(any);
165
- function any(...parameters) {
166
- let index2 = -1;
167
- while (++index2 < checks.length) {
168
- if (checks[index2].call(this, ...parameters))
169
- return true;
170
- }
171
- return false;
172
- }
173
- }
174
- function propsFactory(check) {
175
- return castFactory(all);
176
- function all(node) {
177
- let key;
178
- for (key in check) {
179
- if (node[key] !== check[key])
180
- return false;
181
- }
182
- return true;
183
- }
184
- }
185
- function typeFactory(check) {
186
- return castFactory(type);
187
- function type(node) {
188
- return node && node.type === check;
189
- }
190
- }
191
- function castFactory(check) {
192
- return assertion;
193
- function assertion(node, ...parameters) {
194
- return Boolean(
195
- node && typeof node === "object" && "type" in node && // @ts-expect-error: fine.
196
- Boolean(check.call(this, node, ...parameters))
197
- );
198
- }
199
- }
200
- function ok() {
201
- return true;
202
- }
203
-
204
- // node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js
205
- function color(d) {
206
- return "\x1B[33m" + d + "\x1B[39m";
207
- }
208
-
209
- // node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js
210
- var CONTINUE = true;
211
- var EXIT = false;
212
- var SKIP = "skip";
213
- var visitParents = (
214
- /**
215
- * @type {(
216
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
217
- * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
218
- * )}
219
- */
220
- /**
221
- * @param {Node} tree
222
- * @param {Test} test
223
- * @param {Visitor<Node>} visitor
224
- * @param {boolean | null | undefined} [reverse]
225
- * @returns {void}
226
- */
227
- function(tree, test, visitor, reverse) {
228
- if (typeof test === "function" && typeof visitor !== "function") {
229
- reverse = visitor;
230
- visitor = test;
231
- test = null;
232
- }
233
- const is2 = convert(test);
234
- const step = reverse ? -1 : 1;
235
- factory(tree, void 0, [])();
236
- function factory(node, index, parents) {
237
- const value = node && typeof node === "object" ? node : {};
238
- if (typeof value.type === "string") {
239
- const name = (
240
- // `hast`
241
- typeof value.tagName === "string" ? value.tagName : (
242
- // `xast`
243
- typeof value.name === "string" ? value.name : void 0
244
- )
245
- );
246
- Object.defineProperty(visit2, "name", {
247
- value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")"
248
- });
249
- }
250
- return visit2;
251
- function visit2() {
252
- let result = [];
253
- let subresult;
254
- let offset;
255
- let grandparents;
256
- if (!test || is2(node, index, parents[parents.length - 1] || null)) {
257
- result = toResult(visitor(node, parents));
258
- if (result[0] === EXIT) {
259
- return result;
260
- }
261
- }
262
- if (node.children && result[0] !== SKIP) {
263
- offset = (reverse ? node.children.length : -1) + step;
264
- grandparents = parents.concat(node);
265
- while (offset > -1 && offset < node.children.length) {
266
- subresult = factory(node.children[offset], offset, grandparents)();
267
- if (subresult[0] === EXIT) {
268
- return subresult;
269
- }
270
- offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
271
- }
272
- }
273
- return result;
274
- }
275
- }
276
- }
277
- );
278
- function toResult(value) {
279
- if (Array.isArray(value)) {
280
- return value;
281
- }
282
- if (typeof value === "number") {
283
- return [CONTINUE, value];
284
- }
285
- return [value];
286
- }
287
-
288
- // node_modules/.pnpm/unist-util-visit@4.1.2/node_modules/unist-util-visit/lib/index.js
289
- var visit = (
290
- /**
291
- * @type {(
292
- * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: BuildVisitor<Tree, Check>, reverse?: boolean | null | undefined) => void) &
293
- * (<Tree extends Node>(tree: Tree, visitor: BuildVisitor<Tree>, reverse?: boolean | null | undefined) => void)
294
- * )}
295
- */
296
- /**
297
- * @param {Node} tree
298
- * @param {Test} test
299
- * @param {Visitor} visitor
300
- * @param {boolean | null | undefined} [reverse]
301
- * @returns {void}
302
- */
303
- function(tree, test, visitor, reverse) {
304
- if (typeof test === "function" && typeof visitor !== "function") {
305
- reverse = visitor;
306
- visitor = test;
307
- test = null;
308
- }
309
- visitParents(tree, test, overload, reverse);
310
- function overload(node, parents) {
311
- const parent = parents[parents.length - 1];
312
- return visitor(
313
- node,
314
- parent ? parent.children.indexOf(node) : null,
315
- parent
316
- );
317
- }
318
- }
319
- );
320
-
321
- // src/node/plugin/plugin-mdx/rehypePlugins/preWrapper.ts
322
- var preWrapperPlugin = () => {
323
- return (tree) => {
324
- visit(tree, "element", (node) => {
325
- if (node.tagName === "pre" && _optionalChain([node, 'access', _ => _.children, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.type]) === "element" && node.children[0].tagName === "code" && !_optionalChain([node, 'access', _4 => _4.data, 'optionalAccess', _5 => _5.isVisited])) {
326
- const codeNode = node.children[0];
327
- const codeClassName = _optionalChain([codeNode, 'access', _6 => _6.properties, 'optionalAccess', _7 => _7.className, 'optionalAccess', _8 => _8.toString, 'call', _9 => _9()]) || "";
328
- const lang = codeClassName.split("-")[1];
329
- const nodeClone = {
330
- type: "element",
331
- tagName: "pre",
332
- children: node.children,
333
- data: {
334
- isVisited: true
335
- }
336
- };
337
- node.tagName = "div";
338
- node.properties = node.properties || {};
339
- node.properties.className = codeClassName;
340
- node.children = [
341
- {
342
- type: "element",
343
- tagName: "span",
344
- properties: {
345
- className: "lang"
346
- },
347
- children: [
348
- {
349
- type: "text",
350
- value: lang
351
- }
352
- ]
353
- },
354
- nodeClone
355
- ];
356
- }
357
- });
358
- };
359
- };
360
-
361
- // src/node/plugin/plugin-mdx/rehypePlugins/shiki.ts
362
- var _hastutilfromhtml = require('hast-util-from-html');
363
- var shikiPlugin = ({ highlighter }) => {
364
- return (tree) => {
365
- visit(tree, "element", (node, index, parent) => {
366
- if (node.tagName === "pre" && _optionalChain([node, 'access', _10 => _10.children, 'access', _11 => _11[0], 'optionalAccess', _12 => _12.type]) === "element" && _optionalChain([node, 'access', _13 => _13.children, 'access', _14 => _14[0], 'optionalAccess', _15 => _15.tagName]) === "code") {
367
- const codeNode = node.children[0];
368
- const codeContent = codeNode.children[0].value;
369
- const codeClassName = _optionalChain([codeNode, 'access', _16 => _16.properties, 'optionalAccess', _17 => _17.className, 'optionalAccess', _18 => _18.toString, 'call', _19 => _19()]) || "";
370
- const lang = codeClassName.split("-")[1];
371
- if (!lang)
372
- return;
373
- const highlightCode = highlighter.codeToHtml(codeContent, { lang });
374
- const fragmentAST = _hastutilfromhtml.fromHtml.call(void 0, highlightCode, { fragment: true });
375
- parent.children.splice(index, 1, ...fragmentAST.children);
376
- }
377
- });
378
- };
379
- };
380
-
381
- // src/node/plugin/plugin-mdx/pluginMdxRollup.ts
382
- var _shiki = require('shiki'); var _shiki2 = _interopRequireDefault(_shiki);
383
-
384
- // src/node/plugin/plugin-mdx/remarkPlugins/toc.ts
385
- var _githubslugger = require('github-slugger'); var _githubslugger2 = _interopRequireDefault(_githubslugger);
386
- var _acorn = require('acorn');
387
- var slugger = new (0, _githubslugger2.default)();
388
- var title = "";
389
- var TOCPlugin = () => {
390
- return (tree) => {
391
- const tocTree = [];
392
- visit(tree, "heading", (node) => {
393
- if (!node.depth || !node.children) {
394
- return;
395
- }
396
- if (node.depth === 1) {
397
- title = node.children[0].value;
398
- }
399
- if (node.depth > 1 && node.depth < 5) {
400
- const originText = node.children.map((child) => {
401
- switch (child.type) {
402
- case "link":
403
- return _optionalChain([child, 'access', _20 => _20.children, 'optionalAccess', _21 => _21.map, 'call', _22 => _22((c) => c.value), 'access', _23 => _23.join, 'call', _24 => _24("")]) || "";
404
- default:
405
- return child.value;
406
- }
407
- }).join("");
408
- const id = slugger.slug(originText);
409
- tocTree.push({
410
- id,
411
- text: originText,
412
- depth: node.depth
413
- });
414
- }
415
- });
416
- const insertCode = `export const toc = ${JSON.stringify(tocTree, null, 2)};`;
417
- tree.children.push({
418
- type: "mdxjsEsm",
419
- value: insertCode,
420
- data: {
421
- estree: _acorn.parse.call(void 0, insertCode, {
422
- ecmaVersion: 2020,
423
- sourceType: "module"
424
- })
425
- }
426
- });
427
- if (title) {
428
- const insertTitle = `export const title = "${title}";`;
429
- tree.children.push({
430
- type: "mdxjsEsm",
431
- value: insertTitle,
432
- data: {
433
- estree: _acorn.parse.call(void 0, insertTitle, {
434
- ecmaVersion: 2020,
435
- sourceType: "module"
436
- })
437
- }
438
- });
439
- }
440
- };
441
- };
442
-
443
- // src/node/plugin/plugin-mdx/pluginMdxRollup.ts
444
- async function pluginMdxRollup() {
445
- return _rollup2.default.call(void 0, {
446
- // 添加github的markdown标准-GFM语法
447
- remarkPlugins: [
448
- _remarkgfm2.default,
449
- _remarkfrontmatter2.default,
450
- [_remarkmdxfrontmatter2.default, { name: "frontmatter" }],
451
- TOCPlugin
452
- ],
453
- // md文件解析插件
454
- rehypePlugins: [
455
- _rehypeslug2.default,
456
- [
457
- _rehypeautolinkheadings2.default,
458
- {
459
- properties: {
460
- class: "header-anchor"
461
- },
462
- content: {
463
- type: "text",
464
- value: "#"
465
- }
466
- }
467
- ],
468
- preWrapperPlugin,
469
- [shikiPlugin, { highlighter: await _shiki2.default.getHighlighter({ theme: "nord" }) }]
470
- ]
471
- });
472
- }
473
-
474
- // src/node/plugin/plugin-mdx/index.ts
475
- async function pluginMdx2() {
476
- return [await pluginMdxRollup()];
477
- }
478
-
479
- // src/node/plugin/plugin-routes/RouteService.ts
480
- var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
481
-
482
-
483
- var RouteService = class {
484
- // #scanDir是定义一个私有变量
485
- #scanDir;
486
- // 路由信息数组
487
- #routeData = [];
488
- constructor(scanDir) {
489
- this.#scanDir = scanDir;
490
- }
491
- async init() {
492
- const files = _fastglob2.default.sync(["**/*.{js,jsx,ts,tsx,md,mdx}"], {
493
- cwd: this.#scanDir,
494
- absolute: true,
495
- ignore: ["**/build/**", "**/.vigor/**", "config.ts", "tsconfig.json"]
496
- }).sort();
497
- files.forEach((file) => {
498
- const fileRelativePath = _vite.normalizePath.call(void 0, _path2.default.relative(this.#scanDir, file));
499
- const routePath = this.getRoutePath(fileRelativePath);
500
- this.#routeData.push({
501
- routePath,
502
- absolutePath: file
503
- });
504
- });
505
- }
506
- // 得到路由路径
507
- getRoutePath(fileRelativePath) {
508
- const routePath = fileRelativePath.replace(/\.(.*)?$/, "").replace(/index$/, "");
509
- return routePath.startsWith("/") ? routePath : `/${routePath}`;
510
- }
511
- // 生成路由页面代码
512
- generateRoutesPath(ssr) {
513
- return `
514
- import React from 'react';
515
- ${ssr ? "" : 'import loadable from "@loadable/component";'}
516
- ${this.#routeData.map((route, index) => {
517
- return ssr ? `import Route${index} from "${_vite.normalizePath.call(void 0, route.absolutePath)}";` : `const Route${index} = loadable(() => import('${_vite.normalizePath.call(void 0,
518
- route.absolutePath
519
- )}')); `;
520
- }).join("\n")}
521
-
522
- export const routes = [
523
- ${this.#routeData.map((route, index) => {
524
- return `{ path: '${_vite.normalizePath.call(void 0,
525
- route.routePath
526
- )}', element: React.createElement(Route${index}), preload: () => import('${_vite.normalizePath.call(void 0,
527
- route.absolutePath
528
- )}') },`;
529
- }).join("\n")}
530
- ]
531
- `;
532
- }
533
- // 设定一个访问私有变量的api,用来单元测试
534
- getRouteData() {
535
- return this.#routeData;
536
- }
537
- };
538
-
539
- // src/node/plugin/plugin-routes/index.ts
540
- var CONVENTIONAL_ROUTE_ID = "vigor:routes";
541
- function pluginRoutes(options2) {
542
- const rootService = new RouteService(options2.root);
543
- return {
544
- name: "vigor:routes",
545
- async configResolved() {
546
- await rootService.init();
547
- },
548
- resolveId(id) {
549
- if (id === CONVENTIONAL_ROUTE_ID) {
550
- return "\0" + id;
551
- }
552
- },
553
- load(id) {
554
- if (id === "\0" + CONVENTIONAL_ROUTE_ID) {
555
- return rootService.generateRoutesPath(options2.isSSR || false);
556
- }
557
- }
558
- };
559
- }
560
-
561
- // src/node/dev.ts
562
- var _vite3 = require('unocss/vite'); var _vite4 = _interopRequireDefault(_vite3);
563
-
564
- // src/node/unocssOptions.ts
565
- var _unocss = require('unocss');
566
- var options = {
567
- presets: [_unocss.presetAttributify.call(void 0, ), _unocss.presetIcons.call(void 0, ), _unocss.presetWind.call(void 0, {})],
568
- rules: [
569
- // 下面这种写法和此种写法是一样的,只不过用正则会更加灵活
570
- // [
571
- // "divider-bottom",
572
- // {
573
- // "border-bottom": "1px solid var(--island-c-divider-light)"
574
- // }
575
- // ]
576
- [
577
- /^divider-(\w+)$/,
578
- ([, w]) => ({
579
- [`border-${w}`]: "1px solid var(--vigor-c-divider-light)"
580
- })
581
- ]
582
- ],
583
- shortcuts: {
584
- "flex-center": "flex justify-center items-center"
585
- }
586
- };
587
- var unocssOptions_default = options;
588
-
589
- // src/node/dev.ts
590
- async function createDevServer(root, isSSR = false) {
591
- const config = await _chunkLS3TOABUjs.resolveConfig.call(void 0, root, "serve", "development");
592
- return _vite.createServer.call(void 0, {
593
- root: PACKAGE_ROOT,
594
- // 插件注册
595
- plugins: [
596
- _vite4.default.call(void 0, unocssOptions_default),
597
- pluginIndexHtml(),
598
- _pluginreact2.default.call(void 0, ),
599
- pluginConfig(config),
600
- pluginRoutes({ root: config.root, isSSR }),
601
- await pluginMdx2()
602
- ],
603
- // 配置e2e的服务器检索目录外的项目的合法性
604
- server: {
605
- fs: {
606
- allow: [PACKAGE_ROOT]
607
- }
608
- }
609
- });
610
- }
611
-
612
-
613
-
614
-
615
-
616
-
617
-
618
-
619
-
620
-
621
- exports.CLIENT_ENTRY_PATH = CLIENT_ENTRY_PATH; exports.SERVER_ENTRY_PATH = SERVER_ENTRY_PATH; exports.pluginIndexHtml = pluginIndexHtml; exports.pluginConfig = pluginConfig; exports.pluginMdx = pluginMdx2; exports.pluginRoutes = pluginRoutes; exports.unocssOptions_default = unocssOptions_default; exports.createDevServer = createDevServer;