@theia/preferences 1.45.0 → 1.46.0-next.72
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 +81 -81
- package/lib/browser/abstract-resource-preference-provider.d.ts +47 -47
- package/lib/browser/abstract-resource-preference-provider.js +240 -240
- package/lib/browser/abstract-resource-preference-provider.spec.d.ts +1 -1
- package/lib/browser/abstract-resource-preference-provider.spec.js +83 -83
- package/lib/browser/folder-preference-provider.d.ts +20 -20
- package/lib/browser/folder-preference-provider.js +59 -59
- package/lib/browser/folders-preferences-provider.d.ts +27 -27
- package/lib/browser/folders-preferences-provider.js +245 -245
- package/lib/browser/index.d.ts +7 -7
- package/lib/browser/index.js +34 -34
- package/lib/browser/monaco-jsonc-editor.d.ts +9 -9
- package/lib/browser/monaco-jsonc-editor.js +80 -80
- package/lib/browser/package.spec.js +25 -25
- package/lib/browser/preference-bindings.d.ts +4 -4
- package/lib/browser/preference-bindings.js +63 -63
- package/lib/browser/preference-frontend-module.d.ts +6 -6
- package/lib/browser/preference-frontend-module.js +52 -52
- package/lib/browser/preference-open-handler.d.ts +9 -9
- package/lib/browser/preference-open-handler.js +64 -64
- package/lib/browser/preference-transaction-manager.d.ts +100 -100
- package/lib/browser/preference-transaction-manager.js +293 -293
- package/lib/browser/preference-tree-model.d.ts +60 -60
- package/lib/browser/preference-tree-model.js +243 -243
- package/lib/browser/preferences-contribution.d.ts +37 -37
- package/lib/browser/preferences-contribution.js +280 -280
- package/lib/browser/preferences-json-schema-contribution.d.ts +17 -17
- package/lib/browser/preferences-json-schema-contribution.js +91 -91
- package/lib/browser/preferences-monaco-contribution.d.ts +1 -1
- package/lib/browser/preferences-monaco-contribution.js +27 -27
- package/lib/browser/section-preference-provider.d.ts +21 -21
- package/lib/browser/section-preference-provider.js +96 -96
- package/lib/browser/user-configs-preference-provider.d.ts +22 -22
- package/lib/browser/user-configs-preference-provider.js +137 -137
- package/lib/browser/user-preference-provider.d.ts +13 -13
- package/lib/browser/user-preference-provider.js +41 -41
- package/lib/browser/util/preference-scope-command-manager.d.ts +17 -17
- package/lib/browser/util/preference-scope-command-manager.js +87 -87
- package/lib/browser/util/preference-tree-generator.d.ts +31 -31
- package/lib/browser/util/preference-tree-generator.js +237 -237
- package/lib/browser/util/preference-tree-label-provider.d.ts +11 -11
- package/lib/browser/util/preference-tree-label-provider.js +77 -77
- package/lib/browser/util/preference-tree-label-provider.spec.d.ts +1 -1
- package/lib/browser/util/preference-tree-label-provider.spec.js +87 -87
- package/lib/browser/util/preference-types.d.ts +62 -62
- package/lib/browser/util/preference-types.js +128 -128
- package/lib/browser/views/components/preference-array-input.d.ts +28 -28
- package/lib/browser/views/components/preference-array-input.js +180 -180
- package/lib/browser/views/components/preference-boolean-input.d.ts +17 -17
- package/lib/browser/views/components/preference-boolean-input.js +79 -79
- package/lib/browser/views/components/preference-file-input.d.ts +29 -29
- package/lib/browser/views/components/preference-file-input.js +110 -110
- package/lib/browser/views/components/preference-json-input.d.ts +19 -19
- package/lib/browser/views/components/preference-json-input.js +93 -93
- package/lib/browser/views/components/preference-markdown-renderer.d.ts +12 -12
- package/lib/browser/views/components/preference-markdown-renderer.js +81 -81
- package/lib/browser/views/components/preference-node-renderer-creator.d.ts +48 -48
- package/lib/browser/views/components/preference-node-renderer-creator.js +132 -132
- package/lib/browser/views/components/preference-node-renderer.d.ts +112 -112
- package/lib/browser/views/components/preference-node-renderer.js +441 -441
- package/lib/browser/views/components/preference-number-input.d.ts +34 -34
- package/lib/browser/views/components/preference-number-input.js +142 -142
- package/lib/browser/views/components/preference-select-input.d.ts +28 -28
- package/lib/browser/views/components/preference-select-input.js +138 -138
- package/lib/browser/views/components/preference-string-input.d.ts +17 -17
- package/lib/browser/views/components/preference-string-input.js +89 -89
- package/lib/browser/views/preference-editor-widget.d.ts +67 -67
- package/lib/browser/views/preference-editor-widget.js +363 -363
- package/lib/browser/views/preference-scope-tabbar-widget.d.ts +54 -54
- package/lib/browser/views/preference-scope-tabbar-widget.js +343 -343
- package/lib/browser/views/preference-searchbar-widget.d.ts +53 -53
- package/lib/browser/views/preference-searchbar-widget.js +173 -173
- package/lib/browser/views/preference-tree-widget.d.ts +17 -17
- package/lib/browser/views/preference-tree-widget.js +104 -104
- package/lib/browser/views/preference-widget-bindings.d.ts +3 -3
- package/lib/browser/views/preference-widget-bindings.js +87 -87
- package/lib/browser/views/preference-widget.d.ts +36 -36
- package/lib/browser/views/preference-widget.js +126 -126
- package/lib/browser/workspace-file-preference-provider.d.ts +23 -23
- package/lib/browser/workspace-file-preference-provider.js +110 -110
- package/lib/browser/workspace-preference-provider.d.ts +28 -28
- package/lib/browser/workspace-preference-provider.js +142 -142
- package/package.json +10 -10
- package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
- package/src/browser/abstract-resource-preference-provider.ts +232 -232
- package/src/browser/folder-preference-provider.ts +58 -58
- package/src/browser/folders-preferences-provider.ts +244 -244
- package/src/browser/index.ts +23 -23
- package/src/browser/monaco-jsonc-editor.ts +67 -67
- package/src/browser/package.spec.ts +28 -28
- package/src/browser/preference-bindings.ts +65 -65
- package/src/browser/preference-frontend-module.ts +57 -57
- package/src/browser/preference-open-handler.ts +53 -53
- package/src/browser/preference-transaction-manager.ts +287 -287
- package/src/browser/preference-tree-model.ts +250 -250
- package/src/browser/preferences-contribution.ts +263 -263
- package/src/browser/preferences-json-schema-contribution.ts +86 -86
- package/src/browser/preferences-monaco-contribution.ts +27 -27
- package/src/browser/section-preference-provider.ts +83 -83
- package/src/browser/style/index.css +506 -506
- package/src/browser/style/preference-array.css +94 -94
- package/src/browser/style/preference-context-menu.css +74 -74
- package/src/browser/style/preference-file.css +31 -31
- package/src/browser/style/preference-object.css +49 -49
- package/src/browser/style/search-input.css +66 -66
- package/src/browser/user-configs-preference-provider.ts +127 -127
- package/src/browser/user-preference-provider.ts +35 -35
- package/src/browser/util/preference-scope-command-manager.ts +75 -75
- package/src/browser/util/preference-tree-generator.ts +226 -226
- package/src/browser/util/preference-tree-label-provider.spec.ts +108 -108
- package/src/browser/util/preference-tree-label-provider.ts +64 -64
- package/src/browser/util/preference-types.ts +169 -169
- package/src/browser/views/components/preference-array-input.ts +174 -174
- package/src/browser/views/components/preference-boolean-input.ts +69 -69
- package/src/browser/views/components/preference-file-input.ts +104 -104
- package/src/browser/views/components/preference-json-input.ts +78 -78
- package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
- package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
- package/src/browser/views/components/preference-node-renderer.ts +477 -477
- package/src/browser/views/components/preference-number-input.ts +147 -147
- package/src/browser/views/components/preference-select-input.ts +131 -131
- package/src/browser/views/components/preference-string-input.ts +76 -76
- package/src/browser/views/preference-editor-widget.ts +349 -349
- package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
- package/src/browser/views/preference-searchbar-widget.tsx +183 -183
- package/src/browser/views/preference-tree-widget.tsx +93 -93
- package/src/browser/views/preference-widget-bindings.ts +102 -102
- package/src/browser/views/preference-widget.tsx +117 -117
- package/src/browser/workspace-file-preference-provider.ts +100 -100
- package/src/browser/workspace-preference-provider.ts +134 -134
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2022 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.PreferenceOpenHandler = void 0;
|
|
28
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
29
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
30
|
-
const preferences_contribution_1 = require("./preferences-contribution");
|
|
31
|
-
let PreferenceOpenHandler = class PreferenceOpenHandler {
|
|
32
|
-
constructor() {
|
|
33
|
-
this.id = 'preference';
|
|
34
|
-
}
|
|
35
|
-
canHandle(uri) {
|
|
36
|
-
return uri.scheme === this.id ? 500 : -1;
|
|
37
|
-
}
|
|
38
|
-
async open(uri) {
|
|
39
|
-
const preferencesWidget = await this.preferencesContribution.openView();
|
|
40
|
-
const selector = `li[data-pref-id="${uri.path.toString()}"]:not([data-node-id^="commonly-used@"])`;
|
|
41
|
-
const element = document.querySelector(selector);
|
|
42
|
-
if (element instanceof HTMLElement) {
|
|
43
|
-
if (element.classList.contains('hidden')) {
|
|
44
|
-
// We clear the search term as we have clicked on a hidden preference
|
|
45
|
-
await preferencesWidget.setSearchTerm('');
|
|
46
|
-
await (0, browser_1.animationFrame)();
|
|
47
|
-
}
|
|
48
|
-
element.scrollIntoView({
|
|
49
|
-
block: 'center'
|
|
50
|
-
});
|
|
51
|
-
element.focus();
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
__decorate([
|
|
58
|
-
(0, inversify_1.inject)(preferences_contribution_1.PreferencesContribution),
|
|
59
|
-
__metadata("design:type", preferences_contribution_1.PreferencesContribution)
|
|
60
|
-
], PreferenceOpenHandler.prototype, "preferencesContribution", void 0);
|
|
61
|
-
PreferenceOpenHandler = __decorate([
|
|
62
|
-
(0, inversify_1.injectable)()
|
|
63
|
-
], PreferenceOpenHandler);
|
|
64
|
-
exports.PreferenceOpenHandler = PreferenceOpenHandler;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2022 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.PreferenceOpenHandler = void 0;
|
|
28
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
29
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
30
|
+
const preferences_contribution_1 = require("./preferences-contribution");
|
|
31
|
+
let PreferenceOpenHandler = class PreferenceOpenHandler {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.id = 'preference';
|
|
34
|
+
}
|
|
35
|
+
canHandle(uri) {
|
|
36
|
+
return uri.scheme === this.id ? 500 : -1;
|
|
37
|
+
}
|
|
38
|
+
async open(uri) {
|
|
39
|
+
const preferencesWidget = await this.preferencesContribution.openView();
|
|
40
|
+
const selector = `li[data-pref-id="${uri.path.toString()}"]:not([data-node-id^="commonly-used@"])`;
|
|
41
|
+
const element = document.querySelector(selector);
|
|
42
|
+
if (element instanceof HTMLElement) {
|
|
43
|
+
if (element.classList.contains('hidden')) {
|
|
44
|
+
// We clear the search term as we have clicked on a hidden preference
|
|
45
|
+
await preferencesWidget.setSearchTerm('');
|
|
46
|
+
await (0, browser_1.animationFrame)();
|
|
47
|
+
}
|
|
48
|
+
element.scrollIntoView({
|
|
49
|
+
block: 'center'
|
|
50
|
+
});
|
|
51
|
+
element.focus();
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, inversify_1.inject)(preferences_contribution_1.PreferencesContribution),
|
|
59
|
+
__metadata("design:type", preferences_contribution_1.PreferencesContribution)
|
|
60
|
+
], PreferenceOpenHandler.prototype, "preferencesContribution", void 0);
|
|
61
|
+
PreferenceOpenHandler = __decorate([
|
|
62
|
+
(0, inversify_1.injectable)()
|
|
63
|
+
], PreferenceOpenHandler);
|
|
64
|
+
exports.PreferenceOpenHandler = PreferenceOpenHandler;
|
|
65
65
|
//# sourceMappingURL=preference-open-handler.js.map
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import { Emitter, Event, MaybePromise, MessageService, WaitUntilEvent } from '@theia/core';
|
|
2
|
-
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
3
|
-
import { interfaces } from '@theia/core/shared/inversify';
|
|
4
|
-
import { PreferenceScope } from '@theia/core/lib/common/preferences/preference-scope';
|
|
5
|
-
import URI from '@theia/core/lib/common/uri';
|
|
6
|
-
import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
|
|
7
|
-
import { Mutex } from 'async-mutex';
|
|
8
|
-
import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
|
9
|
-
import { MonacoJSONCEditor } from './monaco-jsonc-editor';
|
|
10
|
-
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
11
|
-
import { IReference } from '@theia/monaco-editor-core/esm/vs/base/common/lifecycle';
|
|
12
|
-
export interface OnWillConcludeEvent<T> extends WaitUntilEvent {
|
|
13
|
-
status: T | false;
|
|
14
|
-
}
|
|
15
|
-
export declare abstract class Transaction<Arguments extends unknown[], Result = unknown, Status = unknown> {
|
|
16
|
-
protected _open: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether the transaction is still accepting new interactions.
|
|
19
|
-
* Enqueueing an action when the Transaction is no longer open will throw an error.
|
|
20
|
-
*/
|
|
21
|
-
get open(): boolean;
|
|
22
|
-
protected _result: Deferred<false | Result>;
|
|
23
|
-
/**
|
|
24
|
-
* The status of the transaction when complete.
|
|
25
|
-
*/
|
|
26
|
-
get result(): Promise<Result | false>;
|
|
27
|
-
/**
|
|
28
|
-
* The transaction will self-dispose when the queue is empty, once at least one action has been processed.
|
|
29
|
-
*/
|
|
30
|
-
protected readonly queue: Mutex;
|
|
31
|
-
protected readonly onWillConcludeEmitter: Emitter<OnWillConcludeEvent<Status>>;
|
|
32
|
-
/**
|
|
33
|
-
* An event fired when the transaction is wrapping up.
|
|
34
|
-
* Consumers can call `waitUntil` on the event to delay the resolution of the `result` Promise.
|
|
35
|
-
*/
|
|
36
|
-
get onWillConclude(): Event<OnWillConcludeEvent<Status>>;
|
|
37
|
-
protected status: Deferred<Status>;
|
|
38
|
-
/**
|
|
39
|
-
* Whether any actions have been added to the transaction.
|
|
40
|
-
* The Transaction will not self-dispose until at least one action has been performed.
|
|
41
|
-
*/
|
|
42
|
-
protected inUse: boolean;
|
|
43
|
-
protected init(): void;
|
|
44
|
-
protected doInit(): Promise<void>;
|
|
45
|
-
waitFor(delay?: Promise<unknown>, disposeIfRejected?: boolean): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* @returns a promise reflecting the result of performing an action. Typically the promise will not resolve until the whole transaction is complete.
|
|
48
|
-
*/
|
|
49
|
-
enqueueAction(...args: Arguments): Promise<Result | false>;
|
|
50
|
-
protected disposeWhenDone(): void;
|
|
51
|
-
protected conclude(): Promise<void>;
|
|
52
|
-
dispose(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Runs any code necessary to initialize the batch of interactions. No interaction will be run until the setup is complete.
|
|
55
|
-
*
|
|
56
|
-
* @returns a representation of the success of setup specific to a given transaction implementation.
|
|
57
|
-
*/
|
|
58
|
-
protected abstract setUp(): MaybePromise<Status>;
|
|
59
|
-
/**
|
|
60
|
-
* Performs a single interaction
|
|
61
|
-
*
|
|
62
|
-
* @returns the result of that interaction, specific to a given transaction type.
|
|
63
|
-
*/
|
|
64
|
-
protected abstract act(...args: Arguments): MaybePromise<Result>;
|
|
65
|
-
/**
|
|
66
|
-
* Runs any code necessary to complete a transaction and release any resources it holds.
|
|
67
|
-
*
|
|
68
|
-
* @returns implementation-specific information about the success of the transaction. Will be used as the final status of the transaction.
|
|
69
|
-
*/
|
|
70
|
-
protected abstract tearDown(): MaybePromise<Result>;
|
|
71
|
-
}
|
|
72
|
-
export interface PreferenceContext {
|
|
73
|
-
getConfigUri(): URI;
|
|
74
|
-
getScope(): PreferenceScope;
|
|
75
|
-
}
|
|
76
|
-
export declare const PreferenceContext: unique symbol;
|
|
77
|
-
export declare const PreferenceTransactionPreludeProvider: unique symbol;
|
|
78
|
-
export declare type PreferenceTransactionPreludeProvider = () => Promise<unknown>;
|
|
79
|
-
export declare class PreferenceTransaction extends Transaction<[string, string[], unknown], boolean> {
|
|
80
|
-
reference: IReference<MonacoEditorModel> | undefined;
|
|
81
|
-
protected readonly context: PreferenceContext;
|
|
82
|
-
protected readonly prelude?: PreferenceTransactionPreludeProvider;
|
|
83
|
-
protected readonly textModelService: MonacoTextModelService;
|
|
84
|
-
protected readonly jsoncEditor: MonacoJSONCEditor;
|
|
85
|
-
protected readonly messageService: MessageService;
|
|
86
|
-
protected readonly editorManager: EditorManager;
|
|
87
|
-
protected doInit(): Promise<void>;
|
|
88
|
-
protected setUp(): Promise<boolean>;
|
|
89
|
-
/**
|
|
90
|
-
* @returns whether the setting operation in progress, and any others started in the meantime, should continue.
|
|
91
|
-
*/
|
|
92
|
-
protected handleDirtyEditor(): Promise<boolean>;
|
|
93
|
-
protected act(key: string, path: string[], value: unknown): Promise<boolean>;
|
|
94
|
-
protected tearDown(): Promise<boolean>;
|
|
95
|
-
}
|
|
96
|
-
export interface PreferenceTransactionFactory {
|
|
97
|
-
(context: PreferenceContext, waitFor?: Promise<unknown>): PreferenceTransaction;
|
|
98
|
-
}
|
|
99
|
-
export declare const PreferenceTransactionFactory: unique symbol;
|
|
100
|
-
export declare const preferenceTransactionFactoryCreator: interfaces.FactoryCreator<PreferenceTransaction>;
|
|
1
|
+
import { Emitter, Event, MaybePromise, MessageService, WaitUntilEvent } from '@theia/core';
|
|
2
|
+
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
3
|
+
import { interfaces } from '@theia/core/shared/inversify';
|
|
4
|
+
import { PreferenceScope } from '@theia/core/lib/common/preferences/preference-scope';
|
|
5
|
+
import URI from '@theia/core/lib/common/uri';
|
|
6
|
+
import { MonacoEditorModel } from '@theia/monaco/lib/browser/monaco-editor-model';
|
|
7
|
+
import { Mutex } from 'async-mutex';
|
|
8
|
+
import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
|
9
|
+
import { MonacoJSONCEditor } from './monaco-jsonc-editor';
|
|
10
|
+
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
11
|
+
import { IReference } from '@theia/monaco-editor-core/esm/vs/base/common/lifecycle';
|
|
12
|
+
export interface OnWillConcludeEvent<T> extends WaitUntilEvent {
|
|
13
|
+
status: T | false;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class Transaction<Arguments extends unknown[], Result = unknown, Status = unknown> {
|
|
16
|
+
protected _open: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the transaction is still accepting new interactions.
|
|
19
|
+
* Enqueueing an action when the Transaction is no longer open will throw an error.
|
|
20
|
+
*/
|
|
21
|
+
get open(): boolean;
|
|
22
|
+
protected _result: Deferred<false | Result>;
|
|
23
|
+
/**
|
|
24
|
+
* The status of the transaction when complete.
|
|
25
|
+
*/
|
|
26
|
+
get result(): Promise<Result | false>;
|
|
27
|
+
/**
|
|
28
|
+
* The transaction will self-dispose when the queue is empty, once at least one action has been processed.
|
|
29
|
+
*/
|
|
30
|
+
protected readonly queue: Mutex;
|
|
31
|
+
protected readonly onWillConcludeEmitter: Emitter<OnWillConcludeEvent<Status>>;
|
|
32
|
+
/**
|
|
33
|
+
* An event fired when the transaction is wrapping up.
|
|
34
|
+
* Consumers can call `waitUntil` on the event to delay the resolution of the `result` Promise.
|
|
35
|
+
*/
|
|
36
|
+
get onWillConclude(): Event<OnWillConcludeEvent<Status>>;
|
|
37
|
+
protected status: Deferred<Status>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether any actions have been added to the transaction.
|
|
40
|
+
* The Transaction will not self-dispose until at least one action has been performed.
|
|
41
|
+
*/
|
|
42
|
+
protected inUse: boolean;
|
|
43
|
+
protected init(): void;
|
|
44
|
+
protected doInit(): Promise<void>;
|
|
45
|
+
waitFor(delay?: Promise<unknown>, disposeIfRejected?: boolean): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* @returns a promise reflecting the result of performing an action. Typically the promise will not resolve until the whole transaction is complete.
|
|
48
|
+
*/
|
|
49
|
+
enqueueAction(...args: Arguments): Promise<Result | false>;
|
|
50
|
+
protected disposeWhenDone(): void;
|
|
51
|
+
protected conclude(): Promise<void>;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Runs any code necessary to initialize the batch of interactions. No interaction will be run until the setup is complete.
|
|
55
|
+
*
|
|
56
|
+
* @returns a representation of the success of setup specific to a given transaction implementation.
|
|
57
|
+
*/
|
|
58
|
+
protected abstract setUp(): MaybePromise<Status>;
|
|
59
|
+
/**
|
|
60
|
+
* Performs a single interaction
|
|
61
|
+
*
|
|
62
|
+
* @returns the result of that interaction, specific to a given transaction type.
|
|
63
|
+
*/
|
|
64
|
+
protected abstract act(...args: Arguments): MaybePromise<Result>;
|
|
65
|
+
/**
|
|
66
|
+
* Runs any code necessary to complete a transaction and release any resources it holds.
|
|
67
|
+
*
|
|
68
|
+
* @returns implementation-specific information about the success of the transaction. Will be used as the final status of the transaction.
|
|
69
|
+
*/
|
|
70
|
+
protected abstract tearDown(): MaybePromise<Result>;
|
|
71
|
+
}
|
|
72
|
+
export interface PreferenceContext {
|
|
73
|
+
getConfigUri(): URI;
|
|
74
|
+
getScope(): PreferenceScope;
|
|
75
|
+
}
|
|
76
|
+
export declare const PreferenceContext: unique symbol;
|
|
77
|
+
export declare const PreferenceTransactionPreludeProvider: unique symbol;
|
|
78
|
+
export declare type PreferenceTransactionPreludeProvider = () => Promise<unknown>;
|
|
79
|
+
export declare class PreferenceTransaction extends Transaction<[string, string[], unknown], boolean> {
|
|
80
|
+
reference: IReference<MonacoEditorModel> | undefined;
|
|
81
|
+
protected readonly context: PreferenceContext;
|
|
82
|
+
protected readonly prelude?: PreferenceTransactionPreludeProvider;
|
|
83
|
+
protected readonly textModelService: MonacoTextModelService;
|
|
84
|
+
protected readonly jsoncEditor: MonacoJSONCEditor;
|
|
85
|
+
protected readonly messageService: MessageService;
|
|
86
|
+
protected readonly editorManager: EditorManager;
|
|
87
|
+
protected doInit(): Promise<void>;
|
|
88
|
+
protected setUp(): Promise<boolean>;
|
|
89
|
+
/**
|
|
90
|
+
* @returns whether the setting operation in progress, and any others started in the meantime, should continue.
|
|
91
|
+
*/
|
|
92
|
+
protected handleDirtyEditor(): Promise<boolean>;
|
|
93
|
+
protected act(key: string, path: string[], value: unknown): Promise<boolean>;
|
|
94
|
+
protected tearDown(): Promise<boolean>;
|
|
95
|
+
}
|
|
96
|
+
export interface PreferenceTransactionFactory {
|
|
97
|
+
(context: PreferenceContext, waitFor?: Promise<unknown>): PreferenceTransaction;
|
|
98
|
+
}
|
|
99
|
+
export declare const PreferenceTransactionFactory: unique symbol;
|
|
100
|
+
export declare const preferenceTransactionFactoryCreator: interfaces.FactoryCreator<PreferenceTransaction>;
|
|
101
101
|
//# sourceMappingURL=preference-transaction-manager.d.ts.map
|