@dcloudio/uni-cli-shared 3.0.0-alpha-4010820240523001 → 3.0.0-alpha-4010820240529001

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.
@@ -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
+ }
@@ -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;
@@ -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
- if (language === 'javascript') {
195
- if (appOptions.js === false) {
196
- return;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4010820240523001",
3
+ "version": "3.0.0-alpha-4010820240529001",
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-4010820240523001",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4010820240523001",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4010820240529001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4010820240529001",
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-4010820240523001",
74
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010820240529001",
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",