@opensumi/ide-theme 2.21.13 → 2.22.0
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/lib/browser/icon-theme-data.js.map +1 -1
- package/lib/browser/icon-theme-store.js.map +1 -1
- package/lib/browser/icon.service.d.ts +3 -1
- package/lib/browser/icon.service.d.ts.map +1 -1
- package/lib/browser/icon.service.js +56 -24
- package/lib/browser/icon.service.js.map +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/semantic-tokens-registry.js.map +1 -1
- package/lib/browser/style.service.js.map +1 -1
- package/lib/browser/theme-data.js +7 -7
- package/lib/browser/theme-data.js.map +1 -1
- package/lib/browser/theme-store.js.map +1 -1
- package/lib/browser/theme.contribution.js +3 -3
- package/lib/browser/theme.contribution.js.map +1 -1
- package/lib/browser/workbench.theme.service.js +2 -2
- package/lib/browser/workbench.theme.service.js.map +1 -1
- package/lib/common/color-tokens/basic-color.d.ts +1 -1
- package/lib/common/color-tokens/basic-color.d.ts.map +1 -1
- package/lib/common/color-tokens/editor.d.ts +13 -0
- package/lib/common/color-tokens/editor.d.ts.map +1 -1
- package/lib/common/color-tokens/editor.js +35 -1
- package/lib/common/color-tokens/editor.js.map +1 -1
- package/lib/common/color.js +40 -40
- package/lib/common/color.js.map +1 -1
- package/lib/common/mocks/theme.service.js.map +1 -1
- package/lib/common/plistParser.js +40 -40
- package/lib/common/plistParser.js.map +1 -1
- package/lib/common/semantic-tokens-registry.d.ts +7 -7
- package/lib/common/semantic-tokens-registry.d.ts.map +1 -1
- package/lib/common/theme.service.d.ts +26 -6
- package/lib/common/theme.service.d.ts.map +1 -1
- package/lib/common/theme.service.js.map +1 -1
- package/package.json +11 -10
- package/src/browser/default-theme.ts +547 -0
- package/src/browser/icon-theme-data.ts +294 -0
- package/src/browser/icon-theme-store.ts +38 -0
- package/src/browser/icon.less +15 -0
- package/src/browser/icon.service.ts +457 -0
- package/src/browser/index.ts +45 -0
- package/src/browser/semantic-tokens-registry.ts +217 -0
- package/src/browser/style.service.ts +51 -0
- package/src/browser/theme-data.ts +719 -0
- package/src/browser/theme-store.ts +95 -0
- package/src/browser/theme.contribution.ts +343 -0
- package/src/browser/workbench.theme.service.ts +703 -0
- package/src/common/color-registry.ts +52 -0
- package/src/common/color-tokens/activity-bar.ts +122 -0
- package/src/common/color-tokens/badge.ts +31 -0
- package/src/common/color-tokens/base.ts +90 -0
- package/src/common/color-tokens/basic-color.ts +9 -0
- package/src/common/color-tokens/breadcrumb.ts +60 -0
- package/src/common/color-tokens/button.ts +69 -0
- package/src/common/color-tokens/charts.ts +68 -0
- package/src/common/color-tokens/checkbox.ts +23 -0
- package/src/common/color-tokens/custom/actionbar.ts +51 -0
- package/src/common/color-tokens/custom/activity-bar.ts +16 -0
- package/src/common/color-tokens/custom/badge.ts +30 -0
- package/src/common/color-tokens/custom/base.ts +111 -0
- package/src/common/color-tokens/custom/button.ts +359 -0
- package/src/common/color-tokens/custom/checkbox.ts +36 -0
- package/src/common/color-tokens/custom/decoration.ts +71 -0
- package/src/common/color-tokens/custom/editor.ts +27 -0
- package/src/common/color-tokens/custom/extension.ts +9 -0
- package/src/common/color-tokens/custom/icon.ts +30 -0
- package/src/common/color-tokens/custom/index.ts +26 -0
- package/src/common/color-tokens/custom/input.ts +48 -0
- package/src/common/color-tokens/custom/menu.ts +61 -0
- package/src/common/color-tokens/custom/modal.ts +57 -0
- package/src/common/color-tokens/custom/notification.ts +16 -0
- package/src/common/color-tokens/custom/panel.ts +112 -0
- package/src/common/color-tokens/custom/popover.ts +28 -0
- package/src/common/color-tokens/custom/select.ts +155 -0
- package/src/common/color-tokens/custom/settings.ts +32 -0
- package/src/common/color-tokens/custom/statusbar.ts +16 -0
- package/src/common/color-tokens/custom/tab.ts +31 -0
- package/src/common/color-tokens/custom/tooltip.ts +55 -0
- package/src/common/color-tokens/custom/tree.ts +106 -0
- package/src/common/color-tokens/debug.ts +103 -0
- package/src/common/color-tokens/debugToolbar.ts +134 -0
- package/src/common/color-tokens/dropdown.ts +27 -0
- package/src/common/color-tokens/editor.ts +945 -0
- package/src/common/color-tokens/index.ts +35 -0
- package/src/common/color-tokens/input.ts +105 -0
- package/src/common/color-tokens/list-tree.ts +205 -0
- package/src/common/color-tokens/menu-bar.ts +43 -0
- package/src/common/color-tokens/menu.ts +53 -0
- package/src/common/color-tokens/merge-conflict.ts +145 -0
- package/src/common/color-tokens/minimap.ts +99 -0
- package/src/common/color-tokens/notification.ts +169 -0
- package/src/common/color-tokens/panel.ts +177 -0
- package/src/common/color-tokens/pick-view.ts +96 -0
- package/src/common/color-tokens/picker.ts +15 -0
- package/src/common/color-tokens/progress-bar.ts +12 -0
- package/src/common/color-tokens/quick-input.ts +57 -0
- package/src/common/color-tokens/scrollbar.ts +42 -0
- package/src/common/color-tokens/settings.ts +126 -0
- package/src/common/color-tokens/sidebar.ts +121 -0
- package/src/common/color-tokens/snippet.ts +33 -0
- package/src/common/color-tokens/status-bar.ts +350 -0
- package/src/common/color-tokens/tab.ts +346 -0
- package/src/common/color-tokens/testing.ts +105 -0
- package/src/common/color-tokens/text.ts +41 -0
- package/src/common/color-tokens/title-bar.ts +62 -0
- package/src/common/color-tokens/toolbar.ts +28 -0
- package/src/common/color-tokens/welcome-page.ts +27 -0
- package/src/common/color.ts +647 -0
- package/src/common/default-themes.ts +273 -0
- package/src/common/event.ts +9 -0
- package/src/common/index.ts +8 -0
- package/src/common/mocks/theme.service.ts +55 -0
- package/src/common/plistParser.ts +525 -0
- package/src/common/semantic-tokens-registry.ts +439 -0
- package/src/common/style.ts +9 -0
- package/src/common/theme.service.ts +363 -0
- package/src/common/themeCompatibility.ts +95 -0
- package/src/common/utils.ts +195 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
2
|
+
/* ---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
// Some code copied and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/workbench/services/themes/common/plistParser.ts
|
|
7
|
+
|
|
8
|
+
const enum ChCode {
|
|
9
|
+
BOM = 65279,
|
|
10
|
+
|
|
11
|
+
SPACE = 32,
|
|
12
|
+
TAB = 9,
|
|
13
|
+
CARRIAGE_RETURN = 13,
|
|
14
|
+
LINE_FEED = 10,
|
|
15
|
+
|
|
16
|
+
SLASH = 47,
|
|
17
|
+
|
|
18
|
+
LESS_THAN = 60,
|
|
19
|
+
QUESTION_MARK = 63,
|
|
20
|
+
EXCLAMATION_MARK = 33,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const enum State {
|
|
24
|
+
ROOT_STATE = 0,
|
|
25
|
+
DICT_STATE = 1,
|
|
26
|
+
ARR_STATE = 2,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parseWithLocation(content: string, filename: string, locationKeyName: string): any {
|
|
30
|
+
return _parse(content, filename, locationKeyName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A very fast plist parser
|
|
35
|
+
*/
|
|
36
|
+
export function parse(content: string): any {
|
|
37
|
+
return _parse(content, null, null);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _parse(content: string, filename: string | null, locationKeyName: string | null): any {
|
|
41
|
+
const len = content.length;
|
|
42
|
+
|
|
43
|
+
let pos = 0;
|
|
44
|
+
let line = 1;
|
|
45
|
+
let char = 0;
|
|
46
|
+
|
|
47
|
+
// Skip UTF8 BOM
|
|
48
|
+
if (len > 0 && content.charCodeAt(0) === ChCode.BOM) {
|
|
49
|
+
pos = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function advancePosBy(by: number): void {
|
|
53
|
+
if (locationKeyName === null) {
|
|
54
|
+
pos = pos + by;
|
|
55
|
+
} else {
|
|
56
|
+
while (by > 0) {
|
|
57
|
+
const chCode = content.charCodeAt(pos);
|
|
58
|
+
if (chCode === ChCode.LINE_FEED) {
|
|
59
|
+
pos++;
|
|
60
|
+
line++;
|
|
61
|
+
char = 0;
|
|
62
|
+
} else {
|
|
63
|
+
pos++;
|
|
64
|
+
char++;
|
|
65
|
+
}
|
|
66
|
+
by--;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function advancePosTo(to: number): void {
|
|
71
|
+
if (locationKeyName === null) {
|
|
72
|
+
pos = to;
|
|
73
|
+
} else {
|
|
74
|
+
advancePosBy(to - pos);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function skipWhitespace(): void {
|
|
79
|
+
while (pos < len) {
|
|
80
|
+
const chCode = content.charCodeAt(pos);
|
|
81
|
+
if (
|
|
82
|
+
chCode !== ChCode.SPACE &&
|
|
83
|
+
chCode !== ChCode.TAB &&
|
|
84
|
+
chCode !== ChCode.CARRIAGE_RETURN &&
|
|
85
|
+
chCode !== ChCode.LINE_FEED
|
|
86
|
+
) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
advancePosBy(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function advanceIfStartsWith(str: string): boolean {
|
|
94
|
+
if (content.substr(pos, str.length) === str) {
|
|
95
|
+
advancePosBy(str.length);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function advanceUntil(str: string): void {
|
|
102
|
+
const nextOccurence = content.indexOf(str, pos);
|
|
103
|
+
if (nextOccurence !== -1) {
|
|
104
|
+
advancePosTo(nextOccurence + str.length);
|
|
105
|
+
} else {
|
|
106
|
+
// EOF
|
|
107
|
+
advancePosTo(len);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function captureUntil(str: string): string {
|
|
112
|
+
const nextOccurence = content.indexOf(str, pos);
|
|
113
|
+
if (nextOccurence !== -1) {
|
|
114
|
+
const r = content.substring(pos, nextOccurence);
|
|
115
|
+
advancePosTo(nextOccurence + str.length);
|
|
116
|
+
return r;
|
|
117
|
+
} else {
|
|
118
|
+
// EOF
|
|
119
|
+
const r = content.substr(pos);
|
|
120
|
+
advancePosTo(len);
|
|
121
|
+
return r;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let state = State.ROOT_STATE;
|
|
126
|
+
|
|
127
|
+
let cur: any = null;
|
|
128
|
+
const stateStack: State[] = [];
|
|
129
|
+
const objStack: any[] = [];
|
|
130
|
+
let curKey: string | null = null;
|
|
131
|
+
|
|
132
|
+
function pushState(newState: State, newCur: any): void {
|
|
133
|
+
stateStack.push(state);
|
|
134
|
+
objStack.push(cur);
|
|
135
|
+
state = newState;
|
|
136
|
+
cur = newCur;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function popState(): void {
|
|
140
|
+
if (stateStack.length === 0) {
|
|
141
|
+
return fail('illegal state stack');
|
|
142
|
+
}
|
|
143
|
+
state = stateStack.pop()!;
|
|
144
|
+
cur = objStack.pop();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function fail(msg: string): void {
|
|
148
|
+
throw new Error('Near offset ' + pos + ': ' + msg + ' ~~~' + content.substr(pos, 50) + '~~~');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const dictState = {
|
|
152
|
+
enterDict() {
|
|
153
|
+
if (curKey === null) {
|
|
154
|
+
return fail('missing <key>');
|
|
155
|
+
}
|
|
156
|
+
const newDict = {};
|
|
157
|
+
if (locationKeyName !== null) {
|
|
158
|
+
newDict[locationKeyName] = {
|
|
159
|
+
filename,
|
|
160
|
+
line,
|
|
161
|
+
char,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
cur[curKey] = newDict;
|
|
165
|
+
curKey = null;
|
|
166
|
+
pushState(State.DICT_STATE, newDict);
|
|
167
|
+
},
|
|
168
|
+
enterArray() {
|
|
169
|
+
if (curKey === null) {
|
|
170
|
+
return fail('missing <key>');
|
|
171
|
+
}
|
|
172
|
+
const newArr: any[] = [];
|
|
173
|
+
cur[curKey] = newArr;
|
|
174
|
+
curKey = null;
|
|
175
|
+
pushState(State.ARR_STATE, newArr);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const arrState = {
|
|
180
|
+
enterDict() {
|
|
181
|
+
const newDict = {};
|
|
182
|
+
if (locationKeyName !== null) {
|
|
183
|
+
newDict[locationKeyName] = {
|
|
184
|
+
filename,
|
|
185
|
+
line,
|
|
186
|
+
char,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
cur.push(newDict);
|
|
190
|
+
pushState(State.DICT_STATE, newDict);
|
|
191
|
+
},
|
|
192
|
+
enterArray() {
|
|
193
|
+
const newArr: any[] = [];
|
|
194
|
+
cur.push(newArr);
|
|
195
|
+
pushState(State.ARR_STATE, newArr);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
function enterDict() {
|
|
200
|
+
if (state === State.DICT_STATE) {
|
|
201
|
+
dictState.enterDict();
|
|
202
|
+
} else if (state === State.ARR_STATE) {
|
|
203
|
+
arrState.enterDict();
|
|
204
|
+
} else {
|
|
205
|
+
// ROOT_STATE
|
|
206
|
+
cur = {};
|
|
207
|
+
if (locationKeyName !== null) {
|
|
208
|
+
cur[locationKeyName] = {
|
|
209
|
+
filename,
|
|
210
|
+
line,
|
|
211
|
+
char,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
pushState(State.DICT_STATE, cur);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function leaveDict() {
|
|
218
|
+
if (state === State.DICT_STATE) {
|
|
219
|
+
popState();
|
|
220
|
+
} else if (state === State.ARR_STATE) {
|
|
221
|
+
return fail('unexpected </dict>');
|
|
222
|
+
} else {
|
|
223
|
+
// ROOT_STATE
|
|
224
|
+
return fail('unexpected </dict>');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function enterArray() {
|
|
228
|
+
if (state === State.DICT_STATE) {
|
|
229
|
+
dictState.enterArray();
|
|
230
|
+
} else if (state === State.ARR_STATE) {
|
|
231
|
+
arrState.enterArray();
|
|
232
|
+
} else {
|
|
233
|
+
// ROOT_STATE
|
|
234
|
+
cur = [];
|
|
235
|
+
pushState(State.ARR_STATE, cur);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function leaveArray() {
|
|
239
|
+
if (state === State.DICT_STATE) {
|
|
240
|
+
return fail('unexpected </array>');
|
|
241
|
+
} else if (state === State.ARR_STATE) {
|
|
242
|
+
popState();
|
|
243
|
+
} else {
|
|
244
|
+
// ROOT_STATE
|
|
245
|
+
return fail('unexpected </array>');
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function acceptKey(val: string) {
|
|
249
|
+
if (state === State.DICT_STATE) {
|
|
250
|
+
if (curKey !== null) {
|
|
251
|
+
return fail('too many <key>');
|
|
252
|
+
}
|
|
253
|
+
curKey = val;
|
|
254
|
+
} else if (state === State.ARR_STATE) {
|
|
255
|
+
return fail('unexpected <key>');
|
|
256
|
+
} else {
|
|
257
|
+
// ROOT_STATE
|
|
258
|
+
return fail('unexpected <key>');
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function acceptString(val: string) {
|
|
262
|
+
if (state === State.DICT_STATE) {
|
|
263
|
+
if (curKey === null) {
|
|
264
|
+
return fail('missing <key>');
|
|
265
|
+
}
|
|
266
|
+
cur[curKey] = val;
|
|
267
|
+
curKey = null;
|
|
268
|
+
} else if (state === State.ARR_STATE) {
|
|
269
|
+
cur.push(val);
|
|
270
|
+
} else {
|
|
271
|
+
// ROOT_STATE
|
|
272
|
+
cur = val;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function acceptReal(val: number) {
|
|
276
|
+
if (isNaN(val)) {
|
|
277
|
+
return fail('cannot parse float');
|
|
278
|
+
}
|
|
279
|
+
if (state === State.DICT_STATE) {
|
|
280
|
+
if (curKey === null) {
|
|
281
|
+
return fail('missing <key>');
|
|
282
|
+
}
|
|
283
|
+
cur[curKey] = val;
|
|
284
|
+
curKey = null;
|
|
285
|
+
} else if (state === State.ARR_STATE) {
|
|
286
|
+
cur.push(val);
|
|
287
|
+
} else {
|
|
288
|
+
// ROOT_STATE
|
|
289
|
+
cur = val;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function acceptInteger(val: number) {
|
|
293
|
+
if (isNaN(val)) {
|
|
294
|
+
return fail('cannot parse integer');
|
|
295
|
+
}
|
|
296
|
+
if (state === State.DICT_STATE) {
|
|
297
|
+
if (curKey === null) {
|
|
298
|
+
return fail('missing <key>');
|
|
299
|
+
}
|
|
300
|
+
cur[curKey] = val;
|
|
301
|
+
curKey = null;
|
|
302
|
+
} else if (state === State.ARR_STATE) {
|
|
303
|
+
cur.push(val);
|
|
304
|
+
} else {
|
|
305
|
+
// ROOT_STATE
|
|
306
|
+
cur = val;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function acceptDate(val: Date) {
|
|
310
|
+
if (state === State.DICT_STATE) {
|
|
311
|
+
if (curKey === null) {
|
|
312
|
+
return fail('missing <key>');
|
|
313
|
+
}
|
|
314
|
+
cur[curKey] = val;
|
|
315
|
+
curKey = null;
|
|
316
|
+
} else if (state === State.ARR_STATE) {
|
|
317
|
+
cur.push(val);
|
|
318
|
+
} else {
|
|
319
|
+
// ROOT_STATE
|
|
320
|
+
cur = val;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function acceptData(val: string) {
|
|
324
|
+
if (state === State.DICT_STATE) {
|
|
325
|
+
if (curKey === null) {
|
|
326
|
+
return fail('missing <key>');
|
|
327
|
+
}
|
|
328
|
+
cur[curKey] = val;
|
|
329
|
+
curKey = null;
|
|
330
|
+
} else if (state === State.ARR_STATE) {
|
|
331
|
+
cur.push(val);
|
|
332
|
+
} else {
|
|
333
|
+
// ROOT_STATE
|
|
334
|
+
cur = val;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function acceptBool(val: boolean) {
|
|
338
|
+
if (state === State.DICT_STATE) {
|
|
339
|
+
if (curKey === null) {
|
|
340
|
+
return fail('missing <key>');
|
|
341
|
+
}
|
|
342
|
+
cur[curKey] = val;
|
|
343
|
+
curKey = null;
|
|
344
|
+
} else if (state === State.ARR_STATE) {
|
|
345
|
+
cur.push(val);
|
|
346
|
+
} else {
|
|
347
|
+
// ROOT_STATE
|
|
348
|
+
cur = val;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function escapeVal(str: string): string {
|
|
353
|
+
return str
|
|
354
|
+
.replace(/&#([0-9]+);/g, function (_: string, m0: string) {
|
|
355
|
+
return (<any>String).fromCodePoint(parseInt(m0, 10));
|
|
356
|
+
})
|
|
357
|
+
.replace(/&#x([0-9a-f]+);/g, function (_: string, m0: string) {
|
|
358
|
+
return (<any>String).fromCodePoint(parseInt(m0, 16));
|
|
359
|
+
})
|
|
360
|
+
.replace(/&|<|>|"|'/g, function (_: string) {
|
|
361
|
+
switch (_) {
|
|
362
|
+
case '&':
|
|
363
|
+
return '&';
|
|
364
|
+
case '<':
|
|
365
|
+
return '<';
|
|
366
|
+
case '>':
|
|
367
|
+
return '>';
|
|
368
|
+
case '"':
|
|
369
|
+
return '"';
|
|
370
|
+
case ''':
|
|
371
|
+
return "'";
|
|
372
|
+
}
|
|
373
|
+
return _;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
interface IParsedTag {
|
|
378
|
+
name: string;
|
|
379
|
+
isClosed: boolean;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function parseOpenTag(): IParsedTag {
|
|
383
|
+
let r = captureUntil('>');
|
|
384
|
+
let isClosed = false;
|
|
385
|
+
if (r.charCodeAt(r.length - 1) === ChCode.SLASH) {
|
|
386
|
+
isClosed = true;
|
|
387
|
+
r = r.substring(0, r.length - 1);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
name: r.trim(),
|
|
392
|
+
isClosed,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function parseTagValue(tag: IParsedTag): string {
|
|
397
|
+
if (tag.isClosed) {
|
|
398
|
+
return '';
|
|
399
|
+
}
|
|
400
|
+
const val = captureUntil('</');
|
|
401
|
+
advanceUntil('>');
|
|
402
|
+
return escapeVal(val);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
while (pos < len) {
|
|
406
|
+
skipWhitespace();
|
|
407
|
+
if (pos >= len) {
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const chCode = content.charCodeAt(pos);
|
|
412
|
+
advancePosBy(1);
|
|
413
|
+
if (chCode !== ChCode.LESS_THAN) {
|
|
414
|
+
return fail('expected <');
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (pos >= len) {
|
|
418
|
+
return fail('unexpected end of input');
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const peekChCode = content.charCodeAt(pos);
|
|
422
|
+
|
|
423
|
+
if (peekChCode === ChCode.QUESTION_MARK) {
|
|
424
|
+
advancePosBy(1);
|
|
425
|
+
advanceUntil('?>');
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (peekChCode === ChCode.EXCLAMATION_MARK) {
|
|
430
|
+
advancePosBy(1);
|
|
431
|
+
|
|
432
|
+
if (advanceIfStartsWith('--')) {
|
|
433
|
+
advanceUntil('-->');
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
advanceUntil('>');
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (peekChCode === ChCode.SLASH) {
|
|
442
|
+
advancePosBy(1);
|
|
443
|
+
skipWhitespace();
|
|
444
|
+
|
|
445
|
+
if (advanceIfStartsWith('plist')) {
|
|
446
|
+
advanceUntil('>');
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (advanceIfStartsWith('dict')) {
|
|
451
|
+
advanceUntil('>');
|
|
452
|
+
leaveDict();
|
|
453
|
+
continue;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (advanceIfStartsWith('array')) {
|
|
457
|
+
advanceUntil('>');
|
|
458
|
+
leaveArray();
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return fail('unexpected closed tag');
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const tag = parseOpenTag();
|
|
466
|
+
|
|
467
|
+
switch (tag.name) {
|
|
468
|
+
case 'dict':
|
|
469
|
+
enterDict();
|
|
470
|
+
if (tag.isClosed) {
|
|
471
|
+
leaveDict();
|
|
472
|
+
}
|
|
473
|
+
continue;
|
|
474
|
+
|
|
475
|
+
case 'array':
|
|
476
|
+
enterArray();
|
|
477
|
+
if (tag.isClosed) {
|
|
478
|
+
leaveArray();
|
|
479
|
+
}
|
|
480
|
+
continue;
|
|
481
|
+
|
|
482
|
+
case 'key':
|
|
483
|
+
acceptKey(parseTagValue(tag));
|
|
484
|
+
continue;
|
|
485
|
+
|
|
486
|
+
case 'string':
|
|
487
|
+
acceptString(parseTagValue(tag));
|
|
488
|
+
continue;
|
|
489
|
+
|
|
490
|
+
case 'real':
|
|
491
|
+
acceptReal(parseFloat(parseTagValue(tag)));
|
|
492
|
+
continue;
|
|
493
|
+
|
|
494
|
+
case 'integer':
|
|
495
|
+
acceptInteger(parseInt(parseTagValue(tag), 10));
|
|
496
|
+
continue;
|
|
497
|
+
|
|
498
|
+
case 'date':
|
|
499
|
+
acceptDate(new Date(parseTagValue(tag)));
|
|
500
|
+
continue;
|
|
501
|
+
|
|
502
|
+
case 'data':
|
|
503
|
+
acceptData(parseTagValue(tag));
|
|
504
|
+
continue;
|
|
505
|
+
|
|
506
|
+
case 'true':
|
|
507
|
+
parseTagValue(tag);
|
|
508
|
+
acceptBool(true);
|
|
509
|
+
continue;
|
|
510
|
+
|
|
511
|
+
case 'false':
|
|
512
|
+
parseTagValue(tag);
|
|
513
|
+
acceptBool(false);
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (/^plist/.test(tag.name)) {
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
return fail('unexpected opened tag ' + tag.name);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return cur;
|
|
525
|
+
}
|