@dcloudio/uni-cli-shared 3.0.0-3061820230117001 → 3.0.0-3070320230222002
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/easycom.d.ts +1 -1
- package/dist/easycom.js +26 -10
- package/dist/hbx/env.js +5 -0
- package/dist/hbx/log.js +1 -2
- package/dist/json/app/manifest/arguments.js +1 -2
- package/dist/json/app/manifest/confusion.js +2 -4
- package/dist/json/app/manifest/env.js +2 -4
- package/dist/json/app/manifest/launchwebview.js +1 -1
- package/dist/json/app/manifest/nvue.js +1 -2
- package/dist/json/app/manifest/plus.js +2 -4
- package/dist/json/app/manifest/safearea.js +1 -2
- package/dist/json/app/manifest/splashscreen.js +1 -2
- package/dist/json/app/manifest/tabBar.js +1 -2
- package/dist/json/app/pages/uniConfig.js +2 -4
- package/dist/json/manifest.js +12 -16
- package/dist/json/mp/jsonFile.js +4 -3
- package/dist/json/mp/pages.js +1 -1
- package/dist/json/pages.js +2 -3
- package/dist/logs/format.js +1 -1
- package/dist/mp/ast.d.ts +2 -1
- package/dist/mp/template.d.ts +2 -2
- package/dist/postcss/plugins/uniapp.js +1 -2
- package/dist/scripts.js +2 -3
- package/dist/uni_modules.js +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +7 -7
- package/dist/uts.d.ts +4 -2
- package/dist/uts.js +73 -10
- package/dist/vite/plugins/vitejs/plugins/asset.js +5 -6
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +44 -21
- package/dist/vite/plugins/vitejs/utils.js +1 -1
- package/package.json +16 -16
package/dist/easycom.d.ts
CHANGED
package/dist/easycom.js
CHANGED
|
@@ -13,6 +13,7 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const pages_1 = require("./json/pages");
|
|
15
15
|
const messages_1 = require("./messages");
|
|
16
|
+
const uts_1 = require("./uts");
|
|
16
17
|
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
17
18
|
const easycoms = [];
|
|
18
19
|
const easycomsCache = new Map();
|
|
@@ -45,18 +46,33 @@ function initEasycoms(inputDir, { dirs, platform }) {
|
|
|
45
46
|
return easycomOptions;
|
|
46
47
|
};
|
|
47
48
|
const options = initEasycomOptions((0, pages_1.parsePagesJsonOnce)(inputDir, platform));
|
|
49
|
+
const initUTSEasycom = () => {
|
|
50
|
+
(0, uts_1.initUTSComponents)(inputDir, platform).forEach((item) => {
|
|
51
|
+
const index = easycoms.findIndex((easycom) => item.pattern.toString() === easycom.pattern.toString());
|
|
52
|
+
if (index > -1) {
|
|
53
|
+
easycoms.splice(index, 1, item);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
easycoms.push(item);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
};
|
|
48
60
|
initEasycom(options);
|
|
61
|
+
initUTSEasycom();
|
|
49
62
|
const res = {
|
|
50
63
|
options,
|
|
51
64
|
filter: (0, pluginutils_1.createFilter)([
|
|
52
65
|
'components/*/*.(vue|jsx|tsx)',
|
|
53
66
|
'uni_modules/*/components/*/*.(vue|jsx|tsx)',
|
|
67
|
+
'utssdk/*/**/*.vue',
|
|
68
|
+
'uni_modules/*/utssdk/*/*.vue',
|
|
54
69
|
], [], {
|
|
55
70
|
resolve: inputDir,
|
|
56
71
|
}),
|
|
57
72
|
refresh() {
|
|
58
73
|
res.options = initEasycomOptions();
|
|
59
74
|
initEasycom(res.options);
|
|
75
|
+
initUTSEasycom();
|
|
60
76
|
},
|
|
61
77
|
easycoms,
|
|
62
78
|
};
|
|
@@ -157,28 +173,28 @@ function initAutoScanEasycoms(dirs, rootDir, extensions) {
|
|
|
157
173
|
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions);
|
|
158
174
|
Object.keys(curEasycoms).forEach((name) => {
|
|
159
175
|
// Use the first component when name conflict
|
|
160
|
-
const
|
|
161
|
-
if (!
|
|
176
|
+
const componentPath = easycoms[name];
|
|
177
|
+
if (!componentPath) {
|
|
162
178
|
easycoms[name] = curEasycoms[name];
|
|
163
179
|
}
|
|
164
180
|
else {
|
|
165
181
|
;
|
|
166
|
-
(conflict[
|
|
182
|
+
(conflict[componentPath] || (conflict[componentPath] = [])).push(normalizeComponentPath(curEasycoms[name], rootDir));
|
|
167
183
|
}
|
|
168
184
|
});
|
|
169
185
|
return easycoms;
|
|
170
186
|
}, Object.create(null));
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
187
|
+
const conflictComponents = Object.keys(conflict);
|
|
188
|
+
if (conflictComponents.length) {
|
|
173
189
|
console.warn(messages_1.M['easycom.conflict']);
|
|
174
|
-
|
|
175
|
-
console.warn([
|
|
190
|
+
conflictComponents.forEach((com) => {
|
|
191
|
+
console.warn([normalizeComponentPath(com, rootDir), conflict[com]].join(','));
|
|
176
192
|
});
|
|
177
193
|
}
|
|
178
194
|
return res;
|
|
179
195
|
}
|
|
180
|
-
function
|
|
181
|
-
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir,
|
|
196
|
+
function normalizeComponentPath(componentPath, rootDir) {
|
|
197
|
+
return (0, utils_1.normalizePath)(path_1.default.relative(rootDir, componentPath));
|
|
182
198
|
}
|
|
183
199
|
function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
184
200
|
importDeclarations.push(createImportDeclaration(local, source, imported));
|
|
@@ -187,7 +203,7 @@ function addImportDeclaration(importDeclarations, local, source, imported) {
|
|
|
187
203
|
exports.addImportDeclaration = addImportDeclaration;
|
|
188
204
|
function createImportDeclaration(local, source, imported) {
|
|
189
205
|
if (imported) {
|
|
190
|
-
return `import {${imported} as ${local}} from '${source}';`;
|
|
206
|
+
return `import { ${imported} as ${local} } from '${source}';`;
|
|
191
207
|
}
|
|
192
208
|
return `import ${local} from '${source}';`;
|
|
193
209
|
}
|
package/dist/hbx/env.js
CHANGED
|
@@ -10,6 +10,11 @@ const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
|
10
10
|
const resolve_1 = require("../resolve");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
exports.isInHBuilderX = (0, uni_shared_1.once)(() => {
|
|
13
|
+
// 自动化测试传入了 HX_APP_ROOT(其实就是UNI_HBUILDERX_PLUGINS)
|
|
14
|
+
if (process.env.HX_APP_ROOT) {
|
|
15
|
+
process.env.UNI_HBUILDERX_PLUGINS = process.env.HX_APP_ROOT + '/plugins';
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
13
18
|
try {
|
|
14
19
|
const { name } = require(path_1.default.resolve(process.cwd(), '../about/package.json'));
|
|
15
20
|
if (name === 'about') {
|
package/dist/hbx/log.js
CHANGED
|
@@ -107,7 +107,6 @@ exports.errorFormatter = {
|
|
|
107
107
|
},
|
|
108
108
|
};
|
|
109
109
|
function buildErrorMessage(err, args = [], includeStack = true) {
|
|
110
|
-
var _a, _b;
|
|
111
110
|
if (err.plugin) {
|
|
112
111
|
args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
|
|
113
112
|
if (err.loc &&
|
|
@@ -132,7 +131,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
|
|
|
132
131
|
args.push(picocolors_1.default.red(err.message));
|
|
133
132
|
}
|
|
134
133
|
if (err.id) {
|
|
135
|
-
args.push(formatAtFilename(err.id,
|
|
134
|
+
args.push(formatAtFilename(err.id, err.loc?.line, err.loc?.column));
|
|
136
135
|
}
|
|
137
136
|
if (err.frame) {
|
|
138
137
|
args.push(picocolors_1.default.yellow(pad(err.frame)));
|
|
@@ -9,7 +9,6 @@ function initArguments(manifestJson, pagesJson) {
|
|
|
9
9
|
}
|
|
10
10
|
exports.initArguments = initArguments;
|
|
11
11
|
function parseArguments(pagesJson) {
|
|
12
|
-
var _a;
|
|
13
12
|
if (process.env.NODE_ENV !== 'development') {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
@@ -21,7 +20,7 @@ function parseArguments(pagesJson) {
|
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
const condition = pagesJson.condition;
|
|
24
|
-
if (condition &&
|
|
23
|
+
if (condition && condition.list?.length) {
|
|
25
24
|
const list = condition.list;
|
|
26
25
|
let current = condition.current || 0;
|
|
27
26
|
if (current < 0) {
|
|
@@ -23,10 +23,9 @@ function isConfusionFile(filename) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.isConfusionFile = isConfusionFile;
|
|
25
25
|
function hasConfusionFile(inputDir) {
|
|
26
|
-
var _a, _b;
|
|
27
26
|
if (inputDir) {
|
|
28
27
|
const manifestJson = (0, manifest_1.parseManifestJsonOnce)(inputDir);
|
|
29
|
-
const resources =
|
|
28
|
+
const resources = manifestJson['app-plus']?.confusion?.resources;
|
|
30
29
|
if (resources && parseConfusion(resources)[1].length) {
|
|
31
30
|
return true;
|
|
32
31
|
}
|
|
@@ -64,9 +63,8 @@ function parseConfusion(resources) {
|
|
|
64
63
|
return [res, dynamicJsFiles];
|
|
65
64
|
}
|
|
66
65
|
function initConfusion(manifestJson) {
|
|
67
|
-
var _a;
|
|
68
66
|
dynamicConfusionJsFiles.length = 0;
|
|
69
|
-
if (!
|
|
67
|
+
if (!manifestJson.plus.confusion?.resources) {
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
72
70
|
const resources = manifestJson.plus.confusion.resources;
|
|
@@ -10,15 +10,13 @@ function getAppRenderer(manifestJson) {
|
|
|
10
10
|
}
|
|
11
11
|
exports.getAppRenderer = getAppRenderer;
|
|
12
12
|
function getAppCodeSpliting(manifestJson) {
|
|
13
|
-
|
|
14
|
-
if (((_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.codeSpliting) === true) {
|
|
13
|
+
if (manifestJson['app-plus']?.optimization?.codeSpliting === true) {
|
|
15
14
|
return true;
|
|
16
15
|
}
|
|
17
16
|
return false;
|
|
18
17
|
}
|
|
19
18
|
exports.getAppCodeSpliting = getAppCodeSpliting;
|
|
20
19
|
function getAppStyleIsolation(manifestJson) {
|
|
21
|
-
|
|
22
|
-
return ((_c = (_b = (_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.styleIsolation) !== null && _c !== void 0 ? _c : 'apply-shared');
|
|
20
|
+
return (manifestJson['app-plus']?.optimization?.styleIsolation ?? 'apply-shared');
|
|
23
21
|
}
|
|
24
22
|
exports.getAppStyleIsolation = getAppStyleIsolation;
|
|
@@ -21,7 +21,7 @@ function initLaunchwebview(manifestJson, pagesJson) {
|
|
|
21
21
|
});
|
|
22
22
|
// 首页为nvue
|
|
23
23
|
const entryPage = pagesJson.pages.find((p) => p.path === entryPagePath);
|
|
24
|
-
if (entryPage
|
|
24
|
+
if (entryPage?.style.isNVue) {
|
|
25
25
|
manifestJson.plus.launchwebview.uniNView = { path: entryPagePath + '.js' };
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
@@ -30,9 +30,8 @@ function getNVueStyleCompiler(manifestJson) {
|
|
|
30
30
|
exports.getNVueStyleCompiler = getNVueStyleCompiler;
|
|
31
31
|
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
32
32
|
function getNVueFlexDirection(manifestJson) {
|
|
33
|
-
var _a, _b;
|
|
34
33
|
let flexDir = 'column';
|
|
35
|
-
if (
|
|
34
|
+
if (manifestJson['app-plus']?.nvue?.['flex-direction']) {
|
|
36
35
|
flexDir = manifestJson['app-plus'].nvue['flex-direction'];
|
|
37
36
|
if (flexDirs.indexOf(flexDir) === -1) {
|
|
38
37
|
flexDir = 'column';
|
|
@@ -14,7 +14,6 @@ const wxPageOrientationMapping = {
|
|
|
14
14
|
landscape: ['landscape-primary', 'landscape-secondary'],
|
|
15
15
|
};
|
|
16
16
|
function initPlus(manifestJson, pagesJson) {
|
|
17
|
-
var _a;
|
|
18
17
|
initUniStatistics(manifestJson);
|
|
19
18
|
// 转换为老版本配置
|
|
20
19
|
if (manifestJson.plus.modules) {
|
|
@@ -50,7 +49,7 @@ function initPlus(manifestJson, pagesJson) {
|
|
|
50
49
|
manifestJson.screenOrientation = manifestJson.plus.screenOrientation;
|
|
51
50
|
delete manifestJson.plus.screenOrientation;
|
|
52
51
|
}
|
|
53
|
-
else if (
|
|
52
|
+
else if (pagesJson.globalStyle?.pageOrientation) {
|
|
54
53
|
// 兼容微信小程序
|
|
55
54
|
const pageOrientationValue = wxPageOrientationMapping[pagesJson.globalStyle
|
|
56
55
|
.pageOrientation];
|
|
@@ -93,7 +92,6 @@ function initPlus(manifestJson, pagesJson) {
|
|
|
93
92
|
}
|
|
94
93
|
exports.initPlus = initPlus;
|
|
95
94
|
function initUniStatistics(manifestJson) {
|
|
96
|
-
var _a;
|
|
97
95
|
// 根节点配置了统计
|
|
98
96
|
if (manifestJson.uniStatistics) {
|
|
99
97
|
manifestJson.plus.uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson.plus.uniStatistics);
|
|
@@ -114,7 +112,7 @@ function initUniStatistics(manifestJson) {
|
|
|
114
112
|
if (!space) {
|
|
115
113
|
return;
|
|
116
114
|
}
|
|
117
|
-
const uniStatistics =
|
|
115
|
+
const uniStatistics = manifestJson.plus?.uniStatistics;
|
|
118
116
|
if (!uniStatistics) {
|
|
119
117
|
return;
|
|
120
118
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initSafearea = void 0;
|
|
4
4
|
function initSafearea(manifestJson, pagesJson) {
|
|
5
|
-
|
|
6
|
-
if ((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length) {
|
|
5
|
+
if (pagesJson.tabBar?.list?.length) {
|
|
7
6
|
// 安全区配置 仅包含 tabBar 的时候才配置
|
|
8
7
|
if (!manifestJson.plus.safearea) {
|
|
9
8
|
manifestJson.plus.safearea = {
|
|
@@ -34,8 +34,7 @@ function initSplashscreen(manifestJson, userManifestJson) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.initSplashscreen = initSplashscreen;
|
|
36
36
|
function getSplashscreen(manifestJson) {
|
|
37
|
-
|
|
38
|
-
const splashscreenOptions = ((_a = manifestJson['app-plus']) === null || _a === void 0 ? void 0 : _a.splashscreen) || {};
|
|
37
|
+
const splashscreenOptions = manifestJson['app-plus']?.splashscreen || {};
|
|
39
38
|
return {
|
|
40
39
|
autoclose: splashscreenOptions.autoclose !== false,
|
|
41
40
|
alwaysShowBeforeRender: splashscreenOptions.alwaysShowBeforeRender !== false,
|
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initTabBar = void 0;
|
|
4
4
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
5
5
|
function initTabBar(entryPagePath, manifestJson, pagesJson) {
|
|
6
|
-
|
|
7
|
-
if (!((_b = (_a = pagesJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
6
|
+
if (!pagesJson.tabBar?.list?.length) {
|
|
8
7
|
return;
|
|
9
8
|
}
|
|
10
9
|
const tabBar = JSON.parse(JSON.stringify(pagesJson.tabBar));
|
|
@@ -12,7 +12,6 @@ const arguments_1 = require("../manifest/arguments");
|
|
|
12
12
|
const splashscreen_1 = require("../manifest/splashscreen");
|
|
13
13
|
const theme_1 = require("../../theme");
|
|
14
14
|
function normalizeAppUniConfig(pagesJson, manifestJson) {
|
|
15
|
-
var _a;
|
|
16
15
|
const { autoclose, alwaysShowBeforeRender } = (0, splashscreen_1.getSplashscreen)(manifestJson);
|
|
17
16
|
const platformConfig = (0, manifest_1.getPlatformManifestJsonOnce)();
|
|
18
17
|
const config = {
|
|
@@ -23,7 +22,7 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
|
|
|
23
22
|
styleCompiler: (0, manifest_2.getNVueStyleCompiler)(manifestJson),
|
|
24
23
|
'flex-direction': (0, manifest_2.getNVueFlexDirection)(manifestJson),
|
|
25
24
|
},
|
|
26
|
-
renderer:
|
|
25
|
+
renderer: manifestJson['app-plus']?.renderer === 'native' ? 'native' : 'auto',
|
|
27
26
|
appname: manifestJson.name || '',
|
|
28
27
|
splashscreen: {
|
|
29
28
|
alwaysShowBeforeRender,
|
|
@@ -42,7 +41,6 @@ function normalizeAppUniConfig(pagesJson, manifestJson) {
|
|
|
42
41
|
}
|
|
43
42
|
exports.normalizeAppUniConfig = normalizeAppUniConfig;
|
|
44
43
|
function parseEntryPagePath(pagesJson) {
|
|
45
|
-
var _a;
|
|
46
44
|
const res = {
|
|
47
45
|
entryPagePath: '',
|
|
48
46
|
entryPageQuery: '',
|
|
@@ -62,7 +60,7 @@ function parseEntryPagePath(pagesJson) {
|
|
|
62
60
|
res.entryPagePath = entryPagePath;
|
|
63
61
|
res.entryPageQuery = args.query ? '?' + args.query : '';
|
|
64
62
|
// non tabBar page
|
|
65
|
-
if (!(
|
|
63
|
+
if (!(pagesJson.tabBar?.list || []).find((page) => page.pagePath === entryPagePath)) {
|
|
66
64
|
res.realEntryPagePath = realEntryPagePath;
|
|
67
65
|
}
|
|
68
66
|
}
|
package/dist/json/manifest.js
CHANGED
|
@@ -44,17 +44,19 @@ function normalizeNetworkTimeout(networkTimeout) {
|
|
|
44
44
|
exports.normalizeNetworkTimeout = normalizeNetworkTimeout;
|
|
45
45
|
function getUniStatistics(inputDir, platform) {
|
|
46
46
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
47
|
+
if (platform === 'app') {
|
|
48
|
+
platform = 'app-plus';
|
|
49
|
+
}
|
|
47
50
|
return (0, shared_1.extend)({}, manifest.uniStatistics, manifest[platform] && manifest[platform].uniStatistics);
|
|
48
51
|
}
|
|
49
52
|
exports.getUniStatistics = getUniStatistics;
|
|
50
53
|
function isEnableUniPushV1(inputDir, platform) {
|
|
51
|
-
var _a, _b, _c;
|
|
52
54
|
if (isEnableUniPushV2(inputDir, platform)) {
|
|
53
55
|
return false;
|
|
54
56
|
}
|
|
55
57
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
56
58
|
if (platform === 'app') {
|
|
57
|
-
const push =
|
|
59
|
+
const push = manifest['app-plus']?.distribute?.sdkConfigs?.push;
|
|
58
60
|
if (push && (0, shared_1.hasOwn)(push, 'unipush')) {
|
|
59
61
|
return true;
|
|
60
62
|
}
|
|
@@ -63,44 +65,38 @@ function isEnableUniPushV1(inputDir, platform) {
|
|
|
63
65
|
}
|
|
64
66
|
exports.isEnableUniPushV1 = isEnableUniPushV1;
|
|
65
67
|
function isEnableUniPushV2(inputDir, platform) {
|
|
66
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
67
68
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
68
69
|
if (platform === 'app') {
|
|
69
|
-
return (
|
|
70
|
+
return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.version ==
|
|
70
71
|
'2');
|
|
71
72
|
}
|
|
72
|
-
return
|
|
73
|
+
return manifest[platform]?.unipush?.enable === true;
|
|
73
74
|
}
|
|
74
75
|
exports.isEnableUniPushV2 = isEnableUniPushV2;
|
|
75
76
|
function isEnableSecureNetwork(inputDir, platform) {
|
|
76
|
-
var _a, _b, _c, _d;
|
|
77
77
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
78
78
|
if (platform === 'app') {
|
|
79
|
-
return !!
|
|
79
|
+
return !!manifest['app-plus']?.modules?.SecureNetwork;
|
|
80
80
|
}
|
|
81
|
-
return
|
|
81
|
+
return manifest[platform]?.secureNetwork?.enable === true;
|
|
82
82
|
}
|
|
83
83
|
exports.isEnableSecureNetwork = isEnableSecureNetwork;
|
|
84
84
|
function isUniPushOffline(inputDir) {
|
|
85
|
-
var _a, _b, _c, _d, _e;
|
|
86
85
|
const manifest = (0, exports.parseManifestJsonOnce)(inputDir);
|
|
87
|
-
return (
|
|
86
|
+
return (manifest['app-plus']?.distribute?.sdkConfigs?.push?.unipush?.offline ===
|
|
88
87
|
true);
|
|
89
88
|
}
|
|
90
89
|
exports.isUniPushOffline = isUniPushOffline;
|
|
91
90
|
function getRouterOptions(manifestJson) {
|
|
92
|
-
|
|
93
|
-
return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.router);
|
|
91
|
+
return (0, shared_1.extend)({}, manifestJson.h5?.router);
|
|
94
92
|
}
|
|
95
93
|
exports.getRouterOptions = getRouterOptions;
|
|
96
94
|
function isEnableTreeShaking(manifestJson) {
|
|
97
|
-
|
|
98
|
-
return ((_c = (_b = (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.optimization) === null || _b === void 0 ? void 0 : _b.treeShaking) === null || _c === void 0 ? void 0 : _c.enable) !== false;
|
|
95
|
+
return manifestJson.h5?.optimization?.treeShaking?.enable !== false;
|
|
99
96
|
}
|
|
100
97
|
exports.isEnableTreeShaking = isEnableTreeShaking;
|
|
101
98
|
function getDevServerOptions(manifestJson) {
|
|
102
|
-
|
|
103
|
-
return (0, shared_1.extend)({}, (_a = manifestJson.h5) === null || _a === void 0 ? void 0 : _a.devServer);
|
|
99
|
+
return (0, shared_1.extend)({}, manifestJson.h5?.devServer);
|
|
104
100
|
}
|
|
105
101
|
exports.getDevServerOptions = getDevServerOptions;
|
|
106
102
|
function getPlatformManifestJsonOnce() {
|
package/dist/json/mp/jsonFile.js
CHANGED
|
@@ -53,7 +53,6 @@ exports.normalizeJsonFilename = normalizeJsonFilename;
|
|
|
53
53
|
function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
54
54
|
const changedJsonFiles = new Map();
|
|
55
55
|
function findChangedFile(filename, json) {
|
|
56
|
-
var _a;
|
|
57
56
|
const newJson = JSON.parse(JSON.stringify(json));
|
|
58
57
|
if (!newJson.usingComponents) {
|
|
59
58
|
newJson.usingComponents = {};
|
|
@@ -63,12 +62,14 @@ function findChangedJsonFiles(supportGlobalUsingComponents = true) {
|
|
|
63
62
|
// app.json mp-baidu 在 win 不支持相对路径。所有平台改用绝对路径
|
|
64
63
|
if (filename !== 'app') {
|
|
65
64
|
let usingComponents = newJson.usingComponents;
|
|
66
|
-
const globalUsingComponents = (_a = appJsonCache === null || appJsonCache === void 0 ? void 0 : appJsonCache.usingComponents) !== null && _a !== void 0 ? _a : {};
|
|
67
65
|
// 如果小程序不支持 global 的 usingComponents
|
|
68
66
|
if (!supportGlobalUsingComponents) {
|
|
69
|
-
//
|
|
67
|
+
// 从取全局的 usingComponents 并补充到子组件 usingComponents 中
|
|
68
|
+
const globalUsingComponents = appJsonCache?.usingComponents || {};
|
|
69
|
+
const globalComponents = findUsingComponents('app') || {};
|
|
70
70
|
usingComponents = {
|
|
71
71
|
...globalUsingComponents,
|
|
72
|
+
...globalComponents,
|
|
72
73
|
...newJson.usingComponents,
|
|
73
74
|
};
|
|
74
75
|
}
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -115,7 +115,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
;
|
|
118
|
-
['preloadRule', 'workers', 'plugins'].forEach((name) => {
|
|
118
|
+
['preloadRule', 'workers', 'plugins', 'entryPagePath'].forEach((name) => {
|
|
119
119
|
if ((0, shared_1.hasOwn)(pagesJson, name)) {
|
|
120
120
|
appJson[name] = pagesJson[name];
|
|
121
121
|
}
|
package/dist/json/pages.js
CHANGED
|
@@ -305,7 +305,7 @@ function normalizeNavigationBar(pageStyle) {
|
|
|
305
305
|
return navigationBar;
|
|
306
306
|
}
|
|
307
307
|
function normalizeNavigationBarButton(btn, type, titleColor) {
|
|
308
|
-
btn.color =
|
|
308
|
+
btn.color = btn.color || titleColor;
|
|
309
309
|
if (!btn.fontSize) {
|
|
310
310
|
btn.fontSize =
|
|
311
311
|
type === 'transparent' || (btn.text && /\\u/.test(btn.text))
|
|
@@ -408,8 +408,7 @@ function normalizePagesRoute(pagesJson) {
|
|
|
408
408
|
}
|
|
409
409
|
exports.normalizePagesRoute = normalizePagesRoute;
|
|
410
410
|
function isEnablePullDownRefresh(pageStyle) {
|
|
411
|
-
|
|
412
|
-
return pageStyle.enablePullDownRefresh || ((_a = pageStyle.pullToRefresh) === null || _a === void 0 ? void 0 : _a.support);
|
|
411
|
+
return pageStyle.enablePullDownRefresh || pageStyle.pullToRefresh?.support;
|
|
413
412
|
}
|
|
414
413
|
function normalizePullToRefresh(pageStyle) {
|
|
415
414
|
return pageStyle.pullToRefresh;
|
package/dist/logs/format.js
CHANGED
|
@@ -65,7 +65,7 @@ function formatInfoMsg(msg, options) {
|
|
|
65
65
|
if (formatter) {
|
|
66
66
|
return formatter.format(msg, options);
|
|
67
67
|
}
|
|
68
|
-
if (options
|
|
68
|
+
if (options?.nvue) {
|
|
69
69
|
initNVueInfoFormattersOnce();
|
|
70
70
|
const formatter = nvueInfoFormatters.find(({ test }) => test(msg, options));
|
|
71
71
|
if (formatter) {
|
package/dist/mp/ast.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { Program } from '@babel/types';
|
|
1
2
|
import { ParserPlugin } from '@babel/parser';
|
|
2
3
|
export declare function parseProgram(code: string, importer: string, { babelParserPlugins }: {
|
|
3
4
|
babelParserPlugins?: ParserPlugin[];
|
|
4
|
-
}):
|
|
5
|
+
}): Program;
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type LazyElementFn = (node: ElementNode, context: {
|
|
|
6
6
|
[name: string]: {
|
|
7
7
|
name: 'on' | 'bind';
|
|
8
8
|
arg: string[];
|
|
9
|
-
}[];
|
|
9
|
+
}[] | true;
|
|
10
10
|
} | boolean;
|
|
11
11
|
export interface MiniProgramCompilerOptions {
|
|
12
12
|
/**
|
|
@@ -16,7 +16,7 @@ export interface MiniProgramCompilerOptions {
|
|
|
16
16
|
[name: string]: {
|
|
17
17
|
name: 'on' | 'bind';
|
|
18
18
|
arg: string[];
|
|
19
|
-
}[];
|
|
19
|
+
}[] | true;
|
|
20
20
|
} | LazyElementFn;
|
|
21
21
|
event?: {
|
|
22
22
|
key?: boolean;
|
|
@@ -57,9 +57,8 @@ function walkDecls(rpx2unit) {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
function filterPrefersColorScheme(root) {
|
|
60
|
-
var _a;
|
|
61
60
|
if (process.env.VUE_APP_DARK_MODE !== 'true') {
|
|
62
|
-
const filePath =
|
|
61
|
+
const filePath = root.source?.input.file;
|
|
63
62
|
if (filePath && filePath.includes('@dcloudio')) {
|
|
64
63
|
root.walkAtRules((rule) => {
|
|
65
64
|
if (rule.params.includes('prefers-color-scheme')) {
|
package/dist/scripts.js
CHANGED
|
@@ -7,17 +7,16 @@ exports.parseScripts = void 0;
|
|
|
7
7
|
const shared_1 = require("@vue/shared");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
function parseScripts(name, pkgPath) {
|
|
10
|
-
var _a, _b;
|
|
11
10
|
if (!fs_1.default.existsSync(pkgPath)) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
13
|
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
15
|
-
const scripts =
|
|
14
|
+
const scripts = pkg['uni-app']?.scripts || {};
|
|
16
15
|
const options = scripts[name];
|
|
17
16
|
if (!options) {
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
|
-
if (!
|
|
19
|
+
if (!options.env?.UNI_PLATFORM) {
|
|
21
20
|
console.error(`package.json->uni-app->scripts->${name}->env->UNI_PLATFORM is required`);
|
|
22
21
|
process.exit(0);
|
|
23
22
|
}
|
package/dist/uni_modules.js
CHANGED
|
@@ -14,7 +14,6 @@ function parseUniExtApis(vite = true) {
|
|
|
14
14
|
}
|
|
15
15
|
const injects = {};
|
|
16
16
|
fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
|
|
17
|
-
var _a, _b;
|
|
18
17
|
// 必须以 uni- 开头
|
|
19
18
|
if (!uniModuleDir.startsWith('uni-')) {
|
|
20
19
|
return;
|
|
@@ -24,7 +23,8 @@ function parseUniExtApis(vite = true) {
|
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
try {
|
|
27
|
-
const exports =
|
|
26
|
+
const exports = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))
|
|
27
|
+
?.uni_modules?.['uni-ext-api'];
|
|
28
28
|
if (exports) {
|
|
29
29
|
Object.assign(injects, parseInjects(vite, process.env.UNI_PLATFORM === 'h5'
|
|
30
30
|
? 'web'
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function normalizePagePath(pagePath: string, platform: UniApp.PLA
|
|
|
11
11
|
export declare function removeExt(str: string): string;
|
|
12
12
|
export declare function normalizeNodeModules(str: string): string;
|
|
13
13
|
export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
|
|
14
|
-
export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]):
|
|
14
|
+
export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "jsx" | "logicalAssignment" | "importAssertions" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "pipelineOperator" | "recordAndTuple" | "typescript"))[];
|
|
15
15
|
export declare function pathToGlob(pathString: string, glob: string, options?: {
|
|
16
16
|
windows?: boolean;
|
|
17
17
|
escape?: boolean;
|
package/dist/utils.js
CHANGED
|
@@ -17,7 +17,7 @@ exports.version = require('../package.json').version;
|
|
|
17
17
|
try {
|
|
18
18
|
exports.isRunningWithYarnPnp = Boolean(require('pnpapi'));
|
|
19
19
|
}
|
|
20
|
-
catch
|
|
20
|
+
catch { }
|
|
21
21
|
exports.isWindows = os_1.default.platform() === 'win32';
|
|
22
22
|
function normalizePath(id) {
|
|
23
23
|
return exports.isWindows ? id.replace(/\\/g, '/') : id;
|
|
@@ -32,14 +32,14 @@ function normalizeIdentifier(str) {
|
|
|
32
32
|
}
|
|
33
33
|
exports.normalizeIdentifier = normalizeIdentifier;
|
|
34
34
|
function normalizePagePath(pagePath, platform) {
|
|
35
|
-
const
|
|
36
|
-
let
|
|
35
|
+
const absolutePagePath = path_1.default.resolve(process.env.UNI_INPUT_DIR, pagePath);
|
|
36
|
+
let extensions = constants_1.PAGE_EXTNAME;
|
|
37
37
|
if (platform === 'app') {
|
|
38
|
-
|
|
38
|
+
extensions = constants_1.PAGE_EXTNAME_APP;
|
|
39
39
|
}
|
|
40
|
-
for (let i = 0; i <
|
|
41
|
-
const extname =
|
|
42
|
-
if (fs_1.default.existsSync(
|
|
40
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
41
|
+
const extname = extensions[i];
|
|
42
|
+
if (fs_1.default.existsSync(absolutePagePath + extname)) {
|
|
43
43
|
return pagePath + extname;
|
|
44
44
|
}
|
|
45
45
|
}
|
package/dist/uts.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as UTSCompiler from '@dcloudio/uni-uts-v1';
|
|
2
|
+
import type { EasycomMatcher } from './easycom';
|
|
2
3
|
/**
|
|
3
4
|
* 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
|
|
4
5
|
* @param id
|
|
5
6
|
* @param importer
|
|
6
7
|
* @returns
|
|
7
8
|
*/
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function resolveUTSAppModule(id: string, importer: string): string | undefined;
|
|
10
|
+
export declare function resolveUTSModule(id: string, importer: string): string | undefined;
|
|
10
11
|
export declare function resolveUTSCompiler(): typeof UTSCompiler;
|
|
12
|
+
export declare function initUTSComponents(inputDir: string, platform: UniApp.PLATFORM): EasycomMatcher[];
|
package/dist/uts.js
CHANGED
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resolveUTSCompiler = exports.
|
|
6
|
+
exports.initUTSComponents = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
9
10
|
const hbx_1 = require("./hbx");
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
12
|
/**
|
|
@@ -14,7 +15,7 @@ const utils_1 = require("./utils");
|
|
|
14
15
|
* @param importer
|
|
15
16
|
* @returns
|
|
16
17
|
*/
|
|
17
|
-
function
|
|
18
|
+
function resolveUTSAppModule(id, importer) {
|
|
18
19
|
id = path_1.default.resolve(importer, id);
|
|
19
20
|
if (id.includes('utssdk') || id.includes('uni_modules')) {
|
|
20
21
|
const parts = (0, utils_1.normalizePath)(id).split('/');
|
|
@@ -28,21 +29,21 @@ function resolveUtsAppModule(id, importer) {
|
|
|
28
29
|
return path_1.default.resolve(id, basedir, p);
|
|
29
30
|
};
|
|
30
31
|
const extname = ['.uts'];
|
|
31
|
-
if (
|
|
32
|
+
if (resolveUTSFile(resolvePlatformDir('app-android'), extname)) {
|
|
32
33
|
return id;
|
|
33
34
|
}
|
|
34
|
-
if (
|
|
35
|
+
if (resolveUTSFile(resolvePlatformDir('app-ios'), extname)) {
|
|
35
36
|
return id;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
exports.
|
|
41
|
+
exports.resolveUTSAppModule = resolveUTSAppModule;
|
|
41
42
|
// 仅限 root/uni_modules/test-plugin | root/utssdk/test-plugin 格式
|
|
42
|
-
function
|
|
43
|
+
function resolveUTSModule(id, importer) {
|
|
43
44
|
if (process.env.UNI_PLATFORM === 'app' ||
|
|
44
45
|
process.env.UNI_PLATFORM === 'app-plus') {
|
|
45
|
-
return
|
|
46
|
+
return resolveUTSAppModule(id, importer);
|
|
46
47
|
}
|
|
47
48
|
id = path_1.default.resolve(importer, id);
|
|
48
49
|
if (id.includes('utssdk') || id.includes('uni_modules')) {
|
|
@@ -53,7 +54,7 @@ function resolveUtsModule(id, importer) {
|
|
|
53
54
|
const resolvePlatformDir = (p) => {
|
|
54
55
|
return path_1.default.resolve(id, basedir, p);
|
|
55
56
|
};
|
|
56
|
-
let index =
|
|
57
|
+
let index = resolveUTSFile(resolvePlatformDir(process.env.UNI_UTS_PLATFORM));
|
|
57
58
|
if (index) {
|
|
58
59
|
return index;
|
|
59
60
|
}
|
|
@@ -64,8 +65,8 @@ function resolveUtsModule(id, importer) {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
|
-
exports.
|
|
68
|
-
function
|
|
68
|
+
exports.resolveUTSModule = resolveUTSModule;
|
|
69
|
+
function resolveUTSFile(dir, extensions = ['.uts', '.ts', '.js']) {
|
|
69
70
|
for (let i = 0; i < extensions.length; i++) {
|
|
70
71
|
const indexFile = path_1.default.join(dir, 'index' + extensions[i]);
|
|
71
72
|
if (fs_1.default.existsSync(indexFile)) {
|
|
@@ -99,3 +100,65 @@ function resolveUTSCompiler() {
|
|
|
99
100
|
return require(compilerPath);
|
|
100
101
|
}
|
|
101
102
|
exports.resolveUTSCompiler = resolveUTSCompiler;
|
|
103
|
+
function initUTSComponents(inputDir, platform) {
|
|
104
|
+
const components = [];
|
|
105
|
+
if (platform !== 'app' && platform !== 'app-plus') {
|
|
106
|
+
return components;
|
|
107
|
+
}
|
|
108
|
+
const easycomsObj = Object.create(null);
|
|
109
|
+
const dirs = resolveUTSComponentDirs(inputDir);
|
|
110
|
+
dirs.forEach((dir) => {
|
|
111
|
+
const is_uni_modules_utssdk = dir.endsWith('utssdk');
|
|
112
|
+
const is_ussdk = !is_uni_modules_utssdk && path_1.default.dirname(dir).endsWith('utssdk');
|
|
113
|
+
if (is_uni_modules_utssdk || is_ussdk) {
|
|
114
|
+
fast_glob_1.default
|
|
115
|
+
.sync('**/*.vue', {
|
|
116
|
+
cwd: dir,
|
|
117
|
+
absolute: true,
|
|
118
|
+
})
|
|
119
|
+
.forEach((file) => {
|
|
120
|
+
let name = parseVueComponentName(file);
|
|
121
|
+
if (!name) {
|
|
122
|
+
if (file.endsWith('index.vue')) {
|
|
123
|
+
name = path_1.default.basename(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (name) {
|
|
127
|
+
const importDir = (0, utils_1.normalizePath)(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
|
|
128
|
+
easycomsObj[`^${name}$`] = `${importDir}?uts-proxy`;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
Object.keys(easycomsObj).forEach((name) => {
|
|
134
|
+
components.push({
|
|
135
|
+
pattern: new RegExp(name),
|
|
136
|
+
replacement: easycomsObj[name],
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return components;
|
|
140
|
+
}
|
|
141
|
+
exports.initUTSComponents = initUTSComponents;
|
|
142
|
+
function resolveUTSComponentDirs(inputDir) {
|
|
143
|
+
const utssdkDir = path_1.default.resolve(inputDir, 'utssdk');
|
|
144
|
+
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
145
|
+
return fast_glob_1.default
|
|
146
|
+
.sync('*', {
|
|
147
|
+
cwd: utssdkDir,
|
|
148
|
+
absolute: true,
|
|
149
|
+
onlyDirectories: true,
|
|
150
|
+
})
|
|
151
|
+
.concat(fast_glob_1.default.sync('*/utssdk', {
|
|
152
|
+
cwd: uniModulesDir,
|
|
153
|
+
absolute: true,
|
|
154
|
+
onlyDirectories: true,
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
const nameRE = /name\s*:\s*['|"](.*)['|"]/;
|
|
158
|
+
function parseVueComponentName(file) {
|
|
159
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
160
|
+
const matches = content.match(nameRE);
|
|
161
|
+
if (matches) {
|
|
162
|
+
return matches[1];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -145,8 +145,7 @@ function fileToUrl(id, config, ctx, canInline = false) {
|
|
|
145
145
|
}
|
|
146
146
|
exports.fileToUrl = fileToUrl;
|
|
147
147
|
function getAssetFilename(hash, config) {
|
|
148
|
-
|
|
149
|
-
return (_a = assetHashToFilenameMap.get(config)) === null || _a === void 0 ? void 0 : _a.get(hash);
|
|
148
|
+
return assetHashToFilenameMap.get(config)?.get(hash);
|
|
150
149
|
}
|
|
151
150
|
exports.getAssetFilename = getAssetFilename;
|
|
152
151
|
/**
|
|
@@ -227,7 +226,6 @@ function sanitizeFileName(name) {
|
|
|
227
226
|
* and returns the resolved public URL
|
|
228
227
|
*/
|
|
229
228
|
function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canInline = false) {
|
|
230
|
-
var _a, _b, _c, _d;
|
|
231
229
|
if (!skipPublicCheck && checkPublicFile(id, config)) {
|
|
232
230
|
return config.base + id.slice(1);
|
|
233
231
|
}
|
|
@@ -248,15 +246,16 @@ function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, canI
|
|
|
248
246
|
const contentHash = getAssetHash(content);
|
|
249
247
|
const { search, hash } = (0, url_1.parse)(id);
|
|
250
248
|
const postfix = (search || '') + (hash || '');
|
|
251
|
-
const output =
|
|
249
|
+
const output = config.build?.rollupOptions?.output;
|
|
252
250
|
const defaultAssetFileNames = path_1.default.posix.join(config.build.assetsDir, '[name].[hash][extname]');
|
|
253
251
|
// Steps to determine which assetFileNames will be actually used.
|
|
254
252
|
// First, if output is an object or string, use assetFileNames in it.
|
|
255
253
|
// And a default assetFileNames as fallback.
|
|
256
|
-
let assetFileNames = (
|
|
254
|
+
let assetFileNames = (output && !Array.isArray(output) ? output.assetFileNames : undefined) ??
|
|
255
|
+
defaultAssetFileNames;
|
|
257
256
|
if (output && Array.isArray(output)) {
|
|
258
257
|
// Second, if output is an array, adopt assetFileNames in the first object.
|
|
259
|
-
assetFileNames =
|
|
258
|
+
assetFileNames = output[0].assetFileNames ?? assetFileNames;
|
|
260
259
|
}
|
|
261
260
|
const inputDir = (0, utils_1.normalizePath)(process.env.UNI_INPUT_DIR);
|
|
262
261
|
let fileName = file.startsWith(inputDir) && file.includes('/static/')
|
|
@@ -34,7 +34,8 @@ export declare function cssPlugin(config: ResolvedConfig): Plugin;
|
|
|
34
34
|
/**
|
|
35
35
|
* Plugin applied after user plugins
|
|
36
36
|
*/
|
|
37
|
-
export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename, chunkCssCode, }: {
|
|
37
|
+
export declare function cssPostPlugin(config: ResolvedConfig, { platform, chunkCssFilename, chunkCssCode, }: {
|
|
38
|
+
platform: UniApp.PLATFORM;
|
|
38
39
|
chunkCssFilename: (id: string) => string | void;
|
|
39
40
|
chunkCssCode: (filename: string, cssCode: string) => Promise<string> | string;
|
|
40
41
|
}): Plugin;
|
|
@@ -37,9 +37,9 @@ const utils_1 = require("../utils");
|
|
|
37
37
|
const asset_1 = require("./asset");
|
|
38
38
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
39
39
|
const preprocess_1 = require("../../../../preprocess");
|
|
40
|
-
const constants_1 = require("../../../../constants");
|
|
41
40
|
const cleanString_1 = require("../cleanString");
|
|
42
41
|
const shared_1 = require("@vue/shared");
|
|
42
|
+
const constants_1 = require("../../../../constants");
|
|
43
43
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
44
44
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
45
45
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
@@ -139,7 +139,7 @@ function findCssModuleIds(moduleId, cssModuleIds, seen) {
|
|
|
139
139
|
/**
|
|
140
140
|
* Plugin applied after user plugins
|
|
141
141
|
*/
|
|
142
|
-
function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
142
|
+
function cssPostPlugin(config, { platform, chunkCssFilename, chunkCssCode, }) {
|
|
143
143
|
// styles initialization in buildStart causes a styling loss in watch
|
|
144
144
|
const styles = new Map();
|
|
145
145
|
let cssChunks;
|
|
@@ -164,14 +164,42 @@ function cssPostPlugin(config, { chunkCssFilename, chunkCssCode, }) {
|
|
|
164
164
|
moduleSideEffects: 'no-treeshake',
|
|
165
165
|
};
|
|
166
166
|
},
|
|
167
|
-
async
|
|
168
|
-
const
|
|
169
|
-
|
|
167
|
+
async renderChunk(_code, chunk, _opts) {
|
|
168
|
+
const id = chunk.facadeModuleId;
|
|
169
|
+
if (id) {
|
|
170
170
|
const filename = chunkCssFilename(id);
|
|
171
171
|
if (filename) {
|
|
172
|
-
|
|
172
|
+
if (platform === 'app' && filename === 'app.css') {
|
|
173
|
+
// 获取 unocss 的样式文件信息
|
|
174
|
+
const ids = Object.keys(chunk.modules).filter((id) => styles.has(id) &&
|
|
175
|
+
(id.includes('__uno.css') || id.includes('-unocss-')));
|
|
176
|
+
cssChunks.set(filename, ids);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
const ids = Object.keys(chunk.modules).filter((id) => styles.has(id));
|
|
180
|
+
cssChunks.set(filename, ids);
|
|
181
|
+
}
|
|
173
182
|
}
|
|
174
|
-
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
},
|
|
186
|
+
async generateBundle() {
|
|
187
|
+
// app 平台页面并未 chunk,所以 renderChunk 并不会处理页面的 css,需要这里再补充查找
|
|
188
|
+
if (platform === 'app') {
|
|
189
|
+
const moduleIds = Array.from(this.getModuleIds());
|
|
190
|
+
moduleIds.forEach((id) => {
|
|
191
|
+
const filename = chunkCssFilename(id);
|
|
192
|
+
if (filename) {
|
|
193
|
+
const ids = findCssModuleIds.call(this, id);
|
|
194
|
+
if (cssChunks.has(filename)) {
|
|
195
|
+
cssChunks.get(filename).forEach((id) => {
|
|
196
|
+
ids.add(id);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
cssChunks.set(filename, [...ids]);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
175
203
|
if (!cssChunks.size) {
|
|
176
204
|
return;
|
|
177
205
|
}
|
|
@@ -254,7 +282,6 @@ function getCssResolversKeys(resolvers) {
|
|
|
254
282
|
return Object.keys(resolvers);
|
|
255
283
|
}
|
|
256
284
|
async function compileCSS(id, code, config, urlReplacer, atImportResolvers, server) {
|
|
257
|
-
var _a;
|
|
258
285
|
const { modules: modulesOptions, preprocessorOptions, devSourcemap, } = config.css || {};
|
|
259
286
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
|
260
287
|
// although at serve time it can work without processing, we do need to
|
|
@@ -262,7 +289,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
262
289
|
const needInlineImport = code.includes('@import');
|
|
263
290
|
const hasUrl = exports.cssUrlRE.test(code) || cssImageSetRE.test(code);
|
|
264
291
|
const postcssConfig = await resolvePostcssConfig(config);
|
|
265
|
-
const lang =
|
|
292
|
+
const lang = id.match(exports.cssLangRE)?.[1];
|
|
266
293
|
// 1. plain css that needs no processing
|
|
267
294
|
if (lang === 'css' &&
|
|
268
295
|
!postcssConfig &&
|
|
@@ -299,7 +326,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
299
326
|
}
|
|
300
327
|
// important: set this for relative import resolving
|
|
301
328
|
opts.filename = (0, utils_1.cleanUrl)(id);
|
|
302
|
-
opts.enableSourcemap = devSourcemap
|
|
329
|
+
opts.enableSourcemap = devSourcemap ?? false;
|
|
303
330
|
const preprocessResult = await preProcessor(code, config.root, opts, atImportResolvers, !!config.nvue);
|
|
304
331
|
if (preprocessResult.errors.length) {
|
|
305
332
|
throw preprocessResult.errors[0];
|
|
@@ -494,13 +521,12 @@ function combineSourcemapsIfExists(filename, map1, map2) {
|
|
|
494
521
|
: map1;
|
|
495
522
|
}
|
|
496
523
|
async function resolvePostcssConfig(config) {
|
|
497
|
-
var _a;
|
|
498
524
|
let result = postcssConfigCache.get(config);
|
|
499
525
|
if (result !== undefined) {
|
|
500
526
|
return result;
|
|
501
527
|
}
|
|
502
528
|
// inline postcss config via vite config
|
|
503
|
-
const inlineOptions =
|
|
529
|
+
const inlineOptions = config.css?.postcss;
|
|
504
530
|
if ((0, utils_1.isObject)(inlineOptions)) {
|
|
505
531
|
const options = { ...inlineOptions };
|
|
506
532
|
delete options.plugins;
|
|
@@ -552,8 +578,7 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
552
578
|
const isCssImageSet = cssImageSetRE.test(declaration.value);
|
|
553
579
|
if (isCssUrl || isCssImageSet) {
|
|
554
580
|
const replacerForDeclaration = (rawUrl) => {
|
|
555
|
-
|
|
556
|
-
const importer = (_a = declaration.source) === null || _a === void 0 ? void 0 : _a.input.file;
|
|
581
|
+
const importer = declaration.source?.input.file;
|
|
557
582
|
return opts.replacer(rawUrl, importer);
|
|
558
583
|
};
|
|
559
584
|
const rewriterToUse = isCssImageSet
|
|
@@ -700,14 +725,13 @@ async function hoistAtRules(css) {
|
|
|
700
725
|
exports.hoistAtRules = hoistAtRules;
|
|
701
726
|
const loadedPreprocessors = {};
|
|
702
727
|
function loadPreprocessor(lang, root) {
|
|
703
|
-
var _a, _b;
|
|
704
728
|
if (lang in loadedPreprocessors) {
|
|
705
729
|
return loadedPreprocessors[lang];
|
|
706
730
|
}
|
|
707
731
|
try {
|
|
708
732
|
// Search for the preprocessor in the root directory first, and fall back
|
|
709
733
|
// to the default require paths.
|
|
710
|
-
const fallbackPaths =
|
|
734
|
+
const fallbackPaths = require.resolve.paths?.(lang) || [];
|
|
711
735
|
const resolved = require.resolve(lang, { paths: [root, ...fallbackPaths] });
|
|
712
736
|
return (loadedPreprocessors[lang] = require(resolved));
|
|
713
737
|
}
|
|
@@ -722,11 +746,11 @@ const scss = async (source, root, options, resolvers, isNVue) => {
|
|
|
722
746
|
resolvers.sass(url, importer).then((resolved) => {
|
|
723
747
|
if (resolved) {
|
|
724
748
|
rebaseUrls(resolved, options.filename, options.alias, isNVue)
|
|
725
|
-
.then((data) => done
|
|
726
|
-
.catch((data) => done
|
|
749
|
+
.then((data) => done?.(data))
|
|
750
|
+
.catch((data) => done?.(data));
|
|
727
751
|
}
|
|
728
752
|
else {
|
|
729
|
-
done
|
|
753
|
+
done?.(null);
|
|
730
754
|
}
|
|
731
755
|
});
|
|
732
756
|
};
|
|
@@ -937,14 +961,13 @@ function createViteLessPlugin(less, rootFile, alias, resolvers, isNVue) {
|
|
|
937
961
|
}
|
|
938
962
|
// .styl
|
|
939
963
|
const styl = async (source, root, options) => {
|
|
940
|
-
var _a;
|
|
941
964
|
const nodeStylus = loadPreprocessor("stylus" /* PreprocessLang.stylus */, root);
|
|
942
965
|
// Get source with preprocessor options.additionalData. Make sure a new line separator
|
|
943
966
|
// is added to avoid any render error, as added stylus content may not have semi-colon separators
|
|
944
967
|
const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
|
|
945
968
|
// Get preprocessor options.imports dependencies as stylus
|
|
946
969
|
// does not return them with its builtin `.deps()` method
|
|
947
|
-
const importsDeps = (
|
|
970
|
+
const importsDeps = (options.imports ?? []).map((dep) => path_1.default.resolve(dep));
|
|
948
971
|
try {
|
|
949
972
|
const ref = nodeStylus(content, options);
|
|
950
973
|
if (options.enableSourcemap) {
|
|
@@ -113,7 +113,7 @@ async function processSrcSet(srcs, replacer) {
|
|
|
113
113
|
const [url] = imageSetUrlRE.exec(src) || [];
|
|
114
114
|
return {
|
|
115
115
|
url: url,
|
|
116
|
-
descriptor: src
|
|
116
|
+
descriptor: src?.slice(url.length).trim(),
|
|
117
117
|
};
|
|
118
118
|
})
|
|
119
119
|
.filter(({ url }) => !!url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-3070320230222002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,33 +22,33 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@ampproject/remapping": "^2.1.2",
|
|
25
|
-
"@babel/core": "^7.
|
|
26
|
-
"@babel/parser": "^7.
|
|
27
|
-
"@babel/types": "^7.20.
|
|
28
|
-
"@dcloudio/uni-i18n": "3.0.0-
|
|
29
|
-
"@dcloudio/uni-shared": "3.0.0-
|
|
25
|
+
"@babel/core": "^7.20.5",
|
|
26
|
+
"@babel/parser": "^7.20.5",
|
|
27
|
+
"@babel/types": "^7.20.7",
|
|
28
|
+
"@dcloudio/uni-i18n": "3.0.0-3070320230222002",
|
|
29
|
+
"@dcloudio/uni-shared": "3.0.0-3070320230222002",
|
|
30
30
|
"@intlify/core-base": "9.1.9",
|
|
31
31
|
"@intlify/shared": "9.1.9",
|
|
32
32
|
"@intlify/vue-devtools": "9.1.9",
|
|
33
33
|
"@rollup/pluginutils": "^4.2.0",
|
|
34
|
-
"@vue/compiler-core": "3.2.
|
|
35
|
-
"@vue/compiler-dom": "3.2.
|
|
36
|
-
"@vue/compiler-sfc": "3.2.
|
|
37
|
-
"@vue/server-renderer": "3.2.
|
|
38
|
-
"@vue/shared": "3.2.
|
|
34
|
+
"@vue/compiler-core": "3.2.47",
|
|
35
|
+
"@vue/compiler-dom": "3.2.47",
|
|
36
|
+
"@vue/compiler-sfc": "3.2.47",
|
|
37
|
+
"@vue/server-renderer": "3.2.47",
|
|
38
|
+
"@vue/shared": "3.2.47",
|
|
39
39
|
"autoprefixer": "^10.4.13",
|
|
40
40
|
"base64url": "^3.0.1",
|
|
41
41
|
"chokidar": "^3.5.3",
|
|
42
42
|
"compare-versions": "^3.6.0",
|
|
43
43
|
"debug": "^4.3.3",
|
|
44
44
|
"es-module-lexer": "^0.9.3",
|
|
45
|
-
"esbuild": "^0.
|
|
45
|
+
"esbuild": "^0.16.14",
|
|
46
46
|
"estree-walker": "^2.0.2",
|
|
47
47
|
"fast-glob": "^3.2.11",
|
|
48
48
|
"fs-extra": "^10.0.0",
|
|
49
49
|
"hash-sum": "^2.0.0",
|
|
50
50
|
"jsonc-parser": "^3.0.0",
|
|
51
|
-
"magic-string": "^0.
|
|
51
|
+
"magic-string": "^0.27.0",
|
|
52
52
|
"merge": "^2.1.1",
|
|
53
53
|
"mime": "^3.0.0",
|
|
54
54
|
"module-alias": "^2.2.2",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@dcloudio/uni-uts-v1": "3.0.0-
|
|
67
|
+
"@dcloudio/uni-uts-v1": "3.0.0-3070320230222002",
|
|
68
68
|
"@types/babel__core": "^7.1.19",
|
|
69
69
|
"@types/debug": "^4.1.7",
|
|
70
70
|
"@types/estree": "^0.0.51",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/resolve": "^1.20.2",
|
|
77
77
|
"@types/sass": "^1.43.1",
|
|
78
78
|
"@types/stylus": "^0.48.36",
|
|
79
|
-
"postcss": "^8.4.
|
|
80
|
-
"vue": "3.2.
|
|
79
|
+
"postcss": "^8.4.21",
|
|
80
|
+
"vue": "3.2.47"
|
|
81
81
|
}
|
|
82
82
|
}
|