@codingame/monaco-vscode-api 2.1.4 → 2.2.0-next.1

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.
Files changed (190) hide show
  1. package/README.md +2 -0
  2. package/contributions.js +1 -0
  3. package/extensions.d.ts +6 -3
  4. package/extensions.js +18 -7
  5. package/lifecycle.js +11 -3
  6. package/missing-services.js +55 -10
  7. package/monaco.js +7 -3
  8. package/package.json +8 -8
  9. package/service-override/tools/views.d.ts +98 -0
  10. package/service-override/tools/views.js +249 -0
  11. package/services.d.ts +4 -2
  12. package/services.js +11 -9
  13. package/vscode/src/vs/base/browser/deviceAccess.js +60 -0
  14. package/vscode/src/vs/base/browser/dom.js +18 -1
  15. package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +178 -0
  16. package/vscode/src/vs/base/browser/ui/grid/grid.js +492 -0
  17. package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +4 -0
  18. package/vscode/src/vs/base/browser/ui/grid/gridview.d.ts +1 -0
  19. package/vscode/src/vs/base/browser/ui/grid/gridview.js +1109 -0
  20. package/vscode/src/vs/base/browser/ui/sash/sash.js +9 -1
  21. package/vscode/src/vs/base/browser/ui/splitview/splitview.d.ts +348 -1
  22. package/vscode/src/vs/base/common/async.js +46 -2
  23. package/vscode/src/vs/base/common/codicons.d.ts +579 -0
  24. package/vscode/src/vs/base/common/event.js +11 -2
  25. package/vscode/src/vs/base/common/keybindingParser.js +87 -0
  26. package/vscode/src/vs/base/common/network.js +1 -2
  27. package/vscode/src/vs/base/common/observableInternal/utils.js +1 -1
  28. package/vscode/src/vs/base/common/platform.js +2 -1
  29. package/vscode/src/vs/base/common/scrollable.d.ts +28 -0
  30. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/colors.js +17 -0
  31. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/diffEditorItemTemplate.js +214 -0
  32. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorViewModel.js +84 -0
  33. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget.js +54 -0
  34. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidgetImpl.js +324 -0
  35. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/objectPool.js +46 -0
  36. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/style.css.js +4 -0
  37. package/vscode/src/vs/editor/browser/widget/multiDiffEditorWidget/utils.js +11 -0
  38. package/vscode/src/vs/platform/keyboardLayout/common/keyboardLayout.js +61 -1
  39. package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +10 -0
  40. package/vscode/src/vs/platform/log/browser/log.js +24 -0
  41. package/vscode/src/vs/platform/product/common/product.js +1 -2
  42. package/vscode/src/vs/platform/userDataSync/common/abstractSynchronizer.js +772 -0
  43. package/vscode/src/vs/platform/userDataSync/common/userDataSyncStoreService.js +551 -0
  44. package/vscode/src/vs/platform/webview/common/mimeTypes.js +22 -0
  45. package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +62 -0
  46. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +788 -0
  47. package/vscode/src/vs/workbench/browser/actions/listCommands.js +763 -0
  48. package/vscode/src/vs/workbench/browser/layout.d.ts +26 -0
  49. package/vscode/src/vs/workbench/browser/media/style.css.js +1 -1
  50. package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +610 -0
  51. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +4 -0
  52. package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +4 -0
  53. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +148 -0
  54. package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +4 -0
  55. package/vscode/src/vs/workbench/browser/parts/compositeBar.js +603 -0
  56. package/vscode/src/vs/workbench/browser/parts/compositePart.js +333 -0
  57. package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +221 -0
  58. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1406 -0
  59. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +184 -0
  60. package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +509 -0
  61. package/vscode/src/vs/workbench/browser/parts/editor/editorPane.d.ts +112 -0
  62. package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1018 -0
  63. package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +389 -0
  64. package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +4 -0
  65. package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +4 -0
  66. package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +4 -0
  67. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsActions.css.js +4 -0
  68. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsCenter.css.js +4 -0
  69. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsList.css.js +4 -0
  70. package/vscode/src/vs/workbench/browser/parts/notifications/media/notificationsToasts.css.js +4 -0
  71. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsActions.js +213 -0
  72. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js +73 -0
  73. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsCenter.js +307 -0
  74. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsList.js +226 -0
  75. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js +218 -0
  76. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsToasts.js +433 -0
  77. package/vscode/src/vs/workbench/browser/parts/notifications/notificationsViewer.js +436 -0
  78. package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
  79. package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +377 -0
  80. package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +66 -0
  81. package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +144 -0
  82. package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +4 -0
  83. package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +220 -0
  84. package/vscode/src/vs/workbench/browser/window.js +239 -5
  85. package/vscode/src/vs/workbench/common/configuration.js +11 -1
  86. package/vscode/src/vs/workbench/common/theme.js +3 -3
  87. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +298 -0
  88. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +363 -0
  89. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +133 -0
  90. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +4 -0
  91. package/vscode/src/vs/workbench/contrib/comments/browser/commentGlyphWidget.js +90 -0
  92. package/vscode/src/vs/workbench/contrib/comments/browser/commentMenus.js +43 -0
  93. package/vscode/src/vs/workbench/contrib/comments/browser/commentService.js +317 -2
  94. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadRangeDecorator.js +107 -0
  95. package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.js +395 -0
  96. package/vscode/src/vs/workbench/contrib/comments/browser/comments.js +3 -0
  97. package/vscode/src/vs/workbench/contrib/comments/browser/commentsController.js +1277 -0
  98. package/vscode/src/vs/workbench/contrib/comments/browser/commentsFilterOptions.js +17 -0
  99. package/vscode/src/vs/workbench/contrib/comments/browser/commentsModel.js +123 -0
  100. package/vscode/src/vs/workbench/contrib/comments/browser/commentsTreeViewer.js +342 -0
  101. package/vscode/src/vs/workbench/contrib/comments/browser/commentsView.js +451 -0
  102. package/vscode/src/vs/workbench/contrib/comments/browser/commentsViewActions.js +176 -0
  103. package/vscode/src/vs/workbench/contrib/comments/browser/media/panel.css.js +4 -0
  104. package/vscode/src/vs/workbench/contrib/comments/common/commentModel.js +35 -0
  105. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +16 -0
  106. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +143 -0
  107. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +212 -0
  108. package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +4 -0
  109. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +76 -0
  110. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +61 -0
  111. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +117 -0
  112. package/vscode/src/vs/workbench/contrib/editSessions/common/editSessions.js +62 -0
  113. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +5 -0
  114. package/vscode/src/vs/workbench/contrib/files/browser/editors/binaryFileEditor.js +77 -0
  115. package/vscode/src/vs/workbench/contrib/files/browser/editors/fileEditorHandler.js +72 -0
  116. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditor.js +254 -0
  117. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileEditorTracker.js +97 -0
  118. package/vscode/src/vs/workbench/contrib/files/browser/editors/textFileSaveErrorHandler.js +442 -0
  119. package/vscode/src/vs/workbench/contrib/files/browser/explorerService.js +430 -0
  120. package/vscode/src/vs/workbench/contrib/files/browser/fileActions.contribution.js +784 -0
  121. package/vscode/src/vs/workbench/contrib/files/browser/fileCommands.js +487 -0
  122. package/vscode/src/vs/workbench/contrib/files/browser/files.contribution.js +521 -0
  123. package/vscode/src/vs/workbench/contrib/files/browser/workspaceWatcher.js +150 -0
  124. package/vscode/src/vs/workbench/contrib/files/common/dirtyFilesIndicator.js +61 -0
  125. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveDocumentService.js +25 -1
  126. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.js +178 -0
  127. package/vscode/src/vs/workbench/contrib/interactive/browser/interactiveHistoryService.js +49 -0
  128. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
  129. package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +4 -0
  130. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +145 -0
  131. package/vscode/src/vs/workbench/contrib/mappedEdits/common/mappedEdits.contribution.js +22 -0
  132. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +691 -0
  133. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +238 -0
  134. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +76 -0
  135. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +40 -0
  136. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +69 -0
  137. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +346 -0
  138. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +96 -0
  139. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +144 -0
  140. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +103 -0
  141. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +399 -0
  142. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +195 -0
  143. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +39 -0
  144. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +126 -0
  145. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +4 -0
  146. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +611 -0
  147. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +156 -0
  148. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +262 -0
  149. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +171 -0
  150. package/vscode/src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffSourceResolverService.js +41 -0
  151. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/executionStatusBarItemController.js +317 -0
  152. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/notebookVisibleCellObserver.js +56 -0
  153. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindWidget.js +315 -0
  154. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +193 -0
  155. package/vscode/src/vs/workbench/contrib/preferences/common/preferences.js +2 -1
  156. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +37 -0
  157. package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +39 -0
  158. package/vscode/src/vs/workbench/contrib/speech/common/speechService.js +138 -2
  159. package/vscode/src/vs/workbench/contrib/tags/browser/workspaceTagsService.js +12 -0
  160. package/vscode/src/vs/workbench/contrib/tags/common/workspaceTags.js +3 -0
  161. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +4 -0
  162. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +281 -0
  163. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +358 -0
  164. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +131 -0
  165. package/vscode/src/vs/workbench/contrib/update/common/update.js +2 -0
  166. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +288 -0
  167. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +94 -0
  168. package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +86 -0
  169. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +77 -0
  170. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +646 -0
  171. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +63 -0
  172. package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +57 -0
  173. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +140 -0
  174. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +119 -0
  175. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
  176. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +233 -0
  177. package/vscode/src/vs/workbench/services/activity/browser/activityService.js +143 -0
  178. package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +0 -3
  179. package/vscode/src/vs/workbench/services/driver/browser/driver.js +184 -0
  180. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +668 -0
  181. package/vscode/src/vs/workbench/services/history/browser/historyService.js +1482 -0
  182. package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +17 -1
  183. package/vscode/src/vs/workbench/services/lifecycle/common/lifecycle.js +8 -1
  184. package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +4 -0
  185. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +521 -0
  186. package/vscode/src/vs/workbench/services/textMate/common/TMGrammars.js +102 -0
  187. package/vscode/src/vs/workbench/services/themes/common/tokenClassificationExtensionPoint.js +296 -0
  188. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +99 -0
  189. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
  190. package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +596 -0
@@ -0,0 +1,551 @@
1
+ import { __decorate, __param } from '../../../../../../external/tslib/tslib.es6.js';
2
+ import { createCancelablePromise, timeout } from '../../../base/common/async.js';
3
+ import { CancellationToken } from '../../../base/common/cancellation.js';
4
+ import { getErrorMessage, isCancellationError } from '../../../base/common/errors.js';
5
+ import { Emitter, Event } from '../../../base/common/event.js';
6
+ import { Disposable, toDisposable, DisposableStore } from '../../../base/common/lifecycle.js';
7
+ import { Mimes } from '../../../base/common/mime.js';
8
+ import { isWeb } from '../../../base/common/platform.js';
9
+ import { joinPath, relativePath } from '../../../base/common/resources.js';
10
+ import { isString, isObject } from '../../../base/common/types.js';
11
+ import { URI } from '../../../base/common/uri.js';
12
+ import { generateUuid } from '../../../base/common/uuid.js';
13
+ import { IConfigurationService } from '../../configuration/common/configuration.js';
14
+ import { IEnvironmentService } from '../../environment/common/environment.js';
15
+ import { IFileService } from '../../files/common/files.js';
16
+ import { IProductService } from '../../product/common/productService.js';
17
+ import { asJson, asTextOrError, isSuccess, hasNoContent, asText, IRequestService } from '../../request/common/request.js';
18
+ import { getServiceMachineId } from '../../externalServices/common/serviceMachineId.js';
19
+ import { IStorageService } from '../../storage/common/storage.js';
20
+ import { UserDataSyncStoreError, HEADER_OPERATION_ID, HEADER_EXECUTION_ID, IUserDataSyncLogService, IUserDataSyncStoreManagementService, SYNC_SERVICE_URL_TYPE } from './userDataSync.js';
21
+ const CONFIGURATION_SYNC_STORE_KEY = 'configurationSync.store';
22
+ const SYNC_PREVIOUS_STORE = 'sync.previous.store';
23
+ const DONOT_MAKE_REQUESTS_UNTIL_KEY = 'sync.donot-make-requests-until';
24
+ const USER_SESSION_ID_KEY = 'sync.user-session-id';
25
+ const MACHINE_SESSION_ID_KEY = 'sync.machine-session-id';
26
+ const REQUEST_SESSION_LIMIT = 100;
27
+ const REQUEST_SESSION_INTERVAL = 1000 * 60 * 5;
28
+ let AbstractUserDataSyncStoreManagementService = class AbstractUserDataSyncStoreManagementService extends Disposable {
29
+ get userDataSyncStore() { return this._userDataSyncStore; }
30
+ get userDataSyncStoreType() {
31
+ return this.storageService.get(SYNC_SERVICE_URL_TYPE, -1 );
32
+ }
33
+ set userDataSyncStoreType(type) {
34
+ this.storageService.store(SYNC_SERVICE_URL_TYPE, type, -1 , isWeb ? 0 : 1 );
35
+ }
36
+ constructor(productService, configurationService, storageService) {
37
+ super();
38
+ this.productService = productService;
39
+ this.configurationService = configurationService;
40
+ this.storageService = storageService;
41
+ this._onDidChangeUserDataSyncStore = this._register(( new Emitter()));
42
+ this.onDidChangeUserDataSyncStore = this._onDidChangeUserDataSyncStore.event;
43
+ this.updateUserDataSyncStore();
44
+ const disposable = this._register(( new DisposableStore()));
45
+ this._register(Event.filter(storageService.onDidChangeValue(-1 , SYNC_SERVICE_URL_TYPE, disposable), () => this.userDataSyncStoreType !== this.userDataSyncStore?.type, disposable)(() => this.updateUserDataSyncStore()));
46
+ }
47
+ updateUserDataSyncStore() {
48
+ this._userDataSyncStore = this.toUserDataSyncStore(this.productService[CONFIGURATION_SYNC_STORE_KEY]);
49
+ this._onDidChangeUserDataSyncStore.fire();
50
+ }
51
+ toUserDataSyncStore(configurationSyncStore) {
52
+ if (!configurationSyncStore) {
53
+ return undefined;
54
+ }
55
+ configurationSyncStore = isWeb && configurationSyncStore.web ? { ...configurationSyncStore, ...configurationSyncStore.web } : configurationSyncStore;
56
+ if (isString(configurationSyncStore.url)
57
+ && isObject(configurationSyncStore.authenticationProviders)
58
+ && ( Object.keys(configurationSyncStore.authenticationProviders)).every(authenticationProviderId => Array.isArray(configurationSyncStore.authenticationProviders[authenticationProviderId].scopes))) {
59
+ const syncStore = configurationSyncStore;
60
+ const canSwitch = !!syncStore.canSwitch;
61
+ const defaultType = syncStore.url === syncStore.insidersUrl ? 'insiders' : 'stable';
62
+ const type = (canSwitch ? this.userDataSyncStoreType : undefined) || defaultType;
63
+ const url = type === 'insiders' ? syncStore.insidersUrl
64
+ : type === 'stable' ? syncStore.stableUrl
65
+ : syncStore.url;
66
+ return {
67
+ url: ( URI.parse(url)),
68
+ type,
69
+ defaultType,
70
+ defaultUrl: ( URI.parse(syncStore.url)),
71
+ stableUrl: ( URI.parse(syncStore.stableUrl)),
72
+ insidersUrl: ( URI.parse(syncStore.insidersUrl)),
73
+ canSwitch,
74
+ authenticationProviders: ( Object.keys(syncStore.authenticationProviders)).reduce((result, id) => {
75
+ result.push({ id, scopes: syncStore.authenticationProviders[id].scopes });
76
+ return result;
77
+ }, [])
78
+ };
79
+ }
80
+ return undefined;
81
+ }
82
+ };
83
+ AbstractUserDataSyncStoreManagementService = ( __decorate([
84
+ ( __param(0, IProductService)),
85
+ ( __param(1, IConfigurationService)),
86
+ ( __param(2, IStorageService))
87
+ ], AbstractUserDataSyncStoreManagementService));
88
+ let UserDataSyncStoreManagementService = class UserDataSyncStoreManagementService extends AbstractUserDataSyncStoreManagementService {
89
+ constructor(productService, configurationService, storageService) {
90
+ super(productService, configurationService, storageService);
91
+ const previousConfigurationSyncStore = this.storageService.get(SYNC_PREVIOUS_STORE, -1 );
92
+ if (previousConfigurationSyncStore) {
93
+ this.previousConfigurationSyncStore = JSON.parse(previousConfigurationSyncStore);
94
+ }
95
+ const syncStore = this.productService[CONFIGURATION_SYNC_STORE_KEY];
96
+ if (syncStore) {
97
+ this.storageService.store(SYNC_PREVIOUS_STORE, JSON.stringify(syncStore), -1 , 1 );
98
+ }
99
+ else {
100
+ this.storageService.remove(SYNC_PREVIOUS_STORE, -1 );
101
+ }
102
+ }
103
+ async switch(type) {
104
+ if (type !== this.userDataSyncStoreType) {
105
+ this.userDataSyncStoreType = type;
106
+ this.updateUserDataSyncStore();
107
+ }
108
+ }
109
+ async getPreviousUserDataSyncStore() {
110
+ return this.toUserDataSyncStore(this.previousConfigurationSyncStore);
111
+ }
112
+ };
113
+ UserDataSyncStoreManagementService = ( __decorate([
114
+ ( __param(0, IProductService)),
115
+ ( __param(1, IConfigurationService)),
116
+ ( __param(2, IStorageService))
117
+ ], UserDataSyncStoreManagementService));
118
+ let UserDataSyncStoreClient = class UserDataSyncStoreClient extends Disposable {
119
+ get donotMakeRequestsUntil() { return this._donotMakeRequestsUntil; }
120
+ constructor(userDataSyncStoreUrl, productService, requestService, logService, environmentService, fileService, storageService) {
121
+ super();
122
+ this.requestService = requestService;
123
+ this.logService = logService;
124
+ this.storageService = storageService;
125
+ this._onTokenFailed = this._register(( new Emitter()));
126
+ this.onTokenFailed = this._onTokenFailed.event;
127
+ this._onTokenSucceed = this._register(( new Emitter()));
128
+ this.onTokenSucceed = this._onTokenSucceed.event;
129
+ this._donotMakeRequestsUntil = undefined;
130
+ this._onDidChangeDonotMakeRequestsUntil = this._register(( new Emitter()));
131
+ this.onDidChangeDonotMakeRequestsUntil = this._onDidChangeDonotMakeRequestsUntil.event;
132
+ this.resetDonotMakeRequestsUntilPromise = undefined;
133
+ this.updateUserDataSyncStoreUrl(userDataSyncStoreUrl);
134
+ this.commonHeadersPromise = getServiceMachineId(environmentService, fileService, storageService)
135
+ .then(uuid => {
136
+ const headers = {
137
+ 'X-Client-Name': `${productService.applicationName}${isWeb ? '-web' : ''}`,
138
+ 'X-Client-Version': productService.version,
139
+ };
140
+ if (productService.commit) {
141
+ headers['X-Client-Commit'] = productService.commit;
142
+ }
143
+ return headers;
144
+ });
145
+ this.session = ( new RequestsSession(
146
+ REQUEST_SESSION_LIMIT,
147
+ REQUEST_SESSION_INTERVAL,
148
+ this.requestService,
149
+ this.logService
150
+ ));
151
+ this.initDonotMakeRequestsUntil();
152
+ this._register(toDisposable(() => {
153
+ if (this.resetDonotMakeRequestsUntilPromise) {
154
+ this.resetDonotMakeRequestsUntilPromise.cancel();
155
+ this.resetDonotMakeRequestsUntilPromise = undefined;
156
+ }
157
+ }));
158
+ }
159
+ setAuthToken(token, type) {
160
+ this.authToken = { token, type };
161
+ }
162
+ updateUserDataSyncStoreUrl(userDataSyncStoreUrl) {
163
+ this.userDataSyncStoreUrl = userDataSyncStoreUrl ? joinPath(userDataSyncStoreUrl, 'v1') : undefined;
164
+ }
165
+ initDonotMakeRequestsUntil() {
166
+ const donotMakeRequestsUntil = this.storageService.getNumber(DONOT_MAKE_REQUESTS_UNTIL_KEY, -1 );
167
+ if (donotMakeRequestsUntil && Date.now() < donotMakeRequestsUntil) {
168
+ this.setDonotMakeRequestsUntil(( new Date(donotMakeRequestsUntil)));
169
+ }
170
+ }
171
+ setDonotMakeRequestsUntil(donotMakeRequestsUntil) {
172
+ if (this._donotMakeRequestsUntil?.getTime() !== donotMakeRequestsUntil?.getTime()) {
173
+ this._donotMakeRequestsUntil = donotMakeRequestsUntil;
174
+ if (this.resetDonotMakeRequestsUntilPromise) {
175
+ this.resetDonotMakeRequestsUntilPromise.cancel();
176
+ this.resetDonotMakeRequestsUntilPromise = undefined;
177
+ }
178
+ if (this._donotMakeRequestsUntil) {
179
+ this.storageService.store(DONOT_MAKE_REQUESTS_UNTIL_KEY, this._donotMakeRequestsUntil.getTime(), -1 , 1 );
180
+ this.resetDonotMakeRequestsUntilPromise = createCancelablePromise(token => timeout(this._donotMakeRequestsUntil.getTime() - Date.now(), token).then(() => this.setDonotMakeRequestsUntil(undefined)));
181
+ this.resetDonotMakeRequestsUntilPromise.then(null, e => null );
182
+ }
183
+ else {
184
+ this.storageService.remove(DONOT_MAKE_REQUESTS_UNTIL_KEY, -1 );
185
+ }
186
+ this._onDidChangeDonotMakeRequestsUntil.fire();
187
+ }
188
+ }
189
+ async getAllCollections(headers = {}) {
190
+ if (!this.userDataSyncStoreUrl) {
191
+ throw new Error('No settings sync store url configured.');
192
+ }
193
+ const url = ( joinPath(this.userDataSyncStoreUrl, 'collection').toString());
194
+ headers = { ...headers };
195
+ headers['Content-Type'] = 'application/json';
196
+ const context = await this.request(url, { type: 'GET', headers }, [], CancellationToken.None);
197
+ return (await asJson(context))?.map(({ id }) => id) || [];
198
+ }
199
+ async createCollection(headers = {}) {
200
+ if (!this.userDataSyncStoreUrl) {
201
+ throw new Error('No settings sync store url configured.');
202
+ }
203
+ const url = ( joinPath(this.userDataSyncStoreUrl, 'collection').toString());
204
+ headers = { ...headers };
205
+ headers['Content-Type'] = Mimes.text;
206
+ const context = await this.request(url, { type: 'POST', headers }, [], CancellationToken.None);
207
+ const collectionId = await asTextOrError(context);
208
+ if (!collectionId) {
209
+ throw new UserDataSyncStoreError('Server did not return the collection id', url, "NoCollection" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
210
+ }
211
+ return collectionId;
212
+ }
213
+ async deleteCollection(collection, headers = {}) {
214
+ if (!this.userDataSyncStoreUrl) {
215
+ throw new Error('No settings sync store url configured.');
216
+ }
217
+ const url = collection ? ( joinPath(this.userDataSyncStoreUrl, 'collection', collection).toString()) : ( joinPath(this.userDataSyncStoreUrl, 'collection').toString());
218
+ headers = { ...headers };
219
+ await this.request(url, { type: 'DELETE', headers }, [], CancellationToken.None);
220
+ }
221
+ async getAllResourceRefs(resource, collection) {
222
+ if (!this.userDataSyncStoreUrl) {
223
+ throw new Error('No settings sync store url configured.');
224
+ }
225
+ const uri = this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource);
226
+ const headers = {};
227
+ const context = await this.request(( uri.toString()), { type: 'GET', headers }, [], CancellationToken.None);
228
+ const result = (await asJson(context)) || [];
229
+ return ( result.map(
230
+ ({ url, created }) => ({ ref: relativePath(uri, uri.with({ path: url })), created: created * 1000 })
231
+ ));
232
+ }
233
+ async resolveResourceContent(resource, ref, collection, headers = {}) {
234
+ if (!this.userDataSyncStoreUrl) {
235
+ throw new Error('No settings sync store url configured.');
236
+ }
237
+ const url = ( joinPath(this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource), ref).toString());
238
+ headers = { ...headers };
239
+ headers['Cache-Control'] = 'no-cache';
240
+ const context = await this.request(url, { type: 'GET', headers }, [], CancellationToken.None);
241
+ const content = await asTextOrError(context);
242
+ return content;
243
+ }
244
+ async deleteResource(resource, ref, collection) {
245
+ if (!this.userDataSyncStoreUrl) {
246
+ throw new Error('No settings sync store url configured.');
247
+ }
248
+ const url = ref !== null ? ( joinPath(this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource), ref).toString()) : ( this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource).toString());
249
+ const headers = {};
250
+ await this.request(url, { type: 'DELETE', headers }, [], CancellationToken.None);
251
+ }
252
+ async deleteResources() {
253
+ if (!this.userDataSyncStoreUrl) {
254
+ throw new Error('No settings sync store url configured.');
255
+ }
256
+ const url = ( joinPath(this.userDataSyncStoreUrl, 'resource').toString());
257
+ const headers = { 'Content-Type': Mimes.text };
258
+ await this.request(url, { type: 'DELETE', headers }, [], CancellationToken.None);
259
+ }
260
+ async readResource(resource, oldValue, collection, headers = {}) {
261
+ if (!this.userDataSyncStoreUrl) {
262
+ throw new Error('No settings sync store url configured.');
263
+ }
264
+ const url = ( joinPath(this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource), 'latest').toString());
265
+ headers = { ...headers };
266
+ headers['Cache-Control'] = 'no-cache';
267
+ if (oldValue) {
268
+ headers['If-None-Match'] = oldValue.ref;
269
+ }
270
+ const context = await this.request(url, { type: 'GET', headers }, [304], CancellationToken.None);
271
+ let userData = null;
272
+ if (context.res.statusCode === 304) {
273
+ userData = oldValue;
274
+ }
275
+ if (userData === null) {
276
+ const ref = context.res.headers['etag'];
277
+ if (!ref) {
278
+ throw new UserDataSyncStoreError('Server did not return the ref', url, "NoRef" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
279
+ }
280
+ const content = await asTextOrError(context);
281
+ if (!content && context.res.statusCode === 304) {
282
+ throw new UserDataSyncStoreError('Empty response', url, "EmptyResponse" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
283
+ }
284
+ userData = { ref, content };
285
+ }
286
+ return userData;
287
+ }
288
+ async writeResource(resource, data, ref, collection, headers = {}) {
289
+ if (!this.userDataSyncStoreUrl) {
290
+ throw new Error('No settings sync store url configured.');
291
+ }
292
+ const url = ( this.getResourceUrl(this.userDataSyncStoreUrl, collection, resource).toString());
293
+ headers = { ...headers };
294
+ headers['Content-Type'] = Mimes.text;
295
+ if (ref) {
296
+ headers['If-Match'] = ref;
297
+ }
298
+ const context = await this.request(url, { type: 'POST', data, headers }, [], CancellationToken.None);
299
+ const newRef = context.res.headers['etag'];
300
+ if (!newRef) {
301
+ throw new UserDataSyncStoreError('Server did not return the ref', url, "NoRef" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
302
+ }
303
+ return newRef;
304
+ }
305
+ async manifest(oldValue, headers = {}) {
306
+ if (!this.userDataSyncStoreUrl) {
307
+ throw new Error('No settings sync store url configured.');
308
+ }
309
+ const url = ( joinPath(this.userDataSyncStoreUrl, 'manifest').toString());
310
+ headers = { ...headers };
311
+ headers['Content-Type'] = 'application/json';
312
+ if (oldValue) {
313
+ headers['If-None-Match'] = oldValue.ref;
314
+ }
315
+ const context = await this.request(url, { type: 'GET', headers }, [304], CancellationToken.None);
316
+ let manifest = null;
317
+ if (context.res.statusCode === 304) {
318
+ manifest = oldValue;
319
+ }
320
+ if (!manifest) {
321
+ const ref = context.res.headers['etag'];
322
+ if (!ref) {
323
+ throw new UserDataSyncStoreError('Server did not return the ref', url, "NoRef" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
324
+ }
325
+ const content = await asTextOrError(context);
326
+ if (!content && context.res.statusCode === 304) {
327
+ throw new UserDataSyncStoreError('Empty response', url, "EmptyResponse" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
328
+ }
329
+ if (content) {
330
+ manifest = { ...JSON.parse(content), ref };
331
+ }
332
+ }
333
+ const currentSessionId = this.storageService.get(USER_SESSION_ID_KEY, -1 );
334
+ if (currentSessionId && manifest && currentSessionId !== manifest.session) {
335
+ this.clearSession();
336
+ }
337
+ if (manifest === null && currentSessionId) {
338
+ this.clearSession();
339
+ }
340
+ if (manifest) {
341
+ this.storageService.store(USER_SESSION_ID_KEY, manifest.session, -1 , 1 );
342
+ }
343
+ return manifest;
344
+ }
345
+ async clear() {
346
+ if (!this.userDataSyncStoreUrl) {
347
+ throw new Error('No settings sync store url configured.');
348
+ }
349
+ await this.deleteCollection();
350
+ await this.deleteResources();
351
+ this.clearSession();
352
+ }
353
+ async getActivityData() {
354
+ if (!this.userDataSyncStoreUrl) {
355
+ throw new Error('No settings sync store url configured.');
356
+ }
357
+ const url = ( joinPath(this.userDataSyncStoreUrl, 'download').toString());
358
+ const headers = {};
359
+ const context = await this.request(url, { type: 'GET', headers }, [], CancellationToken.None);
360
+ if (!isSuccess(context)) {
361
+ throw new UserDataSyncStoreError('Server returned ' + context.res.statusCode, url, "EmptyResponse" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
362
+ }
363
+ if (hasNoContent(context)) {
364
+ throw new UserDataSyncStoreError('Empty response', url, "EmptyResponse" , context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
365
+ }
366
+ return context.stream;
367
+ }
368
+ getResourceUrl(userDataSyncStoreUrl, collection, resource) {
369
+ return collection ? joinPath(userDataSyncStoreUrl, 'collection', collection, 'resource', resource) : joinPath(userDataSyncStoreUrl, 'resource', resource);
370
+ }
371
+ clearSession() {
372
+ this.storageService.remove(USER_SESSION_ID_KEY, -1 );
373
+ this.storageService.remove(MACHINE_SESSION_ID_KEY, -1 );
374
+ }
375
+ async request(url, options, successCodes, token) {
376
+ if (!this.authToken) {
377
+ throw new UserDataSyncStoreError('No Auth Token Available', url, "Unauthorized" , undefined, undefined);
378
+ }
379
+ if (this._donotMakeRequestsUntil && Date.now() < this._donotMakeRequestsUntil.getTime()) {
380
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of too many requests (429).`, url, "TooManyRequestsAndRetryAfter" , undefined, undefined);
381
+ }
382
+ this.setDonotMakeRequestsUntil(undefined);
383
+ const commonHeaders = await this.commonHeadersPromise;
384
+ options.headers = {
385
+ ...(options.headers || {}),
386
+ ...commonHeaders,
387
+ 'X-Account-Type': this.authToken.type,
388
+ 'authorization': `Bearer ${this.authToken.token}`,
389
+ };
390
+ this.addSessionHeaders(options.headers);
391
+ this.logService.trace('Sending request to server', { url, type: options.type, headers: { ...options.headers, ...{ authorization: undefined } } });
392
+ let context;
393
+ try {
394
+ context = await this.session.request(url, options, token);
395
+ }
396
+ catch (e) {
397
+ if (!(e instanceof UserDataSyncStoreError)) {
398
+ let code = "RequestFailed" ;
399
+ const errorMessage = getErrorMessage(e).toLowerCase();
400
+ if (errorMessage.includes('xhr timeout')) {
401
+ code = "RequestTimeout" ;
402
+ }
403
+ else if (errorMessage.includes('protocol') && errorMessage.includes('not supported')) {
404
+ code = "RequestProtocolNotSupported" ;
405
+ }
406
+ else if (errorMessage.includes('request path contains unescaped characters')) {
407
+ code = "RequestPathNotEscaped" ;
408
+ }
409
+ else if (errorMessage.includes('headers must be an object')) {
410
+ code = "RequestHeadersNotObject" ;
411
+ }
412
+ else if (isCancellationError(e)) {
413
+ code = "RequestCanceled" ;
414
+ }
415
+ e = ( new UserDataSyncStoreError(
416
+ `Connection refused for the request '${url}'.`,
417
+ url,
418
+ code,
419
+ undefined,
420
+ undefined
421
+ ));
422
+ }
423
+ this.logService.info('Request failed', url);
424
+ throw e;
425
+ }
426
+ const operationId = context.res.headers[HEADER_OPERATION_ID];
427
+ const requestInfo = { url, status: context.res.statusCode, 'execution-id': options.headers[HEADER_EXECUTION_ID], 'operation-id': operationId };
428
+ const isSuccess$1 = isSuccess(context) || (context.res.statusCode && successCodes.includes(context.res.statusCode));
429
+ let failureMessage = '';
430
+ if (isSuccess$1) {
431
+ this.logService.trace('Request succeeded', requestInfo);
432
+ }
433
+ else {
434
+ failureMessage = (await asText(context)) || '';
435
+ this.logService.info('Request failed', requestInfo, failureMessage);
436
+ }
437
+ if (context.res.statusCode === 401 || context.res.statusCode === 403) {
438
+ this.authToken = undefined;
439
+ if (context.res.statusCode === 401) {
440
+ this._onTokenFailed.fire("Unauthorized" );
441
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of Unauthorized (401).`, url, "Unauthorized" , context.res.statusCode, operationId);
442
+ }
443
+ if (context.res.statusCode === 403) {
444
+ this._onTokenFailed.fire("Forbidden" );
445
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because the access is forbidden (403).`, url, "Forbidden" , context.res.statusCode, operationId);
446
+ }
447
+ }
448
+ this._onTokenSucceed.fire();
449
+ if (context.res.statusCode === 404) {
450
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because the requested resource is not found (404).`, url, "NotFound" , context.res.statusCode, operationId);
451
+ }
452
+ if (context.res.statusCode === 405) {
453
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because the requested endpoint is not found (405). ${failureMessage}`, url, "MethodNotFound" , context.res.statusCode, operationId);
454
+ }
455
+ if (context.res.statusCode === 409) {
456
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of Conflict (409). There is new data for this resource. Make the request again with latest data.`, url, "Conflict" , context.res.statusCode, operationId);
457
+ }
458
+ if (context.res.statusCode === 410) {
459
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because the requested resource is not longer available (410).`, url, "Gone" , context.res.statusCode, operationId);
460
+ }
461
+ if (context.res.statusCode === 412) {
462
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of Precondition Failed (412). There is new data for this resource. Make the request again with latest data.`, url, "PreconditionFailed" , context.res.statusCode, operationId);
463
+ }
464
+ if (context.res.statusCode === 413) {
465
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of too large payload (413).`, url, "TooLarge" , context.res.statusCode, operationId);
466
+ }
467
+ if (context.res.statusCode === 426) {
468
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed with status Upgrade Required (426). Please upgrade the client and try again.`, url, "UpgradeRequired" , context.res.statusCode, operationId);
469
+ }
470
+ if (context.res.statusCode === 429) {
471
+ const retryAfter = context.res.headers['retry-after'];
472
+ if (retryAfter) {
473
+ this.setDonotMakeRequestsUntil(( new Date(Date.now() + (parseInt(retryAfter) * 1000))));
474
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of too many requests (429).`, url, "TooManyRequestsAndRetryAfter" , context.res.statusCode, operationId);
475
+ }
476
+ else {
477
+ throw new UserDataSyncStoreError(`${options.type} request '${url}' failed because of too many requests (429).`, url, "RemoteTooManyRequests" , context.res.statusCode, operationId);
478
+ }
479
+ }
480
+ if (!isSuccess$1) {
481
+ throw new UserDataSyncStoreError('Server returned ' + context.res.statusCode, url, "Unknown" , context.res.statusCode, operationId);
482
+ }
483
+ return context;
484
+ }
485
+ addSessionHeaders(headers) {
486
+ let machineSessionId = this.storageService.get(MACHINE_SESSION_ID_KEY, -1 );
487
+ if (machineSessionId === undefined) {
488
+ machineSessionId = generateUuid();
489
+ this.storageService.store(MACHINE_SESSION_ID_KEY, machineSessionId, -1 , 1 );
490
+ }
491
+ headers['X-Machine-Session-Id'] = machineSessionId;
492
+ const userSessionId = this.storageService.get(USER_SESSION_ID_KEY, -1 );
493
+ if (userSessionId !== undefined) {
494
+ headers['X-User-Session-Id'] = userSessionId;
495
+ }
496
+ }
497
+ };
498
+ UserDataSyncStoreClient = ( __decorate([
499
+ ( __param(1, IProductService)),
500
+ ( __param(2, IRequestService)),
501
+ ( __param(3, IUserDataSyncLogService)),
502
+ ( __param(4, IEnvironmentService)),
503
+ ( __param(5, IFileService)),
504
+ ( __param(6, IStorageService))
505
+ ], UserDataSyncStoreClient));
506
+ let UserDataSyncStoreService = class UserDataSyncStoreService extends UserDataSyncStoreClient {
507
+ constructor(userDataSyncStoreManagementService, productService, requestService, logService, environmentService, fileService, storageService) {
508
+ super(userDataSyncStoreManagementService.userDataSyncStore?.url, productService, requestService, logService, environmentService, fileService, storageService);
509
+ this._register(userDataSyncStoreManagementService.onDidChangeUserDataSyncStore(() => this.updateUserDataSyncStoreUrl(userDataSyncStoreManagementService.userDataSyncStore?.url)));
510
+ }
511
+ };
512
+ UserDataSyncStoreService = ( __decorate([
513
+ ( __param(0, IUserDataSyncStoreManagementService)),
514
+ ( __param(1, IProductService)),
515
+ ( __param(2, IRequestService)),
516
+ ( __param(3, IUserDataSyncLogService)),
517
+ ( __param(4, IEnvironmentService)),
518
+ ( __param(5, IFileService)),
519
+ ( __param(6, IStorageService))
520
+ ], UserDataSyncStoreService));
521
+ class RequestsSession {
522
+ constructor(limit, interval, requestService, logService) {
523
+ this.limit = limit;
524
+ this.interval = interval;
525
+ this.requestService = requestService;
526
+ this.logService = logService;
527
+ this.requests = [];
528
+ this.startTime = undefined;
529
+ }
530
+ request(url, options, token) {
531
+ if (this.isExpired()) {
532
+ this.reset();
533
+ }
534
+ options.url = url;
535
+ if (this.requests.length >= this.limit) {
536
+ this.logService.info('Too many requests', ...this.requests);
537
+ throw new UserDataSyncStoreError(`Too many requests. Only ${this.limit} requests allowed in ${this.interval / (1000 * 60)} minutes.`, url, "LocalTooManyRequests" , undefined, undefined);
538
+ }
539
+ this.startTime = this.startTime || ( new Date());
540
+ this.requests.push(url);
541
+ return this.requestService.request(options, token);
542
+ }
543
+ isExpired() {
544
+ return this.startTime !== undefined && ( new Date()).getTime() - this.startTime.getTime() > this.interval;
545
+ }
546
+ reset() {
547
+ this.requests = [];
548
+ this.startTime = undefined;
549
+ }
550
+ }
551
+ export { AbstractUserDataSyncStoreManagementService, RequestsSession, UserDataSyncStoreClient, UserDataSyncStoreManagementService, UserDataSyncStoreService };
@@ -0,0 +1,22 @@
1
+ import { getMediaMime, Mimes } from '../../../base/common/mime.js';
2
+ import { extname } from '../../../base/common/path.js';
3
+ const webviewMimeTypes = ( new Map([
4
+ ['.svg', 'image/svg+xml'],
5
+ ['.txt', Mimes.text],
6
+ ['.css', 'text/css'],
7
+ ['.js', 'application/javascript'],
8
+ ['.cjs', 'application/javascript'],
9
+ ['.mjs', 'application/javascript'],
10
+ ['.json', 'application/json'],
11
+ ['.html', 'text/html'],
12
+ ['.htm', 'text/html'],
13
+ ['.xhtml', 'application/xhtml+xml'],
14
+ ['.oft', 'font/otf'],
15
+ ['.xml', 'application/xml'],
16
+ ['.wasm', 'application/wasm'],
17
+ ]));
18
+ function getWebviewContentMimeType(resource) {
19
+ const ext = extname(resource.fsPath).toLowerCase();
20
+ return webviewMimeTypes.get(ext) || getMediaMime(resource.fsPath) || Mimes.unknown;
21
+ }
22
+ export { getWebviewContentMimeType };
@@ -0,0 +1,62 @@
1
+ import { Schemas } from '../../../base/common/network.js';
2
+ import { URI } from '../../../base/common/uri.js';
3
+ import { extractLocalHostUriMetaDataForPortMapping } from '../../tunnel/common/tunnel.js';
4
+ class WebviewPortMappingManager {
5
+ constructor(_getExtensionLocation, _getMappings, tunnelService) {
6
+ this._getExtensionLocation = _getExtensionLocation;
7
+ this._getMappings = _getMappings;
8
+ this.tunnelService = tunnelService;
9
+ this._tunnels = ( new Map());
10
+ }
11
+ async getRedirect(resolveAuthority, url) {
12
+ const uri = ( URI.parse(url));
13
+ const requestLocalHostInfo = extractLocalHostUriMetaDataForPortMapping(uri);
14
+ if (!requestLocalHostInfo) {
15
+ return undefined;
16
+ }
17
+ for (const mapping of this._getMappings()) {
18
+ if (mapping.webviewPort === requestLocalHostInfo.port) {
19
+ const extensionLocation = this._getExtensionLocation();
20
+ if (extensionLocation && extensionLocation.scheme === Schemas.vscodeRemote) {
21
+ const tunnel = resolveAuthority && (await this.getOrCreateTunnel(resolveAuthority, mapping.extensionHostPort));
22
+ if (tunnel) {
23
+ if (tunnel.tunnelLocalPort === mapping.webviewPort) {
24
+ return undefined;
25
+ }
26
+ return encodeURI(( uri.with({
27
+ authority: `127.0.0.1:${tunnel.tunnelLocalPort}`,
28
+ }).toString(true)));
29
+ }
30
+ }
31
+ if (mapping.webviewPort !== mapping.extensionHostPort) {
32
+ return encodeURI(( uri.with({
33
+ authority: `${requestLocalHostInfo.address}:${mapping.extensionHostPort}`
34
+ }).toString(true)));
35
+ }
36
+ }
37
+ }
38
+ return undefined;
39
+ }
40
+ async dispose() {
41
+ for (const tunnel of ( this._tunnels.values())) {
42
+ await tunnel.dispose();
43
+ }
44
+ this._tunnels.clear();
45
+ }
46
+ async getOrCreateTunnel(remoteAuthority, remotePort) {
47
+ const existing = this._tunnels.get(remotePort);
48
+ if (existing) {
49
+ return existing;
50
+ }
51
+ const tunnelOrError = await this.tunnelService.openTunnel({ getAddress: async () => remoteAuthority }, undefined, remotePort);
52
+ let tunnel;
53
+ if (typeof tunnelOrError === 'string') {
54
+ tunnel = undefined;
55
+ }
56
+ if (tunnel) {
57
+ this._tunnels.set(remotePort, tunnel);
58
+ }
59
+ return tunnel;
60
+ }
61
+ }
62
+ export { WebviewPortMappingManager };