@uni-helper/vite-plugin-uni-pages 0.3.8 → 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
@@ -497,21 +497,21 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
497
497
  return pageMeta;
498
498
  }
499
499
  function findMacro(stmts, filename) {
500
- const nodes = stmts.map((raw) => {
501
- let node = raw;
502
- if (raw.type === "ExpressionStatement")
503
- node = raw.expression;
504
- return astKit.isCallOf(node, "definePage") ? node : void 0;
505
- }).filter((node) => !!node);
506
- if (!nodes.length)
507
- return;
508
- if (nodes.length > 1) {
509
- 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
+ }
510
509
  }
511
- const macro = nodes[0];
510
+ if (!macro)
511
+ return;
512
512
  const [opt] = macro.arguments;
513
513
  if (opt && !t__namespace.isFunctionExpression(opt) && !t__namespace.isArrowFunctionExpression(opt) && !t__namespace.isObjectExpression(opt)) {
514
- 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}`);
515
515
  return;
516
516
  }
517
517
  return macro;
package/dist/index.mjs CHANGED
@@ -463,21 +463,21 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
463
463
  return pageMeta;
464
464
  }
465
465
  function findMacro(stmts, filename) {
466
- const nodes = stmts.map((raw) => {
467
- let node = raw;
468
- if (raw.type === "ExpressionStatement")
469
- node = raw.expression;
470
- return isCallOf(node, "definePage") ? node : void 0;
471
- }).filter((node) => !!node);
472
- if (!nodes.length)
473
- return;
474
- if (nodes.length > 1) {
475
- 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
+ }
476
475
  }
477
- const macro = nodes[0];
476
+ if (!macro)
477
+ return;
478
478
  const [opt] = macro.arguments;
479
479
  if (opt && !t.isFunctionExpression(opt) && !t.isArrowFunctionExpression(opt) && !t.isObjectExpression(opt)) {
480
- 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}`);
481
481
  return;
482
482
  }
483
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.8",
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": [