@uni-helper/vite-plugin-uni-pages 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.d.ts CHANGED
@@ -6,6 +6,8 @@ declare module 'virtual:uni-pages' {
6
6
  export const subPackages: SubPackage[]
7
7
  }
8
8
 
9
- declare namespace globalThis {
10
- export const definePage: import('.').DefinePage
9
+ declare global {
10
+ const definePage: import('.').DefinePage
11
11
  }
12
+
13
+ export {}
package/dist/index.cjs CHANGED
@@ -478,7 +478,10 @@ async function tryPageMetaFromMacro(sfc) {
478
478
  code,
479
479
  filename: sfc.filename
480
480
  });
481
- return result;
481
+ return {
482
+ type: "page",
483
+ ...result
484
+ };
482
485
  }
483
486
  return void 0;
484
487
  }
@@ -494,21 +497,21 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
494
497
  return pageMeta;
495
498
  }
496
499
  function findMacro(stmts, filename) {
497
- const nodes = stmts.map((raw) => {
498
- let node = raw;
499
- if (raw.type === "ExpressionStatement")
500
- node = raw.expression;
501
- return astKit.isCallOf(node, "definePage") ? node : void 0;
502
- }).filter((node) => !!node);
503
- if (!nodes.length)
504
- return;
505
- if (nodes.length > 1) {
506
- throw new Error(`\u6BCF\u4E2A\u6587\u4EF6\u53EA\u5141\u8BB8\u8C03\u7528\u4E00\u6B21 definePage(): ${filename}`);
500
+ let macro;
501
+ for (const stmt of stmts) {
502
+ let node = stmt;
503
+ if (stmt.type === "ExpressionStatement")
504
+ node = stmt.expression;
505
+ if (astKit.isCallOf(node, "definePage")) {
506
+ macro = node;
507
+ break;
508
+ }
507
509
  }
508
- const macro = nodes[0];
510
+ if (!macro)
511
+ return;
509
512
  const [opt] = macro.arguments;
510
513
  if (opt && !t__namespace.isFunctionExpression(opt) && !t__namespace.isArrowFunctionExpression(opt) && !t__namespace.isObjectExpression(opt)) {
511
- debug.definePage(`definePage() only accept argument in function or object: ${filename}`);
514
+ debug.definePage(`definePage() \u53C2\u6570\u4EC5\u652F\u6301\u51FD\u6570\u6216\u5BF9\u8C61: ${filename}`);
512
515
  return;
513
516
  }
514
517
  return macro;
package/dist/index.mjs CHANGED
@@ -444,7 +444,10 @@ async function tryPageMetaFromMacro(sfc) {
444
444
  code,
445
445
  filename: sfc.filename
446
446
  });
447
- return result;
447
+ return {
448
+ type: "page",
449
+ ...result
450
+ };
448
451
  }
449
452
  return void 0;
450
453
  }
@@ -460,21 +463,21 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
460
463
  return pageMeta;
461
464
  }
462
465
  function findMacro(stmts, filename) {
463
- const nodes = stmts.map((raw) => {
464
- let node = raw;
465
- if (raw.type === "ExpressionStatement")
466
- node = raw.expression;
467
- return isCallOf(node, "definePage") ? node : void 0;
468
- }).filter((node) => !!node);
469
- if (!nodes.length)
470
- return;
471
- if (nodes.length > 1) {
472
- throw new Error(`\u6BCF\u4E2A\u6587\u4EF6\u53EA\u5141\u8BB8\u8C03\u7528\u4E00\u6B21 definePage(): ${filename}`);
466
+ let macro;
467
+ for (const stmt of stmts) {
468
+ let node = stmt;
469
+ if (stmt.type === "ExpressionStatement")
470
+ node = stmt.expression;
471
+ if (isCallOf(node, "definePage")) {
472
+ macro = node;
473
+ break;
474
+ }
473
475
  }
474
- const macro = nodes[0];
476
+ if (!macro)
477
+ return;
475
478
  const [opt] = macro.arguments;
476
479
  if (opt && !t.isFunctionExpression(opt) && !t.isArrowFunctionExpression(opt) && !t.isObjectExpression(opt)) {
477
- debug.definePage(`definePage() only accept argument in function or object: ${filename}`);
480
+ debug.definePage(`definePage() \u53C2\u6570\u4EC5\u652F\u6301\u51FD\u6570\u6216\u5BF9\u8C61: ${filename}`);
478
481
  return;
479
482
  }
480
483
  return macro;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uni-helper/vite-plugin-uni-pages",
3
3
  "type": "module",
4
- "version": "0.3.7",
4
+ "version": "0.3.9",
5
5
  "description": "File system based routing for uni-app applications using Vite",
6
6
  "author": "KeJun",
7
7
  "maintainers": [