@dcloudio/uni-cli-shared 3.0.0-4010420240430002 → 3.0.0-4020320240708001
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.js +35 -3
- package/dist/fs.js +8 -5
- package/dist/hbx/log.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/json/app/manifest/nvue.d.ts +1 -1
- package/dist/json/app/pages/definePage.d.ts +1 -1
- package/dist/json/app/pages/definePage.js +3 -3
- package/dist/json/app/pages/index.d.ts +1 -1
- package/dist/json/app/pages/index.js +2 -2
- package/dist/json/manifest.d.ts +1 -0
- package/dist/json/manifest.js +13 -2
- package/dist/json/pages.js +20 -2
- package/dist/json/theme.d.ts +19 -0
- package/dist/json/theme.js +240 -2
- package/dist/json/uni-x/uniConfig.js +5 -0
- package/dist/messages/en.d.ts +1 -0
- package/dist/messages/en.js +1 -0
- package/dist/messages/index.d.ts +2 -0
- package/dist/messages/zh_CN.d.ts +1 -0
- package/dist/messages/zh_CN.js +1 -0
- package/dist/postcss/plugins/uniapp.js +1 -0
- package/dist/preprocess/context.js +10 -2
- package/dist/resolve.js +6 -1
- package/dist/uni_modules.d.ts +51 -0
- package/dist/uni_modules.js +357 -23
- package/dist/utils.d.ts +14 -1
- package/dist/utils.js +39 -3
- package/dist/uts.d.ts +1 -1
- package/dist/uts.js +10 -3
- package/dist/vite/autoImport.js +16 -2
- package/dist/vite/cloud.d.ts +6 -0
- package/dist/vite/cloud.js +305 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +4 -1
- package/dist/vite/plugins/easycom.js +3 -1
- package/dist/vite/plugins/uts/uni_modules.d.ts +3 -2
- package/dist/vite/plugins/uts/uni_modules.js +76 -14
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +3 -3
- package/dist/vite/plugins/vitejs/plugins/asset.js +11 -9
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +6 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +27 -25
- package/dist/vite/plugins/vitejs/plugins/static.d.ts +2 -0
- package/dist/vite/plugins/vitejs/plugins/static.js +40 -0
- package/dist/vite/utils/index.js +3 -0
- package/dist/vite/utils/plugin.d.ts +5 -2
- package/dist/vite/utils/plugin.js +7 -2
- package/dist/vite/utils/utils.js +3 -0
- package/dist/vue/transforms/transformPageHead.js +7 -3
- package/package.json +7 -4
package/dist/easycom.js
CHANGED
|
@@ -115,8 +115,18 @@ function initEasycom({ isX, dirs, rootDir, custom, extensions, }) {
|
|
|
115
115
|
if (path_1.default.isAbsolute(source) && source.startsWith(rootDir)) {
|
|
116
116
|
source = '@/' + (0, utils_1.normalizePath)(path_1.default.relative(rootDir, source));
|
|
117
117
|
}
|
|
118
|
+
let imported = '';
|
|
119
|
+
// 加密插件easycom类型导入
|
|
120
|
+
if (source.includes('?uts-proxy')) {
|
|
121
|
+
const moduleId = path_1.default.basename(source.split('?uts-proxy')[0]);
|
|
122
|
+
source = `uts.sdk.modules.${(0, shared_1.camelize)(moduleId)}`;
|
|
123
|
+
imported = genUTSComponentPublicInstanceImported(rootDir, `@/uni_modules/${moduleId}/components/${tagName}/${tagName}`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
imported = genUTSComponentPublicInstanceImported(rootDir, source);
|
|
127
|
+
}
|
|
118
128
|
addUTSEasyComAutoImports(source, [
|
|
119
|
-
|
|
129
|
+
imported,
|
|
120
130
|
genUTSComponentPublicInstanceIdent(tagName),
|
|
121
131
|
]);
|
|
122
132
|
});
|
|
@@ -164,7 +174,16 @@ function matchEasycom(tag) {
|
|
|
164
174
|
return source;
|
|
165
175
|
}
|
|
166
176
|
exports.matchEasycom = matchEasycom;
|
|
167
|
-
const isDir = (path) =>
|
|
177
|
+
const isDir = (path) => {
|
|
178
|
+
const stat = fs_1.default.lstatSync(path);
|
|
179
|
+
if (stat.isDirectory()) {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
else if (stat.isSymbolicLink()) {
|
|
183
|
+
return fs_1.default.lstatSync(fs_1.default.realpathSync(path)).isDirectory();
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
};
|
|
168
187
|
function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
169
188
|
if (!path_1.default.isAbsolute(dir)) {
|
|
170
189
|
dir = path_1.default.resolve(rootDir, dir);
|
|
@@ -173,6 +192,12 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
|
173
192
|
if (!fs_1.default.existsSync(dir)) {
|
|
174
193
|
return easycoms;
|
|
175
194
|
}
|
|
195
|
+
const is_uni_modules = path_1.default.basename(path_1.default.resolve(dir, '../..')) === 'uni_modules';
|
|
196
|
+
const is_encrypt_uni_modules = // uni_modules模式不需要此逻辑
|
|
197
|
+
process.env.UNI_COMPILE_TARGET !== 'uni_modules' &&
|
|
198
|
+
is_uni_modules &&
|
|
199
|
+
fs_1.default.existsSync(path_1.default.resolve(dir, '../encrypt'));
|
|
200
|
+
const uni_modules_plugin_id = is_encrypt_uni_modules && path_1.default.basename(path_1.default.resolve(dir, '..'));
|
|
176
201
|
fs_1.default.readdirSync(dir).forEach((name) => {
|
|
177
202
|
const folder = path_1.default.resolve(dir, name);
|
|
178
203
|
if (!isDir(folder)) {
|
|
@@ -184,7 +209,14 @@ function initAutoScanEasycom(dir, rootDir, extensions) {
|
|
|
184
209
|
for (let i = 0; i < extensions.length; i++) {
|
|
185
210
|
const ext = extensions[i];
|
|
186
211
|
if (files.includes(name + ext)) {
|
|
187
|
-
easycoms[`^${name}$`] =
|
|
212
|
+
easycoms[`^${name}$`] = is_encrypt_uni_modules
|
|
213
|
+
? (0, utils_1.normalizePath)(path_1.default.join(rootDir, `uni_modules/${uni_modules_plugin_id}?${
|
|
214
|
+
// android 走 proxy
|
|
215
|
+
process.env.UNI_APP_X === 'true' &&
|
|
216
|
+
process.env.UNI_UTS_PLATFORM === 'app-android'
|
|
217
|
+
? 'uts-proxy'
|
|
218
|
+
: 'uni_helpers'}`))
|
|
219
|
+
: `${importDir}/${name}${ext}`;
|
|
188
220
|
break;
|
|
189
221
|
}
|
|
190
222
|
}
|
package/dist/fs.js
CHANGED
|
@@ -7,12 +7,15 @@ exports.emptyDir = void 0;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
function emptyDir(dir, skip = []) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
try {
|
|
11
|
+
for (const file of fs_1.default.readdirSync(dir)) {
|
|
12
|
+
if (skip.includes(file)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
// node >= 14.14.0
|
|
16
|
+
fs_1.default.rmSync(path_1.default.resolve(dir, file), { recursive: true, force: true });
|
|
13
17
|
}
|
|
14
|
-
// node >= 14.14.0
|
|
15
|
-
fs_1.default.rmSync(path_1.default.resolve(dir, file), { recursive: true, force: true });
|
|
16
18
|
}
|
|
19
|
+
catch (e) { }
|
|
17
20
|
}
|
|
18
21
|
exports.emptyDir = emptyDir;
|
package/dist/hbx/log.js
CHANGED
|
@@ -110,7 +110,16 @@ exports.errorFormatter = {
|
|
|
110
110
|
};
|
|
111
111
|
function buildErrorMessage(err, args = [], includeStack = true) {
|
|
112
112
|
if (err.plugin) {
|
|
113
|
+
const otherMsgs = [];
|
|
114
|
+
if (err.message.includes(': [plugin ')) {
|
|
115
|
+
const messages = err.message.split(': [plugin ');
|
|
116
|
+
err.message = messages[0];
|
|
117
|
+
messages.slice(1).forEach((msg) => {
|
|
118
|
+
otherMsgs.push(`[plugin:${msg}`);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
113
121
|
args.push(`${picocolors_1.default.magenta('[plugin:' + err.plugin + ']')} ${picocolors_1.default.red(err.message)}`);
|
|
122
|
+
args.push(...otherMsgs);
|
|
114
123
|
if (err.loc &&
|
|
115
124
|
err.hook === 'transform' &&
|
|
116
125
|
err.plugin === 'rollup-plugin-dynamic-import-variables' &&
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export * from './resolve';
|
|
|
22
22
|
export * from './scripts';
|
|
23
23
|
export * from './platform';
|
|
24
24
|
export * from './utsUtils';
|
|
25
|
-
export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, } from './uni_modules';
|
|
25
|
+
export { parseUniExtApi, parseUniExtApis, parseInjects, parseUniModulesArtifacts, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, resolveEncryptUniModule, formatExtApiProviderName, } from './uni_modules';
|
|
26
26
|
export { M } from './messages';
|
|
27
27
|
export * from './exports';
|
|
28
28
|
export { checkUpdate } from './checkUpdate';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.checkUpdate = exports.M = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
17
|
+
exports.checkUpdate = exports.M = exports.formatExtApiProviderName = exports.resolveEncryptUniModule = exports.getUniExtApiProviderRegisters = exports.parseUniModulesArtifacts = exports.parseInjects = exports.parseUniExtApis = exports.parseUniExtApi = void 0;
|
|
18
18
|
__exportStar(require("./fs"), exports);
|
|
19
19
|
__exportStar(require("./mp"), exports);
|
|
20
20
|
__exportStar(require("./url"), exports);
|
|
@@ -40,9 +40,13 @@ __exportStar(require("./scripts"), exports);
|
|
|
40
40
|
__exportStar(require("./platform"), exports);
|
|
41
41
|
__exportStar(require("./utsUtils"), exports);
|
|
42
42
|
var uni_modules_1 = require("./uni_modules");
|
|
43
|
+
Object.defineProperty(exports, "parseUniExtApi", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApi; } });
|
|
43
44
|
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
|
44
45
|
Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
|
|
46
|
+
Object.defineProperty(exports, "parseUniModulesArtifacts", { enumerable: true, get: function () { return uni_modules_1.parseUniModulesArtifacts; } });
|
|
45
47
|
Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
|
|
48
|
+
Object.defineProperty(exports, "resolveEncryptUniModule", { enumerable: true, get: function () { return uni_modules_1.resolveEncryptUniModule; } });
|
|
49
|
+
Object.defineProperty(exports, "formatExtApiProviderName", { enumerable: true, get: function () { return uni_modules_1.formatExtApiProviderName; } });
|
|
46
50
|
var messages_1 = require("./messages");
|
|
47
51
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
48
52
|
__exportStar(require("./exports"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function initNVue(manifestJson: Record<string, any>, pagesJson: UniApp.PagesJson): void;
|
|
2
|
-
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "
|
|
2
|
+
export declare function getNVueCompiler(manifestJson: Record<string, any>): "uni-app" | "weex" | "vue" | "vite";
|
|
3
3
|
export declare function getNVueStyleCompiler(manifestJson: Record<string, any>): "uni-app" | "weex";
|
|
4
4
|
export declare function getNVueFlexDirection(manifestJson: Record<string, any>): "column" | "row" | "row-reverse" | "column-reverse";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function definePageCode(pagesJson: Record<string, any
|
|
1
|
+
export declare function definePageCode(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM): string;
|
|
2
2
|
export declare function defineNVuePageCode(pagesJson: Record<string, any>): string;
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineNVuePageCode = exports.definePageCode = void 0;
|
|
4
4
|
const utils_1 = require("../../../utils");
|
|
5
|
-
function definePageCode(pagesJson) {
|
|
5
|
+
function definePageCode(pagesJson, platform = 'app') {
|
|
6
6
|
const importPagesCode = [];
|
|
7
7
|
const definePagesCode = [];
|
|
8
8
|
pagesJson.pages.forEach((page) => {
|
|
9
|
-
if (page.style.isNVue) {
|
|
9
|
+
if (platform === 'app' && page.style.isNVue) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
const pagePath = page.path;
|
|
13
13
|
const pageIdentifier = (0, utils_1.normalizeIdentifier)(pagePath);
|
|
14
|
-
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath,
|
|
14
|
+
const pagePathWithExtname = (0, utils_1.normalizePagePath)(pagePath, platform);
|
|
15
15
|
if (pagePathWithExtname) {
|
|
16
16
|
if (process.env.UNI_APP_CODE_SPLITING) {
|
|
17
17
|
// 拆分页面
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function normalizeAppPagesJson(pagesJson: Record<string, any
|
|
1
|
+
export declare function normalizeAppPagesJson(pagesJson: Record<string, any>, platform?: UniApp.PLATFORM): string;
|
|
2
2
|
export declare function normalizeAppNVuePagesJson(pagesJson: Record<string, any>): string;
|
|
3
3
|
export declare function normalizeAppConfigService(pagesJson: UniApp.PagesJson, manifestJson: Record<string, any>): string;
|
|
@@ -5,8 +5,8 @@ const code_1 = require("./code");
|
|
|
5
5
|
const definePage_1 = require("./definePage");
|
|
6
6
|
const uniConfig_1 = require("./uniConfig");
|
|
7
7
|
const uniRoutes_1 = require("./uniRoutes");
|
|
8
|
-
function normalizeAppPagesJson(pagesJson) {
|
|
9
|
-
return (0, definePage_1.definePageCode)(pagesJson);
|
|
8
|
+
function normalizeAppPagesJson(pagesJson, platform = 'app') {
|
|
9
|
+
return (0, definePage_1.definePageCode)(pagesJson, platform);
|
|
10
10
|
}
|
|
11
11
|
exports.normalizeAppPagesJson = normalizeAppPagesJson;
|
|
12
12
|
function normalizeAppNVuePagesJson(pagesJson) {
|
package/dist/json/manifest.d.ts
CHANGED
|
@@ -31,4 +31,5 @@ export declare function getRouterOptions(manifestJson: Record<string, any>): {
|
|
|
31
31
|
export declare function isEnableTreeShaking(manifestJson: Record<string, any>): boolean;
|
|
32
32
|
export declare function getDevServerOptions(manifestJson: Record<string, any>): any;
|
|
33
33
|
export declare function getPlatformManifestJsonOnce(): any;
|
|
34
|
+
export declare function validateThemeValue(value: string): boolean;
|
|
34
35
|
export {};
|
package/dist/json/manifest.js
CHANGED
|
@@ -3,19 +3,25 @@ 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.getPlatformManifestJsonOnce = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
6
|
+
exports.validateThemeValue = exports.getPlatformManifestJsonOnce = exports.getDevServerOptions = exports.isEnableTreeShaking = exports.getRouterOptions = exports.isUniPushOffline = exports.hasPushModule = exports.isEnableSecureNetwork = exports.isEnableUniPushV2 = exports.isEnableUniPushV1 = exports.getUniStatistics = exports.normalizeNetworkTimeout = exports.parseCompatConfigOnce = exports.parseRpx2UnitOnce = exports.parseManifestJsonOnce = exports.parseManifestJson = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
10
10
|
const uni_shared_1 = require("@dcloudio/uni-shared");
|
|
11
11
|
const json_1 = require("./json");
|
|
12
12
|
const parseManifestJson = (inputDir) => {
|
|
13
|
+
const manifestFilename = path_1.default.join(inputDir, 'manifest.json');
|
|
14
|
+
if (!fs_1.default.existsSync(manifestFilename)) {
|
|
15
|
+
if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
13
19
|
return (0, json_1.parseJson)(fs_1.default.readFileSync(path_1.default.join(inputDir, 'manifest.json'), 'utf8'));
|
|
14
20
|
};
|
|
15
21
|
exports.parseManifestJson = parseManifestJson;
|
|
16
22
|
exports.parseManifestJsonOnce = (0, uni_shared_1.once)(exports.parseManifestJson);
|
|
17
23
|
exports.parseRpx2UnitOnce = (0, uni_shared_1.once)((inputDir, platform = 'h5') => {
|
|
18
|
-
const rpx2unit = platform === 'h5' || platform === 'app'
|
|
24
|
+
const rpx2unit = platform === 'h5' || platform === 'app' || platform === 'app-harmony'
|
|
19
25
|
? uni_shared_1.defaultRpx2Unit
|
|
20
26
|
: uni_shared_1.defaultMiniProgramRpx2Unit;
|
|
21
27
|
const platformOptions = (0, exports.parseManifestJsonOnce)(inputDir)[platform];
|
|
@@ -115,3 +121,8 @@ function getPlatformManifestJsonOnce() {
|
|
|
115
121
|
: (0, exports.parseManifestJsonOnce)(process.env.UNI_INPUT_DIR)[platform] || {};
|
|
116
122
|
}
|
|
117
123
|
exports.getPlatformManifestJsonOnce = getPlatformManifestJsonOnce;
|
|
124
|
+
const themeValues = ['dark', 'light', 'auto'];
|
|
125
|
+
function validateThemeValue(value) {
|
|
126
|
+
return themeValues.indexOf(value) !== -1;
|
|
127
|
+
}
|
|
128
|
+
exports.validateThemeValue = validateThemeValue;
|
package/dist/json/pages.js
CHANGED
|
@@ -43,7 +43,16 @@ exports.isUniPageSfcFile = isUniPageSfcFile;
|
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
45
|
const parsePagesJson = (inputDir, platform, normalize = true) => {
|
|
46
|
-
const
|
|
46
|
+
const pagesFilename = path_1.default.join(inputDir, 'pages.json');
|
|
47
|
+
if (!fs_1.default.existsSync(pagesFilename)) {
|
|
48
|
+
if (process.env.UNI_COMPILE_TARGET === 'uni_modules') {
|
|
49
|
+
return {
|
|
50
|
+
pages: [],
|
|
51
|
+
globalStyle: { navigationBar: {} },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const jsonStr = fs_1.default.readFileSync(pagesFilename, 'utf8');
|
|
47
56
|
if (normalize) {
|
|
48
57
|
return normalizePagesJson(jsonStr, platform);
|
|
49
58
|
}
|
|
@@ -146,6 +155,15 @@ exports.validatePages = validatePages;
|
|
|
146
155
|
function normalizePages(pages, platform) {
|
|
147
156
|
pages.forEach((page) => {
|
|
148
157
|
page.style = normalizePageStyle(page.path, page.style, platform);
|
|
158
|
+
if (platform === 'app-harmony') {
|
|
159
|
+
// 鸿蒙下强制 isNVue 为 false,增加额外的 isNVueStyle 来标记样式处理
|
|
160
|
+
// 因为已有的代码里太多根据 isNVue 来处理的逻辑,这些逻辑在鸿蒙都不适用
|
|
161
|
+
// 鸿蒙仅需要将 nvue 当做 vue,并补充 css 即可
|
|
162
|
+
if (page.style.isNVue) {
|
|
163
|
+
page.style.isNVue = false;
|
|
164
|
+
page.style.isNVueStyle = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
149
167
|
});
|
|
150
168
|
if (platform !== 'app') {
|
|
151
169
|
return;
|
|
@@ -233,7 +251,7 @@ function normalizePageStyle(pagePath, pageStyle, platform) {
|
|
|
233
251
|
else {
|
|
234
252
|
(0, shared_1.extend)(pageStyle, pageStyle[platform]);
|
|
235
253
|
}
|
|
236
|
-
if (['h5', 'app'].includes(platform)) {
|
|
254
|
+
if (['h5', 'app', 'app-harmony'].includes(platform)) {
|
|
237
255
|
pageStyle.navigationBar = normalizeNavigationBar(pageStyle);
|
|
238
256
|
if (isEnablePullDownRefresh(pageStyle)) {
|
|
239
257
|
pageStyle.enablePullDownRefresh = true;
|
package/dist/json/theme.d.ts
CHANGED
|
@@ -2,3 +2,22 @@ export declare function hasThemeJson(themeLocation: string): boolean;
|
|
|
2
2
|
export declare const parseThemeJson: (themeLocation?: string) => UniApp.ThemeJson;
|
|
3
3
|
export declare const normalizeThemeConfigOnce: (manifestJsonPlatform?: Record<string, any>) => UniApp.ThemeJson;
|
|
4
4
|
export declare function initTheme<T extends object>(manifestJson: Record<string, any>, pagesJson: T): T;
|
|
5
|
+
export declare class ThemeSassParser {
|
|
6
|
+
_index: number;
|
|
7
|
+
_input: string;
|
|
8
|
+
_theme: Record<string, Record<string, any>>;
|
|
9
|
+
constructor();
|
|
10
|
+
parse(input: string): Record<string, Record<string, any>>;
|
|
11
|
+
parseVariable(): void;
|
|
12
|
+
parseVariableValue(): any;
|
|
13
|
+
parseFunction(): void | string[];
|
|
14
|
+
skipOtherValue(): void;
|
|
15
|
+
parseString(): string;
|
|
16
|
+
pushThemeValue(key: string, valuePair: string[]): void;
|
|
17
|
+
consume(expected: string): void;
|
|
18
|
+
get currentChar(): string;
|
|
19
|
+
skipWhiteSpaceAndComments(): void;
|
|
20
|
+
skipComment(): void;
|
|
21
|
+
skipWhiteSpace(): void;
|
|
22
|
+
isspace(str: string): boolean;
|
|
23
|
+
}
|
package/dist/json/theme.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.initTheme = exports.normalizeThemeConfigOnce = exports.parseThemeJson = exports.hasThemeJson = void 0;
|
|
6
|
+
exports.ThemeSassParser = exports.initTheme = exports.normalizeThemeConfigOnce = exports.parseThemeJson = exports.hasThemeJson = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const json_1 = require("./json");
|
|
@@ -27,7 +27,61 @@ const parseThemeJson = (themeLocation = 'theme.json') => {
|
|
|
27
27
|
return (0, json_1.parseJson)(jsonStr, true);
|
|
28
28
|
};
|
|
29
29
|
exports.parseThemeJson = parseThemeJson;
|
|
30
|
-
|
|
30
|
+
const SCHEME_RE = /^([a-z-]+:)?\/\//i;
|
|
31
|
+
const DATA_RE = /^data:.*,.*/;
|
|
32
|
+
function normalizeFilepath(filepath) {
|
|
33
|
+
if (!(SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) &&
|
|
34
|
+
filepath.indexOf('/') !== 0) {
|
|
35
|
+
return (0, uni_shared_1.addLeadingSlash)(filepath);
|
|
36
|
+
}
|
|
37
|
+
return filepath;
|
|
38
|
+
}
|
|
39
|
+
const parseThemeJsonIconPath = (themeConfig, curPathThemeJsonKey) => {
|
|
40
|
+
if (themeConfig.light?.[curPathThemeJsonKey]) {
|
|
41
|
+
themeConfig.light[curPathThemeJsonKey] = normalizeFilepath(themeConfig.light[curPathThemeJsonKey]);
|
|
42
|
+
}
|
|
43
|
+
if (themeConfig.dark?.[curPathThemeJsonKey]) {
|
|
44
|
+
themeConfig.dark[curPathThemeJsonKey] = normalizeFilepath(themeConfig.dark[curPathThemeJsonKey]);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function normalizeUniConfigThemeJsonIconPath(themeConfig, pagesJson) {
|
|
48
|
+
// 处理 tabbar 下 list -> item -> iconPath、selectedIconPath; midButton -> backgroundImage 路径 / 不开头的情况
|
|
49
|
+
const tabBar = pagesJson.tabBar;
|
|
50
|
+
if (tabBar) {
|
|
51
|
+
tabBar.list.forEach((item) => {
|
|
52
|
+
if (item.iconPath && item.iconPath.indexOf('@') === 0) {
|
|
53
|
+
parseThemeJsonIconPath(themeConfig, item.iconPath.replace(/^@/, ''));
|
|
54
|
+
}
|
|
55
|
+
if (item.selectedIconPath && item.selectedIconPath.indexOf('@') === 0) {
|
|
56
|
+
parseThemeJsonIconPath(themeConfig, item.selectedIconPath.replace(/^@/, ''));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const midButtonBackgroundImage = tabBar.midButton?.backgroundImage;
|
|
60
|
+
if (midButtonBackgroundImage &&
|
|
61
|
+
midButtonBackgroundImage.indexOf('@') === 0) {
|
|
62
|
+
parseThemeJsonIconPath(themeConfig, midButtonBackgroundImage.replace(/^@/, ''));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return themeConfig;
|
|
66
|
+
}
|
|
67
|
+
const getPagesJson = (inputDir) => {
|
|
68
|
+
const pagesFilename = path_1.default.join(inputDir, 'pages.json');
|
|
69
|
+
if (!fs_1.default.existsSync(pagesFilename)) {
|
|
70
|
+
return {
|
|
71
|
+
pages: [],
|
|
72
|
+
globalStyle: { navigationBar: {} },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const jsonStr = fs_1.default.readFileSync(pagesFilename, 'utf8');
|
|
76
|
+
return (0, json_1.parseJson)(jsonStr, true);
|
|
77
|
+
};
|
|
78
|
+
exports.normalizeThemeConfigOnce = (0, uni_shared_1.once)((manifestJsonPlatform = {}) => {
|
|
79
|
+
const themeConfig = (0, exports.parseThemeJson)(manifestJsonPlatform.themeLocation);
|
|
80
|
+
if (process.env.UNI_INPUT_DIR) {
|
|
81
|
+
normalizeUniConfigThemeJsonIconPath(themeConfig, getPagesJson(process.env.UNI_INPUT_DIR));
|
|
82
|
+
}
|
|
83
|
+
return themeConfig;
|
|
84
|
+
});
|
|
31
85
|
function initTheme(manifestJson, pagesJson) {
|
|
32
86
|
const platform = process.env.UNI_PLATFORM === 'app' ? 'app-plus' : process.env.UNI_PLATFORM;
|
|
33
87
|
const manifestPlatform = manifestJson['plus'] || manifestJson[platform] || {};
|
|
@@ -35,3 +89,187 @@ function initTheme(manifestJson, pagesJson) {
|
|
|
35
89
|
return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
|
|
36
90
|
}
|
|
37
91
|
exports.initTheme = initTheme;
|
|
92
|
+
// TODO
|
|
93
|
+
class ThemeSassParser {
|
|
94
|
+
constructor() {
|
|
95
|
+
this._index = 0;
|
|
96
|
+
this._input = '';
|
|
97
|
+
this._theme = {};
|
|
98
|
+
}
|
|
99
|
+
parse(input) {
|
|
100
|
+
this._index = 0;
|
|
101
|
+
this._input = input;
|
|
102
|
+
this._theme = {};
|
|
103
|
+
this._theme['light'] = {};
|
|
104
|
+
this._theme['dark'] = {};
|
|
105
|
+
this.parseVariable();
|
|
106
|
+
return this._theme;
|
|
107
|
+
}
|
|
108
|
+
parseVariable() {
|
|
109
|
+
this.skipWhiteSpaceAndComments();
|
|
110
|
+
this.consume('$');
|
|
111
|
+
this.skipWhiteSpaceAndComments();
|
|
112
|
+
let key = this.parseString();
|
|
113
|
+
this.skipWhiteSpaceAndComments();
|
|
114
|
+
this.consume(':');
|
|
115
|
+
this.skipWhiteSpace();
|
|
116
|
+
const value = this.parseVariableValue();
|
|
117
|
+
if (Array.isArray(value)) {
|
|
118
|
+
this.pushThemeValue(key, value);
|
|
119
|
+
}
|
|
120
|
+
this.consume(';');
|
|
121
|
+
this.skipWhiteSpaceAndComments();
|
|
122
|
+
if (this._index < this._input.length) {
|
|
123
|
+
this.parseVariable();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
parseVariableValue() {
|
|
127
|
+
switch (this.currentChar) {
|
|
128
|
+
case 'l':
|
|
129
|
+
return this.parseFunction();
|
|
130
|
+
default:
|
|
131
|
+
return this.skipOtherValue();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
parseFunction() {
|
|
135
|
+
let functionName = '';
|
|
136
|
+
while (this.currentChar != '(') {
|
|
137
|
+
functionName += this.currentChar;
|
|
138
|
+
if (this._index + 1 < this._input.length) {
|
|
139
|
+
++this._index;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (functionName != 'light-dark') {
|
|
146
|
+
return this.skipOtherValue();
|
|
147
|
+
}
|
|
148
|
+
let valuePair = new Array(2);
|
|
149
|
+
valuePair[0] = '';
|
|
150
|
+
valuePair[1] = '';
|
|
151
|
+
this.consume('(');
|
|
152
|
+
let index = 0;
|
|
153
|
+
// TODO rgb?
|
|
154
|
+
while (this.currentChar != ')') {
|
|
155
|
+
valuePair[index] += this.currentChar;
|
|
156
|
+
if (this.currentChar === ',') {
|
|
157
|
+
index++;
|
|
158
|
+
}
|
|
159
|
+
++this._index;
|
|
160
|
+
}
|
|
161
|
+
this.consume(')');
|
|
162
|
+
valuePair[0] = valuePair[0].trim();
|
|
163
|
+
valuePair[1] = valuePair[1].trim();
|
|
164
|
+
return valuePair;
|
|
165
|
+
}
|
|
166
|
+
skipOtherValue() {
|
|
167
|
+
while (this.currentChar != ';') {
|
|
168
|
+
if (this._index + 1 < this._input.length) {
|
|
169
|
+
++this._index;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
parseString() {
|
|
177
|
+
let str = '';
|
|
178
|
+
while (this.currentChar != ':') {
|
|
179
|
+
if (this.currentChar == '\\') {
|
|
180
|
+
str += this.currentChar;
|
|
181
|
+
if (this._index + 1 < this._input.length) {
|
|
182
|
+
str += this._input[++this._index];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
str += this.currentChar;
|
|
186
|
+
if (this._index + 1 < this._input.length) {
|
|
187
|
+
++this._index;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return str;
|
|
194
|
+
}
|
|
195
|
+
pushThemeValue(key, valuePair) {
|
|
196
|
+
this._theme['light'][key] = valuePair[0];
|
|
197
|
+
this._theme['dark'][key] = valuePair[1];
|
|
198
|
+
}
|
|
199
|
+
consume(expected) {
|
|
200
|
+
if (this.currentChar != expected) {
|
|
201
|
+
throw new Error('Unexpected character ' +
|
|
202
|
+
expected +
|
|
203
|
+
' index=' +
|
|
204
|
+
this._index +
|
|
205
|
+
' ' +
|
|
206
|
+
this.currentChar);
|
|
207
|
+
}
|
|
208
|
+
++this._index;
|
|
209
|
+
}
|
|
210
|
+
get currentChar() {
|
|
211
|
+
if (this._index >= this._input.length) {
|
|
212
|
+
throw new Error('Unexpected end of input');
|
|
213
|
+
}
|
|
214
|
+
return this._input[this._index];
|
|
215
|
+
}
|
|
216
|
+
skipWhiteSpaceAndComments() {
|
|
217
|
+
while (this._index < this._input.length) {
|
|
218
|
+
const c = this._input[this._index];
|
|
219
|
+
if (this.isspace(c)) {
|
|
220
|
+
++this._index;
|
|
221
|
+
}
|
|
222
|
+
else if (c == '/') {
|
|
223
|
+
this.skipComment();
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
skipComment() {
|
|
231
|
+
if (this.currentChar != '/') {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
this.consume('/');
|
|
235
|
+
let nextChar = this.currentChar;
|
|
236
|
+
if (nextChar == '/') {
|
|
237
|
+
// Single line comment
|
|
238
|
+
while (
|
|
239
|
+
// @ts-expect-error
|
|
240
|
+
this.currentChar !== '\n' &&
|
|
241
|
+
this._index < this._input.length - 1) {
|
|
242
|
+
++this._index;
|
|
243
|
+
}
|
|
244
|
+
this.skipWhiteSpace();
|
|
245
|
+
}
|
|
246
|
+
else if (nextChar === '*') {
|
|
247
|
+
// Multi-line comment
|
|
248
|
+
while (true) {
|
|
249
|
+
if (this._index + 1 >= this._input.length) {
|
|
250
|
+
throw new Error('Unterminated multi-line comment');
|
|
251
|
+
}
|
|
252
|
+
++this._index;
|
|
253
|
+
// @ts-expect-error
|
|
254
|
+
if (this.currentChar === '*' && this._input[this._index + 1] === '/') {
|
|
255
|
+
this._index += 2;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
this.skipWhiteSpace();
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
throw new Error('Invalid comment');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
skipWhiteSpace() {
|
|
266
|
+
while (this._index < this._input.length &&
|
|
267
|
+
this.isspace(this._input[this._index])) {
|
|
268
|
+
++this._index;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
isspace(str) {
|
|
272
|
+
return str == ' ' || str == '\n' || str == '\r' || str == "'";
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.ThemeSassParser = ThemeSassParser;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeAppXUniConfig = void 0;
|
|
4
4
|
const uniConfig_1 = require("../app/pages/uniConfig");
|
|
5
|
+
// app-config.js 内容
|
|
5
6
|
function normalizeAppXUniConfig(pagesJson, manifestJson) {
|
|
6
7
|
const config = {
|
|
7
8
|
pages: [],
|
|
@@ -16,6 +17,10 @@ function normalizeAppXUniConfig(pagesJson, manifestJson) {
|
|
|
16
17
|
config.conditionUrl = config.entryPagePath;
|
|
17
18
|
config.entryPagePath = config.realEntryPagePath;
|
|
18
19
|
}
|
|
20
|
+
// darkmode
|
|
21
|
+
if (pagesJson.themeConfig) {
|
|
22
|
+
config.themeConfig = pagesJson.themeConfig;
|
|
23
|
+
}
|
|
19
24
|
// TODO 待支持分包
|
|
20
25
|
return JSON.stringify(config);
|
|
21
26
|
}
|
package/dist/messages/en.d.ts
CHANGED
|
@@ -43,5 +43,6 @@ declare const _default: {
|
|
|
43
43
|
readonly 'prompt.run.devtools.quickapp-webview-union': "Quick App Alliance Devtools";
|
|
44
44
|
readonly 'uvue.unsupported': "uvue does not support {platform} platform";
|
|
45
45
|
readonly 'uvue.dev.watching.end.empty': "The compilation outcome remains unchanged; there is no need to synchronize.";
|
|
46
|
+
readonly 'uni_modules.import': "Plug-in [{0}] only supports @/uni_modules/{1}.";
|
|
46
47
|
};
|
|
47
48
|
export default _default;
|
package/dist/messages/en.js
CHANGED
|
@@ -45,4 +45,5 @@ exports.default = {
|
|
|
45
45
|
'prompt.run.devtools.quickapp-webview-union': 'Quick App Alliance Devtools',
|
|
46
46
|
'uvue.unsupported': 'uvue does not support {platform} platform',
|
|
47
47
|
'uvue.dev.watching.end.empty': 'The compilation outcome remains unchanged; there is no need to synchronize.',
|
|
48
|
+
'uni_modules.import': 'Plug-in [{0}] only supports @/uni_modules/{1}.',
|
|
48
49
|
};
|
package/dist/messages/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export declare const M: {
|
|
|
43
43
|
readonly 'prompt.run.devtools.quickapp-webview-union': "快应用联盟开发者工具";
|
|
44
44
|
readonly 'uvue.unsupported': "uvue 暂不支持 {platform} 平台";
|
|
45
45
|
readonly 'uvue.dev.watching.end.empty': "本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。";
|
|
46
|
+
readonly 'uni_modules.import': "插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。";
|
|
46
47
|
} | {
|
|
47
48
|
readonly 'app.compiler.version': "Compiler version: {version}";
|
|
48
49
|
readonly compiling: "Compiling...";
|
|
@@ -88,4 +89,5 @@ export declare const M: {
|
|
|
88
89
|
readonly 'prompt.run.devtools.quickapp-webview-union': "Quick App Alliance Devtools";
|
|
89
90
|
readonly 'uvue.unsupported': "uvue does not support {platform} platform";
|
|
90
91
|
readonly 'uvue.dev.watching.end.empty': "The compilation outcome remains unchanged; there is no need to synchronize.";
|
|
92
|
+
readonly 'uni_modules.import': "Plug-in [{0}] only supports @/uni_modules/{1}.";
|
|
91
93
|
};
|
package/dist/messages/zh_CN.d.ts
CHANGED
|
@@ -43,5 +43,6 @@ declare const _default: {
|
|
|
43
43
|
readonly 'prompt.run.devtools.quickapp-webview-union': "快应用联盟开发者工具";
|
|
44
44
|
readonly 'uvue.unsupported': "uvue 暂不支持 {platform} 平台";
|
|
45
45
|
readonly 'uvue.dev.watching.end.empty': "本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。";
|
|
46
|
+
readonly 'uni_modules.import': "插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。";
|
|
46
47
|
};
|
|
47
48
|
export default _default;
|
package/dist/messages/zh_CN.js
CHANGED
|
@@ -45,4 +45,5 @@ exports.default = {
|
|
|
45
45
|
'prompt.run.devtools.quickapp-webview-union': '快应用联盟开发者工具',
|
|
46
46
|
'uvue.unsupported': 'uvue 暂不支持 {platform} 平台',
|
|
47
47
|
'uvue.dev.watching.end.empty': '本次代码变更,编译结果未发生变化,跳过同步手机端程序文件。',
|
|
48
|
+
'uni_modules.import': '插件[{0}]仅支持 @/uni_modules/{1} 方式引入,不支持直接导入内部文件 {2}。',
|
|
48
49
|
};
|