@dcloudio/uni-cli-shared 2.0.1-alpha-36320220919002 → 2.0.1-alpha-36720221017001
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/components/ad.mixin.js +4 -2
- package/lib/cache.js +7 -2
- package/lib/file-loader.js +5 -6
- package/lib/index.js +1 -1
- package/lib/manifest.js +18 -4
- package/lib/pages.js +21 -7
- package/lib/uni_modules/uni_modules.js +99 -0
- package/lib/util.js +9 -0
- package/package.json +2 -2
package/components/ad.mixin.js
CHANGED
|
@@ -54,12 +54,14 @@ class AdBase {
|
|
|
54
54
|
})
|
|
55
55
|
ad.onError(({
|
|
56
56
|
code,
|
|
57
|
-
message
|
|
57
|
+
message,
|
|
58
|
+
detail
|
|
58
59
|
}) => {
|
|
59
60
|
this._isLoading = false
|
|
60
61
|
const data = {
|
|
61
62
|
code: code,
|
|
62
|
-
errMsg: message
|
|
63
|
+
errMsg: message,
|
|
64
|
+
detail: detail
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
if (this._retry && code === -5008) {
|
package/lib/cache.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
const crypto = require('crypto')
|
|
4
|
+
const {
|
|
5
|
+
isNormalPage
|
|
6
|
+
} = require('./util')
|
|
4
7
|
/**
|
|
5
8
|
* 1.page-loader 缓存基础的 app.json page.json project.config.json
|
|
6
9
|
* 2.main-loader 缓存 app.json 中的 usingComponents 节点
|
|
@@ -49,7 +52,9 @@ function getJsonFile (name) {
|
|
|
49
52
|
function getChangedJsonFileMap (clear = true) {
|
|
50
53
|
const changedJsonFileMap = new Map()
|
|
51
54
|
for (const name of changedJsonFileSet.values()) {
|
|
52
|
-
|
|
55
|
+
if (isNormalPage(name)) {
|
|
56
|
+
changedJsonFileMap.set(name + '.json', jsonFileMap.get(name))
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
clear && changedJsonFileSet.clear()
|
|
55
60
|
return changedJsonFileMap
|
|
@@ -361,4 +366,4 @@ module.exports = {
|
|
|
361
366
|
getChangedJsonFileMap,
|
|
362
367
|
getSpecialMethods,
|
|
363
368
|
supportGlobalUsingComponents
|
|
364
|
-
}
|
|
369
|
+
}
|
package/lib/file-loader.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
|
|
2
|
+
const {
|
|
3
|
+
normalizeNodeModules
|
|
4
|
+
} = require('./util')
|
|
6
5
|
|
|
7
6
|
module.exports = {
|
|
8
7
|
loader: 'file-loader',
|
|
9
8
|
options: {
|
|
10
9
|
publicPath (url, resourcePath, context) {
|
|
11
|
-
return '/' +
|
|
10
|
+
return '/' + normalizeNodeModules(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
|
|
12
11
|
},
|
|
13
12
|
outputPath (url, resourcePath, context) {
|
|
14
|
-
return
|
|
13
|
+
return normalizeNodeModules(path.relative(process.env.UNI_INPUT_DIR, resourcePath))
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
}
|
package/lib/index.js
CHANGED
package/lib/manifest.js
CHANGED
|
@@ -108,7 +108,7 @@ function isEnableUniPushV1 (manifestJson, platform) {
|
|
|
108
108
|
if (isEnableUniPushV2(manifestJson, platform)) {
|
|
109
109
|
return false
|
|
110
110
|
}
|
|
111
|
-
if (platform === 'app-plus') {
|
|
111
|
+
if (platform === 'app-plus') {
|
|
112
112
|
const platformOptions = manifestJson[platform]
|
|
113
113
|
const sdkConfigs = platformOptions && platformOptions.distribute && platformOptions.distribute.sdkConfigs
|
|
114
114
|
const push = sdkConfigs && sdkConfigs.push
|
|
@@ -135,6 +135,19 @@ function isEnableUniPushV2 (manifestJson, platform) {
|
|
|
135
135
|
return platformOptions && platformOptions.unipush && platformOptions.unipush.enable === true
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
function isEnableSecureNetwork (manifestJson, platform) {
|
|
139
|
+
if (!manifestJson) {
|
|
140
|
+
manifestJson = getManifestJson()
|
|
141
|
+
}
|
|
142
|
+
const platformOptions = manifestJson[platform]
|
|
143
|
+
if (platform === 'app-plus') {
|
|
144
|
+
return !!(
|
|
145
|
+
platformOptions && platformOptions.modules && platformOptions.modules.SecureNetwork
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
return platformOptions && platformOptions.secureNetwork && platformOptions.secureNetwork.enable === true
|
|
149
|
+
}
|
|
150
|
+
|
|
138
151
|
function isUniPushOffline (manifestJson) {
|
|
139
152
|
if (!manifestJson) {
|
|
140
153
|
manifestJson = getManifestJson()
|
|
@@ -149,8 +162,9 @@ module.exports = {
|
|
|
149
162
|
getManifestJson,
|
|
150
163
|
parseManifestJson,
|
|
151
164
|
getNetworkTimeout,
|
|
152
|
-
getH5Options,
|
|
165
|
+
getH5Options,
|
|
153
166
|
isEnableUniPushV1,
|
|
154
167
|
isEnableUniPushV2,
|
|
155
|
-
isUniPushOffline
|
|
156
|
-
|
|
168
|
+
isUniPushOffline,
|
|
169
|
+
isEnableSecureNetwork
|
|
170
|
+
}
|
package/lib/pages.js
CHANGED
|
@@ -6,7 +6,8 @@ const {
|
|
|
6
6
|
removeExt,
|
|
7
7
|
normalizePath,
|
|
8
8
|
camelize,
|
|
9
|
-
capitalize
|
|
9
|
+
capitalize,
|
|
10
|
+
isNormalPage
|
|
10
11
|
} = require('./util')
|
|
11
12
|
|
|
12
13
|
const {
|
|
@@ -113,7 +114,9 @@ function isNVuePage (page, root = '') {
|
|
|
113
114
|
|
|
114
115
|
function isValidPage (page, root = '') {
|
|
115
116
|
if (typeof page === 'string' || !page.path) { // 不合法的配置
|
|
116
|
-
console.warn(uniI18n.__('cliShared.pagesJsonError', {
|
|
117
|
+
console.warn(uniI18n.__('cliShared.pagesJsonError', {
|
|
118
|
+
0: 'https://uniapp.dcloud.io/collocation/pages?id=pages'
|
|
119
|
+
}))
|
|
117
120
|
return false
|
|
118
121
|
}
|
|
119
122
|
let pagePath = page.path
|
|
@@ -213,7 +216,10 @@ function parseEntry (pagesJson) {
|
|
|
213
216
|
const weixinConfig = manifestConfig['mp-weixin'] || {}
|
|
214
217
|
const independentSwitch = !!weixinConfig.independent
|
|
215
218
|
if (independentSwitch) {
|
|
216
|
-
Object.values(process.UNI_SUBPACKAGES).forEach(({
|
|
219
|
+
Object.values(process.UNI_SUBPACKAGES).forEach(({
|
|
220
|
+
root,
|
|
221
|
+
independent = false
|
|
222
|
+
}) => {
|
|
217
223
|
if (root && independent) {
|
|
218
224
|
const pkgRootMainJsKey = `${root}/common/main`
|
|
219
225
|
// const pkgRootMainJsPath = `${process.env.UNI_INPUT_DIR}/${root}/main.js`;
|
|
@@ -239,7 +245,9 @@ function parseEntry (pagesJson) {
|
|
|
239
245
|
|
|
240
246
|
// pages
|
|
241
247
|
pagesJson.pages.forEach(page => {
|
|
242
|
-
|
|
248
|
+
if (isNormalPage(page.path)) {
|
|
249
|
+
process.UNI_ENTRY[page.path] = getMainJsPath(page.path)
|
|
250
|
+
}
|
|
243
251
|
})
|
|
244
252
|
// subPackages
|
|
245
253
|
if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) {
|
|
@@ -404,7 +412,11 @@ function initAutoComponents () {
|
|
|
404
412
|
})
|
|
405
413
|
if (conflictFiles.length > 0) {
|
|
406
414
|
conflictFiles.forEach(files => {
|
|
407
|
-
console.warn(uniI18n.__('cliShared.easycomConflict', {
|
|
415
|
+
console.warn(uniI18n.__('cliShared.easycomConflict', {
|
|
416
|
+
0: '[' + files.map((file, index) => {
|
|
417
|
+
return file
|
|
418
|
+
}).join(',') + ']'
|
|
419
|
+
}))
|
|
408
420
|
console.log('\n')
|
|
409
421
|
})
|
|
410
422
|
}
|
|
@@ -519,7 +531,9 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) {
|
|
|
519
531
|
|
|
520
532
|
const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media']
|
|
521
533
|
|
|
522
|
-
const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial',
|
|
534
|
+
const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial',
|
|
535
|
+
'ad-interactive'
|
|
536
|
+
]
|
|
523
537
|
|
|
524
538
|
function isBuiltInComponent (name) { // uni-template-compiler/lib/util.js 识别微信内置组件
|
|
525
539
|
return BUILT_IN_COMPONENTS.includes(name)
|
|
@@ -551,4 +565,4 @@ module.exports = {
|
|
|
551
565
|
getGlobalUsingComponentsCode,
|
|
552
566
|
parseUsingAutoImportComponents,
|
|
553
567
|
generateGlobalUsingComponentsCode
|
|
554
|
-
}
|
|
568
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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.parseInject = exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const merge_1 = require("merge");
|
|
10
|
+
function parseUniExtApis() {
|
|
11
|
+
const uniModulesDir = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules');
|
|
12
|
+
if (!fs_extra_1.default.existsSync(uniModulesDir)) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const injects = {};
|
|
16
|
+
fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
// 必须以 uni- 开头
|
|
19
|
+
if (!uniModuleDir.startsWith('uni-')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const pkgPath = path_1.default.resolve(uniModulesDir, uniModuleDir, 'package.json');
|
|
23
|
+
if (!fs_extra_1.default.existsSync(pkgPath)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b['uni-ext-api'];
|
|
27
|
+
if (exports) {
|
|
28
|
+
Object.assign(injects, parseInjects(process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return injects;
|
|
32
|
+
}
|
|
33
|
+
exports.parseUniExtApis = parseUniExtApis;
|
|
34
|
+
/**
|
|
35
|
+
* uni:'getBatteryInfo'
|
|
36
|
+
* import getBatteryInfo from '..'
|
|
37
|
+
*
|
|
38
|
+
* uni:['getBatteryInfo']
|
|
39
|
+
* import { getBatteryInfo } from '..'
|
|
40
|
+
*
|
|
41
|
+
* uni:['openLocation','chooseLocation']
|
|
42
|
+
* import { openLocation, chooseLocation } from '..'
|
|
43
|
+
*
|
|
44
|
+
* uni:{
|
|
45
|
+
* onUserCaptureScreen: "onCaptureScreen"
|
|
46
|
+
* offUserCaptureScreen: "offCaptureScreen"
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* uni.getBatteryInfo = getBatteryInfo
|
|
50
|
+
* @param source
|
|
51
|
+
* @param globalObject
|
|
52
|
+
* @param define
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
function parseInjects(platform, source, exports = {}) {
|
|
56
|
+
let rootDefines = {};
|
|
57
|
+
Object.keys(exports).forEach((name) => {
|
|
58
|
+
if (name.startsWith('uni')) {
|
|
59
|
+
rootDefines[name] = exports[name];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const platformDefines = exports[platform];
|
|
63
|
+
// 该平台不支持
|
|
64
|
+
if (platformDefines === false) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
if (platformDefines) {
|
|
68
|
+
rootDefines = (0, merge_1.recursive)(true, rootDefines, platformDefines);
|
|
69
|
+
}
|
|
70
|
+
const injects = {};
|
|
71
|
+
for (const key in rootDefines) {
|
|
72
|
+
Object.assign(injects, parseInject(source, 'uni', rootDefines[key]));
|
|
73
|
+
}
|
|
74
|
+
return injects;
|
|
75
|
+
}
|
|
76
|
+
exports.parseInjects = parseInjects;
|
|
77
|
+
function parseInject(source, globalObject, define) {
|
|
78
|
+
const injects = {};
|
|
79
|
+
if (define === false) {
|
|
80
|
+
}
|
|
81
|
+
else if (typeof define === 'string') {
|
|
82
|
+
// {'uni.getBatteryInfo' : '@dcloudio/uni-getbatteryinfo'}
|
|
83
|
+
injects[globalObject + '.' + define] = source;
|
|
84
|
+
}
|
|
85
|
+
else if (Array.isArray(define)) {
|
|
86
|
+
// {'uni.getBatteryInfo' : ['@dcloudio/uni-getbatteryinfo','getBatteryInfo]}
|
|
87
|
+
define.forEach((d) => {
|
|
88
|
+
injects[globalObject + '.' + d] = [source, d];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const keys = Object.keys(define);
|
|
93
|
+
keys.forEach((d) => {
|
|
94
|
+
injects[globalObject + '.' + d] = [source, define[d]];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return injects;
|
|
98
|
+
}
|
|
99
|
+
exports.parseInject = parseInject;
|
package/lib/util.js
CHANGED
|
@@ -150,8 +150,17 @@ function pathToGlob (pathString, glob, options = {}) {
|
|
|
150
150
|
}
|
|
151
151
|
return path.posix.join(safeStr, glob)
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* 字节跳动小程序可以配置 ext:// 开头的插件页面模板,如 ext://microapp-trade-plugin/order-confirm
|
|
155
|
+
* @param pagePath
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
function isNormalPage (pagePath) {
|
|
159
|
+
return !pagePath.startsWith('ext://')
|
|
160
|
+
}
|
|
153
161
|
|
|
154
162
|
module.exports = {
|
|
163
|
+
isNormalPage,
|
|
155
164
|
isInHBuilderX,
|
|
156
165
|
isInHBuilderXAlpha,
|
|
157
166
|
getCLIContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-36720221017001",
|
|
4
4
|
"description": "uni-cli-shared",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"postcss-urlrewrite": "^0.2.2",
|
|
26
26
|
"strip-json-comments": "^2.0.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "7d7030aaaffab530253dc4cf02f87a13023c0d1f"
|
|
29
29
|
}
|