@cleanslate/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/NOTICE +48 -0
- package/README.md +103 -0
- package/VENDOR.md +60 -0
- package/dist/agent/cleanSlateAgentExecutionPhase.d.ts +55 -0
- package/dist/agent/cleanSlateAgentExecutionPhase.d.ts.map +1 -0
- package/dist/agent/cleanSlateAgentExecutionPhase.js +474 -0
- package/dist/agent/cleanSlateAgentExecutionPhase.js.map +1 -0
- package/dist/agent/cleanSlateAgentExecutionSupport.d.ts +22 -0
- package/dist/agent/cleanSlateAgentExecutionSupport.d.ts.map +1 -0
- package/dist/agent/cleanSlateAgentExecutionSupport.js +205 -0
- package/dist/agent/cleanSlateAgentExecutionSupport.js.map +1 -0
- package/dist/agent/cleanSlateAgentParsing.d.ts +21 -0
- package/dist/agent/cleanSlateAgentParsing.d.ts.map +1 -0
- package/dist/agent/cleanSlateAgentParsing.js +106 -0
- package/dist/agent/cleanSlateAgentParsing.js.map +1 -0
- package/dist/agent/cleanSlateAgentSession.d.ts +44 -0
- package/dist/agent/cleanSlateAgentSession.d.ts.map +1 -0
- package/dist/agent/cleanSlateAgentSession.js +205 -0
- package/dist/agent/cleanSlateAgentSession.js.map +1 -0
- package/dist/agent/cleanSlateAgentTypes.d.ts +91 -0
- package/dist/agent/cleanSlateAgentTypes.d.ts.map +1 -0
- package/dist/agent/cleanSlateAgentTypes.js +27 -0
- package/dist/agent/cleanSlateAgentTypes.js.map +1 -0
- package/dist/agent/cleanSlateCommandPolicy.d.ts +12 -0
- package/dist/agent/cleanSlateCommandPolicy.d.ts.map +1 -0
- package/dist/agent/cleanSlateCommandPolicy.js +30 -0
- package/dist/agent/cleanSlateCommandPolicy.js.map +1 -0
- package/dist/agent/cleanSlateContextBudgetManager.d.ts +82 -0
- package/dist/agent/cleanSlateContextBudgetManager.d.ts.map +1 -0
- package/dist/agent/cleanSlateContextBudgetManager.js +419 -0
- package/dist/agent/cleanSlateContextBudgetManager.js.map +1 -0
- package/dist/agent/cleanSlateDomainProfile.d.ts +71 -0
- package/dist/agent/cleanSlateDomainProfile.d.ts.map +1 -0
- package/dist/agent/cleanSlateDomainProfile.js +124 -0
- package/dist/agent/cleanSlateDomainProfile.js.map +1 -0
- package/dist/agent/cleanSlateExecutionBudget.d.ts +19 -0
- package/dist/agent/cleanSlateExecutionBudget.d.ts.map +1 -0
- package/dist/agent/cleanSlateExecutionBudget.js +28 -0
- package/dist/agent/cleanSlateExecutionBudget.js.map +1 -0
- package/dist/agent/cleanSlateExecutionEditPolicy.d.ts +15 -0
- package/dist/agent/cleanSlateExecutionEditPolicy.d.ts.map +1 -0
- package/dist/agent/cleanSlateExecutionEditPolicy.js +148 -0
- package/dist/agent/cleanSlateExecutionEditPolicy.js.map +1 -0
- package/dist/agent/cleanSlateExecutionEvidenceLedger.d.ts +23 -0
- package/dist/agent/cleanSlateExecutionEvidenceLedger.d.ts.map +1 -0
- package/dist/agent/cleanSlateExecutionEvidenceLedger.js +121 -0
- package/dist/agent/cleanSlateExecutionEvidenceLedger.js.map +1 -0
- package/dist/agent/cleanSlateExecutionLoopPrompts.d.ts +5 -0
- package/dist/agent/cleanSlateExecutionLoopPrompts.d.ts.map +1 -0
- package/dist/agent/cleanSlateExecutionLoopPrompts.js +41 -0
- package/dist/agent/cleanSlateExecutionLoopPrompts.js.map +1 -0
- package/dist/agent/cleanSlateExecutionQuery.d.ts +162 -0
- package/dist/agent/cleanSlateExecutionQuery.d.ts.map +1 -0
- package/dist/agent/cleanSlateExecutionQuery.js +1448 -0
- package/dist/agent/cleanSlateExecutionQuery.js.map +1 -0
- package/dist/agent/cleanSlateFilesModifiedService.d.ts +96 -0
- package/dist/agent/cleanSlateFilesModifiedService.d.ts.map +1 -0
- package/dist/agent/cleanSlateFilesModifiedService.js +581 -0
- package/dist/agent/cleanSlateFilesModifiedService.js.map +1 -0
- package/dist/agent/cleanSlateNativeToolTranscript.d.ts +22 -0
- package/dist/agent/cleanSlateNativeToolTranscript.d.ts.map +1 -0
- package/dist/agent/cleanSlateNativeToolTranscript.js +77 -0
- package/dist/agent/cleanSlateNativeToolTranscript.js.map +1 -0
- package/dist/agent/cleanSlatePrompts.d.ts +30 -0
- package/dist/agent/cleanSlatePrompts.d.ts.map +1 -0
- package/dist/agent/cleanSlatePrompts.js +65 -0
- package/dist/agent/cleanSlatePrompts.js.map +1 -0
- package/dist/agent/cleanSlateQueryRunner.d.ts +56 -0
- package/dist/agent/cleanSlateQueryRunner.d.ts.map +1 -0
- package/dist/agent/cleanSlateQueryRunner.js +69 -0
- package/dist/agent/cleanSlateQueryRunner.js.map +1 -0
- package/dist/agent/cleanSlateRuntimePromptBuilder.d.ts +30 -0
- package/dist/agent/cleanSlateRuntimePromptBuilder.d.ts.map +1 -0
- package/dist/agent/cleanSlateRuntimePromptBuilder.js +99 -0
- package/dist/agent/cleanSlateRuntimePromptBuilder.js.map +1 -0
- package/dist/agent/cleanSlateStreamingToolExecutor.d.ts +55 -0
- package/dist/agent/cleanSlateStreamingToolExecutor.d.ts.map +1 -0
- package/dist/agent/cleanSlateStreamingToolExecutor.js +214 -0
- package/dist/agent/cleanSlateStreamingToolExecutor.js.map +1 -0
- package/dist/agent/cleanSlateToolCallLedger.d.ts +32 -0
- package/dist/agent/cleanSlateToolCallLedger.d.ts.map +1 -0
- package/dist/agent/cleanSlateToolCallLedger.js +164 -0
- package/dist/agent/cleanSlateToolCallLedger.js.map +1 -0
- package/dist/agent/cleanSlateToolResultPromptSerializer.d.ts +9 -0
- package/dist/agent/cleanSlateToolResultPromptSerializer.d.ts.map +1 -0
- package/dist/agent/cleanSlateToolResultPromptSerializer.js +184 -0
- package/dist/agent/cleanSlateToolResultPromptSerializer.js.map +1 -0
- package/dist/composer/commands/slashCommands.d.ts +8 -0
- package/dist/composer/commands/slashCommands.d.ts.map +1 -0
- package/dist/composer/commands/slashCommands.js +46 -0
- package/dist/composer/commands/slashCommands.js.map +1 -0
- package/dist/composer/instructions/baseInstructions.d.ts +3 -0
- package/dist/composer/instructions/baseInstructions.d.ts.map +1 -0
- package/dist/composer/instructions/baseInstructions.js +35 -0
- package/dist/composer/instructions/baseInstructions.js.map +1 -0
- package/dist/composer/instructions/runtimeInstructions.d.ts +11 -0
- package/dist/composer/instructions/runtimeInstructions.d.ts.map +1 -0
- package/dist/composer/instructions/runtimeInstructions.js +31 -0
- package/dist/composer/instructions/runtimeInstructions.js.map +1 -0
- package/dist/composer/kernel/coreKernel.d.ts +3 -0
- package/dist/composer/kernel/coreKernel.d.ts.map +1 -0
- package/dist/composer/kernel/coreKernel.js +11 -0
- package/dist/composer/kernel/coreKernel.js.map +1 -0
- package/dist/composer/kernel/editingRules.d.ts +3 -0
- package/dist/composer/kernel/editingRules.d.ts.map +1 -0
- package/dist/composer/kernel/editingRules.js +24 -0
- package/dist/composer/kernel/editingRules.js.map +1 -0
- package/dist/composer/kernel/toolProtocols.d.ts +2 -0
- package/dist/composer/kernel/toolProtocols.d.ts.map +1 -0
- package/dist/composer/kernel/toolProtocols.js +32 -0
- package/dist/composer/kernel/toolProtocols.js.map +1 -0
- package/dist/composer/modes/execution.mode.d.ts +2 -0
- package/dist/composer/modes/execution.mode.d.ts.map +1 -0
- package/dist/composer/modes/execution.mode.js +21 -0
- package/dist/composer/modes/execution.mode.js.map +1 -0
- package/dist/composer/modes/planning.mode.d.ts +2 -0
- package/dist/composer/modes/planning.mode.d.ts.map +1 -0
- package/dist/composer/modes/planning.mode.js +23 -0
- package/dist/composer/modes/planning.mode.js.map +1 -0
- package/dist/composer/promptComposer.d.ts +22 -0
- package/dist/composer/promptComposer.d.ts.map +1 -0
- package/dist/composer/promptComposer.js +62 -0
- package/dist/composer/promptComposer.js.map +1 -0
- package/dist/composer/registry/agentSchema.d.ts +16 -0
- package/dist/composer/registry/agentSchema.d.ts.map +1 -0
- package/dist/composer/registry/agentSchema.js +6 -0
- package/dist/composer/registry/agentSchema.js.map +1 -0
- package/dist/core/arrays.d.ts +311 -0
- package/dist/core/arrays.d.ts.map +1 -0
- package/dist/core/arrays.js +811 -0
- package/dist/core/arrays.js.map +1 -0
- package/dist/core/arraysFind.d.ts +72 -0
- package/dist/core/arraysFind.d.ts.map +1 -0
- package/dist/core/arraysFind.js +200 -0
- package/dist/core/arraysFind.js.map +1 -0
- package/dist/core/assert.d.ts +36 -0
- package/dist/core/assert.d.ts.map +1 -0
- package/dist/core/assert.js +84 -0
- package/dist/core/assert.js.map +1 -0
- package/dist/core/async.d.ts +11 -0
- package/dist/core/async.d.ts.map +1 -0
- package/dist/core/async.js +6 -0
- package/dist/core/async.js.map +1 -0
- package/dist/core/buffer.d.ts +23 -0
- package/dist/core/buffer.d.ts.map +1 -0
- package/dist/core/buffer.js +40 -0
- package/dist/core/buffer.js.map +1 -0
- package/dist/core/cancellation.d.ts +52 -0
- package/dist/core/cancellation.d.ts.map +1 -0
- package/dist/core/cancellation.js +169 -0
- package/dist/core/cancellation.js.map +1 -0
- package/dist/core/charCode.d.ts +428 -0
- package/dist/core/charCode.d.ts.map +1 -0
- package/dist/core/charCode.js +439 -0
- package/dist/core/charCode.js.map +1 -0
- package/dist/core/collections.d.ts +49 -0
- package/dist/core/collections.d.ts.map +1 -0
- package/dist/core/collections.js +132 -0
- package/dist/core/collections.js.map +1 -0
- package/dist/core/diff/diff.d.ts +151 -0
- package/dist/core/diff/diff.d.ts.map +1 -0
- package/dist/core/diff/diff.js +1076 -0
- package/dist/core/diff/diff.js.map +1 -0
- package/dist/core/diff/diffChange.d.ts +39 -0
- package/dist/core/diff/diffChange.d.ts.map +1 -0
- package/dist/core/diff/diffChange.js +37 -0
- package/dist/core/diff/diffChange.js.map +1 -0
- package/dist/core/errors.d.ts +114 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +258 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/event.d.ts +595 -0
- package/dist/core/event.d.ts.map +1 -0
- package/dist/core/event.js +1479 -0
- package/dist/core/event.js.map +1 -0
- package/dist/core/functional.d.ts +5 -0
- package/dist/core/functional.d.ts.map +1 -0
- package/dist/core/functional.js +35 -0
- package/dist/core/functional.js.map +1 -0
- package/dist/core/hash.d.ts +15 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +27 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/iterator.d.ts +33 -0
- package/dist/core/iterator.d.ts.map +1 -0
- package/dist/core/iterator.js +188 -0
- package/dist/core/iterator.js.map +1 -0
- package/dist/core/lifecycle.d.ts +313 -0
- package/dist/core/lifecycle.d.ts.map +1 -0
- package/dist/core/lifecycle.js +789 -0
- package/dist/core/lifecycle.js.map +1 -0
- package/dist/core/linkedList.d.ts +17 -0
- package/dist/core/linkedList.d.ts.map +1 -0
- package/dist/core/linkedList.js +138 -0
- package/dist/core/linkedList.js.map +1 -0
- package/dist/core/map.d.ts +175 -0
- package/dist/core/map.d.ts.map +1 -0
- package/dist/core/map.js +796 -0
- package/dist/core/map.js.map +1 -0
- package/dist/core/marshallingIds.d.ts +29 -0
- package/dist/core/marshallingIds.d.ts.map +1 -0
- package/dist/core/marshallingIds.js +38 -0
- package/dist/core/marshallingIds.js.map +1 -0
- package/dist/core/observable.d.ts +28 -0
- package/dist/core/observable.d.ts.map +1 -0
- package/dist/core/observable.js +6 -0
- package/dist/core/observable.js.map +1 -0
- package/dist/core/platform.d.ts +4 -0
- package/dist/core/platform.d.ts.map +1 -0
- package/dist/core/platform.js +17 -0
- package/dist/core/platform.js.map +1 -0
- package/dist/core/position.d.ts +91 -0
- package/dist/core/position.d.ts.map +1 -0
- package/dist/core/position.js +145 -0
- package/dist/core/position.js.map +1 -0
- package/dist/core/range.d.ts +198 -0
- package/dist/core/range.d.ts.map +1 -0
- package/dist/core/range.js +426 -0
- package/dist/core/range.js.map +1 -0
- package/dist/core/resources.d.ts +10 -0
- package/dist/core/resources.d.ts.map +1 -0
- package/dist/core/resources.js +126 -0
- package/dist/core/resources.js.map +1 -0
- package/dist/core/sequence.d.ts +20 -0
- package/dist/core/sequence.d.ts.map +1 -0
- package/dist/core/sequence.js +21 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/stopwatch.d.ts +11 -0
- package/dist/core/stopwatch.d.ts.map +1 -0
- package/dist/core/stopwatch.js +33 -0
- package/dist/core/stopwatch.js.map +1 -0
- package/dist/core/symbols.d.ts +5 -0
- package/dist/core/symbols.d.ts.map +1 -0
- package/dist/core/symbols.js +13 -0
- package/dist/core/symbols.js.map +1 -0
- package/dist/core/types.d.ts +229 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +278 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/uint.d.ts +32 -0
- package/dist/core/uint.d.ts.map +1 -0
- package/dist/core/uint.js +57 -0
- package/dist/core/uint.js.map +1 -0
- package/dist/core/uri.d.ts +172 -0
- package/dist/core/uri.d.ts.map +1 -0
- package/dist/core/uri.js +623 -0
- package/dist/core/uri.js.map +1 -0
- package/dist/host/browserAutomation.d.ts +276 -0
- package/dist/host/browserAutomation.d.ts.map +1 -0
- package/dist/host/browserAutomation.js +6 -0
- package/dist/host/browserAutomation.js.map +1 -0
- package/dist/host/diagnostics.d.ts +68 -0
- package/dist/host/diagnostics.d.ts.map +1 -0
- package/dist/host/diagnostics.js +41 -0
- package/dist/host/diagnostics.js.map +1 -0
- package/dist/host/files.d.ts +70 -0
- package/dist/host/files.d.ts.map +1 -0
- package/dist/host/files.js +54 -0
- package/dist/host/files.js.map +1 -0
- package/dist/host/services.d.ts +106 -0
- package/dist/host/services.d.ts.map +1 -0
- package/dist/host/services.js +6 -0
- package/dist/host/services.js.map +1 -0
- package/dist/host/symbols.d.ts +45 -0
- package/dist/host/symbols.d.ts.map +1 -0
- package/dist/host/symbols.js +43 -0
- package/dist/host/symbols.js.map +1 -0
- package/dist/host/textModel.d.ts +83 -0
- package/dist/host/textModel.d.ts.map +1 -0
- package/dist/host/textModel.js +6 -0
- package/dist/host/textModel.js.map +1 -0
- package/dist/host/workspace.d.ts +123 -0
- package/dist/host/workspace.d.ts.map +1 -0
- package/dist/host/workspace.js +32 -0
- package/dist/host/workspace.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/node/cleanSlateAnthropicMessageAdapter.d.ts +12 -0
- package/dist/node/cleanSlateAnthropicMessageAdapter.d.ts.map +1 -0
- package/dist/node/cleanSlateAnthropicMessageAdapter.js +130 -0
- package/dist/node/cleanSlateAnthropicMessageAdapter.js.map +1 -0
- package/dist/node/cleanSlateHeadlessRunner.d.ts +63 -0
- package/dist/node/cleanSlateHeadlessRunner.d.ts.map +1 -0
- package/dist/node/cleanSlateHeadlessRunner.js +84 -0
- package/dist/node/cleanSlateHeadlessRunner.js.map +1 -0
- package/dist/node/cleanSlateNodeAgentRuntime.d.ts +94 -0
- package/dist/node/cleanSlateNodeAgentRuntime.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeAgentRuntime.js +339 -0
- package/dist/node/cleanSlateNodeAgentRuntime.js.map +1 -0
- package/dist/node/cleanSlateNodeBrowserAutomation.d.ts +279 -0
- package/dist/node/cleanSlateNodeBrowserAutomation.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeBrowserAutomation.js +470 -0
- package/dist/node/cleanSlateNodeBrowserAutomation.js.map +1 -0
- package/dist/node/cleanSlateNodeCommandService.d.ts +40 -0
- package/dist/node/cleanSlateNodeCommandService.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeCommandService.js +435 -0
- package/dist/node/cleanSlateNodeCommandService.js.map +1 -0
- package/dist/node/cleanSlateNodeFileServices.d.ts +68 -0
- package/dist/node/cleanSlateNodeFileServices.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeFileServices.js +138 -0
- package/dist/node/cleanSlateNodeFileServices.js.map +1 -0
- package/dist/node/cleanSlateNodeIndexService.d.ts +17 -0
- package/dist/node/cleanSlateNodeIndexService.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeIndexService.js +128 -0
- package/dist/node/cleanSlateNodeIndexService.js.map +1 -0
- package/dist/node/cleanSlateNodeLanguageCommands.d.ts +11 -0
- package/dist/node/cleanSlateNodeLanguageCommands.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeLanguageCommands.js +146 -0
- package/dist/node/cleanSlateNodeLanguageCommands.js.map +1 -0
- package/dist/node/cleanSlateNodeMainService.d.ts +87 -0
- package/dist/node/cleanSlateNodeMainService.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeMainService.js +1304 -0
- package/dist/node/cleanSlateNodeMainService.js.map +1 -0
- package/dist/node/cleanSlateNodeMcpClient.d.ts +20 -0
- package/dist/node/cleanSlateNodeMcpClient.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeMcpClient.js +184 -0
- package/dist/node/cleanSlateNodeMcpClient.js.map +1 -0
- package/dist/node/cleanSlateNodeSearchService.d.ts +14 -0
- package/dist/node/cleanSlateNodeSearchService.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeSearchService.js +180 -0
- package/dist/node/cleanSlateNodeSearchService.js.map +1 -0
- package/dist/node/cleanSlateNodeTextModel.d.ts +56 -0
- package/dist/node/cleanSlateNodeTextModel.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeTextModel.js +127 -0
- package/dist/node/cleanSlateNodeTextModel.js.map +1 -0
- package/dist/node/cleanSlateNodeToolContext.d.ts +50 -0
- package/dist/node/cleanSlateNodeToolContext.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeToolContext.js +134 -0
- package/dist/node/cleanSlateNodeToolContext.js.map +1 -0
- package/dist/node/cleanSlateNodeWebRetrieval.d.ts +20 -0
- package/dist/node/cleanSlateNodeWebRetrieval.d.ts.map +1 -0
- package/dist/node/cleanSlateNodeWebRetrieval.js +379 -0
- package/dist/node/cleanSlateNodeWebRetrieval.js.map +1 -0
- package/dist/node/cleanSlateOpenAIMessageAdapter.d.ts +8 -0
- package/dist/node/cleanSlateOpenAIMessageAdapter.d.ts.map +1 -0
- package/dist/node/cleanSlateOpenAIMessageAdapter.js +111 -0
- package/dist/node/cleanSlateOpenAIMessageAdapter.js.map +1 -0
- package/dist/node/cleanSlateProviderSchemaNormalizer.d.ts +18 -0
- package/dist/node/cleanSlateProviderSchemaNormalizer.d.ts.map +1 -0
- package/dist/node/cleanSlateProviderSchemaNormalizer.js +175 -0
- package/dist/node/cleanSlateProviderSchemaNormalizer.js.map +1 -0
- package/dist/node/index.d.ts +25 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +28 -0
- package/dist/node/index.js.map +1 -0
- package/dist/protocol/cleanSlateAI.d.ts +964 -0
- package/dist/protocol/cleanSlateAI.d.ts.map +1 -0
- package/dist/protocol/cleanSlateAI.js +35 -0
- package/dist/protocol/cleanSlateAI.js.map +1 -0
- package/dist/protocol/cleanSlateModelCapabilities.d.ts +86 -0
- package/dist/protocol/cleanSlateModelCapabilities.d.ts.map +1 -0
- package/dist/protocol/cleanSlateModelCapabilities.js +1104 -0
- package/dist/protocol/cleanSlateModelCapabilities.js.map +1 -0
- package/dist/protocol/cleanSlateProviderMessageTransforms.d.ts +11 -0
- package/dist/protocol/cleanSlateProviderMessageTransforms.d.ts.map +1 -0
- package/dist/protocol/cleanSlateProviderMessageTransforms.js +178 -0
- package/dist/protocol/cleanSlateProviderMessageTransforms.js.map +1 -0
- package/dist/protocol/cleanSlateService.d.ts +68 -0
- package/dist/protocol/cleanSlateService.d.ts.map +1 -0
- package/dist/protocol/cleanSlateService.js +1149 -0
- package/dist/protocol/cleanSlateService.js.map +1 -0
- package/dist/services/cleanSlateCancellation.d.ts +7 -0
- package/dist/services/cleanSlateCancellation.d.ts.map +1 -0
- package/dist/services/cleanSlateCancellation.js +56 -0
- package/dist/services/cleanSlateCancellation.js.map +1 -0
- package/dist/services/cleanSlateCommandExecutionService.d.ts +25 -0
- package/dist/services/cleanSlateCommandExecutionService.d.ts.map +1 -0
- package/dist/services/cleanSlateCommandExecutionService.js +31 -0
- package/dist/services/cleanSlateCommandExecutionService.js.map +1 -0
- package/dist/services/cleanSlateDiffService.d.ts +62 -0
- package/dist/services/cleanSlateDiffService.d.ts.map +1 -0
- package/dist/services/cleanSlateDiffService.js +428 -0
- package/dist/services/cleanSlateDiffService.js.map +1 -0
- package/dist/services/cleanSlateEditMatchValidator.d.ts +63 -0
- package/dist/services/cleanSlateEditMatchValidator.d.ts.map +1 -0
- package/dist/services/cleanSlateEditMatchValidator.js +341 -0
- package/dist/services/cleanSlateEditMatchValidator.js.map +1 -0
- package/dist/services/cleanSlateEditService.d.ts +155 -0
- package/dist/services/cleanSlateEditService.d.ts.map +1 -0
- package/dist/services/cleanSlateEditService.js +848 -0
- package/dist/services/cleanSlateEditService.js.map +1 -0
- package/dist/services/cleanSlateFileHistory.d.ts +56 -0
- package/dist/services/cleanSlateFileHistory.d.ts.map +1 -0
- package/dist/services/cleanSlateFileHistory.js +157 -0
- package/dist/services/cleanSlateFileHistory.js.map +1 -0
- package/dist/services/cleanSlateTaskEvidenceCodec.d.ts +15 -0
- package/dist/services/cleanSlateTaskEvidenceCodec.d.ts.map +1 -0
- package/dist/services/cleanSlateTaskEvidenceCodec.js +151 -0
- package/dist/services/cleanSlateTaskEvidenceCodec.js.map +1 -0
- package/dist/services/cleanSlateTaskSessionService.d.ts +258 -0
- package/dist/services/cleanSlateTaskSessionService.d.ts.map +1 -0
- package/dist/services/cleanSlateTaskSessionService.js +1079 -0
- package/dist/services/cleanSlateTaskSessionService.js.map +1 -0
- package/dist/services/cleanSlateTaskState.d.ts +32 -0
- package/dist/services/cleanSlateTaskState.d.ts.map +1 -0
- package/dist/services/cleanSlateTaskState.js +40 -0
- package/dist/services/cleanSlateTaskState.js.map +1 -0
- package/dist/services/cleanSlateThreadService.d.ts +64 -0
- package/dist/services/cleanSlateThreadService.d.ts.map +1 -0
- package/dist/services/cleanSlateThreadService.js +188 -0
- package/dist/services/cleanSlateThreadService.js.map +1 -0
- package/dist/services/cleanSlateTools.d.ts +29 -0
- package/dist/services/cleanSlateTools.d.ts.map +1 -0
- package/dist/services/cleanSlateTools.js +38 -0
- package/dist/services/cleanSlateTools.js.map +1 -0
- package/dist/services/cleanSlateVerificationTargetTracker.d.ts +23 -0
- package/dist/services/cleanSlateVerificationTargetTracker.d.ts.map +1 -0
- package/dist/services/cleanSlateVerificationTargetTracker.js +214 -0
- package/dist/services/cleanSlateVerificationTargetTracker.js.map +1 -0
- package/dist/skills/cleanSlateSkillCatalog.d.ts +29 -0
- package/dist/skills/cleanSlateSkillCatalog.d.ts.map +1 -0
- package/dist/skills/cleanSlateSkillCatalog.js +225 -0
- package/dist/skills/cleanSlateSkillCatalog.js.map +1 -0
- package/dist/tools/ApplyEditTool.d.ts +73 -0
- package/dist/tools/ApplyEditTool.d.ts.map +1 -0
- package/dist/tools/ApplyEditTool.js +741 -0
- package/dist/tools/ApplyEditTool.js.map +1 -0
- package/dist/tools/AskQuestionTool.d.ts +3 -0
- package/dist/tools/AskQuestionTool.d.ts.map +1 -0
- package/dist/tools/AskQuestionTool.js +113 -0
- package/dist/tools/AskQuestionTool.js.map +1 -0
- package/dist/tools/BrowserAutomationTools.d.ts +28 -0
- package/dist/tools/BrowserAutomationTools.d.ts.map +1 -0
- package/dist/tools/BrowserAutomationTools.js +639 -0
- package/dist/tools/BrowserAutomationTools.js.map +1 -0
- package/dist/tools/CreateMultipleFilesTool.d.ts +6 -0
- package/dist/tools/CreateMultipleFilesTool.d.ts.map +1 -0
- package/dist/tools/CreateMultipleFilesTool.js +115 -0
- package/dist/tools/CreateMultipleFilesTool.js.map +1 -0
- package/dist/tools/ExecuteCommandTool.d.ts +12 -0
- package/dist/tools/ExecuteCommandTool.d.ts.map +1 -0
- package/dist/tools/ExecuteCommandTool.js +378 -0
- package/dist/tools/ExecuteCommandTool.js.map +1 -0
- package/dist/tools/FileHistoryRewindTool.d.ts +3 -0
- package/dist/tools/FileHistoryRewindTool.d.ts.map +1 -0
- package/dist/tools/FileHistoryRewindTool.js +45 -0
- package/dist/tools/FileHistoryRewindTool.js.map +1 -0
- package/dist/tools/FindByNameTool.d.ts +6 -0
- package/dist/tools/FindByNameTool.d.ts.map +1 -0
- package/dist/tools/FindByNameTool.js +80 -0
- package/dist/tools/FindByNameTool.js.map +1 -0
- package/dist/tools/FindReferencesTool.d.ts +3 -0
- package/dist/tools/FindReferencesTool.d.ts.map +1 -0
- package/dist/tools/FindReferencesTool.js +128 -0
- package/dist/tools/FindReferencesTool.js.map +1 -0
- package/dist/tools/GetDefinitionsTool.d.ts +3 -0
- package/dist/tools/GetDefinitionsTool.d.ts.map +1 -0
- package/dist/tools/GetDefinitionsTool.js +136 -0
- package/dist/tools/GetDefinitionsTool.js.map +1 -0
- package/dist/tools/GetOpenFilesTool.d.ts +6 -0
- package/dist/tools/GetOpenFilesTool.d.ts.map +1 -0
- package/dist/tools/GetOpenFilesTool.js +21 -0
- package/dist/tools/GetOpenFilesTool.js.map +1 -0
- package/dist/tools/GrepSearchTool.d.ts +7 -0
- package/dist/tools/GrepSearchTool.d.ts.map +1 -0
- package/dist/tools/GrepSearchTool.js +95 -0
- package/dist/tools/GrepSearchTool.js.map +1 -0
- package/dist/tools/ListDirTool.d.ts +6 -0
- package/dist/tools/ListDirTool.d.ts.map +1 -0
- package/dist/tools/ListDirTool.js +39 -0
- package/dist/tools/ListDirTool.js.map +1 -0
- package/dist/tools/MCPTools.d.ts +6 -0
- package/dist/tools/MCPTools.d.ts.map +1 -0
- package/dist/tools/MCPTools.js +103 -0
- package/dist/tools/MCPTools.js.map +1 -0
- package/dist/tools/MultiFileReplaceTool.d.ts +6 -0
- package/dist/tools/MultiFileReplaceTool.d.ts.map +1 -0
- package/dist/tools/MultiFileReplaceTool.js +345 -0
- package/dist/tools/MultiFileReplaceTool.js.map +1 -0
- package/dist/tools/ReadFileRangeTool.d.ts +6 -0
- package/dist/tools/ReadFileRangeTool.d.ts.map +1 -0
- package/dist/tools/ReadFileRangeTool.js +150 -0
- package/dist/tools/ReadFileRangeTool.js.map +1 -0
- package/dist/tools/ReadFileTool.d.ts +6 -0
- package/dist/tools/ReadFileTool.d.ts.map +1 -0
- package/dist/tools/ReadFileTool.js +183 -0
- package/dist/tools/ReadFileTool.js.map +1 -0
- package/dist/tools/ReadLintsTool.d.ts +6 -0
- package/dist/tools/ReadLintsTool.d.ts.map +1 -0
- package/dist/tools/ReadLintsTool.js +83 -0
- package/dist/tools/ReadLintsTool.js.map +1 -0
- package/dist/tools/ReadReferenceTool.d.ts +6 -0
- package/dist/tools/ReadReferenceTool.d.ts.map +1 -0
- package/dist/tools/ReadReferenceTool.js +24 -0
- package/dist/tools/ReadReferenceTool.js.map +1 -0
- package/dist/tools/ReadSymbolsTool.d.ts +3 -0
- package/dist/tools/ReadSymbolsTool.d.ts.map +1 -0
- package/dist/tools/ReadSymbolsTool.js +100 -0
- package/dist/tools/ReadSymbolsTool.js.map +1 -0
- package/dist/tools/SearchCodebaseTool.d.ts +6 -0
- package/dist/tools/SearchCodebaseTool.d.ts.map +1 -0
- package/dist/tools/SearchCodebaseTool.js +30 -0
- package/dist/tools/SearchCodebaseTool.js.map +1 -0
- package/dist/tools/SearchWorkspaceTool.d.ts +7 -0
- package/dist/tools/SearchWorkspaceTool.d.ts.map +1 -0
- package/dist/tools/SearchWorkspaceTool.js +21 -0
- package/dist/tools/SearchWorkspaceTool.js.map +1 -0
- package/dist/tools/SemanticSearchTool.d.ts +12 -0
- package/dist/tools/SemanticSearchTool.d.ts.map +1 -0
- package/dist/tools/SemanticSearchTool.js +46 -0
- package/dist/tools/SemanticSearchTool.js.map +1 -0
- package/dist/tools/SkillTools.d.ts +3 -0
- package/dist/tools/SkillTools.d.ts.map +1 -0
- package/dist/tools/SkillTools.js +108 -0
- package/dist/tools/SkillTools.js.map +1 -0
- package/dist/tools/SpawnWorkerTool.d.ts +6 -0
- package/dist/tools/SpawnWorkerTool.d.ts.map +1 -0
- package/dist/tools/SpawnWorkerTool.js +28 -0
- package/dist/tools/SpawnWorkerTool.js.map +1 -0
- package/dist/tools/SubmitArtifactTool.d.ts +3 -0
- package/dist/tools/SubmitArtifactTool.d.ts.map +1 -0
- package/dist/tools/SubmitArtifactTool.js +121 -0
- package/dist/tools/SubmitArtifactTool.js.map +1 -0
- package/dist/tools/UndoEditTool.d.ts +3 -0
- package/dist/tools/UndoEditTool.d.ts.map +1 -0
- package/dist/tools/UndoEditTool.js +66 -0
- package/dist/tools/UndoEditTool.js.map +1 -0
- package/dist/tools/UpdateTodoTool.d.ts +6 -0
- package/dist/tools/UpdateTodoTool.d.ts.map +1 -0
- package/dist/tools/UpdateTodoTool.js +116 -0
- package/dist/tools/UpdateTodoTool.js.map +1 -0
- package/dist/tools/WebRetrievalTools.d.ts +4 -0
- package/dist/tools/WebRetrievalTools.d.ts.map +1 -0
- package/dist/tools/WebRetrievalTools.js +169 -0
- package/dist/tools/WebRetrievalTools.js.map +1 -0
- package/dist/tools/WriteFileTool.d.ts +6 -0
- package/dist/tools/WriteFileTool.d.ts.map +1 -0
- package/dist/tools/WriteFileTool.js +145 -0
- package/dist/tools/WriteFileTool.js.map +1 -0
- package/dist/tools/cleanSlateFileReadPolicy.d.ts +33 -0
- package/dist/tools/cleanSlateFileReadPolicy.d.ts.map +1 -0
- package/dist/tools/cleanSlateFileReadPolicy.js +84 -0
- package/dist/tools/cleanSlateFileReadPolicy.js.map +1 -0
- package/dist/tools/cleanSlateHostTypes.d.ts +100 -0
- package/dist/tools/cleanSlateHostTypes.d.ts.map +1 -0
- package/dist/tools/cleanSlateHostTypes.js +6 -0
- package/dist/tools/cleanSlateHostTypes.js.map +1 -0
- package/dist/tools/cleanSlatePlanArtifactPolicy.d.ts +47 -0
- package/dist/tools/cleanSlatePlanArtifactPolicy.d.ts.map +1 -0
- package/dist/tools/cleanSlatePlanArtifactPolicy.js +126 -0
- package/dist/tools/cleanSlatePlanArtifactPolicy.js.map +1 -0
- package/dist/tools/cleanSlateStaleDiagnosticPolicy.d.ts +3 -0
- package/dist/tools/cleanSlateStaleDiagnosticPolicy.d.ts.map +1 -0
- package/dist/tools/cleanSlateStaleDiagnosticPolicy.js +13 -0
- package/dist/tools/cleanSlateStaleDiagnosticPolicy.js.map +1 -0
- package/dist/tools/languageFeatureActivation.d.ts +13 -0
- package/dist/tools/languageFeatureActivation.d.ts.map +1 -0
- package/dist/tools/languageFeatureActivation.js +95 -0
- package/dist/tools/languageFeatureActivation.js.map +1 -0
- package/dist/tools/registry.d.ts +5 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +104 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/structuredEditCanonicalizer.d.ts +11 -0
- package/dist/tools/structuredEditCanonicalizer.d.ts.map +1 -0
- package/dist/tools/structuredEditCanonicalizer.js +44 -0
- package/dist/tools/structuredEditCanonicalizer.js.map +1 -0
- package/dist/tools/symbolContext.d.ts +36 -0
- package/dist/tools/symbolContext.d.ts.map +1 -0
- package/dist/tools/symbolContext.js +146 -0
- package/dist/tools/symbolContext.js.map +1 -0
- package/dist/tools/symbolEditResolver.d.ts +11 -0
- package/dist/tools/symbolEditResolver.d.ts.map +1 -0
- package/dist/tools/symbolEditResolver.js +259 -0
- package/dist/tools/symbolEditResolver.js.map +1 -0
- package/dist/tools/symbolIndex.d.ts +18 -0
- package/dist/tools/symbolIndex.d.ts.map +1 -0
- package/dist/tools/symbolIndex.js +235 -0
- package/dist/tools/symbolIndex.js.map +1 -0
- package/dist/tools/types.d.ts +108 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +6 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/utils.d.ts +56 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +205 -0
- package/dist/tools/utils.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/*
|
|
6
|
+
* Vendored from microsoft/vscode (vs/base/common/lifecycle.ts) for @cleanslate/sdk.
|
|
7
|
+
* Changes: see packages/cleanslate-sdk/VENDOR.md.
|
|
8
|
+
*/
|
|
9
|
+
import { compareBy, numberComparator } from './arrays.js';
|
|
10
|
+
import { groupBy } from './collections.js';
|
|
11
|
+
import { SetMap, ResourceMap } from './map.js';
|
|
12
|
+
import { createSingleCallFunction } from './functional.js';
|
|
13
|
+
import { Iterable } from './iterator.js';
|
|
14
|
+
import { BugIndicatingError, onUnexpectedError } from './errors.js';
|
|
15
|
+
// #region Disposable Tracking
|
|
16
|
+
/**
|
|
17
|
+
* Enables logging of potentially leaked disposables.
|
|
18
|
+
*
|
|
19
|
+
* A disposable is considered leaked if it is not disposed or not registered as the child of
|
|
20
|
+
* another disposable. This tracking is very simple an only works for classes that either
|
|
21
|
+
* extend Disposable or use a DisposableStore. This means there are a lot of false positives.
|
|
22
|
+
*/
|
|
23
|
+
const TRACK_DISPOSABLES = false;
|
|
24
|
+
let disposableTracker = null;
|
|
25
|
+
export class GCBasedDisposableTracker {
|
|
26
|
+
constructor() {
|
|
27
|
+
this._registry = new FinalizationRegistry(heldValue => {
|
|
28
|
+
console.warn(`[LEAKED DISPOSABLE] ${heldValue}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
trackDisposable(disposable) {
|
|
32
|
+
const stack = new Error('CREATED via:').stack;
|
|
33
|
+
this._registry.register(disposable, stack, disposable);
|
|
34
|
+
}
|
|
35
|
+
setParent(child, parent) {
|
|
36
|
+
if (parent) {
|
|
37
|
+
this._registry.unregister(child);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.trackDisposable(child);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
markAsDisposed(disposable) {
|
|
44
|
+
this._registry.unregister(disposable);
|
|
45
|
+
}
|
|
46
|
+
markAsSingleton(disposable) {
|
|
47
|
+
this._registry.unregister(disposable);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export class DisposableTracker {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.livingDisposables = new Map();
|
|
53
|
+
}
|
|
54
|
+
static { this.idx = 0; }
|
|
55
|
+
getDisposableData(d) {
|
|
56
|
+
let val = this.livingDisposables.get(d);
|
|
57
|
+
if (!val) {
|
|
58
|
+
val = { parent: null, source: null, isSingleton: false, value: d, idx: DisposableTracker.idx++ };
|
|
59
|
+
this.livingDisposables.set(d, val);
|
|
60
|
+
}
|
|
61
|
+
return val;
|
|
62
|
+
}
|
|
63
|
+
trackDisposable(d) {
|
|
64
|
+
const data = this.getDisposableData(d);
|
|
65
|
+
if (!data.source) {
|
|
66
|
+
data.source =
|
|
67
|
+
new Error().stack;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
setParent(child, parent) {
|
|
71
|
+
const data = this.getDisposableData(child);
|
|
72
|
+
data.parent = parent;
|
|
73
|
+
}
|
|
74
|
+
markAsDisposed(x) {
|
|
75
|
+
this.livingDisposables.delete(x);
|
|
76
|
+
}
|
|
77
|
+
markAsSingleton(disposable) {
|
|
78
|
+
this.getDisposableData(disposable).isSingleton = true;
|
|
79
|
+
}
|
|
80
|
+
getRootParent(data, cache) {
|
|
81
|
+
const cacheValue = cache.get(data);
|
|
82
|
+
if (cacheValue) {
|
|
83
|
+
return cacheValue;
|
|
84
|
+
}
|
|
85
|
+
const result = data.parent ? this.getRootParent(this.getDisposableData(data.parent), cache) : data;
|
|
86
|
+
cache.set(data, result);
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
getTrackedDisposables() {
|
|
90
|
+
const rootParentCache = new Map();
|
|
91
|
+
const leaking = [...this.livingDisposables.entries()]
|
|
92
|
+
.filter(([, v]) => v.source !== null && !this.getRootParent(v, rootParentCache).isSingleton)
|
|
93
|
+
.flatMap(([k]) => k);
|
|
94
|
+
return leaking;
|
|
95
|
+
}
|
|
96
|
+
computeLeakingDisposables(maxReported = 10, preComputedLeaks) {
|
|
97
|
+
let uncoveredLeakingObjs;
|
|
98
|
+
if (preComputedLeaks) {
|
|
99
|
+
uncoveredLeakingObjs = preComputedLeaks;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
const rootParentCache = new Map();
|
|
103
|
+
const leakingObjects = [...this.livingDisposables.values()]
|
|
104
|
+
.filter((info) => info.source !== null && !this.getRootParent(info, rootParentCache).isSingleton);
|
|
105
|
+
if (leakingObjects.length === 0) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const leakingObjsSet = new Set(leakingObjects.map(o => o.value));
|
|
109
|
+
// Remove all objects that are a child of other leaking objects. Assumes there are no cycles.
|
|
110
|
+
uncoveredLeakingObjs = leakingObjects.filter(l => {
|
|
111
|
+
return !(l.parent && leakingObjsSet.has(l.parent));
|
|
112
|
+
});
|
|
113
|
+
if (uncoveredLeakingObjs.length === 0) {
|
|
114
|
+
throw new Error('There are cyclic diposable chains!');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!uncoveredLeakingObjs) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
function getStackTracePath(leaking) {
|
|
121
|
+
function removePrefix(array, linesToRemove) {
|
|
122
|
+
while (array.length > 0 && linesToRemove.some(regexp => typeof regexp === 'string' ? regexp === array[0] : array[0].match(regexp))) {
|
|
123
|
+
array.shift();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const lines = leaking.source.split('\n').map(p => p.trim().replace('at ', '')).filter(l => l !== '');
|
|
127
|
+
removePrefix(lines, ['Error', /^trackDisposable \(.*\)$/, /^DisposableTracker.trackDisposable \(.*\)$/]);
|
|
128
|
+
return lines.reverse();
|
|
129
|
+
}
|
|
130
|
+
const stackTraceStarts = new SetMap();
|
|
131
|
+
for (const leaking of uncoveredLeakingObjs) {
|
|
132
|
+
const stackTracePath = getStackTracePath(leaking);
|
|
133
|
+
for (let i = 0; i <= stackTracePath.length; i++) {
|
|
134
|
+
stackTraceStarts.add(stackTracePath.slice(0, i).join('\n'), leaking);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Put earlier leaks first
|
|
138
|
+
uncoveredLeakingObjs.sort(compareBy(l => l.idx, numberComparator));
|
|
139
|
+
let message = '';
|
|
140
|
+
let i = 0;
|
|
141
|
+
for (const leaking of uncoveredLeakingObjs.slice(0, maxReported)) {
|
|
142
|
+
i++;
|
|
143
|
+
const stackTracePath = getStackTracePath(leaking);
|
|
144
|
+
const stackTraceFormattedLines = [];
|
|
145
|
+
for (let i = 0; i < stackTracePath.length; i++) {
|
|
146
|
+
let line = stackTracePath[i];
|
|
147
|
+
const starts = stackTraceStarts.get(stackTracePath.slice(0, i + 1).join('\n'));
|
|
148
|
+
line = `(shared with ${starts.size}/${uncoveredLeakingObjs.length} leaks) at ${line}`;
|
|
149
|
+
const prevStarts = stackTraceStarts.get(stackTracePath.slice(0, i).join('\n'));
|
|
150
|
+
const continuations = groupBy([...prevStarts].map(d => getStackTracePath(d)[i]), v => v);
|
|
151
|
+
delete continuations[stackTracePath[i]];
|
|
152
|
+
for (const [cont, set] of Object.entries(continuations)) {
|
|
153
|
+
if (set) {
|
|
154
|
+
stackTraceFormattedLines.unshift(` - stacktraces of ${set.length} other leaks continue with ${cont}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
stackTraceFormattedLines.unshift(line);
|
|
158
|
+
}
|
|
159
|
+
message += `\n\n\n==================== Leaking disposable ${i}/${uncoveredLeakingObjs.length}: ${leaking.value.constructor.name} ====================\n${stackTraceFormattedLines.join('\n')}\n============================================================\n\n`;
|
|
160
|
+
}
|
|
161
|
+
if (uncoveredLeakingObjs.length > maxReported) {
|
|
162
|
+
message += `\n\n\n... and ${uncoveredLeakingObjs.length - maxReported} more leaking disposables\n\n`;
|
|
163
|
+
}
|
|
164
|
+
return { leaks: uncoveredLeakingObjs, details: message };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export function setDisposableTracker(tracker) {
|
|
168
|
+
disposableTracker = tracker;
|
|
169
|
+
}
|
|
170
|
+
if (TRACK_DISPOSABLES) {
|
|
171
|
+
const __is_disposable_tracked__ = '__is_disposable_tracked__';
|
|
172
|
+
setDisposableTracker(new class {
|
|
173
|
+
trackDisposable(x) {
|
|
174
|
+
const stack = new Error('Potentially leaked disposable').stack;
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
// eslint-disable-next-line local/code-no-any-casts
|
|
177
|
+
if (!x[__is_disposable_tracked__]) {
|
|
178
|
+
console.log(stack);
|
|
179
|
+
}
|
|
180
|
+
}, 3000);
|
|
181
|
+
}
|
|
182
|
+
setParent(child, parent) {
|
|
183
|
+
if (child && child !== Disposable.None) {
|
|
184
|
+
try {
|
|
185
|
+
// eslint-disable-next-line local/code-no-any-casts
|
|
186
|
+
child[__is_disposable_tracked__] = true;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// noop
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
markAsDisposed(disposable) {
|
|
194
|
+
if (disposable && disposable !== Disposable.None) {
|
|
195
|
+
try {
|
|
196
|
+
// eslint-disable-next-line local/code-no-any-casts
|
|
197
|
+
disposable[__is_disposable_tracked__] = true;
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// noop
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
markAsSingleton(disposable) { }
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
export function trackDisposable(x) {
|
|
208
|
+
disposableTracker?.trackDisposable(x);
|
|
209
|
+
return x;
|
|
210
|
+
}
|
|
211
|
+
export function markAsDisposed(disposable) {
|
|
212
|
+
disposableTracker?.markAsDisposed(disposable);
|
|
213
|
+
}
|
|
214
|
+
function setParentOfDisposable(child, parent) {
|
|
215
|
+
disposableTracker?.setParent(child, parent);
|
|
216
|
+
}
|
|
217
|
+
function setParentOfDisposables(children, parent) {
|
|
218
|
+
if (!disposableTracker) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
for (const child of children) {
|
|
222
|
+
disposableTracker.setParent(child, parent);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Indicates that the given object is a singleton which does not need to be disposed.
|
|
227
|
+
*/
|
|
228
|
+
export function markAsSingleton(singleton) {
|
|
229
|
+
disposableTracker?.markAsSingleton(singleton);
|
|
230
|
+
return singleton;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Check if `thing` is {@link IDisposable disposable}.
|
|
234
|
+
*/
|
|
235
|
+
export function isDisposable(thing) {
|
|
236
|
+
// eslint-disable-next-line local/code-no-any-casts
|
|
237
|
+
return typeof thing === 'object' && thing !== null && typeof thing.dispose === 'function' && thing.dispose.length === 0;
|
|
238
|
+
}
|
|
239
|
+
export function dispose(arg) {
|
|
240
|
+
if (Iterable.is(arg)) {
|
|
241
|
+
const errors = [];
|
|
242
|
+
for (const d of arg) {
|
|
243
|
+
if (d) {
|
|
244
|
+
try {
|
|
245
|
+
d.dispose();
|
|
246
|
+
}
|
|
247
|
+
catch (e) {
|
|
248
|
+
errors.push(e);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (errors.length === 1) {
|
|
253
|
+
throw errors[0];
|
|
254
|
+
}
|
|
255
|
+
else if (errors.length > 1) {
|
|
256
|
+
throw new AggregateError(errors, 'Encountered errors while disposing of store');
|
|
257
|
+
}
|
|
258
|
+
return Array.isArray(arg) ? [] : arg;
|
|
259
|
+
}
|
|
260
|
+
else if (arg) {
|
|
261
|
+
arg.dispose();
|
|
262
|
+
return arg;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export function disposeIfDisposable(disposables) {
|
|
266
|
+
for (const d of disposables) {
|
|
267
|
+
if (isDisposable(d)) {
|
|
268
|
+
d.dispose();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return [];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Combine multiple disposable values into a single {@link IDisposable}.
|
|
275
|
+
*/
|
|
276
|
+
export function combinedDisposable(...disposables) {
|
|
277
|
+
const parent = toDisposable(() => dispose(disposables));
|
|
278
|
+
setParentOfDisposables(disposables, parent);
|
|
279
|
+
return parent;
|
|
280
|
+
}
|
|
281
|
+
class FunctionDisposable {
|
|
282
|
+
constructor(fn) {
|
|
283
|
+
this._isDisposed = false;
|
|
284
|
+
this._fn = fn;
|
|
285
|
+
trackDisposable(this);
|
|
286
|
+
}
|
|
287
|
+
dispose() {
|
|
288
|
+
if (this._isDisposed) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!this._fn) {
|
|
292
|
+
throw new Error(`Unbound disposable context: Need to use an arrow function to preserve the value of this`);
|
|
293
|
+
}
|
|
294
|
+
this._isDisposed = true;
|
|
295
|
+
markAsDisposed(this);
|
|
296
|
+
this._fn();
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Turn a function that implements dispose into an {@link IDisposable}.
|
|
301
|
+
*
|
|
302
|
+
* @param fn Clean up function, guaranteed to be called only **once**.
|
|
303
|
+
*/
|
|
304
|
+
export function toDisposable(fn) {
|
|
305
|
+
return new FunctionDisposable(fn);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Manages a collection of disposable values.
|
|
309
|
+
*
|
|
310
|
+
* This is the preferred way to manage multiple disposables. A `DisposableStore` is safer to work with than an
|
|
311
|
+
* `IDisposable[]` as it considers edge cases, such as registering the same value multiple times or adding an item to a
|
|
312
|
+
* store that has already been disposed of.
|
|
313
|
+
*/
|
|
314
|
+
export class DisposableStore {
|
|
315
|
+
static { this.DISABLE_DISPOSED_WARNING = false; }
|
|
316
|
+
constructor() {
|
|
317
|
+
this._toDispose = new Set();
|
|
318
|
+
this._isDisposed = false;
|
|
319
|
+
trackDisposable(this);
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Dispose of all registered disposables and mark this object as disposed.
|
|
323
|
+
*
|
|
324
|
+
* Any future disposables added to this object will be disposed of on `add`.
|
|
325
|
+
*/
|
|
326
|
+
dispose() {
|
|
327
|
+
if (this._isDisposed) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
markAsDisposed(this);
|
|
331
|
+
this._isDisposed = true;
|
|
332
|
+
this.clear();
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @return `true` if this object has been disposed of.
|
|
336
|
+
*/
|
|
337
|
+
get isDisposed() {
|
|
338
|
+
return this._isDisposed;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Dispose of all registered disposables but do not mark this object as disposed.
|
|
342
|
+
*/
|
|
343
|
+
clear() {
|
|
344
|
+
if (this._toDispose.size === 0) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
dispose(this._toDispose);
|
|
349
|
+
}
|
|
350
|
+
finally {
|
|
351
|
+
this._toDispose.clear();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Add a new {@link IDisposable disposable} to the collection.
|
|
356
|
+
*/
|
|
357
|
+
add(o) {
|
|
358
|
+
if (!o || o === Disposable.None) {
|
|
359
|
+
return o;
|
|
360
|
+
}
|
|
361
|
+
if (o === this) {
|
|
362
|
+
throw new Error('Cannot register a disposable on itself!');
|
|
363
|
+
}
|
|
364
|
+
setParentOfDisposable(o, this);
|
|
365
|
+
if (this._isDisposed) {
|
|
366
|
+
if (!DisposableStore.DISABLE_DISPOSED_WARNING) {
|
|
367
|
+
console.warn(new Error('Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!').stack);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
this._toDispose.add(o);
|
|
372
|
+
}
|
|
373
|
+
return o;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Deletes a disposable from store and disposes of it. This will not throw or warn and proceed to dispose the
|
|
377
|
+
* disposable even when the disposable is not part in the store.
|
|
378
|
+
*/
|
|
379
|
+
delete(o) {
|
|
380
|
+
if (!o) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (o === this) {
|
|
384
|
+
throw new Error('Cannot dispose a disposable on itself!');
|
|
385
|
+
}
|
|
386
|
+
this._toDispose.delete(o);
|
|
387
|
+
o.dispose();
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Deletes the value from the store, but does not dispose it.
|
|
391
|
+
*/
|
|
392
|
+
deleteAndLeak(o) {
|
|
393
|
+
if (!o) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
if (this._toDispose.delete(o)) {
|
|
397
|
+
setParentOfDisposable(o, null);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
assertNotDisposed() {
|
|
401
|
+
if (this._isDisposed) {
|
|
402
|
+
onUnexpectedError(new BugIndicatingError('Object disposed'));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Abstract base class for a {@link IDisposable disposable} object.
|
|
408
|
+
*
|
|
409
|
+
* Subclasses can {@linkcode _register} disposables that will be automatically cleaned up when this object is disposed of.
|
|
410
|
+
*/
|
|
411
|
+
export class Disposable {
|
|
412
|
+
/**
|
|
413
|
+
* A disposable that does nothing when it is disposed of.
|
|
414
|
+
*
|
|
415
|
+
* TODO: This should not be a static property.
|
|
416
|
+
*/
|
|
417
|
+
static { this.None = Object.freeze({ dispose() { } }); }
|
|
418
|
+
constructor() {
|
|
419
|
+
this._store = new DisposableStore();
|
|
420
|
+
trackDisposable(this);
|
|
421
|
+
setParentOfDisposable(this._store, this);
|
|
422
|
+
}
|
|
423
|
+
dispose() {
|
|
424
|
+
markAsDisposed(this);
|
|
425
|
+
this._store.dispose();
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Adds `o` to the collection of disposables managed by this object.
|
|
429
|
+
*/
|
|
430
|
+
_register(o) {
|
|
431
|
+
if (o === this) {
|
|
432
|
+
throw new Error('Cannot register a disposable on itself!');
|
|
433
|
+
}
|
|
434
|
+
return this._store.add(o);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Manages the lifecycle of a disposable value that may be changed.
|
|
439
|
+
*
|
|
440
|
+
* This ensures that when the disposable value is changed, the previously held disposable is disposed of. You can
|
|
441
|
+
* also register a `MutableDisposable` on a `Disposable` to ensure it is automatically cleaned up.
|
|
442
|
+
*/
|
|
443
|
+
export class MutableDisposable {
|
|
444
|
+
constructor() {
|
|
445
|
+
this._isDisposed = false;
|
|
446
|
+
trackDisposable(this);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Get the currently held disposable value, or `undefined` if this MutableDisposable has been disposed
|
|
450
|
+
*/
|
|
451
|
+
get value() {
|
|
452
|
+
return this._isDisposed ? undefined : this._value;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Set a new disposable value.
|
|
456
|
+
*
|
|
457
|
+
* Behaviour:
|
|
458
|
+
* - If the MutableDisposable has been disposed, the setter is a no-op.
|
|
459
|
+
* - If the new value is strictly equal to the current value, the setter is a no-op.
|
|
460
|
+
* - Otherwise the previous value (if any) is disposed and the new value is stored.
|
|
461
|
+
*
|
|
462
|
+
* Related helpers:
|
|
463
|
+
* - clear() resets the value to `undefined` (and disposes the previous value).
|
|
464
|
+
* - clearAndLeak() returns the old value without disposing it and removes its parent.
|
|
465
|
+
*/
|
|
466
|
+
set value(value) {
|
|
467
|
+
if (this._isDisposed || value === this._value) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
this._value?.dispose();
|
|
471
|
+
if (value) {
|
|
472
|
+
setParentOfDisposable(value, this);
|
|
473
|
+
}
|
|
474
|
+
this._value = value;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Resets the stored value and disposed of the previously stored value.
|
|
478
|
+
*/
|
|
479
|
+
clear() {
|
|
480
|
+
this.value = undefined;
|
|
481
|
+
}
|
|
482
|
+
dispose() {
|
|
483
|
+
this._isDisposed = true;
|
|
484
|
+
markAsDisposed(this);
|
|
485
|
+
this._value?.dispose();
|
|
486
|
+
this._value = undefined;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Clears the value, but does not dispose it.
|
|
490
|
+
* The old value is returned.
|
|
491
|
+
*/
|
|
492
|
+
clearAndLeak() {
|
|
493
|
+
const oldValue = this._value;
|
|
494
|
+
this._value = undefined;
|
|
495
|
+
if (oldValue) {
|
|
496
|
+
setParentOfDisposable(oldValue, null);
|
|
497
|
+
}
|
|
498
|
+
return oldValue;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Manages the lifecycle of a disposable value that may be changed like {@link MutableDisposable}, but the value must
|
|
503
|
+
* exist and cannot be undefined.
|
|
504
|
+
*/
|
|
505
|
+
export class MandatoryMutableDisposable {
|
|
506
|
+
constructor(initialValue) {
|
|
507
|
+
this._disposable = new MutableDisposable();
|
|
508
|
+
this._isDisposed = false;
|
|
509
|
+
this._disposable.value = initialValue;
|
|
510
|
+
}
|
|
511
|
+
get value() {
|
|
512
|
+
return this._disposable.value;
|
|
513
|
+
}
|
|
514
|
+
set value(value) {
|
|
515
|
+
if (this._isDisposed || value === this._disposable.value) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
this._disposable.value = value;
|
|
519
|
+
}
|
|
520
|
+
dispose() {
|
|
521
|
+
this._isDisposed = true;
|
|
522
|
+
this._disposable.dispose();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
export class RefCountedDisposable {
|
|
526
|
+
constructor(_disposable) {
|
|
527
|
+
this._disposable = _disposable;
|
|
528
|
+
this._counter = 1;
|
|
529
|
+
}
|
|
530
|
+
acquire() {
|
|
531
|
+
this._counter++;
|
|
532
|
+
return this;
|
|
533
|
+
}
|
|
534
|
+
release() {
|
|
535
|
+
if (--this._counter === 0) {
|
|
536
|
+
this._disposable.dispose();
|
|
537
|
+
}
|
|
538
|
+
return this;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
export class ReferenceCollection {
|
|
542
|
+
constructor() {
|
|
543
|
+
this.references = new Map();
|
|
544
|
+
}
|
|
545
|
+
acquire(key, ...args) {
|
|
546
|
+
let reference = this.references.get(key);
|
|
547
|
+
if (!reference) {
|
|
548
|
+
reference = { counter: 0, object: this.createReferencedObject(key, ...args) };
|
|
549
|
+
this.references.set(key, reference);
|
|
550
|
+
}
|
|
551
|
+
const { object } = reference;
|
|
552
|
+
const dispose = createSingleCallFunction(() => {
|
|
553
|
+
if (--reference.counter === 0) {
|
|
554
|
+
this.destroyReferencedObject(key, reference.object);
|
|
555
|
+
this.references.delete(key);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
reference.counter++;
|
|
559
|
+
return { object, dispose };
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Unwraps a reference collection of promised values. Makes sure
|
|
564
|
+
* references are disposed whenever promises get rejected.
|
|
565
|
+
*/
|
|
566
|
+
export class AsyncReferenceCollection {
|
|
567
|
+
constructor(referenceCollection) {
|
|
568
|
+
this.referenceCollection = referenceCollection;
|
|
569
|
+
}
|
|
570
|
+
async acquire(key, ...args) {
|
|
571
|
+
const ref = this.referenceCollection.acquire(key, ...args);
|
|
572
|
+
try {
|
|
573
|
+
const object = await ref.object;
|
|
574
|
+
return {
|
|
575
|
+
object,
|
|
576
|
+
dispose: () => ref.dispose()
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
ref.dispose();
|
|
581
|
+
throw error;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
export class ImmortalReference {
|
|
586
|
+
constructor(object) {
|
|
587
|
+
this.object = object;
|
|
588
|
+
}
|
|
589
|
+
dispose() { }
|
|
590
|
+
}
|
|
591
|
+
export function disposeOnReturn(fn) {
|
|
592
|
+
const store = new DisposableStore();
|
|
593
|
+
try {
|
|
594
|
+
fn(store);
|
|
595
|
+
}
|
|
596
|
+
finally {
|
|
597
|
+
store.dispose();
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* A map the manages the lifecycle of the values that it stores.
|
|
602
|
+
*/
|
|
603
|
+
export class DisposableMap {
|
|
604
|
+
constructor(store = new Map()) {
|
|
605
|
+
this._isDisposed = false;
|
|
606
|
+
this._store = store;
|
|
607
|
+
trackDisposable(this);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Disposes of all stored values and mark this object as disposed.
|
|
611
|
+
*
|
|
612
|
+
* Trying to use this object after it has been disposed of is an error.
|
|
613
|
+
*/
|
|
614
|
+
dispose() {
|
|
615
|
+
markAsDisposed(this);
|
|
616
|
+
this._isDisposed = true;
|
|
617
|
+
this.clearAndDisposeAll();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Disposes of all stored values and clear the map, but DO NOT mark this object as disposed.
|
|
621
|
+
*/
|
|
622
|
+
clearAndDisposeAll() {
|
|
623
|
+
if (!this._store.size) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
try {
|
|
627
|
+
dispose(this._store.values());
|
|
628
|
+
}
|
|
629
|
+
finally {
|
|
630
|
+
this._store.clear();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
has(key) {
|
|
634
|
+
return this._store.has(key);
|
|
635
|
+
}
|
|
636
|
+
get size() {
|
|
637
|
+
return this._store.size;
|
|
638
|
+
}
|
|
639
|
+
get(key) {
|
|
640
|
+
return this._store.get(key);
|
|
641
|
+
}
|
|
642
|
+
set(key, value, skipDisposeOnOverwrite = false) {
|
|
643
|
+
if (this._isDisposed) {
|
|
644
|
+
console.warn(new Error('Trying to add a disposable to a DisposableMap that has already been disposed of. The added object will be leaked!').stack);
|
|
645
|
+
}
|
|
646
|
+
if (!skipDisposeOnOverwrite) {
|
|
647
|
+
this._store.get(key)?.dispose();
|
|
648
|
+
}
|
|
649
|
+
this._store.set(key, value);
|
|
650
|
+
setParentOfDisposable(value, this);
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Delete the value stored for `key` from this map and also dispose of it.
|
|
654
|
+
*/
|
|
655
|
+
deleteAndDispose(key) {
|
|
656
|
+
this._store.get(key)?.dispose();
|
|
657
|
+
this._store.delete(key);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Delete the value stored for `key` from this map but return it. The caller is
|
|
661
|
+
* responsible for disposing of the value.
|
|
662
|
+
*/
|
|
663
|
+
deleteAndLeak(key) {
|
|
664
|
+
const value = this._store.get(key);
|
|
665
|
+
if (value) {
|
|
666
|
+
setParentOfDisposable(value, null);
|
|
667
|
+
}
|
|
668
|
+
this._store.delete(key);
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
keys() {
|
|
672
|
+
return this._store.keys();
|
|
673
|
+
}
|
|
674
|
+
values() {
|
|
675
|
+
return this._store.values();
|
|
676
|
+
}
|
|
677
|
+
[Symbol.iterator]() {
|
|
678
|
+
return this._store[Symbol.iterator]();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* A set that manages the lifecycle of the values that it stores.
|
|
683
|
+
*/
|
|
684
|
+
export class DisposableSet {
|
|
685
|
+
constructor(store = new Set()) {
|
|
686
|
+
this._isDisposed = false;
|
|
687
|
+
this._store = store;
|
|
688
|
+
trackDisposable(this);
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Disposes of all stored values and mark this object as disposed.
|
|
692
|
+
*
|
|
693
|
+
* Trying to use this object after it has been disposed of is an error.
|
|
694
|
+
*/
|
|
695
|
+
dispose() {
|
|
696
|
+
markAsDisposed(this);
|
|
697
|
+
this._isDisposed = true;
|
|
698
|
+
this.clearAndDisposeAll();
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Disposes of all stored values and clear the set, but DO NOT mark this object as disposed.
|
|
702
|
+
*/
|
|
703
|
+
clearAndDisposeAll() {
|
|
704
|
+
if (!this._store.size) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
try {
|
|
708
|
+
dispose(this._store.values());
|
|
709
|
+
}
|
|
710
|
+
finally {
|
|
711
|
+
this._store.clear();
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
has(value) {
|
|
715
|
+
return this._store.has(value);
|
|
716
|
+
}
|
|
717
|
+
get size() {
|
|
718
|
+
return this._store.size;
|
|
719
|
+
}
|
|
720
|
+
add(value) {
|
|
721
|
+
if (this._isDisposed) {
|
|
722
|
+
console.warn(new Error('Trying to add a disposable to a DisposableSet that has already been disposed of. The added object will be leaked!').stack);
|
|
723
|
+
}
|
|
724
|
+
this._store.add(value);
|
|
725
|
+
setParentOfDisposable(value, this);
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* Delete the value from this set and also dispose of it.
|
|
729
|
+
*/
|
|
730
|
+
deleteAndDispose(value) {
|
|
731
|
+
if (this._store.delete(value)) {
|
|
732
|
+
value.dispose();
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Delete the value from this set but return it. The caller is
|
|
737
|
+
* responsible for disposing of the value.
|
|
738
|
+
*/
|
|
739
|
+
deleteAndLeak(value) {
|
|
740
|
+
if (this._store.delete(value)) {
|
|
741
|
+
setParentOfDisposable(value, null);
|
|
742
|
+
return value;
|
|
743
|
+
}
|
|
744
|
+
return undefined;
|
|
745
|
+
}
|
|
746
|
+
values() {
|
|
747
|
+
return this._store.values();
|
|
748
|
+
}
|
|
749
|
+
[Symbol.iterator]() {
|
|
750
|
+
return this._store[Symbol.iterator]();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Call `then` on a Promise, unless the returned disposable is disposed.
|
|
755
|
+
*/
|
|
756
|
+
export function thenIfNotDisposed(promise, then) {
|
|
757
|
+
let disposed = false;
|
|
758
|
+
promise.then(result => {
|
|
759
|
+
if (disposed) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
then(result);
|
|
763
|
+
});
|
|
764
|
+
return toDisposable(() => {
|
|
765
|
+
disposed = true;
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Call `then` on a promise that resolves to a {@link IDisposable}, then either register the
|
|
770
|
+
* disposable or register it to the {@link DisposableStore}, depending on whether the store is
|
|
771
|
+
* disposed or not.
|
|
772
|
+
*/
|
|
773
|
+
export function thenRegisterOrDispose(promise, store) {
|
|
774
|
+
return promise.then(disposable => {
|
|
775
|
+
if (store.isDisposed) {
|
|
776
|
+
disposable.dispose();
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
store.add(disposable);
|
|
780
|
+
}
|
|
781
|
+
return disposable;
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
export class DisposableResourceMap extends DisposableMap {
|
|
785
|
+
constructor() {
|
|
786
|
+
super(new ResourceMap());
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
//# sourceMappingURL=lifecycle.js.map
|