@opensumi/ide-decoration 2.12.1-next-079c1930

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/README.md ADDED
@@ -0,0 +1,116 @@
1
+ ---
2
+ id: decoration
3
+ title: 文件 decoration 模块
4
+ ---
5
+
6
+ FileDecoration 模块主要用来注册/管理/分发跟文件名相关 Decoration 服务
7
+
8
+ # Interface
9
+
10
+ ## IDecorationData
11
+
12
+ Decoration 的详情
13
+
14
+ ```ts
15
+ interface IDecorationData {
16
+ /**
17
+ * 权重
18
+ */
19
+ readonly weight?: number;
20
+ /**
21
+ * Decoration 颜色
22
+ */
23
+ readonly color?: ColorIdentifier;
24
+ /**
25
+ * Decoration 字符
26
+ */
27
+ readonly letter?: string;
28
+ /**
29
+ * Decoration tooltip
30
+ */
31
+ readonly tooltip?: string;
32
+ /**
33
+ * Decoration 是否冒泡,类似文件的 Decoration 是否传给文件夹
34
+ */
35
+ readonly bubble?: boolean;
36
+ }
37
+ ```
38
+
39
+ # 类
40
+
41
+ ## FileDecorationsService
42
+
43
+ `DI token: IDecorationsService`
44
+
45
+ 提供基于文件名的修饰服务
46
+
47
+ ### Property
48
+
49
+ #### `onDidChangeDecorations`
50
+
51
+ ```ts
52
+ readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent>;
53
+ ```
54
+
55
+ 针对文件名的 Decoration 变更事件进行事件分发
56
+
57
+ ##### Example
58
+
59
+ ```ts
60
+ this.decorationsService.onDidChangeDecorations(() => {
61
+ // some listener
62
+ })
63
+ ```
64
+
65
+ ### Methods
66
+
67
+ #### `registerDecorationsProvider`
68
+
69
+ ```ts
70
+ registerDecorationsProvider(provider: IDecorationsProvider): IDisposable;
71
+ ```
72
+
73
+ 注册 DecorationsProvider
74
+
75
+ ##### Example
76
+
77
+ ```ts
78
+ class SampleDecorationsProvider implements IDecorationsProvider {
79
+ readonly label = 'sample';
80
+
81
+ readonly onDidChangeEmitter: Emitter<Uri[]> = new Emitter();
82
+
83
+ get onDidChange() {
84
+ return this.onDidChangeEmitter.event;
85
+ }
86
+
87
+ provideDecorations(resource: Uri): IDecorationData | undefined {
88
+ if (file.scheme !== 'file') {
89
+ return undefined;
90
+ }
91
+
92
+ return {
93
+ letter: '😸',
94
+ color: 'cat.smileForeground',
95
+ tooltip: localize('cat.smile'),
96
+ weight: -1,
97
+ bubble: false,
98
+ } as IDecorationData;
99
+ }
100
+ }
101
+ ```
102
+
103
+
104
+ #### `getDecoration`
105
+
106
+ ```ts
107
+ getDecoration(uri: Uri, includeChildren: boolean, overwrite?: IDecorationData): IDecoration | undefined;
108
+ ```
109
+
110
+ 获取 uri 的方式获取当前文件的 Decoration 结果,如果没有获取到则返回 undefined
111
+
112
+ ##### Example
113
+
114
+ ```ts
115
+ this.decorationsService.getDecoration(uri, true);
116
+ ```
@@ -0,0 +1,14 @@
1
+ import { Uri, Disposable, Event, IDisposable } from '@opensumi/ide-core-common';
2
+ import { IDecorationsService, IDecoration, IResourceDecorationChangeEvent, IDecorationsProvider, IDecorationData } from '../common/decorations';
3
+ export declare class FileDecorationsService extends Disposable implements IDecorationsService {
4
+ private readonly logger;
5
+ private readonly _data;
6
+ private readonly _onDidChangeDecorationsDelayed;
7
+ private readonly _onDidChangeDecorations;
8
+ readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent>;
9
+ dispose(): void;
10
+ registerDecorationsProvider(provider: IDecorationsProvider): IDisposable;
11
+ getDecoration(uri: Uri, includeChildren: boolean): IDecoration | undefined;
12
+ asDecoration(data: IDecorationData[], containsChildren: boolean): IDecoration | undefined;
13
+ }
14
+ //# sourceMappingURL=decorationsService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorationsService.d.ts","sourceRoot":"","sources":["../../src/browser/decorationsService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAA0D,WAAW,EAAyB,MAAM,2BAA2B,CAAC;AAM/J,OAAO,EACL,mBAAmB,EAAE,WAAW,EAAE,8BAA8B,EAChE,oBAAoB,EAAE,eAAe,EACtC,MAAM,uBAAuB,CAAC;AAuK/B,qBACa,sBAAuB,SAAQ,UAAW,YAAW,mBAAmB;IACnF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAE3C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+C;IACrE,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAA8B;IAC7E,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAiD;IAEzF,QAAQ,CAAC,sBAAsB,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAOpE;IAEF,OAAO,IAAI,IAAI;IAKf,2BAA2B,CAAC,QAAQ,EAAE,oBAAoB,GAAG,WAAW;IAwBxE,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS;IAoB1E,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,gBAAgB,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS;CAc1F"}
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileDecorationsService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
7
+ const errors_1 = require("@opensumi/ide-core-common/lib/errors");
8
+ const map_1 = require("@opensumi/ide-core-common/lib/map");
9
+ const linked_list_1 = require("@opensumi/ide-core-common/lib/linked-list");
10
+ const ide_core_common_2 = require("@opensumi/ide-core-common");
11
+ class FileDecorationChangeEvent {
12
+ constructor() {
13
+ this._data = map_1.TernarySearchTree.forPaths();
14
+ }
15
+ affectsResource(uri) {
16
+ return this._data.get(uri.toString()) || this._data.findSuperstr(uri.toString()) !== undefined;
17
+ }
18
+ static debouncer(last, current) {
19
+ if (!last) {
20
+ last = new FileDecorationChangeEvent();
21
+ }
22
+ if (Array.isArray(current)) {
23
+ // many
24
+ for (const uri of current) {
25
+ last._data.set(uri.toString(), true);
26
+ }
27
+ }
28
+ else {
29
+ // one
30
+ last._data.set(current.toString(), true);
31
+ }
32
+ return last;
33
+ }
34
+ }
35
+ class DecorationDataRequest {
36
+ constructor(source, thenable) {
37
+ this.source = source;
38
+ this.thenable = thenable;
39
+ }
40
+ }
41
+ class DecorationProviderWrapper {
42
+ constructor(_provider, _uriEmitter, _flushEmitter) {
43
+ this._provider = _provider;
44
+ this._uriEmitter = _uriEmitter;
45
+ this._flushEmitter = _flushEmitter;
46
+ this.data = map_1.TernarySearchTree.forPaths();
47
+ this._dispoable = this._provider.onDidChange((uris) => {
48
+ if (!uris) {
49
+ // flush event -> drop all data, can affect everything
50
+ this.data.clear();
51
+ this._flushEmitter.fire({ affectsResource() { return true; } });
52
+ }
53
+ else {
54
+ // selective changes -> drop for resource, fetch again, send event
55
+ // perf: the map stores thenables, decorations, or `null`-markers.
56
+ // we make us of that and ignore all uris in which we have never
57
+ // been interested.
58
+ for (const uri of uris) {
59
+ this._fetchData(uri);
60
+ }
61
+ }
62
+ });
63
+ }
64
+ dispose() {
65
+ this._dispoable.dispose();
66
+ this.data.clear();
67
+ }
68
+ knowsAbout(uri) {
69
+ return Boolean(this.data.get(uri.toString())) || Boolean(this.data.findSuperstr(uri.toString()));
70
+ }
71
+ getOrRetrieve(uri, includeChildren, callback) {
72
+ const key = uri.toString();
73
+ let item = this.data.get(key);
74
+ if (item === undefined) {
75
+ // unknown -> trigger request
76
+ item = this._fetchData(uri);
77
+ }
78
+ if (item && !(item instanceof DecorationDataRequest)) {
79
+ // found something (which isn't pending anymore)
80
+ callback(item, false);
81
+ }
82
+ if (includeChildren) {
83
+ // (resolved) children
84
+ const iter = this.data.findSuperstr(key);
85
+ if (iter) {
86
+ for (let item = iter.next(); !item.done; item = iter.next()) {
87
+ if (item.value && !(item.value instanceof DecorationDataRequest)) {
88
+ callback(item.value, true);
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ _fetchData(uri) {
95
+ // check for pending request and cancel it
96
+ const pendingRequest = this.data.get(uri.toString());
97
+ if (pendingRequest instanceof DecorationDataRequest) {
98
+ pendingRequest.source.cancel();
99
+ this.data.delete(uri.toString());
100
+ }
101
+ const source = new ide_core_common_1.CancellationTokenSource();
102
+ const dataOrThenable = this._provider.provideDecorations(uri, source.token);
103
+ if (!(0, ide_core_common_1.isThenable)(dataOrThenable)) {
104
+ // sync -> we have a result now
105
+ return this._keepItem(uri, dataOrThenable);
106
+ }
107
+ else {
108
+ // async -> we have a result soon
109
+ const request = new DecorationDataRequest(source, Promise.resolve(dataOrThenable).then((data) => {
110
+ if (this.data.get(uri.toString()) === request) {
111
+ this._keepItem(uri, data);
112
+ }
113
+ }).catch((err) => {
114
+ if (!(0, errors_1.isPromiseCanceledError)(err) && this.data.get(uri.toString()) === request) {
115
+ this.data.delete(uri.toString());
116
+ }
117
+ }));
118
+ this.data.set(uri.toString(), request);
119
+ return null;
120
+ }
121
+ }
122
+ _keepItem(uri, data) {
123
+ const deco = data ? data : null;
124
+ const old = this.data.set(uri.toString(), deco);
125
+ if (deco || old) {
126
+ // only fire event when something changed
127
+ this._uriEmitter.fire(uri);
128
+ }
129
+ return deco;
130
+ }
131
+ }
132
+ // 将 IDecorationData 转成 `${color}/${letter}` 形式
133
+ function keyOfDecorationRule(data) {
134
+ const list = (0, ide_core_common_2.asArray)(data);
135
+ return list.map(({ color, letter }) => `${color}/${letter}`).join(',');
136
+ }
137
+ function getDecorationRule(data) {
138
+ const list = (0, ide_core_common_2.asArray)(data);
139
+ if (!list.length) {
140
+ // 前置拦截(目前代码逻辑是不会进来的)
141
+ /* istanbul ignore next */
142
+ return;
143
+ }
144
+ return {
145
+ // 获取 color/letter 生成的 唯一键 key
146
+ key: keyOfDecorationRule(data),
147
+ // label
148
+ color: list[0].color,
149
+ // badge
150
+ badge: list.filter((d) => !(0, ide_core_common_2.isFalsyOrWhitespace)(d.letter)).map((d) => d.letter).join(','),
151
+ tooltip: list.filter((d) => !(0, ide_core_common_2.isFalsyOrWhitespace)(d.tooltip)).map((d) => d.tooltip).join(' • '),
152
+ };
153
+ }
154
+ let FileDecorationsService = class FileDecorationsService extends ide_core_common_1.Disposable {
155
+ constructor() {
156
+ super(...arguments);
157
+ this.logger = (0, ide_core_common_2.getDebugLogger)();
158
+ this._data = new linked_list_1.LinkedList();
159
+ this._onDidChangeDecorationsDelayed = new ide_core_common_1.Emitter();
160
+ this._onDidChangeDecorations = new ide_core_common_1.Emitter();
161
+ this.onDidChangeDecorations = ide_core_common_1.Event.any(this._onDidChangeDecorations.event, ide_core_common_1.Event.debounce(this._onDidChangeDecorationsDelayed.event, FileDecorationChangeEvent.debouncer, // todo: remove it
162
+ undefined, undefined, 500));
163
+ }
164
+ dispose() {
165
+ (0, ide_core_common_1.dispose)(this._onDidChangeDecorations);
166
+ (0, ide_core_common_1.dispose)(this._onDidChangeDecorationsDelayed);
167
+ }
168
+ registerDecorationsProvider(provider) {
169
+ this.logger.log('DecorationService#registerDecorationsProvider', provider);
170
+ const wrapper = new DecorationProviderWrapper(provider, this._onDidChangeDecorationsDelayed, this._onDidChangeDecorations);
171
+ const remove = this._data.push(wrapper);
172
+ this._onDidChangeDecorations.fire({
173
+ // everything might have changed
174
+ affectsResource() { return true; },
175
+ });
176
+ return (0, ide_core_common_1.toDisposable)(() => {
177
+ // fire event that says 'yes' for any resource
178
+ // known to this provider. then dispose and remove it.
179
+ remove();
180
+ this._onDidChangeDecorations.fire({ affectsResource: (uri) => wrapper.knowsAbout(uri) });
181
+ wrapper.dispose();
182
+ });
183
+ }
184
+ getDecoration(uri, includeChildren) {
185
+ const data = [];
186
+ let containsChildren = false;
187
+ for (let iter = this._data.iterator(), next = iter.next(); !next.done; next = iter.next()) {
188
+ next.value.getOrRetrieve(uri, includeChildren, (deco, isChild) => {
189
+ if (!isChild || deco.bubble) {
190
+ data.push(deco);
191
+ containsChildren = isChild || containsChildren;
192
+ }
193
+ });
194
+ }
195
+ if (data.length === 0) {
196
+ return undefined;
197
+ }
198
+ else {
199
+ const result = this.asDecoration(data, containsChildren);
200
+ return result;
201
+ }
202
+ }
203
+ asDecoration(data, containsChildren) {
204
+ // sort by weight
205
+ data.sort((a, b) => (b.weight || 0) - (a.weight || 0));
206
+ const rule = getDecorationRule(data);
207
+ if (rule && containsChildren) {
208
+ // 目录下文件修改过则仅显示一个圆点并统一 tooltip
209
+ // show items from its children only
210
+ rule.badge = '•';
211
+ rule.tooltip = (0, ide_core_common_1.localize)('bubbleTitle', 'Contains emphasized items');
212
+ }
213
+ return rule;
214
+ }
215
+ };
216
+ FileDecorationsService = (0, tslib_1.__decorate)([
217
+ (0, di_1.Injectable)()
218
+ ], FileDecorationsService);
219
+ exports.FileDecorationsService = FileDecorationsService;
220
+ //# sourceMappingURL=decorationsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorationsService.js","sourceRoot":"","sources":["../../src/browser/decorationsService.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAC1C,+DAA+J;AAC/J,iEAA8E;AAC9E,2DAAsE;AACtE,2EAAuE;AACvE,+DAAyF;AAOzF,MAAM,yBAAyB;IAA/B;QAEmB,UAAK,GAAG,uBAAiB,CAAC,QAAQ,EAAW,CAAC;IAsBjE,CAAC;IApBC,eAAe,CAAC,GAAQ;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,SAAS,CAAC;IACjG,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAA+B,EAAE,OAAoB;QACpE,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,yBAAyB,EAAE,CAAC;SACxC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1B,OAAO;YACP,KAAK,MAAM,GAAG,IAAI,O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,gBAAgB,CAAC,CAAC;YACzD,OAAO,MAAM,CAAC;SACf;IACH,CAAC;IAED,YAAY,CAAC,IAAuB,EAAE,gBAAyB;QAC7D,iBAAiB;QACjB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACvD,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAErC,IAAI,IAAI,IAAI,gBAAgB,EAAE;YAC5B,8BAA8B;YAC9B,oCAAoC;YACpC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;YACjB,IAAI,CAAC,OAAO,GAAG,IAAA,0BAAQ,EAAC,aAAa,EAAE,2BAA2B,CAAC,CAAC;SACrE;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AA/EY,sBAAsB;IADlC,IAAA,eAAU,GAAE;GACA,sBAAsB,CA+ElC;AA/EY,wDAAsB"}
@@ -0,0 +1,6 @@
1
+ import { Provider } from '@opensumi/di';
2
+ import { BrowserModule } from '@opensumi/ide-core-browser';
3
+ export declare class DecorationModule extends BrowserModule {
4
+ providers: Provider[];
5
+ }
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAK3D,qBACa,gBAAiB,SAAQ,aAAa;IACjD,SAAS,EAAE,QAAQ,EAAE,CAKnB;CACH"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecorationModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const ide_core_browser_1 = require("@opensumi/ide-core-browser");
7
+ const decorations_1 = require("../common/decorations");
8
+ const decorationsService_1 = require("./decorationsService");
9
+ let DecorationModule = class DecorationModule extends ide_core_browser_1.BrowserModule {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.providers = [
13
+ {
14
+ token: decorations_1.IDecorationsService,
15
+ useClass: decorationsService_1.FileDecorationsService,
16
+ },
17
+ ];
18
+ }
19
+ };
20
+ DecorationModule = (0, tslib_1.__decorate)([
21
+ (0, di_1.Injectable)()
22
+ ], DecorationModule);
23
+ exports.DecorationModule = DecorationModule;
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,iEAA2D;AAE3D,uDAA4D;AAC5D,6DAA8D;AAG9D,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,gCAAa;IAAnD;;QACE,cAAS,GAAe;YACtB;gBACE,KAAK,EAAE,iCAAmB;gBAC1B,QAAQ,EAAE,2CAAsB;aACjC;SACF,CAAC;IACJ,CAAC;CAAA,CAAA;AAPY,gBAAgB;IAD5B,IAAA,eAAU,GAAE;GACA,gBAAgB,CAO5B;AAPY,4CAAgB"}
@@ -0,0 +1,54 @@
1
+ import { Disposable, Uri, Event, CancellationToken, IDisposable } from '@opensumi/ide-core-common';
2
+ declare type ColorIdentifier = string;
3
+ export interface IDecorationData {
4
+ /**
5
+ * 权重
6
+ */
7
+ readonly weight?: number;
8
+ /**
9
+ * Decoration 颜色
10
+ */
11
+ readonly color?: ColorIdentifier;
12
+ /**
13
+ * Decoration 字符
14
+ */
15
+ readonly letter?: string;
16
+ /**
17
+ * Decoration tooltip
18
+ */
19
+ readonly tooltip?: string;
20
+ /**
21
+ * Decoration 是否冒泡,类似文件的 Decoration 是否传给文件夹
22
+ */
23
+ readonly bubble?: boolean;
24
+ }
25
+ export interface IDecorationsProvider {
26
+ readonly label: string;
27
+ readonly onDidChange: Event<Uri[]>;
28
+ provideDecorations(uri: Uri, token: CancellationToken): IDecorationData | Promise<IDecorationData | undefined> | undefined;
29
+ }
30
+ export interface IResourceDecorationChangeEvent {
31
+ affectsResource(uri: Uri): boolean;
32
+ }
33
+ export interface IDecoration {
34
+ key: string;
35
+ badge: string;
36
+ tooltip: string;
37
+ color?: string;
38
+ }
39
+ export declare abstract class IDecorationsService extends Disposable {
40
+ /**
41
+ * 分发 Decoration Change Event
42
+ */
43
+ readonly onDidChangeDecorations: Event<IResourceDecorationChangeEvent>;
44
+ /**
45
+ * 注册 Decoration Provider
46
+ */
47
+ abstract registerDecorationsProvider(provider: IDecorationsProvider): IDisposable;
48
+ /**
49
+ * 通过传入 Uri 和选项获取 Decoration 数据
50
+ */
51
+ abstract getDecoration(uri: Uri, includeChildren: boolean, overwrite?: IDecorationData): IDecoration | undefined;
52
+ }
53
+ export {};
54
+ //# sourceMappingURL=decorations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorations.d.ts","sourceRoot":"","sources":["../../src/common/decorations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAEnG,aAAK,eAAe,GAAG,MAAM,CAAC;AAE9B,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACnC,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,iBAAiB,GAAG,eAAe,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CAC5H;AAED,MAAM,WAAW,8BAA8B;IAC7C,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,8BAAsB,mBAAoB,SAAQ,UAAU;IAC1D;;OAEG;IACH,QAAQ,CAAC,sBAAsB,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAEvE;;OAEG;IACH,QAAQ,CAAC,2BAA2B,CAAC,QAAQ,EAAE,oBAAoB,GAAG,WAAW;IAEjF;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,SAAS;CACjH"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IDecorationsService = void 0;
4
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
5
+ class IDecorationsService extends ide_core_common_1.Disposable {
6
+ }
7
+ exports.IDecorationsService = IDecorationsService;
8
+ //# sourceMappingURL=decorations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorations.js","sourceRoot":"","sources":["../../src/common/decorations.ts"],"names":[],"mappings":";;;AAAA,+DAAmG;AA4CnG,MAAsB,mBAAoB,SAAQ,4BAAU;CAe3D;AAfD,kDAeC"}
@@ -0,0 +1,2 @@
1
+ export * from './decorations';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./decorations"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,6DAA8B"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './common';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./common"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAAyB"}
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@opensumi/ide-decoration",
3
+ "version": "2.12.1-next-079c1930",
4
+ "files": [
5
+ "lib"
6
+ ],
7
+ "license": "MIT",
8
+ "main": "lib/index.js",
9
+ "typings": "lib/index.d.ts",
10
+ "scripts": {
11
+ "prepublishOnly": "npm run build",
12
+ "build": "tsc --build ../../configs/ts/references/tsconfig.decoration.json"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git@github.com:opensumi/core.git"
17
+ },
18
+ "dependencies": {
19
+ "@opensumi/ide-core-common": "2.12.1-next-079c1930",
20
+ "@opensumi/ide-core-node": "2.12.1-next-079c1930"
21
+ },
22
+ "devDependencies": {
23
+ "@opensumi/ide-core-browser": "2.12.1-next-079c1930",
24
+ "@opensumi/ide-dev-tool": "^1.3.1"
25
+ }
26
+ }