@dcloudio/uni-cli-shared 3.0.0-alpha-4010820240523001 → 3.0.0-alpha-4010820240529002
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/json/theme.d.ts +19 -0
- package/dist/json/theme.js +185 -1
- package/dist/json/uni-x/uniConfig.js +5 -0
- package/dist/uni_modules.d.ts +3 -3
- package/dist/uni_modules.js +10 -20
- package/dist/vite/cloud.js +4 -3
- package/package.json +4 -4
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");
|
|
@@ -35,3 +35,187 @@ function initTheme(manifestJson, pagesJson) {
|
|
|
35
35
|
return (0, uni_shared_1.normalizeStyles)(pagesJson, themeConfig);
|
|
36
36
|
}
|
|
37
37
|
exports.initTheme = initTheme;
|
|
38
|
+
// TODO
|
|
39
|
+
class ThemeSassParser {
|
|
40
|
+
constructor() {
|
|
41
|
+
this._index = 0;
|
|
42
|
+
this._input = '';
|
|
43
|
+
this._theme = {};
|
|
44
|
+
}
|
|
45
|
+
parse(input) {
|
|
46
|
+
this._index = 0;
|
|
47
|
+
this._input = input;
|
|
48
|
+
this._theme = {};
|
|
49
|
+
this._theme['light'] = {};
|
|
50
|
+
this._theme['dark'] = {};
|
|
51
|
+
this.parseVariable();
|
|
52
|
+
return this._theme;
|
|
53
|
+
}
|
|
54
|
+
parseVariable() {
|
|
55
|
+
this.skipWhiteSpaceAndComments();
|
|
56
|
+
this.consume('$');
|
|
57
|
+
this.skipWhiteSpaceAndComments();
|
|
58
|
+
let key = this.parseString();
|
|
59
|
+
this.skipWhiteSpaceAndComments();
|
|
60
|
+
this.consume(':');
|
|
61
|
+
this.skipWhiteSpace();
|
|
62
|
+
const value = this.parseVariableValue();
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
this.pushThemeValue(key, value);
|
|
65
|
+
}
|
|
66
|
+
this.consume(';');
|
|
67
|
+
this.skipWhiteSpaceAndComments();
|
|
68
|
+
if (this._index < this._input.length) {
|
|
69
|
+
this.parseVariable();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
parseVariableValue() {
|
|
73
|
+
switch (this.currentChar) {
|
|
74
|
+
case 'l':
|
|
75
|
+
return this.parseFunction();
|
|
76
|
+
default:
|
|
77
|
+
return this.skipOtherValue();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
parseFunction() {
|
|
81
|
+
let functionName = '';
|
|
82
|
+
while (this.currentChar != '(') {
|
|
83
|
+
functionName += this.currentChar;
|
|
84
|
+
if (this._index + 1 < this._input.length) {
|
|
85
|
+
++this._index;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (functionName != 'light-dark') {
|
|
92
|
+
return this.skipOtherValue();
|
|
93
|
+
}
|
|
94
|
+
let valuePair = new Array(2);
|
|
95
|
+
valuePair[0] = '';
|
|
96
|
+
valuePair[1] = '';
|
|
97
|
+
this.consume('(');
|
|
98
|
+
let index = 0;
|
|
99
|
+
// TODO rgb?
|
|
100
|
+
while (this.currentChar != ')') {
|
|
101
|
+
valuePair[index] += this.currentChar;
|
|
102
|
+
if (this.currentChar === ',') {
|
|
103
|
+
index++;
|
|
104
|
+
}
|
|
105
|
+
++this._index;
|
|
106
|
+
}
|
|
107
|
+
this.consume(')');
|
|
108
|
+
valuePair[0] = valuePair[0].trim();
|
|
109
|
+
valuePair[1] = valuePair[1].trim();
|
|
110
|
+
return valuePair;
|
|
111
|
+
}
|
|
112
|
+
skipOtherValue() {
|
|
113
|
+
while (this.currentChar != ';') {
|
|
114
|
+
if (this._index + 1 < this._input.length) {
|
|
115
|
+
++this._index;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
parseString() {
|
|
123
|
+
let str = '';
|
|
124
|
+
while (this.currentChar != ':') {
|
|
125
|
+
if (this.currentChar == '\\') {
|
|
126
|
+
str += this.currentChar;
|
|
127
|
+
if (this._index + 1 < this._input.length) {
|
|
128
|
+
str += this._input[++this._index];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
str += this.currentChar;
|
|
132
|
+
if (this._index + 1 < this._input.length) {
|
|
133
|
+
++this._index;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return str;
|
|
140
|
+
}
|
|
141
|
+
pushThemeValue(key, valuePair) {
|
|
142
|
+
this._theme['light'][key] = valuePair[0];
|
|
143
|
+
this._theme['dark'][key] = valuePair[1];
|
|
144
|
+
}
|
|
145
|
+
consume(expected) {
|
|
146
|
+
if (this.currentChar != expected) {
|
|
147
|
+
throw new Error('Unexpected character ' +
|
|
148
|
+
expected +
|
|
149
|
+
' index=' +
|
|
150
|
+
this._index +
|
|
151
|
+
' ' +
|
|
152
|
+
this.currentChar);
|
|
153
|
+
}
|
|
154
|
+
++this._index;
|
|
155
|
+
}
|
|
156
|
+
get currentChar() {
|
|
157
|
+
if (this._index >= this._input.length) {
|
|
158
|
+
throw new Error('Unexpected end of input');
|
|
159
|
+
}
|
|
160
|
+
return this._input[this._index];
|
|
161
|
+
}
|
|
162
|
+
skipWhiteSpaceAndComments() {
|
|
163
|
+
while (this._index < this._input.length) {
|
|
164
|
+
const c = this._input[this._index];
|
|
165
|
+
if (this.isspace(c)) {
|
|
166
|
+
++this._index;
|
|
167
|
+
}
|
|
168
|
+
else if (c == '/') {
|
|
169
|
+
this.skipComment();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
skipComment() {
|
|
177
|
+
if (this.currentChar != '/') {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this.consume('/');
|
|
181
|
+
let nextChar = this.currentChar;
|
|
182
|
+
if (nextChar == '/') {
|
|
183
|
+
// Single line comment
|
|
184
|
+
while (
|
|
185
|
+
// @ts-expect-error
|
|
186
|
+
this.currentChar !== '\n' &&
|
|
187
|
+
this._index < this._input.length - 1) {
|
|
188
|
+
++this._index;
|
|
189
|
+
}
|
|
190
|
+
this.skipWhiteSpace();
|
|
191
|
+
}
|
|
192
|
+
else if (nextChar === '*') {
|
|
193
|
+
// Multi-line comment
|
|
194
|
+
while (true) {
|
|
195
|
+
if (this._index + 1 >= this._input.length) {
|
|
196
|
+
throw new Error('Unterminated multi-line comment');
|
|
197
|
+
}
|
|
198
|
+
++this._index;
|
|
199
|
+
// @ts-expect-error
|
|
200
|
+
if (this.currentChar === '*' && this._input[this._index + 1] === '/') {
|
|
201
|
+
this._index += 2;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
this.skipWhiteSpace();
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
throw new Error('Invalid comment');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
skipWhiteSpace() {
|
|
212
|
+
while (this._index < this._input.length &&
|
|
213
|
+
this.isspace(this._input[this._index])) {
|
|
214
|
+
++this._index;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
isspace(str) {
|
|
218
|
+
return str == ' ' || str == '\n' || str == '\r' || str == "'";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
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/uni_modules.d.ts
CHANGED
|
@@ -70,15 +70,15 @@ export declare const capitalize: (str: string) => string;
|
|
|
70
70
|
* @returns
|
|
71
71
|
*/
|
|
72
72
|
export declare function parseUTSModuleDeps(deps: string[], inputDir: string): string[];
|
|
73
|
-
export declare function genEncryptEasyComModuleIndex(components: string
|
|
74
|
-
export declare function parseUniModulesWithComponents(inputDir: string): Record<string, string
|
|
73
|
+
export declare function genEncryptEasyComModuleIndex(components: Record<string, '.vue' | '.uvue'>): string;
|
|
74
|
+
export declare function parseUniModulesWithComponents(inputDir: string): Record<string, Record<string, ".vue" | ".uvue">>;
|
|
75
75
|
/**
|
|
76
76
|
* 解析 easyCom 组件列表
|
|
77
77
|
* @param pluginId
|
|
78
78
|
* @param inputDir
|
|
79
79
|
* @returns
|
|
80
80
|
*/
|
|
81
|
-
export declare function parseEasyComComponents(pluginId: string, inputDir: string, detectBinary?: boolean): string
|
|
81
|
+
export declare function parseEasyComComponents(pluginId: string, inputDir: string, detectBinary?: boolean): Record<string, ".vue" | ".uvue">;
|
|
82
82
|
export declare function findEncryptUniModules(inputDir: string, cacheDir?: string): Record<string, EncryptPackageJson | undefined>;
|
|
83
83
|
export declare function findUploadEncryptUniModulesFiles(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string): Record<string, string[]>;
|
|
84
84
|
export declare function packUploadEncryptUniModules(uniModules: Record<string, EncryptPackageJson | undefined>, platform: typeof process.env.UNI_UTS_PLATFORM, inputDir: string, cacheDir: string): {
|
package/dist/uni_modules.js
CHANGED
|
@@ -191,20 +191,9 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
|
|
|
191
191
|
const skipCheck = process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' &&
|
|
192
192
|
source.includes('app-js');
|
|
193
193
|
if (!skipCheck) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
else if (language === 'kotlin') {
|
|
200
|
-
if (appOptions.kotlin === false) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
else if (language === 'swift') {
|
|
205
|
-
if (appOptions.swift === false) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
194
|
+
const targetLanguage = language === 'javascript' ? 'js' : language;
|
|
195
|
+
if (targetLanguage && appOptions[targetLanguage] === false) {
|
|
196
|
+
return;
|
|
208
197
|
}
|
|
209
198
|
}
|
|
210
199
|
}
|
|
@@ -266,9 +255,9 @@ exports.parseUTSModuleDeps = parseUTSModuleDeps;
|
|
|
266
255
|
function genEncryptEasyComModuleIndex(components) {
|
|
267
256
|
const imports = [];
|
|
268
257
|
const ids = [];
|
|
269
|
-
components.forEach((component) => {
|
|
258
|
+
Object.keys(components).forEach((component) => {
|
|
270
259
|
const id = (0, exports.capitalize)((0, exports.camelize)(component));
|
|
271
|
-
imports.push(`import ${id} from './components/${component}/${component}
|
|
260
|
+
imports.push(`import ${id} from './components/${component}/${component}${components[component]}'`);
|
|
272
261
|
ids.push(id);
|
|
273
262
|
});
|
|
274
263
|
return `
|
|
@@ -302,11 +291,11 @@ exports.parseUniModulesWithComponents = parseUniModulesWithComponents;
|
|
|
302
291
|
*/
|
|
303
292
|
function parseEasyComComponents(pluginId, inputDir, detectBinary = true) {
|
|
304
293
|
const componentsDir = path_1.default.resolve(inputDir, 'uni_modules', pluginId, 'components');
|
|
305
|
-
const components =
|
|
294
|
+
const components = {};
|
|
306
295
|
if (fs_extra_1.default.existsSync(componentsDir)) {
|
|
307
296
|
fs_extra_1.default.readdirSync(componentsDir).forEach((componentDir) => {
|
|
308
297
|
const componentFile = path_1.default.resolve(componentsDir, componentDir, componentDir);
|
|
309
|
-
|
|
298
|
+
const extname = ['.vue', '.uvue'].find((extname) => {
|
|
310
299
|
const filename = componentFile + extname;
|
|
311
300
|
// 探测 filename 是否是二进制文件
|
|
312
301
|
if (fs_extra_1.default.existsSync(filename)) {
|
|
@@ -320,8 +309,9 @@ function parseEasyComComponents(pluginId, inputDir, detectBinary = true) {
|
|
|
320
309
|
return true;
|
|
321
310
|
}
|
|
322
311
|
}
|
|
323
|
-
})
|
|
324
|
-
|
|
312
|
+
});
|
|
313
|
+
if (extname) {
|
|
314
|
+
components[componentDir] = extname;
|
|
325
315
|
}
|
|
326
316
|
});
|
|
327
317
|
}
|
package/dist/vite/cloud.js
CHANGED
|
@@ -216,13 +216,14 @@ function initEncryptUniModulesBuildOptions(inputDir) {
|
|
|
216
216
|
// 生成入口文件
|
|
217
217
|
const input = {};
|
|
218
218
|
moduleNames.forEach((module) => {
|
|
219
|
-
const
|
|
219
|
+
const moduleDir = path_1.default.resolve(inputDir, 'uni_modules', module);
|
|
220
|
+
const indexEncryptFile = path_1.default.resolve(moduleDir, 'index.module.uts');
|
|
220
221
|
const codes = [];
|
|
221
|
-
if (hasIndexFile(
|
|
222
|
+
if (hasIndexFile(moduleDir)) {
|
|
222
223
|
codes.push(`export * from './index'`);
|
|
223
224
|
}
|
|
224
225
|
// easyCom
|
|
225
|
-
if (modules[module].length) {
|
|
226
|
+
if (modules[module] && Object.keys(modules[module]).length) {
|
|
226
227
|
codes.push((0, uni_modules_1.genEncryptEasyComModuleIndex)(modules[module]));
|
|
227
228
|
}
|
|
228
229
|
if (codes.length) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-4010820240529002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@babel/core": "^7.23.3",
|
|
27
27
|
"@babel/parser": "^7.23.9",
|
|
28
28
|
"@babel/types": "^7.20.7",
|
|
29
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
30
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
29
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-4010820240529002",
|
|
30
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4010820240529002",
|
|
31
31
|
"@intlify/core-base": "9.1.9",
|
|
32
32
|
"@intlify/shared": "9.1.9",
|
|
33
33
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
74
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4010820240529002",
|
|
75
75
|
"@types/adm-zip": "^0.5.5",
|
|
76
76
|
"@types/babel__code-frame": "^7.0.6",
|
|
77
77
|
"@types/babel__core": "^7.1.19",
|