@uni-helper/vite-plugin-uni-pages 0.3.19 → 0.3.20
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 +5 -4
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +5 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -938,8 +938,7 @@ class PageContext {
|
|
|
938
938
|
async genratePagesJSON() {
|
|
939
939
|
const content = await fs__default.promises.readFile(this.resolvedPagesJSONPath, { encoding: "utf-8" }).catch(() => "");
|
|
940
940
|
const { pages: oldPages, subPackages: oldSubPackages, tabBar: oldTabBar } = commentJson.parse(content || "{}");
|
|
941
|
-
const { pages: _, subPackages: __, tabBar: ___, ...
|
|
942
|
-
const pageJson = { ...others };
|
|
941
|
+
const { pages: _, subPackages: __, tabBar: ___, ...pageJson } = this.pagesGlobConfig || {};
|
|
943
942
|
const currentPlatform = uniEnv.platform.toUpperCase();
|
|
944
943
|
pageJson.pages = mergePlatformItems(oldPages, currentPlatform, this.pageMetaData, "path");
|
|
945
944
|
pageJson.subPackages = oldSubPackages || new commentJson.CommentArray();
|
|
@@ -1040,7 +1039,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1040
1039
|
continue;
|
|
1041
1040
|
}
|
|
1042
1041
|
const existing = tmpMap.get(uniqueKey) || [];
|
|
1043
|
-
existing.push({ item, platforms, platformStr: platforms.join(" || ") });
|
|
1042
|
+
existing.push({ item, itemStr: JSON.stringify(item), platforms, platformStr: platforms.join(" || ") });
|
|
1044
1043
|
tmpMap.set(uniqueKey, existing);
|
|
1045
1044
|
}
|
|
1046
1045
|
for (const item of items) {
|
|
@@ -1052,6 +1051,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1052
1051
|
if (!tmpMap.has(uniqueKey)) {
|
|
1053
1052
|
tmpMap.set(uniqueKey, [{
|
|
1054
1053
|
item: newItem,
|
|
1054
|
+
itemStr: JSON.stringify(newItem),
|
|
1055
1055
|
platforms: [currentPlatform],
|
|
1056
1056
|
platformStr: currentPlatform
|
|
1057
1057
|
}]);
|
|
@@ -1059,13 +1059,14 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
const existing = tmpMap.get(uniqueKey);
|
|
1061
1061
|
const newItemStr = JSON.stringify(newItem);
|
|
1062
|
-
const equalObj = existing.find((val) =>
|
|
1062
|
+
const equalObj = existing.find((val) => val.itemStr === newItemStr);
|
|
1063
1063
|
if (equalObj) {
|
|
1064
1064
|
equalObj.platforms.push(currentPlatform);
|
|
1065
1065
|
equalObj.platformStr = equalObj.platforms.join(" || ");
|
|
1066
1066
|
} else {
|
|
1067
1067
|
existing.push({
|
|
1068
1068
|
item: newItem,
|
|
1069
|
+
itemStr: newItemStr,
|
|
1069
1070
|
platforms: [currentPlatform],
|
|
1070
1071
|
platformStr: currentPlatform
|
|
1071
1072
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -3152,6 +3152,9 @@ interface PageMetaDatum {
|
|
|
3152
3152
|
needLogin?: boolean;
|
|
3153
3153
|
[x: string]: any;
|
|
3154
3154
|
}
|
|
3155
|
+
type ExcludeIndexSignature<T> = {
|
|
3156
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
3157
|
+
};
|
|
3155
3158
|
interface SubPageMetaDatum {
|
|
3156
3159
|
root: string;
|
|
3157
3160
|
pages: PageMetaDatum[];
|
|
@@ -3214,4 +3217,4 @@ declare function resolvePageDirs(dir: string, root: string, exclude: string[]):
|
|
|
3214
3217
|
declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
|
|
3215
3218
|
|
|
3216
3219
|
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, getRouteBlock, getRouteSfcBlock, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromCustomBlock, tryPageMetaFromMacro, writeFileWithLock };
|
|
3217
|
-
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
|
3220
|
+
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, ExcludeIndexSignature, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
package/dist/index.d.mts
CHANGED
|
@@ -3152,6 +3152,9 @@ interface PageMetaDatum {
|
|
|
3152
3152
|
needLogin?: boolean;
|
|
3153
3153
|
[x: string]: any;
|
|
3154
3154
|
}
|
|
3155
|
+
type ExcludeIndexSignature<T> = {
|
|
3156
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
3157
|
+
};
|
|
3155
3158
|
interface SubPageMetaDatum {
|
|
3156
3159
|
root: string;
|
|
3157
3160
|
pages: PageMetaDatum[];
|
|
@@ -3214,4 +3217,4 @@ declare function resolvePageDirs(dir: string, root: string, exclude: string[]):
|
|
|
3214
3217
|
declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
|
|
3215
3218
|
|
|
3216
3219
|
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, getRouteBlock, getRouteSfcBlock, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromCustomBlock, tryPageMetaFromMacro, writeFileWithLock };
|
|
3217
|
-
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
|
3220
|
+
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, ExcludeIndexSignature, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
package/dist/index.d.ts
CHANGED
|
@@ -3152,6 +3152,9 @@ interface PageMetaDatum {
|
|
|
3152
3152
|
needLogin?: boolean;
|
|
3153
3153
|
[x: string]: any;
|
|
3154
3154
|
}
|
|
3155
|
+
type ExcludeIndexSignature<T> = {
|
|
3156
|
+
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
|
|
3157
|
+
};
|
|
3155
3158
|
interface SubPageMetaDatum {
|
|
3156
3159
|
root: string;
|
|
3157
3160
|
pages: PageMetaDatum[];
|
|
@@ -3214,4 +3217,4 @@ declare function resolvePageDirs(dir: string, root: string, exclude: string[]):
|
|
|
3214
3217
|
declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
|
|
3215
3218
|
|
|
3216
3219
|
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, getRouteBlock, getRouteSfcBlock, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromCustomBlock, tryPageMetaFromMacro, writeFileWithLock };
|
|
3217
|
-
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
|
3220
|
+
export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, ExcludeIndexSignature, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
|
package/dist/index.mjs
CHANGED
|
@@ -903,8 +903,7 @@ class PageContext {
|
|
|
903
903
|
async genratePagesJSON() {
|
|
904
904
|
const content = await fs.promises.readFile(this.resolvedPagesJSONPath, { encoding: "utf-8" }).catch(() => "");
|
|
905
905
|
const { pages: oldPages, subPackages: oldSubPackages, tabBar: oldTabBar } = parse(content || "{}");
|
|
906
|
-
const { pages: _, subPackages: __, tabBar: ___, ...
|
|
907
|
-
const pageJson = { ...others };
|
|
906
|
+
const { pages: _, subPackages: __, tabBar: ___, ...pageJson } = this.pagesGlobConfig || {};
|
|
908
907
|
const currentPlatform = platform.toUpperCase();
|
|
909
908
|
pageJson.pages = mergePlatformItems(oldPages, currentPlatform, this.pageMetaData, "path");
|
|
910
909
|
pageJson.subPackages = oldSubPackages || new CommentArray();
|
|
@@ -1005,7 +1004,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1005
1004
|
continue;
|
|
1006
1005
|
}
|
|
1007
1006
|
const existing = tmpMap.get(uniqueKey) || [];
|
|
1008
|
-
existing.push({ item, platforms, platformStr: platforms.join(" || ") });
|
|
1007
|
+
existing.push({ item, itemStr: JSON.stringify(item), platforms, platformStr: platforms.join(" || ") });
|
|
1009
1008
|
tmpMap.set(uniqueKey, existing);
|
|
1010
1009
|
}
|
|
1011
1010
|
for (const item of items) {
|
|
@@ -1017,6 +1016,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1017
1016
|
if (!tmpMap.has(uniqueKey)) {
|
|
1018
1017
|
tmpMap.set(uniqueKey, [{
|
|
1019
1018
|
item: newItem,
|
|
1019
|
+
itemStr: JSON.stringify(newItem),
|
|
1020
1020
|
platforms: [currentPlatform],
|
|
1021
1021
|
platformStr: currentPlatform
|
|
1022
1022
|
}]);
|
|
@@ -1024,13 +1024,14 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
const existing = tmpMap.get(uniqueKey);
|
|
1026
1026
|
const newItemStr = JSON.stringify(newItem);
|
|
1027
|
-
const equalObj = existing.find((val) =>
|
|
1027
|
+
const equalObj = existing.find((val) => val.itemStr === newItemStr);
|
|
1028
1028
|
if (equalObj) {
|
|
1029
1029
|
equalObj.platforms.push(currentPlatform);
|
|
1030
1030
|
equalObj.platformStr = equalObj.platforms.join(" || ");
|
|
1031
1031
|
} else {
|
|
1032
1032
|
existing.push({
|
|
1033
1033
|
item: newItem,
|
|
1034
|
+
itemStr: newItemStr,
|
|
1034
1035
|
platforms: [currentPlatform],
|
|
1035
1036
|
platformStr: currentPlatform
|
|
1036
1037
|
});
|