@codingame/monaco-vscode-dialogs-service-override 5.3.0 → 6.0.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/dialogs.js +8 -42
- package/package.json +2 -2
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js +3 -2
- package/vscode/src/vs/workbench/browser/parts/dialogs/dialogHandler.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.js +6 -4
- package/vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeWidget.js +2 -1
- package/vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js +8 -8
- package/vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js +1 -0
- package/vscode/src/vs/workbench/services/dialogs/browser/simpleFileDialog.js +4 -3
- package/vscode/src/vs/workbench/services/dialogs/common/dialogService.js +1 -0
- package/tools.js +0 -42
package/dialogs.js
CHANGED
|
@@ -1,56 +1,22 @@
|
|
|
1
1
|
import { DialogService } from './vscode/src/vs/workbench/services/dialogs/common/dialogService.js';
|
|
2
2
|
import { IDialogService, IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
3
3
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
4
|
-
import { AbstractFileDialogService } from './vscode/src/vs/workbench/services/dialogs/browser/abstractFileDialogService.js';
|
|
5
4
|
import { FileDialogService } from './vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js';
|
|
6
|
-
import { unsupported } from './tools.js';
|
|
7
5
|
import './vscode/src/vs/workbench/browser/parts/dialogs/dialog.web.contribution.js';
|
|
8
6
|
import './vscode/src/vs/workbench/contrib/welcomeDialog/browser/welcomeDialog.contribution.js';
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const schema = this.getFileSystemSchema(options);
|
|
17
|
-
if (options.defaultUri == null) {
|
|
18
|
-
options.defaultUri = await this.defaultFilePath(schema);
|
|
19
|
-
}
|
|
20
|
-
return super.pickFileFolderAndOpenSimplified(schema, options, false);
|
|
21
|
-
}
|
|
22
|
-
async pickFolderAndOpen(options) {
|
|
23
|
-
const schema = this.getFileSystemSchema(options);
|
|
24
|
-
if (options.defaultUri == null) {
|
|
25
|
-
options.defaultUri = await this.defaultFolderPath(schema);
|
|
26
|
-
}
|
|
27
|
-
return super.pickFolderAndOpenSimplified(schema, options);
|
|
28
|
-
}
|
|
29
|
-
async pickFileAndOpen(options) {
|
|
30
|
-
const schema = this.getFileSystemSchema(options);
|
|
31
|
-
if (options.defaultUri == null) {
|
|
32
|
-
options.defaultUri = await this.defaultFilePath(schema);
|
|
33
|
-
}
|
|
34
|
-
return super.pickFileAndOpenSimplified(schema, options, false);
|
|
35
|
-
}
|
|
36
|
-
async showSaveDialog(options) {
|
|
37
|
-
const schema = this.getFileSystemSchema(options);
|
|
38
|
-
return super.showSaveDialogSimplified(schema, options);
|
|
39
|
-
}
|
|
40
|
-
async showOpenDialog(options) {
|
|
41
|
-
const schema = this.getFileSystemSchema(options);
|
|
42
|
-
return super.showOpenDialogSimplified(schema, options);
|
|
43
|
-
}
|
|
44
|
-
async pickFileToSave(defaultUri, availableFileSystems) {
|
|
45
|
-
const schema = this.getFileSystemSchema({ defaultUri, availableFileSystems });
|
|
46
|
-
const options = this.getPickFileToSaveDialogOptions(defaultUri, availableFileSystems);
|
|
47
|
-
return super.pickFileToSaveSimplified(schema, options);
|
|
8
|
+
function isHTMLFileSystemProvider(provider) {
|
|
9
|
+
return provider.directories != null;
|
|
10
|
+
}
|
|
11
|
+
class DialogServiceOverride extends FileDialogService {
|
|
12
|
+
shouldUseSimplified(scheme) {
|
|
13
|
+
return !isHTMLFileSystemProvider(super.fileSystemProvider) || super.shouldUseSimplified(scheme);
|
|
48
14
|
}
|
|
49
15
|
}
|
|
50
|
-
function getServiceOverride(
|
|
16
|
+
function getServiceOverride() {
|
|
51
17
|
return {
|
|
52
18
|
[( IDialogService.toString())]: new SyncDescriptor(DialogService, undefined, true),
|
|
53
|
-
[( IFileDialogService.toString())]:
|
|
19
|
+
[( IFileDialogService.toString())]: new SyncDescriptor(DialogServiceOverride, undefined, true)
|
|
54
20
|
};
|
|
55
21
|
}
|
|
56
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-dialogs-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@6.0.0"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -5,7 +5,7 @@ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/
|
|
|
5
5
|
import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService.service';
|
|
6
6
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
7
7
|
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
8
|
-
import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
8
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
9
9
|
import { BrowserDialogHandler } from './dialogHandler.js';
|
|
10
10
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
11
11
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
@@ -70,6 +70,7 @@ DialogHandlerContribution = ( __decorate([
|
|
|
70
70
|
( __param(5, IProductService)),
|
|
71
71
|
( __param(6, IClipboardService))
|
|
72
72
|
], DialogHandlerContribution));
|
|
73
|
-
registerWorkbenchContribution2(DialogHandlerContribution.ID, DialogHandlerContribution,
|
|
73
|
+
registerWorkbenchContribution2(DialogHandlerContribution.ID, DialogHandlerContribution, WorkbenchPhase.BlockStartup
|
|
74
|
+
);
|
|
74
75
|
|
|
75
76
|
export { DialogHandlerContribution };
|
|
@@ -14,6 +14,7 @@ import { fromNow } from 'vscode/vscode/vs/base/common/date';
|
|
|
14
14
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
15
15
|
import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
|
16
16
|
import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
|
|
17
|
+
import { ResultKind } from 'vscode/vscode/vs/platform/keybinding/common/keybindingResolver';
|
|
17
18
|
|
|
18
19
|
var BrowserDialogHandler_1;
|
|
19
20
|
const _moduleId = "vs/workbench/browser/parts/dialogs/dialogHandler";
|
|
@@ -94,7 +95,7 @@ let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHand
|
|
|
94
95
|
type: this.getDialogType(type),
|
|
95
96
|
keyEventProcessor: (event) => {
|
|
96
97
|
const resolved = this.keybindingService.softDispatch(event, this.layoutService.activeContainer);
|
|
97
|
-
if (resolved.kind ===
|
|
98
|
+
if (resolved.kind === ResultKind.KbFound && resolved.commandId) {
|
|
98
99
|
if (BrowserDialogHandler_1.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
|
|
99
100
|
EventHelper.stop(event, true);
|
|
100
101
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
|
|
2
3
|
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
3
4
|
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
5
|
+
import { StorageScope } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
4
6
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
5
7
|
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService.service';
|
|
6
8
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
@@ -13,7 +15,7 @@ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/comma
|
|
|
13
15
|
import { WelcomeWidget } from './welcomeWidget.js';
|
|
14
16
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
15
17
|
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
|
|
16
|
-
import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
18
|
+
import { Extensions as Extensions$1, ConfigurationScope } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
17
19
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
18
20
|
import { applicationConfigurationNodeBase } from 'vscode/vscode/vs/workbench/common/configuration';
|
|
19
21
|
import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
|
|
@@ -25,7 +27,7 @@ let WelcomeDialogContribution = class WelcomeDialogContribution extends Disposab
|
|
|
25
27
|
constructor(storageService, environmentService, configurationService, contextService, codeEditorService, instantiationService, commandService, telemetryService, openerService, editorService) {
|
|
26
28
|
super();
|
|
27
29
|
this.isRendered = false;
|
|
28
|
-
if (!storageService.isNew(
|
|
30
|
+
if (!storageService.isNew(StorageScope.APPLICATION)) {
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
33
|
const setting = configurationService.inspect(configurationKey);
|
|
@@ -78,13 +80,13 @@ WelcomeDialogContribution = ( (__decorate([
|
|
|
78
80
|
( (__param(9, IEditorService)))
|
|
79
81
|
], WelcomeDialogContribution)));
|
|
80
82
|
( (Registry.as(Extensions.Workbench)))
|
|
81
|
-
.registerWorkbenchContribution(WelcomeDialogContribution,
|
|
83
|
+
.registerWorkbenchContribution(WelcomeDialogContribution, LifecyclePhase.Eventually);
|
|
82
84
|
const configurationRegistry = ( (Registry.as(Extensions$1.Configuration)));
|
|
83
85
|
configurationRegistry.registerConfiguration({
|
|
84
86
|
...applicationConfigurationNodeBase,
|
|
85
87
|
properties: {
|
|
86
88
|
'workbench.welcome.experimental.dialog': {
|
|
87
|
-
scope:
|
|
89
|
+
scope: ConfigurationScope.APPLICATION,
|
|
88
90
|
type: 'boolean',
|
|
89
91
|
default: false,
|
|
90
92
|
tags: ['experimental'],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './media/welcomeWidget.css.js';
|
|
2
2
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
|
+
import { OverlayWidgetPositionPreference } from 'vscode/vscode/vs/editor/browser/editorBrowser';
|
|
3
4
|
import { $, hide, append } from 'vscode/vscode/vs/base/browser/dom';
|
|
4
5
|
import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
|
|
5
6
|
import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
|
@@ -134,7 +135,7 @@ class WelcomeWidget extends Disposable {
|
|
|
134
135
|
}
|
|
135
136
|
getPosition() {
|
|
136
137
|
return {
|
|
137
|
-
preference:
|
|
138
|
+
preference: OverlayWidgetPositionPreference.TOP_RIGHT_CORNER
|
|
138
139
|
};
|
|
139
140
|
}
|
|
140
141
|
_show() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
3
|
import { isWorkspaceToOpen, isFileToOpen } from 'vscode/vscode/vs/platform/window/common/window';
|
|
4
|
-
import { getFileNamesMessage } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
4
|
+
import { ConfirmResult, getFileNamesMessage } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
5
5
|
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
6
|
-
import { isSavedWorkspace, isTemporaryWorkspace, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
6
|
+
import { WorkbenchState, isSavedWorkspace, isTemporaryWorkspace, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
7
7
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
8
8
|
import { IHistoryService } from 'vscode/vscode/vs/workbench/services/history/common/history.service';
|
|
9
9
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
@@ -92,7 +92,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
92
92
|
}
|
|
93
93
|
async defaultWorkspacePath(schemeFilter = this.getSchemeFilterForWindow()) {
|
|
94
94
|
let defaultWorkspacePath;
|
|
95
|
-
if (this.contextService.getWorkbenchState() ===
|
|
95
|
+
if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) {
|
|
96
96
|
const configuration = this.contextService.getWorkspace().configuration;
|
|
97
97
|
if (configuration?.scheme === schemeFilter && isSavedWorkspace(configuration, this.environmentService) && !isTemporaryWorkspace(configuration)) {
|
|
98
98
|
defaultWorkspacePath = dirname(configuration);
|
|
@@ -106,7 +106,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
106
106
|
async showSaveConfirm(fileNamesOrResources) {
|
|
107
107
|
if (this.skipDialogs()) {
|
|
108
108
|
this.logService.trace('FileDialogService: refused to show save confirmation dialog in tests.');
|
|
109
|
-
return
|
|
109
|
+
return ConfirmResult.DONT_SAVE;
|
|
110
110
|
}
|
|
111
111
|
return this.doShowSaveConfirm(fileNamesOrResources);
|
|
112
112
|
}
|
|
@@ -118,7 +118,7 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
118
118
|
}
|
|
119
119
|
async doShowSaveConfirm(fileNamesOrResources) {
|
|
120
120
|
if (fileNamesOrResources.length === 0) {
|
|
121
|
-
return
|
|
121
|
+
return ConfirmResult.DONT_SAVE;
|
|
122
122
|
}
|
|
123
123
|
let message;
|
|
124
124
|
let detail = ( localizeWithPath(_moduleId, 0, "Your changes will be lost if you don't save them."));
|
|
@@ -148,15 +148,15 @@ let AbstractFileDialogService = class AbstractFileDialogService {
|
|
|
148
148
|
label: fileNamesOrResources.length > 1 ?
|
|
149
149
|
( localizeWithPath(_moduleId, 3, "&&Save All")) :
|
|
150
150
|
( localizeWithPath(_moduleId, 4, "&&Save")),
|
|
151
|
-
run: () =>
|
|
151
|
+
run: () => ConfirmResult.SAVE
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
154
|
label: ( localizeWithPath(_moduleId, 5, "Do&&n't Save")),
|
|
155
|
-
run: () =>
|
|
155
|
+
run: () => ConfirmResult.DONT_SAVE
|
|
156
156
|
}
|
|
157
157
|
],
|
|
158
158
|
cancelButton: {
|
|
159
|
-
run: () =>
|
|
159
|
+
run: () => ConfirmResult.CANCEL
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
162
|
return result;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
3
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
3
4
|
import { AbstractFileDialogService } from './abstractFileDialogService.js';
|
|
4
5
|
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
5
6
|
import { memoize } from 'vscode/vscode/vs/base/common/decorators';
|
|
@@ -7,7 +7,7 @@ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.servi
|
|
|
7
7
|
import { ItemActivation } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
8
8
|
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
9
9
|
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
10
|
-
import { isWindows } from 'vscode/vscode/vs/base/common/platform';
|
|
10
|
+
import { isWindows, OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
|
|
11
11
|
import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
12
12
|
import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.service';
|
|
13
13
|
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
@@ -28,6 +28,7 @@ import { dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
|
28
28
|
import { createCancelablePromise } from 'vscode/vscode/vs/base/common/async';
|
|
29
29
|
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
30
30
|
import { normalizeDriveLetter } from 'vscode/vscode/vs/base/common/labels';
|
|
31
|
+
import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
|
|
31
32
|
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
|
|
32
33
|
import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility.service';
|
|
33
34
|
import { getActiveDocument } from 'vscode/vscode/vs/base/browser/dom';
|
|
@@ -54,7 +55,7 @@ var SaveLocalFileCommand;
|
|
|
54
55
|
const editorService = accessor.get(IEditorService);
|
|
55
56
|
const activeEditorPane = editorService.activeEditorPane;
|
|
56
57
|
if (activeEditorPane) {
|
|
57
|
-
return editorService.save({ groupId: activeEditorPane.group.id, editor: activeEditorPane.input }, { saveAs: true, availableFileSystems: [Schemas.file], reason:
|
|
58
|
+
return editorService.save({ groupId: activeEditorPane.group.id, editor: activeEditorPane.input }, { saveAs: true, availableFileSystems: [Schemas.file], reason: SaveReason.EXPLICIT });
|
|
58
59
|
}
|
|
59
60
|
return Promise.resolve(undefined);
|
|
60
61
|
};
|
|
@@ -882,7 +883,7 @@ let SimpleFileDialog = class SimpleFileDialog {
|
|
|
882
883
|
let isWindowsOS = isWindows;
|
|
883
884
|
const env = await this.getRemoteAgentEnvironment();
|
|
884
885
|
if (env) {
|
|
885
|
-
isWindowsOS = env.os ===
|
|
886
|
+
isWindowsOS = env.os === OperatingSystem.Windows;
|
|
886
887
|
}
|
|
887
888
|
return isWindowsOS;
|
|
888
889
|
}
|
|
@@ -3,6 +3,7 @@ import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
|
3
3
|
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
4
|
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
5
|
import { DialogsModel } from '../../../common/dialogs.js';
|
|
6
|
+
import 'vscode/vscode/vs/platform/instantiation/common/extensions';
|
|
6
7
|
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
7
8
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
8
9
|
|
package/tools.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
function unsupported() {
|
|
2
|
-
throw new Error('unsupported');
|
|
3
|
-
}
|
|
4
|
-
function memoized(fct) {
|
|
5
|
-
let v = null;
|
|
6
|
-
return (...args) => {
|
|
7
|
-
if (v == null) {
|
|
8
|
-
v = fct(...args);
|
|
9
|
-
}
|
|
10
|
-
return v;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function memoizedConstructor(ctor) {
|
|
14
|
-
return new Proxy(ctor, {
|
|
15
|
-
construct: memoized((target, args) => {
|
|
16
|
-
return Reflect.construct(ctor, args);
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async function sleep(duration) {
|
|
21
|
-
await new Promise(resolve => setTimeout(resolve, duration));
|
|
22
|
-
}
|
|
23
|
-
function throttle(fct, merge, delay) {
|
|
24
|
-
let lastPromise = Promise.resolve();
|
|
25
|
-
let toConsume = null;
|
|
26
|
-
return async (param) => {
|
|
27
|
-
if (toConsume == null) {
|
|
28
|
-
toConsume = param;
|
|
29
|
-
lastPromise = lastPromise.then(async () => sleep(delay)).then(async () => {
|
|
30
|
-
const _toConsume = toConsume;
|
|
31
|
-
toConsume = null;
|
|
32
|
-
await fct(_toConsume);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
toConsume = merge(toConsume, param);
|
|
37
|
-
}
|
|
38
|
-
await lastPromise;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export { memoized, memoizedConstructor, sleep, throttle, unsupported };
|