monaco-editor-core 0.54.0-dev-20251004 → 0.54.0-dev-20251006
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/esm/nls.messages.de.js +1 -1
- package/esm/nls.messages.es.js +1 -1
- package/esm/nls.messages.fr.js +1 -1
- package/esm/nls.messages.it.js +1 -1
- package/esm/nls.messages.ja.js +1 -1
- package/esm/nls.messages.ko.js +1 -1
- package/esm/nls.messages.ru.js +1 -1
- package/esm/nls.messages.zh-cn.js +1 -1
- package/esm/nls.messages.zh-tw.js +1 -1
- package/esm/vs/base/browser/dom.js.map +1 -1
- package/esm/vs/base/browser/fastDomNode.js +0 -1
- package/esm/vs/base/browser/fastDomNode.js.map +1 -1
- package/esm/vs/base/browser/ui/scrollbar/scrollableElement.js +1 -1
- package/esm/vs/base/browser/ui/scrollbar/scrollableElement.js.map +1 -1
- package/esm/vs/base/common/buffer.js.map +1 -1
- package/esm/vs/base/common/errors.js.map +1 -1
- package/esm/vs/base/common/hash.js.map +1 -1
- package/esm/vs/base/common/worker/webWorker.js +26 -22
- package/esm/vs/base/common/worker/webWorker.js.map +1 -1
- package/esm/vs/editor/browser/config/editorConfiguration.js +3 -6
- package/esm/vs/editor/browser/config/editorConfiguration.js.map +1 -1
- package/esm/vs/editor/browser/config/migrateOptions.js +1 -2
- package/esm/vs/editor/browser/config/migrateOptions.js.map +1 -1
- package/esm/vs/editor/browser/controller/editContext/native/editContextFactory.js +0 -1
- package/esm/vs/editor/browser/controller/editContext/native/editContextFactory.js.map +1 -1
- package/esm/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.js +2 -2
- package/esm/vs/editor/browser/controller/editContext/native/nativeEditContextUtils.js.map +1 -1
- package/esm/vs/editor/browser/controller/mouseHandler.js +2 -2
- package/esm/vs/editor/browser/controller/mouseHandler.js.map +1 -1
- package/esm/vs/editor/browser/controller/mouseTarget.js +7 -8
- package/esm/vs/editor/browser/controller/mouseTarget.js.map +1 -1
- package/esm/vs/editor/browser/controller/pointerHandler.js +0 -2
- package/esm/vs/editor/browser/controller/pointerHandler.js.map +1 -1
- package/esm/vs/editor/browser/coreCommands.js.map +1 -1
- package/esm/vs/editor/browser/editorBrowser.js.map +1 -1
- package/esm/vs/editor/browser/editorDom.js +0 -2
- package/esm/vs/editor/browser/editorDom.js.map +1 -1
- package/esm/vs/editor/browser/editorExtensions.js.map +1 -1
- package/esm/vs/editor/browser/gpu/gpuUtils.js +1 -1
- package/esm/vs/editor/browser/gpu/gpuUtils.js.map +1 -1
- package/esm/vs/editor/browser/gpu/viewGpuContext.js +1 -1
- package/esm/vs/editor/browser/gpu/viewGpuContext.js.map +1 -1
- package/esm/vs/editor/browser/services/abstractCodeEditorService.js.map +1 -1
- package/esm/vs/editor/browser/services/bulkEditService.js.map +1 -1
- package/esm/vs/editor/browser/services/codeEditorService.js.map +1 -1
- package/esm/vs/editor/browser/services/editorWorkerService.js.map +1 -1
- package/esm/vs/editor/browser/services/hoverService/hoverService.js +0 -1
- package/esm/vs/editor/browser/services/hoverService/hoverService.js.map +1 -1
- package/esm/vs/editor/browser/services/hoverService/hoverWidget.js +1 -1
- package/esm/vs/editor/browser/services/hoverService/hoverWidget.js.map +1 -1
- package/esm/vs/editor/browser/services/openerService.js.map +1 -1
- package/esm/vs/editor/browser/view.js.map +1 -1
- package/esm/vs/editor/browser/viewParts/contentWidgets/contentWidgets.js +1 -0
- package/esm/vs/editor/browser/viewParts/contentWidgets/contentWidgets.js.map +1 -1
- package/esm/vs/editor/browser/viewParts/viewZones/viewZones.js +1 -0
- package/esm/vs/editor/browser/viewParts/viewZones/viewZones.js.map +1 -1
- package/esm/vs/editor/browser/widget/codeEditor/codeEditorContributions.js.map +1 -1
- package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js +4 -2
- package/esm/vs/editor/browser/widget/codeEditor/codeEditorWidget.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorEditors.js +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/components/diffEditorEditors.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/delegatingEditorImpl.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorOptions.js +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorOptions.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/utils.js +2 -2
- package/esm/vs/editor/browser/widget/diffEditor/utils.js.map +1 -1
- package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js +2 -2
- package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js.map +1 -1
- package/esm/vs/editor/common/config/editorOptions.js +121 -72
- package/esm/vs/editor/common/config/editorOptions.js.map +1 -1
- package/esm/vs/editor/common/config/fontInfo.js +32 -16
- package/esm/vs/editor/common/config/fontInfo.js.map +1 -1
- package/esm/vs/editor/common/config/fontInfoFromSettings.js +16 -0
- package/esm/vs/editor/common/config/fontInfoFromSettings.js.map +1 -0
- package/esm/vs/editor/common/core/edits/edit.js +1 -0
- package/esm/vs/editor/common/core/edits/edit.js.map +1 -1
- package/esm/vs/editor/common/core/edits/stringEdit.js +2 -0
- package/esm/vs/editor/common/core/edits/stringEdit.js.map +1 -1
- package/esm/vs/editor/common/core/position.js +1 -1
- package/esm/vs/editor/common/core/position.js.map +1 -1
- package/esm/vs/editor/common/core/range.js +1 -1
- package/esm/vs/editor/common/core/range.js.map +1 -1
- package/esm/vs/editor/common/core/selection.js +1 -1
- package/esm/vs/editor/common/core/selection.js.map +1 -1
- package/esm/vs/editor/common/cursor/cursorMoveCommands.js.map +1 -1
- package/esm/vs/editor/common/editorCommon.js.map +1 -1
- package/esm/vs/editor/common/languages.js +1 -2
- package/esm/vs/editor/common/languages.js.map +1 -1
- package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length.js +14 -13
- package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/length.js.map +1 -1
- package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet.js +2 -0
- package/esm/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/smallImmutableSet.js.map +1 -1
- package/esm/vs/editor/common/model/textModel.js +1 -1
- package/esm/vs/editor/common/model/textModel.js.map +1 -1
- package/esm/vs/editor/common/model.js +1 -1
- package/esm/vs/editor/common/model.js.map +1 -1
- package/esm/vs/editor/common/services/editorBaseApi.js +0 -2
- package/esm/vs/editor/common/services/editorBaseApi.js.map +1 -1
- package/esm/vs/editor/common/services/editorWebWorker.js +1 -0
- package/esm/vs/editor/common/services/editorWebWorker.js.map +1 -1
- package/esm/vs/editor/common/services/editorWorkerHost.js.map +1 -1
- package/esm/vs/editor/common/services/modelService.js +14 -21
- package/esm/vs/editor/common/services/modelService.js.map +1 -1
- package/esm/vs/editor/common/textModelEditSource.js +2 -1
- package/esm/vs/editor/common/textModelEditSource.js.map +1 -1
- package/esm/vs/editor/common/viewLayout/viewLineRenderer.js +40 -1
- package/esm/vs/editor/common/viewLayout/viewLineRenderer.js.map +1 -1
- package/esm/vs/editor/common/viewModel/viewModelImpl.js +2 -1
- package/esm/vs/editor/common/viewModel/viewModelImpl.js.map +1 -1
- package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js +1 -0
- package/esm/vs/editor/contrib/codeAction/browser/codeActionController.js.map +1 -1
- package/esm/vs/editor/contrib/codelens/browser/codelensController.js +1 -1
- package/esm/vs/editor/contrib/codelens/browser/codelensController.js.map +1 -1
- package/esm/vs/editor/contrib/folding/browser/foldingDecorations.js.map +1 -1
- package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js +1 -1
- package/esm/vs/editor/contrib/gotoSymbol/browser/link/goToDefinitionAtPosition.js.map +1 -1
- package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsController.js +1 -1
- package/esm/vs/editor/contrib/inlayHints/browser/inlayHintsController.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js +1 -0
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.js.map +1 -1
- package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js +1 -1
- package/esm/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.js.map +1 -1
- package/esm/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.js.map +1 -1
- package/esm/vs/editor/editor.api.d.ts +8 -8
- package/esm/vs/editor/standalone/browser/standaloneWebWorker.js.map +1 -1
- package/monaco.d.ts +8 -8
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/errors.ts","vs/base/common/errors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAMhG,uFAAuF;AACvF,MAAM,OAAO,YAAY;IAIxB;QAEC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAEpB,IAAI,CAAC,sBAAsB,GAAG,UAAU,CAAM;YAC7C,UAAU,CAAC,GAAG,EAAE;gBACf,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;oBACb,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC5C,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC1D,CAAC;oBAED,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC/C,CAAC;gBAED,MAAM,CAAC,CAAC;YACT,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,CAAM;QAClB,IAAI,CAAC,SAA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.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface ErrorListenerCallback {\n\t(error: any): void;\n}\n\n// Avoid circular dependency on EventEmitter by implementing a subset of the interface.\nexport class ErrorHandler {\n\tprivate unexpectedErrorHandler: (e: any) => void;\n\tprivate listeners: ErrorListenerCallback[];\n\n\tconstructor() {\n\n\t\tthis.listeners = [];\n\n\t\tthis.unexpectedErrorHandler = function (e: any) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (e.stack) {\n\t\t\t\t\tif (ErrorNoTelemetry.isErrorNoTelemetry(e)) {\n\t\t\t\t\t\tthrow new ErrorNoTelemetry(e.message + '\\n\\n' + e.stack);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(e.message + '\\n\\n' + e.stack);\n\t\t\t\t}\n\n\t\t\t\tthrow e;\n\t\t\t}, 0);\n\t\t};\n\t}\n\n\tprivate emit(e: any): void {\n\t\tthis.listeners.forEach((listener) => {\n\t\t\tlistener(e);\n\t\t});\n\t}\n\n\tonUnexpectedError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t\tthis.emit(e);\n\t}\n\n\t// For external errors, we don't want the listeners to be called\n\tonUnexpectedExternalError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t}\n}\n\nexport const errorHandler = new ErrorHandler();\n\n/**\n * This function should only be called with errors that indicate a bug in the product.\n * E.g. buggy extensions/invalid user-input/network issues should not be able to trigger this code path.\n * If they are, this indicates there is also a bug in the product.\n*/\nexport function onBugIndicatingError(e: any): undefined {\n\terrorHandler.onUnexpectedError(e);\n\treturn undefined;\n}\n\nexport function onUnexpectedError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedError(e);\n\t}\n\treturn undefined;\n}\n\nexport function onUnexpectedExternalError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedExternalError(e);\n\t}\n\treturn undefined;\n}\n\nexport interface SerializedError {\n}\n\ntype ErrorWithCode = Error & {\n\tcode: string | undefined;\n};\n\nexport function transformErrorForSerialization(error: Error): SerializedError;\nexport function transformErrorForSerialization(error: any): any;\nexport function transformErrorForSerialization(error: any): any {\n\tif (error instanceof Error) {\n\t\tconst { name, message, cause } = error;\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tconst stack: string = (<any>error).stacktrace || (<any>error).stack;\n\t\treturn {\n\t\t\t$isError: true,\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tstack,\n\t\t\tnoTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),\n\t\t\tcause: cause ? transformErrorForSerialization(cause) : undefined,\n\t\t\tcode: (<ErrorWithCode>error).code\n\t\t};\n\t}\n\n\t// return as is\n\treturn error;\n}\n\nexport const canceledName = 'Canceled';\n\n/**\n * Checks if the given error is a promise in canceled state\n */\nexport function isCancellationError(error: any): boolean {\n\tif (error instanceof CancellationError) {\n\t\treturn true;\n\t}\n\treturn error instanceof Error && error.name === canceledName && error.message === canceledName;\n}\n\n// !!!IMPORTANT!!!\n// Do NOT change this class because it is also used as an API-type.\nexport class CancellationError extends Error {\n\tconstructor() {\n\t\tsuper(canceledName);\n\t\tthis.name = this.message;\n\t}\n}\n\n/**\n * @deprecated use {@link CancellationError `new CancellationError()`} instead\n */\nexport function canceled(): Error {\n\tconst error = new Error(canceledName);\n\terror.name = error.message;\n\treturn error;\n}\n\nexport function illegalArgument(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal argument: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal argument');\n\t}\n}\n\nexport function illegalState(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal state: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal state');\n\t}\n}\n\nexport class NotSupportedError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper('NotSupported');\n\t\tif (message) {\n\t\t\tthis.message = message;\n\t\t}\n\t}\n}\n\n/**\n * Error that when thrown won't be logged in telemetry as an unhandled error.\n */\nexport class ErrorNoTelemetry extends Error {\n\toverride readonly name: string;\n\n\tconstructor(msg?: string) {\n\t\tsuper(msg);\n\t\tthis.name = 'CodeExpectedError';\n\t}\n\n\tpublic static fromError(err: Error): ErrorNoTelemetry {\n\t\tif (err instanceof ErrorNoTelemetry) {\n\t\t\treturn err;\n\t\t}\n\n\t\tconst result = new ErrorNoTelemetry();\n\t\tresult.message = err.message;\n\t\tresult.stack = err.stack;\n\t\treturn result;\n\t}\n\n\tpublic static isErrorNoTelemetry(err: Error): err is ErrorNoTelemetry {\n\t\treturn err.name === 'CodeExpectedError';\n\t}\n}\n\n/**\n * This error indicates a bug.\n * Do not throw this for invalid user input.\n * Only catch this error to recover gracefully from bugs.\n */\nexport class BugIndicatingError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper(message || 'An unexpected bug occurred.');\n\t\tObject.setPrototypeOf(this, BugIndicatingError.prototype);\n\n\t\t// Because we know for sure only buggy code throws this,\n\t\t// we definitely want to break here and fix the bug.\n\t\t// debugger;\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface ErrorListenerCallback {\n\t(error: any): void;\n}\n\n// Avoid circular dependency on EventEmitter by implementing a subset of the interface.\nexport class ErrorHandler {\n\tprivate unexpectedErrorHandler: (e: any) => void;\n\tprivate listeners: ErrorListenerCallback[];\n\n\tconstructor() {\n\n\t\tthis.listeners = [];\n\n\t\tthis.unexpectedErrorHandler = function (e: any) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (e.stack) {\n\t\t\t\t\tif (ErrorNoTelemetry.isErrorNoTelemetry(e)) {\n\t\t\t\t\t\tthrow new ErrorNoTelemetry(e.message + '\\n\\n' + e.stack);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(e.message + '\\n\\n' + e.stack);\n\t\t\t\t}\n\n\t\t\t\tthrow e;\n\t\t\t}, 0);\n\t\t};\n\t}\n\n\tprivate emit(e: any): void {\n\t\tthis.listeners.forEach((listener) => {\n\t\t\tlistener(e);\n\t\t});\n\t}\n\n\tonUnexpectedError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t\tthis.emit(e);\n\t}\n\n\t// For external errors, we don't want the listeners to be called\n\tonUnexpectedExternalError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t}\n}\n\nexport const errorHandler = new ErrorHandler();\n\n/**\n * This function should only be called with errors that indicate a bug in the product.\n * E.g. buggy extensions/invalid user-input/network issues should not be able to trigger this code path.\n * If they are, this indicates there is also a bug in the product.\n*/\nexport function onBugIndicatingError(e: any): undefined {\n\terrorHandler.onUnexpectedError(e);\n\treturn undefined;\n}\n\nexport function onUnexpectedError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedError(e);\n\t}\n\treturn undefined;\n}\n\nexport function onUnexpectedExternalError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedExternalError(e);\n\t}\n\treturn undefined;\n}\n\nexport interface SerializedError {\n}\n\ntype ErrorWithCode = Error & {\n\tcode: string | undefined;\n};\n\nexport function transformErrorForSerialization(error: Error): SerializedError;\nexport function transformErrorForSerialization(error: any): any;\nexport function transformErrorForSerialization(error: any): any {\n\tif (error instanceof Error) {\n\t\tconst { name, message, cause } = error;\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tconst stack: string = (<any>error).stacktrace || (<any>error).stack;\n\t\treturn {\n\t\t\t$isError: true,\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tstack,\n\t\t\tnoTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),\n\t\t\tcause: cause ? transformErrorForSerialization(cause) : undefined,\n\t\t\tcode: (<ErrorWithCode>error).code\n\t\t};\n\t}\n\n\t// return as is\n\treturn error;\n}\n\nexport const canceledName = 'Canceled';\n\n/**\n * Checks if the given error is a promise in canceled state\n */\nexport function isCancellationError(error: any): boolean {\n\tif (error instanceof CancellationError) {\n\t\treturn true;\n\t}\n\treturn error instanceof Error && error.name === canceledName && error.message === canceledName;\n}\n\n// !!!IMPORTANT!!!\n// Do NOT change this class because it is also used as an API-type.\nexport class CancellationError extends Error {\n\tconstructor() {\n\t\tsuper(canceledName);\n\t\tthis.name = this.message;\n\t}\n}\n\n/**\n * @deprecated use {@link CancellationError `new CancellationError()`} instead\n */\nexport function canceled(): Error {\n\tconst error = new Error(canceledName);\n\terror.name = error.message;\n\treturn error;\n}\n\nexport function illegalArgument(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal argument: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal argument');\n\t}\n}\n\nexport function illegalState(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal state: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal state');\n\t}\n}\n\nexport class NotSupportedError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper('NotSupported');\n\t\tif (message) {\n\t\t\tthis.message = message;\n\t\t}\n\t}\n}\n\n/**\n * Error that when thrown won't be logged in telemetry as an unhandled error.\n */\nexport class ErrorNoTelemetry extends Error {\n\toverride readonly name: string;\n\n\tconstructor(msg?: string) {\n\t\tsuper(msg);\n\t\tthis.name = 'CodeExpectedError';\n\t}\n\n\tpublic static fromError(err: Error): ErrorNoTelemetry {\n\t\tif (err instanceof ErrorNoTelemetry) {\n\t\t\treturn err;\n\t\t}\n\n\t\tconst result = new ErrorNoTelemetry();\n\t\tresult.message = err.message;\n\t\tresult.stack = err.stack;\n\t\treturn result;\n\t}\n\n\tpublic static isErrorNoTelemetry(err: Error): err is ErrorNoTelemetry {\n\t\treturn err.name === 'CodeExpectedError';\n\t}\n}\n\n/**\n * This error indicates a bug.\n * Do not throw this for invalid user input.\n * Only catch this error to recover gracefully from bugs.\n */\nexport class BugIndicatingError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper(message || 'An unexpected bug occurred.');\n\t\tObject.setPrototypeOf(this, BugIndicatingError.prototype);\n\n\t\t// Because we know for sure only buggy code throws this,\n\t\t// we definitely want to break here and fix the bug.\n\t\t// debugger;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/errors.ts","vs/base/common/errors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAMhG,uFAAuF;AACvF,MAAM,OAAO,YAAY;IAIxB;QAEC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QAEpB,IAAI,CAAC,sBAAsB,GAAG,UAAU,CAAM;YAC7C,UAAU,CAAC,GAAG,EAAE;gBACf,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;oBACb,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC5C,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC1D,CAAC;oBAED,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC/C,CAAC;gBAED,MAAM,CAAC,CAAC;YACT,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;IACH,CAAC;IAEO,IAAI,CAAC,CAAM;QAClB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,iBAAiB,CAAC,CAAM;QACv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,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;AACF,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC3C,YAAY,OAAgB;QAC3B,KAAK,CAAC,cAAc,CAAC,CAAC;QACtB,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACxB,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAG1C,YAAY,GAAY;QACvB,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,GAAU;QACjC,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;YACrC,OAAO,GAAG,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACtC,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC7B,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;QACzB,OAAO,MAAM,CAAC;IACf,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,GAAU;QAC1C,OAAO,GAAG,CAAC,IAAI,KAAK,mBAAmB,CAAC;IACzC,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5C,YAAY,OAAgB;QAC3B,KAAK,CAAC,OAAO,IAAI,6BAA6B,CAAC,CAAC;QAChD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAE1D,wDAAwD;QACxD,oDAAoD;QACpD,YAAY;IACb,CAAC;CACD","file":"errors.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface ErrorListenerCallback {\n\t(error: any): void;\n}\n\n// Avoid circular dependency on EventEmitter by implementing a subset of the interface.\nexport class ErrorHandler {\n\tprivate unexpectedErrorHandler: (e: any) => void;\n\tprivate listeners: ErrorListenerCallback[];\n\n\tconstructor() {\n\n\t\tthis.listeners = [];\n\n\t\tthis.unexpectedErrorHandler = function (e: any) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (e.stack) {\n\t\t\t\t\tif (ErrorNoTelemetry.isErrorNoTelemetry(e)) {\n\t\t\t\t\t\tthrow new ErrorNoTelemetry(e.message + '\\n\\n' + e.stack);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(e.message + '\\n\\n' + e.stack);\n\t\t\t\t}\n\n\t\t\t\tthrow e;\n\t\t\t}, 0);\n\t\t};\n\t}\n\n\tprivate emit(e: any): void {\n\t\tthis.listeners.forEach((listener) => {\n\t\t\tlistener(e);\n\t\t});\n\t}\n\n\tonUnexpectedError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t\tthis.emit(e);\n\t}\n\n\t// For external errors, we don't want the listeners to be called\n\tonUnexpectedExternalError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t}\n}\n\nexport const errorHandler = new ErrorHandler();\n\n/**\n * This function should only be called with errors that indicate a bug in the product.\n * E.g. buggy extensions/invalid user-input/network issues should not be able to trigger this code path.\n * If they are, this indicates there is also a bug in the product.\n*/\nexport function onBugIndicatingError(e: any): undefined {\n\terrorHandler.onUnexpectedError(e);\n\treturn undefined;\n}\n\nexport function onUnexpectedError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedError(e);\n\t}\n\treturn undefined;\n}\n\nexport function onUnexpectedExternalError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedExternalError(e);\n\t}\n\treturn undefined;\n}\n\nexport interface SerializedError {\n\treadonly $isError: true;\n\treadonly name: string;\n\treadonly message: string;\n\treadonly stack: string;\n}\n\ntype ErrorWithCode = Error & {\n\tcode: string | undefined;\n};\n\nexport function transformErrorForSerialization(error: Error): SerializedError;\nexport function transformErrorForSerialization(error: any): any;\nexport function transformErrorForSerialization(error: any): any {\n\tif (error instanceof Error) {\n\t\tconst { name, message, cause } = error;\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tconst stack: string = (<any>error).stacktrace || (<any>error).stack;\n\t\treturn {\n\t\t\t$isError: true,\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tstack,\n\t\t\tnoTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),\n\t\t\tcause: cause ? transformErrorForSerialization(cause) : undefined,\n\t\t\tcode: (<ErrorWithCode>error).code\n\t\t};\n\t}\n\n\t// return as is\n\treturn error;\n}\n\nexport const canceledName = 'Canceled';\n\n/**\n * Checks if the given error is a promise in canceled state\n */\nexport function isCancellationError(error: any): boolean {\n\tif (error instanceof CancellationError) {\n\t\treturn true;\n\t}\n\treturn error instanceof Error && error.name === canceledName && error.message === canceledName;\n}\n\n// !!!IMPORTANT!!!\n// Do NOT change this class because it is also used as an API-type.\nexport class CancellationError extends Error {\n\tconstructor() {\n\t\tsuper(canceledName);\n\t\tthis.name = this.message;\n\t}\n}\n\n/**\n * @deprecated use {@link CancellationError `new CancellationError()`} instead\n */\nexport function canceled(): Error {\n\tconst error = new Error(canceledName);\n\terror.name = error.message;\n\treturn error;\n}\n\nexport function illegalArgument(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal argument: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal argument');\n\t}\n}\n\nexport function illegalState(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal state: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal state');\n\t}\n}\n\nexport class NotSupportedError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper('NotSupported');\n\t\tif (message) {\n\t\t\tthis.message = message;\n\t\t}\n\t}\n}\n\n/**\n * Error that when thrown won't be logged in telemetry as an unhandled error.\n */\nexport class ErrorNoTelemetry extends Error {\n\toverride readonly name: string;\n\n\tconstructor(msg?: string) {\n\t\tsuper(msg);\n\t\tthis.name = 'CodeExpectedError';\n\t}\n\n\tpublic static fromError(err: Error): ErrorNoTelemetry {\n\t\tif (err instanceof ErrorNoTelemetry) {\n\t\t\treturn err;\n\t\t}\n\n\t\tconst result = new ErrorNoTelemetry();\n\t\tresult.message = err.message;\n\t\tresult.stack = err.stack;\n\t\treturn result;\n\t}\n\n\tpublic static isErrorNoTelemetry(err: Error): err is ErrorNoTelemetry {\n\t\treturn err.name === 'CodeExpectedError';\n\t}\n}\n\n/**\n * This error indicates a bug.\n * Do not throw this for invalid user input.\n * Only catch this error to recover gracefully from bugs.\n */\nexport class BugIndicatingError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper(message || 'An unexpected bug occurred.');\n\t\tObject.setPrototypeOf(this, BugIndicatingError.prototype);\n\n\t\t// Because we know for sure only buggy code throws this,\n\t\t// we definitely want to break here and fix the bug.\n\t\t// debugger;\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nexport interface ErrorListenerCallback {\n\t(error: any): void;\n}\n\n// Avoid circular dependency on EventEmitter by implementing a subset of the interface.\nexport class ErrorHandler {\n\tprivate unexpectedErrorHandler: (e: any) => void;\n\tprivate listeners: ErrorListenerCallback[];\n\n\tconstructor() {\n\n\t\tthis.listeners = [];\n\n\t\tthis.unexpectedErrorHandler = function (e: any) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tif (e.stack) {\n\t\t\t\t\tif (ErrorNoTelemetry.isErrorNoTelemetry(e)) {\n\t\t\t\t\t\tthrow new ErrorNoTelemetry(e.message + '\\n\\n' + e.stack);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error(e.message + '\\n\\n' + e.stack);\n\t\t\t\t}\n\n\t\t\t\tthrow e;\n\t\t\t}, 0);\n\t\t};\n\t}\n\n\tprivate emit(e: any): void {\n\t\tthis.listeners.forEach((listener) => {\n\t\t\tlistener(e);\n\t\t});\n\t}\n\n\tonUnexpectedError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t\tthis.emit(e);\n\t}\n\n\t// For external errors, we don't want the listeners to be called\n\tonUnexpectedExternalError(e: any): void {\n\t\tthis.unexpectedErrorHandler(e);\n\t}\n}\n\nexport const errorHandler = new ErrorHandler();\n\n/**\n * This function should only be called with errors that indicate a bug in the product.\n * E.g. buggy extensions/invalid user-input/network issues should not be able to trigger this code path.\n * If they are, this indicates there is also a bug in the product.\n*/\nexport function onBugIndicatingError(e: any): undefined {\n\terrorHandler.onUnexpectedError(e);\n\treturn undefined;\n}\n\nexport function onUnexpectedError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedError(e);\n\t}\n\treturn undefined;\n}\n\nexport function onUnexpectedExternalError(e: any): undefined {\n\t// ignore errors from cancelled promises\n\tif (!isCancellationError(e)) {\n\t\terrorHandler.onUnexpectedExternalError(e);\n\t}\n\treturn undefined;\n}\n\nexport interface SerializedError {\n\treadonly $isError: true;\n\treadonly name: string;\n\treadonly message: string;\n\treadonly stack: string;\n}\n\ntype ErrorWithCode = Error & {\n\tcode: string | undefined;\n};\n\nexport function transformErrorForSerialization(error: Error): SerializedError;\nexport function transformErrorForSerialization(error: any): any;\nexport function transformErrorForSerialization(error: any): any {\n\tif (error instanceof Error) {\n\t\tconst { name, message, cause } = error;\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tconst stack: string = (<any>error).stacktrace || (<any>error).stack;\n\t\treturn {\n\t\t\t$isError: true,\n\t\t\tname,\n\t\t\tmessage,\n\t\t\tstack,\n\t\t\tnoTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),\n\t\t\tcause: cause ? transformErrorForSerialization(cause) : undefined,\n\t\t\tcode: (<ErrorWithCode>error).code\n\t\t};\n\t}\n\n\t// return as is\n\treturn error;\n}\n\nexport const canceledName = 'Canceled';\n\n/**\n * Checks if the given error is a promise in canceled state\n */\nexport function isCancellationError(error: any): boolean {\n\tif (error instanceof CancellationError) {\n\t\treturn true;\n\t}\n\treturn error instanceof Error && error.name === canceledName && error.message === canceledName;\n}\n\n// !!!IMPORTANT!!!\n// Do NOT change this class because it is also used as an API-type.\nexport class CancellationError extends Error {\n\tconstructor() {\n\t\tsuper(canceledName);\n\t\tthis.name = this.message;\n\t}\n}\n\n/**\n * @deprecated use {@link CancellationError `new CancellationError()`} instead\n */\nexport function canceled(): Error {\n\tconst error = new Error(canceledName);\n\terror.name = error.message;\n\treturn error;\n}\n\nexport function illegalArgument(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal argument: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal argument');\n\t}\n}\n\nexport function illegalState(name?: string): Error {\n\tif (name) {\n\t\treturn new Error(`Illegal state: ${name}`);\n\t} else {\n\t\treturn new Error('Illegal state');\n\t}\n}\n\nexport class NotSupportedError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper('NotSupported');\n\t\tif (message) {\n\t\t\tthis.message = message;\n\t\t}\n\t}\n}\n\n/**\n * Error that when thrown won't be logged in telemetry as an unhandled error.\n */\nexport class ErrorNoTelemetry extends Error {\n\toverride readonly name: string;\n\n\tconstructor(msg?: string) {\n\t\tsuper(msg);\n\t\tthis.name = 'CodeExpectedError';\n\t}\n\n\tpublic static fromError(err: Error): ErrorNoTelemetry {\n\t\tif (err instanceof ErrorNoTelemetry) {\n\t\t\treturn err;\n\t\t}\n\n\t\tconst result = new ErrorNoTelemetry();\n\t\tresult.message = err.message;\n\t\tresult.stack = err.stack;\n\t\treturn result;\n\t}\n\n\tpublic static isErrorNoTelemetry(err: Error): err is ErrorNoTelemetry {\n\t\treturn err.name === 'CodeExpectedError';\n\t}\n}\n\n/**\n * This error indicates a bug.\n * Do not throw this for invalid user input.\n * Only catch this error to recover gracefully from bugs.\n */\nexport class BugIndicatingError extends Error {\n\tconstructor(message?: string) {\n\t\tsuper(message || 'An unexpected bug occurred.');\n\t\tObject.setPrototypeOf(this, BugIndicatingError.prototype);\n\n\t\t// Because we know for sure only buggy code throws this,\n\t\t// we definitely want to break here and fix the bug.\n\t\t// debugger;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/hash.ts","vs/base/common/hash.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAI,GAA0C;IACjE,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAY,EAAE,OAAe;IACnD,QAAQ,OAAO,GAAG,EAAE,CAAC;QACpB,KAAK,QAAQ;YACZ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBAClB,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,KAAK,QAAQ;YACZ,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,KAAK,SAAS;YACb,OAAO,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,KAAK,QAAQ;YACZ,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,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IACxC,CAAC","file":"hash.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { encodeHex, VSBuffer } from './buffer.js';\nimport * as strings from './strings.js';\n\ntype NotSyncHashable = ArrayBufferLike | ArrayBufferView;\n\n/**\n * Return a hash value for an object.\n *\n * Note that this should not be used for binary data types. Instead,\n * prefer {@link hashAsync}.\n */\nexport function hash<T>(obj: T extends NotSyncHashable ? never : T): number {\n\treturn doHash(obj, 0);\n}\n\nexport function doHash(obj: unknown, hashVal: number): number {\n\tswitch (typeof obj) {\n\t\tcase 'object':\n\t\t\tif (obj === null) {\n\t\t\t\treturn numberHash(349, hashVal);\n\t\t\t} else if (Array.isArray(obj)) {\n\t\t\t\treturn arrayHash(obj, hashVal);\n\t\t\t}\n\t\t\treturn objectHash(obj, hashVal);\n\t\tcase 'string':\n\t\t\treturn stringHash(obj, hashVal);\n\t\tcase 'boolean':\n\t\t\treturn booleanHash(obj, hashVal);\n\t\tcase 'number':\n\t\t\treturn numberHash(obj, hashVal);\n\t\tcase 'undefined':\n\t\t\treturn numberHash(937, hashVal);\n\t\tdefault:\n\t\t\treturn numberHash(617, hashVal);\n\t}\n}\n\nexport function numberHash(val: number, initialHashVal: number): number {\n\treturn (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32\n}\n\nfunction booleanHash(b: boolean, initialHashVal: number): number {\n\treturn numberHash(b ? 433 : 863, initialHashVal);\n}\n\nexport function stringHash(s: string, hashVal: number) {\n\thashVal = numberHash(149417, hashVal);\n\tfor (let i = 0, length = s.length; i < length; i++) {\n\t\thashVal = numberHash(s.charCodeAt(i), hashVal);\n\t}\n\treturn hashVal;\n}\n\nfunction arrayHash(arr: any[], initialHashVal: number): number {\n\tinitialHashVal = numberHash(104579, initialHashVal);\n\treturn arr.reduce((hashVal, item) => doHash(item, hashVal), initialHashVal);\n}\n\nfunction objectHash(obj: any, initialHashVal: number): number {\n\tinitialHashVal = numberHash(181387, initialHashVal);\n\treturn Object.keys(obj).sort().reduce((hashVal, key) => {\n\t\thashVal = stringHash(key, hashVal);\n\t\treturn doHash(obj[key], hashVal);\n\t}, initialHashVal);\n}\n\n\n\n/** Hashes the input as SHA-1, returning a hex-encoded string. */\nexport const hashAsync = (input: string | ArrayBufferView | VSBuffer) => {\n\t// Note: I would very much like to expose a streaming interface for hashing\n\t// generally, but this is not available in web crypto yet, see\n\t// https://github.com/w3c/webcrypto/issues/73\n\n\t// StringSHA1 is faster for small string input, use it since we have it:\n\tif (typeof input === 'string' && input.length < 250) {\n\t\tconst sha = new StringSHA1();\n\t\tsha.update(input);\n\t\treturn Promise.resolve(sha.digest());\n\t}\n\n\tlet buff: ArrayBufferView;\n\tif (typeof input === 'string') {\n\t\tbuff = new TextEncoder().encode(input);\n\t} else if (input instanceof VSBuffer) {\n\t\tbuff = input.buffer;\n\t} else {\n\t\tbuff = input;\n\t}\n\n\treturn crypto.subtle.digest('sha-1', buff as ArrayBufferView<ArrayBuffer>).then(toHexString); // CodeQL [SM04514] we use sha1 here for validating old stored client state, not for security\n};\n\nconst enum SHA1Constant {\n\tBLOCK_SIZE = 64, // 512 / 8\n\tUNICODE_REPLACEMENT = 0xFFFD,\n}\n\nfunction leftRotate(value: number, bits: number, totalBits: number = 32): number {\n\t// delta + bits = totalBits\n\tconst delta = totalBits - bits;\n\n\t// All ones, expect `delta` zeros aligned to the right\n\tconst mask = ~((1 << delta) - 1);\n\n\t// Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)\n\treturn ((value << bits) | ((mask & value) >>> delta)) >>> 0;\n}\n\nfunction toHexString(buffer: ArrayBuffer): string;\nfunction toHexString(value: number, bitsize?: number): string;\nfunction toHexString(bufferOrValue: ArrayBuffer | number, bitsize: number = 32): string {\n\tif (bufferOrValue instanceof ArrayBuffer) {\n\t\treturn encodeHex(VSBuffer.wrap(new Uint8Array(bufferOrValue)));\n\t}\n\n\treturn (bufferOrValue >>> 0).toString(16).padStart(bitsize / 4, '0');\n}\n\n/**\n * A SHA1 implementation that works with strings and does not allocate.\n *\n * Prefer to use {@link hashAsync} in async contexts\n */\nexport class StringSHA1 {\n\tprivate static _bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320\n\n\tprivate _h0 = 0x67452301;\n\tprivate _h1 = 0xEFCDAB89;\n\tprivate _h2 = 0x98BADCFE;\n\tprivate _h3 = 0x10325476;\n\tprivate _h4 = 0xC3D2E1F0;\n\n\tprivate readonly _buff: Uint8Array;\n\tprivate readonly _buffDV: DataView;\n\tprivate _buffLen: number;\n\tprivate _totalLen: number;\n\tprivate _leftoverHighSurrogate: number;\n\tprivate _finished: boolean;\n\n\tconstructor() {\n\t\tthis._buff = new Uint8Array(SHA1Constant.BLOCK_SIZE + 3 /* to fit any utf-8 */);\n\t\tthis._buffDV = new DataView(this._buff.buffer);\n\t\tthis._buffLen = 0;\n\t\tthis._totalLen = 0;\n\t\tthis._leftoverHighSurrogate = 0;\n\t\tthis._finished = false;\n\t}\n\n\tpublic update(str: string): void {\n\t\tconst strLen = str.length;\n\t\tif (strLen === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buff = this._buff;\n\t\tlet buffLen = this._buffLen;\n\t\tlet leftoverHighSurrogate = this._leftoverHighSurrogate;\n\t\tlet charCode: number;\n\t\tlet offset: number;\n\n\t\tif (leftoverHighSurrogate !== 0) {\n\t\t\tcharCode = leftoverHighSurrogate;\n\t\t\toffset = -1;\n\t\t\tleftoverHighSurrogate = 0;\n\t\t} else {\n\t\t\tcharCode = str.charCodeAt(0);\n\t\t\toffset = 0;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tlet codePoint = charCode;\n\t\t\tif (strings.isHighSurrogate(charCode)) {\n\t\t\t\tif (offset + 1 < strLen) {\n\t\t\t\t\tconst nextCharCode = str.charCodeAt(offset + 1);\n\t\t\t\t\tif (strings.isLowSurrogate(nextCharCode)) {\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tcodePoint = strings.computeCodePoint(charCode, nextCharCode);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// illegal => unicode replacement character\n\t\t\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// last character is a surrogate pair\n\t\t\t\t\tleftoverHighSurrogate = charCode;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (strings.isLowSurrogate(charCode)) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t}\n\n\t\t\tbuffLen = this._push(buff, buffLen, codePoint);\n\t\t\toffset++;\n\t\t\tif (offset < strLen) {\n\t\t\t\tcharCode = str.charCodeAt(offset);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis._buffLen = buffLen;\n\t\tthis._leftoverHighSurrogate = leftoverHighSurrogate;\n\t}\n\n\tprivate _push(buff: Uint8Array, buffLen: number, codePoint: number): number {\n\t\tif (codePoint < 0x0080) {\n\t\t\tbuff[buffLen++] = codePoint;\n\t\t} else if (codePoint < 0x0800) {\n\t\t\tbuff[buffLen++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else if (codePoint < 0x10000) {\n\t\t\tbuff[buffLen++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else {\n\t\t\tbuff[buffLen++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t}\n\n\t\tif (buffLen >= SHA1Constant.BLOCK_SIZE) {\n\t\t\tthis._step();\n\t\t\tbuffLen -= SHA1Constant.BLOCK_SIZE;\n\t\t\tthis._totalLen += SHA1Constant.BLOCK_SIZE;\n\t\t\t// take last 3 in case of UTF8 overflow\n\t\t\tbuff[0] = buff[SHA1Constant.BLOCK_SIZE + 0];\n\t\t\tbuff[1] = buff[SHA1Constant.BLOCK_SIZE + 1];\n\t\t\tbuff[2] = buff[SHA1Constant.BLOCK_SIZE + 2];\n\t\t}\n\n\t\treturn buffLen;\n\t}\n\n\tpublic digest(): string {\n\t\tif (!this._finished) {\n\t\t\tthis._finished = true;\n\t\t\tif (this._leftoverHighSurrogate) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tthis._leftoverHighSurrogate = 0;\n\t\t\t\tthis._buffLen = this._push(this._buff, this._buffLen, SHA1Constant.UNICODE_REPLACEMENT);\n\t\t\t}\n\t\t\tthis._totalLen += this._buffLen;\n\t\t\tthis._wrapUp();\n\t\t}\n\n\t\treturn toHexString(this._h0) + toHexString(this._h1) + toHexString(this._h2) + toHexString(this._h3) + toHexString(this._h4);\n\t}\n\n\tprivate _wrapUp(): void {\n\t\tthis._buff[this._buffLen++] = 0x80;\n\t\tthis._buff.subarray(this._buffLen).fill(0);\n\n\t\tif (this._buffLen > 56) {\n\t\t\tthis._step();\n\t\t\tthis._buff.fill(0);\n\t\t}\n\n\t\t// this will fit because the mantissa can cover up to 52 bits\n\t\tconst ml = 8 * this._totalLen;\n\n\t\tthis._buffDV.setUint32(56, Math.floor(ml / 4294967296), false);\n\t\tthis._buffDV.setUint32(60, ml % 4294967296, false);\n\n\t\tthis._step();\n\t}\n\n\tprivate _step(): void {\n\t\tconst bigBlock32 = StringSHA1._bigBlock32;\n\t\tconst data = this._buffDV;\n\n\t\tfor (let j = 0; j < 64 /* 16*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, data.getUint32(j, false), false);\n\t\t}\n\n\t\tfor (let j = 64; j < 320 /* 80*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, leftRotate((bigBlock32.getUint32(j - 12, false) ^ bigBlock32.getUint32(j - 32, false) ^ bigBlock32.getUint32(j - 56, false) ^ bigBlock32.getUint32(j - 64, false)), 1), false);\n\t\t}\n\n\t\tlet a = this._h0;\n\t\tlet b = this._h1;\n\t\tlet c = this._h2;\n\t\tlet d = this._h3;\n\t\tlet e = this._h4;\n\n\t\tlet f: number, k: number;\n\t\tlet temp: number;\n\n\t\tfor (let j = 0; j < 80; j++) {\n\t\t\tif (j < 20) {\n\t\t\t\tf = (b & c) | ((~b) & d);\n\t\t\t\tk = 0x5A827999;\n\t\t\t} else if (j < 40) {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0x6ED9EBA1;\n\t\t\t} else if (j < 60) {\n\t\t\t\tf = (b & c) | (b & d) | (c & d);\n\t\t\t\tk = 0x8F1BBCDC;\n\t\t\t} else {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0xCA62C1D6;\n\t\t\t}\n\n\t\t\ttemp = (leftRotate(a, 5) + f + e + k + bigBlock32.getUint32(j * 4, false)) & 0xffffffff;\n\t\t\te = d;\n\t\t\td = c;\n\t\t\tc = leftRotate(b, 30);\n\t\t\tb = a;\n\t\t\ta = temp;\n\t\t}\n\n\t\tthis._h0 = (this._h0 + a) & 0xffffffff;\n\t\tthis._h1 = (this._h1 + b) & 0xffffffff;\n\t\tthis._h2 = (this._h2 + c) & 0xffffffff;\n\t\tthis._h3 = (this._h3 + d) & 0xffffffff;\n\t\tthis._h4 = (this._h4 + e) & 0xffffffff;\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { encodeHex, VSBuffer } from './buffer.js';\nimport * as strings from './strings.js';\n\ntype NotSyncHashable = ArrayBufferLike | ArrayBufferView;\n\n/**\n * Return a hash value for an object.\n *\n * Note that this should not be used for binary data types. Instead,\n * prefer {@link hashAsync}.\n */\nexport function hash<T>(obj: T extends NotSyncHashable ? never : T): number {\n\treturn doHash(obj, 0);\n}\n\nexport function doHash(obj: unknown, hashVal: number): number {\n\tswitch (typeof obj) {\n\t\tcase 'object':\n\t\t\tif (obj === null) {\n\t\t\t\treturn numberHash(349, hashVal);\n\t\t\t} else if (Array.isArray(obj)) {\n\t\t\t\treturn arrayHash(obj, hashVal);\n\t\t\t}\n\t\t\treturn objectHash(obj, hashVal);\n\t\tcase 'string':\n\t\t\treturn stringHash(obj, hashVal);\n\t\tcase 'boolean':\n\t\t\treturn booleanHash(obj, hashVal);\n\t\tcase 'number':\n\t\t\treturn numberHash(obj, hashVal);\n\t\tcase 'undefined':\n\t\t\treturn numberHash(937, hashVal);\n\t\tdefault:\n\t\t\treturn numberHash(617, hashVal);\n\t}\n}\n\nexport function numberHash(val: number, initialHashVal: number): number {\n\treturn (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32\n}\n\nfunction booleanHash(b: boolean, initialHashVal: number): number {\n\treturn numberHash(b ? 433 : 863, initialHashVal);\n}\n\nexport function stringHash(s: string, hashVal: number) {\n\thashVal = numberHash(149417, hashVal);\n\tfor (let i = 0, length = s.length; i < length; i++) {\n\t\thashVal = numberHash(s.charCodeAt(i), hashVal);\n\t}\n\treturn hashVal;\n}\n\nfunction arrayHash(arr: any[], initialHashVal: number): number {\n\tinitialHashVal = numberHash(104579, initialHashVal);\n\treturn arr.reduce((hashVal, item) => doHash(item, hashVal), initialHashVal);\n}\n\nfunction objectHash(obj: any, initialHashVal: number): number {\n\tinitialHashVal = numberHash(181387, initialHashVal);\n\treturn Object.keys(obj).sort().reduce((hashVal, key) => {\n\t\thashVal = stringHash(key, hashVal);\n\t\treturn doHash(obj[key], hashVal);\n\t}, initialHashVal);\n}\n\n\n\n/** Hashes the input as SHA-1, returning a hex-encoded string. */\nexport const hashAsync = (input: string | ArrayBufferView | VSBuffer) => {\n\t// Note: I would very much like to expose a streaming interface for hashing\n\t// generally, but this is not available in web crypto yet, see\n\t// https://github.com/w3c/webcrypto/issues/73\n\n\t// StringSHA1 is faster for small string input, use it since we have it:\n\tif (typeof input === 'string' && input.length < 250) {\n\t\tconst sha = new StringSHA1();\n\t\tsha.update(input);\n\t\treturn Promise.resolve(sha.digest());\n\t}\n\n\tlet buff: ArrayBufferView;\n\tif (typeof input === 'string') {\n\t\tbuff = new TextEncoder().encode(input);\n\t} else if (input instanceof VSBuffer) {\n\t\tbuff = input.buffer;\n\t} else {\n\t\tbuff = input;\n\t}\n\n\treturn crypto.subtle.digest('sha-1', buff as ArrayBufferView<ArrayBuffer>).then(toHexString); // CodeQL [SM04514] we use sha1 here for validating old stored client state, not for security\n};\n\nconst enum SHA1Constant {\n\tBLOCK_SIZE = 64, // 512 / 8\n\tUNICODE_REPLACEMENT = 0xFFFD,\n}\n\nfunction leftRotate(value: number, bits: number, totalBits: number = 32): number {\n\t// delta + bits = totalBits\n\tconst delta = totalBits - bits;\n\n\t// All ones, expect `delta` zeros aligned to the right\n\tconst mask = ~((1 << delta) - 1);\n\n\t// Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)\n\treturn ((value << bits) | ((mask & value) >>> delta)) >>> 0;\n}\n\nfunction toHexString(buffer: ArrayBuffer): string;\nfunction toHexString(value: number, bitsize?: number): string;\nfunction toHexString(bufferOrValue: ArrayBuffer | number, bitsize: number = 32): string {\n\tif (bufferOrValue instanceof ArrayBuffer) {\n\t\treturn encodeHex(VSBuffer.wrap(new Uint8Array(bufferOrValue)));\n\t}\n\n\treturn (bufferOrValue >>> 0).toString(16).padStart(bitsize / 4, '0');\n}\n\n/**\n * A SHA1 implementation that works with strings and does not allocate.\n *\n * Prefer to use {@link hashAsync} in async contexts\n */\nexport class StringSHA1 {\n\tprivate static _bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320\n\n\tprivate _h0 = 0x67452301;\n\tprivate _h1 = 0xEFCDAB89;\n\tprivate _h2 = 0x98BADCFE;\n\tprivate _h3 = 0x10325476;\n\tprivate _h4 = 0xC3D2E1F0;\n\n\tprivate readonly _buff: Uint8Array;\n\tprivate readonly _buffDV: DataView;\n\tprivate _buffLen: number;\n\tprivate _totalLen: number;\n\tprivate _leftoverHighSurrogate: number;\n\tprivate _finished: boolean;\n\n\tconstructor() {\n\t\tthis._buff = new Uint8Array(SHA1Constant.BLOCK_SIZE + 3 /* to fit any utf-8 */);\n\t\tthis._buffDV = new DataView(this._buff.buffer);\n\t\tthis._buffLen = 0;\n\t\tthis._totalLen = 0;\n\t\tthis._leftoverHighSurrogate = 0;\n\t\tthis._finished = false;\n\t}\n\n\tpublic update(str: string): void {\n\t\tconst strLen = str.length;\n\t\tif (strLen === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buff = this._buff;\n\t\tlet buffLen = this._buffLen;\n\t\tlet leftoverHighSurrogate = this._leftoverHighSurrogate;\n\t\tlet charCode: number;\n\t\tlet offset: number;\n\n\t\tif (leftoverHighSurrogate !== 0) {\n\t\t\tcharCode = leftoverHighSurrogate;\n\t\t\toffset = -1;\n\t\t\tleftoverHighSurrogate = 0;\n\t\t} else {\n\t\t\tcharCode = str.charCodeAt(0);\n\t\t\toffset = 0;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tlet codePoint = charCode;\n\t\t\tif (strings.isHighSurrogate(charCode)) {\n\t\t\t\tif (offset + 1 < strLen) {\n\t\t\t\t\tconst nextCharCode = str.charCodeAt(offset + 1);\n\t\t\t\t\tif (strings.isLowSurrogate(nextCharCode)) {\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tcodePoint = strings.computeCodePoint(charCode, nextCharCode);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// illegal => unicode replacement character\n\t\t\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// last character is a surrogate pair\n\t\t\t\t\tleftoverHighSurrogate = charCode;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (strings.isLowSurrogate(charCode)) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t}\n\n\t\t\tbuffLen = this._push(buff, buffLen, codePoint);\n\t\t\toffset++;\n\t\t\tif (offset < strLen) {\n\t\t\t\tcharCode = str.charCodeAt(offset);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis._buffLen = buffLen;\n\t\tthis._leftoverHighSurrogate = leftoverHighSurrogate;\n\t}\n\n\tprivate _push(buff: Uint8Array, buffLen: number, codePoint: number): number {\n\t\tif (codePoint < 0x0080) {\n\t\t\tbuff[buffLen++] = codePoint;\n\t\t} else if (codePoint < 0x0800) {\n\t\t\tbuff[buffLen++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else if (codePoint < 0x10000) {\n\t\t\tbuff[buffLen++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else {\n\t\t\tbuff[buffLen++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t}\n\n\t\tif (buffLen >= SHA1Constant.BLOCK_SIZE) {\n\t\t\tthis._step();\n\t\t\tbuffLen -= SHA1Constant.BLOCK_SIZE;\n\t\t\tthis._totalLen += SHA1Constant.BLOCK_SIZE;\n\t\t\t// take last 3 in case of UTF8 overflow\n\t\t\tbuff[0] = buff[SHA1Constant.BLOCK_SIZE + 0];\n\t\t\tbuff[1] = buff[SHA1Constant.BLOCK_SIZE + 1];\n\t\t\tbuff[2] = buff[SHA1Constant.BLOCK_SIZE + 2];\n\t\t}\n\n\t\treturn buffLen;\n\t}\n\n\tpublic digest(): string {\n\t\tif (!this._finished) {\n\t\t\tthis._finished = true;\n\t\t\tif (this._leftoverHighSurrogate) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tthis._leftoverHighSurrogate = 0;\n\t\t\t\tthis._buffLen = this._push(this._buff, this._buffLen, SHA1Constant.UNICODE_REPLACEMENT);\n\t\t\t}\n\t\t\tthis._totalLen += this._buffLen;\n\t\t\tthis._wrapUp();\n\t\t}\n\n\t\treturn toHexString(this._h0) + toHexString(this._h1) + toHexString(this._h2) + toHexString(this._h3) + toHexString(this._h4);\n\t}\n\n\tprivate _wrapUp(): void {\n\t\tthis._buff[this._buffLen++] = 0x80;\n\t\tthis._buff.subarray(this._buffLen).fill(0);\n\n\t\tif (this._buffLen > 56) {\n\t\t\tthis._step();\n\t\t\tthis._buff.fill(0);\n\t\t}\n\n\t\t// this will fit because the mantissa can cover up to 52 bits\n\t\tconst ml = 8 * this._totalLen;\n\n\t\tthis._buffDV.setUint32(56, Math.floor(ml / 4294967296), false);\n\t\tthis._buffDV.setUint32(60, ml % 4294967296, false);\n\n\t\tthis._step();\n\t}\n\n\tprivate _step(): void {\n\t\tconst bigBlock32 = StringSHA1._bigBlock32;\n\t\tconst data = this._buffDV;\n\n\t\tfor (let j = 0; j < 64 /* 16*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, data.getUint32(j, false), false);\n\t\t}\n\n\t\tfor (let j = 64; j < 320 /* 80*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, leftRotate((bigBlock32.getUint32(j - 12, false) ^ bigBlock32.getUint32(j - 32, false) ^ bigBlock32.getUint32(j - 56, false) ^ bigBlock32.getUint32(j - 64, false)), 1), false);\n\t\t}\n\n\t\tlet a = this._h0;\n\t\tlet b = this._h1;\n\t\tlet c = this._h2;\n\t\tlet d = this._h3;\n\t\tlet e = this._h4;\n\n\t\tlet f: number, k: number;\n\t\tlet temp: number;\n\n\t\tfor (let j = 0; j < 80; j++) {\n\t\t\tif (j < 20) {\n\t\t\t\tf = (b & c) | ((~b) & d);\n\t\t\t\tk = 0x5A827999;\n\t\t\t} else if (j < 40) {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0x6ED9EBA1;\n\t\t\t} else if (j < 60) {\n\t\t\t\tf = (b & c) | (b & d) | (c & d);\n\t\t\t\tk = 0x8F1BBCDC;\n\t\t\t} else {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0xCA62C1D6;\n\t\t\t}\n\n\t\t\ttemp = (leftRotate(a, 5) + f + e + k + bigBlock32.getUint32(j * 4, false)) & 0xffffffff;\n\t\t\te = d;\n\t\t\td = c;\n\t\t\tc = leftRotate(b, 30);\n\t\t\tb = a;\n\t\t\ta = temp;\n\t\t}\n\n\t\tthis._h0 = (this._h0 + a) & 0xffffffff;\n\t\tthis._h1 = (this._h1 + b) & 0xffffffff;\n\t\tthis._h2 = (this._h2 + c) & 0xffffffff;\n\t\tthis._h3 = (this._h3 + d) & 0xffffffff;\n\t\tthis._h4 = (this._h4 + e) & 0xffffffff;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/hash.ts","vs/base/common/hash.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC;;;;;GAKG;AACH,MAAM,UAAU,IAAI,CAAI,GAA0C;IACjE,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAY,EAAE,OAAe;IACnD,QAAQ,OAAO,GAAG,EAAE,CAAC;QACpB,KAAK,QAAQ;YACZ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;gBAClB,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACjC,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,OAAO,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,KAAK,QAAQ;YACZ,OAAO,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,KAAK,SAAS;YACb,OAAO,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,KAAK,QAA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AAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;IACxC,CAAC","file":"hash.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { encodeHex, VSBuffer } from './buffer.js';\nimport * as strings from './strings.js';\n\ntype NotSyncHashable = ArrayBufferLike | ArrayBufferView;\n\n/**\n * Return a hash value for an object.\n *\n * Note that this should not be used for binary data types. Instead,\n * prefer {@link hashAsync}.\n */\nexport function hash<T>(obj: T extends NotSyncHashable ? never : T): number {\n\treturn doHash(obj, 0);\n}\n\nexport function doHash(obj: unknown, hashVal: number): number {\n\tswitch (typeof obj) {\n\t\tcase 'object':\n\t\t\tif (obj === null) {\n\t\t\t\treturn numberHash(349, hashVal);\n\t\t\t} else if (Array.isArray(obj)) {\n\t\t\t\treturn arrayHash(obj, hashVal);\n\t\t\t}\n\t\t\treturn objectHash(obj, hashVal);\n\t\tcase 'string':\n\t\t\treturn stringHash(obj, hashVal);\n\t\tcase 'boolean':\n\t\t\treturn booleanHash(obj, hashVal);\n\t\tcase 'number':\n\t\t\treturn numberHash(obj, hashVal);\n\t\tcase 'undefined':\n\t\t\treturn numberHash(937, hashVal);\n\t\tdefault:\n\t\t\treturn numberHash(617, hashVal);\n\t}\n}\n\nexport function numberHash(val: number, initialHashVal: number): number {\n\treturn (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32\n}\n\nfunction booleanHash(b: boolean, initialHashVal: number): number {\n\treturn numberHash(b ? 433 : 863, initialHashVal);\n}\n\nexport function stringHash(s: string, hashVal: number) {\n\thashVal = numberHash(149417, hashVal);\n\tfor (let i = 0, length = s.length; i < length; i++) {\n\t\thashVal = numberHash(s.charCodeAt(i), hashVal);\n\t}\n\treturn hashVal;\n}\n\nfunction arrayHash(arr: unknown[], initialHashVal: number): number {\n\tinitialHashVal = numberHash(104579, initialHashVal);\n\treturn arr.reduce<number>((hashVal, item) => doHash(item, hashVal), initialHashVal);\n}\n\nfunction objectHash(obj: object, initialHashVal: number): number {\n\tinitialHashVal = numberHash(181387, initialHashVal);\n\treturn Object.keys(obj).sort().reduce((hashVal, key) => {\n\t\thashVal = stringHash(key, hashVal);\n\t\treturn doHash((obj as Record<string, unknown>)[key], hashVal);\n\t}, initialHashVal);\n}\n\n\n\n/** Hashes the input as SHA-1, returning a hex-encoded string. */\nexport const hashAsync = (input: string | ArrayBufferView | VSBuffer) => {\n\t// Note: I would very much like to expose a streaming interface for hashing\n\t// generally, but this is not available in web crypto yet, see\n\t// https://github.com/w3c/webcrypto/issues/73\n\n\t// StringSHA1 is faster for small string input, use it since we have it:\n\tif (typeof input === 'string' && input.length < 250) {\n\t\tconst sha = new StringSHA1();\n\t\tsha.update(input);\n\t\treturn Promise.resolve(sha.digest());\n\t}\n\n\tlet buff: ArrayBufferView;\n\tif (typeof input === 'string') {\n\t\tbuff = new TextEncoder().encode(input);\n\t} else if (input instanceof VSBuffer) {\n\t\tbuff = input.buffer;\n\t} else {\n\t\tbuff = input;\n\t}\n\n\treturn crypto.subtle.digest('sha-1', buff as ArrayBufferView<ArrayBuffer>).then(toHexString); // CodeQL [SM04514] we use sha1 here for validating old stored client state, not for security\n};\n\nconst enum SHA1Constant {\n\tBLOCK_SIZE = 64, // 512 / 8\n\tUNICODE_REPLACEMENT = 0xFFFD,\n}\n\nfunction leftRotate(value: number, bits: number, totalBits: number = 32): number {\n\t// delta + bits = totalBits\n\tconst delta = totalBits - bits;\n\n\t// All ones, expect `delta` zeros aligned to the right\n\tconst mask = ~((1 << delta) - 1);\n\n\t// Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)\n\treturn ((value << bits) | ((mask & value) >>> delta)) >>> 0;\n}\n\nfunction toHexString(buffer: ArrayBuffer): string;\nfunction toHexString(value: number, bitsize?: number): string;\nfunction toHexString(bufferOrValue: ArrayBuffer | number, bitsize: number = 32): string {\n\tif (bufferOrValue instanceof ArrayBuffer) {\n\t\treturn encodeHex(VSBuffer.wrap(new Uint8Array(bufferOrValue)));\n\t}\n\n\treturn (bufferOrValue >>> 0).toString(16).padStart(bitsize / 4, '0');\n}\n\n/**\n * A SHA1 implementation that works with strings and does not allocate.\n *\n * Prefer to use {@link hashAsync} in async contexts\n */\nexport class StringSHA1 {\n\tprivate static _bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320\n\n\tprivate _h0 = 0x67452301;\n\tprivate _h1 = 0xEFCDAB89;\n\tprivate _h2 = 0x98BADCFE;\n\tprivate _h3 = 0x10325476;\n\tprivate _h4 = 0xC3D2E1F0;\n\n\tprivate readonly _buff: Uint8Array;\n\tprivate readonly _buffDV: DataView;\n\tprivate _buffLen: number;\n\tprivate _totalLen: number;\n\tprivate _leftoverHighSurrogate: number;\n\tprivate _finished: boolean;\n\n\tconstructor() {\n\t\tthis._buff = new Uint8Array(SHA1Constant.BLOCK_SIZE + 3 /* to fit any utf-8 */);\n\t\tthis._buffDV = new DataView(this._buff.buffer);\n\t\tthis._buffLen = 0;\n\t\tthis._totalLen = 0;\n\t\tthis._leftoverHighSurrogate = 0;\n\t\tthis._finished = false;\n\t}\n\n\tpublic update(str: string): void {\n\t\tconst strLen = str.length;\n\t\tif (strLen === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buff = this._buff;\n\t\tlet buffLen = this._buffLen;\n\t\tlet leftoverHighSurrogate = this._leftoverHighSurrogate;\n\t\tlet charCode: number;\n\t\tlet offset: number;\n\n\t\tif (leftoverHighSurrogate !== 0) {\n\t\t\tcharCode = leftoverHighSurrogate;\n\t\t\toffset = -1;\n\t\t\tleftoverHighSurrogate = 0;\n\t\t} else {\n\t\t\tcharCode = str.charCodeAt(0);\n\t\t\toffset = 0;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tlet codePoint = charCode;\n\t\t\tif (strings.isHighSurrogate(charCode)) {\n\t\t\t\tif (offset + 1 < strLen) {\n\t\t\t\t\tconst nextCharCode = str.charCodeAt(offset + 1);\n\t\t\t\t\tif (strings.isLowSurrogate(nextCharCode)) {\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tcodePoint = strings.computeCodePoint(charCode, nextCharCode);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// illegal => unicode replacement character\n\t\t\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// last character is a surrogate pair\n\t\t\t\t\tleftoverHighSurrogate = charCode;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (strings.isLowSurrogate(charCode)) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t}\n\n\t\t\tbuffLen = this._push(buff, buffLen, codePoint);\n\t\t\toffset++;\n\t\t\tif (offset < strLen) {\n\t\t\t\tcharCode = str.charCodeAt(offset);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis._buffLen = buffLen;\n\t\tthis._leftoverHighSurrogate = leftoverHighSurrogate;\n\t}\n\n\tprivate _push(buff: Uint8Array, buffLen: number, codePoint: number): number {\n\t\tif (codePoint < 0x0080) {\n\t\t\tbuff[buffLen++] = codePoint;\n\t\t} else if (codePoint < 0x0800) {\n\t\t\tbuff[buffLen++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else if (codePoint < 0x10000) {\n\t\t\tbuff[buffLen++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else {\n\t\t\tbuff[buffLen++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t}\n\n\t\tif (buffLen >= SHA1Constant.BLOCK_SIZE) {\n\t\t\tthis._step();\n\t\t\tbuffLen -= SHA1Constant.BLOCK_SIZE;\n\t\t\tthis._totalLen += SHA1Constant.BLOCK_SIZE;\n\t\t\t// take last 3 in case of UTF8 overflow\n\t\t\tbuff[0] = buff[SHA1Constant.BLOCK_SIZE + 0];\n\t\t\tbuff[1] = buff[SHA1Constant.BLOCK_SIZE + 1];\n\t\t\tbuff[2] = buff[SHA1Constant.BLOCK_SIZE + 2];\n\t\t}\n\n\t\treturn buffLen;\n\t}\n\n\tpublic digest(): string {\n\t\tif (!this._finished) {\n\t\t\tthis._finished = true;\n\t\t\tif (this._leftoverHighSurrogate) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tthis._leftoverHighSurrogate = 0;\n\t\t\t\tthis._buffLen = this._push(this._buff, this._buffLen, SHA1Constant.UNICODE_REPLACEMENT);\n\t\t\t}\n\t\t\tthis._totalLen += this._buffLen;\n\t\t\tthis._wrapUp();\n\t\t}\n\n\t\treturn toHexString(this._h0) + toHexString(this._h1) + toHexString(this._h2) + toHexString(this._h3) + toHexString(this._h4);\n\t}\n\n\tprivate _wrapUp(): void {\n\t\tthis._buff[this._buffLen++] = 0x80;\n\t\tthis._buff.subarray(this._buffLen).fill(0);\n\n\t\tif (this._buffLen > 56) {\n\t\t\tthis._step();\n\t\t\tthis._buff.fill(0);\n\t\t}\n\n\t\t// this will fit because the mantissa can cover up to 52 bits\n\t\tconst ml = 8 * this._totalLen;\n\n\t\tthis._buffDV.setUint32(56, Math.floor(ml / 4294967296), false);\n\t\tthis._buffDV.setUint32(60, ml % 4294967296, false);\n\n\t\tthis._step();\n\t}\n\n\tprivate _step(): void {\n\t\tconst bigBlock32 = StringSHA1._bigBlock32;\n\t\tconst data = this._buffDV;\n\n\t\tfor (let j = 0; j < 64 /* 16*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, data.getUint32(j, false), false);\n\t\t}\n\n\t\tfor (let j = 64; j < 320 /* 80*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, leftRotate((bigBlock32.getUint32(j - 12, false) ^ bigBlock32.getUint32(j - 32, false) ^ bigBlock32.getUint32(j - 56, false) ^ bigBlock32.getUint32(j - 64, false)), 1), false);\n\t\t}\n\n\t\tlet a = this._h0;\n\t\tlet b = this._h1;\n\t\tlet c = this._h2;\n\t\tlet d = this._h3;\n\t\tlet e = this._h4;\n\n\t\tlet f: number, k: number;\n\t\tlet temp: number;\n\n\t\tfor (let j = 0; j < 80; j++) {\n\t\t\tif (j < 20) {\n\t\t\t\tf = (b & c) | ((~b) & d);\n\t\t\t\tk = 0x5A827999;\n\t\t\t} else if (j < 40) {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0x6ED9EBA1;\n\t\t\t} else if (j < 60) {\n\t\t\t\tf = (b & c) | (b & d) | (c & d);\n\t\t\t\tk = 0x8F1BBCDC;\n\t\t\t} else {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0xCA62C1D6;\n\t\t\t}\n\n\t\t\ttemp = (leftRotate(a, 5) + f + e + k + bigBlock32.getUint32(j * 4, false)) & 0xffffffff;\n\t\t\te = d;\n\t\t\td = c;\n\t\t\tc = leftRotate(b, 30);\n\t\t\tb = a;\n\t\t\ta = temp;\n\t\t}\n\n\t\tthis._h0 = (this._h0 + a) & 0xffffffff;\n\t\tthis._h1 = (this._h1 + b) & 0xffffffff;\n\t\tthis._h2 = (this._h2 + c) & 0xffffffff;\n\t\tthis._h3 = (this._h3 + d) & 0xffffffff;\n\t\tthis._h4 = (this._h4 + e) & 0xffffffff;\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { encodeHex, VSBuffer } from './buffer.js';\nimport * as strings from './strings.js';\n\ntype NotSyncHashable = ArrayBufferLike | ArrayBufferView;\n\n/**\n * Return a hash value for an object.\n *\n * Note that this should not be used for binary data types. Instead,\n * prefer {@link hashAsync}.\n */\nexport function hash<T>(obj: T extends NotSyncHashable ? never : T): number {\n\treturn doHash(obj, 0);\n}\n\nexport function doHash(obj: unknown, hashVal: number): number {\n\tswitch (typeof obj) {\n\t\tcase 'object':\n\t\t\tif (obj === null) {\n\t\t\t\treturn numberHash(349, hashVal);\n\t\t\t} else if (Array.isArray(obj)) {\n\t\t\t\treturn arrayHash(obj, hashVal);\n\t\t\t}\n\t\t\treturn objectHash(obj, hashVal);\n\t\tcase 'string':\n\t\t\treturn stringHash(obj, hashVal);\n\t\tcase 'boolean':\n\t\t\treturn booleanHash(obj, hashVal);\n\t\tcase 'number':\n\t\t\treturn numberHash(obj, hashVal);\n\t\tcase 'undefined':\n\t\t\treturn numberHash(937, hashVal);\n\t\tdefault:\n\t\t\treturn numberHash(617, hashVal);\n\t}\n}\n\nexport function numberHash(val: number, initialHashVal: number): number {\n\treturn (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32\n}\n\nfunction booleanHash(b: boolean, initialHashVal: number): number {\n\treturn numberHash(b ? 433 : 863, initialHashVal);\n}\n\nexport function stringHash(s: string, hashVal: number) {\n\thashVal = numberHash(149417, hashVal);\n\tfor (let i = 0, length = s.length; i < length; i++) {\n\t\thashVal = numberHash(s.charCodeAt(i), hashVal);\n\t}\n\treturn hashVal;\n}\n\nfunction arrayHash(arr: unknown[], initialHashVal: number): number {\n\tinitialHashVal = numberHash(104579, initialHashVal);\n\treturn arr.reduce<number>((hashVal, item) => doHash(item, hashVal), initialHashVal);\n}\n\nfunction objectHash(obj: object, initialHashVal: number): number {\n\tinitialHashVal = numberHash(181387, initialHashVal);\n\treturn Object.keys(obj).sort().reduce((hashVal, key) => {\n\t\thashVal = stringHash(key, hashVal);\n\t\treturn doHash((obj as Record<string, unknown>)[key], hashVal);\n\t}, initialHashVal);\n}\n\n\n\n/** Hashes the input as SHA-1, returning a hex-encoded string. */\nexport const hashAsync = (input: string | ArrayBufferView | VSBuffer) => {\n\t// Note: I would very much like to expose a streaming interface for hashing\n\t// generally, but this is not available in web crypto yet, see\n\t// https://github.com/w3c/webcrypto/issues/73\n\n\t// StringSHA1 is faster for small string input, use it since we have it:\n\tif (typeof input === 'string' && input.length < 250) {\n\t\tconst sha = new StringSHA1();\n\t\tsha.update(input);\n\t\treturn Promise.resolve(sha.digest());\n\t}\n\n\tlet buff: ArrayBufferView;\n\tif (typeof input === 'string') {\n\t\tbuff = new TextEncoder().encode(input);\n\t} else if (input instanceof VSBuffer) {\n\t\tbuff = input.buffer;\n\t} else {\n\t\tbuff = input;\n\t}\n\n\treturn crypto.subtle.digest('sha-1', buff as ArrayBufferView<ArrayBuffer>).then(toHexString); // CodeQL [SM04514] we use sha1 here for validating old stored client state, not for security\n};\n\nconst enum SHA1Constant {\n\tBLOCK_SIZE = 64, // 512 / 8\n\tUNICODE_REPLACEMENT = 0xFFFD,\n}\n\nfunction leftRotate(value: number, bits: number, totalBits: number = 32): number {\n\t// delta + bits = totalBits\n\tconst delta = totalBits - bits;\n\n\t// All ones, expect `delta` zeros aligned to the right\n\tconst mask = ~((1 << delta) - 1);\n\n\t// Join (value left-shifted `bits` bits) with (masked value right-shifted `delta` bits)\n\treturn ((value << bits) | ((mask & value) >>> delta)) >>> 0;\n}\n\nfunction toHexString(buffer: ArrayBuffer): string;\nfunction toHexString(value: number, bitsize?: number): string;\nfunction toHexString(bufferOrValue: ArrayBuffer | number, bitsize: number = 32): string {\n\tif (bufferOrValue instanceof ArrayBuffer) {\n\t\treturn encodeHex(VSBuffer.wrap(new Uint8Array(bufferOrValue)));\n\t}\n\n\treturn (bufferOrValue >>> 0).toString(16).padStart(bitsize / 4, '0');\n}\n\n/**\n * A SHA1 implementation that works with strings and does not allocate.\n *\n * Prefer to use {@link hashAsync} in async contexts\n */\nexport class StringSHA1 {\n\tprivate static _bigBlock32 = new DataView(new ArrayBuffer(320)); // 80 * 4 = 320\n\n\tprivate _h0 = 0x67452301;\n\tprivate _h1 = 0xEFCDAB89;\n\tprivate _h2 = 0x98BADCFE;\n\tprivate _h3 = 0x10325476;\n\tprivate _h4 = 0xC3D2E1F0;\n\n\tprivate readonly _buff: Uint8Array;\n\tprivate readonly _buffDV: DataView;\n\tprivate _buffLen: number;\n\tprivate _totalLen: number;\n\tprivate _leftoverHighSurrogate: number;\n\tprivate _finished: boolean;\n\n\tconstructor() {\n\t\tthis._buff = new Uint8Array(SHA1Constant.BLOCK_SIZE + 3 /* to fit any utf-8 */);\n\t\tthis._buffDV = new DataView(this._buff.buffer);\n\t\tthis._buffLen = 0;\n\t\tthis._totalLen = 0;\n\t\tthis._leftoverHighSurrogate = 0;\n\t\tthis._finished = false;\n\t}\n\n\tpublic update(str: string): void {\n\t\tconst strLen = str.length;\n\t\tif (strLen === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst buff = this._buff;\n\t\tlet buffLen = this._buffLen;\n\t\tlet leftoverHighSurrogate = this._leftoverHighSurrogate;\n\t\tlet charCode: number;\n\t\tlet offset: number;\n\n\t\tif (leftoverHighSurrogate !== 0) {\n\t\t\tcharCode = leftoverHighSurrogate;\n\t\t\toffset = -1;\n\t\t\tleftoverHighSurrogate = 0;\n\t\t} else {\n\t\t\tcharCode = str.charCodeAt(0);\n\t\t\toffset = 0;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tlet codePoint = charCode;\n\t\t\tif (strings.isHighSurrogate(charCode)) {\n\t\t\t\tif (offset + 1 < strLen) {\n\t\t\t\t\tconst nextCharCode = str.charCodeAt(offset + 1);\n\t\t\t\t\tif (strings.isLowSurrogate(nextCharCode)) {\n\t\t\t\t\t\toffset++;\n\t\t\t\t\t\tcodePoint = strings.computeCodePoint(charCode, nextCharCode);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// illegal => unicode replacement character\n\t\t\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// last character is a surrogate pair\n\t\t\t\t\tleftoverHighSurrogate = charCode;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else if (strings.isLowSurrogate(charCode)) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tcodePoint = SHA1Constant.UNICODE_REPLACEMENT;\n\t\t\t}\n\n\t\t\tbuffLen = this._push(buff, buffLen, codePoint);\n\t\t\toffset++;\n\t\t\tif (offset < strLen) {\n\t\t\t\tcharCode = str.charCodeAt(offset);\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tthis._buffLen = buffLen;\n\t\tthis._leftoverHighSurrogate = leftoverHighSurrogate;\n\t}\n\n\tprivate _push(buff: Uint8Array, buffLen: number, codePoint: number): number {\n\t\tif (codePoint < 0x0080) {\n\t\t\tbuff[buffLen++] = codePoint;\n\t\t} else if (codePoint < 0x0800) {\n\t\t\tbuff[buffLen++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else if (codePoint < 0x10000) {\n\t\t\tbuff[buffLen++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t} else {\n\t\t\tbuff[buffLen++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);\n\t\t\tbuff[buffLen++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);\n\t\t}\n\n\t\tif (buffLen >= SHA1Constant.BLOCK_SIZE) {\n\t\t\tthis._step();\n\t\t\tbuffLen -= SHA1Constant.BLOCK_SIZE;\n\t\t\tthis._totalLen += SHA1Constant.BLOCK_SIZE;\n\t\t\t// take last 3 in case of UTF8 overflow\n\t\t\tbuff[0] = buff[SHA1Constant.BLOCK_SIZE + 0];\n\t\t\tbuff[1] = buff[SHA1Constant.BLOCK_SIZE + 1];\n\t\t\tbuff[2] = buff[SHA1Constant.BLOCK_SIZE + 2];\n\t\t}\n\n\t\treturn buffLen;\n\t}\n\n\tpublic digest(): string {\n\t\tif (!this._finished) {\n\t\t\tthis._finished = true;\n\t\t\tif (this._leftoverHighSurrogate) {\n\t\t\t\t// illegal => unicode replacement character\n\t\t\t\tthis._leftoverHighSurrogate = 0;\n\t\t\t\tthis._buffLen = this._push(this._buff, this._buffLen, SHA1Constant.UNICODE_REPLACEMENT);\n\t\t\t}\n\t\t\tthis._totalLen += this._buffLen;\n\t\t\tthis._wrapUp();\n\t\t}\n\n\t\treturn toHexString(this._h0) + toHexString(this._h1) + toHexString(this._h2) + toHexString(this._h3) + toHexString(this._h4);\n\t}\n\n\tprivate _wrapUp(): void {\n\t\tthis._buff[this._buffLen++] = 0x80;\n\t\tthis._buff.subarray(this._buffLen).fill(0);\n\n\t\tif (this._buffLen > 56) {\n\t\t\tthis._step();\n\t\t\tthis._buff.fill(0);\n\t\t}\n\n\t\t// this will fit because the mantissa can cover up to 52 bits\n\t\tconst ml = 8 * this._totalLen;\n\n\t\tthis._buffDV.setUint32(56, Math.floor(ml / 4294967296), false);\n\t\tthis._buffDV.setUint32(60, ml % 4294967296, false);\n\n\t\tthis._step();\n\t}\n\n\tprivate _step(): void {\n\t\tconst bigBlock32 = StringSHA1._bigBlock32;\n\t\tconst data = this._buffDV;\n\n\t\tfor (let j = 0; j < 64 /* 16*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, data.getUint32(j, false), false);\n\t\t}\n\n\t\tfor (let j = 64; j < 320 /* 80*4 */; j += 4) {\n\t\t\tbigBlock32.setUint32(j, leftRotate((bigBlock32.getUint32(j - 12, false) ^ bigBlock32.getUint32(j - 32, false) ^ bigBlock32.getUint32(j - 56, false) ^ bigBlock32.getUint32(j - 64, false)), 1), false);\n\t\t}\n\n\t\tlet a = this._h0;\n\t\tlet b = this._h1;\n\t\tlet c = this._h2;\n\t\tlet d = this._h3;\n\t\tlet e = this._h4;\n\n\t\tlet f: number, k: number;\n\t\tlet temp: number;\n\n\t\tfor (let j = 0; j < 80; j++) {\n\t\t\tif (j < 20) {\n\t\t\t\tf = (b & c) | ((~b) & d);\n\t\t\t\tk = 0x5A827999;\n\t\t\t} else if (j < 40) {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0x6ED9EBA1;\n\t\t\t} else if (j < 60) {\n\t\t\t\tf = (b & c) | (b & d) | (c & d);\n\t\t\t\tk = 0x8F1BBCDC;\n\t\t\t} else {\n\t\t\t\tf = b ^ c ^ d;\n\t\t\t\tk = 0xCA62C1D6;\n\t\t\t}\n\n\t\t\ttemp = (leftRotate(a, 5) + f + e + k + bigBlock32.getUint32(j * 4, false)) & 0xffffffff;\n\t\t\te = d;\n\t\t\td = c;\n\t\t\tc = leftRotate(b, 30);\n\t\t\tb = a;\n\t\t\ta = temp;\n\t\t}\n\n\t\tthis._h0 = (this._h0 + a) & 0xffffffff;\n\t\tthis._h1 = (this._h1 + b) & 0xffffffff;\n\t\tthis._h2 = (this._h2 + c) & 0xffffffff;\n\t\tthis._h3 = (this._h3 + d) & 0xffffffff;\n\t\tthis._h4 = (this._h4 + e) & 0xffffffff;\n\t}\n}\n"]}
|
|
@@ -77,7 +77,7 @@ class WebWorkerProtocol {
|
|
|
77
77
|
setWorkerId(workerId) {
|
|
78
78
|
this._workerId = workerId;
|
|
79
79
|
}
|
|
80
|
-
sendMessage(channel, method, args) {
|
|
80
|
+
async sendMessage(channel, method, args) {
|
|
81
81
|
const req = String(++this._lastSentReq);
|
|
82
82
|
return new Promise((resolve, reject) => {
|
|
83
83
|
this._pendingReplies[req] = {
|
|
@@ -160,10 +160,11 @@ class WebWorkerProtocol {
|
|
|
160
160
|
if (replyMessage.err) {
|
|
161
161
|
let err = replyMessage.err;
|
|
162
162
|
if (replyMessage.err.$isError) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
const newErr = new Error();
|
|
164
|
+
newErr.name = replyMessage.err.name;
|
|
165
|
+
newErr.message = replyMessage.err.message;
|
|
166
|
+
newErr.stack = replyMessage.err.stack;
|
|
167
|
+
err = newErr;
|
|
167
168
|
}
|
|
168
169
|
reply.reject(err);
|
|
169
170
|
return;
|
|
@@ -209,8 +210,9 @@ class WebWorkerProtocol {
|
|
|
209
210
|
const transfer = [];
|
|
210
211
|
if (msg.type === 0 /* MessageType.Request */) {
|
|
211
212
|
for (let i = 0; i < msg.args.length; i++) {
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
const arg = msg.args[i];
|
|
214
|
+
if (arg instanceof ArrayBuffer) {
|
|
215
|
+
transfer.push(arg);
|
|
214
216
|
}
|
|
215
217
|
}
|
|
216
218
|
}
|
|
@@ -252,7 +254,7 @@ export class WebWorkerClient extends Disposable {
|
|
|
252
254
|
// Send initialize message
|
|
253
255
|
this._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [
|
|
254
256
|
this._worker.getId(),
|
|
255
|
-
]);
|
|
257
|
+
]).then(() => { });
|
|
256
258
|
this.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });
|
|
257
259
|
this._onModuleLoaded.catch((e) => {
|
|
258
260
|
this._onError('Worker failed to load ', e);
|
|
@@ -263,13 +265,12 @@ export class WebWorkerClient extends Disposable {
|
|
|
263
265
|
if (!channel) {
|
|
264
266
|
return Promise.reject(new Error(`Missing channel ${channelName} on main thread`));
|
|
265
267
|
}
|
|
266
|
-
|
|
267
|
-
if (typeof
|
|
268
|
+
const fn = channel[method];
|
|
269
|
+
if (typeof fn !== 'function') {
|
|
268
270
|
return Promise.reject(new Error(`Missing method ${method} on main thread channel ${channelName}`));
|
|
269
271
|
}
|
|
270
272
|
try {
|
|
271
|
-
|
|
272
|
-
return Promise.resolve(channel[method].apply(channel, args));
|
|
273
|
+
return Promise.resolve(fn.apply(channel, args));
|
|
273
274
|
}
|
|
274
275
|
catch (e) {
|
|
275
276
|
return Promise.reject(e);
|
|
@@ -281,15 +282,17 @@ export class WebWorkerClient extends Disposable {
|
|
|
281
282
|
throw new Error(`Missing channel ${channelName} on main thread`);
|
|
282
283
|
}
|
|
283
284
|
if (propertyIsDynamicEvent(eventName)) {
|
|
284
|
-
|
|
285
|
-
|
|
285
|
+
const fn = channel[eventName];
|
|
286
|
+
if (typeof fn !== 'function') {
|
|
287
|
+
throw new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);
|
|
288
|
+
}
|
|
289
|
+
const event = fn.call(channel, arg);
|
|
286
290
|
if (typeof event !== 'function') {
|
|
287
291
|
throw new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);
|
|
288
292
|
}
|
|
289
293
|
return event;
|
|
290
294
|
}
|
|
291
295
|
if (propertyIsEvent(eventName)) {
|
|
292
|
-
// eslint-disable-next-line local/code-no-any-casts
|
|
293
296
|
const event = channel[eventName];
|
|
294
297
|
if (typeof event !== 'function') {
|
|
295
298
|
throw new Error(`Missing event ${eventName} on main thread channel ${channelName}.`);
|
|
@@ -341,13 +344,12 @@ export class WebWorkerServer {
|
|
|
341
344
|
if (!requestHandler) {
|
|
342
345
|
return Promise.reject(new Error(`Missing channel ${channel} on worker thread`));
|
|
343
346
|
}
|
|
344
|
-
|
|
345
|
-
if (typeof
|
|
347
|
+
const fn = requestHandler[method];
|
|
348
|
+
if (typeof fn !== 'function') {
|
|
346
349
|
return Promise.reject(new Error(`Missing method ${method} on worker thread channel ${channel}`));
|
|
347
350
|
}
|
|
348
351
|
try {
|
|
349
|
-
|
|
350
|
-
return Promise.resolve(requestHandler[method].apply(requestHandler, args));
|
|
352
|
+
return Promise.resolve(fn.apply(requestHandler, args));
|
|
351
353
|
}
|
|
352
354
|
catch (e) {
|
|
353
355
|
return Promise.reject(e);
|
|
@@ -359,15 +361,17 @@ export class WebWorkerServer {
|
|
|
359
361
|
throw new Error(`Missing channel ${channel} on worker thread`);
|
|
360
362
|
}
|
|
361
363
|
if (propertyIsDynamicEvent(eventName)) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
+
const fn = requestHandler[eventName];
|
|
365
|
+
if (typeof fn !== 'function') {
|
|
366
|
+
throw new Error(`Missing dynamic event ${eventName} on request handler.`);
|
|
367
|
+
}
|
|
368
|
+
const event = fn.call(requestHandler, arg);
|
|
364
369
|
if (typeof event !== 'function') {
|
|
365
370
|
throw new Error(`Missing dynamic event ${eventName} on request handler.`);
|
|
366
371
|
}
|
|
367
372
|
return event;
|
|
368
373
|
}
|
|
369
374
|
if (propertyIsEvent(eventName)) {
|
|
370
|
-
// eslint-disable-next-line local/code-no-any-casts
|
|
371
375
|
const event = requestHandler[eventName];
|
|
372
376
|
if (typeof event !== 'function') {
|
|
373
377
|
throw new Error(`Missing event ${eventName} on request handler.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/worker/webWorker.ts","vs/base/common/worker/webWorker.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AAEzC,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,UAAU,GAAG,aAAa,CAAC;AASjC,IAAI,sBAAsB,GAAG,KAAK,CAAC;AACnC,MAAM,UAAU,uBAAuB,CAAC,GAAQ;IAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,gBAAgB;QAChB,OAAO;IACR,CAAC;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC7B,sBAAsB,GAAG,IAAI,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,iLAAiL,CAAC,CAAC;IACjM,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC;AASD,MAAM,cAAc;IAEnB,YACiB,QAAgB,EAChB,GAAW,EACX,OAAe,EACf,MAAc,EACd,IAAW;QAJX,aAAQ,GAAR,QAAQ,CAAQ;QAChB,QAAG,GAAH,GAAG,CAAQ;QACX,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAO;QANZ,SAAI,+BAAuB;IAOvC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CAAC,OAAO,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;YAChE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAe,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAAgB;QACxC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACD","file":"webWorker.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { CharCode } from '../charCode.js';\nimport { onUnexpectedError, transformErrorForSerialization } from '../errors.js';\nimport { Emitter, Event } from '../event.js';\nimport { Disposable, IDisposable } from '../lifecycle.js';\nimport { isWeb } from '../platform.js';\nimport * as strings from '../strings.js';\n\nconst DEFAULT_CHANNEL = 'default';\nconst INITIALIZE = '$initialize';\n\nexport interface IWebWorker extends IDisposable {\n\tgetId(): number;\n\tonMessage: Event<Message>;\n\tonError: Event<any>;\n\tpostMessage(message: Message, transfer: ArrayBuffer[]): void;\n}\n\nlet webWorkerWarningLogged = false;\nexport function logOnceWebWorkerWarning(err: any): void {\n\tif (!isWeb) {\n\t\t// running tests\n\t\treturn;\n\t}\n\tif (!webWorkerWarningLogged) {\n\t\twebWorkerWarningLogged = true;\n\t\tconsole.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq');\n\t}\n\tconsole.warn(err.message);\n}\n\nconst enum MessageType {\n\tRequest,\n\tReply,\n\tSubscribeEvent,\n\tEvent,\n\tUnsubscribeEvent\n}\nclass RequestMessage {\n\tpublic readonly type = MessageType.Request;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly method: string,\n\t\tpublic readonly args: any[]\n\t) { }\n}\nclass ReplyMessage {\n\tpublic readonly type = MessageType.Reply;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly seq: string,\n\t\tpublic readonly res: any,\n\t\tpublic readonly err: any\n\t) { }\n}\nclass SubscribeEventMessage {\n\tpublic readonly type = MessageType.SubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly eventName: string,\n\t\tpublic readonly arg: any\n\t) { }\n}\nclass EventMessage {\n\tpublic readonly type = MessageType.Event;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly event: any\n\t) { }\n}\nclass UnsubscribeEventMessage {\n\tpublic readonly type = MessageType.UnsubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string\n\t) { }\n}\nexport type Message = RequestMessage | ReplyMessage | SubscribeEventMessage | EventMessage | UnsubscribeEventMessage;\n\ninterface IMessageReply {\n\tresolve: (value?: any) => void;\n\treject: (error?: any) => void;\n}\n\ninterface IMessageHandler {\n\tsendMessage(msg: any, transfer?: ArrayBuffer[]): void;\n\thandleMessage(channel: string, method: string, args: any[]): Promise<any>;\n\thandleEvent(channel: string, eventName: string, arg: any): Event<any>;\n}\n\nclass WebWorkerProtocol {\n\n\tprivate _workerId: number;\n\tprivate _lastSentReq: number;\n\tprivate _pendingReplies: { [req: string]: IMessageReply };\n\tprivate _pendingEmitters: Map<string, Emitter<any>>;\n\tprivate _pendingEvents: Map<string, IDisposable>;\n\tprivate _handler: IMessageHandler;\n\n\tconstructor(handler: IMessageHandler) {\n\t\tthis._workerId = -1;\n\t\tthis._handler = handler;\n\t\tthis._lastSentReq = 0;\n\t\tthis._pendingReplies = Object.create(null);\n\t\tthis._pendingEmitters = new Map<string, Emitter<any>>();\n\t\tthis._pendingEvents = new Map<string, IDisposable>();\n\t}\n\n\tpublic setWorkerId(workerId: number): void {\n\t\tthis._workerId = workerId;\n\t}\n\n\tpublic sendMessage(channel: string, method: string, args: any[]): Promise<any> {\n\t\tconst req = String(++this._lastSentReq);\n\t\treturn new Promise<any>((resolve, reject) => {\n\t\t\tthis._pendingReplies[req] = {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject: reject\n\t\t\t};\n\t\t\tthis._send(new RequestMessage(this._workerId, req, channel, method, args));\n\t\t});\n\t}\n\n\tpublic listen(channel: string, eventName: string, arg: any): Event<any> {\n\t\tlet req: string | null = null;\n\t\tconst emitter = new Emitter<any>({\n\t\t\tonWillAddFirstListener: () => {\n\t\t\t\treq = String(++this._lastSentReq);\n\t\t\t\tthis._pendingEmitters.set(req, emitter);\n\t\t\t\tthis._send(new SubscribeEventMessage(this._workerId, req, channel, eventName, arg));\n\t\t\t},\n\t\t\tonDidRemoveLastListener: () => {\n\t\t\t\tthis._pendingEmitters.delete(req!);\n\t\t\t\tthis._send(new UnsubscribeEventMessage(this._workerId, req!));\n\t\t\t\treq = null;\n\t\t\t}\n\t\t});\n\t\treturn emitter.event;\n\t}\n\n\tpublic handleMessage(message: Message): void {\n\t\tif (!message || !message.vsWorker) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._workerId !== -1 && message.vsWorker !== this._workerId) {\n\t\t\treturn;\n\t\t}\n\t\tthis._handleMessage(message);\n\t}\n\n\tpublic createProxyToRemoteChannel<T extends object>(channel: string, sendMessageBarrier?: () => Promise<void>): T {\n\t\tconst handler = {\n\t\t\tget: (target: any, name: PropertyKey) => {\n\t\t\t\tif (typeof name === 'string' && !target[name]) {\n\t\t\t\t\tif (propertyIsDynamicEvent(name)) { // onDynamic...\n\t\t\t\t\t\ttarget[name] = (arg: any): Event<any> => {\n\t\t\t\t\t\t\treturn this.listen(channel, name, arg);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (propertyIsEvent(name)) { // on...\n\t\t\t\t\t\ttarget[name] = this.listen(channel, name, undefined);\n\t\t\t\t\t} else if (name.charCodeAt(0) === CharCode.DollarSign) { // $...\n\t\t\t\t\t\ttarget[name] = async (...myArgs: any[]) => {\n\t\t\t\t\t\t\tawait sendMessageBarrier?.();\n\t\t\t\t\t\t\treturn this.sendMessage(channel, name, myArgs);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[name];\n\t\t\t}\n\t\t};\n\t\treturn new Proxy(Object.create(null), handler);\n\t}\n\n\tprivate _handleMessage(msg: Message): void {\n\t\tswitch (msg.type) {\n\t\t\tcase MessageType.Reply:\n\t\t\t\treturn this._handleReplyMessage(msg);\n\t\t\tcase MessageType.Request:\n\t\t\t\treturn this._handleRequestMessage(msg);\n\t\t\tcase MessageType.SubscribeEvent:\n\t\t\t\treturn this._handleSubscribeEventMessage(msg);\n\t\t\tcase MessageType.Event:\n\t\t\t\treturn this._handleEventMessage(msg);\n\t\t\tcase MessageType.UnsubscribeEvent:\n\t\t\t\treturn this._handleUnsubscribeEventMessage(msg);\n\t\t}\n\t}\n\n\tprivate _handleReplyMessage(replyMessage: ReplyMessage): void {\n\t\tif (!this._pendingReplies[replyMessage.seq]) {\n\t\t\tconsole.warn('Got reply to unknown seq');\n\t\t\treturn;\n\t\t}\n\n\t\tconst reply = this._pendingReplies[replyMessage.seq];\n\t\tdelete this._pendingReplies[replyMessage.seq];\n\n\t\tif (replyMessage.err) {\n\t\t\tlet err = replyMessage.err;\n\t\t\tif (replyMessage.err.$isError) {\n\t\t\t\terr = new Error();\n\t\t\t\terr.name = replyMessage.err.name;\n\t\t\t\terr.message = replyMessage.err.message;\n\t\t\t\terr.stack = replyMessage.err.stack;\n\t\t\t}\n\t\t\treply.reject(err);\n\t\t\treturn;\n\t\t}\n\n\t\treply.resolve(replyMessage.res);\n\t}\n\n\tprivate _handleRequestMessage(requestMessage: RequestMessage): void {\n\t\tconst req = requestMessage.req;\n\t\tconst result = this._handler.handleMessage(requestMessage.channel, requestMessage.method, requestMessage.args);\n\t\tresult.then((r) => {\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, r, undefined));\n\t\t}, (e) => {\n\t\t\tif (e.detail instanceof Error) {\n\t\t\t\t// Loading errors have a detail property that points to the actual error\n\t\t\t\te.detail = transformErrorForSerialization(e.detail);\n\t\t\t}\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, undefined, transformErrorForSerialization(e)));\n\t\t});\n\t}\n\n\tprivate _handleSubscribeEventMessage(msg: SubscribeEventMessage): void {\n\t\tconst req = msg.req;\n\t\tconst disposable = this._handler.handleEvent(msg.channel, msg.eventName, msg.arg)((event) => {\n\t\t\tthis._send(new EventMessage(this._workerId, req, event));\n\t\t});\n\t\tthis._pendingEvents.set(req, disposable);\n\t}\n\n\tprivate _handleEventMessage(msg: EventMessage): void {\n\t\tif (!this._pendingEmitters.has(msg.req)) {\n\t\t\tconsole.warn('Got event for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEmitters.get(msg.req)!.fire(msg.event);\n\t}\n\n\tprivate _handleUnsubscribeEventMessage(msg: UnsubscribeEventMessage): void {\n\t\tif (!this._pendingEvents.has(msg.req)) {\n\t\t\tconsole.warn('Got unsubscribe for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEvents.get(msg.req)!.dispose();\n\t\tthis._pendingEvents.delete(msg.req);\n\t}\n\n\tprivate _send(msg: Message): void {\n\t\tconst transfer: ArrayBuffer[] = [];\n\t\tif (msg.type === MessageType.Request) {\n\t\t\tfor (let i = 0; i < msg.args.length; i++) {\n\t\t\t\tif (msg.args[i] instanceof ArrayBuffer) {\n\t\t\t\t\ttransfer.push(msg.args[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (msg.type === MessageType.Reply) {\n\t\t\tif (msg.res instanceof ArrayBuffer) {\n\t\t\t\ttransfer.push(msg.res);\n\t\t\t}\n\t\t}\n\t\tthis._handler.sendMessage(msg, transfer);\n\t}\n}\n\ntype ProxiedMethodName = (`$${string}` | `on${string}`);\n\nexport type Proxied<T> = { [K in keyof T]: T[K] extends (...args: infer A) => infer R\n\t? (\n\t\tK extends ProxiedMethodName\n\t\t? (...args: A) => Promise<Awaited<R>>\n\t\t: never\n\t)\n\t: never\n};\n\nexport interface IWebWorkerClient<TProxy> {\n\tproxy: Proxied<TProxy>;\n\tdispose(): void;\n\tsetChannel<T extends object>(channel: string, handler: T): void;\n}\n\nexport interface IWebWorkerServer {\n\tgetChannel<T extends object>(channel: string): Proxied<T>;\n}\n\n/**\n * Main thread side\n */\nexport class WebWorkerClient<W extends object> extends Disposable implements IWebWorkerClient<W> {\n\n\tprivate readonly _worker: IWebWorker;\n\tprivate readonly _onModuleLoaded: Promise<void>;\n\tprivate readonly _protocol: WebWorkerProtocol;\n\tpublic readonly proxy: Proxied<W>;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\n\tconstructor(\n\t\tworker: IWebWorker\n\t) {\n\t\tsuper();\n\n\t\tthis._worker = this._register(worker);\n\t\tthis._register(this._worker.onMessage((msg) => {\n\t\t\tthis._protocol.handleMessage(msg);\n\t\t}));\n\t\tthis._register(this._worker.onError((err) => {\n\t\t\tlogOnceWebWorkerWarning(err);\n\t\t\tonUnexpectedError(err);\n\t\t}));\n\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: any, transfer: ArrayBuffer[]): void => {\n\t\t\t\tthis._worker.postMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: any[]): Promise<any> => {\n\t\t\t\treturn this._handleMessage(channel, method, args);\n\t\t\t},\n\t\t\thandleEvent: (channel: string, eventName: string, arg: any): Event<any> => {\n\t\t\t\treturn this._handleEvent(channel, eventName, arg);\n\t\t\t}\n\t\t});\n\t\tthis._protocol.setWorkerId(this._worker.getId());\n\n\t\t// Send initialize message\n\t\tthis._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [\n\t\t\tthis._worker.getId(),\n\t\t]);\n\n\t\tthis.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });\n\t\tthis._onModuleLoaded.catch((e) => {\n\t\t\tthis._onError('Worker failed to load ', e);\n\t\t});\n\t}\n\n\tprivate _handleMessage(channelName: string, method: string, args: any[]): Promise<any> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channelName} on main thread`));\n\t\t}\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tif (typeof (channel as any)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on main thread channel ${channelName}`));\n\t\t}\n\n\t\ttry {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\treturn Promise.resolve((channel as any)[method].apply(channel, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channelName: string, eventName: string, arg: any): Event<any> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\tthrow new Error(`Missing channel ${channelName} on main thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (channel as any)[eventName].call(channel, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (channel as any)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic setChannel<T extends object>(channel: string, handler: T): void {\n\t\tthis._localChannels.set(channel, handler);\n\t}\n\n\tprivate _onError(message: string, error?: any): void {\n\t\tconsole.error(message);\n\t\tconsole.info(error);\n\t}\n}\n\nfunction propertyIsEvent(name: string): boolean {\n\t// Assume a property is an event if it has a form of \"onSomething\"\n\treturn name[0] === 'o' && name[1] === 'n' && strings.isUpperAsciiLetter(name.charCodeAt(2));\n}\n\nfunction propertyIsDynamicEvent(name: string): boolean {\n\t// Assume a property is a dynamic event (a method that returns an event) if it has a form of \"onDynamicSomething\"\n\treturn /^onDynamic/.test(name) && strings.isUpperAsciiLetter(name.charCodeAt(9));\n}\n\nexport interface IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: any;\n\t[prop: string]: any;\n}\n\nexport interface IWebWorkerServerRequestHandlerFactory<T extends IWebWorkerServerRequestHandler> {\n\t(workerServer: IWebWorkerServer): T;\n}\n\n/**\n * Worker side\n */\nexport class WebWorkerServer<T extends IWebWorkerServerRequestHandler> implements IWebWorkerServer {\n\n\tpublic readonly requestHandler: T;\n\tprivate _protocol: WebWorkerProtocol;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\tprivate readonly _remoteChannels: Map<string, object> = new Map();\n\n\tconstructor(postMessage: (msg: Message, transfer?: ArrayBuffer[]) => void, requestHandlerFactory: IWebWorkerServerRequestHandlerFactory<T>) {\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: any, transfer: ArrayBuffer[]): void => {\n\t\t\t\tpostMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: any[]): Promise<any> => this._handleMessage(channel, method, args),\n\t\t\thandleEvent: (channel: string, eventName: string, arg: any): Event<any> => this._handleEvent(channel, eventName, arg)\n\t\t});\n\t\tthis.requestHandler = requestHandlerFactory(this);\n\t}\n\n\tpublic onmessage(msg: any): void {\n\t\tthis._protocol.handleMessage(msg);\n\t}\n\n\tprivate _handleMessage(channel: string, method: string, args: any[]): Promise<any> {\n\t\tif (channel === DEFAULT_CHANNEL && method === INITIALIZE) {\n\t\t\treturn this.initialize(<number>args[0]);\n\t\t}\n\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channel} on worker thread`));\n\t\t}\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tif (typeof (requestHandler as any)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on worker thread channel ${channel}`));\n\t\t}\n\n\t\ttry {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\treturn Promise.resolve((requestHandler as any)[method].apply(requestHandler, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channel: string, eventName: string, arg: any): Event<any> {\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\tthrow new Error(`Missing channel ${channel} on worker thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (requestHandler as any)[eventName].call(requestHandler, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (requestHandler as any)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic getChannel<T extends object>(channel: string): Proxied<T> {\n\t\tif (!this._remoteChannels.has(channel)) {\n\t\t\tconst inst = this._protocol.createProxyToRemoteChannel(channel);\n\t\t\tthis._remoteChannels.set(channel, inst);\n\t\t}\n\t\treturn this._remoteChannels.get(channel) as Proxied<T>;\n\t}\n\n\tprivate async initialize(workerId: number): Promise<void> {\n\t\tthis._protocol.setWorkerId(workerId);\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { CharCode } from '../charCode.js';\nimport { onUnexpectedError, transformErrorForSerialization } from '../errors.js';\nimport { Emitter, Event } from '../event.js';\nimport { Disposable, IDisposable } from '../lifecycle.js';\nimport { isWeb } from '../platform.js';\nimport * as strings from '../strings.js';\n\nconst DEFAULT_CHANNEL = 'default';\nconst INITIALIZE = '$initialize';\n\nexport interface IWebWorker extends IDisposable {\n\tgetId(): number;\n\tonMessage: Event<Message>;\n\tonError: Event<any>;\n\tpostMessage(message: Message, transfer: ArrayBuffer[]): void;\n}\n\nlet webWorkerWarningLogged = false;\nexport function logOnceWebWorkerWarning(err: any): void {\n\tif (!isWeb) {\n\t\t// running tests\n\t\treturn;\n\t}\n\tif (!webWorkerWarningLogged) {\n\t\twebWorkerWarningLogged = true;\n\t\tconsole.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq');\n\t}\n\tconsole.warn(err.message);\n}\n\nconst enum MessageType {\n\tRequest,\n\tReply,\n\tSubscribeEvent,\n\tEvent,\n\tUnsubscribeEvent\n}\nclass RequestMessage {\n\tpublic readonly type = MessageType.Request;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly method: string,\n\t\tpublic readonly args: any[]\n\t) { }\n}\nclass ReplyMessage {\n\tpublic readonly type = MessageType.Reply;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly seq: string,\n\t\tpublic readonly res: any,\n\t\tpublic readonly err: any\n\t) { }\n}\nclass SubscribeEventMessage {\n\tpublic readonly type = MessageType.SubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly eventName: string,\n\t\tpublic readonly arg: any\n\t) { }\n}\nclass EventMessage {\n\tpublic readonly type = MessageType.Event;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly event: any\n\t) { }\n}\nclass UnsubscribeEventMessage {\n\tpublic readonly type = MessageType.UnsubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string\n\t) { }\n}\nexport type Message = RequestMessage | ReplyMessage | SubscribeEventMessage | EventMessage | UnsubscribeEventMessage;\n\ninterface IMessageReply {\n\tresolve: (value?: any) => void;\n\treject: (error?: any) => void;\n}\n\ninterface IMessageHandler {\n\tsendMessage(msg: any, transfer?: ArrayBuffer[]): void;\n\thandleMessage(channel: string, method: string, args: any[]): Promise<any>;\n\thandleEvent(channel: string, eventName: string, arg: any): Event<any>;\n}\n\nclass WebWorkerProtocol {\n\n\tprivate _workerId: number;\n\tprivate _lastSentReq: number;\n\tprivate _pendingReplies: { [req: string]: IMessageReply };\n\tprivate _pendingEmitters: Map<string, Emitter<any>>;\n\tprivate _pendingEvents: Map<string, IDisposable>;\n\tprivate _handler: IMessageHandler;\n\n\tconstructor(handler: IMessageHandler) {\n\t\tthis._workerId = -1;\n\t\tthis._handler = handler;\n\t\tthis._lastSentReq = 0;\n\t\tthis._pendingReplies = Object.create(null);\n\t\tthis._pendingEmitters = new Map<string, Emitter<any>>();\n\t\tthis._pendingEvents = new Map<string, IDisposable>();\n\t}\n\n\tpublic setWorkerId(workerId: number): void {\n\t\tthis._workerId = workerId;\n\t}\n\n\tpublic sendMessage(channel: string, method: string, args: any[]): Promise<any> {\n\t\tconst req = String(++this._lastSentReq);\n\t\treturn new Promise<any>((resolve, reject) => {\n\t\t\tthis._pendingReplies[req] = {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject: reject\n\t\t\t};\n\t\t\tthis._send(new RequestMessage(this._workerId, req, channel, method, args));\n\t\t});\n\t}\n\n\tpublic listen(channel: string, eventName: string, arg: any): Event<any> {\n\t\tlet req: string | null = null;\n\t\tconst emitter = new Emitter<any>({\n\t\t\tonWillAddFirstListener: () => {\n\t\t\t\treq = String(++this._lastSentReq);\n\t\t\t\tthis._pendingEmitters.set(req, emitter);\n\t\t\t\tthis._send(new SubscribeEventMessage(this._workerId, req, channel, eventName, arg));\n\t\t\t},\n\t\t\tonDidRemoveLastListener: () => {\n\t\t\t\tthis._pendingEmitters.delete(req!);\n\t\t\t\tthis._send(new UnsubscribeEventMessage(this._workerId, req!));\n\t\t\t\treq = null;\n\t\t\t}\n\t\t});\n\t\treturn emitter.event;\n\t}\n\n\tpublic handleMessage(message: Message): void {\n\t\tif (!message || !message.vsWorker) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._workerId !== -1 && message.vsWorker !== this._workerId) {\n\t\t\treturn;\n\t\t}\n\t\tthis._handleMessage(message);\n\t}\n\n\tpublic createProxyToRemoteChannel<T extends object>(channel: string, sendMessageBarrier?: () => Promise<void>): T {\n\t\tconst handler = {\n\t\t\tget: (target: any, name: PropertyKey) => {\n\t\t\t\tif (typeof name === 'string' && !target[name]) {\n\t\t\t\t\tif (propertyIsDynamicEvent(name)) { // onDynamic...\n\t\t\t\t\t\ttarget[name] = (arg: any): Event<any> => {\n\t\t\t\t\t\t\treturn this.listen(channel, name, arg);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (propertyIsEvent(name)) { // on...\n\t\t\t\t\t\ttarget[name] = this.listen(channel, name, undefined);\n\t\t\t\t\t} else if (name.charCodeAt(0) === CharCode.DollarSign) { // $...\n\t\t\t\t\t\ttarget[name] = async (...myArgs: any[]) => {\n\t\t\t\t\t\t\tawait sendMessageBarrier?.();\n\t\t\t\t\t\t\treturn this.sendMessage(channel, name, myArgs);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[name];\n\t\t\t}\n\t\t};\n\t\treturn new Proxy(Object.create(null), handler);\n\t}\n\n\tprivate _handleMessage(msg: Message): void {\n\t\tswitch (msg.type) {\n\t\t\tcase MessageType.Reply:\n\t\t\t\treturn this._handleReplyMessage(msg);\n\t\t\tcase MessageType.Request:\n\t\t\t\treturn this._handleRequestMessage(msg);\n\t\t\tcase MessageType.SubscribeEvent:\n\t\t\t\treturn this._handleSubscribeEventMessage(msg);\n\t\t\tcase MessageType.Event:\n\t\t\t\treturn this._handleEventMessage(msg);\n\t\t\tcase MessageType.UnsubscribeEvent:\n\t\t\t\treturn this._handleUnsubscribeEventMessage(msg);\n\t\t}\n\t}\n\n\tprivate _handleReplyMessage(replyMessage: ReplyMessage): void {\n\t\tif (!this._pendingReplies[replyMessage.seq]) {\n\t\t\tconsole.warn('Got reply to unknown seq');\n\t\t\treturn;\n\t\t}\n\n\t\tconst reply = this._pendingReplies[replyMessage.seq];\n\t\tdelete this._pendingReplies[replyMessage.seq];\n\n\t\tif (replyMessage.err) {\n\t\t\tlet err = replyMessage.err;\n\t\t\tif (replyMessage.err.$isError) {\n\t\t\t\terr = new Error();\n\t\t\t\terr.name = replyMessage.err.name;\n\t\t\t\terr.message = replyMessage.err.message;\n\t\t\t\terr.stack = replyMessage.err.stack;\n\t\t\t}\n\t\t\treply.reject(err);\n\t\t\treturn;\n\t\t}\n\n\t\treply.resolve(replyMessage.res);\n\t}\n\n\tprivate _handleRequestMessage(requestMessage: RequestMessage): void {\n\t\tconst req = requestMessage.req;\n\t\tconst result = this._handler.handleMessage(requestMessage.channel, requestMessage.method, requestMessage.args);\n\t\tresult.then((r) => {\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, r, undefined));\n\t\t}, (e) => {\n\t\t\tif (e.detail instanceof Error) {\n\t\t\t\t// Loading errors have a detail property that points to the actual error\n\t\t\t\te.detail = transformErrorForSerialization(e.detail);\n\t\t\t}\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, undefined, transformErrorForSerialization(e)));\n\t\t});\n\t}\n\n\tprivate _handleSubscribeEventMessage(msg: SubscribeEventMessage): void {\n\t\tconst req = msg.req;\n\t\tconst disposable = this._handler.handleEvent(msg.channel, msg.eventName, msg.arg)((event) => {\n\t\t\tthis._send(new EventMessage(this._workerId, req, event));\n\t\t});\n\t\tthis._pendingEvents.set(req, disposable);\n\t}\n\n\tprivate _handleEventMessage(msg: EventMessage): void {\n\t\tif (!this._pendingEmitters.has(msg.req)) {\n\t\t\tconsole.warn('Got event for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEmitters.get(msg.req)!.fire(msg.event);\n\t}\n\n\tprivate _handleUnsubscribeEventMessage(msg: UnsubscribeEventMessage): void {\n\t\tif (!this._pendingEvents.has(msg.req)) {\n\t\t\tconsole.warn('Got unsubscribe for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEvents.get(msg.req)!.dispose();\n\t\tthis._pendingEvents.delete(msg.req);\n\t}\n\n\tprivate _send(msg: Message): void {\n\t\tconst transfer: ArrayBuffer[] = [];\n\t\tif (msg.type === MessageType.Request) {\n\t\t\tfor (let i = 0; i < msg.args.length; i++) {\n\t\t\t\tif (msg.args[i] instanceof ArrayBuffer) {\n\t\t\t\t\ttransfer.push(msg.args[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (msg.type === MessageType.Reply) {\n\t\t\tif (msg.res instanceof ArrayBuffer) {\n\t\t\t\ttransfer.push(msg.res);\n\t\t\t}\n\t\t}\n\t\tthis._handler.sendMessage(msg, transfer);\n\t}\n}\n\ntype ProxiedMethodName = (`$${string}` | `on${string}`);\n\nexport type Proxied<T> = { [K in keyof T]: T[K] extends (...args: infer A) => infer R\n\t? (\n\t\tK extends ProxiedMethodName\n\t\t? (...args: A) => Promise<Awaited<R>>\n\t\t: never\n\t)\n\t: never\n};\n\nexport interface IWebWorkerClient<TProxy> {\n\tproxy: Proxied<TProxy>;\n\tdispose(): void;\n\tsetChannel<T extends object>(channel: string, handler: T): void;\n}\n\nexport interface IWebWorkerServer {\n\tgetChannel<T extends object>(channel: string): Proxied<T>;\n}\n\n/**\n * Main thread side\n */\nexport class WebWorkerClient<W extends object> extends Disposable implements IWebWorkerClient<W> {\n\n\tprivate readonly _worker: IWebWorker;\n\tprivate readonly _onModuleLoaded: Promise<void>;\n\tprivate readonly _protocol: WebWorkerProtocol;\n\tpublic readonly proxy: Proxied<W>;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\n\tconstructor(\n\t\tworker: IWebWorker\n\t) {\n\t\tsuper();\n\n\t\tthis._worker = this._register(worker);\n\t\tthis._register(this._worker.onMessage((msg) => {\n\t\t\tthis._protocol.handleMessage(msg);\n\t\t}));\n\t\tthis._register(this._worker.onError((err) => {\n\t\t\tlogOnceWebWorkerWarning(err);\n\t\t\tonUnexpectedError(err);\n\t\t}));\n\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: any, transfer: ArrayBuffer[]): void => {\n\t\t\t\tthis._worker.postMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: any[]): Promise<any> => {\n\t\t\t\treturn this._handleMessage(channel, method, args);\n\t\t\t},\n\t\t\thandleEvent: (channel: string, eventName: string, arg: any): Event<any> => {\n\t\t\t\treturn this._handleEvent(channel, eventName, arg);\n\t\t\t}\n\t\t});\n\t\tthis._protocol.setWorkerId(this._worker.getId());\n\n\t\t// Send initialize message\n\t\tthis._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [\n\t\t\tthis._worker.getId(),\n\t\t]);\n\n\t\tthis.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });\n\t\tthis._onModuleLoaded.catch((e) => {\n\t\t\tthis._onError('Worker failed to load ', e);\n\t\t});\n\t}\n\n\tprivate _handleMessage(channelName: string, method: string, args: any[]): Promise<any> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channelName} on main thread`));\n\t\t}\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tif (typeof (channel as any)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on main thread channel ${channelName}`));\n\t\t}\n\n\t\ttry {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\treturn Promise.resolve((channel as any)[method].apply(channel, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channelName: string, eventName: string, arg: any): Event<any> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\tthrow new Error(`Missing channel ${channelName} on main thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (channel as any)[eventName].call(channel, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (channel as any)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic setChannel<T extends object>(channel: string, handler: T): void {\n\t\tthis._localChannels.set(channel, handler);\n\t}\n\n\tprivate _onError(message: string, error?: any): void {\n\t\tconsole.error(message);\n\t\tconsole.info(error);\n\t}\n}\n\nfunction propertyIsEvent(name: string): boolean {\n\t// Assume a property is an event if it has a form of \"onSomething\"\n\treturn name[0] === 'o' && name[1] === 'n' && strings.isUpperAsciiLetter(name.charCodeAt(2));\n}\n\nfunction propertyIsDynamicEvent(name: string): boolean {\n\t// Assume a property is a dynamic event (a method that returns an event) if it has a form of \"onDynamicSomething\"\n\treturn /^onDynamic/.test(name) && strings.isUpperAsciiLetter(name.charCodeAt(9));\n}\n\nexport interface IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: any;\n\t[prop: string]: any;\n}\n\nexport interface IWebWorkerServerRequestHandlerFactory<T extends IWebWorkerServerRequestHandler> {\n\t(workerServer: IWebWorkerServer): T;\n}\n\n/**\n * Worker side\n */\nexport class WebWorkerServer<T extends IWebWorkerServerRequestHandler> implements IWebWorkerServer {\n\n\tpublic readonly requestHandler: T;\n\tprivate _protocol: WebWorkerProtocol;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\tprivate readonly _remoteChannels: Map<string, object> = new Map();\n\n\tconstructor(postMessage: (msg: Message, transfer?: ArrayBuffer[]) => void, requestHandlerFactory: IWebWorkerServerRequestHandlerFactory<T>) {\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: any, transfer: ArrayBuffer[]): void => {\n\t\t\t\tpostMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: any[]): Promise<any> => this._handleMessage(channel, method, args),\n\t\t\thandleEvent: (channel: string, eventName: string, arg: any): Event<any> => this._handleEvent(channel, eventName, arg)\n\t\t});\n\t\tthis.requestHandler = requestHandlerFactory(this);\n\t}\n\n\tpublic onmessage(msg: any): void {\n\t\tthis._protocol.handleMessage(msg);\n\t}\n\n\tprivate _handleMessage(channel: string, method: string, args: any[]): Promise<any> {\n\t\tif (channel === DEFAULT_CHANNEL && method === INITIALIZE) {\n\t\t\treturn this.initialize(<number>args[0]);\n\t\t}\n\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channel} on worker thread`));\n\t\t}\n\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\tif (typeof (requestHandler as any)[method] !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on worker thread channel ${channel}`));\n\t\t}\n\n\t\ttry {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\treturn Promise.resolve((requestHandler as any)[method].apply(requestHandler, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channel: string, eventName: string, arg: any): Event<any> {\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\tthrow new Error(`Missing channel ${channel} on worker thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (requestHandler as any)[eventName].call(requestHandler, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\t// eslint-disable-next-line local/code-no-any-casts\n\t\t\tconst event = (requestHandler as any)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic getChannel<T extends object>(channel: string): Proxied<T> {\n\t\tif (!this._remoteChannels.has(channel)) {\n\t\t\tconst inst = this._protocol.createProxyToRemoteChannel(channel);\n\t\t\tthis._remoteChannels.set(channel, inst);\n\t\t}\n\t\treturn this._remoteChannels.get(channel) as Proxied<T>;\n\t}\n\n\tprivate async initialize(workerId: number): Promise<void> {\n\t\tthis._protocol.setWorkerId(workerId);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/worker/webWorker.ts","vs/base/common/worker/webWorker.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,iBAAiB,EAAmB,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAe,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AAEzC,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,UAAU,GAAG,aAAa,CAAC;AASjC,IAAI,sBAAsB,GAAG,KAAK,CAAC;AACnC,MAAM,UAAU,uBAAuB,CAAC,GAAY;IACnD,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,gBAAgB;QAChB,OAAO;IACR,CAAC;IACD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC7B,sBAAsB,GAAG,IAAI,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,iLAAiL,CAAC,CAAC;IACjM,CAAC;IACD,OAAO,CAAC,IAAI,CAAE,GAAa,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AASD,MAAM,cAAc;IAEnB,YACiB,QAAgB,EAChB,GAAW,EACX,OAAe,EACf,MAAc,EACd,IAAe;QAJf,aAAQ,GAAR,QAAQ,CAAQ;QAChB,QAAG,GAAH,GAAG,CAAQ;QACX,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAW;QANhB,SAAI,+BAAuB;IAOvC,CAAC;CACL;AACD,MAAM,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C;YAChC,MAAM,KAAK,GAAI,cAA0C,CAAC,SAAS,CAAC,CAAC;YACrE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,iBAAiB,SAAS,sBAAsB,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,KAAuB,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,SAAS,EAAE,CAAC,CAAC;IACtD,CAAC;IAEM,UAAU,CAAmB,OAAe;QAClD,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;YAChE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAe,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAAgB;QACxC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;CACD","file":"webWorker.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { CharCode } from '../charCode.js';\nimport { onUnexpectedError, SerializedError, transformErrorForSerialization } from '../errors.js';\nimport { Emitter, Event } from '../event.js';\nimport { Disposable, IDisposable } from '../lifecycle.js';\nimport { isWeb } from '../platform.js';\nimport * as strings from '../strings.js';\n\nconst DEFAULT_CHANNEL = 'default';\nconst INITIALIZE = '$initialize';\n\nexport interface IWebWorker extends IDisposable {\n\tgetId(): number;\n\tonMessage: Event<Message>;\n\tonError: Event<unknown>;\n\tpostMessage(message: Message, transfer: ArrayBuffer[]): void;\n}\n\nlet webWorkerWarningLogged = false;\nexport function logOnceWebWorkerWarning(err: unknown): void {\n\tif (!isWeb) {\n\t\t// running tests\n\t\treturn;\n\t}\n\tif (!webWorkerWarningLogged) {\n\t\twebWorkerWarningLogged = true;\n\t\tconsole.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq');\n\t}\n\tconsole.warn((err as Error).message);\n}\n\nconst enum MessageType {\n\tRequest,\n\tReply,\n\tSubscribeEvent,\n\tEvent,\n\tUnsubscribeEvent\n}\nclass RequestMessage {\n\tpublic readonly type = MessageType.Request;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly method: string,\n\t\tpublic readonly args: unknown[]\n\t) { }\n}\nclass ReplyMessage {\n\tpublic readonly type = MessageType.Reply;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly seq: string,\n\t\tpublic readonly res: unknown,\n\t\tpublic readonly err: unknown | SerializedError\n\t) { }\n}\nclass SubscribeEventMessage {\n\tpublic readonly type = MessageType.SubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly eventName: string,\n\t\tpublic readonly arg: unknown\n\t) { }\n}\nclass EventMessage {\n\tpublic readonly type = MessageType.Event;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly event: unknown\n\t) { }\n}\nclass UnsubscribeEventMessage {\n\tpublic readonly type = MessageType.UnsubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string\n\t) { }\n}\nexport type Message = RequestMessage | ReplyMessage | SubscribeEventMessage | EventMessage | UnsubscribeEventMessage;\n\ninterface IMessageReply {\n\tresolve: (value?: unknown) => void;\n\treject: (error?: unknown) => void;\n}\n\ninterface IMessageHandler {\n\tsendMessage(msg: unknown, transfer?: ArrayBuffer[]): void;\n\thandleMessage(channel: string, method: string, args: unknown[]): Promise<unknown>;\n\thandleEvent(channel: string, eventName: string, arg: unknown): Event<unknown>;\n}\n\nclass WebWorkerProtocol {\n\n\tprivate _workerId: number;\n\tprivate _lastSentReq: number;\n\tprivate _pendingReplies: { [req: string]: IMessageReply };\n\tprivate _pendingEmitters: Map<string, Emitter<unknown>>;\n\tprivate _pendingEvents: Map<string, IDisposable>;\n\tprivate _handler: IMessageHandler;\n\n\tconstructor(handler: IMessageHandler) {\n\t\tthis._workerId = -1;\n\t\tthis._handler = handler;\n\t\tthis._lastSentReq = 0;\n\t\tthis._pendingReplies = Object.create(null);\n\t\tthis._pendingEmitters = new Map<string, Emitter<unknown>>();\n\t\tthis._pendingEvents = new Map<string, IDisposable>();\n\t}\n\n\tpublic setWorkerId(workerId: number): void {\n\t\tthis._workerId = workerId;\n\t}\n\n\tpublic async sendMessage(channel: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tconst req = String(++this._lastSentReq);\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tthis._pendingReplies[req] = {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject: reject\n\t\t\t};\n\t\t\tthis._send(new RequestMessage(this._workerId, req, channel, method, args));\n\t\t});\n\t}\n\n\tpublic listen(channel: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tlet req: string | null = null;\n\t\tconst emitter = new Emitter<unknown>({\n\t\t\tonWillAddFirstListener: () => {\n\t\t\t\treq = String(++this._lastSentReq);\n\t\t\t\tthis._pendingEmitters.set(req, emitter);\n\t\t\t\tthis._send(new SubscribeEventMessage(this._workerId, req, channel, eventName, arg));\n\t\t\t},\n\t\t\tonDidRemoveLastListener: () => {\n\t\t\t\tthis._pendingEmitters.delete(req!);\n\t\t\t\tthis._send(new UnsubscribeEventMessage(this._workerId, req!));\n\t\t\t\treq = null;\n\t\t\t}\n\t\t});\n\t\treturn emitter.event;\n\t}\n\n\tpublic handleMessage(message: unknown): void {\n\t\tif (!message || !(message as Message).vsWorker) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._workerId !== -1 && (message as Message).vsWorker !== this._workerId) {\n\t\t\treturn;\n\t\t}\n\t\tthis._handleMessage(message as Message);\n\t}\n\n\tpublic createProxyToRemoteChannel<T extends object>(channel: string, sendMessageBarrier?: () => Promise<void>): T {\n\t\tconst handler = {\n\t\t\tget: (target: Record<PropertyKey, unknown>, name: PropertyKey) => {\n\t\t\t\tif (typeof name === 'string' && !target[name]) {\n\t\t\t\t\tif (propertyIsDynamicEvent(name)) { // onDynamic...\n\t\t\t\t\t\ttarget[name] = (arg: unknown): Event<unknown> => {\n\t\t\t\t\t\t\treturn this.listen(channel, name, arg);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (propertyIsEvent(name)) { // on...\n\t\t\t\t\t\ttarget[name] = this.listen(channel, name, undefined);\n\t\t\t\t\t} else if (name.charCodeAt(0) === CharCode.DollarSign) { // $...\n\t\t\t\t\t\ttarget[name] = async (...myArgs: unknown[]) => {\n\t\t\t\t\t\t\tawait sendMessageBarrier?.();\n\t\t\t\t\t\t\treturn this.sendMessage(channel, name, myArgs);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[name];\n\t\t\t}\n\t\t};\n\t\treturn new Proxy(Object.create(null), handler);\n\t}\n\n\tprivate _handleMessage(msg: Message): void {\n\t\tswitch (msg.type) {\n\t\t\tcase MessageType.Reply:\n\t\t\t\treturn this._handleReplyMessage(msg);\n\t\t\tcase MessageType.Request:\n\t\t\t\treturn this._handleRequestMessage(msg);\n\t\t\tcase MessageType.SubscribeEvent:\n\t\t\t\treturn this._handleSubscribeEventMessage(msg);\n\t\t\tcase MessageType.Event:\n\t\t\t\treturn this._handleEventMessage(msg);\n\t\t\tcase MessageType.UnsubscribeEvent:\n\t\t\t\treturn this._handleUnsubscribeEventMessage(msg);\n\t\t}\n\t}\n\n\tprivate _handleReplyMessage(replyMessage: ReplyMessage): void {\n\t\tif (!this._pendingReplies[replyMessage.seq]) {\n\t\t\tconsole.warn('Got reply to unknown seq');\n\t\t\treturn;\n\t\t}\n\n\t\tconst reply = this._pendingReplies[replyMessage.seq];\n\t\tdelete this._pendingReplies[replyMessage.seq];\n\n\t\tif (replyMessage.err) {\n\t\t\tlet err = replyMessage.err;\n\t\t\tif ((replyMessage.err as SerializedError).$isError) {\n\t\t\t\tconst newErr = new Error();\n\t\t\t\tnewErr.name = (replyMessage.err as SerializedError).name;\n\t\t\t\tnewErr.message = (replyMessage.err as SerializedError).message;\n\t\t\t\tnewErr.stack = (replyMessage.err as SerializedError).stack;\n\t\t\t\terr = newErr;\n\t\t\t}\n\t\t\treply.reject(err);\n\t\t\treturn;\n\t\t}\n\n\t\treply.resolve(replyMessage.res);\n\t}\n\n\tprivate _handleRequestMessage(requestMessage: RequestMessage): void {\n\t\tconst req = requestMessage.req;\n\t\tconst result = this._handler.handleMessage(requestMessage.channel, requestMessage.method, requestMessage.args);\n\t\tresult.then((r) => {\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, r, undefined));\n\t\t}, (e) => {\n\t\t\tif (e.detail instanceof Error) {\n\t\t\t\t// Loading errors have a detail property that points to the actual error\n\t\t\t\te.detail = transformErrorForSerialization(e.detail);\n\t\t\t}\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, undefined, transformErrorForSerialization(e)));\n\t\t});\n\t}\n\n\tprivate _handleSubscribeEventMessage(msg: SubscribeEventMessage): void {\n\t\tconst req = msg.req;\n\t\tconst disposable = this._handler.handleEvent(msg.channel, msg.eventName, msg.arg)((event) => {\n\t\t\tthis._send(new EventMessage(this._workerId, req, event));\n\t\t});\n\t\tthis._pendingEvents.set(req, disposable);\n\t}\n\n\tprivate _handleEventMessage(msg: EventMessage): void {\n\t\tif (!this._pendingEmitters.has(msg.req)) {\n\t\t\tconsole.warn('Got event for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEmitters.get(msg.req)!.fire(msg.event);\n\t}\n\n\tprivate _handleUnsubscribeEventMessage(msg: UnsubscribeEventMessage): void {\n\t\tif (!this._pendingEvents.has(msg.req)) {\n\t\t\tconsole.warn('Got unsubscribe for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEvents.get(msg.req)!.dispose();\n\t\tthis._pendingEvents.delete(msg.req);\n\t}\n\n\tprivate _send(msg: Message): void {\n\t\tconst transfer: ArrayBuffer[] = [];\n\t\tif (msg.type === MessageType.Request) {\n\t\t\tfor (let i = 0; i < msg.args.length; i++) {\n\t\t\t\tconst arg = msg.args[i];\n\t\t\t\tif (arg instanceof ArrayBuffer) {\n\t\t\t\t\ttransfer.push(arg);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (msg.type === MessageType.Reply) {\n\t\t\tif (msg.res instanceof ArrayBuffer) {\n\t\t\t\ttransfer.push(msg.res);\n\t\t\t}\n\t\t}\n\t\tthis._handler.sendMessage(msg, transfer);\n\t}\n}\n\ntype ProxiedMethodName = (`$${string}` | `on${string}`);\n\nexport type Proxied<T> = { [K in keyof T]: T[K] extends (...args: infer A) => infer R\n\t? (\n\t\tK extends ProxiedMethodName\n\t\t? (...args: A) => Promise<Awaited<R>>\n\t\t: never\n\t)\n\t: never\n};\n\nexport interface IWebWorkerClient<TProxy> {\n\tproxy: Proxied<TProxy>;\n\tdispose(): void;\n\tsetChannel<T extends object>(channel: string, handler: T): void;\n}\n\nexport interface IWebWorkerServer {\n\tgetChannel<T extends object>(channel: string): Proxied<T>;\n}\n\n/**\n * Main thread side\n */\nexport class WebWorkerClient<W extends object> extends Disposable implements IWebWorkerClient<W> {\n\n\tprivate readonly _worker: IWebWorker;\n\tprivate readonly _onModuleLoaded: Promise<void>;\n\tprivate readonly _protocol: WebWorkerProtocol;\n\tpublic readonly proxy: Proxied<W>;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\n\tconstructor(\n\t\tworker: IWebWorker\n\t) {\n\t\tsuper();\n\n\t\tthis._worker = this._register(worker);\n\t\tthis._register(this._worker.onMessage((msg) => {\n\t\t\tthis._protocol.handleMessage(msg);\n\t\t}));\n\t\tthis._register(this._worker.onError((err) => {\n\t\t\tlogOnceWebWorkerWarning(err);\n\t\t\tonUnexpectedError(err);\n\t\t}));\n\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: Message, transfer: ArrayBuffer[]): void => {\n\t\t\t\tthis._worker.postMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: unknown[]): Promise<unknown> => {\n\t\t\t\treturn this._handleMessage(channel, method, args);\n\t\t\t},\n\t\t\thandleEvent: (channel: string, eventName: string, arg: unknown): Event<unknown> => {\n\t\t\t\treturn this._handleEvent(channel, eventName, arg);\n\t\t\t}\n\t\t});\n\t\tthis._protocol.setWorkerId(this._worker.getId());\n\n\t\t// Send initialize message\n\t\tthis._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [\n\t\t\tthis._worker.getId(),\n\t\t]).then(() => { });\n\n\t\tthis.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });\n\t\tthis._onModuleLoaded.catch((e) => {\n\t\t\tthis._onError('Worker failed to load ', e);\n\t\t});\n\t}\n\n\tprivate _handleMessage(channelName: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channelName} on main thread`));\n\t\t}\n\n\t\tconst fn = (channel as Record<string, unknown>)[method];\n\t\tif (typeof fn !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on main thread channel ${channelName}`));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(fn.apply(channel, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channelName: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\tthrow new Error(`Missing channel ${channelName} on main thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\tconst fn = (channel as Record<string, unknown>)[eventName];\n\t\t\tif (typeof fn !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\tconst event = fn.call(channel, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\tconst event = (channel as Record<string, unknown>)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event as Event<unknown>;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic setChannel<T extends object>(channel: string, handler: T): void {\n\t\tthis._localChannels.set(channel, handler);\n\t}\n\n\tprivate _onError(message: string, error?: unknown): void {\n\t\tconsole.error(message);\n\t\tconsole.info(error);\n\t}\n}\n\nfunction propertyIsEvent(name: string): boolean {\n\t// Assume a property is an event if it has a form of \"onSomething\"\n\treturn name[0] === 'o' && name[1] === 'n' && strings.isUpperAsciiLetter(name.charCodeAt(2));\n}\n\nfunction propertyIsDynamicEvent(name: string): boolean {\n\t// Assume a property is a dynamic event (a method that returns an event) if it has a form of \"onDynamicSomething\"\n\treturn /^onDynamic/.test(name) && strings.isUpperAsciiLetter(name.charCodeAt(9));\n}\n\nexport interface IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: void;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[prop: string]: any;\n}\n\nexport interface IWebWorkerServerRequestHandlerFactory<T extends IWebWorkerServerRequestHandler> {\n\t(workerServer: IWebWorkerServer): T;\n}\n\n/**\n * Worker side\n */\nexport class WebWorkerServer<T extends IWebWorkerServerRequestHandler> implements IWebWorkerServer {\n\n\tpublic readonly requestHandler: T;\n\tprivate _protocol: WebWorkerProtocol;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\tprivate readonly _remoteChannels: Map<string, object> = new Map();\n\n\tconstructor(postMessage: (msg: Message, transfer?: ArrayBuffer[]) => void, requestHandlerFactory: IWebWorkerServerRequestHandlerFactory<T>) {\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: Message, transfer: ArrayBuffer[]): void => {\n\t\t\t\tpostMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: unknown[]): Promise<unknown> => this._handleMessage(channel, method, args),\n\t\t\thandleEvent: (channel: string, eventName: string, arg: unknown): Event<unknown> => this._handleEvent(channel, eventName, arg)\n\t\t});\n\t\tthis.requestHandler = requestHandlerFactory(this);\n\t}\n\n\tpublic onmessage(msg: unknown): void {\n\t\tthis._protocol.handleMessage(msg);\n\t}\n\n\tprivate _handleMessage(channel: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tif (channel === DEFAULT_CHANNEL && method === INITIALIZE) {\n\t\t\treturn this.initialize(<number>args[0]);\n\t\t}\n\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channel} on worker thread`));\n\t\t}\n\n\t\tconst fn = (requestHandler as Record<string, unknown>)[method];\n\t\tif (typeof fn !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on worker thread channel ${channel}`));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(fn.apply(requestHandler, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channel: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\tthrow new Error(`Missing channel ${channel} on worker thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\tconst fn = (requestHandler as Record<string, unknown>)[eventName];\n\t\t\tif (typeof fn !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\n\t\t\tconst event = fn.call(requestHandler, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\tconst event = (requestHandler as Record<string, unknown>)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event as Event<unknown>;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic getChannel<T extends object>(channel: string): Proxied<T> {\n\t\tif (!this._remoteChannels.has(channel)) {\n\t\t\tconst inst = this._protocol.createProxyToRemoteChannel(channel);\n\t\t\tthis._remoteChannels.set(channel, inst);\n\t\t}\n\t\treturn this._remoteChannels.get(channel) as Proxied<T>;\n\t}\n\n\tprivate async initialize(workerId: number): Promise<void> {\n\t\tthis._protocol.setWorkerId(workerId);\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { CharCode } from '../charCode.js';\nimport { onUnexpectedError, SerializedError, transformErrorForSerialization } from '../errors.js';\nimport { Emitter, Event } from '../event.js';\nimport { Disposable, IDisposable } from '../lifecycle.js';\nimport { isWeb } from '../platform.js';\nimport * as strings from '../strings.js';\n\nconst DEFAULT_CHANNEL = 'default';\nconst INITIALIZE = '$initialize';\n\nexport interface IWebWorker extends IDisposable {\n\tgetId(): number;\n\tonMessage: Event<Message>;\n\tonError: Event<unknown>;\n\tpostMessage(message: Message, transfer: ArrayBuffer[]): void;\n}\n\nlet webWorkerWarningLogged = false;\nexport function logOnceWebWorkerWarning(err: unknown): void {\n\tif (!isWeb) {\n\t\t// running tests\n\t\treturn;\n\t}\n\tif (!webWorkerWarningLogged) {\n\t\twebWorkerWarningLogged = true;\n\t\tconsole.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/microsoft/monaco-editor#faq');\n\t}\n\tconsole.warn((err as Error).message);\n}\n\nconst enum MessageType {\n\tRequest,\n\tReply,\n\tSubscribeEvent,\n\tEvent,\n\tUnsubscribeEvent\n}\nclass RequestMessage {\n\tpublic readonly type = MessageType.Request;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly method: string,\n\t\tpublic readonly args: unknown[]\n\t) { }\n}\nclass ReplyMessage {\n\tpublic readonly type = MessageType.Reply;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly seq: string,\n\t\tpublic readonly res: unknown,\n\t\tpublic readonly err: unknown | SerializedError\n\t) { }\n}\nclass SubscribeEventMessage {\n\tpublic readonly type = MessageType.SubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly channel: string,\n\t\tpublic readonly eventName: string,\n\t\tpublic readonly arg: unknown\n\t) { }\n}\nclass EventMessage {\n\tpublic readonly type = MessageType.Event;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string,\n\t\tpublic readonly event: unknown\n\t) { }\n}\nclass UnsubscribeEventMessage {\n\tpublic readonly type = MessageType.UnsubscribeEvent;\n\tconstructor(\n\t\tpublic readonly vsWorker: number,\n\t\tpublic readonly req: string\n\t) { }\n}\nexport type Message = RequestMessage | ReplyMessage | SubscribeEventMessage | EventMessage | UnsubscribeEventMessage;\n\ninterface IMessageReply {\n\tresolve: (value?: unknown) => void;\n\treject: (error?: unknown) => void;\n}\n\ninterface IMessageHandler {\n\tsendMessage(msg: unknown, transfer?: ArrayBuffer[]): void;\n\thandleMessage(channel: string, method: string, args: unknown[]): Promise<unknown>;\n\thandleEvent(channel: string, eventName: string, arg: unknown): Event<unknown>;\n}\n\nclass WebWorkerProtocol {\n\n\tprivate _workerId: number;\n\tprivate _lastSentReq: number;\n\tprivate _pendingReplies: { [req: string]: IMessageReply };\n\tprivate _pendingEmitters: Map<string, Emitter<unknown>>;\n\tprivate _pendingEvents: Map<string, IDisposable>;\n\tprivate _handler: IMessageHandler;\n\n\tconstructor(handler: IMessageHandler) {\n\t\tthis._workerId = -1;\n\t\tthis._handler = handler;\n\t\tthis._lastSentReq = 0;\n\t\tthis._pendingReplies = Object.create(null);\n\t\tthis._pendingEmitters = new Map<string, Emitter<unknown>>();\n\t\tthis._pendingEvents = new Map<string, IDisposable>();\n\t}\n\n\tpublic setWorkerId(workerId: number): void {\n\t\tthis._workerId = workerId;\n\t}\n\n\tpublic async sendMessage(channel: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tconst req = String(++this._lastSentReq);\n\t\treturn new Promise<unknown>((resolve, reject) => {\n\t\t\tthis._pendingReplies[req] = {\n\t\t\t\tresolve: resolve,\n\t\t\t\treject: reject\n\t\t\t};\n\t\t\tthis._send(new RequestMessage(this._workerId, req, channel, method, args));\n\t\t});\n\t}\n\n\tpublic listen(channel: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tlet req: string | null = null;\n\t\tconst emitter = new Emitter<unknown>({\n\t\t\tonWillAddFirstListener: () => {\n\t\t\t\treq = String(++this._lastSentReq);\n\t\t\t\tthis._pendingEmitters.set(req, emitter);\n\t\t\t\tthis._send(new SubscribeEventMessage(this._workerId, req, channel, eventName, arg));\n\t\t\t},\n\t\t\tonDidRemoveLastListener: () => {\n\t\t\t\tthis._pendingEmitters.delete(req!);\n\t\t\t\tthis._send(new UnsubscribeEventMessage(this._workerId, req!));\n\t\t\t\treq = null;\n\t\t\t}\n\t\t});\n\t\treturn emitter.event;\n\t}\n\n\tpublic handleMessage(message: unknown): void {\n\t\tif (!message || !(message as Message).vsWorker) {\n\t\t\treturn;\n\t\t}\n\t\tif (this._workerId !== -1 && (message as Message).vsWorker !== this._workerId) {\n\t\t\treturn;\n\t\t}\n\t\tthis._handleMessage(message as Message);\n\t}\n\n\tpublic createProxyToRemoteChannel<T extends object>(channel: string, sendMessageBarrier?: () => Promise<void>): T {\n\t\tconst handler = {\n\t\t\tget: (target: Record<PropertyKey, unknown>, name: PropertyKey) => {\n\t\t\t\tif (typeof name === 'string' && !target[name]) {\n\t\t\t\t\tif (propertyIsDynamicEvent(name)) { // onDynamic...\n\t\t\t\t\t\ttarget[name] = (arg: unknown): Event<unknown> => {\n\t\t\t\t\t\t\treturn this.listen(channel, name, arg);\n\t\t\t\t\t\t};\n\t\t\t\t\t} else if (propertyIsEvent(name)) { // on...\n\t\t\t\t\t\ttarget[name] = this.listen(channel, name, undefined);\n\t\t\t\t\t} else if (name.charCodeAt(0) === CharCode.DollarSign) { // $...\n\t\t\t\t\t\ttarget[name] = async (...myArgs: unknown[]) => {\n\t\t\t\t\t\t\tawait sendMessageBarrier?.();\n\t\t\t\t\t\t\treturn this.sendMessage(channel, name, myArgs);\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn target[name];\n\t\t\t}\n\t\t};\n\t\treturn new Proxy(Object.create(null), handler);\n\t}\n\n\tprivate _handleMessage(msg: Message): void {\n\t\tswitch (msg.type) {\n\t\t\tcase MessageType.Reply:\n\t\t\t\treturn this._handleReplyMessage(msg);\n\t\t\tcase MessageType.Request:\n\t\t\t\treturn this._handleRequestMessage(msg);\n\t\t\tcase MessageType.SubscribeEvent:\n\t\t\t\treturn this._handleSubscribeEventMessage(msg);\n\t\t\tcase MessageType.Event:\n\t\t\t\treturn this._handleEventMessage(msg);\n\t\t\tcase MessageType.UnsubscribeEvent:\n\t\t\t\treturn this._handleUnsubscribeEventMessage(msg);\n\t\t}\n\t}\n\n\tprivate _handleReplyMessage(replyMessage: ReplyMessage): void {\n\t\tif (!this._pendingReplies[replyMessage.seq]) {\n\t\t\tconsole.warn('Got reply to unknown seq');\n\t\t\treturn;\n\t\t}\n\n\t\tconst reply = this._pendingReplies[replyMessage.seq];\n\t\tdelete this._pendingReplies[replyMessage.seq];\n\n\t\tif (replyMessage.err) {\n\t\t\tlet err = replyMessage.err;\n\t\t\tif ((replyMessage.err as SerializedError).$isError) {\n\t\t\t\tconst newErr = new Error();\n\t\t\t\tnewErr.name = (replyMessage.err as SerializedError).name;\n\t\t\t\tnewErr.message = (replyMessage.err as SerializedError).message;\n\t\t\t\tnewErr.stack = (replyMessage.err as SerializedError).stack;\n\t\t\t\terr = newErr;\n\t\t\t}\n\t\t\treply.reject(err);\n\t\t\treturn;\n\t\t}\n\n\t\treply.resolve(replyMessage.res);\n\t}\n\n\tprivate _handleRequestMessage(requestMessage: RequestMessage): void {\n\t\tconst req = requestMessage.req;\n\t\tconst result = this._handler.handleMessage(requestMessage.channel, requestMessage.method, requestMessage.args);\n\t\tresult.then((r) => {\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, r, undefined));\n\t\t}, (e) => {\n\t\t\tif (e.detail instanceof Error) {\n\t\t\t\t// Loading errors have a detail property that points to the actual error\n\t\t\t\te.detail = transformErrorForSerialization(e.detail);\n\t\t\t}\n\t\t\tthis._send(new ReplyMessage(this._workerId, req, undefined, transformErrorForSerialization(e)));\n\t\t});\n\t}\n\n\tprivate _handleSubscribeEventMessage(msg: SubscribeEventMessage): void {\n\t\tconst req = msg.req;\n\t\tconst disposable = this._handler.handleEvent(msg.channel, msg.eventName, msg.arg)((event) => {\n\t\t\tthis._send(new EventMessage(this._workerId, req, event));\n\t\t});\n\t\tthis._pendingEvents.set(req, disposable);\n\t}\n\n\tprivate _handleEventMessage(msg: EventMessage): void {\n\t\tif (!this._pendingEmitters.has(msg.req)) {\n\t\t\tconsole.warn('Got event for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEmitters.get(msg.req)!.fire(msg.event);\n\t}\n\n\tprivate _handleUnsubscribeEventMessage(msg: UnsubscribeEventMessage): void {\n\t\tif (!this._pendingEvents.has(msg.req)) {\n\t\t\tconsole.warn('Got unsubscribe for unknown req');\n\t\t\treturn;\n\t\t}\n\t\tthis._pendingEvents.get(msg.req)!.dispose();\n\t\tthis._pendingEvents.delete(msg.req);\n\t}\n\n\tprivate _send(msg: Message): void {\n\t\tconst transfer: ArrayBuffer[] = [];\n\t\tif (msg.type === MessageType.Request) {\n\t\t\tfor (let i = 0; i < msg.args.length; i++) {\n\t\t\t\tconst arg = msg.args[i];\n\t\t\t\tif (arg instanceof ArrayBuffer) {\n\t\t\t\t\ttransfer.push(arg);\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (msg.type === MessageType.Reply) {\n\t\t\tif (msg.res instanceof ArrayBuffer) {\n\t\t\t\ttransfer.push(msg.res);\n\t\t\t}\n\t\t}\n\t\tthis._handler.sendMessage(msg, transfer);\n\t}\n}\n\ntype ProxiedMethodName = (`$${string}` | `on${string}`);\n\nexport type Proxied<T> = { [K in keyof T]: T[K] extends (...args: infer A) => infer R\n\t? (\n\t\tK extends ProxiedMethodName\n\t\t? (...args: A) => Promise<Awaited<R>>\n\t\t: never\n\t)\n\t: never\n};\n\nexport interface IWebWorkerClient<TProxy> {\n\tproxy: Proxied<TProxy>;\n\tdispose(): void;\n\tsetChannel<T extends object>(channel: string, handler: T): void;\n}\n\nexport interface IWebWorkerServer {\n\tgetChannel<T extends object>(channel: string): Proxied<T>;\n}\n\n/**\n * Main thread side\n */\nexport class WebWorkerClient<W extends object> extends Disposable implements IWebWorkerClient<W> {\n\n\tprivate readonly _worker: IWebWorker;\n\tprivate readonly _onModuleLoaded: Promise<void>;\n\tprivate readonly _protocol: WebWorkerProtocol;\n\tpublic readonly proxy: Proxied<W>;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\n\tconstructor(\n\t\tworker: IWebWorker\n\t) {\n\t\tsuper();\n\n\t\tthis._worker = this._register(worker);\n\t\tthis._register(this._worker.onMessage((msg) => {\n\t\t\tthis._protocol.handleMessage(msg);\n\t\t}));\n\t\tthis._register(this._worker.onError((err) => {\n\t\t\tlogOnceWebWorkerWarning(err);\n\t\t\tonUnexpectedError(err);\n\t\t}));\n\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: Message, transfer: ArrayBuffer[]): void => {\n\t\t\t\tthis._worker.postMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: unknown[]): Promise<unknown> => {\n\t\t\t\treturn this._handleMessage(channel, method, args);\n\t\t\t},\n\t\t\thandleEvent: (channel: string, eventName: string, arg: unknown): Event<unknown> => {\n\t\t\t\treturn this._handleEvent(channel, eventName, arg);\n\t\t\t}\n\t\t});\n\t\tthis._protocol.setWorkerId(this._worker.getId());\n\n\t\t// Send initialize message\n\t\tthis._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [\n\t\t\tthis._worker.getId(),\n\t\t]).then(() => { });\n\n\t\tthis.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });\n\t\tthis._onModuleLoaded.catch((e) => {\n\t\t\tthis._onError('Worker failed to load ', e);\n\t\t});\n\t}\n\n\tprivate _handleMessage(channelName: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channelName} on main thread`));\n\t\t}\n\n\t\tconst fn = (channel as Record<string, unknown>)[method];\n\t\tif (typeof fn !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on main thread channel ${channelName}`));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(fn.apply(channel, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channelName: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tconst channel: object | undefined = this._localChannels.get(channelName);\n\t\tif (!channel) {\n\t\t\tthrow new Error(`Missing channel ${channelName} on main thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\tconst fn = (channel as Record<string, unknown>)[eventName];\n\t\t\tif (typeof fn !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\tconst event = fn.call(channel, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\tconst event = (channel as Record<string, unknown>)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on main thread channel ${channelName}.`);\n\t\t\t}\n\t\t\treturn event as Event<unknown>;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic setChannel<T extends object>(channel: string, handler: T): void {\n\t\tthis._localChannels.set(channel, handler);\n\t}\n\n\tprivate _onError(message: string, error?: unknown): void {\n\t\tconsole.error(message);\n\t\tconsole.info(error);\n\t}\n}\n\nfunction propertyIsEvent(name: string): boolean {\n\t// Assume a property is an event if it has a form of \"onSomething\"\n\treturn name[0] === 'o' && name[1] === 'n' && strings.isUpperAsciiLetter(name.charCodeAt(2));\n}\n\nfunction propertyIsDynamicEvent(name: string): boolean {\n\t// Assume a property is a dynamic event (a method that returns an event) if it has a form of \"onDynamicSomething\"\n\treturn /^onDynamic/.test(name) && strings.isUpperAsciiLetter(name.charCodeAt(9));\n}\n\nexport interface IWebWorkerServerRequestHandler {\n\t_requestHandlerBrand: void;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[prop: string]: any;\n}\n\nexport interface IWebWorkerServerRequestHandlerFactory<T extends IWebWorkerServerRequestHandler> {\n\t(workerServer: IWebWorkerServer): T;\n}\n\n/**\n * Worker side\n */\nexport class WebWorkerServer<T extends IWebWorkerServerRequestHandler> implements IWebWorkerServer {\n\n\tpublic readonly requestHandler: T;\n\tprivate _protocol: WebWorkerProtocol;\n\tprivate readonly _localChannels: Map<string, object> = new Map();\n\tprivate readonly _remoteChannels: Map<string, object> = new Map();\n\n\tconstructor(postMessage: (msg: Message, transfer?: ArrayBuffer[]) => void, requestHandlerFactory: IWebWorkerServerRequestHandlerFactory<T>) {\n\t\tthis._protocol = new WebWorkerProtocol({\n\t\t\tsendMessage: (msg: Message, transfer: ArrayBuffer[]): void => {\n\t\t\t\tpostMessage(msg, transfer);\n\t\t\t},\n\t\t\thandleMessage: (channel: string, method: string, args: unknown[]): Promise<unknown> => this._handleMessage(channel, method, args),\n\t\t\thandleEvent: (channel: string, eventName: string, arg: unknown): Event<unknown> => this._handleEvent(channel, eventName, arg)\n\t\t});\n\t\tthis.requestHandler = requestHandlerFactory(this);\n\t}\n\n\tpublic onmessage(msg: unknown): void {\n\t\tthis._protocol.handleMessage(msg);\n\t}\n\n\tprivate _handleMessage(channel: string, method: string, args: unknown[]): Promise<unknown> {\n\t\tif (channel === DEFAULT_CHANNEL && method === INITIALIZE) {\n\t\t\treturn this.initialize(<number>args[0]);\n\t\t}\n\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\treturn Promise.reject(new Error(`Missing channel ${channel} on worker thread`));\n\t\t}\n\n\t\tconst fn = (requestHandler as Record<string, unknown>)[method];\n\t\tif (typeof fn !== 'function') {\n\t\t\treturn Promise.reject(new Error(`Missing method ${method} on worker thread channel ${channel}`));\n\t\t}\n\n\t\ttry {\n\t\t\treturn Promise.resolve(fn.apply(requestHandler, args));\n\t\t} catch (e) {\n\t\t\treturn Promise.reject(e);\n\t\t}\n\t}\n\n\tprivate _handleEvent(channel: string, eventName: string, arg: unknown): Event<unknown> {\n\t\tconst requestHandler: object | null | undefined = (channel === DEFAULT_CHANNEL ? this.requestHandler : this._localChannels.get(channel));\n\t\tif (!requestHandler) {\n\t\t\tthrow new Error(`Missing channel ${channel} on worker thread`);\n\t\t}\n\t\tif (propertyIsDynamicEvent(eventName)) {\n\t\t\tconst fn = (requestHandler as Record<string, unknown>)[eventName];\n\t\t\tif (typeof fn !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\n\t\t\tconst event = fn.call(requestHandler, arg);\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing dynamic event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event;\n\t\t}\n\t\tif (propertyIsEvent(eventName)) {\n\t\t\tconst event = (requestHandler as Record<string, unknown>)[eventName];\n\t\t\tif (typeof event !== 'function') {\n\t\t\t\tthrow new Error(`Missing event ${eventName} on request handler.`);\n\t\t\t}\n\t\t\treturn event as Event<unknown>;\n\t\t}\n\t\tthrow new Error(`Malformed event name ${eventName}`);\n\t}\n\n\tpublic getChannel<T extends object>(channel: string): Proxied<T> {\n\t\tif (!this._remoteChannels.has(channel)) {\n\t\t\tconst inst = this._protocol.createProxyToRemoteChannel(channel);\n\t\t\tthis._remoteChannels.set(channel, inst);\n\t\t}\n\t\treturn this._remoteChannels.get(channel) as Proxied<T>;\n\t}\n\n\tprivate async initialize(workerId: number): Promise<void> {\n\t\tthis._protocol.setWorkerId(workerId);\n\t}\n}\n"]}
|