@uni-helper/vite-plugin-uni-pages 0.2.10 → 0.2.12
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/dist/index.cjs +11 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +11 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const MagicString = require('magic-string');
|
|
|
10
10
|
const chokidar = require('chokidar');
|
|
11
11
|
const unconfig = require('unconfig');
|
|
12
12
|
const Debug = require('debug');
|
|
13
|
+
const uniEnv = require('@uni-helper/uni-env');
|
|
13
14
|
const fs = require('node:fs');
|
|
14
15
|
const promises = require('node:fs/promises');
|
|
15
16
|
const lodashUnified = require('lodash-unified');
|
|
@@ -327,6 +328,7 @@ class PageContext {
|
|
|
327
328
|
__publicField(this, "root");
|
|
328
329
|
__publicField(this, "options");
|
|
329
330
|
__publicField(this, "logger");
|
|
331
|
+
__publicField(this, "withUniPlatform", false);
|
|
330
332
|
this.rawOptions = userOptions;
|
|
331
333
|
this.root = slash(viteRoot);
|
|
332
334
|
debug.options("root", this.root);
|
|
@@ -459,7 +461,7 @@ class PageContext {
|
|
|
459
461
|
if (hasHome)
|
|
460
462
|
return true;
|
|
461
463
|
const isFoundHome = result.some((item) => {
|
|
462
|
-
if (this.options.homePage.
|
|
464
|
+
if (this.options.homePage.some((v) => v.startsWith(item.path))) {
|
|
463
465
|
item.type = "home";
|
|
464
466
|
return true;
|
|
465
467
|
} else {
|
|
@@ -515,6 +517,12 @@ class PageContext {
|
|
|
515
517
|
await this.mergePageMetaData();
|
|
516
518
|
await this.mergeSubPageMetaData();
|
|
517
519
|
this.options.onAfterMergePageMetaData(this);
|
|
520
|
+
if (this.withUniPlatform) {
|
|
521
|
+
const pagesMap = /* @__PURE__ */ new Map();
|
|
522
|
+
const pages = this.pageMetaData.filter((v) => !/\..*$/.test(v.path) || v.path.includes(uniEnv.platform)).map((v) => ({ ...v, path: v.path.replace(/\..*$/, "") }));
|
|
523
|
+
pages.forEach((v) => pagesMap.set(v.path, v));
|
|
524
|
+
this.pageMetaData = [...pagesMap.values()];
|
|
525
|
+
}
|
|
518
526
|
this.options.onBeforeWriteFile(this);
|
|
519
527
|
const data = {
|
|
520
528
|
...this.pagesGlobConfig,
|
|
@@ -593,6 +601,8 @@ function VitePluginUniPages(userOptions = {}) {
|
|
|
593
601
|
enforce: "pre",
|
|
594
602
|
async configResolved(config) {
|
|
595
603
|
ctx = new PageContext(userOptions, config.root);
|
|
604
|
+
if (config.plugins.some((v) => v.name === "vite-plugin-uni-platform"))
|
|
605
|
+
ctx.withUniPlatform = true;
|
|
596
606
|
const logger = vite.createLogger(void 0, {
|
|
597
607
|
prefix: "[vite-plugin-uni-pages]"
|
|
598
608
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -649,6 +649,7 @@ declare class PageContext {
|
|
|
649
649
|
root: string;
|
|
650
650
|
options: ResolvedOptions;
|
|
651
651
|
logger?: Logger;
|
|
652
|
+
withUniPlatform: boolean;
|
|
652
653
|
constructor(userOptions: UserOptions, viteRoot?: string);
|
|
653
654
|
setLogger(logger: Logger): void;
|
|
654
655
|
loadUserPagesConfig(): Promise<void>;
|
package/dist/index.d.mts
CHANGED
|
@@ -649,6 +649,7 @@ declare class PageContext {
|
|
|
649
649
|
root: string;
|
|
650
650
|
options: ResolvedOptions;
|
|
651
651
|
logger?: Logger;
|
|
652
|
+
withUniPlatform: boolean;
|
|
652
653
|
constructor(userOptions: UserOptions, viteRoot?: string);
|
|
653
654
|
setLogger(logger: Logger): void;
|
|
654
655
|
loadUserPagesConfig(): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -649,6 +649,7 @@ declare class PageContext {
|
|
|
649
649
|
root: string;
|
|
650
650
|
options: ResolvedOptions;
|
|
651
651
|
logger?: Logger;
|
|
652
|
+
withUniPlatform: boolean;
|
|
652
653
|
constructor(userOptions: UserOptions, viteRoot?: string);
|
|
653
654
|
setLogger(logger: Logger): void;
|
|
654
655
|
loadUserPagesConfig(): Promise<void>;
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import MagicString from 'magic-string';
|
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
7
|
import { loadConfig } from 'unconfig';
|
|
8
8
|
import Debug from 'debug';
|
|
9
|
+
import { platform } from '@uni-helper/uni-env';
|
|
9
10
|
import fs, { existsSync } from 'node:fs';
|
|
10
11
|
import { readFile, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
11
12
|
import { groupBy } from 'lodash-unified';
|
|
@@ -312,6 +313,7 @@ class PageContext {
|
|
|
312
313
|
__publicField(this, "root");
|
|
313
314
|
__publicField(this, "options");
|
|
314
315
|
__publicField(this, "logger");
|
|
316
|
+
__publicField(this, "withUniPlatform", false);
|
|
315
317
|
this.rawOptions = userOptions;
|
|
316
318
|
this.root = slash(viteRoot);
|
|
317
319
|
debug.options("root", this.root);
|
|
@@ -444,7 +446,7 @@ class PageContext {
|
|
|
444
446
|
if (hasHome)
|
|
445
447
|
return true;
|
|
446
448
|
const isFoundHome = result.some((item) => {
|
|
447
|
-
if (this.options.homePage.
|
|
449
|
+
if (this.options.homePage.some((v) => v.startsWith(item.path))) {
|
|
448
450
|
item.type = "home";
|
|
449
451
|
return true;
|
|
450
452
|
} else {
|
|
@@ -500,6 +502,12 @@ class PageContext {
|
|
|
500
502
|
await this.mergePageMetaData();
|
|
501
503
|
await this.mergeSubPageMetaData();
|
|
502
504
|
this.options.onAfterMergePageMetaData(this);
|
|
505
|
+
if (this.withUniPlatform) {
|
|
506
|
+
const pagesMap = /* @__PURE__ */ new Map();
|
|
507
|
+
const pages = this.pageMetaData.filter((v) => !/\..*$/.test(v.path) || v.path.includes(platform)).map((v) => ({ ...v, path: v.path.replace(/\..*$/, "") }));
|
|
508
|
+
pages.forEach((v) => pagesMap.set(v.path, v));
|
|
509
|
+
this.pageMetaData = [...pagesMap.values()];
|
|
510
|
+
}
|
|
503
511
|
this.options.onBeforeWriteFile(this);
|
|
504
512
|
const data = {
|
|
505
513
|
...this.pagesGlobConfig,
|
|
@@ -578,6 +586,8 @@ function VitePluginUniPages(userOptions = {}) {
|
|
|
578
586
|
enforce: "pre",
|
|
579
587
|
async configResolved(config) {
|
|
580
588
|
ctx = new PageContext(userOptions, config.root);
|
|
589
|
+
if (config.plugins.some((v) => v.name === "vite-plugin-uni-platform"))
|
|
590
|
+
ctx.withUniPlatform = true;
|
|
581
591
|
const logger = createLogger(void 0, {
|
|
582
592
|
prefix: "[vite-plugin-uni-pages]"
|
|
583
593
|
});
|
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.2.
|
|
4
|
+
"version": "0.2.12",
|
|
5
5
|
"description": "File system based routing for uni-app applications using Vite",
|
|
6
6
|
"author": "KeJun",
|
|
7
7
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"module": "./dist/index.mjs",
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
34
|
"files": [
|
|
35
|
-
"
|
|
36
|
-
"
|
|
35
|
+
"client.d.ts",
|
|
36
|
+
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@uni-helper/uni-env": "^0.0.3",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"fast-glob": "^3.3.1",
|
|
44
44
|
"json5": "^2.2.3",
|
|
45
45
|
"lodash-unified": "^1.0.3",
|
|
46
|
-
"magic-string": "^0.30.
|
|
47
|
-
"unconfig": "^0.3.
|
|
46
|
+
"magic-string": "^0.30.4",
|
|
47
|
+
"unconfig": "^0.3.11",
|
|
48
48
|
"yaml": "^2.3.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@antfu/utils": "^0.7.6",
|
|
52
|
-
"@types/debug": "^4.1.
|
|
53
|
-
"@types/node": "^
|
|
52
|
+
"@types/debug": "^4.1.9",
|
|
53
|
+
"@types/node": "^20.8.3"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "unbuild",
|