@dcloudio/uni-cli-shared 0.0.1-nvue3.3030820220125001
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/checkUpdate.d.ts +30 -0
- package/dist/checkUpdate.js +243 -0
- package/dist/constants.d.ts +19 -0
- package/dist/constants.js +43 -0
- package/dist/deps.d.ts +19 -0
- package/dist/deps.js +39 -0
- package/dist/easycom.d.ts +29 -0
- package/dist/easycom.js +202 -0
- package/dist/env/define.d.ts +15 -0
- package/dist/env/define.js +45 -0
- package/dist/env/index.d.ts +2 -0
- package/dist/env/index.js +8 -0
- package/dist/env/provide.d.ts +9 -0
- package/dist/env/provide.js +24 -0
- package/dist/esbuild.d.ts +3 -0
- package/dist/esbuild.js +42 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +8 -0
- package/dist/filter.d.ts +16 -0
- package/dist/filter.js +60 -0
- package/dist/fs.d.ts +1 -0
- package/dist/fs.js +25 -0
- package/dist/hbx/alias.d.ts +5 -0
- package/dist/hbx/alias.js +75 -0
- package/dist/hbx/env.d.ts +6 -0
- package/dist/hbx/env.js +44 -0
- package/dist/hbx/index.d.ts +3 -0
- package/dist/hbx/index.js +36 -0
- package/dist/hbx/log.d.ts +6 -0
- package/dist/hbx/log.js +99 -0
- package/dist/i18n.d.ts +10 -0
- package/dist/i18n.js +94 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +40 -0
- package/dist/json/app/index.d.ts +3 -0
- package/dist/json/app/index.js +17 -0
- package/dist/json/app/manifest/arguments.d.ts +2 -0
- package/dist/json/app/manifest/arguments.js +36 -0
- package/dist/json/app/manifest/confusion.d.ts +4 -0
- package/dist/json/app/manifest/confusion.js +77 -0
- package/dist/json/app/manifest/defaultManifestJson.d.ts +1 -0
- package/dist/json/app/manifest/defaultManifestJson.js +41 -0
- package/dist/json/app/manifest/env.d.ts +3 -0
- package/dist/json/app/manifest/env.js +24 -0
- package/dist/json/app/manifest/i18n.d.ts +1 -0
- package/dist/json/app/manifest/i18n.js +14 -0
- package/dist/json/app/manifest/index.d.ts +4 -0
- package/dist/json/app/manifest/index.js +49 -0
- package/dist/json/app/manifest/launchwebview.d.ts +1 -0
- package/dist/json/app/manifest/launchwebview.js +32 -0
- package/dist/json/app/manifest/merge.d.ts +1 -0
- package/dist/json/app/manifest/merge.js +17 -0
- package/dist/json/app/manifest/nvue.d.ts +4 -0
- package/dist/json/app/manifest/nvue.js +43 -0
- package/dist/json/app/manifest/plus.d.ts +1 -0
- package/dist/json/app/manifest/plus.js +83 -0
- package/dist/json/app/manifest/safearea.d.ts +1 -0
- package/dist/json/app/manifest/safearea.js +28 -0
- package/dist/json/app/manifest/splashscreen.d.ts +5 -0
- package/dist/json/app/manifest/splashscreen.js +44 -0
- package/dist/json/app/manifest/statusbar.d.ts +1 -0
- package/dist/json/app/manifest/statusbar.js +14 -0
- package/dist/json/app/manifest/tabBar.d.ts +1 -0
- package/dist/json/app/manifest/tabBar.js +27 -0
- package/dist/json/app/manifest/uniApp.d.ts +1 -0
- package/dist/json/app/manifest/uniApp.js +19 -0
- package/dist/json/app/pages/code.d.ts +3 -0
- package/dist/json/app/pages/code.js +44 -0
- package/dist/json/app/pages/definePage.d.ts +2 -0
- package/dist/json/app/pages/definePage.js +42 -0
- package/dist/json/app/pages/index.d.ts +3 -0
- package/dist/json/app/pages/index.js +28 -0
- package/dist/json/app/pages/uniConfig.d.ts +1 -0
- package/dist/json/app/pages/uniConfig.js +69 -0
- package/dist/json/app/pages/uniRoutes.d.ts +1 -0
- package/dist/json/app/pages/uniRoutes.js +8 -0
- package/dist/json/index.d.ts +5 -0
- package/dist/json/index.js +17 -0
- package/dist/json/json.d.ts +1 -0
- package/dist/json/json.js +9 -0
- package/dist/json/manifest.d.ts +28 -0
- package/dist/json/manifest.js +64 -0
- package/dist/json/mp/index.d.ts +4 -0
- package/dist/json/mp/index.js +19 -0
- package/dist/json/mp/jsonFile.d.ts +23 -0
- package/dist/json/mp/jsonFile.js +127 -0
- package/dist/json/mp/pages.d.ts +17 -0
- package/dist/json/mp/pages.js +126 -0
- package/dist/json/mp/project.d.ts +14 -0
- package/dist/json/mp/project.js +81 -0
- package/dist/json/mp/types.d.ts +118 -0
- package/dist/json/mp/types.js +2 -0
- package/dist/json/mp/utils.d.ts +3 -0
- package/dist/json/mp/utils.js +66 -0
- package/dist/json/pages.d.ts +30 -0
- package/dist/json/pages.js +383 -0
- package/dist/logs/console.d.ts +4 -0
- package/dist/logs/console.js +49 -0
- package/dist/logs/format.d.ts +11 -0
- package/dist/logs/format.js +82 -0
- package/dist/logs/index.d.ts +1 -0
- package/dist/logs/index.js +7 -0
- package/dist/messages/index.d.ts +20 -0
- package/dist/messages/index.js +23 -0
- package/dist/mp/ast.d.ts +4 -0
- package/dist/mp/ast.js +12 -0
- package/dist/mp/constants.d.ts +5 -0
- package/dist/mp/constants.js +8 -0
- package/dist/mp/event.d.ts +5 -0
- package/dist/mp/event.js +35 -0
- package/dist/mp/externalClasses.d.ts +5 -0
- package/dist/mp/externalClasses.js +42 -0
- package/dist/mp/imports.d.ts +12 -0
- package/dist/mp/imports.js +72 -0
- package/dist/mp/index.d.ts +11 -0
- package/dist/mp/index.js +38 -0
- package/dist/mp/nvue.d.ts +1 -0
- package/dist/mp/nvue.js +18 -0
- package/dist/mp/plugin.d.ts +2 -0
- package/dist/mp/plugin.js +13 -0
- package/dist/mp/style.d.ts +1 -0
- package/dist/mp/style.js +9 -0
- package/dist/mp/tags.d.ts +1 -0
- package/dist/mp/tags.js +117 -0
- package/dist/mp/template.d.ts +73 -0
- package/dist/mp/template.js +73 -0
- package/dist/mp/usingComponents.d.ts +65 -0
- package/dist/mp/usingComponents.js +402 -0
- package/dist/mp/wxs.d.ts +2 -0
- package/dist/mp/wxs.js +55 -0
- package/dist/platform.d.ts +2 -0
- package/dist/platform.js +31 -0
- package/dist/postcss/index.d.ts +10 -0
- package/dist/postcss/index.js +19 -0
- package/dist/postcss/plugins/stylePluginScoped.d.ts +3 -0
- package/dist/postcss/plugins/stylePluginScoped.js +176 -0
- package/dist/postcss/plugins/uniapp.d.ts +11 -0
- package/dist/postcss/plugins/uniapp.js +110 -0
- package/dist/preprocess/context.d.ts +3 -0
- package/dist/preprocess/context.js +81 -0
- package/dist/preprocess/index.d.ts +9 -0
- package/dist/preprocess/index.js +28 -0
- package/dist/resolve.d.ts +6 -0
- package/dist/resolve.js +102 -0
- package/dist/scripts.d.ts +10 -0
- package/dist/scripts.js +44 -0
- package/dist/ssr.d.ts +4 -0
- package/dist/ssr.js +20 -0
- package/dist/url.d.ts +2 -0
- package/dist/url.js +15 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.js +80 -0
- package/dist/vite/features.d.ts +41 -0
- package/dist/vite/features.js +191 -0
- package/dist/vite/index.d.ts +36 -0
- package/dist/vite/index.js +17 -0
- package/dist/vite/plugins/console.d.ts +8 -0
- package/dist/vite/plugins/console.js +42 -0
- package/dist/vite/plugins/copy.d.ts +11 -0
- package/dist/vite/plugins/copy.js +51 -0
- package/dist/vite/plugins/cssScoped.d.ts +6 -0
- package/dist/vite/plugins/cssScoped.js +54 -0
- package/dist/vite/plugins/dynamicImportPolyfill.d.ts +2 -0
- package/dist/vite/plugins/dynamicImportPolyfill.js +15 -0
- package/dist/vite/plugins/index.d.ts +10 -0
- package/dist/vite/plugins/index.js +32 -0
- package/dist/vite/plugins/inject.d.ts +12 -0
- package/dist/vite/plugins/inject.js +207 -0
- package/dist/vite/plugins/jsonJs.d.ts +3 -0
- package/dist/vite/plugins/jsonJs.js +52 -0
- package/dist/vite/plugins/mainJs.d.ts +2 -0
- package/dist/vite/plugins/mainJs.js +29 -0
- package/dist/vite/plugins/vitejs/config.d.ts +1 -0
- package/dist/vite/plugins/vitejs/config.js +2 -0
- package/dist/vite/plugins/vitejs/constants.d.ts +8 -0
- package/dist/vite/plugins/vitejs/constants.js +11 -0
- package/dist/vite/plugins/vitejs/index.d.ts +1 -0
- package/dist/vite/plugins/vitejs/index.js +2 -0
- package/dist/vite/plugins/vitejs/plugin.d.ts +1 -0
- package/dist/vite/plugins/vitejs/plugin.js +2 -0
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +40 -0
- package/dist/vite/plugins/vitejs/plugins/asset.js +270 -0
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +48 -0
- package/dist/vite/plugins/vitejs/plugins/css.js +760 -0
- package/dist/vite/plugins/vitejs/server/moduleGraph.d.ts +1 -0
- package/dist/vite/plugins/vitejs/server/moduleGraph.js +2 -0
- package/dist/vite/plugins/vitejs/utils.d.ts +29 -0
- package/dist/vite/plugins/vitejs/utils.js +129 -0
- package/dist/vite/utils/ast.d.ts +17 -0
- package/dist/vite/utils/ast.js +85 -0
- package/dist/vite/utils/index.d.ts +7 -0
- package/dist/vite/utils/index.js +23 -0
- package/dist/vite/utils/plugin.d.ts +11 -0
- package/dist/vite/utils/plugin.js +45 -0
- package/dist/vite/utils/url.d.ts +28 -0
- package/dist/vite/utils/url.js +69 -0
- package/dist/vite/utils/utils.d.ts +3 -0
- package/dist/vite/utils/utils.js +14 -0
- package/dist/vue/babel.d.ts +3 -0
- package/dist/vue/babel.js +17 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +19 -0
- package/dist/vue/transforms/index.d.ts +13 -0
- package/dist/vue/transforms/index.js +48 -0
- package/dist/vue/transforms/templateTransformAssetUrl.d.ts +33 -0
- package/dist/vue/transforms/templateTransformAssetUrl.js +150 -0
- package/dist/vue/transforms/templateTransformSrcset.d.ts +4 -0
- package/dist/vue/transforms/templateTransformSrcset.js +122 -0
- package/dist/vue/transforms/templateUtils.d.ts +9 -0
- package/dist/vue/transforms/templateUtils.js +41 -0
- package/dist/vue/transforms/transformComponent.d.ts +3 -0
- package/dist/vue/transforms/transformComponent.js +26 -0
- package/dist/vue/transforms/transformEvent.d.ts +2 -0
- package/dist/vue/transforms/transformEvent.js +28 -0
- package/dist/vue/transforms/transformPageHead.d.ts +2 -0
- package/dist/vue/transforms/transformPageHead.js +11 -0
- package/dist/vue/transforms/transformRef.d.ts +2 -0
- package/dist/vue/transforms/transformRef.js +32 -0
- package/dist/vue/transforms/transformTag.d.ts +2 -0
- package/dist/vue/transforms/transformTag.js +18 -0
- package/dist/vue/transforms/vModel.d.ts +12 -0
- package/dist/vue/transforms/vModel.js +33 -0
- package/dist/vue/transforms/vOn.d.ts +15 -0
- package/dist/vue/transforms/vOn.js +88 -0
- package/dist/vue/utils.d.ts +31 -0
- package/dist/vue/utils.js +120 -0
- package/dist/watcher.d.ts +30 -0
- package/dist/watcher.js +92 -0
- package/lib/crypto.js +65 -0
- package/lib/nvue.css +34 -0
- package/lib/preprocess/LICENSE +13 -0
- package/lib/preprocess/README.md +410 -0
- package/lib/preprocess/lib/preprocess.js +437 -0
- package/lib/preprocess/lib/regexrules.js +121 -0
- package/lib/preprocess/package.json +68 -0
- package/package.json +68 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mergeMiniProgramAppJson = exports.parseMiniProgramPagesJson = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const shared_1 = require("@vue/shared");
|
|
10
|
+
const json_1 = require("../json");
|
|
11
|
+
const pages_1 = require("../pages");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const utils_2 = require("../../utils");
|
|
14
|
+
const project_1 = require("./project");
|
|
15
|
+
function parseMiniProgramPagesJson(jsonStr, platform, options = { subpackages: false }) {
|
|
16
|
+
return parsePagesJson(jsonStr, platform, options);
|
|
17
|
+
}
|
|
18
|
+
exports.parseMiniProgramPagesJson = parseMiniProgramPagesJson;
|
|
19
|
+
function mergeMiniProgramAppJson(appJson, platformJson = {}) {
|
|
20
|
+
Object.keys(platformJson).forEach((name) => {
|
|
21
|
+
if (!(0, project_1.isMiniProgramProjectJsonKey)(name) &&
|
|
22
|
+
!['usingComponents', 'optimization', 'scopedSlotsCompiler'].includes(name)) {
|
|
23
|
+
appJson[name] = platformJson[name];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
exports.mergeMiniProgramAppJson = mergeMiniProgramAppJson;
|
|
28
|
+
function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, subpackages, windowOptionsMap, tabBarOptionsMap, tabBarItemOptionsMap, } = {
|
|
29
|
+
subpackages: false,
|
|
30
|
+
}) {
|
|
31
|
+
const appJson = {
|
|
32
|
+
pages: [],
|
|
33
|
+
};
|
|
34
|
+
const pageJsons = {};
|
|
35
|
+
const nvuePages = [];
|
|
36
|
+
// preprocess
|
|
37
|
+
const pagesJson = (0, json_1.parseJson)(jsonStr, true);
|
|
38
|
+
if (!pagesJson) {
|
|
39
|
+
throw new Error(`[vite] Error: pages.json parse failed.\n`);
|
|
40
|
+
}
|
|
41
|
+
function addPageJson(pagePath, style) {
|
|
42
|
+
const filename = path_1.default.join(process.env.UNI_INPUT_DIR, pagePath);
|
|
43
|
+
if (fs_1.default.existsSync(filename + '.nvue') &&
|
|
44
|
+
!fs_1.default.existsSync(filename + '.vue')) {
|
|
45
|
+
nvuePages.push(pagePath);
|
|
46
|
+
}
|
|
47
|
+
const windowOptions = {};
|
|
48
|
+
if (platform === 'mp-baidu') {
|
|
49
|
+
// 仅百度小程序需要页面配置 component:true
|
|
50
|
+
// 快手小程序反而不能配置 component:true,故不能统一添加,目前硬编码处理
|
|
51
|
+
windowOptions.component = true;
|
|
52
|
+
}
|
|
53
|
+
pageJsons[pagePath] = (0, shared_1.extend)(windowOptions, (0, utils_1.parseWindowOptions)(style, platform, windowOptionsMap));
|
|
54
|
+
}
|
|
55
|
+
// pages
|
|
56
|
+
(0, pages_1.validatePages)(pagesJson, jsonStr);
|
|
57
|
+
pagesJson.pages.forEach((page) => {
|
|
58
|
+
appJson.pages.push(page.path);
|
|
59
|
+
addPageJson(page.path, page.style);
|
|
60
|
+
});
|
|
61
|
+
// subpackages
|
|
62
|
+
pagesJson.subPackages = pagesJson.subPackages || pagesJson.subpackages;
|
|
63
|
+
if (pagesJson.subPackages) {
|
|
64
|
+
if (subpackages) {
|
|
65
|
+
appJson.subPackages = pagesJson.subPackages.map(({ root, pages, ...rest }) => {
|
|
66
|
+
return (0, shared_1.extend)({
|
|
67
|
+
root,
|
|
68
|
+
pages: pages.map((page) => {
|
|
69
|
+
addPageJson((0, utils_2.normalizePath)(path_1.default.join(root, page.path)), page.style);
|
|
70
|
+
return page.path;
|
|
71
|
+
}),
|
|
72
|
+
}, rest);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
pagesJson.subPackages.forEach(({ root, pages }) => {
|
|
77
|
+
pages.forEach((page) => {
|
|
78
|
+
const pagePath = (0, utils_2.normalizePath)(path_1.default.join(root, page.path));
|
|
79
|
+
appJson.pages.push(pagePath);
|
|
80
|
+
addPageJson(pagePath, page.style);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// window
|
|
86
|
+
if (pagesJson.globalStyle) {
|
|
87
|
+
const windowOptions = (0, utils_1.parseWindowOptions)(pagesJson.globalStyle, platform, windowOptionsMap);
|
|
88
|
+
const { usingComponents } = windowOptions;
|
|
89
|
+
if (usingComponents) {
|
|
90
|
+
delete windowOptions.usingComponents;
|
|
91
|
+
appJson.usingComponents = usingComponents;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
delete appJson.usingComponents;
|
|
95
|
+
}
|
|
96
|
+
appJson.window = windowOptions;
|
|
97
|
+
}
|
|
98
|
+
// tabBar
|
|
99
|
+
if (pagesJson.tabBar) {
|
|
100
|
+
const tabBar = (0, utils_1.parseTabBar)(pagesJson.tabBar, platform, tabBarOptionsMap, tabBarItemOptionsMap);
|
|
101
|
+
if (tabBar) {
|
|
102
|
+
appJson.tabBar = tabBar;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
;
|
|
106
|
+
['preloadRule', 'workers', 'plugins'].forEach((name) => {
|
|
107
|
+
if ((0, shared_1.hasOwn)(pagesJson, name)) {
|
|
108
|
+
appJson[name] = pagesJson[name];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
if (debug) {
|
|
112
|
+
appJson.debug = debug;
|
|
113
|
+
}
|
|
114
|
+
if (networkTimeout) {
|
|
115
|
+
appJson.networkTimeout = networkTimeout;
|
|
116
|
+
}
|
|
117
|
+
if (darkmode) {
|
|
118
|
+
appJson.darkmode = true;
|
|
119
|
+
appJson.themeLocation = 'theme.json';
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
appJson,
|
|
123
|
+
pageJsons,
|
|
124
|
+
nvuePages,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ParseMiniProgramProjectJsonOptions {
|
|
2
|
+
template: Record<string, any>;
|
|
3
|
+
pagesJson: UniApp.PagesJson;
|
|
4
|
+
}
|
|
5
|
+
interface ProjectConfig {
|
|
6
|
+
appid: string;
|
|
7
|
+
projectname: string;
|
|
8
|
+
condition?: {
|
|
9
|
+
miniprogram?: UniApp.PagesJson['condition'];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function isMiniProgramProjectJsonKey(name: string): boolean;
|
|
13
|
+
export declare function parseMiniProgramProjectJson(jsonStr: string, platform: UniApp.PLATFORM, { template, pagesJson }: ParseMiniProgramProjectJsonOptions): ProjectConfig;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseMiniProgramProjectJson = exports.isMiniProgramProjectJsonKey = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const json_1 = require("../json");
|
|
6
|
+
const projectKeys = [
|
|
7
|
+
'appid',
|
|
8
|
+
'setting',
|
|
9
|
+
'miniprogramRoot',
|
|
10
|
+
'cloudfunctionRoot',
|
|
11
|
+
'qcloudRoot',
|
|
12
|
+
'pluginRoot',
|
|
13
|
+
'compileType',
|
|
14
|
+
'libVersion',
|
|
15
|
+
'projectname',
|
|
16
|
+
'packOptions',
|
|
17
|
+
'debugOptions',
|
|
18
|
+
'scripts',
|
|
19
|
+
'cloudbaseRoot',
|
|
20
|
+
];
|
|
21
|
+
function isMiniProgramProjectJsonKey(name) {
|
|
22
|
+
return projectKeys.includes(name);
|
|
23
|
+
}
|
|
24
|
+
exports.isMiniProgramProjectJsonKey = isMiniProgramProjectJsonKey;
|
|
25
|
+
function parseMiniProgramProjectJson(jsonStr, platform, { template, pagesJson }) {
|
|
26
|
+
const projectJson = JSON.parse(JSON.stringify(template));
|
|
27
|
+
const manifestJson = (0, json_1.parseJson)(jsonStr);
|
|
28
|
+
if (manifestJson) {
|
|
29
|
+
projectJson.projectname = manifestJson.name;
|
|
30
|
+
const platformConfig = manifestJson[platform];
|
|
31
|
+
if (platformConfig) {
|
|
32
|
+
projectKeys.forEach((name) => {
|
|
33
|
+
if ((0, shared_1.hasOwn)(platformConfig, name)) {
|
|
34
|
+
;
|
|
35
|
+
projectJson[name] = platformConfig[name];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// 其实仅开发期间 condition 生效即可,暂不做判断
|
|
41
|
+
const miniprogram = parseMiniProgramCondition(pagesJson);
|
|
42
|
+
if (miniprogram) {
|
|
43
|
+
if (!projectJson.condition) {
|
|
44
|
+
projectJson.condition = {};
|
|
45
|
+
}
|
|
46
|
+
projectJson.condition.miniprogram = miniprogram;
|
|
47
|
+
}
|
|
48
|
+
if (!projectJson.appid) {
|
|
49
|
+
projectJson.appid = 'touristappid';
|
|
50
|
+
}
|
|
51
|
+
return projectJson;
|
|
52
|
+
}
|
|
53
|
+
exports.parseMiniProgramProjectJson = parseMiniProgramProjectJson;
|
|
54
|
+
function parseMiniProgramCondition(pagesJson) {
|
|
55
|
+
const launchPagePath = process.env.UNI_CLI_LAUNCH_PAGE_PATH || '';
|
|
56
|
+
if (launchPagePath) {
|
|
57
|
+
return {
|
|
58
|
+
current: 0,
|
|
59
|
+
list: [
|
|
60
|
+
{
|
|
61
|
+
id: 0,
|
|
62
|
+
name: launchPagePath,
|
|
63
|
+
pathName: launchPagePath,
|
|
64
|
+
query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY || '', // 启动参数,在页面的onLoad函数里面得到。
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const condition = pagesJson.condition;
|
|
70
|
+
if (!condition || !(0, shared_1.isArray)(condition.list) || !condition.list.length) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
condition.list.forEach(function (item, index) {
|
|
74
|
+
item.id = item.id || index;
|
|
75
|
+
if (item.path) {
|
|
76
|
+
item.pathName = item.path;
|
|
77
|
+
delete item.path;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return condition;
|
|
81
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export interface ComponentJson {
|
|
2
|
+
component: true;
|
|
3
|
+
usingComponents?: UsingComponents;
|
|
4
|
+
}
|
|
5
|
+
interface ShareWindowOptions {
|
|
6
|
+
navigationBarBackgroundColor?: string;
|
|
7
|
+
navigationBarTextStyle?: 'white' | 'black';
|
|
8
|
+
navigationBarTitleText?: string;
|
|
9
|
+
navigationStyle?: 'default' | 'custom';
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
backgroundTextStyle?: 'dark' | 'light';
|
|
12
|
+
backgroundColorTop?: string;
|
|
13
|
+
backgroundColorBottom?: string;
|
|
14
|
+
enablePullDownRefresh?: boolean;
|
|
15
|
+
onReachBottomDistance?: number;
|
|
16
|
+
pageOrientation?: 'portrait' | 'landscape' | 'auto';
|
|
17
|
+
}
|
|
18
|
+
declare type Style = 'v2' | string;
|
|
19
|
+
declare type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string;
|
|
20
|
+
export interface PageWindowOptions extends ShareWindowOptions {
|
|
21
|
+
component?: true;
|
|
22
|
+
disableScroll?: boolean;
|
|
23
|
+
usingComponents?: UsingComponents;
|
|
24
|
+
initialRenderingCache?: 'static' | string;
|
|
25
|
+
style?: Style;
|
|
26
|
+
singlePage?: SinglePage;
|
|
27
|
+
restartStrategy?: RestartStrategy;
|
|
28
|
+
}
|
|
29
|
+
export interface AppWindowOptions extends ShareWindowOptions {
|
|
30
|
+
visualEffectInBackground?: 'none' | 'hidden';
|
|
31
|
+
}
|
|
32
|
+
interface SubPackage {
|
|
33
|
+
name?: string;
|
|
34
|
+
root: string;
|
|
35
|
+
pages: string[];
|
|
36
|
+
independent?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface TabBarItem {
|
|
39
|
+
pagePath: string;
|
|
40
|
+
text: string;
|
|
41
|
+
iconPath?: string;
|
|
42
|
+
selectedIconPath?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface TabBar {
|
|
45
|
+
color: string;
|
|
46
|
+
selectedColor: string;
|
|
47
|
+
backgroundColor: string;
|
|
48
|
+
borderStyle?: 'black' | 'white';
|
|
49
|
+
list: TabBarItem[];
|
|
50
|
+
position?: 'bottom' | 'top';
|
|
51
|
+
custom?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface NetworkTimeout {
|
|
54
|
+
request?: number;
|
|
55
|
+
requeconnectSocketst?: number;
|
|
56
|
+
uploadFile?: number;
|
|
57
|
+
downloadFile?: number;
|
|
58
|
+
}
|
|
59
|
+
interface Plugins {
|
|
60
|
+
[name: string]: {
|
|
61
|
+
version: string;
|
|
62
|
+
provider: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
interface PreloadRule {
|
|
66
|
+
[name: string]: {
|
|
67
|
+
network: 'wifi' | 'all';
|
|
68
|
+
packages: string[];
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export interface UsingComponents {
|
|
72
|
+
[name: string]: string;
|
|
73
|
+
}
|
|
74
|
+
interface Permission {
|
|
75
|
+
[name: string]: {
|
|
76
|
+
desc: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
interface UseExtendedLib {
|
|
80
|
+
kbone: boolean;
|
|
81
|
+
weui: boolean;
|
|
82
|
+
}
|
|
83
|
+
interface EntranceDeclare {
|
|
84
|
+
locationMessage: {
|
|
85
|
+
path: string;
|
|
86
|
+
query: string;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
interface SinglePage {
|
|
90
|
+
navigationBarFit?: 'squeezed' | 'float';
|
|
91
|
+
}
|
|
92
|
+
export interface AppJson {
|
|
93
|
+
entryPagePath?: string;
|
|
94
|
+
pages: string[];
|
|
95
|
+
window?: AppWindowOptions;
|
|
96
|
+
tabBar?: TabBar;
|
|
97
|
+
networkTimeout?: NetworkTimeout;
|
|
98
|
+
debug?: boolean;
|
|
99
|
+
functionalPages?: boolean;
|
|
100
|
+
subPackages?: SubPackage[];
|
|
101
|
+
workers?: string;
|
|
102
|
+
requiredBackgroundModes?: string[];
|
|
103
|
+
plugins?: Plugins;
|
|
104
|
+
preloadRule?: PreloadRule;
|
|
105
|
+
resizable?: boolean;
|
|
106
|
+
usingComponents?: UsingComponents;
|
|
107
|
+
permission?: Permission;
|
|
108
|
+
sitemapLocation?: string;
|
|
109
|
+
style?: Style;
|
|
110
|
+
useExtendedLib?: UseExtendedLib;
|
|
111
|
+
entranceDeclare?: EntranceDeclare;
|
|
112
|
+
darkmode?: boolean;
|
|
113
|
+
themeLocation?: string;
|
|
114
|
+
lazyCodeLoading?: 'requiredComponents' | string;
|
|
115
|
+
singlePage?: SinglePage;
|
|
116
|
+
restartStrategy?: RestartStrategy;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AppWindowOptions, PageWindowOptions, TabBar } from './types';
|
|
2
|
+
export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string>): PageWindowOptions | AppWindowOptions;
|
|
3
|
+
export declare function parseTabBar(tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM, tabBarOptionsMap?: Record<string, string>, tabBarItemOptionsMap?: Record<string, string>): TabBar;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTabBar = exports.parseWindowOptions = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const pages_1 = require("../pages");
|
|
6
|
+
function trimJson(json) {
|
|
7
|
+
delete json.maxWidth;
|
|
8
|
+
delete json.topWindow;
|
|
9
|
+
delete json.leftWindow;
|
|
10
|
+
delete json.rightWindow;
|
|
11
|
+
if (json.tabBar) {
|
|
12
|
+
delete json.tabBar.matchMedia;
|
|
13
|
+
}
|
|
14
|
+
return json;
|
|
15
|
+
}
|
|
16
|
+
function convert(to, from, map) {
|
|
17
|
+
Object.keys(map).forEach((key) => {
|
|
18
|
+
if ((0, shared_1.hasOwn)(from, map[key])) {
|
|
19
|
+
to[key] = from[map[key]];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return to;
|
|
23
|
+
}
|
|
24
|
+
function parseWindowOptions(style, platform, windowOptionsMap) {
|
|
25
|
+
if (!style) {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
28
|
+
const platformStyle = style[platform] || {};
|
|
29
|
+
(0, pages_1.removePlatformStyle)(trimJson(style));
|
|
30
|
+
const res = {};
|
|
31
|
+
if (windowOptionsMap) {
|
|
32
|
+
return (0, shared_1.extend)(convert(res, style, windowOptionsMap), platformStyle);
|
|
33
|
+
}
|
|
34
|
+
return (0, shared_1.extend)(res, style, platformStyle);
|
|
35
|
+
}
|
|
36
|
+
exports.parseWindowOptions = parseWindowOptions;
|
|
37
|
+
function trimTabBarJson(tabBar) {
|
|
38
|
+
;
|
|
39
|
+
[
|
|
40
|
+
'fontSize',
|
|
41
|
+
'height',
|
|
42
|
+
'iconWidth',
|
|
43
|
+
'midButton',
|
|
44
|
+
'selectedIndex',
|
|
45
|
+
'spacing',
|
|
46
|
+
].forEach((name) => {
|
|
47
|
+
delete tabBar[name];
|
|
48
|
+
});
|
|
49
|
+
return tabBar;
|
|
50
|
+
}
|
|
51
|
+
function parseTabBar(tabBar, platform, tabBarOptionsMap, tabBarItemOptionsMap) {
|
|
52
|
+
const platformStyle = tabBar[platform] || {};
|
|
53
|
+
(0, pages_1.removePlatformStyle)(trimTabBarJson(tabBar));
|
|
54
|
+
const res = {};
|
|
55
|
+
if (tabBarOptionsMap) {
|
|
56
|
+
if (tabBarItemOptionsMap && tabBar.list) {
|
|
57
|
+
tabBar.list = tabBar.list.map((item) => {
|
|
58
|
+
return convert({}, item, tabBarItemOptionsMap);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
convert(res, tabBar, tabBarOptionsMap);
|
|
62
|
+
return (0, shared_1.extend)(res, platformStyle);
|
|
63
|
+
}
|
|
64
|
+
return (0, shared_1.extend)(res, tabBar, platformStyle);
|
|
65
|
+
}
|
|
66
|
+
exports.parseTabBar = parseTabBar;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare function isUniPageFile(file: string, inputDir?: string): boolean;
|
|
2
|
+
export declare function isUniPageSfcFile(file: string, inputDir?: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* 小程序平台慎用,因为该解析不支持 subpackages
|
|
5
|
+
* @param inputDir
|
|
6
|
+
* @param platform
|
|
7
|
+
* @param normalize
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const parsePagesJson: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
11
|
+
/**
|
|
12
|
+
* 该方法解析出来的是不支持 subpackages,会被合并入 pages
|
|
13
|
+
*/
|
|
14
|
+
export declare const parsePagesJsonOnce: (inputDir: string, platform: UniApp.PLATFORM, normalize?: boolean) => UniApp.PagesJson;
|
|
15
|
+
/**
|
|
16
|
+
* 目前 App 和 H5 使用了该方法
|
|
17
|
+
* @param jsonStr
|
|
18
|
+
* @param platform
|
|
19
|
+
* @param param2
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizePagesJson(jsonStr: string, platform: UniApp.PLATFORM, { subpackages, }?: {
|
|
23
|
+
subpackages: boolean;
|
|
24
|
+
}): UniApp.PagesJson;
|
|
25
|
+
export declare function validatePages(pagesJson: Record<string, any>, jsonStr: string): void;
|
|
26
|
+
export declare function removePlatformStyle(pageStyle: Record<string, any>): Record<string, any>;
|
|
27
|
+
export declare function normalizePagesRoute(pagesJson: UniApp.PagesJson): UniApp.UniRoute[];
|
|
28
|
+
declare function parseSubpackagesRoot(inputDir: string, platform: UniApp.PLATFORM): string[];
|
|
29
|
+
export declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot;
|
|
30
|
+
export {};
|