@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,30 @@
|
|
|
1
|
+
interface CheckUpdateOptions {
|
|
2
|
+
inputDir: string;
|
|
3
|
+
compilerVersion: string;
|
|
4
|
+
versionType: 'a' | 'r';
|
|
5
|
+
}
|
|
6
|
+
interface CheckUpdatePlatform {
|
|
7
|
+
appid?: string;
|
|
8
|
+
dev: number;
|
|
9
|
+
build: number;
|
|
10
|
+
}
|
|
11
|
+
interface CheckUpdateCache {
|
|
12
|
+
vid: string;
|
|
13
|
+
lastCheck: number;
|
|
14
|
+
newVersion?: string;
|
|
15
|
+
note?: string;
|
|
16
|
+
[name: string]: CheckUpdatePlatform | undefined | string | number;
|
|
17
|
+
}
|
|
18
|
+
export declare function checkUpdate(options: CheckUpdateOptions): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 检查本地缓存,返回 false 表示需要执行云端检查,返回 true 表示,无需云端检查,返回 string 表示,无需云端检测,且有更新
|
|
21
|
+
* @param inputDir
|
|
22
|
+
* @param compilerVersion
|
|
23
|
+
* @param interval
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
export declare function checkLocalCache(updateCache: CheckUpdateCache, compilerVersion: string, interval?: number): string | boolean;
|
|
27
|
+
export declare function md5(str: string): string;
|
|
28
|
+
export declare function getMac(): string;
|
|
29
|
+
export declare function createPostData({ versionType, compilerVersion }: CheckUpdateOptions, manifestJson: Record<string, any>, updateCache: CheckUpdateCache): string;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
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.createPostData = exports.getMac = exports.md5 = exports.checkLocalCache = exports.checkUpdate = void 0;
|
|
7
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
+
const os_1 = __importDefault(require("os"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
const https_1 = require("https");
|
|
13
|
+
const compare_versions_1 = __importDefault(require("compare-versions"));
|
|
14
|
+
const shared_1 = require("@vue/shared");
|
|
15
|
+
const json_1 = require("./json");
|
|
16
|
+
const hbx_1 = require("./hbx");
|
|
17
|
+
const debugCheckUpdate = (0, debug_1.default)('uni:check-update');
|
|
18
|
+
const INTERVAL = 1000 * 60 * 60 * 24;
|
|
19
|
+
async function checkUpdate(options) {
|
|
20
|
+
if (process.env.CI) {
|
|
21
|
+
debugCheckUpdate('isInCI');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if ((0, hbx_1.isInHBuilderX)()) {
|
|
25
|
+
debugCheckUpdate('isInHBuilderX');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const { inputDir, compilerVersion } = options;
|
|
29
|
+
const updateCache = readCheckUpdateCache(inputDir);
|
|
30
|
+
debugCheckUpdate('read.cache', updateCache);
|
|
31
|
+
const res = checkLocalCache(updateCache, compilerVersion);
|
|
32
|
+
if (res) {
|
|
33
|
+
if ((0, shared_1.isString)(res)) {
|
|
34
|
+
console.log();
|
|
35
|
+
console.log(res);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await checkVersion(options, normalizeUpdateCache(updateCache, (0, json_1.parseManifestJsonOnce)(inputDir)));
|
|
40
|
+
}
|
|
41
|
+
writeCheckUpdateCache(inputDir, statUpdateCache(normalizeUpdateCache(updateCache)));
|
|
42
|
+
}
|
|
43
|
+
exports.checkUpdate = checkUpdate;
|
|
44
|
+
function normalizeUpdateCache(updateCache, manifestJson) {
|
|
45
|
+
const platform = process.env.UNI_PLATFORM;
|
|
46
|
+
if (!updateCache[platform]) {
|
|
47
|
+
updateCache[platform] = {
|
|
48
|
+
appid: '',
|
|
49
|
+
dev: 0,
|
|
50
|
+
build: 0,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (manifestJson) {
|
|
54
|
+
const platformOptions = manifestJson[platform === 'app' ? 'app-plus' : platform];
|
|
55
|
+
updateCache[platform].appid = platformOptions
|
|
56
|
+
? platformOptions.appid || platformOptions.package || ''
|
|
57
|
+
: '';
|
|
58
|
+
}
|
|
59
|
+
return updateCache;
|
|
60
|
+
}
|
|
61
|
+
function statUpdateCache(updateCache) {
|
|
62
|
+
debugCheckUpdate('stat.before', updateCache);
|
|
63
|
+
const platform = process.env.UNI_PLATFORM;
|
|
64
|
+
const type = process.env.NODE_ENV === 'production' ? 'build' : 'dev';
|
|
65
|
+
const platformOptions = updateCache[platform];
|
|
66
|
+
platformOptions[type] = (platformOptions[type] || 0) + 1;
|
|
67
|
+
debugCheckUpdate('stat.after', updateCache);
|
|
68
|
+
return updateCache;
|
|
69
|
+
}
|
|
70
|
+
function getFilepath(inputDir, filename) {
|
|
71
|
+
return path_1.default.resolve(os_1.default.tmpdir(), 'uni-app-cli', md5(inputDir), filename);
|
|
72
|
+
}
|
|
73
|
+
function getCheckUpdateFilepath(inputDir) {
|
|
74
|
+
return getFilepath(inputDir, 'check-update.json');
|
|
75
|
+
}
|
|
76
|
+
function generateVid() {
|
|
77
|
+
let result = '';
|
|
78
|
+
for (let i = 0; i < 4; i++) {
|
|
79
|
+
result += ((65536 * (1 + Math.random())) | 0).toString(16).substring(1);
|
|
80
|
+
}
|
|
81
|
+
return 'UNI_' + result.toUpperCase();
|
|
82
|
+
}
|
|
83
|
+
function createCheckUpdateCache(vid = generateVid()) {
|
|
84
|
+
return {
|
|
85
|
+
vid: generateVid(),
|
|
86
|
+
lastCheck: 0,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function readCheckUpdateCache(inputDir) {
|
|
90
|
+
const updateFilepath = getCheckUpdateFilepath(inputDir);
|
|
91
|
+
debugCheckUpdate('read:', updateFilepath);
|
|
92
|
+
if (fs_extra_1.default.existsSync(updateFilepath)) {
|
|
93
|
+
try {
|
|
94
|
+
return require(updateFilepath);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
debugCheckUpdate('read.error', e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return createCheckUpdateCache();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 检查本地缓存,返回 false 表示需要执行云端检查,返回 true 表示,无需云端检查,返回 string 表示,无需云端检测,且有更新
|
|
104
|
+
* @param inputDir
|
|
105
|
+
* @param compilerVersion
|
|
106
|
+
* @param interval
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
function checkLocalCache(updateCache, compilerVersion, interval = INTERVAL) {
|
|
110
|
+
if (!updateCache.lastCheck) {
|
|
111
|
+
debugCheckUpdate('cache: lastCheck not found');
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (Date.now() - updateCache.lastCheck > interval) {
|
|
115
|
+
debugCheckUpdate('cache: lastCheck > interval');
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
if (updateCache.newVersion &&
|
|
119
|
+
(0, compare_versions_1.default)(updateCache.newVersion, compilerVersion) > 0) {
|
|
120
|
+
debugCheckUpdate('cache: find new version');
|
|
121
|
+
return updateCache.note;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
exports.checkLocalCache = checkLocalCache;
|
|
126
|
+
function writeCheckUpdateCache(inputDir, updateCache) {
|
|
127
|
+
const filepath = getCheckUpdateFilepath(inputDir);
|
|
128
|
+
debugCheckUpdate('write:', filepath, updateCache);
|
|
129
|
+
try {
|
|
130
|
+
fs_extra_1.default.outputFileSync(filepath, JSON.stringify(updateCache));
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
debugCheckUpdate('write.error', e);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function md5(str) {
|
|
137
|
+
return crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
138
|
+
}
|
|
139
|
+
exports.md5 = md5;
|
|
140
|
+
function getMac() {
|
|
141
|
+
let mac = '';
|
|
142
|
+
const network = os_1.default.networkInterfaces();
|
|
143
|
+
for (const key in network) {
|
|
144
|
+
const array = network[key];
|
|
145
|
+
for (let i = 0; i < array.length; i++) {
|
|
146
|
+
const item = array[i];
|
|
147
|
+
if (!item.family || (item.mac && item.mac === '00:00:00:00:00:00')) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (item.family === 'IPv4' || item.family === 'IPv6') {
|
|
151
|
+
mac = item.mac;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return mac;
|
|
157
|
+
}
|
|
158
|
+
exports.getMac = getMac;
|
|
159
|
+
function createPostData({ versionType, compilerVersion }, manifestJson, updateCache) {
|
|
160
|
+
const data = {
|
|
161
|
+
vv: 3,
|
|
162
|
+
device: md5(getMac()),
|
|
163
|
+
vtype: versionType,
|
|
164
|
+
vcode: compilerVersion,
|
|
165
|
+
};
|
|
166
|
+
if (manifestJson.appid) {
|
|
167
|
+
data.appid = manifestJson.appid;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
data.vid = updateCache.vid;
|
|
171
|
+
}
|
|
172
|
+
Object.keys(updateCache).forEach((name) => {
|
|
173
|
+
const value = updateCache[name];
|
|
174
|
+
if ((0, shared_1.isPlainObject)(value) &&
|
|
175
|
+
((0, shared_1.hasOwn)(value, 'dev') || (0, shared_1.hasOwn)(value, 'build'))) {
|
|
176
|
+
data[name] = value;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return JSON.stringify(data);
|
|
180
|
+
}
|
|
181
|
+
exports.createPostData = createPostData;
|
|
182
|
+
function handleCheckVersion({ code, isUpdate, newVersion, note }, updateCache) {
|
|
183
|
+
if (code !== 0) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// clear
|
|
187
|
+
Object.keys(updateCache).forEach((key) => {
|
|
188
|
+
if (key !== 'vid')
|
|
189
|
+
delete updateCache[key];
|
|
190
|
+
});
|
|
191
|
+
updateCache.lastCheck = Date.now();
|
|
192
|
+
if (isUpdate) {
|
|
193
|
+
updateCache.note = note;
|
|
194
|
+
updateCache.newVersion = newVersion;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
delete updateCache.note;
|
|
198
|
+
delete updateCache.newVersion;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const HOSTNAME = 'uniapp.dcloud.net.cn';
|
|
202
|
+
const PATH = '/update/cli';
|
|
203
|
+
function checkVersion(options, updateCache) {
|
|
204
|
+
return new Promise((resolve) => {
|
|
205
|
+
const postData = JSON.stringify({
|
|
206
|
+
id: createPostData(options, (0, json_1.parseManifestJsonOnce)(options.inputDir), updateCache),
|
|
207
|
+
});
|
|
208
|
+
let responseData = '';
|
|
209
|
+
const req = (0, https_1.request)({
|
|
210
|
+
hostname: HOSTNAME,
|
|
211
|
+
path: PATH,
|
|
212
|
+
port: 443,
|
|
213
|
+
method: 'POST',
|
|
214
|
+
headers: {
|
|
215
|
+
'Content-Type': 'application/json',
|
|
216
|
+
'Content-Length': postData.length,
|
|
217
|
+
},
|
|
218
|
+
}, (res) => {
|
|
219
|
+
res.setEncoding('utf8');
|
|
220
|
+
res.on('data', (chunk) => {
|
|
221
|
+
responseData += chunk;
|
|
222
|
+
});
|
|
223
|
+
res.on('end', () => {
|
|
224
|
+
debugCheckUpdate('response: ', responseData);
|
|
225
|
+
try {
|
|
226
|
+
handleCheckVersion(JSON.parse(responseData), updateCache);
|
|
227
|
+
}
|
|
228
|
+
catch (e) { }
|
|
229
|
+
resolve(true);
|
|
230
|
+
});
|
|
231
|
+
res.on('error', (e) => {
|
|
232
|
+
debugCheckUpdate('response.error:', e);
|
|
233
|
+
resolve(false);
|
|
234
|
+
});
|
|
235
|
+
}).on('error', (e) => {
|
|
236
|
+
debugCheckUpdate('request.error:', e);
|
|
237
|
+
resolve(false);
|
|
238
|
+
});
|
|
239
|
+
debugCheckUpdate('request: ', postData);
|
|
240
|
+
req.write(postData);
|
|
241
|
+
req.end();
|
|
242
|
+
});
|
|
243
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const PUBLIC_DIR = "static";
|
|
2
|
+
export declare const EXTNAME_JS: string[];
|
|
3
|
+
export declare const EXTNAME_TS: string[];
|
|
4
|
+
export declare const EXTNAME_VUE: string[];
|
|
5
|
+
export declare const EXTNAME_VUE_TEMPLATE: string[];
|
|
6
|
+
export declare const EXTNAME_VUE_RE: RegExp;
|
|
7
|
+
export declare const EXTNAME_JS_RE: RegExp;
|
|
8
|
+
export declare const EXTNAME_TS_RE: RegExp;
|
|
9
|
+
export declare const extensions: string[];
|
|
10
|
+
export declare const ASSETS_INLINE_LIMIT: number;
|
|
11
|
+
export declare const APP_SERVICE_FILENAME = "app-service.js";
|
|
12
|
+
export declare const BINDING_COMPONENTS = "__BINDING_COMPONENTS__";
|
|
13
|
+
export declare const PAGE_EXTNAME_APP: string[];
|
|
14
|
+
export declare const PAGE_EXTNAME: string[];
|
|
15
|
+
export declare const H5_API_STYLE_PATH = "@dcloudio/uni-h5/style/api/";
|
|
16
|
+
export declare const H5_FRAMEWORK_STYLE_PATH = "@dcloudio/uni-h5/style/framework/";
|
|
17
|
+
export declare const H5_COMPONENTS_STYLE_PATH = "@dcloudio/uni-h5/style/";
|
|
18
|
+
export declare const BASE_COMPONENTS_STYLE_PATH = "@dcloudio/uni-components/style/";
|
|
19
|
+
export declare const COMMON_EXCLUDE: RegExp[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMMON_EXCLUDE = exports.BASE_COMPONENTS_STYLE_PATH = exports.H5_COMPONENTS_STYLE_PATH = exports.H5_FRAMEWORK_STYLE_PATH = exports.H5_API_STYLE_PATH = exports.PAGE_EXTNAME = exports.PAGE_EXTNAME_APP = exports.BINDING_COMPONENTS = exports.APP_SERVICE_FILENAME = exports.ASSETS_INLINE_LIMIT = exports.extensions = exports.EXTNAME_TS_RE = exports.EXTNAME_JS_RE = exports.EXTNAME_VUE_RE = exports.EXTNAME_VUE_TEMPLATE = exports.EXTNAME_VUE = exports.EXTNAME_TS = exports.EXTNAME_JS = exports.PUBLIC_DIR = void 0;
|
|
4
|
+
exports.PUBLIC_DIR = 'static';
|
|
5
|
+
exports.EXTNAME_JS = ['.js', '.ts', '.jsx', '.tsx'];
|
|
6
|
+
exports.EXTNAME_TS = ['.ts', '.tsx'];
|
|
7
|
+
exports.EXTNAME_VUE = ['.vue', '.nvue'];
|
|
8
|
+
exports.EXTNAME_VUE_TEMPLATE = ['.vue', '.nvue', '.jsx', '.tsx'];
|
|
9
|
+
exports.EXTNAME_VUE_RE = /\.(vue|nvue)$/;
|
|
10
|
+
exports.EXTNAME_JS_RE = /\.[jt]sx?$/;
|
|
11
|
+
exports.EXTNAME_TS_RE = /\.tsx?$/;
|
|
12
|
+
exports.extensions = [
|
|
13
|
+
'.mjs',
|
|
14
|
+
'.js',
|
|
15
|
+
'.ts',
|
|
16
|
+
'.jsx',
|
|
17
|
+
'.tsx',
|
|
18
|
+
'.json',
|
|
19
|
+
].concat(exports.EXTNAME_VUE);
|
|
20
|
+
exports.ASSETS_INLINE_LIMIT = 40 * 1024;
|
|
21
|
+
exports.APP_SERVICE_FILENAME = 'app-service.js';
|
|
22
|
+
exports.BINDING_COMPONENTS = '__BINDING_COMPONENTS__';
|
|
23
|
+
// APP 平台解析页面后缀的优先级
|
|
24
|
+
exports.PAGE_EXTNAME_APP = ['.nvue', '.vue', '.tsx', '.jsx', '.js'];
|
|
25
|
+
// 其他平台解析页面后缀的优先级
|
|
26
|
+
exports.PAGE_EXTNAME = ['.vue', '.nvue', '.tsx', '.jsx', '.js'];
|
|
27
|
+
exports.H5_API_STYLE_PATH = '@dcloudio/uni-h5/style/api/';
|
|
28
|
+
exports.H5_FRAMEWORK_STYLE_PATH = '@dcloudio/uni-h5/style/framework/';
|
|
29
|
+
exports.H5_COMPONENTS_STYLE_PATH = '@dcloudio/uni-h5/style/';
|
|
30
|
+
exports.BASE_COMPONENTS_STYLE_PATH = '@dcloudio/uni-components/style/';
|
|
31
|
+
exports.COMMON_EXCLUDE = [
|
|
32
|
+
/\/pages\.json\.js$/,
|
|
33
|
+
/\/manifest\.json\.js$/,
|
|
34
|
+
/\/vite\//,
|
|
35
|
+
/\/@vue\//,
|
|
36
|
+
/\/vue-router\//,
|
|
37
|
+
/\/vuex\//,
|
|
38
|
+
/\/vue-i18n\//,
|
|
39
|
+
/\/@dcloudio\/uni-h5-vue/,
|
|
40
|
+
/\/@dcloudio\/uni-shared/,
|
|
41
|
+
/\/@dcloudio\/uni-h5\/style/,
|
|
42
|
+
/\/@dcloudio\/uni-components\/style/,
|
|
43
|
+
];
|
package/dist/deps.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const API_DEPS_CSS: {
|
|
2
|
+
showModal: string[];
|
|
3
|
+
showToast: string[];
|
|
4
|
+
showActionSheet: string[];
|
|
5
|
+
previewImage: string[];
|
|
6
|
+
openLocation: string[];
|
|
7
|
+
chooseLocation: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare const COMPONENT_DEPS_CSS: {
|
|
10
|
+
canvas: string[];
|
|
11
|
+
image: string[];
|
|
12
|
+
'movable-area': string[];
|
|
13
|
+
'picker-view': string[];
|
|
14
|
+
'picker-view-column': string[];
|
|
15
|
+
'rich-text': string[];
|
|
16
|
+
textarea: string[];
|
|
17
|
+
'web-view': string[];
|
|
18
|
+
picker: string[];
|
|
19
|
+
};
|
package/dist/deps.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
|
6
|
+
exports.API_DEPS_CSS = {
|
|
7
|
+
showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
|
|
8
|
+
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
|
9
|
+
showActionSheet: [`${constants_1.H5_API_STYLE_PATH}action-sheet.css`],
|
|
10
|
+
previewImage: [
|
|
11
|
+
RESIZE_SENSOR_CSS,
|
|
12
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper.css`,
|
|
13
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}swiper-item.css`,
|
|
14
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-area.css`,
|
|
15
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}movable-view.css`,
|
|
16
|
+
],
|
|
17
|
+
openLocation: [`${constants_1.H5_API_STYLE_PATH}location-view.css`],
|
|
18
|
+
chooseLocation: [
|
|
19
|
+
`${constants_1.H5_API_STYLE_PATH}/location-picker.css`,
|
|
20
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/input.css`,
|
|
21
|
+
`${constants_1.H5_COMPONENTS_STYLE_PATH}/map.css`,
|
|
22
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}/scroll-view.css`,
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
exports.COMPONENT_DEPS_CSS = {
|
|
26
|
+
canvas: [RESIZE_SENSOR_CSS],
|
|
27
|
+
image: [RESIZE_SENSOR_CSS],
|
|
28
|
+
'movable-area': [RESIZE_SENSOR_CSS],
|
|
29
|
+
'picker-view': [RESIZE_SENSOR_CSS],
|
|
30
|
+
'picker-view-column': [RESIZE_SENSOR_CSS],
|
|
31
|
+
'rich-text': [RESIZE_SENSOR_CSS],
|
|
32
|
+
textarea: [RESIZE_SENSOR_CSS],
|
|
33
|
+
'web-view': [RESIZE_SENSOR_CSS],
|
|
34
|
+
picker: [
|
|
35
|
+
RESIZE_SENSOR_CSS,
|
|
36
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
|
|
37
|
+
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
|
|
38
|
+
],
|
|
39
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface EasycomOption {
|
|
2
|
+
dirs?: string[];
|
|
3
|
+
rootDir: string;
|
|
4
|
+
extensions?: string[];
|
|
5
|
+
autoscan?: boolean;
|
|
6
|
+
custom?: EasycomCustom;
|
|
7
|
+
}
|
|
8
|
+
interface EasycomMatcher {
|
|
9
|
+
pattern: RegExp;
|
|
10
|
+
replacement: string;
|
|
11
|
+
}
|
|
12
|
+
interface EasycomCustom {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function initEasycoms(inputDir: string, { dirs, platform }: {
|
|
16
|
+
dirs: string[];
|
|
17
|
+
platform: UniApp.PLATFORM;
|
|
18
|
+
}): {
|
|
19
|
+
options: EasycomOption;
|
|
20
|
+
filter: (id: unknown) => boolean;
|
|
21
|
+
refresh(): void;
|
|
22
|
+
easycoms: EasycomMatcher[];
|
|
23
|
+
};
|
|
24
|
+
export declare const initEasycomsOnce: typeof initEasycoms;
|
|
25
|
+
export declare function matchEasycom(tag: string): string | false | undefined;
|
|
26
|
+
export declare function addImportDeclaration(importDeclarations: string[], local: string, source: string, imported?: string): string;
|
|
27
|
+
export declare function genResolveEasycomCode(importDeclarations: string[], code: string, name: string): string;
|
|
28
|
+
export declare const UNI_EASYCOM_EXCLUDE: RegExp[];
|
|
29
|
+
export {};
|
package/dist/easycom.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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.UNI_EASYCOM_EXCLUDE = exports.genResolveEasycomCode = exports.addImportDeclaration = exports.matchEasycom = exports.initEasycomsOnce = exports.initEasycoms = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const shared_1 = require("@vue/shared");
|
|
11
|
+
const pluginutils_1 = require("@rollup/pluginutils");
|
|
12
|
+
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const pages_1 = require("./json/pages");
|
|
15
|
+
const messages_1 = require("./messages");
|
|
16
|
+
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
17
|
+
const easycoms = [];
|
|
18
|
+
const easycomsCache = new Map();
|
|
19
|
+
const easycomsInvalidCache = new Set();
|
|
20
|
+
let hasEasycom = false;
|
|
21
|
+
function clearEasycom() {
|
|
22
|
+
easycoms.length = 0;
|
|
23
|
+
easycomsCache.clear();
|
|
24
|
+
easycomsInvalidCache.clear();
|
|
25
|
+
}
|
|
26
|
+
function initEasycoms(inputDir, { dirs, platform }) {
|
|
27
|
+
const componentsDir = path_1.default.resolve(inputDir, 'components');
|
|
28
|
+
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
29
|
+
const initEasycomOptions = (pagesJson) => {
|
|
30
|
+
// 初始化时,从once中读取缓存,refresh时,实时读取
|
|
31
|
+
const { easycom } = pagesJson || (0, pages_1.parsePagesJson)(inputDir, platform, false);
|
|
32
|
+
const easycomOptions = {
|
|
33
|
+
dirs: easycom && easycom.autoscan === false
|
|
34
|
+
? [...dirs] // 禁止自动扫描
|
|
35
|
+
: [
|
|
36
|
+
...dirs,
|
|
37
|
+
componentsDir,
|
|
38
|
+
...initUniModulesEasycomDirs(uniModulesDir),
|
|
39
|
+
],
|
|
40
|
+
rootDir: inputDir,
|
|
41
|
+
autoscan: !!(easycom && easycom.autoscan),
|
|
42
|
+
custom: (easycom && easycom.custom) || {},
|
|
43
|
+
};
|
|
44
|
+
debugEasycom(easycomOptions);
|
|
45
|
+
return easycomOptions;
|
|
46
|
+
};
|
|
47
|
+
const options = initEasycomOptions((0, pages_1.parsePagesJsonOnce)(inputDir, platform));
|
|
48
|
+
initEasycom(options);
|
|
49
|
+
const res = {
|
|
50
|
+
options,
|
|
51
|
+
filter: (0, pluginutils_1.createFilter)([
|
|
52
|
+
'components/*/*.(vue|jsx|tsx)',
|
|
53
|
+
'uni_modules/*/components/*/*.(vue|jsx|tsx)',
|
|
54
|
+
], [], {
|
|
55
|
+
resolve: inputDir,
|
|
56
|
+
}),
|
|
57
|
+
refresh() {
|
|
58
|
+
res.options = initEasycomOptions();
|
|
59
|
+
initEasycom(res.options);
|
|
60
|
+
},
|
|
61
|
+
easycoms,
|
|
62
|
+
};
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
exports.initEasycoms = initEasycoms;
|
|
66
|
+
exports.initEasycomsOnce = (0, uni_shared_1.once)(initEasycoms);
|
|
67
|
+
function initUniModulesEasycomDirs(uniModulesDir) {
|
|
68
|
+
if (!fs_1.default.existsSync(uniModulesDir)) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
return fs_1.default
|
|
72
|
+
.readdirSync(uniModulesDir)
|
|
73
|
+
.map((uniModuleDir) => {
|
|
74
|
+
const uniModuleComponentsDir = path_1.default.resolve(uniModulesDir, uniModuleDir, 'components');
|
|
75
|
+
if (fs_1.default.existsSync(uniModuleComponentsDir)) {
|
|
76
|
+
return uniModuleComponentsDir;
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
.filter(Boolean);
|
|
80
|
+
}
|
|
81
|
+
function initEasycom({ dirs, rootDir, custom, extensions = ['.vue', '.jsx', '.tsx'], }) {
|
|
82
|
+
clearEasycom();
|
|
83
|
+
const easycomsObj = Object.create(null);
|
|
84
|
+
if (dirs && dirs.length && rootDir) {
|
|
85
|
+
(0, shared_1.extend)(easycomsObj, initAutoScanEasycoms(dirs, rootDir, extensions));
|
|
86
|
+
}
|
|
87
|
+
if (custom) {
|
|
88
|
+
Object.keys(custom).forEach((name) => {
|
|
89
|
+
const componentPath = custom[name];
|
|
90
|
+
easycomsObj[name] = componentPath.startsWith('@/')
|
|
91
|
+
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, componentPath.substr(2)))
|
|
92
|
+
: componentPath;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
Object.keys(easycomsObj).forEach((name) => {
|
|
96
|
+
easycoms.push({
|
|
97
|
+
pattern: new RegExp(name),
|
|
98
|
+
replacement: easycomsObj[name],
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
debugEasycom(easycoms);
|
|
102
|
+
hasEasycom = !!easycoms.length;
|
|
103
|
+
return easycoms;
|
|
104
|
+
}
|
|
105
|
+
function matchEasycom(tag) {
|
|
106
|
+
if (!hasEasycom) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
let source = easycomsCache.get(tag);
|
|
110
|
+
if (source) {
|
|
111
|
+
return source;
|
|
112
|
+
}
|
|
113
|
+
if (easycomsInvalidCache.has(tag)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
const matcher = easycoms.find((matcher) => matcher.pattern.test(tag));
|
|
117
|
+
if (!matcher) {
|
|
118
|
+
easycomsInvalidCache.add(tag);
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
source = tag.replace(matcher.pattern, matcher.replacement);
|
|
122
|
+
easycomsCache.set(tag, source);
|
|
123
|
+
debugEasycom('matchEasycom', tag, source);
|
|
124
|
+
return source;
|
|
125
|
+
}
|
|
126
|
+
exports.matchEasycom = matchEasycom;
|
|
127
|
+
const isDir = (path) => fs_1.default.lstatSync(path).isDirectory();
|
|
128
|
+
function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
129
|
+
if (!path_1.default.isAbsolute(dir)) {
|
|
130
|
+
dir = path_1.default.resolve(rootDir, dir);
|
|
131
|
+
}
|
|
132
|
+
const easycoms = Object.create(null);
|
|
133
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
134
|
+
return easycoms;
|
|
135
|
+
}
|
|
136
|
+
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
137
|
+
const folder = path_1.default.resolve(dir, name);
|
|
138
|
+
if (!isDir(folder)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const importDir = (0, utils_1.normalizePath)(folder);
|
|
142
|
+
const files = fs_1.default.readdirSync(folder);
|
|
143
|
+
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
|
|
144
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
145
|
+
const ext = extensions[i];
|
|
146
|
+
if (files.includes(name + ext)) {
|
|
147
|
+
easycoms[`^${name}$`] = `${importDir}/${name}${ext}`;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return easycoms;
|
|
153
|
+
}
|
|
154
|
+
function initAutoScanEasycoms(dirs, rootDir, extensions) {
|
|
155
|
+
const conflict = {};
|
|
156
|
+
const res = dirs.reduce((easycoms, dir) => {
|
|
157
|
+
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions);
|
|
158
|
+
Object.keys(curEasycoms).forEach((name) => {
|
|
159
|
+
// Use the first component when name conflict
|
|
160
|
+
const compath = easycoms[name];
|
|
161
|
+
if (!compath) {
|
|
162
|
+
easycoms[name] = curEasycoms[name];
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
;
|
|
166
|
+
(conflict[compath] || (conflict[compath] = [])).push(normalizeCompath(curEasycoms[name], rootDir));
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return easycoms;
|
|
170
|
+
}, Object.create(null));
|
|
171
|
+
const conflictComs = Object.keys(conflict);
|
|
172
|
+
if (conflictComs.length) {
|
|
173
|
+
console.warn(messages_1.M['easycom.conflict']);
|
|
174
|
+
conflictComs.forEach((com) => {
|
|
175
|
+
console.warn([normalizeCompath(com, rootDir), conflict[com]].join(','));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return res;
|
|
179
|
+
}
|
|
180
|
+
function normalizeCompath(compath, rootDir) {
|
|
181
|
+
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir, compath));
|
|
182
|
+
}
|
|
183
|
+
function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
184
|
+
importDeclarations.push(createImportDeclaration(local, source, imported));
|
|
185
|
+
return local;
|
|
186
|
+
}
|
|
187
|
+
exports.addImportDeclaration = addImportDeclaration;
|
|
188
|
+
function createImportDeclaration(local, source, imported) {
|
|
189
|
+
if (imported) {
|
|
190
|
+
return `import {${imported} as ${local}} from '${source}';`;
|
|
191
|
+
}
|
|
192
|
+
return `import ${local} from '${source}';`;
|
|
193
|
+
}
|
|
194
|
+
const RESOLVE_EASYCOM_IMPORT_CODE = `import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';`;
|
|
195
|
+
function genResolveEasycomCode(importDeclarations, code, name) {
|
|
196
|
+
if (!importDeclarations.includes(RESOLVE_EASYCOM_IMPORT_CODE)) {
|
|
197
|
+
importDeclarations.push(RESOLVE_EASYCOM_IMPORT_CODE);
|
|
198
|
+
}
|
|
199
|
+
return `resolveEasycom(${code.replace('_resolveComponent', '__resolveDynamicComponent')}, ${name})`;
|
|
200
|
+
}
|
|
201
|
+
exports.genResolveEasycomCode = genResolveEasycomCode;
|
|
202
|
+
exports.UNI_EASYCOM_EXCLUDE = [/App.vue$/, /@dcloudio\/uni-h5/];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function initDefine(stringifyBoolean?: boolean): {
|
|
2
|
+
'process.env.NODE_ENV': string;
|
|
3
|
+
'process.env.UNI_DEBUG': string | boolean;
|
|
4
|
+
'process.env.UNI_APP_ID': string;
|
|
5
|
+
'process.env.UNI_APP_NAME': string;
|
|
6
|
+
'process.env.UNI_PLATFORM': string;
|
|
7
|
+
'process.env.UNI_MP_PLUGIN': string;
|
|
8
|
+
'process.env.UNI_SUBPACKAGE': string;
|
|
9
|
+
'process.env.UNI_COMPILER_VERSION': string;
|
|
10
|
+
'process.env.RUN_BY_HBUILDERX': string | boolean;
|
|
11
|
+
'process.env.UNI_AUTOMATOR_WS_ENDPOINT': string;
|
|
12
|
+
'process.env.UNI_CLOUD_PROVIDER': string;
|
|
13
|
+
'process.env.UNICLOUD_DEBUG': string;
|
|
14
|
+
'process.env.VUE_APP_PLATFORM': string;
|
|
15
|
+
};
|