@uni-helper/vite-plugin-uni-pages 0.4.7 → 0.4.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/dist/index.cjs +15 -39
- package/dist/index.d.cts +2 -17
- package/dist/index.d.mts +2 -17
- package/dist/index.mjs +16 -38
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -100,6 +100,8 @@ function getDeclaration(ctx) {
|
|
|
100
100
|
}) ?? [];
|
|
101
101
|
return `/* eslint-disable */
|
|
102
102
|
/* prettier-ignore */
|
|
103
|
+
/* oxlint-disable */
|
|
104
|
+
/* oxfmt-ignore */
|
|
103
105
|
// @ts-nocheck
|
|
104
106
|
// Generated by vite-plugin-uni-pages
|
|
105
107
|
|
|
@@ -312,27 +314,6 @@ function getDefaultExport(expr) {
|
|
|
312
314
|
}
|
|
313
315
|
/** Babel code generator for converting AST back to code */
|
|
314
316
|
const babelGenerate = getDefaultExport(_babel_generator.default);
|
|
315
|
-
function stripType(item) {
|
|
316
|
-
const { type, ...rest } = item;
|
|
317
|
-
return rest;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Remove the internal `type` marker (`'home'` / `'page'`) from every element of
|
|
321
|
-
* a `CommentArray` *in place* and return the same array.
|
|
322
|
-
*
|
|
323
|
-
* Unlike `items.map(stripType)`, this preserves the `Symbol.for('before:N')` /
|
|
324
|
-
* `Symbol.for('after:N')` comment slots that `comment-json` attaches to the
|
|
325
|
-
* array, so multi-platform `#ifdef` / `#endif` conditional-compilation blocks
|
|
326
|
-
* survive serialization into pages.json. `.map()` rebuilds the array and drops
|
|
327
|
-
* those symbol-keyed comments.
|
|
328
|
-
*
|
|
329
|
-
* @param items - CommentArray (or plain array) of page/tabBar metadata
|
|
330
|
-
* @returns The same array reference, with `type` removed from each element
|
|
331
|
-
*/
|
|
332
|
-
function stripTypeInPlace(items) {
|
|
333
|
-
for (const item of items) if (item && "type" in item) delete item.type;
|
|
334
|
-
return items;
|
|
335
|
-
}
|
|
336
317
|
//#endregion
|
|
337
318
|
//#region src/files.ts
|
|
338
319
|
/**
|
|
@@ -1043,17 +1024,14 @@ var PageContext = class {
|
|
|
1043
1024
|
* @returns JSON string of main package page metadata
|
|
1044
1025
|
*/
|
|
1045
1026
|
resolveRoutes() {
|
|
1046
|
-
return (0, comment_json.stringify)(this.pageMetaData
|
|
1027
|
+
return (0, comment_json.stringify)(this.pageMetaData, null, 2);
|
|
1047
1028
|
}
|
|
1048
1029
|
/**
|
|
1049
1030
|
* Resolve sub-package route data to JSON string
|
|
1050
1031
|
* @returns JSON string of sub-package page metadata
|
|
1051
1032
|
*/
|
|
1052
1033
|
resolveSubRoutes() {
|
|
1053
|
-
return (0, comment_json.stringify)(this.subPageMetaData
|
|
1054
|
-
...rest,
|
|
1055
|
-
pages: pages.map(stripType)
|
|
1056
|
-
})), null, 2);
|
|
1034
|
+
return (0, comment_json.stringify)(this.subPageMetaData, null, 2);
|
|
1057
1035
|
}
|
|
1058
1036
|
/**
|
|
1059
1037
|
* Resolve tabBar configuration
|
|
@@ -1093,7 +1071,7 @@ var PageContext = class {
|
|
|
1093
1071
|
const { pages: oldPages, subPackages: oldSubPackages, tabBar: oldTabBar } = (0, comment_json.parse)(await node_fs.default.promises.readFile(this.resolvedPagesJSONPath, { encoding: "utf-8" }).catch(() => "") || "{}");
|
|
1094
1072
|
const { pages: _pages, subPackages: _subPackages, tabBar: _tabBar, ...pageJson } = this.pagesGlobConfig || {};
|
|
1095
1073
|
const currentPlatform = _uni_helper_uni_env.platform.toUpperCase();
|
|
1096
|
-
pageJson.pages =
|
|
1074
|
+
pageJson.pages = mergePlatformItems(oldPages, currentPlatform, this.pageMetaData, "path");
|
|
1097
1075
|
if (pageJson.pages && pageJson.pages.length > 0) {
|
|
1098
1076
|
const pagesArray = pageJson.pages;
|
|
1099
1077
|
const homeIndex = pagesArray.findIndex((page) => page.type === "home");
|
|
@@ -1108,7 +1086,7 @@ var PageContext = class {
|
|
|
1108
1086
|
for (const existing of pageJson.subPackages) {
|
|
1109
1087
|
const sub = newSubPackages.get(existing.root);
|
|
1110
1088
|
if (sub) {
|
|
1111
|
-
existing.pages =
|
|
1089
|
+
existing.pages = mergePlatformItems(existing.pages, currentPlatform, sub.pages, "path");
|
|
1112
1090
|
if (sub.plugins) existing.plugins = sub.plugins;
|
|
1113
1091
|
newSubPackages.delete(existing.root);
|
|
1114
1092
|
}
|
|
@@ -1116,7 +1094,7 @@ var PageContext = class {
|
|
|
1116
1094
|
for (const [_, newSub] of newSubPackages) {
|
|
1117
1095
|
const subPackage = {
|
|
1118
1096
|
root: newSub.root,
|
|
1119
|
-
pages:
|
|
1097
|
+
pages: mergePlatformItems(void 0, currentPlatform, newSub.pages, "path")
|
|
1120
1098
|
};
|
|
1121
1099
|
if (newSub.plugins) subPackage.plugins = newSub.plugins;
|
|
1122
1100
|
pageJson.subPackages.push(subPackage);
|
|
@@ -1186,6 +1164,13 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1186
1164
|
const trimed = comment.value.trim();
|
|
1187
1165
|
if (trimed.startsWith("GENERATED BY UNI-PAGES, PLATFORM:")) lastPlatforms = trimed.split(":")[1].split("||").map((s) => s.trim()).filter((s) => s !== currentPlatform).sort();
|
|
1188
1166
|
}
|
|
1167
|
+
const stringifyForCompare = (val) => {
|
|
1168
|
+
if (val && typeof val === "object" && "type" in val) {
|
|
1169
|
+
const { type: _type, ...rest } = val;
|
|
1170
|
+
return JSON.stringify(rest);
|
|
1171
|
+
}
|
|
1172
|
+
return JSON.stringify(val);
|
|
1173
|
+
};
|
|
1189
1174
|
const tmpMap = /* @__PURE__ */ new Map();
|
|
1190
1175
|
for (let i = 0; i < src.length; i++) {
|
|
1191
1176
|
const item = src[i];
|
|
@@ -1201,19 +1186,12 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1201
1186
|
const existing = tmpMap.get(uniqueKey) || [];
|
|
1202
1187
|
existing.push({
|
|
1203
1188
|
item,
|
|
1204
|
-
itemStr:
|
|
1189
|
+
itemStr: stringifyForCompare(item),
|
|
1205
1190
|
platforms,
|
|
1206
1191
|
platformStr: platforms.join(" || ")
|
|
1207
1192
|
});
|
|
1208
1193
|
tmpMap.set(uniqueKey, existing);
|
|
1209
1194
|
}
|
|
1210
|
-
const stringifyForCompare = (val) => {
|
|
1211
|
-
if (val && typeof val === "object" && "type" in val) {
|
|
1212
|
-
const { type: _type, ...rest } = val;
|
|
1213
|
-
return JSON.stringify(rest);
|
|
1214
|
-
}
|
|
1215
|
-
return JSON.stringify(val);
|
|
1216
|
-
};
|
|
1217
1195
|
for (const item of items) {
|
|
1218
1196
|
const newItem = item;
|
|
1219
1197
|
const uniqueKey = item[uniqueKeyName];
|
|
@@ -1418,8 +1396,6 @@ exports.parseSFC = parseSFC;
|
|
|
1418
1396
|
exports.resolveOptions = resolveOptions;
|
|
1419
1397
|
exports.resolvePageDirs = resolvePageDirs;
|
|
1420
1398
|
exports.sleep = sleep;
|
|
1421
|
-
exports.stripType = stripType;
|
|
1422
|
-
exports.stripTypeInPlace = stripTypeInPlace;
|
|
1423
1399
|
exports.tryPageMetaFromMacro = tryPageMetaFromMacro;
|
|
1424
1400
|
exports.withFileLock = withFileLock;
|
|
1425
1401
|
exports.writeFileWithLock = writeFileWithLock;
|
package/dist/index.d.cts
CHANGED
|
@@ -336,21 +336,6 @@ declare function parseCode(options: {
|
|
|
336
336
|
declare function sleep(ms: number): Promise<unknown>;
|
|
337
337
|
/** Babel code generator for converting AST back to code */
|
|
338
338
|
declare const babelGenerate: typeof babelGenerator;
|
|
339
|
-
declare function stripType<T extends Record<string, unknown>>(item: T): Omit<T, 'type'>;
|
|
340
|
-
/**
|
|
341
|
-
* Remove the internal `type` marker (`'home'` / `'page'`) from every element of
|
|
342
|
-
* a `CommentArray` *in place* and return the same array.
|
|
343
|
-
*
|
|
344
|
-
* Unlike `items.map(stripType)`, this preserves the `Symbol.for('before:N')` /
|
|
345
|
-
* `Symbol.for('after:N')` comment slots that `comment-json` attaches to the
|
|
346
|
-
* array, so multi-platform `#ifdef` / `#endif` conditional-compilation blocks
|
|
347
|
-
* survive serialization into pages.json. `.map()` rebuilds the array and drops
|
|
348
|
-
* those symbol-keyed comments.
|
|
349
|
-
*
|
|
350
|
-
* @param items - CommentArray (or plain array) of page/tabBar metadata
|
|
351
|
-
* @returns The same array reference, with `type` removed from each element
|
|
352
|
-
*/
|
|
353
|
-
declare function stripTypeInPlace<T extends Record<string, unknown>>(items: T[]): T[];
|
|
354
339
|
//#endregion
|
|
355
340
|
//#region src/types.d.ts
|
|
356
341
|
/** Debug log type, corresponding to methods in the debug object */
|
|
@@ -565,7 +550,7 @@ declare function resolveOptions(userOptions: UserOptions, viteRoot?: string): Re
|
|
|
565
550
|
*/
|
|
566
551
|
declare function resolvePageDirs(dir: string, root: string, exclude: string[]): string[];
|
|
567
552
|
declare namespace index_d_exports {
|
|
568
|
-
export { ConfigSource, DefinePage, ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, MaybeCallable, MaybePromise, MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, SubPageMetaDatum, UserOptions, UserPageMeta, UserTabBarItem, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, debugType, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep,
|
|
553
|
+
export { ConfigSource, DefinePage, ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, MaybeCallable, MaybePromise, MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, SubPageMetaDatum, UserOptions, UserPageMeta, UserTabBarItem, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, debugType, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromMacro, withFileLock, writeFileWithLock };
|
|
569
554
|
}
|
|
570
555
|
/**
|
|
571
556
|
* vite-plugin-uni-pages plugin main entry
|
|
@@ -581,4 +566,4 @@ declare namespace index_d_exports {
|
|
|
581
566
|
*/
|
|
582
567
|
declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
|
|
583
568
|
//#endregion
|
|
584
|
-
export { ConfigSource, type DefinePage, type ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, type MaybeCallable, type MaybePromise, type MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, type PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, type SubPageMetaDatum, UserOptions, type UserPageMeta, type UserTabBarItem, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, debugType, type definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep,
|
|
569
|
+
export { ConfigSource, type DefinePage, type ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, type MaybeCallable, type MaybePromise, type MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, type PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, type SubPageMetaDatum, UserOptions, type UserPageMeta, type UserTabBarItem, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, debugType, type definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromMacro, withFileLock, writeFileWithLock };
|
package/dist/index.d.mts
CHANGED
|
@@ -337,21 +337,6 @@ declare function parseCode(options: {
|
|
|
337
337
|
declare function sleep(ms: number): Promise<unknown>;
|
|
338
338
|
/** Babel code generator for converting AST back to code */
|
|
339
339
|
declare const babelGenerate: typeof babelGenerator;
|
|
340
|
-
declare function stripType<T extends Record<string, unknown>>(item: T): Omit<T, 'type'>;
|
|
341
|
-
/**
|
|
342
|
-
* Remove the internal `type` marker (`'home'` / `'page'`) from every element of
|
|
343
|
-
* a `CommentArray` *in place* and return the same array.
|
|
344
|
-
*
|
|
345
|
-
* Unlike `items.map(stripType)`, this preserves the `Symbol.for('before:N')` /
|
|
346
|
-
* `Symbol.for('after:N')` comment slots that `comment-json` attaches to the
|
|
347
|
-
* array, so multi-platform `#ifdef` / `#endif` conditional-compilation blocks
|
|
348
|
-
* survive serialization into pages.json. `.map()` rebuilds the array and drops
|
|
349
|
-
* those symbol-keyed comments.
|
|
350
|
-
*
|
|
351
|
-
* @param items - CommentArray (or plain array) of page/tabBar metadata
|
|
352
|
-
* @returns The same array reference, with `type` removed from each element
|
|
353
|
-
*/
|
|
354
|
-
declare function stripTypeInPlace<T extends Record<string, unknown>>(items: T[]): T[];
|
|
355
340
|
//#endregion
|
|
356
341
|
//#region src/types.d.ts
|
|
357
342
|
/** Debug log type, corresponding to methods in the debug object */
|
|
@@ -566,7 +551,7 @@ declare function resolveOptions(userOptions: UserOptions, viteRoot?: string): Re
|
|
|
566
551
|
*/
|
|
567
552
|
declare function resolvePageDirs(dir: string, root: string, exclude: string[]): string[];
|
|
568
553
|
declare namespace index_d_exports {
|
|
569
|
-
export { ConfigSource, DefinePage, ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, MaybeCallable, MaybePromise, MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, SubPageMetaDatum, UserOptions, UserPageMeta, UserTabBarItem, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, debugType, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep,
|
|
554
|
+
export { ConfigSource, DefinePage, ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, MaybeCallable, MaybePromise, MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, SubPageMetaDatum, UserOptions, UserPageMeta, UserTabBarItem, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, debugType, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromMacro, withFileLock, writeFileWithLock };
|
|
570
555
|
}
|
|
571
556
|
/**
|
|
572
557
|
* vite-plugin-uni-pages plugin main entry
|
|
@@ -582,4 +567,4 @@ declare namespace index_d_exports {
|
|
|
582
567
|
*/
|
|
583
568
|
declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
|
|
584
569
|
//#endregion
|
|
585
|
-
export { ConfigSource, type DefinePage, type ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, type MaybeCallable, type MaybePromise, type MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, type PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, type SubPageMetaDatum, UserOptions, type UserPageMeta, type UserTabBarItem, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, debugType, type definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep,
|
|
570
|
+
export { ConfigSource, type DefinePage, type ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, type MaybeCallable, type MaybePromise, type MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, type PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, type SubPageMetaDatum, UserOptions, type UserPageMeta, type UserTabBarItem, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, debugType, type definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromMacro, withFileLock, writeFileWithLock };
|
package/dist/index.mjs
CHANGED
|
@@ -59,6 +59,8 @@ function getDeclaration(ctx) {
|
|
|
59
59
|
}) ?? [];
|
|
60
60
|
return `/* eslint-disable */
|
|
61
61
|
/* prettier-ignore */
|
|
62
|
+
/* oxlint-disable */
|
|
63
|
+
/* oxfmt-ignore */
|
|
62
64
|
// @ts-nocheck
|
|
63
65
|
// Generated by vite-plugin-uni-pages
|
|
64
66
|
|
|
@@ -271,27 +273,6 @@ function getDefaultExport(expr) {
|
|
|
271
273
|
}
|
|
272
274
|
/** Babel code generator for converting AST back to code */
|
|
273
275
|
const babelGenerate = getDefaultExport(babelGenerator);
|
|
274
|
-
function stripType(item) {
|
|
275
|
-
const { type, ...rest } = item;
|
|
276
|
-
return rest;
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Remove the internal `type` marker (`'home'` / `'page'`) from every element of
|
|
280
|
-
* a `CommentArray` *in place* and return the same array.
|
|
281
|
-
*
|
|
282
|
-
* Unlike `items.map(stripType)`, this preserves the `Symbol.for('before:N')` /
|
|
283
|
-
* `Symbol.for('after:N')` comment slots that `comment-json` attaches to the
|
|
284
|
-
* array, so multi-platform `#ifdef` / `#endif` conditional-compilation blocks
|
|
285
|
-
* survive serialization into pages.json. `.map()` rebuilds the array and drops
|
|
286
|
-
* those symbol-keyed comments.
|
|
287
|
-
*
|
|
288
|
-
* @param items - CommentArray (or plain array) of page/tabBar metadata
|
|
289
|
-
* @returns The same array reference, with `type` removed from each element
|
|
290
|
-
*/
|
|
291
|
-
function stripTypeInPlace(items) {
|
|
292
|
-
for (const item of items) if (item && "type" in item) delete item.type;
|
|
293
|
-
return items;
|
|
294
|
-
}
|
|
295
276
|
//#endregion
|
|
296
277
|
//#region src/files.ts
|
|
297
278
|
/**
|
|
@@ -1002,17 +983,14 @@ var PageContext = class {
|
|
|
1002
983
|
* @returns JSON string of main package page metadata
|
|
1003
984
|
*/
|
|
1004
985
|
resolveRoutes() {
|
|
1005
|
-
return stringify(this.pageMetaData
|
|
986
|
+
return stringify(this.pageMetaData, null, 2);
|
|
1006
987
|
}
|
|
1007
988
|
/**
|
|
1008
989
|
* Resolve sub-package route data to JSON string
|
|
1009
990
|
* @returns JSON string of sub-package page metadata
|
|
1010
991
|
*/
|
|
1011
992
|
resolveSubRoutes() {
|
|
1012
|
-
return stringify(this.subPageMetaData
|
|
1013
|
-
...rest,
|
|
1014
|
-
pages: pages.map(stripType)
|
|
1015
|
-
})), null, 2);
|
|
993
|
+
return stringify(this.subPageMetaData, null, 2);
|
|
1016
994
|
}
|
|
1017
995
|
/**
|
|
1018
996
|
* Resolve tabBar configuration
|
|
@@ -1052,7 +1030,7 @@ var PageContext = class {
|
|
|
1052
1030
|
const { pages: oldPages, subPackages: oldSubPackages, tabBar: oldTabBar } = parse(await fs.promises.readFile(this.resolvedPagesJSONPath, { encoding: "utf-8" }).catch(() => "") || "{}");
|
|
1053
1031
|
const { pages: _pages, subPackages: _subPackages, tabBar: _tabBar, ...pageJson } = this.pagesGlobConfig || {};
|
|
1054
1032
|
const currentPlatform = platform.toUpperCase();
|
|
1055
|
-
pageJson.pages =
|
|
1033
|
+
pageJson.pages = mergePlatformItems(oldPages, currentPlatform, this.pageMetaData, "path");
|
|
1056
1034
|
if (pageJson.pages && pageJson.pages.length > 0) {
|
|
1057
1035
|
const pagesArray = pageJson.pages;
|
|
1058
1036
|
const homeIndex = pagesArray.findIndex((page) => page.type === "home");
|
|
@@ -1067,7 +1045,7 @@ var PageContext = class {
|
|
|
1067
1045
|
for (const existing of pageJson.subPackages) {
|
|
1068
1046
|
const sub = newSubPackages.get(existing.root);
|
|
1069
1047
|
if (sub) {
|
|
1070
|
-
existing.pages =
|
|
1048
|
+
existing.pages = mergePlatformItems(existing.pages, currentPlatform, sub.pages, "path");
|
|
1071
1049
|
if (sub.plugins) existing.plugins = sub.plugins;
|
|
1072
1050
|
newSubPackages.delete(existing.root);
|
|
1073
1051
|
}
|
|
@@ -1075,7 +1053,7 @@ var PageContext = class {
|
|
|
1075
1053
|
for (const [_, newSub] of newSubPackages) {
|
|
1076
1054
|
const subPackage = {
|
|
1077
1055
|
root: newSub.root,
|
|
1078
|
-
pages:
|
|
1056
|
+
pages: mergePlatformItems(void 0, currentPlatform, newSub.pages, "path")
|
|
1079
1057
|
};
|
|
1080
1058
|
if (newSub.plugins) subPackage.plugins = newSub.plugins;
|
|
1081
1059
|
pageJson.subPackages.push(subPackage);
|
|
@@ -1145,6 +1123,13 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1145
1123
|
const trimed = comment.value.trim();
|
|
1146
1124
|
if (trimed.startsWith("GENERATED BY UNI-PAGES, PLATFORM:")) lastPlatforms = trimed.split(":")[1].split("||").map((s) => s.trim()).filter((s) => s !== currentPlatform).sort();
|
|
1147
1125
|
}
|
|
1126
|
+
const stringifyForCompare = (val) => {
|
|
1127
|
+
if (val && typeof val === "object" && "type" in val) {
|
|
1128
|
+
const { type: _type, ...rest } = val;
|
|
1129
|
+
return JSON.stringify(rest);
|
|
1130
|
+
}
|
|
1131
|
+
return JSON.stringify(val);
|
|
1132
|
+
};
|
|
1148
1133
|
const tmpMap = /* @__PURE__ */ new Map();
|
|
1149
1134
|
for (let i = 0; i < src.length; i++) {
|
|
1150
1135
|
const item = src[i];
|
|
@@ -1160,19 +1145,12 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1160
1145
|
const existing = tmpMap.get(uniqueKey) || [];
|
|
1161
1146
|
existing.push({
|
|
1162
1147
|
item,
|
|
1163
|
-
itemStr:
|
|
1148
|
+
itemStr: stringifyForCompare(item),
|
|
1164
1149
|
platforms,
|
|
1165
1150
|
platformStr: platforms.join(" || ")
|
|
1166
1151
|
});
|
|
1167
1152
|
tmpMap.set(uniqueKey, existing);
|
|
1168
1153
|
}
|
|
1169
|
-
const stringifyForCompare = (val) => {
|
|
1170
|
-
if (val && typeof val === "object" && "type" in val) {
|
|
1171
|
-
const { type: _type, ...rest } = val;
|
|
1172
|
-
return JSON.stringify(rest);
|
|
1173
|
-
}
|
|
1174
|
-
return JSON.stringify(val);
|
|
1175
|
-
};
|
|
1176
1154
|
for (const item of items) {
|
|
1177
1155
|
const newItem = item;
|
|
1178
1156
|
const uniqueKey = item[uniqueKeyName];
|
|
@@ -1353,4 +1331,4 @@ function VitePluginUniPages(userOptions = {}) {
|
|
|
1353
1331
|
};
|
|
1354
1332
|
}
|
|
1355
1333
|
//#endregion
|
|
1356
|
-
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep,
|
|
1334
|
+
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromMacro, withFileLock, writeFileWithLock };
|
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.4.
|
|
4
|
+
"version": "0.4.9",
|
|
5
5
|
"description": "File system based routing for uni-app applications using Vite",
|
|
6
6
|
"author": "KeJun",
|
|
7
7
|
"maintainers": [
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"unconfig": "^7.5.0",
|
|
73
73
|
"write-file-atomic": "^7.0.1",
|
|
74
74
|
"yaml": "^2.9.0",
|
|
75
|
-
"@uni-helper/uni-pages-types": "0.4.
|
|
75
|
+
"@uni-helper/uni-pages-types": "0.4.9"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@antfu/utils": "^9.3.0",
|