@vscode/chat-lib 0.0.1 → 0.0.2

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 (391) hide show
  1. package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
  2. package/dist/src/_internal/extension/xtab/common/promptCrafting.js +6 -5
  3. package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
  4. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +1 -0
  5. package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
  6. package/dist/src/_internal/platform/configuration/common/configurationService.js +1 -0
  7. package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
  8. package/dist/src/_internal/platform/env/common/envService.d.ts +5 -0
  9. package/dist/src/_internal/platform/env/common/envService.d.ts.map +1 -1
  10. package/dist/src/_internal/platform/env/common/envService.js +2 -1
  11. package/dist/src/_internal/platform/env/common/envService.js.map +1 -1
  12. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts +3 -0
  13. package/dist/src/_internal/platform/env/common/nullEnvService.d.ts.map +1 -1
  14. package/dist/src/_internal/platform/env/common/nullEnvService.js +8 -1
  15. package/dist/src/_internal/platform/env/common/nullEnvService.js.map +1 -1
  16. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts +7 -0
  17. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.d.ts.map +1 -1
  18. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js +1 -0
  19. package/dist/src/_internal/platform/telemetry/common/nullExperimentationService.js.map +1 -1
  20. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +8 -0
  21. package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
  22. package/dist/src/_internal/util/common/test/shims/chatTypes.js +19 -1
  23. package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
  24. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
  25. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +8 -1
  26. package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
  27. package/dist/src/_internal/vscodeTypes.d.ts +4 -0
  28. package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
  29. package/dist/src/_internal/vscodeTypes.js +5 -1
  30. package/dist/src/_internal/vscodeTypes.js.map +1 -1
  31. package/dist/src/main.d.ts +5 -0
  32. package/dist/src/main.d.ts.map +1 -1
  33. package/dist/src/main.js +12 -0
  34. package/dist/src/main.js.map +1 -1
  35. package/dist/src/package.json +46 -19
  36. package/package.json +3 -6
  37. package/src/_internal/extension/byok/node/openAIEndpoint.ts +0 -171
  38. package/src/_internal/extension/common/constants.ts +0 -90
  39. package/src/_internal/extension/inlineEdits/common/delayer.ts +0 -108
  40. package/src/_internal/extension/inlineEdits/common/editRebase.ts +0 -268
  41. package/src/_internal/extension/inlineEdits/common/ghNearbyNesProvider.tsx +0 -163
  42. package/src/_internal/extension/inlineEdits/common/nearbyCursorInlineEditProvider.ts +0 -225
  43. package/src/_internal/extension/inlineEdits/common/rejectionCollector.ts +0 -164
  44. package/src/_internal/extension/inlineEdits/node/debugRecorder.ts +0 -205
  45. package/src/_internal/extension/inlineEdits/node/importFiltering.ts +0 -25
  46. package/src/_internal/extension/inlineEdits/node/nesConfigs.ts +0 -12
  47. package/src/_internal/extension/inlineEdits/node/nextEditCache.ts +0 -278
  48. package/src/_internal/extension/inlineEdits/node/nextEditProvider.ts +0 -778
  49. package/src/_internal/extension/inlineEdits/node/nextEditProviderTelemetry.ts +0 -983
  50. package/src/_internal/extension/inlineEdits/node/nextEditResult.ts +0 -40
  51. package/src/_internal/extension/prompt/common/importStatement.ts +0 -25
  52. package/src/_internal/extension/prompt/node/chatMLFetcher.ts +0 -706
  53. package/src/_internal/extension/prompts/node/inline/summarizedDocument/fragments.ts +0 -146
  54. package/src/_internal/extension/prompts/node/inline/summarizedDocument/implementation.ts +0 -527
  55. package/src/_internal/extension/prompts/node/inline/summarizedDocument/projectedText.ts +0 -76
  56. package/src/_internal/extension/prompts/node/inline/visualization.ts +0 -65
  57. package/src/_internal/extension/vscode.proposed.activeComment.d.ts +0 -23
  58. package/src/_internal/extension/vscode.proposed.aiRelatedInformation.d.ts +0 -49
  59. package/src/_internal/extension/vscode.proposed.aiSettingsSearch.d.ts +0 -31
  60. package/src/_internal/extension/vscode.proposed.aiTextSearchProvider.d.ts +0 -41
  61. package/src/_internal/extension/vscode.proposed.authLearnMore.d.ts +0 -16
  62. package/src/_internal/extension/vscode.proposed.chatBinaryReferenceData.d.ts +0 -41
  63. package/src/_internal/extension/vscode.proposed.chatEditing.d.ts +0 -29
  64. package/src/_internal/extension/vscode.proposed.chatParticipantAdditions.d.ts +0 -636
  65. package/src/_internal/extension/vscode.proposed.chatParticipantPrivate.d.ts +0 -276
  66. package/src/_internal/extension/vscode.proposed.chatProvider.d.ts +0 -62
  67. package/src/_internal/extension/vscode.proposed.chatReadonlyPromptReference.d.ts +0 -17
  68. package/src/_internal/extension/vscode.proposed.chatReferenceDiagnostic.d.ts +0 -23
  69. package/src/_internal/extension/vscode.proposed.chatSessionsProvider.d.ts +0 -218
  70. package/src/_internal/extension/vscode.proposed.chatStatusItem.d.ts +0 -61
  71. package/src/_internal/extension/vscode.proposed.codeActionAI.d.ts +0 -16
  72. package/src/_internal/extension/vscode.proposed.commentReveal.d.ts +0 -32
  73. package/src/_internal/extension/vscode.proposed.contribCommentThreadAdditionalMenu.d.ts +0 -8
  74. package/src/_internal/extension/vscode.proposed.contribCommentsViewThreadMenus.d.ts +0 -6
  75. package/src/_internal/extension/vscode.proposed.contribSourceControlInputBoxMenu.d.ts +0 -7
  76. package/src/_internal/extension/vscode.proposed.dataChannels.d.ts +0 -19
  77. package/src/_internal/extension/vscode.proposed.defaultChatParticipant.d.ts +0 -52
  78. package/src/_internal/extension/vscode.proposed.documentFiltersExclusive.d.ts +0 -13
  79. package/src/_internal/extension/vscode.proposed.embeddings.d.ts +0 -33
  80. package/src/_internal/extension/vscode.proposed.extensionsAny.d.ts +0 -40
  81. package/src/_internal/extension/vscode.proposed.findFiles2.d.ts +0 -125
  82. package/src/_internal/extension/vscode.proposed.findTextInFiles.d.ts +0 -104
  83. package/src/_internal/extension/vscode.proposed.findTextInFiles2.d.ts +0 -144
  84. package/src/_internal/extension/vscode.proposed.inlineCompletionsAdditions.d.ts +0 -202
  85. package/src/_internal/extension/vscode.proposed.interactive.d.ts +0 -11
  86. package/src/_internal/extension/vscode.proposed.languageModelCapabilities.d.ts +0 -25
  87. package/src/_internal/extension/vscode.proposed.languageModelDataPart.d.ts +0 -163
  88. package/src/_internal/extension/vscode.proposed.languageModelSystem.d.ts +0 -17
  89. package/src/_internal/extension/vscode.proposed.languageModelThinkingPart.d.ts +0 -49
  90. package/src/_internal/extension/vscode.proposed.languageModelToolResultAudience.d.ts +0 -36
  91. package/src/_internal/extension/vscode.proposed.mappedEditsProvider.d.ts +0 -110
  92. package/src/_internal/extension/vscode.proposed.newSymbolNamesProvider.d.ts +0 -47
  93. package/src/_internal/extension/vscode.proposed.readonlyMessage.d.ts +0 -14
  94. package/src/_internal/extension/vscode.proposed.resolvers.d.ts +0 -475
  95. package/src/_internal/extension/vscode.proposed.scmInputBoxValueProvider.d.ts +0 -25
  96. package/src/_internal/extension/vscode.proposed.taskProblemMatcherStatus.d.ts +0 -42
  97. package/src/_internal/extension/vscode.proposed.terminalDataWriteEvent.d.ts +0 -32
  98. package/src/_internal/extension/vscode.proposed.terminalExecuteCommandEvent.d.ts +0 -48
  99. package/src/_internal/extension/vscode.proposed.terminalQuickFixProvider.d.ts +0 -87
  100. package/src/_internal/extension/vscode.proposed.terminalSelection.d.ts +0 -16
  101. package/src/_internal/extension/vscode.proposed.testObserver.d.ts +0 -199
  102. package/src/_internal/extension/vscode.proposed.textDocumentChangeReason.d.ts +0 -30
  103. package/src/_internal/extension/vscode.proposed.textSearchProvider.d.ts +0 -281
  104. package/src/_internal/extension/vscode.proposed.textSearchProvider2.d.ts +0 -297
  105. package/src/_internal/extension/xtab/common/promptCrafting.ts +0 -670
  106. package/src/_internal/extension/xtab/node/xtabEndpoint.ts +0 -102
  107. package/src/_internal/extension/xtab/node/xtabProvider.ts +0 -976
  108. package/src/_internal/extension/xtab/node/xtabUtils.ts +0 -62
  109. package/src/_internal/platform/authentication/common/authentication.ts +0 -309
  110. package/src/_internal/platform/authentication/common/copilotToken.ts +0 -300
  111. package/src/_internal/platform/authentication/common/copilotTokenManager.ts +0 -59
  112. package/src/_internal/platform/authentication/common/copilotTokenStore.ts +0 -40
  113. package/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.ts +0 -96
  114. package/src/_internal/platform/authentication/node/copilotTokenManager.ts +0 -303
  115. package/src/_internal/platform/chat/common/chatMLFetcher.ts +0 -124
  116. package/src/_internal/platform/chat/common/chatQuotaService.ts +0 -63
  117. package/src/_internal/platform/chat/common/chatQuotaServiceImpl.ts +0 -96
  118. package/src/_internal/platform/chat/common/commonTypes.ts +0 -353
  119. package/src/_internal/platform/chat/common/conversationOptions.ts +0 -16
  120. package/src/_internal/platform/chat/common/globalStringUtils.ts +0 -54
  121. package/src/_internal/platform/chat/common/interactionService.ts +0 -35
  122. package/src/_internal/platform/configuration/common/configurationService.ts +0 -803
  123. package/src/_internal/platform/configuration/common/defaultsOnlyConfigurationService.ts +0 -39
  124. package/src/_internal/platform/configuration/common/jsonSchema.ts +0 -139
  125. package/src/_internal/platform/configuration/common/validator.ts +0 -242
  126. package/src/_internal/platform/diff/common/diffService.ts +0 -41
  127. package/src/_internal/platform/diff/common/diffWorker.ts +0 -83
  128. package/src/_internal/platform/diff/node/diffServiceImpl.ts +0 -85
  129. package/src/_internal/platform/editing/common/abstractText.ts +0 -177
  130. package/src/_internal/platform/editing/common/notebookDocumentSnapshot.ts +0 -122
  131. package/src/_internal/platform/editing/common/positionOffsetTransformer.ts +0 -202
  132. package/src/_internal/platform/editing/common/textDocumentSnapshot.ts +0 -274
  133. package/src/_internal/platform/endpoint/common/capiClient.ts +0 -37
  134. package/src/_internal/platform/endpoint/common/chatModelCapabilities.ts +0 -115
  135. package/src/_internal/platform/endpoint/common/domainService.ts +0 -27
  136. package/src/_internal/platform/endpoint/common/endpointProvider.ts +0 -104
  137. package/src/_internal/platform/endpoint/common/endpointTypes.ts +0 -12
  138. package/src/_internal/platform/endpoint/common/licenseAgreement.ts +0 -11
  139. package/src/_internal/platform/endpoint/common/statefulMarkerContainer.tsx +0 -85
  140. package/src/_internal/platform/endpoint/common/thinkingDataContainer.tsx +0 -44
  141. package/src/_internal/platform/endpoint/node/capiClientImpl.ts +0 -18
  142. package/src/_internal/platform/endpoint/node/chatEndpoint.ts +0 -435
  143. package/src/_internal/platform/endpoint/node/domainServiceImpl.ts +0 -80
  144. package/src/_internal/platform/endpoint/node/proxyXtabEndpoint.ts +0 -43
  145. package/src/_internal/platform/endpoint/node/responsesApi.ts +0 -326
  146. package/src/_internal/platform/env/common/envService.ts +0 -134
  147. package/src/_internal/platform/env/common/nullEnvService.ts +0 -68
  148. package/src/_internal/platform/env/common/packagejson.ts +0 -49
  149. package/src/_internal/platform/git/common/gitExtensionService.ts +0 -21
  150. package/src/_internal/platform/git/common/nullGitExtensionService.ts +0 -20
  151. package/src/_internal/platform/git/vscode/git.d.ts +0 -414
  152. package/src/_internal/platform/github/common/githubAPI.ts +0 -44
  153. package/src/_internal/platform/github/common/githubService.ts +0 -87
  154. package/src/_internal/platform/github/common/nullOctokitServiceImpl.ts +0 -21
  155. package/src/_internal/platform/ignore/common/ignoreService.ts +0 -72
  156. package/src/_internal/platform/inlineCompletions/common/api.ts +0 -198
  157. package/src/_internal/platform/inlineEdits/common/dataTypes/diagnosticData.ts +0 -32
  158. package/src/_internal/platform/inlineEdits/common/dataTypes/documentId.ts +0 -52
  159. package/src/_internal/platform/inlineEdits/common/dataTypes/edit.ts +0 -165
  160. package/src/_internal/platform/inlineEdits/common/dataTypes/editUtils.ts +0 -74
  161. package/src/_internal/platform/inlineEdits/common/dataTypes/fetchCancellationError.ts +0 -14
  162. package/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.ts +0 -107
  163. package/src/_internal/platform/inlineEdits/common/dataTypes/languageId.ts +0 -14
  164. package/src/_internal/platform/inlineEdits/common/dataTypes/permutation.ts +0 -69
  165. package/src/_internal/platform/inlineEdits/common/dataTypes/rootedLineEdit.ts +0 -49
  166. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLength.ts +0 -74
  167. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/combineTextEditInfos.ts +0 -132
  168. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/length.ts +0 -184
  169. package/src/_internal/platform/inlineEdits/common/dataTypes/textEditLengthHelper/textEditInfo.ts +0 -32
  170. package/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.ts +0 -89
  171. package/src/_internal/platform/inlineEdits/common/debugRecorderBookmark.ts +0 -10
  172. package/src/_internal/platform/inlineEdits/common/editReason.ts +0 -134
  173. package/src/_internal/platform/inlineEdits/common/inlineEditLogContext.ts +0 -490
  174. package/src/_internal/platform/inlineEdits/common/observableGit.ts +0 -49
  175. package/src/_internal/platform/inlineEdits/common/observableWorkspace.ts +0 -239
  176. package/src/_internal/platform/inlineEdits/common/responseProcessor.ts +0 -249
  177. package/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.ts +0 -468
  178. package/src/_internal/platform/inlineEdits/common/statelessNextEditProviders.ts +0 -59
  179. package/src/_internal/platform/inlineEdits/common/utils/observable.ts +0 -54
  180. package/src/_internal/platform/inlineEdits/common/utils/stringifyChatMessages.ts +0 -29
  181. package/src/_internal/platform/inlineEdits/common/utils/utils.ts +0 -56
  182. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/historyContextProvider.ts +0 -60
  183. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesHistoryContextProvider.ts +0 -353
  184. package/src/_internal/platform/inlineEdits/common/workspaceEditTracker/nesXtabHistoryTracker.ts +0 -176
  185. package/src/_internal/platform/languageContextProvider/common/languageContextProviderService.ts +0 -25
  186. package/src/_internal/platform/languageContextProvider/common/nullLanguageContextProviderService.ts +0 -38
  187. package/src/_internal/platform/languageServer/common/languageContextService.ts +0 -186
  188. package/src/_internal/platform/languages/common/languageDiagnosticsService.ts +0 -67
  189. package/src/_internal/platform/languages/common/testLanguageDiagnosticsService.ts +0 -28
  190. package/src/_internal/platform/log/common/logService.ts +0 -232
  191. package/src/_internal/platform/nesFetch/common/completionsAPI.ts +0 -78
  192. package/src/_internal/platform/nesFetch/common/completionsFetchService.ts +0 -118
  193. package/src/_internal/platform/nesFetch/common/responseStream.ts +0 -151
  194. package/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts +0 -236
  195. package/src/_internal/platform/nesFetch/node/streamTransformer.ts +0 -95
  196. package/src/_internal/platform/networking/common/fetch.ts +0 -349
  197. package/src/_internal/platform/networking/common/fetcherService.ts +0 -84
  198. package/src/_internal/platform/networking/common/networking.ts +0 -442
  199. package/src/_internal/platform/networking/common/openai.ts +0 -273
  200. package/src/_internal/platform/networking/node/chatStream.ts +0 -137
  201. package/src/_internal/platform/networking/node/stream.ts +0 -749
  202. package/src/_internal/platform/notebook/common/alternativeContent.ts +0 -89
  203. package/src/_internal/platform/notebook/common/alternativeContentFormat.ts +0 -10
  204. package/src/_internal/platform/notebook/common/alternativeContentProvider.json.ts +0 -262
  205. package/src/_internal/platform/notebook/common/alternativeContentProvider.text.ts +0 -243
  206. package/src/_internal/platform/notebook/common/alternativeContentProvider.ts +0 -41
  207. package/src/_internal/platform/notebook/common/alternativeContentProvider.xml.ts +0 -205
  208. package/src/_internal/platform/notebook/common/alternativeNotebookDocument.ts +0 -155
  209. package/src/_internal/platform/notebook/common/helpers.ts +0 -212
  210. package/src/_internal/platform/notebook/common/notebookService.ts +0 -43
  211. package/src/_internal/platform/openai/node/fetch.ts +0 -596
  212. package/src/_internal/platform/parser/node/nodes.ts +0 -190
  213. package/src/_internal/platform/requestLogger/node/nullRequestLogger.ts +0 -26
  214. package/src/_internal/platform/requestLogger/node/requestLogger.ts +0 -383
  215. package/src/_internal/platform/simulationTestContext/common/simulationTestContext.ts +0 -29
  216. package/src/_internal/platform/snippy/common/snippyService.ts +0 -25
  217. package/src/_internal/platform/telemetry/common/nullExperimentationService.ts +0 -64
  218. package/src/_internal/platform/telemetry/common/nullTelemetryService.ts +0 -53
  219. package/src/_internal/platform/telemetry/common/telemetry.ts +0 -215
  220. package/src/_internal/platform/telemetry/common/telemetryData.ts +0 -205
  221. package/src/_internal/platform/thinking/common/thinking.ts +0 -61
  222. package/src/_internal/platform/thinking/common/thinkingUtils.ts +0 -57
  223. package/src/_internal/platform/tokenizer/node/parseTikTokens.ts +0 -23
  224. package/src/_internal/platform/tokenizer/node/tikTokenizerImpl.ts +0 -74
  225. package/src/_internal/platform/tokenizer/node/tikTokenizerWorker.ts +0 -24
  226. package/src/_internal/platform/tokenizer/node/tokenizer.ts +0 -357
  227. package/src/_internal/platform/workspace/common/workspaceService.ts +0 -226
  228. package/src/_internal/platform/workspaceRecorder/common/workspaceLog.ts +0 -118
  229. package/src/_internal/util/common/anomalyDetection.ts +0 -112
  230. package/src/_internal/util/common/arrays.ts +0 -81
  231. package/src/_internal/util/common/async.ts +0 -155
  232. package/src/_internal/util/common/cache.ts +0 -183
  233. package/src/_internal/util/common/crypto.ts +0 -41
  234. package/src/_internal/util/common/errors.ts +0 -22
  235. package/src/_internal/util/common/globals.d.ts +0 -12
  236. package/src/_internal/util/common/imageUtils.ts +0 -154
  237. package/src/_internal/util/common/languages.ts +0 -940
  238. package/src/_internal/util/common/notebooks.ts +0 -286
  239. package/src/_internal/util/common/result.ts +0 -71
  240. package/src/_internal/util/common/services.ts +0 -43
  241. package/src/_internal/util/common/test/shims/chatTypes.ts +0 -448
  242. package/src/_internal/util/common/test/shims/editing.ts +0 -233
  243. package/src/_internal/util/common/test/shims/enums.ts +0 -61
  244. package/src/_internal/util/common/test/shims/l10n.ts +0 -37
  245. package/src/_internal/util/common/test/shims/newSymbolName.ts +0 -23
  246. package/src/_internal/util/common/test/shims/terminal.ts +0 -33
  247. package/src/_internal/util/common/test/shims/vscodeTypesShim.ts +0 -115
  248. package/src/_internal/util/common/time.ts +0 -31
  249. package/src/_internal/util/common/tokenizer.ts +0 -30
  250. package/src/_internal/util/common/tracing.ts +0 -52
  251. package/src/_internal/util/common/types.ts +0 -33
  252. package/src/_internal/util/common/variableLengthQuantity.ts +0 -40
  253. package/src/_internal/util/node/worker.ts +0 -130
  254. package/src/_internal/util/vs/base/common/arrays.ts +0 -926
  255. package/src/_internal/util/vs/base/common/arraysFind.ts +0 -206
  256. package/src/_internal/util/vs/base/common/assert.ts +0 -89
  257. package/src/_internal/util/vs/base/common/async.ts +0 -2582
  258. package/src/_internal/util/vs/base/common/buffer.ts +0 -501
  259. package/src/_internal/util/vs/base/common/cache.ts +0 -122
  260. package/src/_internal/util/vs/base/common/cancellation.ts +0 -150
  261. package/src/_internal/util/vs/base/common/charCode.ts +0 -452
  262. package/src/_internal/util/vs/base/common/codicons.ts +0 -66
  263. package/src/_internal/util/vs/base/common/codiconsLibrary.ts +0 -618
  264. package/src/_internal/util/vs/base/common/codiconsUtil.ts +0 -30
  265. package/src/_internal/util/vs/base/common/collections.ts +0 -156
  266. package/src/_internal/util/vs/base/common/diff/diff.ts +0 -1317
  267. package/src/_internal/util/vs/base/common/diff/diffChange.ts +0 -62
  268. package/src/_internal/util/vs/base/common/equals.ts +0 -148
  269. package/src/_internal/util/vs/base/common/errors.ts +0 -342
  270. package/src/_internal/util/vs/base/common/event.ts +0 -1782
  271. package/src/_internal/util/vs/base/common/extpath.ts +0 -425
  272. package/src/_internal/util/vs/base/common/filters.ts +0 -928
  273. package/src/_internal/util/vs/base/common/functional.ts +0 -34
  274. package/src/_internal/util/vs/base/common/glob.ts +0 -839
  275. package/src/_internal/util/vs/base/common/hash.ts +0 -326
  276. package/src/_internal/util/vs/base/common/htmlContent.ts +0 -212
  277. package/src/_internal/util/vs/base/common/iconLabels.ts +0 -118
  278. package/src/_internal/util/vs/base/common/iterator.ts +0 -196
  279. package/src/_internal/util/vs/base/common/lazy.ts +0 -59
  280. package/src/_internal/util/vs/base/common/lifecycle.ts +0 -845
  281. package/src/_internal/util/vs/base/common/linkedList.ts +0 -144
  282. package/src/_internal/util/vs/base/common/map.ts +0 -954
  283. package/src/_internal/util/vs/base/common/marshallingIds.ts +0 -35
  284. package/src/_internal/util/vs/base/common/mime.ts +0 -136
  285. package/src/_internal/util/vs/base/common/naturalLanguage/korean.ts +0 -425
  286. package/src/_internal/util/vs/base/common/network.ts +0 -429
  287. package/src/_internal/util/vs/base/common/numbers.ts +0 -166
  288. package/src/_internal/util/vs/base/common/objects.ts +0 -242
  289. package/src/_internal/util/vs/base/common/observable.ts +0 -10
  290. package/src/_internal/util/vs/base/common/observableInternal/base.ts +0 -208
  291. package/src/_internal/util/vs/base/common/observableInternal/changeTracker.ts +0 -96
  292. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/cancellation.ts +0 -9
  293. package/src/_internal/util/vs/base/common/observableInternal/commonFacade/deps.ts +0 -12
  294. package/src/_internal/util/vs/base/common/observableInternal/debugLocation.ts +0 -88
  295. package/src/_internal/util/vs/base/common/observableInternal/debugName.ts +0 -150
  296. package/src/_internal/util/vs/base/common/observableInternal/experimental/utils.ts +0 -62
  297. package/src/_internal/util/vs/base/common/observableInternal/index.ts +0 -61
  298. package/src/_internal/util/vs/base/common/observableInternal/logging/consoleObservableLogger.ts +0 -388
  299. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerApi.d.ts +0 -154
  300. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/debuggerRpc.ts +0 -80
  301. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/devToolsLogger.ts +0 -485
  302. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/rpc.ts +0 -103
  303. package/src/_internal/util/vs/base/common/observableInternal/logging/debugger/utils.ts +0 -69
  304. package/src/_internal/util/vs/base/common/observableInternal/logging/logging.ts +0 -133
  305. package/src/_internal/util/vs/base/common/observableInternal/map.ts +0 -81
  306. package/src/_internal/util/vs/base/common/observableInternal/observables/baseObservable.ts +0 -172
  307. package/src/_internal/util/vs/base/common/observableInternal/observables/constObservable.ts +0 -44
  308. package/src/_internal/util/vs/base/common/observableInternal/observables/derived.ts +0 -190
  309. package/src/_internal/util/vs/base/common/observableInternal/observables/derivedImpl.ts +0 -445
  310. package/src/_internal/util/vs/base/common/observableInternal/observables/lazyObservableValue.ts +0 -154
  311. package/src/_internal/util/vs/base/common/observableInternal/observables/observableFromEvent.ts +0 -174
  312. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignal.ts +0 -67
  313. package/src/_internal/util/vs/base/common/observableInternal/observables/observableSignalFromEvent.ts +0 -62
  314. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValue.ts +0 -131
  315. package/src/_internal/util/vs/base/common/observableInternal/observables/observableValueOpts.ts +0 -37
  316. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorun.ts +0 -188
  317. package/src/_internal/util/vs/base/common/observableInternal/reactions/autorunImpl.ts +0 -256
  318. package/src/_internal/util/vs/base/common/observableInternal/set.ts +0 -78
  319. package/src/_internal/util/vs/base/common/observableInternal/transaction.ts +0 -115
  320. package/src/_internal/util/vs/base/common/observableInternal/utils/promise.ts +0 -129
  321. package/src/_internal/util/vs/base/common/observableInternal/utils/runOnChange.ts +0 -65
  322. package/src/_internal/util/vs/base/common/observableInternal/utils/utils.ts +0 -281
  323. package/src/_internal/util/vs/base/common/observableInternal/utils/utilsCancellation.ts +0 -101
  324. package/src/_internal/util/vs/base/common/observableInternal/utils/valueWithChangeEvent.ts +0 -31
  325. package/src/_internal/util/vs/base/common/path.ts +0 -1591
  326. package/src/_internal/util/vs/base/common/platform.ts +0 -282
  327. package/src/_internal/util/vs/base/common/process.ts +0 -78
  328. package/src/_internal/util/vs/base/common/resources.ts +0 -446
  329. package/src/_internal/util/vs/base/common/sequence.ts +0 -36
  330. package/src/_internal/util/vs/base/common/sseParser.ts +0 -247
  331. package/src/_internal/util/vs/base/common/stopwatch.ts +0 -43
  332. package/src/_internal/util/vs/base/common/stream.ts +0 -792
  333. package/src/_internal/util/vs/base/common/strings.ts +0 -1364
  334. package/src/_internal/util/vs/base/common/symbols.ts +0 -11
  335. package/src/_internal/util/vs/base/common/themables.ts +0 -106
  336. package/src/_internal/util/vs/base/common/types.ts +0 -345
  337. package/src/_internal/util/vs/base/common/uint.ts +0 -61
  338. package/src/_internal/util/vs/base/common/uri.ts +0 -752
  339. package/src/_internal/util/vs/base/common/uuid.ts +0 -72
  340. package/src/_internal/util/vs/base-common.d.ts +0 -42
  341. package/src/_internal/util/vs/editor/common/core/editOperation.ts +0 -62
  342. package/src/_internal/util/vs/editor/common/core/edits/edit.ts +0 -399
  343. package/src/_internal/util/vs/editor/common/core/edits/lineEdit.ts +0 -414
  344. package/src/_internal/util/vs/editor/common/core/edits/stringEdit.ts +0 -568
  345. package/src/_internal/util/vs/editor/common/core/edits/textEdit.ts +0 -411
  346. package/src/_internal/util/vs/editor/common/core/position.ts +0 -186
  347. package/src/_internal/util/vs/editor/common/core/range.ts +0 -519
  348. package/src/_internal/util/vs/editor/common/core/ranges/lineRange.ts +0 -416
  349. package/src/_internal/util/vs/editor/common/core/ranges/offsetRange.ts +0 -275
  350. package/src/_internal/util/vs/editor/common/core/text/abstractText.ts +0 -127
  351. package/src/_internal/util/vs/editor/common/core/text/positionToOffset.ts +0 -26
  352. package/src/_internal/util/vs/editor/common/core/text/positionToOffsetImpl.ts +0 -144
  353. package/src/_internal/util/vs/editor/common/core/text/textLength.ts +0 -150
  354. package/src/_internal/util/vs/editor/common/core/wordHelper.ts +0 -177
  355. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/diffAlgorithm.ts +0 -210
  356. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/dynamicProgrammingDiffing.ts +0 -109
  357. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/algorithms/myersDiffAlgorithm.ts +0 -178
  358. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/computeMovedLines.ts +0 -331
  359. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/defaultLinesDiffComputer.ts +0 -273
  360. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/heuristicSequenceOptimizations.ts +0 -475
  361. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/lineSequence.ts +0 -47
  362. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/linesSliceCharSequence.ts +0 -248
  363. package/src/_internal/util/vs/editor/common/diff/defaultLinesDiffComputer/utils.ts +0 -76
  364. package/src/_internal/util/vs/editor/common/diff/legacyLinesDiffComputer.ts +0 -693
  365. package/src/_internal/util/vs/editor/common/diff/linesDiffComputer.ts +0 -61
  366. package/src/_internal/util/vs/editor/common/diff/rangeMapping.ts +0 -418
  367. package/src/_internal/util/vs/editor/common/model/prefixSumComputer.ts +0 -304
  368. package/src/_internal/util/vs/nls.messages.ts +0 -21
  369. package/src/_internal/util/vs/nls.ts +0 -243
  370. package/src/_internal/util/vs/platform/instantiation/common/descriptors.ts +0 -23
  371. package/src/_internal/util/vs/platform/instantiation/common/graph.ts +0 -113
  372. package/src/_internal/util/vs/platform/instantiation/common/instantiation.ts +0 -127
  373. package/src/_internal/util/vs/platform/instantiation/common/instantiationService.ts +0 -483
  374. package/src/_internal/util/vs/platform/instantiation/common/serviceCollection.ts +0 -34
  375. package/src/_internal/util/vs/vscode-globals-nls.d.ts +0 -42
  376. package/src/_internal/util/vs/vscode-globals-product.d.ts +0 -35
  377. package/src/_internal/util/vs/workbench/api/common/extHostTypes/diagnostic.ts +0 -109
  378. package/src/_internal/util/vs/workbench/api/common/extHostTypes/es5ClassCompat.ts +0 -34
  379. package/src/_internal/util/vs/workbench/api/common/extHostTypes/location.ts +0 -51
  380. package/src/_internal/util/vs/workbench/api/common/extHostTypes/markdownString.ts +0 -83
  381. package/src/_internal/util/vs/workbench/api/common/extHostTypes/notebooks.ts +0 -296
  382. package/src/_internal/util/vs/workbench/api/common/extHostTypes/position.ts +0 -195
  383. package/src/_internal/util/vs/workbench/api/common/extHostTypes/range.ts +0 -167
  384. package/src/_internal/util/vs/workbench/api/common/extHostTypes/selection.ts +0 -94
  385. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetString.ts +0 -103
  386. package/src/_internal/util/vs/workbench/api/common/extHostTypes/snippetTextEdit.ts +0 -44
  387. package/src/_internal/util/vs/workbench/api/common/extHostTypes/symbolInformation.ts +0 -89
  388. package/src/_internal/util/vs/workbench/api/common/extHostTypes/textEdit.ts +0 -99
  389. package/src/_internal/vscodeTypes.ts +0 -100
  390. package/src/main.ts +0 -207
  391. package/src/package.json +0 -4063
@@ -1,926 +0,0 @@
1
- //!!! DO NOT modify, this file was COPIED from 'microsoft/vscode'
2
-
3
- /*---------------------------------------------------------------------------------------------
4
- * Copyright (c) Microsoft Corporation. All rights reserved.
5
- * Licensed under the MIT License. See License.txt in the project root for license information.
6
- *--------------------------------------------------------------------------------------------*/
7
-
8
- import { findFirstIdxMonotonousOrArrLen } from './arraysFind';
9
- import { CancellationToken } from './cancellation';
10
- import { CancellationError } from './errors';
11
- import { ISplice } from './sequence';
12
-
13
- /**
14
- * Returns the last entry and the initial N-1 entries of the array, as a tuple of [rest, last].
15
- *
16
- * The array must have at least one element.
17
- *
18
- * @param arr The input array
19
- * @returns A tuple of [rest, last] where rest is all but the last element and last is the last element
20
- * @throws Error if the array is empty
21
- */
22
- export function tail<T>(arr: T[]): [T[], T] {
23
- if (arr.length === 0) {
24
- throw new Error('Invalid tail call');
25
- }
26
-
27
- return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
28
- }
29
-
30
- export function equals<T>(one: ReadonlyArray<T> | undefined, other: ReadonlyArray<T> | undefined, itemEquals: (a: T, b: T) => boolean = (a, b) => a === b): boolean {
31
- if (one === other) {
32
- return true;
33
- }
34
-
35
- if (!one || !other) {
36
- return false;
37
- }
38
-
39
- if (one.length !== other.length) {
40
- return false;
41
- }
42
-
43
- for (let i = 0, len = one.length; i < len; i++) {
44
- if (!itemEquals(one[i], other[i])) {
45
- return false;
46
- }
47
- }
48
-
49
- return true;
50
- }
51
-
52
- /**
53
- * Remove the element at `index` by replacing it with the last element. This is faster than `splice`
54
- * but changes the order of the array
55
- */
56
- export function removeFastWithoutKeepingOrder<T>(array: T[], index: number) {
57
- const last = array.length - 1;
58
- if (index < last) {
59
- array[index] = array[last];
60
- }
61
- array.pop();
62
- }
63
-
64
- /**
65
- * Performs a binary search algorithm over a sorted array.
66
- *
67
- * @param array The array being searched.
68
- * @param key The value we search for.
69
- * @param comparator A function that takes two array elements and returns zero
70
- * if they are equal, a negative number if the first element precedes the
71
- * second one in the sorting order, or a positive number if the second element
72
- * precedes the first one.
73
- * @return See {@link binarySearch2}
74
- */
75
- export function binarySearch<T>(array: ReadonlyArray<T>, key: T, comparator: (op1: T, op2: T) => number): number {
76
- return binarySearch2(array.length, i => comparator(array[i], key));
77
- }
78
-
79
- /**
80
- * Performs a binary search algorithm over a sorted collection. Useful for cases
81
- * when we need to perform a binary search over something that isn't actually an
82
- * array, and converting data to an array would defeat the use of binary search
83
- * in the first place.
84
- *
85
- * @param length The collection length.
86
- * @param compareToKey A function that takes an index of an element in the
87
- * collection and returns zero if the value at this index is equal to the
88
- * search key, a negative number if the value precedes the search key in the
89
- * sorting order, or a positive number if the search key precedes the value.
90
- * @return A non-negative index of an element, if found. If not found, the
91
- * result is -(n+1) (or ~n, using bitwise notation), where n is the index
92
- * where the key should be inserted to maintain the sorting order.
93
- */
94
- export function binarySearch2(length: number, compareToKey: (index: number) => number): number {
95
- let low = 0,
96
- high = length - 1;
97
-
98
- while (low <= high) {
99
- const mid = ((low + high) / 2) | 0;
100
- const comp = compareToKey(mid);
101
- if (comp < 0) {
102
- low = mid + 1;
103
- } else if (comp > 0) {
104
- high = mid - 1;
105
- } else {
106
- return mid;
107
- }
108
- }
109
- return -(low + 1);
110
- }
111
-
112
- type Compare<T> = (a: T, b: T) => number;
113
-
114
-
115
- export function quickSelect<T>(nth: number, data: T[], compare: Compare<T>): T {
116
-
117
- nth = nth | 0;
118
-
119
- if (nth >= data.length) {
120
- throw new TypeError('invalid index');
121
- }
122
-
123
- const pivotValue = data[Math.floor(data.length * Math.random())];
124
- const lower: T[] = [];
125
- const higher: T[] = [];
126
- const pivots: T[] = [];
127
-
128
- for (const value of data) {
129
- const val = compare(value, pivotValue);
130
- if (val < 0) {
131
- lower.push(value);
132
- } else if (val > 0) {
133
- higher.push(value);
134
- } else {
135
- pivots.push(value);
136
- }
137
- }
138
-
139
- if (nth < lower.length) {
140
- return quickSelect(nth, lower, compare);
141
- } else if (nth < lower.length + pivots.length) {
142
- return pivots[0];
143
- } else {
144
- return quickSelect(nth - (lower.length + pivots.length), higher, compare);
145
- }
146
- }
147
-
148
- export function groupBy<T>(data: ReadonlyArray<T>, compare: (a: T, b: T) => number): T[][] {
149
- const result: T[][] = [];
150
- let currentGroup: T[] | undefined = undefined;
151
- for (const element of data.slice(0).sort(compare)) {
152
- if (!currentGroup || compare(currentGroup[0], element) !== 0) {
153
- currentGroup = [element];
154
- result.push(currentGroup);
155
- } else {
156
- currentGroup.push(element);
157
- }
158
- }
159
- return result;
160
- }
161
-
162
- /**
163
- * Splits the given items into a list of (non-empty) groups.
164
- * `shouldBeGrouped` is used to decide if two consecutive items should be in the same group.
165
- * The order of the items is preserved.
166
- */
167
- export function* groupAdjacentBy<T>(items: Iterable<T>, shouldBeGrouped: (item1: T, item2: T) => boolean): Iterable<T[]> {
168
- let currentGroup: T[] | undefined;
169
- let last: T | undefined;
170
- for (const item of items) {
171
- if (last !== undefined && shouldBeGrouped(last, item)) {
172
- currentGroup!.push(item);
173
- } else {
174
- if (currentGroup) {
175
- yield currentGroup;
176
- }
177
- currentGroup = [item];
178
- }
179
- last = item;
180
- }
181
- if (currentGroup) {
182
- yield currentGroup;
183
- }
184
- }
185
-
186
- export function forEachAdjacent<T>(arr: T[], f: (item1: T | undefined, item2: T | undefined) => void): void {
187
- for (let i = 0; i <= arr.length; i++) {
188
- f(i === 0 ? undefined : arr[i - 1], i === arr.length ? undefined : arr[i]);
189
- }
190
- }
191
-
192
- export function forEachWithNeighbors<T>(arr: T[], f: (before: T | undefined, element: T, after: T | undefined) => void): void {
193
- for (let i = 0; i < arr.length; i++) {
194
- f(i === 0 ? undefined : arr[i - 1], arr[i], i + 1 === arr.length ? undefined : arr[i + 1]);
195
- }
196
- }
197
-
198
- export function concatArrays<TArr extends any[]>(...arrays: TArr): TArr[number][number][] {
199
- return ([] as any[]).concat(...arrays);
200
- }
201
-
202
- interface IMutableSplice<T> extends ISplice<T> {
203
- readonly toInsert: T[];
204
- deleteCount: number;
205
- }
206
-
207
- /**
208
- * Diffs two *sorted* arrays and computes the splices which apply the diff.
209
- */
210
- export function sortedDiff<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): ISplice<T>[] {
211
- const result: IMutableSplice<T>[] = [];
212
-
213
- function pushSplice(start: number, deleteCount: number, toInsert: T[]): void {
214
- if (deleteCount === 0 && toInsert.length === 0) {
215
- return;
216
- }
217
-
218
- const latest = result[result.length - 1];
219
-
220
- if (latest && latest.start + latest.deleteCount === start) {
221
- latest.deleteCount += deleteCount;
222
- latest.toInsert.push(...toInsert);
223
- } else {
224
- result.push({ start, deleteCount, toInsert });
225
- }
226
- }
227
-
228
- let beforeIdx = 0;
229
- let afterIdx = 0;
230
-
231
- while (true) {
232
- if (beforeIdx === before.length) {
233
- pushSplice(beforeIdx, 0, after.slice(afterIdx));
234
- break;
235
- }
236
- if (afterIdx === after.length) {
237
- pushSplice(beforeIdx, before.length - beforeIdx, []);
238
- break;
239
- }
240
-
241
- const beforeElement = before[beforeIdx];
242
- const afterElement = after[afterIdx];
243
- const n = compare(beforeElement, afterElement);
244
- if (n === 0) {
245
- // equal
246
- beforeIdx += 1;
247
- afterIdx += 1;
248
- } else if (n < 0) {
249
- // beforeElement is smaller -> before element removed
250
- pushSplice(beforeIdx, 1, []);
251
- beforeIdx += 1;
252
- } else if (n > 0) {
253
- // beforeElement is greater -> after element added
254
- pushSplice(beforeIdx, 0, [afterElement]);
255
- afterIdx += 1;
256
- }
257
- }
258
-
259
- return result;
260
- }
261
-
262
- /**
263
- * Takes two *sorted* arrays and computes their delta (removed, added elements).
264
- * Finishes in `Math.min(before.length, after.length)` steps.
265
- */
266
- export function delta<T>(before: ReadonlyArray<T>, after: ReadonlyArray<T>, compare: (a: T, b: T) => number): { removed: T[]; added: T[] } {
267
- const splices = sortedDiff(before, after, compare);
268
- const removed: T[] = [];
269
- const added: T[] = [];
270
-
271
- for (const splice of splices) {
272
- removed.push(...before.slice(splice.start, splice.start + splice.deleteCount));
273
- added.push(...splice.toInsert);
274
- }
275
-
276
- return { removed, added };
277
- }
278
-
279
- /**
280
- * Returns the top N elements from the array.
281
- *
282
- * Faster than sorting the entire array when the array is a lot larger than N.
283
- *
284
- * @param array The unsorted array.
285
- * @param compare A sort function for the elements.
286
- * @param n The number of elements to return.
287
- * @return The first n elements from array when sorted with compare.
288
- */
289
- export function top<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, n: number): T[] {
290
- if (n === 0) {
291
- return [];
292
- }
293
- const result = array.slice(0, n).sort(compare);
294
- topStep(array, compare, result, n, array.length);
295
- return result;
296
- }
297
-
298
- /**
299
- * Asynchronous variant of `top()` allowing for splitting up work in batches between which the event loop can run.
300
- *
301
- * Returns the top N elements from the array.
302
- *
303
- * Faster than sorting the entire array when the array is a lot larger than N.
304
- *
305
- * @param array The unsorted array.
306
- * @param compare A sort function for the elements.
307
- * @param n The number of elements to return.
308
- * @param batch The number of elements to examine before yielding to the event loop.
309
- * @return The first n elements from array when sorted with compare.
310
- */
311
- export function topAsync<T>(array: T[], compare: (a: T, b: T) => number, n: number, batch: number, token?: CancellationToken): Promise<T[]> {
312
- if (n === 0) {
313
- return Promise.resolve([]);
314
- }
315
-
316
- return new Promise((resolve, reject) => {
317
- (async () => {
318
- const o = array.length;
319
- const result = array.slice(0, n).sort(compare);
320
- for (let i = n, m = Math.min(n + batch, o); i < o; i = m, m = Math.min(m + batch, o)) {
321
- if (i > n) {
322
- await new Promise(resolve => setTimeout(resolve)); // any other delay function would starve I/O
323
- }
324
- if (token && token.isCancellationRequested) {
325
- throw new CancellationError();
326
- }
327
- topStep(array, compare, result, i, m);
328
- }
329
- return result;
330
- })()
331
- .then(resolve, reject);
332
- });
333
- }
334
-
335
- function topStep<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, result: T[], i: number, m: number): void {
336
- for (const n = result.length; i < m; i++) {
337
- const element = array[i];
338
- if (compare(element, result[n - 1]) < 0) {
339
- result.pop();
340
- const j = findFirstIdxMonotonousOrArrLen(result, e => compare(element, e) < 0);
341
- result.splice(j, 0, element);
342
- }
343
- }
344
- }
345
-
346
- /**
347
- * @returns New array with all falsy values removed. The original array IS NOT modified.
348
- */
349
- export function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[] {
350
- return array.filter((e): e is T => !!e);
351
- }
352
-
353
- /**
354
- * Remove all falsy values from `array`. The original array IS modified.
355
- */
356
- export function coalesceInPlace<T>(array: Array<T | undefined | null>): asserts array is Array<T> {
357
- let to = 0;
358
- for (let i = 0; i < array.length; i++) {
359
- if (!!array[i]) {
360
- array[to] = array[i];
361
- to += 1;
362
- }
363
- }
364
- array.length = to;
365
- }
366
-
367
- /**
368
- * @deprecated Use `Array.copyWithin` instead
369
- */
370
- export function move(array: unknown[], from: number, to: number): void {
371
- array.splice(to, 0, array.splice(from, 1)[0]);
372
- }
373
-
374
- /**
375
- * @returns false if the provided object is an array and not empty.
376
- */
377
- export function isFalsyOrEmpty(obj: unknown): boolean {
378
- return !Array.isArray(obj) || obj.length === 0;
379
- }
380
-
381
- /**
382
- * @returns True if the provided object is an array and has at least one element.
383
- */
384
- export function isNonEmptyArray<T>(obj: T[] | undefined | null): obj is T[];
385
- export function isNonEmptyArray<T>(obj: readonly T[] | undefined | null): obj is readonly T[];
386
- export function isNonEmptyArray<T>(obj: T[] | readonly T[] | undefined | null): obj is T[] | readonly T[] {
387
- return Array.isArray(obj) && obj.length > 0;
388
- }
389
-
390
- /**
391
- * Removes duplicates from the given array. The optional keyFn allows to specify
392
- * how elements are checked for equality by returning an alternate value for each.
393
- */
394
- export function distinct<T>(array: ReadonlyArray<T>, keyFn: (value: T) => unknown = value => value): T[] {
395
- const seen = new Set<any>();
396
-
397
- return array.filter(element => {
398
- const key = keyFn!(element);
399
- if (seen.has(key)) {
400
- return false;
401
- }
402
- seen.add(key);
403
- return true;
404
- });
405
- }
406
-
407
- export function uniqueFilter<T, R>(keyFn: (t: T) => R): (t: T) => boolean {
408
- const seen = new Set<R>();
409
-
410
- return element => {
411
- const key = keyFn(element);
412
-
413
- if (seen.has(key)) {
414
- return false;
415
- }
416
-
417
- seen.add(key);
418
- return true;
419
- };
420
- }
421
-
422
- export function commonPrefixLength<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, equals: (a: T, b: T) => boolean = (a, b) => a === b): number {
423
- let result = 0;
424
-
425
- for (let i = 0, len = Math.min(one.length, other.length); i < len && equals(one[i], other[i]); i++) {
426
- result++;
427
- }
428
-
429
- return result;
430
- }
431
-
432
- export function range(to: number): number[];
433
- export function range(from: number, to: number): number[];
434
- export function range(arg: number, to?: number): number[] {
435
- let from = typeof to === 'number' ? arg : 0;
436
-
437
- if (typeof to === 'number') {
438
- from = arg;
439
- } else {
440
- from = 0;
441
- to = arg;
442
- }
443
-
444
- const result: number[] = [];
445
-
446
- if (from <= to) {
447
- for (let i = from; i < to; i++) {
448
- result.push(i);
449
- }
450
- } else {
451
- for (let i = from; i > to; i--) {
452
- result.push(i);
453
- }
454
- }
455
-
456
- return result;
457
- }
458
-
459
- export function index<T>(array: ReadonlyArray<T>, indexer: (t: T) => string): { [key: string]: T };
460
- export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper: (t: T) => R): { [key: string]: R };
461
- export function index<T, R>(array: ReadonlyArray<T>, indexer: (t: T) => string, mapper?: (t: T) => R): { [key: string]: R } {
462
- return array.reduce((r, t) => {
463
- r[indexer(t)] = mapper ? mapper(t) : t;
464
- return r;
465
- }, Object.create(null));
466
- }
467
-
468
- /**
469
- * Inserts an element into an array. Returns a function which, when
470
- * called, will remove that element from the array.
471
- *
472
- * @deprecated In almost all cases, use a `Set<T>` instead.
473
- */
474
- export function insert<T>(array: T[], element: T): () => void {
475
- array.push(element);
476
-
477
- return () => remove(array, element);
478
- }
479
-
480
- /**
481
- * Removes an element from an array if it can be found.
482
- *
483
- * @deprecated In almost all cases, use a `Set<T>` instead.
484
- */
485
- export function remove<T>(array: T[], element: T): T | undefined {
486
- const index = array.indexOf(element);
487
- if (index > -1) {
488
- array.splice(index, 1);
489
-
490
- return element;
491
- }
492
-
493
- return undefined;
494
- }
495
-
496
- /**
497
- * Insert `insertArr` inside `target` at `insertIndex`.
498
- * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
499
- */
500
- export function arrayInsert<T>(target: T[], insertIndex: number, insertArr: T[]): T[] {
501
- const before = target.slice(0, insertIndex);
502
- const after = target.slice(insertIndex);
503
- return before.concat(insertArr, after);
504
- }
505
-
506
- /**
507
- * Uses Fisher-Yates shuffle to shuffle the given array
508
- */
509
- export function shuffle<T>(array: T[], _seed?: number): void {
510
- let rand: () => number;
511
-
512
- if (typeof _seed === 'number') {
513
- let seed = _seed;
514
- // Seeded random number generator in JS. Modified from:
515
- // https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript
516
- rand = () => {
517
- const x = Math.sin(seed++) * 179426549; // throw away most significant digits and reduce any potential bias
518
- return x - Math.floor(x);
519
- };
520
- } else {
521
- rand = Math.random;
522
- }
523
-
524
- for (let i = array.length - 1; i > 0; i -= 1) {
525
- const j = Math.floor(rand() * (i + 1));
526
- const temp = array[i];
527
- array[i] = array[j];
528
- array[j] = temp;
529
- }
530
- }
531
-
532
- /**
533
- * Pushes an element to the start of the array, if found.
534
- */
535
- export function pushToStart<T>(arr: T[], value: T): void {
536
- const index = arr.indexOf(value);
537
-
538
- if (index > -1) {
539
- arr.splice(index, 1);
540
- arr.unshift(value);
541
- }
542
- }
543
-
544
- /**
545
- * Pushes an element to the end of the array, if found.
546
- */
547
- export function pushToEnd<T>(arr: T[], value: T): void {
548
- const index = arr.indexOf(value);
549
-
550
- if (index > -1) {
551
- arr.splice(index, 1);
552
- arr.push(value);
553
- }
554
- }
555
-
556
- export function pushMany<T>(arr: T[], items: ReadonlyArray<T>): void {
557
- for (const item of items) {
558
- arr.push(item);
559
- }
560
- }
561
-
562
- export function mapArrayOrNot<T, U>(items: T | T[], fn: (_: T) => U): U | U[] {
563
- return Array.isArray(items) ?
564
- items.map(fn) :
565
- fn(items);
566
- }
567
-
568
- export function asArray<T>(x: T | T[]): T[];
569
- export function asArray<T>(x: T | readonly T[]): readonly T[];
570
- export function asArray<T>(x: T | T[]): T[] {
571
- return Array.isArray(x) ? x : [x];
572
- }
573
-
574
- export function getRandomElement<T>(arr: T[]): T | undefined {
575
- return arr[Math.floor(Math.random() * arr.length)];
576
- }
577
-
578
- /**
579
- * Insert the new items in the array.
580
- * @param array The original array.
581
- * @param start The zero-based location in the array from which to start inserting elements.
582
- * @param newItems The items to be inserted
583
- */
584
- export function insertInto<T>(array: T[], start: number, newItems: T[]): void {
585
- const startIdx = getActualStartIndex(array, start);
586
- const originalLength = array.length;
587
- const newItemsLength = newItems.length;
588
- array.length = originalLength + newItemsLength;
589
- // Move the items after the start index, start from the end so that we don't overwrite any value.
590
- for (let i = originalLength - 1; i >= startIdx; i--) {
591
- array[i + newItemsLength] = array[i];
592
- }
593
-
594
- for (let i = 0; i < newItemsLength; i++) {
595
- array[i + startIdx] = newItems[i];
596
- }
597
- }
598
-
599
- /**
600
- * Removes elements from an array and inserts new elements in their place, returning the deleted elements. Alternative to the native Array.splice method, it
601
- * can only support limited number of items due to the maximum call stack size limit.
602
- * @param array The original array.
603
- * @param start The zero-based location in the array from which to start removing elements.
604
- * @param deleteCount The number of elements to remove.
605
- * @returns An array containing the elements that were deleted.
606
- */
607
- export function splice<T>(array: T[], start: number, deleteCount: number, newItems: T[]): T[] {
608
- const index = getActualStartIndex(array, start);
609
- let result = array.splice(index, deleteCount);
610
- if (result === undefined) {
611
- // see https://bugs.webkit.org/show_bug.cgi?id=261140
612
- result = [];
613
- }
614
- insertInto(array, index, newItems);
615
- return result;
616
- }
617
-
618
- /**
619
- * Determine the actual start index (same logic as the native splice() or slice())
620
- * If greater than the length of the array, start will be set to the length of the array. In this case, no element will be deleted but the method will behave as an adding function, adding as many element as item[n*] provided.
621
- * If negative, it will begin that many elements from the end of the array. (In this case, the origin -1, meaning -n is the index of the nth last element, and is therefore equivalent to the index of array.length - n.) If array.length + start is less than 0, it will begin from index 0.
622
- * @param array The target array.
623
- * @param start The operation index.
624
- */
625
- function getActualStartIndex<T>(array: T[], start: number): number {
626
- return start < 0 ? Math.max(start + array.length, 0) : Math.min(start, array.length);
627
- }
628
-
629
-
630
-
631
- /**
632
- * When comparing two values,
633
- * a negative number indicates that the first value is less than the second,
634
- * a positive number indicates that the first value is greater than the second,
635
- * and zero indicates that neither is the case.
636
- */
637
- export type CompareResult = number;
638
-
639
- export namespace CompareResult {
640
- export function isLessThan(result: CompareResult): boolean {
641
- return result < 0;
642
- }
643
-
644
- export function isLessThanOrEqual(result: CompareResult): boolean {
645
- return result <= 0;
646
- }
647
-
648
- export function isGreaterThan(result: CompareResult): boolean {
649
- return result > 0;
650
- }
651
-
652
- export function isNeitherLessOrGreaterThan(result: CompareResult): boolean {
653
- return result === 0;
654
- }
655
-
656
- export const greaterThan = 1;
657
- export const lessThan = -1;
658
- export const neitherLessOrGreaterThan = 0;
659
- }
660
-
661
- /**
662
- * A comparator `c` defines a total order `<=` on `T` as following:
663
- * `c(a, b) <= 0` iff `a` <= `b`.
664
- * We also have `c(a, b) == 0` iff `c(b, a) == 0`.
665
- */
666
- export type Comparator<T> = (a: T, b: T) => CompareResult;
667
-
668
- export function compareBy<TItem, TCompareBy>(selector: (item: TItem) => TCompareBy, comparator: Comparator<TCompareBy>): Comparator<TItem> {
669
- return (a, b) => comparator(selector(a), selector(b));
670
- }
671
-
672
- export function tieBreakComparators<TItem>(...comparators: Comparator<TItem>[]): Comparator<TItem> {
673
- return (item1, item2) => {
674
- for (const comparator of comparators) {
675
- const result = comparator(item1, item2);
676
- if (!CompareResult.isNeitherLessOrGreaterThan(result)) {
677
- return result;
678
- }
679
- }
680
- return CompareResult.neitherLessOrGreaterThan;
681
- };
682
- }
683
-
684
- /**
685
- * The natural order on numbers.
686
- */
687
- export const numberComparator: Comparator<number> = (a, b) => a - b;
688
-
689
- export const booleanComparator: Comparator<boolean> = (a, b) => numberComparator(a ? 1 : 0, b ? 1 : 0);
690
-
691
- export function reverseOrder<TItem>(comparator: Comparator<TItem>): Comparator<TItem> {
692
- return (a, b) => -comparator(a, b);
693
- }
694
-
695
- /**
696
- * Returns a new comparator that treats `undefined` as the smallest value.
697
- * All other values are compared using the given comparator.
698
- */
699
- export function compareUndefinedSmallest<T>(comparator: Comparator<T>): Comparator<T | undefined> {
700
- return (a, b) => {
701
- if (a === undefined) {
702
- return b === undefined ? CompareResult.neitherLessOrGreaterThan : CompareResult.lessThan;
703
- } else if (b === undefined) {
704
- return CompareResult.greaterThan;
705
- }
706
-
707
- return comparator(a, b);
708
- };
709
- }
710
-
711
- export class ArrayQueue<T> {
712
- private readonly items: readonly T[];
713
- private firstIdx = 0;
714
- private lastIdx: number;
715
-
716
- /**
717
- * Constructs a queue that is backed by the given array. Runtime is O(1).
718
- */
719
- constructor(items: readonly T[]) {
720
- this.items = items;
721
- this.lastIdx = this.items.length - 1;
722
- }
723
-
724
- get length(): number {
725
- return this.lastIdx - this.firstIdx + 1;
726
- }
727
-
728
- /**
729
- * Consumes elements from the beginning of the queue as long as the predicate returns true.
730
- * If no elements were consumed, `null` is returned. Has a runtime of O(result.length).
731
- */
732
- takeWhile(predicate: (value: T) => boolean): T[] | null {
733
- // P(k) := k <= this.lastIdx && predicate(this.items[k])
734
- // Find s := min { k | k >= this.firstIdx && !P(k) } and return this.data[this.firstIdx...s)
735
-
736
- let startIdx = this.firstIdx;
737
- while (startIdx < this.items.length && predicate(this.items[startIdx])) {
738
- startIdx++;
739
- }
740
- const result = startIdx === this.firstIdx ? null : this.items.slice(this.firstIdx, startIdx);
741
- this.firstIdx = startIdx;
742
- return result;
743
- }
744
-
745
- /**
746
- * Consumes elements from the end of the queue as long as the predicate returns true.
747
- * If no elements were consumed, `null` is returned.
748
- * The result has the same order as the underlying array!
749
- */
750
- takeFromEndWhile(predicate: (value: T) => boolean): T[] | null {
751
- // P(k) := this.firstIdx >= k && predicate(this.items[k])
752
- // Find s := max { k | k <= this.lastIdx && !P(k) } and return this.data(s...this.lastIdx]
753
-
754
- let endIdx = this.lastIdx;
755
- while (endIdx >= 0 && predicate(this.items[endIdx])) {
756
- endIdx--;
757
- }
758
- const result = endIdx === this.lastIdx ? null : this.items.slice(endIdx + 1, this.lastIdx + 1);
759
- this.lastIdx = endIdx;
760
- return result;
761
- }
762
-
763
- peek(): T | undefined {
764
- if (this.length === 0) {
765
- return undefined;
766
- }
767
- return this.items[this.firstIdx];
768
- }
769
-
770
- peekLast(): T | undefined {
771
- if (this.length === 0) {
772
- return undefined;
773
- }
774
- return this.items[this.lastIdx];
775
- }
776
-
777
- dequeue(): T | undefined {
778
- const result = this.items[this.firstIdx];
779
- this.firstIdx++;
780
- return result;
781
- }
782
-
783
- removeLast(): T | undefined {
784
- const result = this.items[this.lastIdx];
785
- this.lastIdx--;
786
- return result;
787
- }
788
-
789
- takeCount(count: number): T[] {
790
- const result = this.items.slice(this.firstIdx, this.firstIdx + count);
791
- this.firstIdx += count;
792
- return result;
793
- }
794
- }
795
-
796
- /**
797
- * This class is faster than an iterator and array for lazy computed data.
798
- */
799
- export class CallbackIterable<T> {
800
- public static readonly empty = new CallbackIterable<never>(_callback => { });
801
-
802
- constructor(
803
- /**
804
- * Calls the callback for every item.
805
- * Stops when the callback returns false.
806
- */
807
- public readonly iterate: (callback: (item: T) => boolean) => void
808
- ) {
809
- }
810
-
811
- forEach(handler: (item: T) => void) {
812
- this.iterate(item => { handler(item); return true; });
813
- }
814
-
815
- toArray(): T[] {
816
- const result: T[] = [];
817
- this.iterate(item => { result.push(item); return true; });
818
- return result;
819
- }
820
-
821
- filter(predicate: (item: T) => boolean): CallbackIterable<T> {
822
- return new CallbackIterable(cb => this.iterate(item => predicate(item) ? cb(item) : true));
823
- }
824
-
825
- map<TResult>(mapFn: (item: T) => TResult): CallbackIterable<TResult> {
826
- return new CallbackIterable<TResult>(cb => this.iterate(item => cb(mapFn(item))));
827
- }
828
-
829
- some(predicate: (item: T) => boolean): boolean {
830
- let result = false;
831
- this.iterate(item => { result = predicate(item); return !result; });
832
- return result;
833
- }
834
-
835
- findFirst(predicate: (item: T) => boolean): T | undefined {
836
- let result: T | undefined;
837
- this.iterate(item => {
838
- if (predicate(item)) {
839
- result = item;
840
- return false;
841
- }
842
- return true;
843
- });
844
- return result;
845
- }
846
-
847
- findLast(predicate: (item: T) => boolean): T | undefined {
848
- let result: T | undefined;
849
- this.iterate(item => {
850
- if (predicate(item)) {
851
- result = item;
852
- }
853
- return true;
854
- });
855
- return result;
856
- }
857
-
858
- findLastMaxBy(comparator: Comparator<T>): T | undefined {
859
- let result: T | undefined;
860
- let first = true;
861
- this.iterate(item => {
862
- if (first || CompareResult.isGreaterThan(comparator(item, result!))) {
863
- first = false;
864
- result = item;
865
- }
866
- return true;
867
- });
868
- return result;
869
- }
870
- }
871
-
872
- /**
873
- * Represents a re-arrangement of items in an array.
874
- */
875
- export class Permutation {
876
- constructor(private readonly _indexMap: readonly number[]) { }
877
-
878
- /**
879
- * Returns a permutation that sorts the given array according to the given compare function.
880
- */
881
- public static createSortPermutation<T>(arr: readonly T[], compareFn: (a: T, b: T) => number): Permutation {
882
- const sortIndices = Array.from(arr.keys()).sort((index1, index2) => compareFn(arr[index1], arr[index2]));
883
- return new Permutation(sortIndices);
884
- }
885
-
886
- /**
887
- * Returns a new array with the elements of the given array re-arranged according to this permutation.
888
- */
889
- apply<T>(arr: readonly T[]): T[] {
890
- return arr.map((_, index) => arr[this._indexMap[index]]);
891
- }
892
-
893
- /**
894
- * Returns a new permutation that undoes the re-arrangement of this permutation.
895
- */
896
- inverse(): Permutation {
897
- const inverseIndexMap = this._indexMap.slice();
898
- for (let i = 0; i < this._indexMap.length; i++) {
899
- inverseIndexMap[this._indexMap[i]] = i;
900
- }
901
- return new Permutation(inverseIndexMap);
902
- }
903
- }
904
-
905
- /**
906
- * Asynchronous variant of `Array.find()`, returning the first element in
907
- * the array for which the predicate returns true.
908
- *
909
- * This implementation does not bail early and waits for all promises to
910
- * resolve before returning.
911
- */
912
- export async function findAsync<T>(array: readonly T[], predicate: (element: T, index: number) => Promise<boolean>): Promise<T | undefined> {
913
- const results = await Promise.all(array.map(
914
- async (element, index) => ({ element, ok: await predicate(element, index) })
915
- ));
916
-
917
- return results.find(r => r.ok)?.element;
918
- }
919
-
920
- export function sum(array: readonly number[]): number {
921
- return array.reduce((acc, value) => acc + value, 0);
922
- }
923
-
924
- export function sumBy<T>(array: readonly T[], selector: (value: T) => number): number {
925
- return array.reduce((acc, value) => acc + selector(value), 0);
926
- }