@codingame/monaco-vscode-api 1.80.2 → 1.80.3

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.
@@ -0,0 +1,18 @@
1
+ import { IDisposable } from '../vscode/vs/base/common/lifecycle.js';
2
+ import { IStorageItemsChangeEvent } from '../vscode/vs/base/parts/storage/common/storage.js';
3
+ import { IEditorOverrideServices } from '../vscode/vs/editor/standalone/browser/standaloneServices.js';
4
+
5
+ declare enum StorageScope {
6
+ APPLICATION = -1,
7
+ PROFILE = 0,
8
+ WORKSPACE = 1
9
+ }
10
+ interface IStorageProvider {
11
+ read(scope: StorageScope): Map<string, string> | undefined;
12
+ write(scope: StorageScope, data: Map<string, string>): Promise<void>;
13
+ close?(scope: StorageScope): Promise<void>;
14
+ onDidChange?(listener: (event: IStorageItemsChangeEvent) => void): IDisposable;
15
+ }
16
+ declare function getStorageServiceOverride(provider: IStorageProvider): IEditorOverrideServices;
17
+
18
+ export { IStorageItemsChangeEvent, IStorageProvider, StorageScope, getStorageServiceOverride as default };
@@ -0,0 +1,87 @@
1
+ import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
2
+ import { Storage } from 'monaco-editor/esm/vs/base/parts/storage/common/storage.js';
3
+ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
4
+ import { IStorageService, AbstractStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
5
+ var StorageScope;
6
+ ( (function(StorageScope) {
7
+ StorageScope[StorageScope["APPLICATION"] = -1] = "APPLICATION";
8
+ StorageScope[StorageScope["PROFILE"] = 0] = "PROFILE";
9
+ StorageScope[StorageScope["WORKSPACE"] = 1] = "WORKSPACE";
10
+ })(StorageScope || (StorageScope = {})));
11
+ class ExternalStorage extends Storage {
12
+ constructor(scope, provider) {
13
+ const items = provider.read(scope);
14
+ super(new ExternalStorageDatabase(scope, provider, items));
15
+ if (items != null) {
16
+ for (const [key, value] of items) {
17
+ this.items.set(key, value);
18
+ }
19
+ }
20
+ }
21
+ }
22
+ class ExternalStorageDatabase {
23
+ constructor(scope, provider, items = new Map()) {
24
+ this.scope = scope;
25
+ this.provider = provider;
26
+ this.items = items;
27
+ this.onDidChangeItemsExternal = this.provider.onDidChange ?? Event.None;
28
+ }
29
+ async getItems() {
30
+ return this.items;
31
+ }
32
+ async updateItems(request) {
33
+ request.insert?.forEach((value, key) => this.items.set(key, value));
34
+ request.delete?.forEach(key => this.items.delete(key));
35
+ await this.provider.write(this.scope, this.items);
36
+ }
37
+ async close() {
38
+ return this.provider.close?.(this.scope);
39
+ }
40
+ }
41
+ class ExternalStorageService extends AbstractStorageService {
42
+ constructor(provider) {
43
+ super();
44
+ this.provider = provider;
45
+ this.applicationStorage = this._register(new ExternalStorage(StorageScope.APPLICATION, this.provider));
46
+ this.profileStorage = this._register(new ExternalStorage(StorageScope.PROFILE, this.provider));
47
+ this.workspaceStorage = this._register(new ExternalStorage(StorageScope.WORKSPACE, this.provider));
48
+ this._register(this.workspaceStorage.onDidChangeStorage(key => this.emitDidChangeValue(1 , key)));
49
+ this._register(this.profileStorage.onDidChangeStorage(key => this.emitDidChangeValue(0 , key)));
50
+ this._register(this.applicationStorage.onDidChangeStorage(key => this.emitDidChangeValue(-1 , key)));
51
+ }
52
+ getStorage(scope) {
53
+ switch (scope) {
54
+ case -1 :
55
+ return this.applicationStorage;
56
+ case 0 :
57
+ return this.profileStorage;
58
+ default:
59
+ return this.workspaceStorage;
60
+ }
61
+ }
62
+ getLogDetails(scope) {
63
+ switch (scope) {
64
+ case -1 :
65
+ return 'External (application)';
66
+ case 0 :
67
+ return 'External (profile)';
68
+ default:
69
+ return 'External (workspace)';
70
+ }
71
+ }
72
+ async doInitialize() {
73
+ }
74
+ async switchToProfile() {
75
+ }
76
+ async switchToWorkspace() {
77
+ }
78
+ hasScope(_scope) {
79
+ return false;
80
+ }
81
+ }
82
+ function getStorageServiceOverride(provider) {
83
+ return {
84
+ [( IStorageService.toString())]: new SyncDescriptor(ExternalStorageService, [provider])
85
+ };
86
+ }
87
+ export { StorageScope, getStorageServiceOverride as default };
@@ -1,3 +1,7 @@
1
+ interface IStorageItemsChangeEvent {
2
+ readonly changed?: Map<string, string>;
3
+ readonly deleted?: Set<string>;
4
+ }
1
5
  type StorageValue = string | boolean | number | undefined | null | object;
2
6
 
3
- export { StorageValue };
7
+ export { IStorageItemsChangeEvent, StorageValue };