@aws/lsp-codewhisperer 0.0.9 → 0.0.11
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/CHANGELOG.md +8 -0
- package/node_modules/@amzn/codewhisperer-streaming/package.json +4 -4
- package/node_modules/@aws/lsp-fqn/out/common/commonFqnWorkerPool.js +12 -25
- package/node_modules/@aws/lsp-fqn/out/common/commonFqnWorkerPool.js.map +1 -1
- package/node_modules/@aws/lsp-fqn/out/common/fqnExtractor.js +1 -2
- package/node_modules/@aws/lsp-fqn/out/common/fqnExtractor.js.map +1 -1
- package/node_modules/@aws/lsp-fqn/package.json +1 -1
- package/node_modules/@aws/lsp-fqn/tsconfig.tsbuildinfo +1 -1
- package/out/client/streamingClient/codewhispererStreamingClient.d.ts +5 -0
- package/out/client/streamingClient/codewhispererStreamingClient.js +25 -0
- package/out/client/streamingClient/codewhispererStreamingClient.js.map +1 -0
- package/out/client/token/bearer-token-service.json +55 -2
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/language-server/chat/chatController.js +104 -108
- package/out/language-server/chat/chatController.js.map +1 -1
- package/out/language-server/chat/chatController.test.js +16 -1
- package/out/language-server/chat/chatController.test.js.map +1 -1
- package/out/language-server/chat/chatEventParser.js +28 -34
- package/out/language-server/chat/chatEventParser.js.map +1 -1
- package/out/language-server/chat/chatSessionManagementService.js +22 -36
- package/out/language-server/chat/chatSessionManagementService.js.map +1 -1
- package/out/language-server/chat/chatSessionService.js +24 -37
- package/out/language-server/chat/chatSessionService.js.map +1 -1
- package/out/language-server/chat/constants.d.ts +2 -0
- package/out/language-server/chat/constants.js +32 -0
- package/out/language-server/chat/constants.js.map +1 -0
- package/out/language-server/chat/contexts/documentContext.js +11 -24
- package/out/language-server/chat/contexts/documentContext.js.map +1 -1
- package/out/language-server/chat/contexts/documentFqnExtractor.js +67 -78
- package/out/language-server/chat/contexts/documentFqnExtractor.js.map +1 -1
- package/out/language-server/chat/contexts/triggerContext.js +32 -44
- package/out/language-server/chat/contexts/triggerContext.js.map +1 -1
- package/out/language-server/chat/quickActions.d.ts +0 -1
- package/out/language-server/chat/quickActions.js +1 -28
- package/out/language-server/chat/quickActions.js.map +1 -1
- package/out/language-server/chat/telemetry/chatTelemetryController.js +114 -126
- package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
- package/out/language-server/chat/utils.d.ts +6 -0
- package/out/language-server/chat/utils.js +60 -0
- package/out/language-server/chat/utils.js.map +1 -0
- package/out/language-server/codeWhispererService.js +13 -11
- package/out/language-server/codeWhispererService.js.map +1 -1
- package/out/language-server/constants.d.ts +3 -0
- package/out/language-server/constants.js +7 -0
- package/out/language-server/constants.js.map +1 -0
- package/out/language-server/dependencyGraph/csharpDependencyGraph.js +2 -2
- package/out/language-server/dependencyGraph/csharpDependencyGraph.js.map +1 -1
- package/out/language-server/dependencyGraph/dependencyGraph.js +12 -9
- package/out/language-server/dependencyGraph/dependencyGraph.js.map +1 -1
- package/out/language-server/dependencyGraph/gitIgnoreFilter.js +1 -0
- package/out/language-server/dependencyGraph/gitIgnoreFilter.js.map +1 -1
- package/out/language-server/netTransform/artifactManager.d.ts +29 -0
- package/out/language-server/netTransform/artifactManager.js +191 -0
- package/out/language-server/netTransform/artifactManager.js.map +1 -0
- package/out/language-server/netTransform/converter.d.ts +9 -0
- package/out/language-server/netTransform/converter.js +108 -0
- package/out/language-server/netTransform/converter.js.map +1 -0
- package/out/language-server/netTransform/metrics.d.ts +17 -0
- package/out/language-server/netTransform/metrics.js +222 -0
- package/out/language-server/netTransform/metrics.js.map +1 -0
- package/out/language-server/netTransform/models.d.ts +84 -0
- package/out/language-server/netTransform/models.js +12 -0
- package/out/language-server/netTransform/models.js.map +1 -0
- package/out/language-server/netTransform/resources/SupportedProjects.d.ts +2 -0
- package/out/language-server/netTransform/resources/SupportedProjects.js +26 -0
- package/out/language-server/netTransform/resources/SupportedProjects.js.map +1 -0
- package/out/language-server/netTransform/tests/converter.test.d.ts +1 -0
- package/out/language-server/netTransform/tests/converter.test.js +265 -0
- package/out/language-server/netTransform/tests/converter.test.js.map +1 -0
- package/out/language-server/netTransform/tests/mockData.d.ts +21 -0
- package/out/language-server/netTransform/tests/mockData.js +60 -0
- package/out/language-server/netTransform/tests/mockData.js.map +1 -0
- package/out/language-server/netTransform/tests/transformHandler.test.d.ts +1 -0
- package/out/language-server/netTransform/tests/transformHandler.test.js +242 -0
- package/out/language-server/netTransform/tests/transformHandler.test.js.map +1 -0
- package/out/language-server/netTransform/tests/validation.test.d.ts +1 -0
- package/out/language-server/netTransform/tests/validation.test.js +80 -0
- package/out/language-server/netTransform/tests/validation.test.js.map +1 -0
- package/out/language-server/netTransform/transformHandler.d.ts +27 -0
- package/out/language-server/netTransform/transformHandler.js +315 -0
- package/out/language-server/netTransform/transformHandler.js.map +1 -0
- package/out/language-server/netTransform/validation.d.ts +9 -0
- package/out/language-server/netTransform/validation.js +79 -0
- package/out/language-server/netTransform/validation.js.map +1 -0
- package/out/language-server/netTransformServer.d.ts +5 -6
- package/out/language-server/netTransformServer.js +149 -15
- package/out/language-server/netTransformServer.js.map +1 -1
- package/out/language-server/proxy-server.d.ts +1 -0
- package/out/language-server/proxy-server.js +16 -1
- package/out/language-server/proxy-server.js.map +1 -1
- package/out/language-server/securityScan/securityScanDiagnosticsProvider.js +10 -6
- package/out/language-server/securityScan/securityScanDiagnosticsProvider.js.map +1 -1
- package/out/language-server/securityScan/securityScanHandler.js +4 -0
- package/out/language-server/securityScan/securityScanHandler.js.map +1 -1
- package/out/language-server/session/sessionManager.js +35 -15
- package/out/language-server/session/sessionManager.js.map +1 -1
- package/out/language-server/telemetry/codeDiffTracker.js +69 -80
- package/out/language-server/telemetry/codeDiffTracker.js.map +1 -1
- package/out/language-server/telemetry/codePercentage.js +3 -0
- package/out/language-server/telemetry/codePercentage.js.map +1 -1
- package/out/language-server/telemetry/metric.js +8 -21
- package/out/language-server/telemetry/metric.js.map +1 -1
- package/out/language-server/telemetry/types.d.ts +38 -0
- package/out/language-server/telemetry/types.js.map +1 -1
- package/out/language-server/utils.d.ts +2 -5
- package/out/language-server/utils.js +25 -49
- package/out/language-server/utils.js.map +1 -1
- package/package.json +5 -2
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/HISTORY.md +0 -395
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/LICENSE +0 -201
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/README.md +0 -530
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.js +0 -288
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.js.map +0 -1
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.min.js +0 -2
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/worker.min.js.map +0 -1
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.js +0 -1737
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.js.map +0 -1
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js +0 -3
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js.LICENSE.txt +0 -24
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/dist/workerpool.min.js.map +0 -1
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/package.json +0 -57
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/Pool.js +0 -476
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/Promise.js +0 -293
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/WorkerHandler.js +0 -547
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/debug-port-allocator.js +0 -28
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/environment.js +0 -30
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/generated/embeddedWorker.js +0 -6
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/header.js +0 -24
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/index.js +0 -60
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/requireFoolWebpack.js +0 -8
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/transfer.js +0 -12
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/types.js +0 -46
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/validateOptions.js +0 -51
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/src/worker.js +0 -256
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/Pool.d.ts +0 -130
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/Promise.d.ts +0 -125
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/WorkerHandler.d.ts +0 -89
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/debug-port-allocator.d.ts +0 -8
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/environment.d.ts +0 -4
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/generated/embeddedWorker.d.ts +0 -2
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/index.d.ts +0 -43
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/transfer.d.ts +0 -19
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/types.d.ts +0 -99
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/validateOptions.d.ts +0 -4
- package/node_modules/@aws/lsp-fqn/node_modules/workerpool/types/worker.d.ts +0 -8
- package/node_modules/@aws-sdk/middleware-recursion-detection/LICENSE +0 -201
- package/node_modules/@aws-sdk/middleware-recursion-detection/README.md +0 -10
- package/node_modules/@aws-sdk/middleware-recursion-detection/dist-cjs/index.js +0 -39
- package/node_modules/@aws-sdk/middleware-recursion-detection/dist-es/index.js +0 -34
- package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/index.d.ts +0 -18
- package/node_modules/@aws-sdk/middleware-recursion-detection/dist-types/ts3.4/index.d.ts +0 -18
- package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +0 -59
- package/node_modules/@aws-sdk/middleware-user-agent/LICENSE +0 -201
- package/node_modules/@aws-sdk/middleware-user-agent/README.md +0 -4
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/configurations.js +0 -10
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/constants.js +0 -10
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js +0 -5
- package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/user-agent-middleware.js +0 -79
- package/node_modules/@aws-sdk/middleware-user-agent/dist-es/configurations.js +0 -6
- package/node_modules/@aws-sdk/middleware-user-agent/dist-es/constants.js +0 -7
- package/node_modules/@aws-sdk/middleware-user-agent/dist-es/index.js +0 -2
- package/node_modules/@aws-sdk/middleware-user-agent/dist-es/user-agent-middleware.js +0 -72
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/configurations.d.ts +0 -31
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/constants.d.ts +0 -7
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/index.d.ts +0 -2
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/ts3.4/configurations.d.ts +0 -17
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/ts3.4/constants.d.ts +0 -7
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/ts3.4/index.d.ts +0 -2
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/ts3.4/user-agent-middleware.d.ts +0 -20
- package/node_modules/@aws-sdk/middleware-user-agent/dist-types/user-agent-middleware.d.ts +0 -17
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +0 -61
- package/node_modules/@aws-sdk/util-locate-window/LICENSE +0 -201
- package/node_modules/@aws-sdk/util-locate-window/README.md +0 -4
- package/node_modules/@aws-sdk/util-locate-window/dist-cjs/index.js +0 -41
- package/node_modules/@aws-sdk/util-locate-window/dist-es/index.js +0 -10
- package/node_modules/@aws-sdk/util-locate-window/dist-types/index.d.ts +0 -6
- package/node_modules/@aws-sdk/util-locate-window/dist-types/ts3.4/index.d.ts +0 -1
- package/node_modules/@aws-sdk/util-locate-window/package.json +0 -52
- package/node_modules/@smithy/eventstream-serde-config-resolver/LICENSE +0 -201
- package/node_modules/@smithy/eventstream-serde-config-resolver/README.md +0 -10
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-cjs/EventStreamSerdeConfig.js +0 -1
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-cjs/index.js +0 -37
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-es/EventStreamSerdeConfig.js +0 -4
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-es/index.js +0 -1
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/EventStreamSerdeConfig.d.ts +0 -24
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/index.d.ts +0 -4
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/ts3.4/EventStreamSerdeConfig.d.ts +0 -24
- package/node_modules/@smithy/eventstream-serde-config-resolver/dist-types/ts3.4/index.d.ts +0 -4
- package/node_modules/@smithy/eventstream-serde-config-resolver/package.json +0 -61
- package/node_modules/@smithy/util-utf8/LICENSE +0 -201
- package/node_modules/@smithy/util-utf8/README.md +0 -4
- package/node_modules/@smithy/util-utf8/dist-cjs/fromUtf8.browser.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-cjs/fromUtf8.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-cjs/index.js +0 -65
- package/node_modules/@smithy/util-utf8/dist-cjs/toUint8Array.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-cjs/toUtf8.browser.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-cjs/toUtf8.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js +0 -1
- package/node_modules/@smithy/util-utf8/dist-es/fromUtf8.js +0 -5
- package/node_modules/@smithy/util-utf8/dist-es/index.js +0 -3
- package/node_modules/@smithy/util-utf8/dist-es/toUint8Array.js +0 -10
- package/node_modules/@smithy/util-utf8/dist-es/toUtf8.browser.js +0 -9
- package/node_modules/@smithy/util-utf8/dist-es/toUtf8.js +0 -10
- package/node_modules/@smithy/util-utf8/dist-types/fromUtf8.browser.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/fromUtf8.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/index.d.ts +0 -3
- package/node_modules/@smithy/util-utf8/dist-types/toUint8Array.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/toUtf8.browser.d.ts +0 -7
- package/node_modules/@smithy/util-utf8/dist-types/toUtf8.d.ts +0 -7
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/fromUtf8.browser.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/fromUtf8.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/index.d.ts +0 -3
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/toUint8Array.d.ts +0 -1
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/toUtf8.browser.d.ts +0 -7
- package/node_modules/@smithy/util-utf8/dist-types/ts3.4/toUtf8.d.ts +0 -7
- package/node_modules/@smithy/util-utf8/package.json +0 -66
- package/node_modules/bowser/CHANGELOG.md +0 -218
- package/node_modules/bowser/LICENSE +0 -39
- package/node_modules/bowser/README.md +0 -179
- package/node_modules/bowser/bundled.js +0 -1
- package/node_modules/bowser/es5.js +0 -1
- package/node_modules/bowser/index.d.ts +0 -250
- package/node_modules/bowser/package.json +0 -83
- package/node_modules/bowser/src/bowser.js +0 -77
- package/node_modules/bowser/src/constants.js +0 -116
- package/node_modules/bowser/src/parser-browsers.js +0 -700
- package/node_modules/bowser/src/parser-engines.js +0 -120
- package/node_modules/bowser/src/parser-os.js +0 -199
- package/node_modules/bowser/src/parser-platforms.js +0 -266
- package/node_modules/bowser/src/parser.js +0 -496
- package/node_modules/bowser/src/utils.js +0 -309
- package/node_modules/tslib/CopyrightNotice.txt +0 -15
- package/node_modules/tslib/LICENSE.txt +0 -12
- package/node_modules/tslib/README.md +0 -164
- package/node_modules/tslib/SECURITY.md +0 -41
- package/node_modules/tslib/modules/index.d.ts +0 -37
- package/node_modules/tslib/modules/index.js +0 -68
- package/node_modules/tslib/modules/package.json +0 -3
- package/node_modules/tslib/package.json +0 -47
- package/node_modules/tslib/tslib.d.ts +0 -453
- package/node_modules/tslib/tslib.es6.html +0 -1
- package/node_modules/tslib/tslib.es6.js +0 -374
- package/node_modules/tslib/tslib.es6.mjs +0 -373
- package/node_modules/tslib/tslib.html +0 -1
- package/node_modules/tslib/tslib.js +0 -424
- package/node_modules/uuid/CHANGELOG.md +0 -274
- package/node_modules/uuid/CONTRIBUTING.md +0 -18
- package/node_modules/uuid/LICENSE.md +0 -9
- package/node_modules/uuid/README.md +0 -466
- package/node_modules/uuid/dist/bin/uuid +0 -2
- package/node_modules/uuid/dist/commonjs-browser/index.js +0 -79
- package/node_modules/uuid/dist/commonjs-browser/md5.js +0 -223
- package/node_modules/uuid/dist/commonjs-browser/native.js +0 -11
- package/node_modules/uuid/dist/commonjs-browser/nil.js +0 -8
- package/node_modules/uuid/dist/commonjs-browser/parse.js +0 -45
- package/node_modules/uuid/dist/commonjs-browser/regex.js +0 -8
- package/node_modules/uuid/dist/commonjs-browser/rng.js +0 -25
- package/node_modules/uuid/dist/commonjs-browser/sha1.js +0 -104
- package/node_modules/uuid/dist/commonjs-browser/stringify.js +0 -44
- package/node_modules/uuid/dist/commonjs-browser/v1.js +0 -107
- package/node_modules/uuid/dist/commonjs-browser/v3.js +0 -16
- package/node_modules/uuid/dist/commonjs-browser/v35.js +0 -80
- package/node_modules/uuid/dist/commonjs-browser/v4.js +0 -43
- package/node_modules/uuid/dist/commonjs-browser/v5.js +0 -16
- package/node_modules/uuid/dist/commonjs-browser/validate.js +0 -17
- package/node_modules/uuid/dist/commonjs-browser/version.js +0 -21
- package/node_modules/uuid/dist/esm-browser/index.js +0 -9
- package/node_modules/uuid/dist/esm-browser/md5.js +0 -215
- package/node_modules/uuid/dist/esm-browser/native.js +0 -4
- package/node_modules/uuid/dist/esm-browser/nil.js +0 -1
- package/node_modules/uuid/dist/esm-browser/parse.js +0 -35
- package/node_modules/uuid/dist/esm-browser/regex.js +0 -1
- package/node_modules/uuid/dist/esm-browser/rng.js +0 -18
- package/node_modules/uuid/dist/esm-browser/sha1.js +0 -96
- package/node_modules/uuid/dist/esm-browser/stringify.js +0 -33
- package/node_modules/uuid/dist/esm-browser/v1.js +0 -95
- package/node_modules/uuid/dist/esm-browser/v3.js +0 -4
- package/node_modules/uuid/dist/esm-browser/v35.js +0 -66
- package/node_modules/uuid/dist/esm-browser/v4.js +0 -29
- package/node_modules/uuid/dist/esm-browser/v5.js +0 -4
- package/node_modules/uuid/dist/esm-browser/validate.js +0 -7
- package/node_modules/uuid/dist/esm-browser/version.js +0 -11
- package/node_modules/uuid/dist/esm-node/index.js +0 -9
- package/node_modules/uuid/dist/esm-node/md5.js +0 -13
- package/node_modules/uuid/dist/esm-node/native.js +0 -4
- package/node_modules/uuid/dist/esm-node/nil.js +0 -1
- package/node_modules/uuid/dist/esm-node/parse.js +0 -35
- package/node_modules/uuid/dist/esm-node/regex.js +0 -1
- package/node_modules/uuid/dist/esm-node/rng.js +0 -12
- package/node_modules/uuid/dist/esm-node/sha1.js +0 -13
- package/node_modules/uuid/dist/esm-node/stringify.js +0 -33
- package/node_modules/uuid/dist/esm-node/v1.js +0 -95
- package/node_modules/uuid/dist/esm-node/v3.js +0 -4
- package/node_modules/uuid/dist/esm-node/v35.js +0 -66
- package/node_modules/uuid/dist/esm-node/v4.js +0 -29
- package/node_modules/uuid/dist/esm-node/v5.js +0 -4
- package/node_modules/uuid/dist/esm-node/validate.js +0 -7
- package/node_modules/uuid/dist/esm-node/version.js +0 -11
- package/node_modules/uuid/dist/index.js +0 -79
- package/node_modules/uuid/dist/md5-browser.js +0 -223
- package/node_modules/uuid/dist/md5.js +0 -23
- package/node_modules/uuid/dist/native-browser.js +0 -11
- package/node_modules/uuid/dist/native.js +0 -15
- package/node_modules/uuid/dist/nil.js +0 -8
- package/node_modules/uuid/dist/parse.js +0 -45
- package/node_modules/uuid/dist/regex.js +0 -8
- package/node_modules/uuid/dist/rng-browser.js +0 -25
- package/node_modules/uuid/dist/rng.js +0 -24
- package/node_modules/uuid/dist/sha1-browser.js +0 -104
- package/node_modules/uuid/dist/sha1.js +0 -23
- package/node_modules/uuid/dist/stringify.js +0 -44
- package/node_modules/uuid/dist/uuid-bin.js +0 -85
- package/node_modules/uuid/dist/v1.js +0 -107
- package/node_modules/uuid/dist/v3.js +0 -16
- package/node_modules/uuid/dist/v35.js +0 -80
- package/node_modules/uuid/dist/v4.js +0 -43
- package/node_modules/uuid/dist/v5.js +0 -16
- package/node_modules/uuid/dist/validate.js +0 -17
- package/node_modules/uuid/dist/version.js +0 -21
- package/node_modules/uuid/package.json +0 -135
- package/node_modules/uuid/wrapper.mjs +0 -10
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var {Promise} = require('./Promise');
|
|
4
|
-
var environment = require('./environment');
|
|
5
|
-
const {validateOptions, forkOptsNames, workerThreadOptsNames, workerOptsNames} = require("./validateOptions");
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Special message sent by parent which causes a child process worker to terminate itself.
|
|
9
|
-
* Not a "message object"; this string is the entire message.
|
|
10
|
-
*/
|
|
11
|
-
var TERMINATE_METHOD_ID = '__workerpool-terminate__';
|
|
12
|
-
|
|
13
|
-
function ensureWorkerThreads() {
|
|
14
|
-
var WorkerThreads = tryRequireWorkerThreads()
|
|
15
|
-
if (!WorkerThreads) {
|
|
16
|
-
throw new Error('WorkerPool: workerType = \'thread\' is not supported, Node >= 11.7.0 required')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return WorkerThreads;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// check whether Worker is supported by the browser
|
|
23
|
-
function ensureWebWorker() {
|
|
24
|
-
// Workaround for a bug in PhantomJS (Or QtWebkit): https://github.com/ariya/phantomjs/issues/14534
|
|
25
|
-
if (typeof Worker !== 'function' && (typeof Worker !== 'object' || typeof Worker.prototype.constructor !== 'function')) {
|
|
26
|
-
throw new Error('WorkerPool: Web Workers not supported');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function tryRequireWorkerThreads() {
|
|
31
|
-
try {
|
|
32
|
-
return require('worker_threads');
|
|
33
|
-
} catch(error) {
|
|
34
|
-
if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {
|
|
35
|
-
// no worker_threads available (old version of node.js)
|
|
36
|
-
return null;
|
|
37
|
-
} else {
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// get the default worker script
|
|
44
|
-
function getDefaultWorker() {
|
|
45
|
-
if (environment.platform === 'browser') {
|
|
46
|
-
// test whether the browser supports all features that we need
|
|
47
|
-
if (typeof Blob === 'undefined') {
|
|
48
|
-
throw new Error('Blob not supported by the browser');
|
|
49
|
-
}
|
|
50
|
-
if (!window.URL || typeof window.URL.createObjectURL !== 'function') {
|
|
51
|
-
throw new Error('URL.createObjectURL not supported by the browser');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// use embedded worker.js
|
|
55
|
-
var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});
|
|
56
|
-
return window.URL.createObjectURL(blob);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// use external worker.js in current directory
|
|
60
|
-
return __dirname + '/worker.js';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function setupWorker(script, options) {
|
|
65
|
-
if (options.workerType === 'web') { // browser only
|
|
66
|
-
ensureWebWorker();
|
|
67
|
-
return setupBrowserWorker(script, options.workerOpts, Worker);
|
|
68
|
-
} else if (options.workerType === 'thread') { // node.js only
|
|
69
|
-
WorkerThreads = ensureWorkerThreads();
|
|
70
|
-
return setupWorkerThreadWorker(script, WorkerThreads, options);
|
|
71
|
-
} else if (options.workerType === 'process' || !options.workerType) { // node.js only
|
|
72
|
-
return setupProcessWorker(script, resolveForkOptions(options), require('child_process'));
|
|
73
|
-
} else { // options.workerType === 'auto' or undefined
|
|
74
|
-
if (environment.platform === 'browser') {
|
|
75
|
-
ensureWebWorker();
|
|
76
|
-
return setupBrowserWorker(script, options.workerOpts, Worker);
|
|
77
|
-
}
|
|
78
|
-
else { // environment.platform === 'node'
|
|
79
|
-
var WorkerThreads = tryRequireWorkerThreads();
|
|
80
|
-
if (WorkerThreads) {
|
|
81
|
-
return setupWorkerThreadWorker(script, WorkerThreads, options);
|
|
82
|
-
} else {
|
|
83
|
-
return setupProcessWorker(script, resolveForkOptions(options), require('child_process'));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function setupBrowserWorker(script, workerOpts, Worker) {
|
|
90
|
-
// validate the options right before creating the worker (not when creating the pool)
|
|
91
|
-
validateOptions(workerOpts, workerOptsNames, 'workerOpts')
|
|
92
|
-
|
|
93
|
-
// create the web worker
|
|
94
|
-
var worker = new Worker(script, workerOpts);
|
|
95
|
-
|
|
96
|
-
worker.isBrowserWorker = true;
|
|
97
|
-
// add node.js API to the web worker
|
|
98
|
-
worker.on = function (event, callback) {
|
|
99
|
-
this.addEventListener(event, function (message) {
|
|
100
|
-
callback(message.data);
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
worker.send = function (message, transfer) {
|
|
104
|
-
this.postMessage(message, transfer);
|
|
105
|
-
};
|
|
106
|
-
return worker;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function setupWorkerThreadWorker(script, WorkerThreads, options) {
|
|
110
|
-
// validate the options right before creating the worker thread (not when creating the pool)
|
|
111
|
-
validateOptions(options?.workerThreadOpts, workerThreadOptsNames, 'workerThreadOpts')
|
|
112
|
-
|
|
113
|
-
var worker = new WorkerThreads.Worker(script, {
|
|
114
|
-
stdout: options?.emitStdStreams ?? false, // pipe worker.STDOUT to process.STDOUT if not requested
|
|
115
|
-
stderr: options?.emitStdStreams ?? false, // pipe worker.STDERR to process.STDERR if not requested
|
|
116
|
-
...options?.workerThreadOpts
|
|
117
|
-
});
|
|
118
|
-
worker.isWorkerThread = true;
|
|
119
|
-
worker.send = function(message, transfer) {
|
|
120
|
-
this.postMessage(message, transfer);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
worker.kill = function() {
|
|
124
|
-
this.terminate();
|
|
125
|
-
return true;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
worker.disconnect = function() {
|
|
129
|
-
this.terminate();
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
if (options?.emitStdStreams) {
|
|
133
|
-
worker.stdout.on('data', (data) => worker.emit("stdout", data))
|
|
134
|
-
worker.stderr.on('data', (data) => worker.emit("stderr", data))
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return worker;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function setupProcessWorker(script, options, child_process) {
|
|
141
|
-
// validate the options right before creating the child process (not when creating the pool)
|
|
142
|
-
validateOptions(options.forkOpts, forkOptsNames, 'forkOpts')
|
|
143
|
-
|
|
144
|
-
// no WorkerThreads, fallback to sub-process based workers
|
|
145
|
-
var worker = child_process.fork(
|
|
146
|
-
script,
|
|
147
|
-
options.forkArgs,
|
|
148
|
-
options.forkOpts
|
|
149
|
-
);
|
|
150
|
-
|
|
151
|
-
// ignore transfer argument since it is not supported by process
|
|
152
|
-
var send = worker.send;
|
|
153
|
-
worker.send = function (message) {
|
|
154
|
-
return send.call(worker, message);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
if (options.emitStdStreams) {
|
|
158
|
-
worker.stdout.on('data', (data) => worker.emit("stdout", data))
|
|
159
|
-
worker.stderr.on('data', (data) => worker.emit("stderr", data))
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
worker.isChildProcess = true;
|
|
163
|
-
return worker;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// add debug flags to child processes if the node inspector is active
|
|
167
|
-
function resolveForkOptions(opts) {
|
|
168
|
-
opts = opts || {};
|
|
169
|
-
|
|
170
|
-
var processExecArgv = process.execArgv.join(' ');
|
|
171
|
-
var inspectorActive = processExecArgv.indexOf('--inspect') !== -1;
|
|
172
|
-
var debugBrk = processExecArgv.indexOf('--debug-brk') !== -1;
|
|
173
|
-
|
|
174
|
-
var execArgv = [];
|
|
175
|
-
if (inspectorActive) {
|
|
176
|
-
execArgv.push('--inspect=' + opts.debugPort);
|
|
177
|
-
|
|
178
|
-
if (debugBrk) {
|
|
179
|
-
execArgv.push('--debug-brk');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
process.execArgv.forEach(function(arg) {
|
|
184
|
-
if (arg.indexOf('--max-old-space-size') > -1) {
|
|
185
|
-
execArgv.push(arg)
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
return Object.assign({}, opts, {
|
|
190
|
-
forkArgs: opts.forkArgs,
|
|
191
|
-
forkOpts: Object.assign({}, opts.forkOpts, {
|
|
192
|
-
execArgv: (opts.forkOpts && opts.forkOpts.execArgv || [])
|
|
193
|
-
.concat(execArgv),
|
|
194
|
-
stdio: opts.emitStdStreams ? "pipe": undefined
|
|
195
|
-
})
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Converts a serialized error to Error
|
|
201
|
-
* @param {Object} obj Error that has been serialized and parsed to object
|
|
202
|
-
* @return {Error} The equivalent Error.
|
|
203
|
-
*/
|
|
204
|
-
function objectToError (obj) {
|
|
205
|
-
var temp = new Error('')
|
|
206
|
-
var props = Object.keys(obj)
|
|
207
|
-
|
|
208
|
-
for (var i = 0; i < props.length; i++) {
|
|
209
|
-
temp[props[i]] = obj[props[i]]
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
return temp
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function handleEmittedStdPayload(handler, payload) {
|
|
216
|
-
// TODO: refactor if parallel task execution gets added
|
|
217
|
-
if (Object.keys(handler.processing).length !== 1) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
var task = Object.values(handler.processing)[0]
|
|
221
|
-
if (task.options && typeof task.options.on === 'function') {
|
|
222
|
-
task.options.on(payload);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* A WorkerHandler controls a single worker. This worker can be a child process
|
|
228
|
-
* on node.js or a WebWorker in a browser environment.
|
|
229
|
-
* @param {String} [script] If no script is provided, a default worker with a
|
|
230
|
-
* function run will be created.
|
|
231
|
-
* @param {import('./types.js').WorkerPoolOptions} [_options] See docs
|
|
232
|
-
* @constructor
|
|
233
|
-
*/
|
|
234
|
-
function WorkerHandler(script, _options) {
|
|
235
|
-
var me = this;
|
|
236
|
-
var options = _options || {};
|
|
237
|
-
|
|
238
|
-
this.script = script || getDefaultWorker();
|
|
239
|
-
this.worker = setupWorker(this.script, options);
|
|
240
|
-
this.debugPort = options.debugPort;
|
|
241
|
-
this.forkOpts = options.forkOpts;
|
|
242
|
-
this.forkArgs = options.forkArgs;
|
|
243
|
-
this.workerOpts = options.workerOpts;
|
|
244
|
-
this.workerThreadOpts = options.workerThreadOpts
|
|
245
|
-
this.workerTerminateTimeout = options.workerTerminateTimeout;
|
|
246
|
-
|
|
247
|
-
// The ready message is only sent if the worker.add method is called (And the default script is not used)
|
|
248
|
-
if (!script) {
|
|
249
|
-
this.worker.ready = true;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// queue for requests that are received before the worker is ready
|
|
253
|
-
this.requestQueue = [];
|
|
254
|
-
|
|
255
|
-
this.worker.on("stdout", function (data) {
|
|
256
|
-
handleEmittedStdPayload(me, {"stdout": data.toString()})
|
|
257
|
-
})
|
|
258
|
-
this.worker.on("stderr", function (data) {
|
|
259
|
-
handleEmittedStdPayload(me, {"stderr": data.toString()})
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
this.worker.on('message', function (response) {
|
|
263
|
-
if (me.terminated) {
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
if (typeof response === 'string' && response === 'ready') {
|
|
267
|
-
me.worker.ready = true;
|
|
268
|
-
dispatchQueuedRequests();
|
|
269
|
-
} else {
|
|
270
|
-
// find the task from the processing queue, and run the tasks callback
|
|
271
|
-
var id = response.id;
|
|
272
|
-
var task = me.processing[id];
|
|
273
|
-
if (task !== undefined) {
|
|
274
|
-
if (response.isEvent) {
|
|
275
|
-
if (task.options && typeof task.options.on === 'function') {
|
|
276
|
-
task.options.on(response.payload);
|
|
277
|
-
}
|
|
278
|
-
} else {
|
|
279
|
-
// remove the task from the queue
|
|
280
|
-
delete me.processing[id];
|
|
281
|
-
|
|
282
|
-
// test if we need to terminate
|
|
283
|
-
if (me.terminating === true) {
|
|
284
|
-
// complete worker termination if all tasks are finished
|
|
285
|
-
me.terminate();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// resolve the task's promise
|
|
289
|
-
if (response.error) {
|
|
290
|
-
task.resolver.reject(objectToError(response.error));
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
task.resolver.resolve(response.result);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
// reject all running tasks on worker error
|
|
301
|
-
function onError(error) {
|
|
302
|
-
me.terminated = true;
|
|
303
|
-
|
|
304
|
-
for (var id in me.processing) {
|
|
305
|
-
if (me.processing[id] !== undefined) {
|
|
306
|
-
me.processing[id].resolver.reject(error);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
me.processing = Object.create(null);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// send all queued requests to worker
|
|
313
|
-
function dispatchQueuedRequests()
|
|
314
|
-
{
|
|
315
|
-
for(const request of me.requestQueue.splice(0)) {
|
|
316
|
-
me.worker.send(request.message, request.transfer);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
var worker = this.worker;
|
|
321
|
-
// listen for worker messages error and exit
|
|
322
|
-
this.worker.on('error', onError);
|
|
323
|
-
this.worker.on('exit', function (exitCode, signalCode) {
|
|
324
|
-
var message = 'Workerpool Worker terminated Unexpectedly\n';
|
|
325
|
-
|
|
326
|
-
message += ' exitCode: `' + exitCode + '`\n';
|
|
327
|
-
message += ' signalCode: `' + signalCode + '`\n';
|
|
328
|
-
|
|
329
|
-
message += ' workerpool.script: `' + me.script + '`\n';
|
|
330
|
-
message += ' spawnArgs: `' + worker.spawnargs + '`\n';
|
|
331
|
-
message += ' spawnfile: `' + worker.spawnfile + '`\n'
|
|
332
|
-
|
|
333
|
-
message += ' stdout: `' + worker.stdout + '`\n'
|
|
334
|
-
message += ' stderr: `' + worker.stderr + '`\n'
|
|
335
|
-
|
|
336
|
-
onError(new Error(message));
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
this.processing = Object.create(null); // queue with tasks currently in progress
|
|
340
|
-
|
|
341
|
-
this.terminating = false;
|
|
342
|
-
this.terminated = false;
|
|
343
|
-
this.cleaning = false;
|
|
344
|
-
this.terminationHandler = null;
|
|
345
|
-
this.lastId = 0;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Get a list with methods available on the worker.
|
|
350
|
-
* @return {Promise.<String[], Error>} methods
|
|
351
|
-
*/
|
|
352
|
-
WorkerHandler.prototype.methods = function () {
|
|
353
|
-
return this.exec('methods');
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Execute a method with given parameters on the worker
|
|
358
|
-
* @param {String} method
|
|
359
|
-
* @param {Array} [params]
|
|
360
|
-
* @param {{resolve: Function, reject: Function}} [resolver]
|
|
361
|
-
* @param {import('./types.js').ExecOptions} [options]
|
|
362
|
-
* @return {Promise.<*, Error>} result
|
|
363
|
-
*/
|
|
364
|
-
WorkerHandler.prototype.exec = function(method, params, resolver, options) {
|
|
365
|
-
if (!resolver) {
|
|
366
|
-
resolver = Promise.defer();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// generate a unique id for the task
|
|
370
|
-
var id = ++this.lastId;
|
|
371
|
-
|
|
372
|
-
// register a new task as being in progress
|
|
373
|
-
this.processing[id] = {
|
|
374
|
-
id: id,
|
|
375
|
-
resolver: resolver,
|
|
376
|
-
options: options
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
// build a JSON-RPC request
|
|
380
|
-
var request = {
|
|
381
|
-
message: {
|
|
382
|
-
id: id,
|
|
383
|
-
method: method,
|
|
384
|
-
params: params
|
|
385
|
-
},
|
|
386
|
-
transfer: options && options.transfer
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
if (this.terminated) {
|
|
390
|
-
resolver.reject(new Error('Worker is terminated'));
|
|
391
|
-
} else if (this.worker.ready) {
|
|
392
|
-
// send the request to the worker
|
|
393
|
-
this.worker.send(request.message, request.transfer);
|
|
394
|
-
} else {
|
|
395
|
-
this.requestQueue.push(request);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// on cancellation, force the worker to terminate
|
|
399
|
-
var me = this;
|
|
400
|
-
return resolver.promise.catch(function (error) {
|
|
401
|
-
if (error instanceof Promise.CancellationError || error instanceof Promise.TimeoutError) {
|
|
402
|
-
// remove this task from the queue. It is already rejected (hence this
|
|
403
|
-
// catch event), and else it will be rejected again when terminating
|
|
404
|
-
delete me.processing[id];
|
|
405
|
-
|
|
406
|
-
// terminate worker
|
|
407
|
-
return me.terminateAndNotify(true)
|
|
408
|
-
.then(function() {
|
|
409
|
-
throw error;
|
|
410
|
-
}, function(err) {
|
|
411
|
-
throw err;
|
|
412
|
-
});
|
|
413
|
-
} else {
|
|
414
|
-
throw error;
|
|
415
|
-
}
|
|
416
|
-
})
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Test whether the worker is processing any tasks or cleaning up before termination.
|
|
421
|
-
* @return {boolean} Returns true if the worker is busy
|
|
422
|
-
*/
|
|
423
|
-
WorkerHandler.prototype.busy = function () {
|
|
424
|
-
return this.cleaning || Object.keys(this.processing).length > 0;
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Terminate the worker.
|
|
429
|
-
* @param {boolean} [force=false] If false (default), the worker is terminated
|
|
430
|
-
* after finishing all tasks currently in
|
|
431
|
-
* progress. If true, the worker will be
|
|
432
|
-
* terminated immediately.
|
|
433
|
-
* @param {function} [callback=null] If provided, will be called when process terminates.
|
|
434
|
-
*/
|
|
435
|
-
WorkerHandler.prototype.terminate = function (force, callback) {
|
|
436
|
-
var me = this;
|
|
437
|
-
if (force) {
|
|
438
|
-
// cancel all tasks in progress
|
|
439
|
-
for (var id in this.processing) {
|
|
440
|
-
if (this.processing[id] !== undefined) {
|
|
441
|
-
this.processing[id].resolver.reject(new Error('Worker terminated'));
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
this.processing = Object.create(null);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (typeof callback === 'function') {
|
|
448
|
-
this.terminationHandler = callback;
|
|
449
|
-
}
|
|
450
|
-
if (!this.busy()) {
|
|
451
|
-
// all tasks are finished. kill the worker
|
|
452
|
-
var cleanup = function(err) {
|
|
453
|
-
me.terminated = true;
|
|
454
|
-
me.cleaning = false;
|
|
455
|
-
if (me.worker != null && me.worker.removeAllListeners) {
|
|
456
|
-
// removeAllListeners is only available for child_process
|
|
457
|
-
me.worker.removeAllListeners('message');
|
|
458
|
-
}
|
|
459
|
-
me.worker = null;
|
|
460
|
-
me.terminating = false;
|
|
461
|
-
if (me.terminationHandler) {
|
|
462
|
-
me.terminationHandler(err, me);
|
|
463
|
-
} else if (err) {
|
|
464
|
-
throw err;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if (this.worker) {
|
|
469
|
-
if (typeof this.worker.kill === 'function') {
|
|
470
|
-
if (this.worker.killed) {
|
|
471
|
-
cleanup(new Error('worker already killed!'));
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// child process and worker threads
|
|
476
|
-
var cleanExitTimeout = setTimeout(function() {
|
|
477
|
-
if (me.worker) {
|
|
478
|
-
me.worker.kill();
|
|
479
|
-
}
|
|
480
|
-
}, this.workerTerminateTimeout);
|
|
481
|
-
|
|
482
|
-
this.worker.once('exit', function() {
|
|
483
|
-
clearTimeout(cleanExitTimeout);
|
|
484
|
-
if (me.worker) {
|
|
485
|
-
me.worker.killed = true;
|
|
486
|
-
}
|
|
487
|
-
cleanup();
|
|
488
|
-
});
|
|
489
|
-
|
|
490
|
-
if (this.worker.ready) {
|
|
491
|
-
this.worker.send(TERMINATE_METHOD_ID);
|
|
492
|
-
} else {
|
|
493
|
-
this.requestQueue.push({ message: TERMINATE_METHOD_ID });
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
// mark that the worker is cleaning up resources
|
|
497
|
-
// to prevent new tasks from being executed
|
|
498
|
-
this.cleaning = true;
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
else if (typeof this.worker.terminate === 'function') {
|
|
502
|
-
this.worker.terminate(); // web worker
|
|
503
|
-
this.worker.killed = true;
|
|
504
|
-
}
|
|
505
|
-
else {
|
|
506
|
-
throw new Error('Failed to terminate worker');
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
cleanup();
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
// we can't terminate immediately, there are still tasks being executed
|
|
513
|
-
this.terminating = true;
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Terminate the worker, returning a Promise that resolves when the termination has been done.
|
|
519
|
-
* @param {boolean} [force=false] If false (default), the worker is terminated
|
|
520
|
-
* after finishing all tasks currently in
|
|
521
|
-
* progress. If true, the worker will be
|
|
522
|
-
* terminated immediately.
|
|
523
|
-
* @param {number} [timeout] If provided and non-zero, worker termination promise will be rejected
|
|
524
|
-
* after timeout if worker process has not been terminated.
|
|
525
|
-
* @return {Promise.<WorkerHandler, Error>}
|
|
526
|
-
*/
|
|
527
|
-
WorkerHandler.prototype.terminateAndNotify = function (force, timeout) {
|
|
528
|
-
var resolver = Promise.defer();
|
|
529
|
-
if (timeout) {
|
|
530
|
-
resolver.promise.timeout(timeout);
|
|
531
|
-
}
|
|
532
|
-
this.terminate(force, function(err, worker) {
|
|
533
|
-
if (err) {
|
|
534
|
-
resolver.reject(err);
|
|
535
|
-
} else {
|
|
536
|
-
resolver.resolve(worker);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
return resolver.promise;
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
module.exports = WorkerHandler;
|
|
543
|
-
module.exports._tryRequireWorkerThreads = tryRequireWorkerThreads;
|
|
544
|
-
module.exports._setupProcessWorker = setupProcessWorker;
|
|
545
|
-
module.exports._setupBrowserWorker = setupBrowserWorker;
|
|
546
|
-
module.exports._setupWorkerThreadWorker = setupWorkerThreadWorker;
|
|
547
|
-
module.exports.ensureWorkerThreads = ensureWorkerThreads;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var MAX_PORTS = 65535;
|
|
4
|
-
module.exports = DebugPortAllocator;
|
|
5
|
-
function DebugPortAllocator() {
|
|
6
|
-
this.ports = Object.create(null);
|
|
7
|
-
this.length = 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
DebugPortAllocator.prototype.nextAvailableStartingAt = function(starting) {
|
|
11
|
-
while (this.ports[starting] === true) {
|
|
12
|
-
starting++;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (starting >= MAX_PORTS) {
|
|
16
|
-
throw new Error('WorkerPool debug port limit reached: ' + starting + '>= ' + MAX_PORTS );
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
this.ports[starting] = true;
|
|
20
|
-
this.length++;
|
|
21
|
-
return starting;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
DebugPortAllocator.prototype.releasePort = function(port) {
|
|
25
|
-
delete this.ports[port];
|
|
26
|
-
this.length--;
|
|
27
|
-
};
|
|
28
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// source: https://github.com/flexdinesh/browser-or-node
|
|
3
|
-
// source: https://github.com/mozilla/pdf.js/blob/7ea0e40e588864cd938d1836ec61f1928d3877d3/src/shared/util.js#L24
|
|
4
|
-
var isNode = function (nodeProcess) {
|
|
5
|
-
return (
|
|
6
|
-
typeof nodeProcess !== 'undefined' &&
|
|
7
|
-
nodeProcess.versions != null &&
|
|
8
|
-
nodeProcess.versions.node != null &&
|
|
9
|
-
nodeProcess + '' === '[object process]'
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
module.exports.isNode = isNode
|
|
13
|
-
|
|
14
|
-
// determines the JavaScript platform: browser or node
|
|
15
|
-
module.exports.platform = typeof process !== 'undefined' && isNode(process)
|
|
16
|
-
? 'node'
|
|
17
|
-
: 'browser';
|
|
18
|
-
|
|
19
|
-
// determines whether the code is running in main thread or not
|
|
20
|
-
// note that in node.js we have to check both worker_thread and child_process
|
|
21
|
-
var worker_threads = module.exports.platform === 'node' && require('worker_threads');
|
|
22
|
-
module.exports.isMainThread = module.exports.platform === 'node'
|
|
23
|
-
? ((!worker_threads || worker_threads.isMainThread) && !process.connected)
|
|
24
|
-
: typeof Window !== 'undefined';
|
|
25
|
-
|
|
26
|
-
// determines the number of cpus available
|
|
27
|
-
module.exports.cpus = module.exports.platform === 'browser'
|
|
28
|
-
? self.navigator.hardwareConcurrency
|
|
29
|
-
: require('os').cpus().length;
|
|
30
|
-
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* embeddedWorker.js contains an embedded version of worker.js.
|
|
3
|
-
* This file is automatically generated,
|
|
4
|
-
* changes made in this file will be overwritten.
|
|
5
|
-
*/
|
|
6
|
-
module.exports = "!function(e,n){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=n():\"function\"==typeof define&&define.amd?define(n):(e=\"undefined\"!=typeof globalThis?globalThis:e||self).worker=n()}(this,(function(){\"use strict\";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,\"default\")?e.default:e}var n={};var t=function(e,n){this.message=e,this.transfer=n};return function(e){var n=t,r={exit:function(){}};if(\"undefined\"!=typeof self&&\"function\"==typeof postMessage&&\"function\"==typeof addEventListener)r.on=function(e,n){addEventListener(e,(function(e){n(e.data)}))},r.send=function(e){postMessage(e)};else{if(\"undefined\"==typeof process)throw new Error(\"Script must be executed as a worker\");var o;try{o=require(\"worker_threads\")}catch(e){if(\"object\"!=typeof e||null===e||\"MODULE_NOT_FOUND\"!==e.code)throw e}if(o&&null!==o.parentPort){var i=o.parentPort;r.send=i.postMessage.bind(i),r.on=i.on.bind(i),r.exit=process.exit.bind(process)}else r.on=process.on.bind(process),r.send=function(e){process.send(e)},r.on(\"disconnect\",(function(){process.exit(1)})),r.exit=process.exit.bind(process)}function s(e){return Object.getOwnPropertyNames(e).reduce((function(n,t){return Object.defineProperty(n,t,{value:e[t],enumerable:!0})}),{})}function d(e){return e&&\"function\"==typeof e.then&&\"function\"==typeof e.catch}r.methods={},r.methods.run=function(e,n){var t=new Function(\"return (\"+e+\").apply(null, arguments);\");return t.apply(t,n)},r.methods.methods=function(){return Object.keys(r.methods)},r.terminationHandler=void 0,r.cleanupAndExit=function(e){var n=function(){r.exit(e)};if(!r.terminationHandler)return n();var t=r.terminationHandler(e);d(t)?t.then(n,n):n()};var u=null;r.on(\"message\",(function(e){if(\"__workerpool-terminate__\"===e)return r.cleanupAndExit(0);try{var t=r.methods[e.method];if(!t)throw new Error('Unknown method \"'+e.method+'\"');u=e.id;var o=t.apply(t,e.params);d(o)?o.then((function(t){t instanceof n?r.send({id:e.id,result:t.message,error:null},t.transfer):r.send({id:e.id,result:t,error:null}),u=null})).catch((function(n){r.send({id:e.id,result:null,error:s(n)}),u=null})):(o instanceof n?r.send({id:e.id,result:o.message,error:null},o.transfer):r.send({id:e.id,result:o,error:null}),u=null)}catch(n){r.send({id:e.id,result:null,error:s(n)})}})),r.register=function(e,n){if(e)for(var t in e)e.hasOwnProperty(t)&&(r.methods[t]=e[t]);n&&(r.terminationHandler=n.onTerminate),r.send(\"ready\")},r.emit=function(e){if(u){if(e instanceof n)return void r.send({id:u,isEvent:!0,payload:e.message},e.transfer);r.send({id:u,isEvent:!0,payload:e})}},e.add=r.register,e.emit=r.emit}(n),e(n)}));\n//# sourceMappingURL=worker.min.js.map\n";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* workerpool.js
|
|
3
|
-
* https://github.com/josdejong/workerpool
|
|
4
|
-
*
|
|
5
|
-
* Offload tasks to a pool of workers on node.js and in the browser.
|
|
6
|
-
*
|
|
7
|
-
* @version @@version
|
|
8
|
-
* @date @@date
|
|
9
|
-
*
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright (C) 2014-2022 Jos de Jong <wjosdejong@gmail.com>
|
|
12
|
-
*
|
|
13
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
14
|
-
* use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at
|
|
16
|
-
*
|
|
17
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
-
*
|
|
19
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
21
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
22
|
-
* License for the specific language governing permissions and limitations under
|
|
23
|
-
* the License.
|
|
24
|
-
*/
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const {platform, isMainThread, cpus} = require('./environment');
|
|
2
|
-
|
|
3
|
-
/** @typedef {import("./Pool")} Pool */
|
|
4
|
-
/** @typedef {import("./types.js").WorkerPoolOptions} WorkerPoolOptions */
|
|
5
|
-
/** @typedef {import("./types.js").WorkerRegisterOptions} WorkerRegisterOptions */
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @template { { [k: string]: (...args: any[]) => any } } T
|
|
9
|
-
* @typedef {import('./types.js').Proxy<T>} Proxy<T>
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @overload
|
|
14
|
-
* Create a new worker pool
|
|
15
|
-
* @param {WorkerPoolOptions} [script]
|
|
16
|
-
* @returns {Pool} pool
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* @overload
|
|
20
|
-
* Create a new worker pool
|
|
21
|
-
* @param {string} [script]
|
|
22
|
-
* @param {WorkerPoolOptions} [options]
|
|
23
|
-
* @returns {Pool} pool
|
|
24
|
-
*/
|
|
25
|
-
function pool(script, options) {
|
|
26
|
-
var Pool = require('./Pool');
|
|
27
|
-
|
|
28
|
-
return new Pool(script, options);
|
|
29
|
-
};
|
|
30
|
-
exports.pool = pool;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Create a worker and optionally register a set of methods to the worker.
|
|
34
|
-
* @param {{ [k: string]: (...args: any[]) => any }} [methods]
|
|
35
|
-
* @param {WorkerRegisterOptions} [options]
|
|
36
|
-
*/
|
|
37
|
-
function worker(methods, options) {
|
|
38
|
-
var worker = require('./worker');
|
|
39
|
-
worker.add(methods, options);
|
|
40
|
-
};
|
|
41
|
-
exports.worker = worker;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Sends an event to the parent worker pool.
|
|
45
|
-
* @param {any} payload
|
|
46
|
-
*/
|
|
47
|
-
function workerEmit(payload) {
|
|
48
|
-
var worker = require('./worker');
|
|
49
|
-
worker.emit(payload);
|
|
50
|
-
};
|
|
51
|
-
exports.workerEmit = workerEmit;
|
|
52
|
-
|
|
53
|
-
const {Promise} = require('./Promise');
|
|
54
|
-
exports.Promise = Promise;
|
|
55
|
-
|
|
56
|
-
exports.Transfer = require('./transfer');
|
|
57
|
-
|
|
58
|
-
exports.platform = platform;
|
|
59
|
-
exports.isMainThread = isMainThread;
|
|
60
|
-
exports.cpus = cpus;
|