@opensumi/ide-theme 2.13.8 → 2.13.10
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.
|
@@ -3,11 +3,15 @@ import { URI } from '@opensumi/ide-core-common';
|
|
|
3
3
|
import { ThemeData } from './theme-data';
|
|
4
4
|
import { ThemeContribution } from '../common/theme.service';
|
|
5
5
|
export declare class ThemeStore {
|
|
6
|
+
static STORE_THEME_DATA_KEY: string;
|
|
6
7
|
private themes;
|
|
7
8
|
injector: Injector;
|
|
8
9
|
protected initTheme(contribution: ThemeContribution, extPath: URI): Promise<ThemeData>;
|
|
9
10
|
private initThemeData;
|
|
10
11
|
loadDefaultTheme(): ThemeData;
|
|
12
|
+
private tryLoadLatestTheme;
|
|
13
|
+
private storeLatestThemeData;
|
|
14
|
+
private getLatestThemeData;
|
|
11
15
|
getThemeData(contribution?: ThemeContribution, basePath?: URI): Promise<ThemeData>;
|
|
12
16
|
}
|
|
13
17
|
//# sourceMappingURL=theme-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-store.d.ts","sourceRoot":"","sources":["../../src/browser/theme-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAkB,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAc,MAAM,yBAAyB,CAAC;AAGxE,qBACa,UAAU;IACrB,OAAO,CAAC,MAAM,CAEP;IAGP,QAAQ,EAAE,QAAQ,CAAC;cAEH,SAAS,CAAC,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;YAU9E,aAAa;IAS3B,gBAAgB;
|
|
1
|
+
{"version":3,"file":"theme-store.d.ts","sourceRoot":"","sources":["../../src/browser/theme-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAkB,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAc,MAAM,yBAAyB,CAAC;AAGxE,qBACa,UAAU;IACrB,MAAM,CAAC,oBAAoB,SAAiB;IAE5C,OAAO,CAAC,MAAM,CAEP;IAGP,QAAQ,EAAE,QAAQ,CAAC;cAEH,SAAS,CAAC,YAAY,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;YAU9E,aAAa;IAS3B,gBAAgB;YAOF,kBAAkB;IAgBhC,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,kBAAkB;IAOb,YAAY,CAAC,YAAY,CAAC,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;CAmBhG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var ThemeStore_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.ThemeStore = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
@@ -7,7 +8,7 @@ const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
|
7
8
|
const theme_data_1 = require("./theme-data");
|
|
8
9
|
const theme_service_1 = require("../common/theme.service");
|
|
9
10
|
const default_theme_1 = (0, tslib_1.__importDefault)(require("./default-theme"));
|
|
10
|
-
let ThemeStore = class ThemeStore {
|
|
11
|
+
let ThemeStore = ThemeStore_1 = class ThemeStore {
|
|
11
12
|
constructor() {
|
|
12
13
|
this.themes = {};
|
|
13
14
|
}
|
|
@@ -29,35 +30,62 @@ let ThemeStore = class ThemeStore {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
loadDefaultTheme() {
|
|
32
|
-
(0, ide_core_common_1.getDebugLogger)().warn('
|
|
33
|
+
(0, ide_core_common_1.getDebugLogger)().warn('The default theme plugin is not detected, and the default theme style is used.');
|
|
33
34
|
const theme = this.injector.get(theme_data_1.ThemeData);
|
|
34
35
|
theme.initializeFromData(default_theme_1.default);
|
|
35
36
|
return theme;
|
|
36
37
|
}
|
|
38
|
+
async tryLoadLatestTheme() {
|
|
39
|
+
// 尝试使用最近一次缓存的主题信息进行加载
|
|
40
|
+
const themeData = this.getLatestThemeData();
|
|
41
|
+
if (themeData) {
|
|
42
|
+
try {
|
|
43
|
+
const { contribution, basePath } = themeData;
|
|
44
|
+
const theme = await this.initTheme(contribution, new ide_core_common_1.URI(basePath));
|
|
45
|
+
return theme;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
// 主题不存在或被卸载时,移除缓存,使用默认样式
|
|
49
|
+
localStorage.removeItem(ThemeStore_1.STORE_THEME_DATA_KEY);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this.loadDefaultTheme();
|
|
53
|
+
}
|
|
54
|
+
storeLatestThemeData(contribution, basePath) {
|
|
55
|
+
localStorage.setItem(ThemeStore_1.STORE_THEME_DATA_KEY, JSON.stringify({ contribution, basePath: basePath === null || basePath === void 0 ? void 0 : basePath.toString() }));
|
|
56
|
+
}
|
|
57
|
+
getLatestThemeData() {
|
|
58
|
+
const data = localStorage.getItem(ThemeStore_1.STORE_THEME_DATA_KEY);
|
|
59
|
+
if (data) {
|
|
60
|
+
return JSON.parse(data);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
37
63
|
async getThemeData(contribution, basePath) {
|
|
38
|
-
// 测试情况下传入的contribution
|
|
64
|
+
// 测试情况下传入的contribution为空,尝试加载上次缓存的最新主题
|
|
39
65
|
if (!contribution || !basePath) {
|
|
40
|
-
return this.
|
|
66
|
+
return await this.tryLoadLatestTheme();
|
|
41
67
|
}
|
|
42
68
|
const id = (0, theme_service_1.getThemeId)(contribution);
|
|
43
69
|
if (!this.themes[id]) {
|
|
44
70
|
const theme = await this.initTheme(contribution, basePath);
|
|
45
71
|
if (theme) {
|
|
46
72
|
// 正常加载主题
|
|
73
|
+
this.storeLatestThemeData(contribution, basePath);
|
|
47
74
|
return theme;
|
|
48
75
|
}
|
|
49
|
-
//
|
|
76
|
+
// 加载主题出现了未知问题, 使用默认主题配色
|
|
50
77
|
return this.loadDefaultTheme();
|
|
51
78
|
}
|
|
52
79
|
// 主题有缓存
|
|
53
80
|
return this.themes[id];
|
|
54
81
|
}
|
|
55
82
|
};
|
|
83
|
+
ThemeStore.STORE_THEME_DATA_KEY = 'latestTheme';
|
|
56
84
|
(0, tslib_1.__decorate)([
|
|
57
85
|
(0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
|
|
58
86
|
(0, tslib_1.__metadata)("design:type", di_1.Injector)
|
|
59
87
|
], ThemeStore.prototype, "injector", void 0);
|
|
60
|
-
ThemeStore = (0, tslib_1.__decorate)([
|
|
88
|
+
ThemeStore = ThemeStore_1 = (0, tslib_1.__decorate)([
|
|
61
89
|
(0, di_1.Injectable)()
|
|
62
90
|
], ThemeStore);
|
|
63
91
|
exports.ThemeStore = ThemeStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-store.js","sourceRoot":"","sources":["../../src/browser/theme-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme-store.js","sourceRoot":"","sources":["../../src/browser/theme-store.ts"],"names":[],"mappings":";;;;;AAAA,qCAA+E;AAC/E,+DAAgE;AAEhE,6CAAyC;AACzC,2DAAwE;AACxE,iFAA2C;AAG3C,IAAa,UAAU,kBAAvB,MAAa,UAAU;IAAvB;QAGU,WAAM,GAEV,EAAE,CAAC;IAgFT,CAAC;IA3EW,KAAK,CAAC,SAAS,CAAC,YAA+B,EAAE,OAAY;QACrE,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC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QAAQ,CAAC,CAAC;gBAClD,OAAO,KAAK,CAAC;aACd;YACD,wBAAwB;YACxB,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;SAChC;QACD,QAAQ;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACF,CAAA;AApFQ,+BAAoB,GAAG,aAAa,CAAC;AAO5C;IADC,IAAA,cAAS,EAAC,mBAAc,CAAC;2CAChB,aAAQ;4CAAC;AARR,UAAU;IADtB,IAAA,eAAU,GAAE;GACA,UAAU,CAqFtB;AArFY,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-theme",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.10",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"url": "git@github.com:opensumi/core.git"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@opensumi/ide-core-common": "2.13.
|
|
20
|
-
"@opensumi/ide-logs": "2.13.
|
|
21
|
-
"@opensumi/ide-core-node": "2.13.
|
|
22
|
-
"@opensumi/ide-file-service": "2.13.
|
|
23
|
-
"@opensumi/ide-static-resource": "2.13.
|
|
24
|
-
"@opensumi/ide-core-browser": "2.13.
|
|
19
|
+
"@opensumi/ide-core-common": "2.13.10",
|
|
20
|
+
"@opensumi/ide-logs": "2.13.10",
|
|
21
|
+
"@opensumi/ide-core-node": "2.13.10",
|
|
22
|
+
"@opensumi/ide-file-service": "2.13.10",
|
|
23
|
+
"@opensumi/ide-static-resource": "2.13.10",
|
|
24
|
+
"@opensumi/ide-core-browser": "2.13.10"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@opensumi/ide-dev-tool": "^1.3.1"
|