vigor-moon 1.0.0 → 1.0.2

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 (53) hide show
  1. package/dist/{chunk-CG4W75R5.mjs → chunk-2PYRPSJR.mjs} +1 -1
  2. package/dist/{chunk-X5IY67V6.js → chunk-WBWQEJDT.js} +1 -1
  3. package/dist/cli.js +13 -11
  4. package/dist/cli.mjs +6 -4
  5. package/dist/dev.js +2 -2
  6. package/dist/dev.mjs +1 -1
  7. package/package.json +4 -2
  8. package/dist/chunk-2M2XJKGT.js +0 -607
  9. package/dist/chunk-3EAR5BNQ.js +0 -610
  10. package/dist/chunk-3ZCIQMBL.js +0 -608
  11. package/dist/chunk-6SPQ2G5U.js +0 -611
  12. package/dist/chunk-7V4TYSIZ.mjs +0 -619
  13. package/dist/chunk-AT54N5D7.js +0 -611
  14. package/dist/chunk-BBRRUMIN.js +0 -616
  15. package/dist/chunk-BE2AQAQS.mjs +0 -608
  16. package/dist/chunk-BS6X4ZCI.js +0 -608
  17. package/dist/chunk-D2WJMNSR.js +0 -618
  18. package/dist/chunk-DTA4ZJEQ.mjs +0 -606
  19. package/dist/chunk-ECPJL6H6.js +0 -618
  20. package/dist/chunk-EU5K7BUZ.mjs +0 -612
  21. package/dist/chunk-FAELXJ3Z.mjs +0 -605
  22. package/dist/chunk-GBGTGHKN.js +0 -621
  23. package/dist/chunk-HW7CAZGA.js +0 -611
  24. package/dist/chunk-IDQ7PFDG.mjs +0 -619
  25. package/dist/chunk-IPVDS3I7.mjs +0 -609
  26. package/dist/chunk-JHZIOXVJ.js +0 -605
  27. package/dist/chunk-KRBN43PO.js +0 -606
  28. package/dist/chunk-KTIICQHT.mjs +0 -622
  29. package/dist/chunk-KZQIA6WA.js +0 -604
  30. package/dist/chunk-L4MZ52TR.mjs +0 -609
  31. package/dist/chunk-LEOZIK2T.mjs +0 -607
  32. package/dist/chunk-MHZT64KI.mjs +0 -605
  33. package/dist/chunk-NTJI6VKJ.mjs +0 -619
  34. package/dist/chunk-NWZZITYZ.mjs +0 -606
  35. package/dist/chunk-OS3F7QDD.js +0 -606
  36. package/dist/chunk-PJPXX4UA.mjs +0 -605
  37. package/dist/chunk-PW73M55D.mjs +0 -611
  38. package/dist/chunk-R6L6GYA4.mjs +0 -607
  39. package/dist/chunk-RNUPZ4CR.mjs +0 -612
  40. package/dist/chunk-SEIXDGYJ.mjs +0 -615
  41. package/dist/chunk-SYCZ35ZW.js +0 -604
  42. package/dist/chunk-THZGRR4I.js +0 -611
  43. package/dist/chunk-TJ5NMLCW.js +0 -614
  44. package/dist/chunk-TYBNSCBA.mjs +0 -611
  45. package/dist/chunk-UGBCHWPA.js +0 -621
  46. package/dist/chunk-VD42YO6T.mjs +0 -622
  47. package/dist/chunk-VMNTKZYD.js +0 -604
  48. package/dist/chunk-W6MHPTGR.js +0 -605
  49. package/dist/chunk-WBSL45KV.mjs +0 -617
  50. package/dist/chunk-XFGBQ3QD.mjs +0 -612
  51. package/dist/chunk-ZBAZASII.js +0 -618
  52. package/dist/chunk-ZGLENLKC.js +0 -610
  53. package/dist/chunk-ZN4CSBNG.mjs +0 -612
@@ -1,606 +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.pathExistsSync(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 TOCPlugin = () => {
389
- return (tree) => {
390
- const tocTree = [];
391
- visit(tree, "heading", (node) => {
392
- if (!node.depth || !node.children) {
393
- return;
394
- }
395
- if (node.depth === 1) {
396
- }
397
- if (node.depth > 1 && node.depth < 5) {
398
- const originText = node.children.map((child) => {
399
- switch (child.type) {
400
- case "link":
401
- return _optionalChain([child, 'access', _20 => _20.children, 'optionalAccess', _21 => _21.map, 'call', _22 => _22((c) => c.value), 'access', _23 => _23.join, 'call', _24 => _24("")]) || "";
402
- default:
403
- return child.value;
404
- }
405
- }).join("");
406
- const id = slugger.slug(originText);
407
- tocTree.push({
408
- id,
409
- text: originText,
410
- depth: node.depth
411
- });
412
- }
413
- });
414
- const insertCode = `export const toc = ${JSON.stringify(tocTree, null, 2)};`;
415
- tree.children.push({
416
- type: "mdxjsEsm",
417
- value: insertCode,
418
- data: {
419
- estree: _acorn.parse.call(void 0, insertCode, {
420
- ecmaVersion: 2020,
421
- sourceType: "module"
422
- })
423
- }
424
- });
425
- };
426
- };
427
-
428
- // src/node/plugin/plugin-mdx/pluginMdxRollup.ts
429
- async function pluginMdxRollup() {
430
- return _rollup2.default.call(void 0, {
431
- // 添加github的markdown标准-GFM语法
432
- remarkPlugins: [
433
- _remarkgfm2.default,
434
- _remarkfrontmatter2.default,
435
- [_remarkmdxfrontmatter2.default, { name: "frontmatter" }],
436
- TOCPlugin
437
- ],
438
- // md文件解析插件
439
- rehypePlugins: [
440
- _rehypeslug2.default,
441
- [
442
- _rehypeautolinkheadings2.default,
443
- {
444
- properties: {
445
- class: "header-anchor"
446
- },
447
- content: {
448
- type: "text",
449
- value: "#"
450
- }
451
- }
452
- ],
453
- preWrapperPlugin,
454
- [shikiPlugin, { highlighter: await _shiki2.default.getHighlighter({ theme: "nord" }) }]
455
- ]
456
- });
457
- }
458
-
459
- // src/node/plugin/plugin-mdx/index.ts
460
- async function pluginMdx2() {
461
- return [await pluginMdxRollup()];
462
- }
463
-
464
- // src/node/plugin/plugin-routes/RouteService.ts
465
- var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
466
-
467
-
468
- var RouteService = class {
469
- // #scanDir是定义一个私有变量
470
- #scanDir;
471
- // 路由信息数组
472
- #routeData = [];
473
- constructor(scanDir) {
474
- this.#scanDir = scanDir;
475
- }
476
- async init() {
477
- const files = _fastglob2.default.sync(["**/*.{js,jsx,ts,tsx,md,mdx}"], {
478
- cwd: this.#scanDir,
479
- absolute: true,
480
- ignore: ["**/build/**", "**/.vigor/**", "config.ts", "tsconfig.json"]
481
- }).sort();
482
- files.forEach((file) => {
483
- const fileRelativePath = _vite.normalizePath.call(void 0, _path2.default.relative(this.#scanDir, file));
484
- const routePath = this.getRoutePath(fileRelativePath);
485
- this.#routeData.push({
486
- routePath,
487
- absolutePath: file
488
- });
489
- });
490
- }
491
- // 得到路由路径
492
- getRoutePath(fileRelativePath) {
493
- const routePath = fileRelativePath.replace(/\.(.*)?$/, "").replace(/index$/, "");
494
- return routePath.startsWith("/") ? routePath : `/${routePath}`;
495
- }
496
- // 生成路由页面代码
497
- generateRoutesPath(ssr) {
498
- return `
499
- import React from 'react';
500
- ${ssr ? "" : 'import loadable from "@loadable/component";'}
501
- ${this.#routeData.map((route, index) => {
502
- return ssr ? `import Route${index} from "${_vite.normalizePath.call(void 0, route.absolutePath)}";` : `const Route${index} = loadable(() => import('${_vite.normalizePath.call(void 0,
503
- route.absolutePath
504
- )}')); `;
505
- }).join("\n")}
506
-
507
- export const routes = [
508
- ${this.#routeData.map((route, index) => {
509
- return `{ path: '${_vite.normalizePath.call(void 0,
510
- route.routePath
511
- )}', element: React.createElement(Route${index}), preload: () => import('${_vite.normalizePath.call(void 0,
512
- route.absolutePath
513
- )}') },`;
514
- }).join("\n")}
515
- ]
516
- `;
517
- }
518
- // 设定一个访问私有变量的api,用来单元测试
519
- getRouteData() {
520
- return this.#routeData;
521
- }
522
- };
523
-
524
- // src/node/plugin/plugin-routes/index.ts
525
- var CONVENTIONAL_ROUTE_ID = "vigor:routes";
526
- function pluginRoutes(options2) {
527
- const rootService = new RouteService(options2.root);
528
- return {
529
- name: "vigor:routes",
530
- async configResolved() {
531
- await rootService.init();
532
- },
533
- resolveId(id) {
534
- if (id === CONVENTIONAL_ROUTE_ID) {
535
- return "\0" + id;
536
- }
537
- },
538
- load(id) {
539
- if (id === "\0" + CONVENTIONAL_ROUTE_ID) {
540
- return rootService.generateRoutesPath(options2.isSSR || false);
541
- }
542
- }
543
- };
544
- }
545
-
546
- // src/node/dev.ts
547
- var _vite3 = require('unocss/vite'); var _vite4 = _interopRequireDefault(_vite3);
548
-
549
- // src/node/unocssOptions.ts
550
- var _unocss = require('unocss');
551
- var options = {
552
- presets: [_unocss.presetAttributify.call(void 0, ), _unocss.presetIcons.call(void 0, ), _unocss.presetWind.call(void 0, {})],
553
- rules: [
554
- // 下面这种写法和此种写法是一样的,只不过用正则会更加灵活
555
- // [
556
- // "divider-bottom",
557
- // {
558
- // "border-bottom": "1px solid var(--island-c-divider-light)"
559
- // }
560
- // ]
561
- [
562
- /^divider-(\w+)$/,
563
- ([, w]) => ({
564
- [`border-${w}`]: "1px solid var(--vigor-c-divider-light)"
565
- })
566
- ]
567
- ],
568
- shortcuts: {
569
- "flex-center": "flex justify-center items-center"
570
- }
571
- };
572
- var unocssOptions_default = options;
573
-
574
- // src/node/dev.ts
575
- async function createDevServer(root, isSSR = false) {
576
- const config = await _chunkLS3TOABUjs.resolveConfig.call(void 0, root, "serve", "development");
577
- return _vite.createServer.call(void 0, {
578
- root: PACKAGE_ROOT,
579
- // 插件注册
580
- plugins: [
581
- _vite4.default.call(void 0, unocssOptions_default),
582
- pluginIndexHtml(),
583
- _pluginreact2.default.call(void 0, ),
584
- pluginConfig(config),
585
- pluginRoutes({ root: config.root, isSSR }),
586
- await pluginMdx2()
587
- ],
588
- // 配置e2e的服务器检索目录外的项目的合法性
589
- server: {
590
- fs: {
591
- allow: [PACKAGE_ROOT]
592
- }
593
- }
594
- });
595
- }
596
-
597
-
598
-
599
-
600
-
601
-
602
-
603
-
604
-
605
-
606
- 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;