die heldin script add
This commit is contained in:
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
1
node_modules/.bin/esbuild
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild
|
||||
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
1
node_modules/.bin/tsc
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsc
|
||||
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
1
node_modules/.bin/tsserver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../typescript/bin/tsserver
|
||||
1
node_modules/.bin/tsx
generated
vendored
Symbolic link
1
node_modules/.bin/tsx
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../tsx/dist/cli.mjs
|
||||
455
node_modules/.package-lock.json
generated
vendored
Normal file
455
node_modules/.package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,455 @@
|
||||
{
|
||||
"name": "dieheldin-export",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.27.3",
|
||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz",
|
||||
"integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@stomp/stompjs": {
|
||||
"version": "6.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@stomp/stompjs/-/stompjs-6.1.2.tgz",
|
||||
"integrity": "sha512-FHDTrIFM5Ospi4L3Xhj6v2+NzCVAeNDcBe95YjUWhWiRMrBF6uN3I7AUOlRgT6jU/2WQvvYK8ZaIxFfxFp+uHQ=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "25.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.0.tgz",
|
||||
"integrity": "sha512-4K3bqJpXpqfg2XKGK9bpDTc6xO/xoUP/RBWS7AtRMug6zZFaRekiLzjVtAoZMquxoAbzBvy5nxQ7veS5eYzf8A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~7.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "0.21.4",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
|
||||
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/axios-auth-refresh": {
|
||||
"version": "3.3.6",
|
||||
"resolved": "https://registry.npmjs.org/axios-auth-refresh/-/axios-auth-refresh-3.3.6.tgz",
|
||||
"integrity": "sha512-2CeBUce/SxIfFxow5/n8vApJ97yYF6qoV4gh1UrswT7aEOnlOdBLxxyhOI4IaxGs6BY0l8YujU2jlc4aCmK17Q==",
|
||||
"peerDependencies": {
|
||||
"axios": ">= 0.18 < 0.19.0 || >= 0.19.1"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
||||
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
"has-tostringtag": "^1.0.2",
|
||||
"hasown": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.27.3",
|
||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz",
|
||||
"integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.27.3",
|
||||
"@esbuild/android-arm": "0.27.3",
|
||||
"@esbuild/android-arm64": "0.27.3",
|
||||
"@esbuild/android-x64": "0.27.3",
|
||||
"@esbuild/darwin-arm64": "0.27.3",
|
||||
"@esbuild/darwin-x64": "0.27.3",
|
||||
"@esbuild/freebsd-arm64": "0.27.3",
|
||||
"@esbuild/freebsd-x64": "0.27.3",
|
||||
"@esbuild/linux-arm": "0.27.3",
|
||||
"@esbuild/linux-arm64": "0.27.3",
|
||||
"@esbuild/linux-ia32": "0.27.3",
|
||||
"@esbuild/linux-loong64": "0.27.3",
|
||||
"@esbuild/linux-mips64el": "0.27.3",
|
||||
"@esbuild/linux-ppc64": "0.27.3",
|
||||
"@esbuild/linux-riscv64": "0.27.3",
|
||||
"@esbuild/linux-s390x": "0.27.3",
|
||||
"@esbuild/linux-x64": "0.27.3",
|
||||
"@esbuild/netbsd-arm64": "0.27.3",
|
||||
"@esbuild/netbsd-x64": "0.27.3",
|
||||
"@esbuild/openbsd-arm64": "0.27.3",
|
||||
"@esbuild/openbsd-x64": "0.27.3",
|
||||
"@esbuild/openharmony-arm64": "0.27.3",
|
||||
"@esbuild/sunos-x64": "0.27.3",
|
||||
"@esbuild/win32-arm64": "0.27.3",
|
||||
"@esbuild/win32-ia32": "0.27.3",
|
||||
"@esbuild/win32-x64": "0.27.3"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.11",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
|
||||
"integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/get-tsconfig": {
|
||||
"version": "4.13.6",
|
||||
"resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.6.tgz",
|
||||
"integrity": "sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"resolve-pkg-maps": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-tostringtag": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash": {
|
||||
"version": "4.17.23",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
||||
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w=="
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"node_modules/openmagicline": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/openmagicline/-/openmagicline-1.1.0.tgz",
|
||||
"integrity": "sha512-zAARHNrjvtDyNG+i8nlroEy6wcsCfEpR1RSNpgCTFDbsZwbNlqA2T8TvxGL0l1rz35ibNttGYaf95LxSjqwI5w==",
|
||||
"dependencies": {
|
||||
"@stomp/stompjs": "^6.1.0",
|
||||
"axios": "^0.21.1",
|
||||
"axios-auth-refresh": "^3.3.4",
|
||||
"debug": "^4.3.1",
|
||||
"form-data": "^4.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"ws": "^7.5.3"
|
||||
}
|
||||
},
|
||||
"node_modules/resolve-pkg-maps": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz",
|
||||
"integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==",
|
||||
"dev": true,
|
||||
"funding": {
|
||||
"url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/tsx": {
|
||||
"version": "4.21.0",
|
||||
"resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz",
|
||||
"integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"esbuild": "~0.27.0",
|
||||
"get-tsconfig": "^4.7.5"
|
||||
},
|
||||
"bin": {
|
||||
"tsx": "dist/cli.mjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"fsevents": "~2.3.3"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.18.2",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
|
||||
"integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "7.5.10",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
||||
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
||||
"engines": {
|
||||
"node": ">=8.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
node_modules/@esbuild/linux-x64/README.md
generated
vendored
Normal file
3
node_modules/@esbuild/linux-x64/README.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is the Linux 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
||||
BIN
node_modules/@esbuild/linux-x64/bin/esbuild
generated
vendored
Executable file
BIN
node_modules/@esbuild/linux-x64/bin/esbuild
generated
vendored
Executable file
Binary file not shown.
20
node_modules/@esbuild/linux-x64/package.json
generated
vendored
Normal file
20
node_modules/@esbuild/linux-x64/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@esbuild/linux-x64",
|
||||
"version": "0.27.3",
|
||||
"description": "The Linux 64-bit binary for esbuild, a JavaScript bundler.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/evanw/esbuild.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"preferUnplugged": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
202
node_modules/@stomp/stompjs/LICENSE
generated
vendored
Normal file
202
node_modules/@stomp/stompjs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018-2020 Deepak Kumar <deepak@kreatio.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
89
node_modules/@stomp/stompjs/README.md
generated
vendored
Normal file
89
node_modules/@stomp/stompjs/README.md
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
# STOMP.js
|
||||
|
||||
[](https://travis-ci.org/stomp-js/stompjs)
|
||||
|
||||
This library provides a STOMP over WebSocket client for Web browser and node.js applications.
|
||||
|
||||
# Introduction
|
||||
|
||||
This repository is for version 5 and above of this library.
|
||||
Lower versions are not supported any longer.
|
||||
|
||||
This library allows you to connect to a STOMP broker over WebSocket. This library
|
||||
supports complete STOMP specifications including all current protocol variants. Most
|
||||
popular messaging brokers support STOMP and STOMP over WebSockets either natively
|
||||
or using plugins.
|
||||
|
||||
In general JavaScript engines in browsers are not friendly to binary protocols,
|
||||
so using STOMP is a good option because it is a text-oriented protocol.
|
||||
|
||||
This library has its roots in a version released by [Jeff Mesnil](http://jmesnil.net/).
|
||||
|
||||
## Current Status
|
||||
|
||||
Version 5 of this library has been bottom-up rewritten using TypeScript (versions 3/4
|
||||
use CoffeeScript). The code has substantially changed, so, while there is a compatibility
|
||||
mode, you might need to update your code.
|
||||
|
||||
This library is feature complete and has been used in production for many years. It
|
||||
is actively maintained. You are welcome to file issues and submit pull requests.
|
||||
|
||||
## Getting started
|
||||
|
||||
The API documentation is hosted as GitHub pages for the entire StompJS family of libraries.
|
||||
You may head straight to the https://stomp-js.github.io/api-docs/latest/
|
||||
|
||||
This library comes with detailed usage instructions. Please find it at
|
||||
[Usage instructions](https://stomp-js.github.io/guide/stompjs/using-stompjs-v5.html).
|
||||
Check out other guides at https://stomp-js.github.io/.
|
||||
|
||||
There are quite detailed API documentation,
|
||||
you should start at https://stomp-js.github.io/api-docs/latest/classes/Client.html.
|
||||
|
||||
## Upgrading
|
||||
|
||||
if you were using an older version of this library, you would need to make changes
|
||||
to your code. Head to
|
||||
[Upgrading](https://stomp-js.github.io/#upgrading).
|
||||
|
||||
## Usage with RxJS
|
||||
|
||||
https://github.com/stomp-js/rx-stomp is based on this library and exposes the entire functionality
|
||||
offered by this library as RxJS Observables.
|
||||
|
||||
## Usage with Angular2+
|
||||
|
||||
https://github.com/stomp-js/ng2-stompjs is based on https://github.com/stomp-js/rx-stomp
|
||||
and exposes key classes as Angular Injectable Services.
|
||||
|
||||
## TypeScript definitions
|
||||
|
||||
The npm package includes TypeScript definitions, so there is no need no install it separately.
|
||||
|
||||
## Change-log
|
||||
|
||||
Please visit [Change Log](Change-log.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
If you want to understand the code, develop, or contribute. Please visit
|
||||
[How to contribute](Contribute.md).
|
||||
|
||||
## Authors
|
||||
|
||||
- [Jeff Mesnil](http://jmesnil.net/)
|
||||
- [Jeff Lindsay](http://github.com/progrium)
|
||||
- [Vanessa Williams](http://github.com/fridgebuzz)
|
||||
- [Deepak Kumar](https://github.com/kum-deepak)
|
||||
- [Astha Deep](https://github.com/astha183)
|
||||
- [Dillon Sellars](https://github.com/dillon-sellars)
|
||||
- [Jimi Charalampidis](https://github.com/jimic)
|
||||
- [Raul](https://github.com/rulonder)
|
||||
- [Dimitar Georgiev](https://github.com/iMitaka)
|
||||
- [Genadi](https://github.com/genadis)
|
||||
- [Bobohuochai](https://github.com/bobohuochai)
|
||||
- [Sailai](https://github.com/sailai)
|
||||
|
||||
## License
|
||||
|
||||
[License](LICENSE) - Apache-2.0
|
||||
2170
node_modules/@stomp/stompjs/bundles/stomp.umd.js
generated
vendored
Normal file
2170
node_modules/@stomp/stompjs/bundles/stomp.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@stomp/stompjs/bundles/stomp.umd.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/bundles/stomp.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@stomp/stompjs/bundles/stomp.umd.min.js
generated
vendored
Normal file
2
node_modules/@stomp/stompjs/bundles/stomp.umd.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@stomp/stompjs/bundles/stomp.umd.min.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/bundles/stomp.umd.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@stomp/stompjs/esm6/augment-websocket.d.ts
generated
vendored
Normal file
5
node_modules/@stomp/stompjs/esm6/augment-websocket.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { IStompSocket } from './types';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare function augmentWebsocket(webSocket: IStompSocket, debug: (msg: string) => void): void;
|
||||
26
node_modules/@stomp/stompjs/esm6/augment-websocket.js
generated
vendored
Normal file
26
node_modules/@stomp/stompjs/esm6/augment-websocket.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function augmentWebsocket(webSocket, debug) {
|
||||
webSocket.terminate = function () {
|
||||
const noOp = () => { };
|
||||
// set all callbacks to no op
|
||||
this.onerror = noOp;
|
||||
this.onmessage = noOp;
|
||||
this.onopen = noOp;
|
||||
const ts = new Date();
|
||||
const origOnClose = this.onclose;
|
||||
// Track delay in actual closure of the socket
|
||||
this.onclose = closeEvent => {
|
||||
const delay = new Date().getTime() - ts.getTime();
|
||||
debug(`Discarded socket closed after ${delay}ms, with code/reason: ${closeEvent.code}/${closeEvent.reason}`);
|
||||
};
|
||||
this.close();
|
||||
origOnClose.call(this, {
|
||||
code: 4001,
|
||||
reason: 'Heartbeat failure, discarding the socket',
|
||||
wasClean: false,
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=augment-websocket.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/augment-websocket.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/augment-websocket.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"augment-websocket.js","sourceRoot":"","sources":["../src/augment-websocket.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAuB,EACvB,KAA4B;IAE5B,SAAS,CAAC,SAAS,GAAG;QACpB,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEtB,6BAA6B;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QAEtB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC;QAEjC,8CAA8C;QAC9C,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,EAAE;YAC1B,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YAClD,KAAK,CACH,iCAAiC,KAAK,yBAAyB,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,CACtG,CAAC;QACJ,CAAC,CAAC;QAEF,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE;YACrB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,0CAA0C;YAClD,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
||||
11
node_modules/@stomp/stompjs/esm6/byte.d.ts
generated
vendored
Normal file
11
node_modules/@stomp/stompjs/esm6/byte.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Some byte values, used as per STOMP specifications.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare const BYTE: {
|
||||
LF: string;
|
||||
NULL: string;
|
||||
};
|
||||
14
node_modules/@stomp/stompjs/esm6/byte.js
generated
vendored
Normal file
14
node_modules/@stomp/stompjs/esm6/byte.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Some byte values, used as per STOMP specifications.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const BYTE = {
|
||||
// LINEFEED byte (octet 10)
|
||||
LF: '\x0A',
|
||||
// NULL byte (octet 0)
|
||||
NULL: '\x00',
|
||||
};
|
||||
//# sourceMappingURL=byte.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/byte.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/byte.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"byte.js","sourceRoot":"","sources":["../src/byte.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,2BAA2B;IAC3B,EAAE,EAAE,MAAM;IACV,sBAAsB;IACtB,IAAI,EAAE,MAAM;CACb,CAAC"}
|
||||
475
node_modules/@stomp/stompjs/esm6/client.d.ts
generated
vendored
Normal file
475
node_modules/@stomp/stompjs/esm6/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,475 @@
|
||||
import { ITransaction } from './i-transaction';
|
||||
import { StompConfig } from './stomp-config';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { StompSubscription } from './stomp-subscription';
|
||||
import { ActivationState, closeEventCallbackType, debugFnType, frameCallbackType, IPublishParams, IStompSocket, messageCallbackType, wsErrorCallbackType } from './types';
|
||||
import { Versions } from './versions';
|
||||
/**
|
||||
* STOMP Client Class.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare class Client {
|
||||
/**
|
||||
* The URL for the STOMP broker to connect to.
|
||||
* Typically like `"ws://broker.329broker.com:15674/ws"` or `"wss://broker.329broker.com:15674/ws"`.
|
||||
*
|
||||
* Only one of this or [Client#webSocketFactory]{@link Client#webSocketFactory} need to be set.
|
||||
* If both are set, [Client#webSocketFactory]{@link Client#webSocketFactory} will be used.
|
||||
*
|
||||
* If your environment does not support WebSockets natively, please refer to
|
||||
* [Polyfills]{@link https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/pollyfils-for-stompjs-v5.html}.
|
||||
*/
|
||||
brokerURL: string;
|
||||
/**
|
||||
* STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Try only versions 1.0 and 1.1
|
||||
* client.stompVersions = new Versions(['1.0', '1.1'])
|
||||
* ```
|
||||
*/
|
||||
stompVersions: Versions;
|
||||
/**
|
||||
* This function should return a WebSocket or a similar (e.g. SockJS) object.
|
||||
* If your environment does not support WebSockets natively, please refer to
|
||||
* [Polyfills]{@link https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/pollyfils-for-stompjs-v5.html}.
|
||||
* If your STOMP Broker supports WebSockets, prefer setting [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*
|
||||
* If both this and [Client#brokerURL]{@link Client#brokerURL} are set, this will be used.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // use a WebSocket
|
||||
* client.webSocketFactory= function () {
|
||||
* return new WebSocket("wss://broker.329broker.com:15674/ws");
|
||||
* };
|
||||
*
|
||||
* // Typical usage with SockJS
|
||||
* client.webSocketFactory= function () {
|
||||
* return new SockJS("http://broker.329broker.com/stomp");
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
webSocketFactory: () => IStompSocket;
|
||||
/**
|
||||
* Will retry if Stomp connection is not established in specified milliseconds.
|
||||
* Default 0, which implies wait for ever.
|
||||
*/
|
||||
connectionTimeout: number;
|
||||
private _connectionWatcher;
|
||||
/**
|
||||
* automatically reconnect with delay in milliseconds, set to 0 to disable.
|
||||
*/
|
||||
reconnectDelay: number;
|
||||
/**
|
||||
* Incoming heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
heartbeatIncoming: number;
|
||||
/**
|
||||
* Outgoing heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
heartbeatOutgoing: number;
|
||||
/**
|
||||
* This switches on a non standard behavior while sending WebSocket packets.
|
||||
* It splits larger (text) packets into chunks of [maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
|
||||
* Only Java Spring brokers seems to use this mode.
|
||||
*
|
||||
* WebSockets, by itself, split large (text) packets,
|
||||
* so it is not needed with a truly compliant STOMP/WebSocket broker.
|
||||
* Actually setting it for such broker will cause large messages to fail.
|
||||
*
|
||||
* `false` by default.
|
||||
*
|
||||
* Binary frames are never split.
|
||||
*/
|
||||
splitLargeFrames: boolean;
|
||||
/**
|
||||
* See [splitLargeFrames]{@link Client#splitLargeFrames}.
|
||||
* This has no effect if [splitLargeFrames]{@link Client#splitLargeFrames} is `false`.
|
||||
*/
|
||||
maxWebSocketChunkSize: number;
|
||||
/**
|
||||
* Usually the
|
||||
* [type of WebSocket frame]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send#Parameters}
|
||||
* is automatically decided by type of the payload.
|
||||
* Default is `false`, which should work with all compliant brokers.
|
||||
*
|
||||
* Set this flag to force binary frames.
|
||||
*/
|
||||
forceBinaryWSFrames: boolean;
|
||||
/**
|
||||
* A bug in ReactNative chops a string on occurrence of a NULL.
|
||||
* See issue [https://github.com/stomp-js/stompjs/issues/89]{@link https://github.com/stomp-js/stompjs/issues/89}.
|
||||
* This makes incoming WebSocket messages invalid STOMP packets.
|
||||
* Setting this flag attempts to reverse the damage by appending a NULL.
|
||||
* If the broker splits a large message into multiple WebSocket messages,
|
||||
* this flag will cause data loss and abnormal termination of connection.
|
||||
*
|
||||
* This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
|
||||
*/
|
||||
appendMissingNULLonIncoming: boolean;
|
||||
/**
|
||||
* Underlying WebSocket instance, READONLY.
|
||||
*/
|
||||
readonly webSocket: IStompSocket;
|
||||
/**
|
||||
* Connection headers, important keys - `login`, `passcode`, `host`.
|
||||
* Though STOMP 1.2 standard marks these keys to be present, check your broker documentation for
|
||||
* details specific to your broker.
|
||||
*/
|
||||
connectHeaders: StompHeaders;
|
||||
/**
|
||||
* Disconnection headers.
|
||||
*/
|
||||
disconnectHeaders: StompHeaders;
|
||||
private _disconnectHeaders;
|
||||
/**
|
||||
* This function will be called for any unhandled messages.
|
||||
* It is useful for receiving messages sent to RabbitMQ temporary queues.
|
||||
*
|
||||
* It can also get invoked with stray messages while the server is processing
|
||||
* a request to [Client#unsubscribe]{@link Client#unsubscribe}
|
||||
* from an endpoint.
|
||||
*
|
||||
* The actual {@link IMessage} will be passed as parameter to the callback.
|
||||
*/
|
||||
onUnhandledMessage: messageCallbackType;
|
||||
/**
|
||||
* STOMP brokers can be requested to notify when an operation is actually completed.
|
||||
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}. See
|
||||
* [Client#watchForReceipt]{@link Client#watchForReceipt} for examples.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
*/
|
||||
onUnhandledReceipt: frameCallbackType;
|
||||
/**
|
||||
* Will be invoked if {@link FrameImpl} of unknown type is received from the STOMP broker.
|
||||
*
|
||||
* The actual {@link IFrame} will be passed as parameter to the callback.
|
||||
*/
|
||||
onUnhandledFrame: frameCallbackType;
|
||||
/**
|
||||
* `true` if there is a active connection with STOMP Broker
|
||||
*/
|
||||
readonly connected: boolean;
|
||||
/**
|
||||
* Callback, invoked on before a connection connection to the STOMP broker.
|
||||
*
|
||||
* You can change options on the client, which will impact the immediate connect.
|
||||
* It is valid to call [Client#decativate]{@link Client#deactivate} in this callback.
|
||||
*
|
||||
* As of version 5.1, this callback can be
|
||||
* [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
|
||||
* (i.e., it can return a
|
||||
* [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)).
|
||||
* In that case connect will be called only after the Promise is resolved.
|
||||
* This can be used to reliably fetch credentials, access token etc. from some other service
|
||||
* in an asynchronous way.
|
||||
*/
|
||||
beforeConnect: () => void | Promise<void>;
|
||||
/**
|
||||
* Callback, invoked on every successful connection to the STOMP broker.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
* Sometimes clients will like to use headers from this frame.
|
||||
*/
|
||||
onConnect: frameCallbackType;
|
||||
/**
|
||||
* Callback, invoked on every successful disconnection from the STOMP broker. It will not be invoked if
|
||||
* the STOMP broker disconnected due to an error.
|
||||
*
|
||||
* The actual Receipt {@link FrameImpl} acknowledging the DISCONNECT will be passed as parameter to the callback.
|
||||
*
|
||||
* The way STOMP protocol is designed, the connection may close/terminate without the client
|
||||
* receiving the Receipt {@link FrameImpl} acknowledging the DISCONNECT.
|
||||
* You might find [Client#onWebSocketClose]{@link Client#onWebSocketClose} more appropriate to watch
|
||||
* STOMP broker disconnects.
|
||||
*/
|
||||
onDisconnect: frameCallbackType;
|
||||
/**
|
||||
* Callback, invoked on an ERROR frame received from the STOMP Broker.
|
||||
* A compliant STOMP Broker will close the connection after this type of frame.
|
||||
* Please check broker specific documentation for exact behavior.
|
||||
*
|
||||
* The actual {@link IFrame} will be passed as parameter to the callback.
|
||||
*/
|
||||
onStompError: frameCallbackType;
|
||||
/**
|
||||
* Callback, invoked when underlying WebSocket is closed.
|
||||
*
|
||||
* Actual [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
|
||||
* is passed as parameter to the callback.
|
||||
*/
|
||||
onWebSocketClose: closeEventCallbackType;
|
||||
/**
|
||||
* Callback, invoked when underlying WebSocket raises an error.
|
||||
*
|
||||
* Actual [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
|
||||
* is passed as parameter to the callback.
|
||||
*/
|
||||
onWebSocketError: wsErrorCallbackType;
|
||||
/**
|
||||
* Set it to log the actual raw communication with the broker.
|
||||
* When unset, it logs headers of the parsed frames.
|
||||
*
|
||||
* Change in this effects from next broker reconnect.
|
||||
*
|
||||
* **Caution: this assumes that frames only have valid UTF8 strings.**
|
||||
*/
|
||||
logRawCommunication: boolean;
|
||||
/**
|
||||
* By default, debug messages are discarded. To log to `console` following can be used:
|
||||
*
|
||||
* ```javascript
|
||||
* client.debug = function(str) {
|
||||
* console.log(str);
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* Currently this method does not support levels of log. Be aware that the output can be quite verbose
|
||||
* and may contain sensitive information (like passwords, tokens etc.).
|
||||
*/
|
||||
debug: debugFnType;
|
||||
/**
|
||||
* Browsers do not immediately close WebSockets when `.close` is issued.
|
||||
* This may cause reconnection to take a longer on certain type of failures.
|
||||
* In case of incoming heartbeat failure, this experimental flag instructs the library
|
||||
* to discard the socket immediately (even before it is actually closed).
|
||||
*/
|
||||
discardWebsocketOnCommFailure: boolean;
|
||||
/**
|
||||
* version of STOMP protocol negotiated with the server, READONLY
|
||||
*/
|
||||
readonly connectedVersion: string;
|
||||
private _stompHandler;
|
||||
/**
|
||||
* if the client is active (connected or going to reconnect)
|
||||
*/
|
||||
readonly active: boolean;
|
||||
/**
|
||||
* It will be called on state change.
|
||||
*
|
||||
* When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
|
||||
*/
|
||||
onChangeState: (state: ActivationState) => void;
|
||||
private _changeState;
|
||||
private _resolveSocketClose;
|
||||
/**
|
||||
* Activation state.
|
||||
*
|
||||
* It will usually be ACTIVE or INACTIVE.
|
||||
* When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
|
||||
*/
|
||||
state: ActivationState;
|
||||
private _reconnector;
|
||||
/**
|
||||
* Create an instance.
|
||||
*/
|
||||
constructor(conf?: StompConfig);
|
||||
/**
|
||||
* Update configuration.
|
||||
*/
|
||||
configure(conf: StompConfig): void;
|
||||
/**
|
||||
* Initiate the connection with the broker.
|
||||
* If the connection breaks, as per [Client#reconnectDelay]{@link Client#reconnectDelay},
|
||||
* it will keep trying to reconnect.
|
||||
*
|
||||
* Call [Client#deactivate]{@link Client#deactivate} to disconnect and stop reconnection attempts.
|
||||
*/
|
||||
activate(): void;
|
||||
private _connect;
|
||||
private _createWebSocket;
|
||||
private _schedule_reconnect;
|
||||
/**
|
||||
* Disconnect if connected and stop auto reconnect loop.
|
||||
* Appropriate callbacks will be invoked if underlying STOMP connection was connected.
|
||||
*
|
||||
* This call is async, it will resolve immediately if there is no underlying active websocket,
|
||||
* otherwise, it will resolve after underlying websocket is properly disposed.
|
||||
*
|
||||
* To reactivate you can call [Client#activate]{@link Client#activate}.
|
||||
*/
|
||||
deactivate(): Promise<void>;
|
||||
/**
|
||||
* Force disconnect if there is an active connection by directly closing the underlying WebSocket.
|
||||
* This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
|
||||
* After forcing disconnect, automatic reconnect will be attempted.
|
||||
* To stop further reconnects call [Client#deactivate]{@link Client#deactivate} as well.
|
||||
*/
|
||||
forceDisconnect(): void;
|
||||
private _disposeStompHandler;
|
||||
/**
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations.
|
||||
*
|
||||
* STOMP protocol specifies and suggests some headers and also allows broker specific headers.
|
||||
*
|
||||
* `body` must be String.
|
||||
* You will need to covert the payload to string in case it is not string (e.g. JSON).
|
||||
*
|
||||
* To send a binary message body use binaryBody parameter. It should be a
|
||||
* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
|
||||
* Sometimes brokers may not support binary frames out of the box.
|
||||
* Please check your broker documentation.
|
||||
*
|
||||
* `content-length` header is automatically added to the STOMP Frame sent to the broker.
|
||||
* Set `skipContentLengthHeader` to indicate that `content-length` header should not be added.
|
||||
* For binary messages `content-length` header is always added.
|
||||
*
|
||||
* Caution: The broker will, most likely, report an error and disconnect if message body has NULL octet(s)
|
||||
* and `content-length` header is missing.
|
||||
*
|
||||
* ```javascript
|
||||
* client.publish({destination: "/queue/test", headers: {priority: 9}, body: "Hello, STOMP"});
|
||||
*
|
||||
* // Only destination is mandatory parameter
|
||||
* client.publish({destination: "/queue/test", body: "Hello, STOMP"});
|
||||
*
|
||||
* // Skip content-length header in the frame to the broker
|
||||
* client.publish({"/queue/test", body: "Hello, STOMP", skipContentLengthHeader: true});
|
||||
*
|
||||
* var binaryData = generateBinaryData(); // This need to be of type Uint8Array
|
||||
* // setting content-type header is not mandatory, however a good practice
|
||||
* client.publish({destination: '/topic/special', binaryBody: binaryData,
|
||||
* headers: {'content-type': 'application/octet-stream'}});
|
||||
* ```
|
||||
*/
|
||||
publish(params: IPublishParams): void;
|
||||
/**
|
||||
* STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
|
||||
* To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
|
||||
* The value (say receipt-id) for this header needs to be unique for each use. Typically a sequence, a UUID, a
|
||||
* random number or a combination may be used.
|
||||
*
|
||||
* A complaint broker will send a RECEIPT frame when an operation has actually been completed.
|
||||
* The operation needs to be matched based in the value of the receipt-id.
|
||||
*
|
||||
* This method allow watching for a receipt and invoke the callback
|
||||
* when corresponding receipt has been received.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Subscribing with acknowledgement
|
||||
* let receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
*
|
||||
* client.subscribe(TEST.destination, onMessage, {receipt: receiptId});
|
||||
*
|
||||
*
|
||||
* // Publishing with acknowledgement
|
||||
* receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
* client.publish({destination: TEST.destination, headers: {receipt: receiptId}, body: msg});
|
||||
* ```
|
||||
*/
|
||||
watchForReceipt(receiptId: string, callback: frameCallbackType): void;
|
||||
/**
|
||||
* Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
|
||||
* the {@link IMessage} as argument.
|
||||
*
|
||||
* Note: The library will generate an unique ID if there is none provided in the headers.
|
||||
* To use your own ID, pass it using the headers argument.
|
||||
*
|
||||
* ```javascript
|
||||
* callback = function(message) {
|
||||
* // called when the client receives a STOMP message from the server
|
||||
* if (message.body) {
|
||||
* alert("got message with body " + message.body)
|
||||
* } else {
|
||||
* alert("got empty message");
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* var subscription = client.subscribe("/queue/test", callback);
|
||||
*
|
||||
* // Explicit subscription id
|
||||
* var mySubId = 'my-subscription-id-001';
|
||||
* var subscription = client.subscribe(destination, callback, { id: mySubId });
|
||||
* ```
|
||||
*/
|
||||
subscribe(destination: string, callback: messageCallbackType, headers?: StompHeaders): StompSubscription;
|
||||
/**
|
||||
* It is preferable to unsubscribe from a subscription by calling
|
||||
* `unsubscribe()` directly on {@link StompSubscription} returned by `client.subscribe()`:
|
||||
*
|
||||
* ```javascript
|
||||
* var subscription = client.subscribe(destination, onmessage);
|
||||
* // ...
|
||||
* subscription.unsubscribe();
|
||||
* ```
|
||||
*
|
||||
* See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
|
||||
*/
|
||||
unsubscribe(id: string, headers?: StompHeaders): void;
|
||||
/**
|
||||
* Start a transaction, the returned {@link ITransaction} has methods - [commit]{@link ITransaction#commit}
|
||||
* and [abort]{@link ITransaction#abort}.
|
||||
*
|
||||
* `transactionId` is optional, if not passed the library will generate it internally.
|
||||
*/
|
||||
begin(transactionId?: string): ITransaction;
|
||||
/**
|
||||
* Commit a transaction.
|
||||
*
|
||||
* It is preferable to commit a transaction by calling [commit]{@link ITransaction#commit} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.commit();
|
||||
* ```
|
||||
*/
|
||||
commit(transactionId: string): void;
|
||||
/**
|
||||
* Abort a transaction.
|
||||
* It is preferable to abort a transaction by calling [abort]{@link ITransaction#abort} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.abort();
|
||||
* ```
|
||||
*/
|
||||
abort(transactionId: string): void;
|
||||
/**
|
||||
* ACK a message. It is preferable to acknowledge a message by calling [ack]{@link IMessage#ack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // acknowledge it
|
||||
* message.ack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
ack(messageId: string, subscriptionId: string, headers?: StompHeaders): void;
|
||||
/**
|
||||
* NACK a message. It is preferable to acknowledge a message by calling [nack]{@link IMessage#nack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // an error occurs, nack it
|
||||
* message.nack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
nack(messageId: string, subscriptionId: string, headers?: StompHeaders): void;
|
||||
}
|
||||
539
node_modules/@stomp/stompjs/esm6/client.js
generated
vendored
Normal file
539
node_modules/@stomp/stompjs/esm6/client.js
generated
vendored
Normal file
@@ -0,0 +1,539 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
import { StompHandler } from './stomp-handler';
|
||||
import { ActivationState, StompSocketState, } from './types';
|
||||
import { Versions } from './versions';
|
||||
/**
|
||||
* STOMP Client Class.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class Client {
|
||||
/**
|
||||
* Create an instance.
|
||||
*/
|
||||
constructor(conf = {}) {
|
||||
/**
|
||||
* STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Try only versions 1.0 and 1.1
|
||||
* client.stompVersions = new Versions(['1.0', '1.1'])
|
||||
* ```
|
||||
*/
|
||||
this.stompVersions = Versions.default;
|
||||
/**
|
||||
* Will retry if Stomp connection is not established in specified milliseconds.
|
||||
* Default 0, which implies wait for ever.
|
||||
*/
|
||||
this.connectionTimeout = 0;
|
||||
/**
|
||||
* automatically reconnect with delay in milliseconds, set to 0 to disable.
|
||||
*/
|
||||
this.reconnectDelay = 5000;
|
||||
/**
|
||||
* Incoming heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
this.heartbeatIncoming = 10000;
|
||||
/**
|
||||
* Outgoing heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
this.heartbeatOutgoing = 10000;
|
||||
/**
|
||||
* This switches on a non standard behavior while sending WebSocket packets.
|
||||
* It splits larger (text) packets into chunks of [maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
|
||||
* Only Java Spring brokers seems to use this mode.
|
||||
*
|
||||
* WebSockets, by itself, split large (text) packets,
|
||||
* so it is not needed with a truly compliant STOMP/WebSocket broker.
|
||||
* Actually setting it for such broker will cause large messages to fail.
|
||||
*
|
||||
* `false` by default.
|
||||
*
|
||||
* Binary frames are never split.
|
||||
*/
|
||||
this.splitLargeFrames = false;
|
||||
/**
|
||||
* See [splitLargeFrames]{@link Client#splitLargeFrames}.
|
||||
* This has no effect if [splitLargeFrames]{@link Client#splitLargeFrames} is `false`.
|
||||
*/
|
||||
this.maxWebSocketChunkSize = 8 * 1024;
|
||||
/**
|
||||
* Usually the
|
||||
* [type of WebSocket frame]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send#Parameters}
|
||||
* is automatically decided by type of the payload.
|
||||
* Default is `false`, which should work with all compliant brokers.
|
||||
*
|
||||
* Set this flag to force binary frames.
|
||||
*/
|
||||
this.forceBinaryWSFrames = false;
|
||||
/**
|
||||
* A bug in ReactNative chops a string on occurrence of a NULL.
|
||||
* See issue [https://github.com/stomp-js/stompjs/issues/89]{@link https://github.com/stomp-js/stompjs/issues/89}.
|
||||
* This makes incoming WebSocket messages invalid STOMP packets.
|
||||
* Setting this flag attempts to reverse the damage by appending a NULL.
|
||||
* If the broker splits a large message into multiple WebSocket messages,
|
||||
* this flag will cause data loss and abnormal termination of connection.
|
||||
*
|
||||
* This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
|
||||
*/
|
||||
this.appendMissingNULLonIncoming = false;
|
||||
/**
|
||||
* Activation state.
|
||||
*
|
||||
* It will usually be ACTIVE or INACTIVE.
|
||||
* When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
|
||||
*/
|
||||
this.state = ActivationState.INACTIVE;
|
||||
// Dummy callbacks
|
||||
const noOp = () => { };
|
||||
this.debug = noOp;
|
||||
this.beforeConnect = noOp;
|
||||
this.onConnect = noOp;
|
||||
this.onDisconnect = noOp;
|
||||
this.onUnhandledMessage = noOp;
|
||||
this.onUnhandledReceipt = noOp;
|
||||
this.onUnhandledFrame = noOp;
|
||||
this.onStompError = noOp;
|
||||
this.onWebSocketClose = noOp;
|
||||
this.onWebSocketError = noOp;
|
||||
this.logRawCommunication = false;
|
||||
this.onChangeState = noOp;
|
||||
// These parameters would typically get proper values before connect is called
|
||||
this.connectHeaders = {};
|
||||
this._disconnectHeaders = {};
|
||||
// Apply configuration
|
||||
this.configure(conf);
|
||||
}
|
||||
/**
|
||||
* Underlying WebSocket instance, READONLY.
|
||||
*/
|
||||
get webSocket() {
|
||||
return this._stompHandler ? this._stompHandler._webSocket : undefined;
|
||||
}
|
||||
/**
|
||||
* Disconnection headers.
|
||||
*/
|
||||
get disconnectHeaders() {
|
||||
return this._disconnectHeaders;
|
||||
}
|
||||
set disconnectHeaders(value) {
|
||||
this._disconnectHeaders = value;
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.disconnectHeaders = this._disconnectHeaders;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* `true` if there is a active connection with STOMP Broker
|
||||
*/
|
||||
get connected() {
|
||||
return !!this._stompHandler && this._stompHandler.connected;
|
||||
}
|
||||
/**
|
||||
* version of STOMP protocol negotiated with the server, READONLY
|
||||
*/
|
||||
get connectedVersion() {
|
||||
return this._stompHandler ? this._stompHandler.connectedVersion : undefined;
|
||||
}
|
||||
/**
|
||||
* if the client is active (connected or going to reconnect)
|
||||
*/
|
||||
get active() {
|
||||
return this.state === ActivationState.ACTIVE;
|
||||
}
|
||||
_changeState(state) {
|
||||
this.state = state;
|
||||
this.onChangeState(state);
|
||||
}
|
||||
/**
|
||||
* Update configuration.
|
||||
*/
|
||||
configure(conf) {
|
||||
// bulk assign all properties to this
|
||||
Object.assign(this, conf);
|
||||
}
|
||||
/**
|
||||
* Initiate the connection with the broker.
|
||||
* If the connection breaks, as per [Client#reconnectDelay]{@link Client#reconnectDelay},
|
||||
* it will keep trying to reconnect.
|
||||
*
|
||||
* Call [Client#deactivate]{@link Client#deactivate} to disconnect and stop reconnection attempts.
|
||||
*/
|
||||
activate() {
|
||||
if (this.state === ActivationState.DEACTIVATING) {
|
||||
this.debug('Still DEACTIVATING, please await call to deactivate before trying to re-activate');
|
||||
throw new Error('Still DEACTIVATING, can not activate now');
|
||||
}
|
||||
if (this.active) {
|
||||
this.debug('Already ACTIVE, ignoring request to activate');
|
||||
return;
|
||||
}
|
||||
this._changeState(ActivationState.ACTIVE);
|
||||
this._connect();
|
||||
}
|
||||
_connect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.connected) {
|
||||
this.debug('STOMP: already connected, nothing to do');
|
||||
return;
|
||||
}
|
||||
yield this.beforeConnect();
|
||||
if (!this.active) {
|
||||
this.debug('Client has been marked inactive, will not attempt to connect');
|
||||
return;
|
||||
}
|
||||
// setup connection watcher
|
||||
if (this.connectionTimeout > 0) {
|
||||
// clear first
|
||||
if (this._connectionWatcher) {
|
||||
clearTimeout(this._connectionWatcher);
|
||||
}
|
||||
this._connectionWatcher = setTimeout(() => {
|
||||
if (this.connected) {
|
||||
return;
|
||||
}
|
||||
// Connection not established, close the underlying socket
|
||||
// a reconnection will be attempted
|
||||
this.debug(`Connection not established in ${this.connectionTimeout}ms, closing socket`);
|
||||
this.forceDisconnect();
|
||||
}, this.connectionTimeout);
|
||||
}
|
||||
this.debug('Opening Web Socket...');
|
||||
// Get the actual WebSocket (or a similar object)
|
||||
const webSocket = this._createWebSocket();
|
||||
this._stompHandler = new StompHandler(this, webSocket, {
|
||||
debug: this.debug,
|
||||
stompVersions: this.stompVersions,
|
||||
connectHeaders: this.connectHeaders,
|
||||
disconnectHeaders: this._disconnectHeaders,
|
||||
heartbeatIncoming: this.heartbeatIncoming,
|
||||
heartbeatOutgoing: this.heartbeatOutgoing,
|
||||
splitLargeFrames: this.splitLargeFrames,
|
||||
maxWebSocketChunkSize: this.maxWebSocketChunkSize,
|
||||
forceBinaryWSFrames: this.forceBinaryWSFrames,
|
||||
logRawCommunication: this.logRawCommunication,
|
||||
appendMissingNULLonIncoming: this.appendMissingNULLonIncoming,
|
||||
discardWebsocketOnCommFailure: this.discardWebsocketOnCommFailure,
|
||||
onConnect: frame => {
|
||||
// Successfully connected, stop the connection watcher
|
||||
if (this._connectionWatcher) {
|
||||
clearTimeout(this._connectionWatcher);
|
||||
this._connectionWatcher = undefined;
|
||||
}
|
||||
if (!this.active) {
|
||||
this.debug('STOMP got connected while deactivate was issued, will disconnect now');
|
||||
this._disposeStompHandler();
|
||||
return;
|
||||
}
|
||||
this.onConnect(frame);
|
||||
},
|
||||
onDisconnect: frame => {
|
||||
this.onDisconnect(frame);
|
||||
},
|
||||
onStompError: frame => {
|
||||
this.onStompError(frame);
|
||||
},
|
||||
onWebSocketClose: evt => {
|
||||
this._stompHandler = undefined; // a new one will be created in case of a reconnect
|
||||
if (this.state === ActivationState.DEACTIVATING) {
|
||||
// Mark deactivation complete
|
||||
this._resolveSocketClose();
|
||||
this._resolveSocketClose = undefined;
|
||||
this._changeState(ActivationState.INACTIVE);
|
||||
}
|
||||
this.onWebSocketClose(evt);
|
||||
// The callback is called before attempting to reconnect, this would allow the client
|
||||
// to be `deactivated` in the callback.
|
||||
if (this.active) {
|
||||
this._schedule_reconnect();
|
||||
}
|
||||
},
|
||||
onWebSocketError: evt => {
|
||||
this.onWebSocketError(evt);
|
||||
},
|
||||
onUnhandledMessage: message => {
|
||||
this.onUnhandledMessage(message);
|
||||
},
|
||||
onUnhandledReceipt: frame => {
|
||||
this.onUnhandledReceipt(frame);
|
||||
},
|
||||
onUnhandledFrame: frame => {
|
||||
this.onUnhandledFrame(frame);
|
||||
},
|
||||
});
|
||||
this._stompHandler.start();
|
||||
});
|
||||
}
|
||||
_createWebSocket() {
|
||||
let webSocket;
|
||||
if (this.webSocketFactory) {
|
||||
webSocket = this.webSocketFactory();
|
||||
}
|
||||
else {
|
||||
webSocket = new WebSocket(this.brokerURL, this.stompVersions.protocolVersions());
|
||||
}
|
||||
webSocket.binaryType = 'arraybuffer';
|
||||
return webSocket;
|
||||
}
|
||||
_schedule_reconnect() {
|
||||
if (this.reconnectDelay > 0) {
|
||||
this.debug(`STOMP: scheduling reconnection in ${this.reconnectDelay}ms`);
|
||||
this._reconnector = setTimeout(() => {
|
||||
this._connect();
|
||||
}, this.reconnectDelay);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Disconnect if connected and stop auto reconnect loop.
|
||||
* Appropriate callbacks will be invoked if underlying STOMP connection was connected.
|
||||
*
|
||||
* This call is async, it will resolve immediately if there is no underlying active websocket,
|
||||
* otherwise, it will resolve after underlying websocket is properly disposed.
|
||||
*
|
||||
* To reactivate you can call [Client#activate]{@link Client#activate}.
|
||||
*/
|
||||
deactivate() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let retPromise;
|
||||
if (this.state !== ActivationState.ACTIVE) {
|
||||
this.debug(`Already ${ActivationState[this.state]}, ignoring call to deactivate`);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this._changeState(ActivationState.DEACTIVATING);
|
||||
// Clear if a reconnection was scheduled
|
||||
if (this._reconnector) {
|
||||
clearTimeout(this._reconnector);
|
||||
}
|
||||
if (this._stompHandler &&
|
||||
this.webSocket.readyState !== StompSocketState.CLOSED) {
|
||||
// we need to wait for underlying websocket to close
|
||||
retPromise = new Promise((resolve, reject) => {
|
||||
this._resolveSocketClose = resolve;
|
||||
});
|
||||
}
|
||||
else {
|
||||
// indicate that auto reconnect loop should terminate
|
||||
this._changeState(ActivationState.INACTIVE);
|
||||
return Promise.resolve();
|
||||
}
|
||||
this._disposeStompHandler();
|
||||
return retPromise;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Force disconnect if there is an active connection by directly closing the underlying WebSocket.
|
||||
* This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
|
||||
* After forcing disconnect, automatic reconnect will be attempted.
|
||||
* To stop further reconnects call [Client#deactivate]{@link Client#deactivate} as well.
|
||||
*/
|
||||
forceDisconnect() {
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.forceDisconnect();
|
||||
}
|
||||
}
|
||||
_disposeStompHandler() {
|
||||
// Dispose STOMP Handler
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.dispose();
|
||||
this._stompHandler = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations.
|
||||
*
|
||||
* STOMP protocol specifies and suggests some headers and also allows broker specific headers.
|
||||
*
|
||||
* `body` must be String.
|
||||
* You will need to covert the payload to string in case it is not string (e.g. JSON).
|
||||
*
|
||||
* To send a binary message body use binaryBody parameter. It should be a
|
||||
* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
|
||||
* Sometimes brokers may not support binary frames out of the box.
|
||||
* Please check your broker documentation.
|
||||
*
|
||||
* `content-length` header is automatically added to the STOMP Frame sent to the broker.
|
||||
* Set `skipContentLengthHeader` to indicate that `content-length` header should not be added.
|
||||
* For binary messages `content-length` header is always added.
|
||||
*
|
||||
* Caution: The broker will, most likely, report an error and disconnect if message body has NULL octet(s)
|
||||
* and `content-length` header is missing.
|
||||
*
|
||||
* ```javascript
|
||||
* client.publish({destination: "/queue/test", headers: {priority: 9}, body: "Hello, STOMP"});
|
||||
*
|
||||
* // Only destination is mandatory parameter
|
||||
* client.publish({destination: "/queue/test", body: "Hello, STOMP"});
|
||||
*
|
||||
* // Skip content-length header in the frame to the broker
|
||||
* client.publish({"/queue/test", body: "Hello, STOMP", skipContentLengthHeader: true});
|
||||
*
|
||||
* var binaryData = generateBinaryData(); // This need to be of type Uint8Array
|
||||
* // setting content-type header is not mandatory, however a good practice
|
||||
* client.publish({destination: '/topic/special', binaryBody: binaryData,
|
||||
* headers: {'content-type': 'application/octet-stream'}});
|
||||
* ```
|
||||
*/
|
||||
publish(params) {
|
||||
this._stompHandler.publish(params);
|
||||
}
|
||||
/**
|
||||
* STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
|
||||
* To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
|
||||
* The value (say receipt-id) for this header needs to be unique for each use. Typically a sequence, a UUID, a
|
||||
* random number or a combination may be used.
|
||||
*
|
||||
* A complaint broker will send a RECEIPT frame when an operation has actually been completed.
|
||||
* The operation needs to be matched based in the value of the receipt-id.
|
||||
*
|
||||
* This method allow watching for a receipt and invoke the callback
|
||||
* when corresponding receipt has been received.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Subscribing with acknowledgement
|
||||
* let receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
*
|
||||
* client.subscribe(TEST.destination, onMessage, {receipt: receiptId});
|
||||
*
|
||||
*
|
||||
* // Publishing with acknowledgement
|
||||
* receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
* client.publish({destination: TEST.destination, headers: {receipt: receiptId}, body: msg});
|
||||
* ```
|
||||
*/
|
||||
watchForReceipt(receiptId, callback) {
|
||||
this._stompHandler.watchForReceipt(receiptId, callback);
|
||||
}
|
||||
/**
|
||||
* Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
|
||||
* the {@link IMessage} as argument.
|
||||
*
|
||||
* Note: The library will generate an unique ID if there is none provided in the headers.
|
||||
* To use your own ID, pass it using the headers argument.
|
||||
*
|
||||
* ```javascript
|
||||
* callback = function(message) {
|
||||
* // called when the client receives a STOMP message from the server
|
||||
* if (message.body) {
|
||||
* alert("got message with body " + message.body)
|
||||
* } else {
|
||||
* alert("got empty message");
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* var subscription = client.subscribe("/queue/test", callback);
|
||||
*
|
||||
* // Explicit subscription id
|
||||
* var mySubId = 'my-subscription-id-001';
|
||||
* var subscription = client.subscribe(destination, callback, { id: mySubId });
|
||||
* ```
|
||||
*/
|
||||
subscribe(destination, callback, headers = {}) {
|
||||
return this._stompHandler.subscribe(destination, callback, headers);
|
||||
}
|
||||
/**
|
||||
* It is preferable to unsubscribe from a subscription by calling
|
||||
* `unsubscribe()` directly on {@link StompSubscription} returned by `client.subscribe()`:
|
||||
*
|
||||
* ```javascript
|
||||
* var subscription = client.subscribe(destination, onmessage);
|
||||
* // ...
|
||||
* subscription.unsubscribe();
|
||||
* ```
|
||||
*
|
||||
* See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
|
||||
*/
|
||||
unsubscribe(id, headers = {}) {
|
||||
this._stompHandler.unsubscribe(id, headers);
|
||||
}
|
||||
/**
|
||||
* Start a transaction, the returned {@link ITransaction} has methods - [commit]{@link ITransaction#commit}
|
||||
* and [abort]{@link ITransaction#abort}.
|
||||
*
|
||||
* `transactionId` is optional, if not passed the library will generate it internally.
|
||||
*/
|
||||
begin(transactionId) {
|
||||
return this._stompHandler.begin(transactionId);
|
||||
}
|
||||
/**
|
||||
* Commit a transaction.
|
||||
*
|
||||
* It is preferable to commit a transaction by calling [commit]{@link ITransaction#commit} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.commit();
|
||||
* ```
|
||||
*/
|
||||
commit(transactionId) {
|
||||
this._stompHandler.commit(transactionId);
|
||||
}
|
||||
/**
|
||||
* Abort a transaction.
|
||||
* It is preferable to abort a transaction by calling [abort]{@link ITransaction#abort} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.abort();
|
||||
* ```
|
||||
*/
|
||||
abort(transactionId) {
|
||||
this._stompHandler.abort(transactionId);
|
||||
}
|
||||
/**
|
||||
* ACK a message. It is preferable to acknowledge a message by calling [ack]{@link IMessage#ack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // acknowledge it
|
||||
* message.ack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
ack(messageId, subscriptionId, headers = {}) {
|
||||
this._stompHandler.ack(messageId, subscriptionId, headers);
|
||||
}
|
||||
/**
|
||||
* NACK a message. It is preferable to acknowledge a message by calling [nack]{@link IMessage#nack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // an error occurs, nack it
|
||||
* message.nack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
nack(messageId, subscriptionId, headers = {}) {
|
||||
this._stompHandler.nack(messageId, subscriptionId, headers);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=client.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/client.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/client.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
149
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.d.ts
generated
vendored
Normal file
149
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
import { Client } from '../client';
|
||||
import { StompHeaders } from '../stomp-headers';
|
||||
import { frameCallbackType, messageCallbackType } from '../types';
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
export declare class CompatClient extends Client {
|
||||
/**
|
||||
* It is no op now. No longer needed. Large packets work out of the box.
|
||||
*/
|
||||
maxWebSocketFrameSize: number;
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}
|
||||
* and [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(webSocketFactory: () => any);
|
||||
private _parseConnect;
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#activate]{@link Client#activate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* The `connect` method accepts different number of arguments and types. See the Overloads list. Use the
|
||||
* version with headers to pass your broker specific options.
|
||||
*
|
||||
* overloads:
|
||||
* - connect(headers, connectCallback)
|
||||
* - connect(headers, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback, host)
|
||||
*
|
||||
* params:
|
||||
* - headers, see [Client#connectHeaders]{@link Client#connectHeaders}
|
||||
* - connectCallback, see [Client#onConnect]{@link Client#onConnect}
|
||||
* - errorCallback, see [Client#onStompError]{@link Client#onStompError}
|
||||
* - closeEventCallback, see [Client#onWebSocketClose]{@link Client#onWebSocketClose}
|
||||
* - login [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - passcode [String], [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - host [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
connect(...args: any[]): void;
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#deactivate]{@link Client#deactivate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* See:
|
||||
* [Client#onDisconnect]{@link Client#onDisconnect}, and
|
||||
* [Client#disconnectHeaders]{@link Client#disconnectHeaders}
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
disconnect(disconnectCallback?: any, headers?: StompHeaders): void;
|
||||
/**
|
||||
* Available for backward compatibility, use [Client#publish]{@link Client#publish}.
|
||||
*
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations. The headers will, typically, be available to the subscriber.
|
||||
* However, there may be special purpose headers corresponding to your STOMP broker.
|
||||
*
|
||||
* **Deprecated**, use [Client#publish]{@link Client#publish}
|
||||
*
|
||||
* Note: Body must be String. You will need to covert the payload to string in case it is not string (e.g. JSON)
|
||||
*
|
||||
* ```javascript
|
||||
* client.send("/queue/test", {priority: 9}, "Hello, STOMP");
|
||||
*
|
||||
* // If you want to send a message with a body, you must also pass the headers argument.
|
||||
* client.send("/queue/test", {}, "Hello, STOMP");
|
||||
* ```
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
send(destination: string, headers?: {
|
||||
[key: string]: any;
|
||||
}, body?: string): void;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
reconnect_delay: number;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
readonly ws: any;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
readonly version: string;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
onreceive: messageCallbackType;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
onreceipt: frameCallbackType;
|
||||
private _heartbeatInfo;
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
heartbeat: {
|
||||
incoming: number;
|
||||
outgoing: number;
|
||||
};
|
||||
}
|
||||
241
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.js
generated
vendored
Normal file
241
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.js
generated
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
import { Client } from '../client';
|
||||
import { HeartbeatInfo } from './heartbeat-info';
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
export class CompatClient extends Client {
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}
|
||||
* and [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(webSocketFactory) {
|
||||
super();
|
||||
/**
|
||||
* It is no op now. No longer needed. Large packets work out of the box.
|
||||
*/
|
||||
this.maxWebSocketFrameSize = 16 * 1024;
|
||||
this._heartbeatInfo = new HeartbeatInfo(this);
|
||||
this.reconnect_delay = 0;
|
||||
this.webSocketFactory = webSocketFactory;
|
||||
// Default from previous version
|
||||
this.debug = (...message) => {
|
||||
console.log(...message);
|
||||
};
|
||||
}
|
||||
_parseConnect(...args) {
|
||||
let closeEventCallback;
|
||||
let connectCallback;
|
||||
let errorCallback;
|
||||
let headers = {};
|
||||
if (args.length < 2) {
|
||||
throw new Error('Connect requires at least 2 arguments');
|
||||
}
|
||||
if (typeof args[1] === 'function') {
|
||||
[headers, connectCallback, errorCallback, closeEventCallback] = args;
|
||||
}
|
||||
else {
|
||||
switch (args.length) {
|
||||
case 6:
|
||||
[
|
||||
headers.login,
|
||||
headers.passcode,
|
||||
connectCallback,
|
||||
errorCallback,
|
||||
closeEventCallback,
|
||||
headers.host,
|
||||
] = args;
|
||||
break;
|
||||
default:
|
||||
[
|
||||
headers.login,
|
||||
headers.passcode,
|
||||
connectCallback,
|
||||
errorCallback,
|
||||
closeEventCallback,
|
||||
] = args;
|
||||
}
|
||||
}
|
||||
return [headers, connectCallback, errorCallback, closeEventCallback];
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#activate]{@link Client#activate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* The `connect` method accepts different number of arguments and types. See the Overloads list. Use the
|
||||
* version with headers to pass your broker specific options.
|
||||
*
|
||||
* overloads:
|
||||
* - connect(headers, connectCallback)
|
||||
* - connect(headers, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback, host)
|
||||
*
|
||||
* params:
|
||||
* - headers, see [Client#connectHeaders]{@link Client#connectHeaders}
|
||||
* - connectCallback, see [Client#onConnect]{@link Client#onConnect}
|
||||
* - errorCallback, see [Client#onStompError]{@link Client#onStompError}
|
||||
* - closeEventCallback, see [Client#onWebSocketClose]{@link Client#onWebSocketClose}
|
||||
* - login [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - passcode [String], [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - host [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
connect(...args) {
|
||||
const out = this._parseConnect(...args);
|
||||
if (out[0]) {
|
||||
this.connectHeaders = out[0];
|
||||
}
|
||||
if (out[1]) {
|
||||
this.onConnect = out[1];
|
||||
}
|
||||
if (out[2]) {
|
||||
this.onStompError = out[2];
|
||||
}
|
||||
if (out[3]) {
|
||||
this.onWebSocketClose = out[3];
|
||||
}
|
||||
super.activate();
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#deactivate]{@link Client#deactivate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* See:
|
||||
* [Client#onDisconnect]{@link Client#onDisconnect}, and
|
||||
* [Client#disconnectHeaders]{@link Client#disconnectHeaders}
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
disconnect(disconnectCallback, headers = {}) {
|
||||
if (disconnectCallback) {
|
||||
this.onDisconnect = disconnectCallback;
|
||||
}
|
||||
this.disconnectHeaders = headers;
|
||||
super.deactivate();
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, use [Client#publish]{@link Client#publish}.
|
||||
*
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations. The headers will, typically, be available to the subscriber.
|
||||
* However, there may be special purpose headers corresponding to your STOMP broker.
|
||||
*
|
||||
* **Deprecated**, use [Client#publish]{@link Client#publish}
|
||||
*
|
||||
* Note: Body must be String. You will need to covert the payload to string in case it is not string (e.g. JSON)
|
||||
*
|
||||
* ```javascript
|
||||
* client.send("/queue/test", {priority: 9}, "Hello, STOMP");
|
||||
*
|
||||
* // If you want to send a message with a body, you must also pass the headers argument.
|
||||
* client.send("/queue/test", {}, "Hello, STOMP");
|
||||
* ```
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
send(destination, headers = {}, body = '') {
|
||||
headers = Object.assign({}, headers);
|
||||
const skipContentLengthHeader = headers['content-length'] === false;
|
||||
if (skipContentLengthHeader) {
|
||||
delete headers['content-length'];
|
||||
}
|
||||
this.publish({
|
||||
destination,
|
||||
headers: headers,
|
||||
body,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set reconnect_delay(value) {
|
||||
this.reconnectDelay = value;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get ws() {
|
||||
return this.webSocket;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get version() {
|
||||
return this.connectedVersion;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get onreceive() {
|
||||
return this.onUnhandledMessage;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set onreceive(value) {
|
||||
this.onUnhandledMessage = value;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get onreceipt() {
|
||||
return this.onUnhandledReceipt;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set onreceipt(value) {
|
||||
this.onUnhandledReceipt = value;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get heartbeat() {
|
||||
return this._heartbeatInfo;
|
||||
}
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set heartbeat(value) {
|
||||
this.heartbeatIncoming = value.incoming;
|
||||
this.heartbeatOutgoing = value.outgoing;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=compat-client.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/compatibility/compat-client.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"compat-client.js","sourceRoot":"","sources":["../../src/compatibility/compat-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM;IAMtC;;;;;;;OAOG;IACH,YAAY,gBAA2B;QACrC,KAAK,EAAE,CAAC;QAdV;;WAEG;QACI,0BAAqB,GAAW,EAAE,GAAG,IAAI,CAAC;QAoOzC,mBAAc,GAAkB,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QAxN9D,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,gCAAgC;QAChC,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,OAAc,EAAE,EAAE;YACjC,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,GAAG,IAAW;QAClC,IAAI,kBAAkB,CAAC;QACvB,IAAI,eAAe,CAAC;QACpB,IAAI,aAAa,CAAC;QAClB,IAAI,OAAO,GAAiB,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;QACD,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,EAAE;YACjC,CAAC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,kBAAkB,CAAC,GAAG,IAAI,CAAC;SACtE;aAAM;YACL,QAAQ,IAAI,CAAC,MAAM,EAAE;gBACnB,KAAK,CAAC;oBACJ;wBACE,OAAO,CAAC,KAAK;wBACb,OAAO,CAAC,QAAQ;wBAChB,eAAe;wBACf,aAAa;wBACb,kBAAkB;wBAClB,OAAO,CAAC,IAAI;qBACb,GAAG,IAAI,CAAC;oBACT,MAAM;gBACR;oBACE;wBACE,OAAO,CAAC,KAAK;wBACb,OAAO,CAAC,QAAQ;wBAChB,eAAe;wBACf,aAAa;wBACb,kBAAkB;qBACnB,GAAG,IAAI,CAAC;aACZ;SACF;QAED,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACI,OAAO,CAAC,GAAG,IAAW;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;QAExC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAC9B;QACD,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SACzB;QACD,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAC5B;QACD,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;YACV,IAAI,CAAC,gBAAgB,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;SAChC;QAED,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnB,CAAC;IAED;;;;;;;;;;OAUG;IACI,UAAU,CACf,kBAAwB,EACxB,UAAwB,EAAE;QAE1B,IAAI,kBAAkB,EAAE;YACtB,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC;SACxC;QACD,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;QAEjC,KAAK,CAAC,UAAU,EAAE,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACI,IAAI,CACT,WAAmB,EACnB,UAAkC,EAAE,EACpC,OAAe,EAAE;QAEjB,OAAO,GAAI,MAAc,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAE9C,MAAM,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,KAAK,CAAC;QACpE,IAAI,uBAAuB,EAAE;YAC3B,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;SAClC;QACD,IAAI,CAAC,OAAO,CAAC;YACX,WAAW;YACX,OAAO,EAAE,OAAuB;YAChC,IAAI;YACJ,uBAAuB;SACxB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,IAAI,eAAe,CAAC,KAAa;QAC/B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS,CAAC,KAA0B;QACtC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,IAAI,SAAS,CAAC,KAAwB;QACpC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;IAID;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS,CAAC,KAA6C;QACzD,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC1C,CAAC;CACF"}
|
||||
12
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.d.ts
generated
vendored
Normal file
12
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { CompatClient } from './compat-client';
|
||||
/**
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare class HeartbeatInfo {
|
||||
private client;
|
||||
constructor(client: CompatClient);
|
||||
outgoing: number;
|
||||
incoming: number;
|
||||
}
|
||||
23
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.js
generated
vendored
Normal file
23
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class HeartbeatInfo {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
get outgoing() {
|
||||
return this.client.heartbeatOutgoing;
|
||||
}
|
||||
set outgoing(value) {
|
||||
this.client.heartbeatOutgoing = value;
|
||||
}
|
||||
get incoming() {
|
||||
return this.client.heartbeatIncoming;
|
||||
}
|
||||
set incoming(value) {
|
||||
this.client.heartbeatIncoming = value;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=heartbeat-info.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/compatibility/heartbeat-info.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"heartbeat-info.js","sourceRoot":"","sources":["../../src/compatibility/heartbeat-info.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACxB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACvC,CAAC;IAED,IAAI,QAAQ,CAAC,KAAa;QACxB,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;IACvC,CAAC;IAED,IAAI,QAAQ,CAAC,KAAa;QACxB,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACxC,CAAC;CACF"}
|
||||
67
node_modules/@stomp/stompjs/esm6/compatibility/stomp.d.ts
generated
vendored
Normal file
67
node_modules/@stomp/stompjs/esm6/compatibility/stomp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { CompatClient } from './compat-client';
|
||||
/**
|
||||
* STOMP Class, acts like a factory to create {@link Client}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}.
|
||||
*/
|
||||
export declare class Stomp {
|
||||
/**
|
||||
* In case you need to use a non standard class for WebSocket.
|
||||
*
|
||||
* For example when using within NodeJS environment:
|
||||
*
|
||||
* ```javascript
|
||||
* StompJs = require('../../esm5/');
|
||||
* Stomp = StompJs.Stomp;
|
||||
* Stomp.WebSocketClass = require('websocket').w3cwebsocket;
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
static WebSocketClass: any;
|
||||
/**
|
||||
* This method creates a WebSocket client that is connected to
|
||||
* the STOMP server located at the url.
|
||||
*
|
||||
* ```javascript
|
||||
* var url = "ws://localhost:61614/stomp";
|
||||
* var client = Stomp.client(url);
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*/
|
||||
static client(url: string, protocols?: string[]): CompatClient;
|
||||
/**
|
||||
* This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
|
||||
* specify the WebSocket to use (either a standard HTML5 WebSocket or
|
||||
* a similar object).
|
||||
*
|
||||
* In order to support reconnection, the function Client._connect should be callable more than once.
|
||||
* While reconnecting
|
||||
* a new instance of underlying transport (TCP Socket, WebSocket or SockJS) will be needed. So, this function
|
||||
* alternatively allows passing a function that should return a new instance of the underlying socket.
|
||||
*
|
||||
* ```javascript
|
||||
* var client = Stomp.over(function(){
|
||||
* return new WebSocket('ws://localhost:15674/ws')
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
static over(ws: any): CompatClient;
|
||||
}
|
||||
102
node_modules/@stomp/stompjs/esm6/compatibility/stomp.js
generated
vendored
Normal file
102
node_modules/@stomp/stompjs/esm6/compatibility/stomp.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import { Versions } from '../versions';
|
||||
import { CompatClient } from './compat-client';
|
||||
/**
|
||||
* STOMP Class, acts like a factory to create {@link Client}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}.
|
||||
*/
|
||||
export class Stomp {
|
||||
/**
|
||||
* This method creates a WebSocket client that is connected to
|
||||
* the STOMP server located at the url.
|
||||
*
|
||||
* ```javascript
|
||||
* var url = "ws://localhost:61614/stomp";
|
||||
* var client = Stomp.client(url);
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*/
|
||||
static client(url, protocols) {
|
||||
// This is a hack to allow another implementation than the standard
|
||||
// HTML5 WebSocket class.
|
||||
//
|
||||
// It is possible to use another class by calling
|
||||
//
|
||||
// Stomp.WebSocketClass = MozWebSocket
|
||||
//
|
||||
// *prior* to call `Stomp.client()`.
|
||||
//
|
||||
// This hack is deprecated and `Stomp.over()` method should be used
|
||||
// instead.
|
||||
// See remarks on the function Stomp.over
|
||||
if (protocols == null) {
|
||||
protocols = Versions.default.protocolVersions();
|
||||
}
|
||||
const wsFn = () => {
|
||||
const klass = Stomp.WebSocketClass || WebSocket;
|
||||
return new klass(url, protocols);
|
||||
};
|
||||
return new CompatClient(wsFn);
|
||||
}
|
||||
/**
|
||||
* This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
|
||||
* specify the WebSocket to use (either a standard HTML5 WebSocket or
|
||||
* a similar object).
|
||||
*
|
||||
* In order to support reconnection, the function Client._connect should be callable more than once.
|
||||
* While reconnecting
|
||||
* a new instance of underlying transport (TCP Socket, WebSocket or SockJS) will be needed. So, this function
|
||||
* alternatively allows passing a function that should return a new instance of the underlying socket.
|
||||
*
|
||||
* ```javascript
|
||||
* var client = Stomp.over(function(){
|
||||
* return new WebSocket('ws://localhost:15674/ws')
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
static over(ws) {
|
||||
let wsFn;
|
||||
if (typeof ws === 'function') {
|
||||
wsFn = ws;
|
||||
}
|
||||
else {
|
||||
console.warn('Stomp.over did not receive a factory, auto reconnect will not work. ' +
|
||||
'Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over');
|
||||
wsFn = () => ws;
|
||||
}
|
||||
return new CompatClient(wsFn);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* In case you need to use a non standard class for WebSocket.
|
||||
*
|
||||
* For example when using within NodeJS environment:
|
||||
*
|
||||
* ```javascript
|
||||
* StompJs = require('../../esm5/');
|
||||
* Stomp = StompJs.Stomp;
|
||||
* Stomp.WebSocketClass = require('websocket').w3cwebsocket;
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
// tslint:disable-next-line:variable-name
|
||||
Stomp.WebSocketClass = null;
|
||||
//# sourceMappingURL=stomp.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/compatibility/stomp.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/compatibility/stomp.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stomp.js","sourceRoot":"","sources":["../../src/compatibility/stomp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C;;;;;;;;GAQG;AACH,MAAM,OAAO,KAAK;IAqBhB;;;;;;;;;;;;;OAaG;IACI,MAAM,CAAC,MAAM,CAAC,GAAW,EAAE,SAAoB;QACpD,mEAAmE;QACnE,yBAAyB;QACzB,EAAE;QACF,iDAAiD;QACjD,EAAE;QACF,0CAA0C;QAC1C,EAAE;QACF,oCAAoC;QACpC,EAAE;QACF,mEAAmE;QACnE,WAAW;QAEX,yCAAyC;QACzC,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;SACjD;QACD,MAAM,IAAI,GAAG,GAAG,EAAE;YAChB,MAAM,KAAK,GAAG,KAAK,CAAC,cAAc,IAAI,SAAS,CAAC;YAChD,OAAO,IAAI,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,MAAM,CAAC,IAAI,CAAC,EAAO;QACxB,IAAI,IAAe,CAAC;QAEpB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,IAAI,GAAG,EAAE,CAAC;SACX;aAAM;YACL,OAAO,CAAC,IAAI,CACV,sEAAsE;gBACpE,+EAA+E,CAClF,CAAC;YACF,IAAI,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC;SACjB;QAED,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;;AA9FD;;;;;;;;;;;;;;;;GAgBG;AACH,yCAAyC;AAC3B,oBAAc,GAAQ,IAAI,CAAC"}
|
||||
95
node_modules/@stomp/stompjs/esm6/frame-impl.d.ts
generated
vendored
Normal file
95
node_modules/@stomp/stompjs/esm6/frame-impl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { IFrame } from './i-frame';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { IRawFrameType } from './types';
|
||||
/**
|
||||
* Frame class represents a STOMP frame.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare class FrameImpl implements IFrame {
|
||||
/**
|
||||
* STOMP Command
|
||||
*/
|
||||
command: string;
|
||||
/**
|
||||
* Headers, key value pairs.
|
||||
*/
|
||||
headers: StompHeaders;
|
||||
/**
|
||||
* Is this frame binary (based on whether body/binaryBody was passed when creating this frame).
|
||||
*/
|
||||
isBinaryBody: boolean;
|
||||
/**
|
||||
* body of the frame
|
||||
*/
|
||||
readonly body: string;
|
||||
private _body;
|
||||
/**
|
||||
* body as Uint8Array
|
||||
*/
|
||||
readonly binaryBody: Uint8Array;
|
||||
private _binaryBody;
|
||||
private escapeHeaderValues;
|
||||
private skipContentLengthHeader;
|
||||
/**
|
||||
* Frame constructor. `command`, `headers` and `body` are available as properties.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(params: {
|
||||
command: string;
|
||||
headers?: StompHeaders;
|
||||
body?: string;
|
||||
binaryBody?: Uint8Array;
|
||||
escapeHeaderValues?: boolean;
|
||||
skipContentLengthHeader?: boolean;
|
||||
});
|
||||
/**
|
||||
* deserialize a STOMP Frame from raw data.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static fromRawFrame(rawFrame: IRawFrameType, escapeHeaderValues: boolean): FrameImpl;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* serialize this Frame in a format suitable to be passed to WebSocket.
|
||||
* If the body is string the output will be string.
|
||||
* If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
serialize(): string | ArrayBuffer;
|
||||
private serializeCmdAndHeaders;
|
||||
private isBodyEmpty;
|
||||
private bodyLength;
|
||||
/**
|
||||
* Compute the size of a UTF-8 string by counting its number of bytes
|
||||
* (and not the number of characters composing the string)
|
||||
*/
|
||||
private static sizeOfUTF8;
|
||||
private static toUnit8Array;
|
||||
/**
|
||||
* Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static marshall(params: {
|
||||
command: string;
|
||||
headers?: StompHeaders;
|
||||
body?: string;
|
||||
binaryBody?: Uint8Array;
|
||||
escapeHeaderValues?: boolean;
|
||||
skipContentLengthHeader?: boolean;
|
||||
}): string | ArrayBuffer;
|
||||
/**
|
||||
* Escape header values
|
||||
*/
|
||||
private static hdrValueEscape;
|
||||
/**
|
||||
* UnEscape header values
|
||||
*/
|
||||
private static hdrValueUnEscape;
|
||||
}
|
||||
170
node_modules/@stomp/stompjs/esm6/frame-impl.js
generated
vendored
Normal file
170
node_modules/@stomp/stompjs/esm6/frame-impl.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
import { BYTE } from './byte';
|
||||
/**
|
||||
* Frame class represents a STOMP frame.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class FrameImpl {
|
||||
/**
|
||||
* Frame constructor. `command`, `headers` and `body` are available as properties.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(params) {
|
||||
const { command, headers, body, binaryBody, escapeHeaderValues, skipContentLengthHeader, } = params;
|
||||
this.command = command;
|
||||
this.headers = Object.assign({}, headers || {});
|
||||
if (binaryBody) {
|
||||
this._binaryBody = binaryBody;
|
||||
this.isBinaryBody = true;
|
||||
}
|
||||
else {
|
||||
this._body = body || '';
|
||||
this.isBinaryBody = false;
|
||||
}
|
||||
this.escapeHeaderValues = escapeHeaderValues || false;
|
||||
this.skipContentLengthHeader = skipContentLengthHeader || false;
|
||||
}
|
||||
/**
|
||||
* body of the frame
|
||||
*/
|
||||
get body() {
|
||||
if (!this._body && this.isBinaryBody) {
|
||||
this._body = new TextDecoder().decode(this._binaryBody);
|
||||
}
|
||||
return this._body;
|
||||
}
|
||||
/**
|
||||
* body as Uint8Array
|
||||
*/
|
||||
get binaryBody() {
|
||||
if (!this._binaryBody && !this.isBinaryBody) {
|
||||
this._binaryBody = new TextEncoder().encode(this._body);
|
||||
}
|
||||
return this._binaryBody;
|
||||
}
|
||||
/**
|
||||
* deserialize a STOMP Frame from raw data.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static fromRawFrame(rawFrame, escapeHeaderValues) {
|
||||
const headers = {};
|
||||
const trim = (str) => str.replace(/^\s+|\s+$/g, '');
|
||||
// In case of repeated headers, as per standards, first value need to be used
|
||||
for (const header of rawFrame.headers.reverse()) {
|
||||
const idx = header.indexOf(':');
|
||||
const key = trim(header[0]);
|
||||
let value = trim(header[1]);
|
||||
if (escapeHeaderValues &&
|
||||
rawFrame.command !== 'CONNECT' &&
|
||||
rawFrame.command !== 'CONNECTED') {
|
||||
value = FrameImpl.hdrValueUnEscape(value);
|
||||
}
|
||||
headers[key] = value;
|
||||
}
|
||||
return new FrameImpl({
|
||||
command: rawFrame.command,
|
||||
headers,
|
||||
binaryBody: rawFrame.binaryBody,
|
||||
escapeHeaderValues,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
toString() {
|
||||
return this.serializeCmdAndHeaders();
|
||||
}
|
||||
/**
|
||||
* serialize this Frame in a format suitable to be passed to WebSocket.
|
||||
* If the body is string the output will be string.
|
||||
* If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
serialize() {
|
||||
const cmdAndHeaders = this.serializeCmdAndHeaders();
|
||||
if (this.isBinaryBody) {
|
||||
return FrameImpl.toUnit8Array(cmdAndHeaders, this._binaryBody).buffer;
|
||||
}
|
||||
else {
|
||||
return cmdAndHeaders + this._body + BYTE.NULL;
|
||||
}
|
||||
}
|
||||
serializeCmdAndHeaders() {
|
||||
const lines = [this.command];
|
||||
if (this.skipContentLengthHeader) {
|
||||
delete this.headers['content-length'];
|
||||
}
|
||||
for (const name of Object.keys(this.headers || {})) {
|
||||
const value = this.headers[name];
|
||||
if (this.escapeHeaderValues &&
|
||||
this.command !== 'CONNECT' &&
|
||||
this.command !== 'CONNECTED') {
|
||||
lines.push(`${name}:${FrameImpl.hdrValueEscape(`${value}`)}`);
|
||||
}
|
||||
else {
|
||||
lines.push(`${name}:${value}`);
|
||||
}
|
||||
}
|
||||
if (this.isBinaryBody ||
|
||||
(!this.isBodyEmpty() && !this.skipContentLengthHeader)) {
|
||||
lines.push(`content-length:${this.bodyLength()}`);
|
||||
}
|
||||
return lines.join(BYTE.LF) + BYTE.LF + BYTE.LF;
|
||||
}
|
||||
isBodyEmpty() {
|
||||
return this.bodyLength() === 0;
|
||||
}
|
||||
bodyLength() {
|
||||
const binaryBody = this.binaryBody;
|
||||
return binaryBody ? binaryBody.length : 0;
|
||||
}
|
||||
/**
|
||||
* Compute the size of a UTF-8 string by counting its number of bytes
|
||||
* (and not the number of characters composing the string)
|
||||
*/
|
||||
static sizeOfUTF8(s) {
|
||||
return s ? new TextEncoder().encode(s).length : 0;
|
||||
}
|
||||
static toUnit8Array(cmdAndHeaders, binaryBody) {
|
||||
const uint8CmdAndHeaders = new TextEncoder().encode(cmdAndHeaders);
|
||||
const nullTerminator = new Uint8Array([0]);
|
||||
const uint8Frame = new Uint8Array(uint8CmdAndHeaders.length + binaryBody.length + nullTerminator.length);
|
||||
uint8Frame.set(uint8CmdAndHeaders);
|
||||
uint8Frame.set(binaryBody, uint8CmdAndHeaders.length);
|
||||
uint8Frame.set(nullTerminator, uint8CmdAndHeaders.length + binaryBody.length);
|
||||
return uint8Frame;
|
||||
}
|
||||
/**
|
||||
* Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static marshall(params) {
|
||||
const frame = new FrameImpl(params);
|
||||
return frame.serialize();
|
||||
}
|
||||
/**
|
||||
* Escape header values
|
||||
*/
|
||||
static hdrValueEscape(str) {
|
||||
return str
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/:/g, '\\c');
|
||||
}
|
||||
/**
|
||||
* UnEscape header values
|
||||
*/
|
||||
static hdrValueUnEscape(str) {
|
||||
return str
|
||||
.replace(/\\r/g, '\r')
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\c/g, ':')
|
||||
.replace(/\\\\/g, '\\');
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=frame-impl.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/frame-impl.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/frame-impl.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"frame-impl.js","sourceRoot":"","sources":["../src/frame-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B;;;;GAIG;AACH,MAAM,OAAO,SAAS;IAyCpB;;;;OAIG;IACH,YAAY,MAOX;QACC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,IAAI,EACJ,UAAU,EACV,kBAAkB,EAClB,uBAAuB,GACxB,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAI,MAAc,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;QAEzD,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;YAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;SAC1B;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;SAC3B;QACD,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,KAAK,CAAC;QACtD,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,IAAI,KAAK,CAAC;IAClE,CAAC;IA1DD;;OAEG;IACH,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE;YACpC,IAAI,CAAC,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SACzD;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAGD;;OAEG;IACH,IAAI,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACzD;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAyCD;;;;OAIG;IACI,MAAM,CAAC,YAAY,CACxB,QAAuB,EACvB,kBAA2B;QAE3B,MAAM,OAAO,GAAiB,EAAE,CAAC;QACjC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAEpE,6EAA6E;QAC7E,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE;YAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEhC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAE5B,IACE,kBAAkB;gBAClB,QAAQ,CAAC,OAAO,KAAK,SAAS;gBAC9B,QAAQ,CAAC,OAAO,KAAK,WAAW,EAChC;gBACA,KAAK,GAAG,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;aAC3C;YAED,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;SACtB;QAED,OAAO,IAAI,SAAS,CAAC;YACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,OAAO;YACP,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,kBAAkB;SACnB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,sBAAsB,EAAE,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACI,SAAS;QACd,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAEpD,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO,SAAS,CAAC,YAAY,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;SACvE;aAAM;YACL,OAAO,aAAa,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;SAC/C;IACH,CAAC;IAEO,sBAAsB;QAC5B,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAChC,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;SACvC;QAED,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE;YAClD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjC,IACE,IAAI,CAAC,kBAAkB;gBACvB,IAAI,CAAC,OAAO,KAAK,SAAS;gBAC1B,IAAI,CAAC,OAAO,KAAK,WAAW,EAC5B;gBACA,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC,cAAc,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;aAC/D;iBAAM;gBACL,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;aAChC;SACF;QACD,IACE,IAAI,CAAC,YAAY;YACjB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,EACtD;YACA,KAAK,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;SACnD;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACjD,CAAC;IAEO,WAAW;QACjB,OAAO,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAEO,UAAU;QAChB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,UAAU,CAAC,CAAS;QACjC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;IAEO,MAAM,CAAC,YAAY,CACzB,aAAqB,EACrB,UAAsB;QAEtB,MAAM,kBAAkB,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACnE,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,IAAI,UAAU,CAC/B,kBAAkB,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CACtE,CAAC;QAEF,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACnC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;QACtD,UAAU,CAAC,GAAG,CACZ,cAAc,EACd,kBAAkB,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAC9C,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,QAAQ,CAAC,MAOtB;QACC,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,SAAS,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,cAAc,CAAC,GAAW;QACvC,OAAO,GAAG;aACP,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;aACtB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;aACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;aACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,gBAAgB,CAAC,GAAW;QACzC,OAAO,GAAG;aACP,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;aACrB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;aACrB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
||||
35
node_modules/@stomp/stompjs/esm6/i-frame.d.ts
generated
vendored
Normal file
35
node_modules/@stomp/stompjs/esm6/i-frame.d.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
/**
|
||||
* It represents a STOMP frame. Many of the callbacks pass an IFrame received from
|
||||
* the STOMP broker. For advanced usage you might need to access [headers]{@link IFrame#headers}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* {@link IMessage} is an extended IFrame.
|
||||
*/
|
||||
export interface IFrame {
|
||||
/**
|
||||
* STOMP Command
|
||||
*/
|
||||
command: string;
|
||||
/**
|
||||
* Headers, key value pairs.
|
||||
*/
|
||||
headers: StompHeaders;
|
||||
/**
|
||||
* Is this frame binary (based on whether body/binaryBody was passed when creating this frame).
|
||||
*/
|
||||
isBinaryBody: boolean;
|
||||
/**
|
||||
* body of the frame as string
|
||||
*/
|
||||
readonly body: string;
|
||||
/**
|
||||
* body as Uint8Array
|
||||
*/
|
||||
readonly binaryBody: Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Alias for {@link IFrame}
|
||||
*/
|
||||
export declare type Frame = IFrame;
|
||||
1
node_modules/@stomp/stompjs/esm6/i-frame.js
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-frame.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=i-frame.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/i-frame.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-frame.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i-frame.js","sourceRoot":"","sources":["../src/i-frame.ts"],"names":[],"mappings":""}
|
||||
32
node_modules/@stomp/stompjs/esm6/i-message.d.ts
generated
vendored
Normal file
32
node_modules/@stomp/stompjs/esm6/i-message.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import { IFrame } from './i-frame';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
/**
|
||||
* Instance of Message will be passed to [subscription callback]{@link Client#subscribe}
|
||||
* and [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
* Since it is an extended {@link FrameImpl}, you can access [headers]{@link FrameImpl#headers}
|
||||
* and [body]{@link FrameImpl#body} as properties.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* See [Client#subscribe]{@link Client#subscribe} for example.
|
||||
*/
|
||||
export interface IMessage extends IFrame {
|
||||
/**
|
||||
* When subscribing with manual acknowledgement, call this method on the message to ACK the message.
|
||||
*
|
||||
* See [Client#ack]{@link Client#ack} for an example.
|
||||
*/
|
||||
ack: (headers?: StompHeaders) => void;
|
||||
/**
|
||||
* When subscribing with manual acknowledgement, call this method on the message to NACK the message.
|
||||
*
|
||||
* See [Client#nack]{@link Client#nack} for an example.
|
||||
*/
|
||||
nack: (headers?: StompHeaders) => void;
|
||||
}
|
||||
/**
|
||||
* Aliased to {@link IMessage}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type Message = IMessage;
|
||||
1
node_modules/@stomp/stompjs/esm6/i-message.js
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-message.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=i-message.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/i-message.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-message.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i-message.js","sourceRoot":"","sources":["../src/i-message.ts"],"names":[],"mappings":""}
|
||||
21
node_modules/@stomp/stompjs/esm6/i-transaction.d.ts
generated
vendored
Normal file
21
node_modules/@stomp/stompjs/esm6/i-transaction.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* A Transaction is created by calling [Client#begin]{@link Client#begin}
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* TODO: Example and caveat
|
||||
*/
|
||||
export interface ITransaction {
|
||||
/**
|
||||
* You will need to access this to send, ack, or nack within this transaction.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Commit this transaction. See [Client#commit]{@link Client#commit} for an example.
|
||||
*/
|
||||
commit: () => void;
|
||||
/**
|
||||
* Abort this transaction. See [Client#abort]{@link Client#abort} for an example.
|
||||
*/
|
||||
abort: () => void;
|
||||
}
|
||||
1
node_modules/@stomp/stompjs/esm6/i-transaction.js
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-transaction.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
//# sourceMappingURL=i-transaction.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/i-transaction.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/i-transaction.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"i-transaction.js","sourceRoot":"","sources":["../src/i-transaction.ts"],"names":[],"mappings":""}
|
||||
13
node_modules/@stomp/stompjs/esm6/index.d.ts
generated
vendored
Normal file
13
node_modules/@stomp/stompjs/esm6/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export * from './client';
|
||||
export * from './frame-impl';
|
||||
export * from './i-frame';
|
||||
export * from './i-message';
|
||||
export * from './parser';
|
||||
export * from './stomp-config';
|
||||
export * from './stomp-headers';
|
||||
export * from './stomp-subscription';
|
||||
export * from './i-transaction';
|
||||
export * from './types';
|
||||
export * from './versions';
|
||||
export * from './compatibility/compat-client';
|
||||
export * from './compatibility/stomp';
|
||||
12
node_modules/@stomp/stompjs/esm6/index.js
generated
vendored
Normal file
12
node_modules/@stomp/stompjs/esm6/index.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export * from './client';
|
||||
export * from './frame-impl';
|
||||
export * from './parser';
|
||||
export * from './stomp-config';
|
||||
export * from './stomp-headers';
|
||||
export * from './stomp-subscription';
|
||||
export * from './types';
|
||||
export * from './versions';
|
||||
// Compatibility code
|
||||
export * from './compatibility/compat-client';
|
||||
export * from './compatibility/stomp';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/index.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAG7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAErC,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAE3B,qBAAqB;AACrB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC"}
|
||||
70
node_modules/@stomp/stompjs/esm6/parser.d.ts
generated
vendored
Normal file
70
node_modules/@stomp/stompjs/esm6/parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import { IRawFrameType } from './types';
|
||||
/**
|
||||
* This is an evented, rec descent parser.
|
||||
* A stream of Octets can be passed and whenever it recognizes
|
||||
* a complete Frame or an incoming ping it will invoke the registered callbacks.
|
||||
*
|
||||
* All incoming Octets are fed into _onByte function.
|
||||
* Depending on current state the _onByte function keeps changing.
|
||||
* Depending on the state it keeps accumulating into _token and _results.
|
||||
* State is indicated by current value of _onByte, all states are named as _collect.
|
||||
*
|
||||
* STOMP standards https://stomp.github.io/stomp-specification-1.2.html
|
||||
* imply that all lengths are considered in bytes (instead of string lengths).
|
||||
* So, before actual parsing, if the incoming data is String it is converted to Octets.
|
||||
* This allows faithful implementation of the protocol and allows NULL Octets to be present in the body.
|
||||
*
|
||||
* There is no peek function on the incoming data.
|
||||
* When a state change occurs based on an Octet without consuming the Octet,
|
||||
* the Octet, after state change, is fed again (_reinjectByte).
|
||||
* This became possible as the state change can be determined by inspecting just one Octet.
|
||||
*
|
||||
* There are two modes to collect the body, if content-length header is there then it by counting Octets
|
||||
* otherwise it is determined by NULL terminator.
|
||||
*
|
||||
* Following the standards, the command and headers are converted to Strings
|
||||
* and the body is returned as Octets.
|
||||
* Headers are returned as an array and not as Hash - to allow multiple occurrence of an header.
|
||||
*
|
||||
* This parser does not use Regular Expressions as that can only operate on Strings.
|
||||
*
|
||||
* It handles if multiple STOMP frames are given as one chunk, a frame is split into multiple chunks, or
|
||||
* any combination there of. The parser remembers its state (any partial frame) and continues when a new chunk
|
||||
* is pushed.
|
||||
*
|
||||
* Typically the higher level function will convert headers to Hash, handle unescaping of header values
|
||||
* (which is protocol version specific), and convert body to text.
|
||||
*
|
||||
* Check the parser.spec.js to understand cases that this parser is supposed to handle.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare class Parser {
|
||||
onFrame: (rawFrame: IRawFrameType) => void;
|
||||
onIncomingPing: () => void;
|
||||
private readonly _encoder;
|
||||
private readonly _decoder;
|
||||
private _results;
|
||||
private _token;
|
||||
private _headerKey;
|
||||
private _bodyBytesRemaining;
|
||||
private _onByte;
|
||||
constructor(onFrame: (rawFrame: IRawFrameType) => void, onIncomingPing: () => void);
|
||||
parseChunk(segment: string | ArrayBuffer, appendMissingNULLonIncoming?: boolean): void;
|
||||
private _collectFrame;
|
||||
private _collectCommand;
|
||||
private _collectHeaders;
|
||||
private _reinjectByte;
|
||||
private _collectHeaderKey;
|
||||
private _collectHeaderValue;
|
||||
private _setupCollectBody;
|
||||
private _collectBodyNullTerminated;
|
||||
private _collectBodyFixedSize;
|
||||
private _retrievedBody;
|
||||
private _consumeByte;
|
||||
private _consumeTokenAsUTF8;
|
||||
private _consumeTokenAsRaw;
|
||||
private _initState;
|
||||
}
|
||||
214
node_modules/@stomp/stompjs/esm6/parser.js
generated
vendored
Normal file
214
node_modules/@stomp/stompjs/esm6/parser.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const NULL = 0;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const LF = 10;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const CR = 13;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const COLON = 58;
|
||||
/**
|
||||
* This is an evented, rec descent parser.
|
||||
* A stream of Octets can be passed and whenever it recognizes
|
||||
* a complete Frame or an incoming ping it will invoke the registered callbacks.
|
||||
*
|
||||
* All incoming Octets are fed into _onByte function.
|
||||
* Depending on current state the _onByte function keeps changing.
|
||||
* Depending on the state it keeps accumulating into _token and _results.
|
||||
* State is indicated by current value of _onByte, all states are named as _collect.
|
||||
*
|
||||
* STOMP standards https://stomp.github.io/stomp-specification-1.2.html
|
||||
* imply that all lengths are considered in bytes (instead of string lengths).
|
||||
* So, before actual parsing, if the incoming data is String it is converted to Octets.
|
||||
* This allows faithful implementation of the protocol and allows NULL Octets to be present in the body.
|
||||
*
|
||||
* There is no peek function on the incoming data.
|
||||
* When a state change occurs based on an Octet without consuming the Octet,
|
||||
* the Octet, after state change, is fed again (_reinjectByte).
|
||||
* This became possible as the state change can be determined by inspecting just one Octet.
|
||||
*
|
||||
* There are two modes to collect the body, if content-length header is there then it by counting Octets
|
||||
* otherwise it is determined by NULL terminator.
|
||||
*
|
||||
* Following the standards, the command and headers are converted to Strings
|
||||
* and the body is returned as Octets.
|
||||
* Headers are returned as an array and not as Hash - to allow multiple occurrence of an header.
|
||||
*
|
||||
* This parser does not use Regular Expressions as that can only operate on Strings.
|
||||
*
|
||||
* It handles if multiple STOMP frames are given as one chunk, a frame is split into multiple chunks, or
|
||||
* any combination there of. The parser remembers its state (any partial frame) and continues when a new chunk
|
||||
* is pushed.
|
||||
*
|
||||
* Typically the higher level function will convert headers to Hash, handle unescaping of header values
|
||||
* (which is protocol version specific), and convert body to text.
|
||||
*
|
||||
* Check the parser.spec.js to understand cases that this parser is supposed to handle.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class Parser {
|
||||
constructor(onFrame, onIncomingPing) {
|
||||
this.onFrame = onFrame;
|
||||
this.onIncomingPing = onIncomingPing;
|
||||
this._encoder = new TextEncoder();
|
||||
this._decoder = new TextDecoder();
|
||||
this._token = [];
|
||||
this._initState();
|
||||
}
|
||||
parseChunk(segment, appendMissingNULLonIncoming = false) {
|
||||
let chunk;
|
||||
if (segment instanceof ArrayBuffer) {
|
||||
chunk = new Uint8Array(segment);
|
||||
}
|
||||
else {
|
||||
chunk = this._encoder.encode(segment);
|
||||
}
|
||||
// See https://github.com/stomp-js/stompjs/issues/89
|
||||
// Remove when underlying issue is fixed.
|
||||
//
|
||||
// Send a NULL byte, if the last byte of a Text frame was not NULL.F
|
||||
if (appendMissingNULLonIncoming && chunk[chunk.length - 1] !== 0) {
|
||||
const chunkWithNull = new Uint8Array(chunk.length + 1);
|
||||
chunkWithNull.set(chunk, 0);
|
||||
chunkWithNull[chunk.length] = 0;
|
||||
chunk = chunkWithNull;
|
||||
}
|
||||
// tslint:disable-next-line:prefer-for-of
|
||||
for (let i = 0; i < chunk.length; i++) {
|
||||
const byte = chunk[i];
|
||||
this._onByte(byte);
|
||||
}
|
||||
}
|
||||
// The following implements a simple Rec Descent Parser.
|
||||
// The grammar is simple and just one byte tells what should be the next state
|
||||
_collectFrame(byte) {
|
||||
if (byte === NULL) {
|
||||
// Ignore
|
||||
return;
|
||||
}
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
// Incoming Ping
|
||||
this.onIncomingPing();
|
||||
return;
|
||||
}
|
||||
this._onByte = this._collectCommand;
|
||||
this._reinjectByte(byte);
|
||||
}
|
||||
_collectCommand(byte) {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._results.command = this._consumeTokenAsUTF8();
|
||||
this._onByte = this._collectHeaders;
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
_collectHeaders(byte) {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._setupCollectBody();
|
||||
return;
|
||||
}
|
||||
this._onByte = this._collectHeaderKey;
|
||||
this._reinjectByte(byte);
|
||||
}
|
||||
_reinjectByte(byte) {
|
||||
this._onByte(byte);
|
||||
}
|
||||
_collectHeaderKey(byte) {
|
||||
if (byte === COLON) {
|
||||
this._headerKey = this._consumeTokenAsUTF8();
|
||||
this._onByte = this._collectHeaderValue;
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
_collectHeaderValue(byte) {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._results.headers.push([this._headerKey, this._consumeTokenAsUTF8()]);
|
||||
this._headerKey = undefined;
|
||||
this._onByte = this._collectHeaders;
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
_setupCollectBody() {
|
||||
const contentLengthHeader = this._results.headers.filter((header) => {
|
||||
return header[0] === 'content-length';
|
||||
})[0];
|
||||
if (contentLengthHeader) {
|
||||
this._bodyBytesRemaining = parseInt(contentLengthHeader[1], 10);
|
||||
this._onByte = this._collectBodyFixedSize;
|
||||
}
|
||||
else {
|
||||
this._onByte = this._collectBodyNullTerminated;
|
||||
}
|
||||
}
|
||||
_collectBodyNullTerminated(byte) {
|
||||
if (byte === NULL) {
|
||||
this._retrievedBody();
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
_collectBodyFixedSize(byte) {
|
||||
// It is post decrement, so that we discard the trailing NULL octet
|
||||
if (this._bodyBytesRemaining-- === 0) {
|
||||
this._retrievedBody();
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
_retrievedBody() {
|
||||
this._results.binaryBody = this._consumeTokenAsRaw();
|
||||
this.onFrame(this._results);
|
||||
this._initState();
|
||||
}
|
||||
// Rec Descent Parser helpers
|
||||
_consumeByte(byte) {
|
||||
this._token.push(byte);
|
||||
}
|
||||
_consumeTokenAsUTF8() {
|
||||
return this._decoder.decode(this._consumeTokenAsRaw());
|
||||
}
|
||||
_consumeTokenAsRaw() {
|
||||
const rawResult = new Uint8Array(this._token);
|
||||
this._token = [];
|
||||
return rawResult;
|
||||
}
|
||||
_initState() {
|
||||
this._results = {
|
||||
command: undefined,
|
||||
headers: [],
|
||||
binaryBody: undefined,
|
||||
};
|
||||
this._token = [];
|
||||
this._headerKey = undefined;
|
||||
this._onByte = this._collectFrame;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=parser.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/parser.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/parser.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,IAAI,GAAG,CAAC,CAAC;AACf;;GAEG;AACH,MAAM,EAAE,GAAG,EAAE,CAAC;AACd;;GAEG;AACH,MAAM,EAAE,GAAG,EAAE,CAAC;AACd;;GAEG;AACH,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,OAAO,MAAM;IAYjB,YACS,OAA0C,EAC1C,cAA0B;QAD1B,YAAO,GAAP,OAAO,CAAmC;QAC1C,mBAAc,GAAd,cAAc,CAAY;QAblB,aAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;QAC7B,aAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;QAItC,WAAM,GAAa,EAAE,CAAC;QAU5B,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEM,UAAU,CACf,OAA6B,EAC7B,8BAAuC,KAAK;QAE5C,IAAI,KAAiB,CAAC;QAEtB,IAAI,OAAO,YAAY,WAAW,EAAE;YAClC,KAAK,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;SACjC;aAAM;YACL,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,oDAAoD;QACpD,yCAAyC;QACzC,EAAE;QACF,oEAAoE;QACpE,IAAI,2BAA2B,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE;YAChE,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACvD,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC5B,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,KAAK,GAAG,aAAa,CAAC;SACvB;QAED,yCAAyC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SACpB;IACH,CAAC;IAED,wDAAwD;IACxD,8EAA8E;IAEtE,aAAa,CAAC,IAAY;QAChC,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,SAAS;YACT,OAAO;SACR;QACD,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,YAAY;YACZ,OAAO;SACR;QACD,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,gBAAgB;YAChB,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO;SACR;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,YAAY;YACZ,OAAO;SACR;QACD,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;YACpC,OAAO;SACR;QAED,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,YAAY;YACZ,OAAO;SACR;QACD,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzB,OAAO;SACR;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,aAAa,CAAC,IAAY;QAChC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAEO,iBAAiB,CAAC,IAAY;QACpC,IAAI,IAAI,KAAK,KAAK,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC;YACxC,OAAO;SACR;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,mBAAmB,CAAC,IAAY;QACtC,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,YAAY;YACZ,OAAO;SACR;QACD,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;YACpC,OAAO;SACR;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,iBAAiB;QACvB,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CACtD,CAAC,MAAwB,EAAE,EAAE;YAC3B,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC;QACxC,CAAC,CACF,CAAC,CAAC,CAAC,CAAC;QAEL,IAAI,mBAAmB,EAAE;YACvB,IAAI,CAAC,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC;SAC3C;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,0BAA0B,CAAC;SAChD;IACH,CAAC;IAEO,0BAA0B,CAAC,IAAY;QAC7C,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO;SACR;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,qBAAqB,CAAC,IAAY;QACxC,mEAAmE;QACnE,IAAI,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,EAAE;YACpC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO;SACR;QACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAErD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5B,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,6BAA6B;IAErB,YAAY,CAAC,IAAY;QAC/B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEO,mBAAmB;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzD,CAAC;IAEO,kBAAkB;QACxB,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,QAAQ,GAAG;YACd,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,EAAE;YACX,UAAU,EAAE,SAAS;SACtB,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;IACpC,CAAC;CACF"}
|
||||
119
node_modules/@stomp/stompjs/esm6/stomp-config.d.ts
generated
vendored
Normal file
119
node_modules/@stomp/stompjs/esm6/stomp-config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { ActivationState, closeEventCallbackType, debugFnType, frameCallbackType, messageCallbackType, wsErrorCallbackType } from './types';
|
||||
import { Versions } from './versions';
|
||||
/**
|
||||
* Configuration options for STOMP Client, each key corresponds to
|
||||
* field by the same name in {@link Client}. This can be passed to
|
||||
* the constructor of {@link Client} or to [Client#configure]{@link Client#configure}.
|
||||
*
|
||||
* There used to be a class with the same name in `@stomp/ng2-stompjs`, which has been replaced by
|
||||
* {@link RxStompConfig} and {@link InjectableRxStompConfig}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare class StompConfig {
|
||||
/**
|
||||
* See [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*/
|
||||
brokerURL?: string;
|
||||
/**
|
||||
* See See [Client#stompVersions]{@link Client#stompVersions}.
|
||||
*/
|
||||
stompVersions?: Versions;
|
||||
/**
|
||||
* See [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
webSocketFactory?: () => any;
|
||||
/**
|
||||
* See [Client#connectionTimeout]{@link Client#connectionTimeout}.
|
||||
*/
|
||||
connectionTimeout?: number;
|
||||
/**
|
||||
* See [Client#reconnectDelay]{@link Client#reconnectDelay}.
|
||||
*/
|
||||
reconnectDelay?: number;
|
||||
/**
|
||||
* See [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}.
|
||||
*/
|
||||
heartbeatIncoming?: number;
|
||||
/**
|
||||
* See [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*/
|
||||
heartbeatOutgoing?: number;
|
||||
/**
|
||||
* See [Client#splitLargeFrames]{@link Client#splitLargeFrames}.
|
||||
*/
|
||||
splitLargeFrames?: boolean;
|
||||
/**
|
||||
* See [Client#forceBinaryWSFrames]{@link Client#forceBinaryWSFrames}.
|
||||
*/
|
||||
forceBinaryWSFrames?: boolean;
|
||||
/**
|
||||
* See [Client#appendMissingNULLonIncoming]{@link Client#appendMissingNULLonIncoming}.
|
||||
*/
|
||||
appendMissingNULLonIncoming?: boolean;
|
||||
/**
|
||||
* See [Client#maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
|
||||
*/
|
||||
maxWebSocketChunkSize?: number;
|
||||
/**
|
||||
* See [Client#connectHeaders]{@link Client#connectHeaders}.
|
||||
*/
|
||||
connectHeaders?: StompHeaders;
|
||||
/**
|
||||
* See [Client#disconnectHeaders]{@link Client#disconnectHeaders}.
|
||||
*/
|
||||
disconnectHeaders?: StompHeaders;
|
||||
/**
|
||||
* See [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*/
|
||||
onUnhandledMessage?: messageCallbackType;
|
||||
/**
|
||||
* See [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
*/
|
||||
onUnhandledReceipt?: frameCallbackType;
|
||||
/**
|
||||
* See [Client#onUnhandledFrame]{@link Client#onUnhandledFrame}.
|
||||
*/
|
||||
onUnhandledFrame?: frameCallbackType;
|
||||
/**
|
||||
* See [Client#beforeConnect]{@link Client#beforeConnect}.
|
||||
*/
|
||||
beforeConnect?: () => void | Promise<void>;
|
||||
/**
|
||||
* See [Client#onConnect]{@link Client#onConnect}.
|
||||
*/
|
||||
onConnect?: frameCallbackType;
|
||||
/**
|
||||
* See [Client#onDisconnect]{@link Client#onDisconnect}.
|
||||
*/
|
||||
onDisconnect?: frameCallbackType;
|
||||
/**
|
||||
* See [Client#onStompError]{@link Client#onStompError}.
|
||||
*/
|
||||
onStompError?: frameCallbackType;
|
||||
/**
|
||||
* See [Client#onWebSocketClose]{@link Client#onWebSocketClose}.
|
||||
*/
|
||||
onWebSocketClose?: closeEventCallbackType;
|
||||
/**
|
||||
* See [Client#onWebSocketError]{@link Client#onWebSocketError}.
|
||||
*/
|
||||
onWebSocketError?: wsErrorCallbackType;
|
||||
/**
|
||||
* See [Client#logRawCommunication]{@link Client#logRawCommunication}.
|
||||
*/
|
||||
logRawCommunication?: boolean;
|
||||
/**
|
||||
* See [Client#debug]{@link Client#debug}.
|
||||
*/
|
||||
debug?: debugFnType;
|
||||
/**
|
||||
* See [Client#discardWebsocketOnCommFailure]{@link Client#discardWebsocketOnCommFailure}.
|
||||
*/
|
||||
discardWebsocketOnCommFailure?: boolean;
|
||||
/**
|
||||
* See [Client#onChangeState]{@link Client#onChangeState}.
|
||||
*/
|
||||
onChangeState?: (state: ActivationState) => void;
|
||||
}
|
||||
13
node_modules/@stomp/stompjs/esm6/stomp-config.js
generated
vendored
Normal file
13
node_modules/@stomp/stompjs/esm6/stomp-config.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Configuration options for STOMP Client, each key corresponds to
|
||||
* field by the same name in {@link Client}. This can be passed to
|
||||
* the constructor of {@link Client} or to [Client#configure]{@link Client#configure}.
|
||||
*
|
||||
* There used to be a class with the same name in `@stomp/ng2-stompjs`, which has been replaced by
|
||||
* {@link RxStompConfig} and {@link InjectableRxStompConfig}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompConfig {
|
||||
}
|
||||
//# sourceMappingURL=stomp-config.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/stomp-config.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/stomp-config.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stomp-config.js","sourceRoot":"","sources":["../src/stomp-config.ts"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AACH,MAAM,OAAO,WAAW;CAkIvB"}
|
||||
72
node_modules/@stomp/stompjs/esm6/stomp-handler.d.ts
generated
vendored
Normal file
72
node_modules/@stomp/stompjs/esm6/stomp-handler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import { Client } from './client';
|
||||
import { ITransaction } from './i-transaction';
|
||||
import { StompConfig } from './stomp-config';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { StompSubscription } from './stomp-subscription';
|
||||
import { closeEventCallbackType, debugFnType, frameCallbackType, IPublishParams, IStompSocket, messageCallbackType, wsErrorCallbackType } from './types';
|
||||
import { Versions } from './versions';
|
||||
/**
|
||||
* The STOMP protocol handler
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare class StompHandler {
|
||||
private _client;
|
||||
_webSocket: IStompSocket;
|
||||
debug: debugFnType;
|
||||
stompVersions: Versions;
|
||||
connectHeaders: StompHeaders;
|
||||
disconnectHeaders: StompHeaders;
|
||||
heartbeatIncoming: number;
|
||||
heartbeatOutgoing: number;
|
||||
onUnhandledMessage: messageCallbackType;
|
||||
onUnhandledReceipt: frameCallbackType;
|
||||
onUnhandledFrame: frameCallbackType;
|
||||
onConnect: frameCallbackType;
|
||||
onDisconnect: frameCallbackType;
|
||||
onStompError: frameCallbackType;
|
||||
onWebSocketClose: closeEventCallbackType;
|
||||
onWebSocketError: wsErrorCallbackType;
|
||||
logRawCommunication: boolean;
|
||||
splitLargeFrames: boolean;
|
||||
maxWebSocketChunkSize: number;
|
||||
forceBinaryWSFrames: boolean;
|
||||
appendMissingNULLonIncoming: boolean;
|
||||
discardWebsocketOnCommFailure: boolean;
|
||||
readonly connectedVersion: string;
|
||||
private _connectedVersion;
|
||||
readonly connected: boolean;
|
||||
private _connected;
|
||||
private readonly _subscriptions;
|
||||
private readonly _receiptWatchers;
|
||||
private _partialData;
|
||||
private _escapeHeaderValues;
|
||||
private _counter;
|
||||
private _pinger;
|
||||
private _ponger;
|
||||
private _lastServerActivityTS;
|
||||
private _onclose;
|
||||
constructor(_client: Client, _webSocket: IStompSocket, config?: StompConfig);
|
||||
configure(conf: StompConfig): void;
|
||||
start(): void;
|
||||
private readonly _serverFrameHandlers;
|
||||
private _setupHeartbeat;
|
||||
private _closeOrDiscardWebsocket;
|
||||
forceDisconnect(): void;
|
||||
_closeWebsocket(): void;
|
||||
private _discardWebsocket;
|
||||
private _transmit;
|
||||
dispose(): void;
|
||||
private _cleanUp;
|
||||
publish(params: IPublishParams): void;
|
||||
watchForReceipt(receiptId: string, callback: frameCallbackType): void;
|
||||
subscribe(destination: string, callback: messageCallbackType, headers?: StompHeaders): StompSubscription;
|
||||
unsubscribe(id: string, headers?: StompHeaders): void;
|
||||
begin(transactionId: string): ITransaction;
|
||||
commit(transactionId: string): void;
|
||||
abort(transactionId: string): void;
|
||||
ack(messageId: string, subscriptionId: string, headers?: StompHeaders): void;
|
||||
nack(messageId: string, subscriptionId: string, headers?: StompHeaders): void;
|
||||
}
|
||||
373
node_modules/@stomp/stompjs/esm6/stomp-handler.js
generated
vendored
Normal file
373
node_modules/@stomp/stompjs/esm6/stomp-handler.js
generated
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
import { BYTE } from './byte';
|
||||
import { FrameImpl } from './frame-impl';
|
||||
import { Parser } from './parser';
|
||||
import { StompSocketState, } from './types';
|
||||
import { Versions } from './versions';
|
||||
import { augmentWebsocket } from './augment-websocket';
|
||||
/**
|
||||
* The STOMP protocol handler
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class StompHandler {
|
||||
constructor(_client, _webSocket, config = {}) {
|
||||
this._client = _client;
|
||||
this._webSocket = _webSocket;
|
||||
this._serverFrameHandlers = {
|
||||
// [CONNECTED Frame](http://stomp.github.com/stomp-specification-1.2.html#CONNECTED_Frame)
|
||||
CONNECTED: frame => {
|
||||
this.debug(`connected to server ${frame.headers.server}`);
|
||||
this._connected = true;
|
||||
this._connectedVersion = frame.headers.version;
|
||||
// STOMP version 1.2 needs header values to be escaped
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
this._escapeHeaderValues = true;
|
||||
}
|
||||
this._setupHeartbeat(frame.headers);
|
||||
this.onConnect(frame);
|
||||
},
|
||||
// [MESSAGE Frame](http://stomp.github.com/stomp-specification-1.2.html#MESSAGE)
|
||||
MESSAGE: frame => {
|
||||
// the callback is registered when the client calls
|
||||
// `subscribe()`.
|
||||
// If there is no registered subscription for the received message,
|
||||
// the default `onUnhandledMessage` callback is used that the client can set.
|
||||
// This is useful for subscriptions that are automatically created
|
||||
// on the browser side (e.g. [RabbitMQ's temporary
|
||||
// queues](http://www.rabbitmq.com/stomp.html)).
|
||||
const subscription = frame.headers.subscription;
|
||||
const onReceive = this._subscriptions[subscription] || this.onUnhandledMessage;
|
||||
// bless the frame to be a Message
|
||||
const message = frame;
|
||||
const client = this;
|
||||
const messageId = this._connectedVersion === Versions.V1_2
|
||||
? message.headers.ack
|
||||
: message.headers['message-id'];
|
||||
// add `ack()` and `nack()` methods directly to the returned frame
|
||||
// so that a simple call to `message.ack()` can acknowledge the message.
|
||||
message.ack = (headers = {}) => {
|
||||
return client.ack(messageId, subscription, headers);
|
||||
};
|
||||
message.nack = (headers = {}) => {
|
||||
return client.nack(messageId, subscription, headers);
|
||||
};
|
||||
onReceive(message);
|
||||
},
|
||||
// [RECEIPT Frame](http://stomp.github.com/stomp-specification-1.2.html#RECEIPT)
|
||||
RECEIPT: frame => {
|
||||
const callback = this._receiptWatchers[frame.headers['receipt-id']];
|
||||
if (callback) {
|
||||
callback(frame);
|
||||
// Server will acknowledge only once, remove the callback
|
||||
delete this._receiptWatchers[frame.headers['receipt-id']];
|
||||
}
|
||||
else {
|
||||
this.onUnhandledReceipt(frame);
|
||||
}
|
||||
},
|
||||
// [ERROR Frame](http://stomp.github.com/stomp-specification-1.2.html#ERROR)
|
||||
ERROR: frame => {
|
||||
this.onStompError(frame);
|
||||
},
|
||||
};
|
||||
// used to index subscribers
|
||||
this._counter = 0;
|
||||
// subscription callbacks indexed by subscriber's ID
|
||||
this._subscriptions = {};
|
||||
// receipt-watchers indexed by receipts-ids
|
||||
this._receiptWatchers = {};
|
||||
this._partialData = '';
|
||||
this._escapeHeaderValues = false;
|
||||
this._lastServerActivityTS = Date.now();
|
||||
this.configure(config);
|
||||
}
|
||||
get connectedVersion() {
|
||||
return this._connectedVersion;
|
||||
}
|
||||
get connected() {
|
||||
return this._connected;
|
||||
}
|
||||
configure(conf) {
|
||||
// bulk assign all properties to this
|
||||
Object.assign(this, conf);
|
||||
}
|
||||
start() {
|
||||
const parser = new Parser(
|
||||
// On Frame
|
||||
rawFrame => {
|
||||
const frame = FrameImpl.fromRawFrame(rawFrame, this._escapeHeaderValues);
|
||||
// if this.logRawCommunication is set, the rawChunk is logged at this._webSocket.onmessage
|
||||
if (!this.logRawCommunication) {
|
||||
this.debug(`<<< ${frame}`);
|
||||
}
|
||||
const serverFrameHandler = this._serverFrameHandlers[frame.command] || this.onUnhandledFrame;
|
||||
serverFrameHandler(frame);
|
||||
},
|
||||
// On Incoming Ping
|
||||
() => {
|
||||
this.debug('<<< PONG');
|
||||
});
|
||||
this._webSocket.onmessage = (evt) => {
|
||||
this.debug('Received data');
|
||||
this._lastServerActivityTS = Date.now();
|
||||
if (this.logRawCommunication) {
|
||||
const rawChunkAsString = evt.data instanceof ArrayBuffer
|
||||
? new TextDecoder().decode(evt.data)
|
||||
: evt.data;
|
||||
this.debug(`<<< ${rawChunkAsString}`);
|
||||
}
|
||||
parser.parseChunk(evt.data, this.appendMissingNULLonIncoming);
|
||||
};
|
||||
this._onclose = (closeEvent) => {
|
||||
this.debug(`Connection closed to ${this._client.brokerURL}`);
|
||||
this._cleanUp();
|
||||
this.onWebSocketClose(closeEvent);
|
||||
};
|
||||
this._webSocket.onclose = this._onclose;
|
||||
this._webSocket.onerror = (errorEvent) => {
|
||||
this.onWebSocketError(errorEvent);
|
||||
};
|
||||
this._webSocket.onopen = () => {
|
||||
// Clone before updating
|
||||
const connectHeaders = Object.assign({}, this.connectHeaders);
|
||||
this.debug('Web Socket Opened...');
|
||||
connectHeaders['accept-version'] = this.stompVersions.supportedVersions();
|
||||
connectHeaders['heart-beat'] = [
|
||||
this.heartbeatOutgoing,
|
||||
this.heartbeatIncoming,
|
||||
].join(',');
|
||||
this._transmit({ command: 'CONNECT', headers: connectHeaders });
|
||||
};
|
||||
}
|
||||
_setupHeartbeat(headers) {
|
||||
if (headers.version !== Versions.V1_1 &&
|
||||
headers.version !== Versions.V1_2) {
|
||||
return;
|
||||
}
|
||||
// It is valid for the server to not send this header
|
||||
// https://stomp.github.io/stomp-specification-1.2.html#Heart-beating
|
||||
if (!headers['heart-beat']) {
|
||||
return;
|
||||
}
|
||||
// heart-beat header received from the server looks like:
|
||||
//
|
||||
// heart-beat: sx, sy
|
||||
const [serverOutgoing, serverIncoming] = headers['heart-beat']
|
||||
.split(',')
|
||||
.map((v) => parseInt(v, 10));
|
||||
if (this.heartbeatOutgoing !== 0 && serverIncoming !== 0) {
|
||||
const ttl = Math.max(this.heartbeatOutgoing, serverIncoming);
|
||||
this.debug(`send PING every ${ttl}ms`);
|
||||
this._pinger = setInterval(() => {
|
||||
if (this._webSocket.readyState === StompSocketState.OPEN) {
|
||||
this._webSocket.send(BYTE.LF);
|
||||
this.debug('>>> PING');
|
||||
}
|
||||
}, ttl);
|
||||
}
|
||||
if (this.heartbeatIncoming !== 0 && serverOutgoing !== 0) {
|
||||
const ttl = Math.max(this.heartbeatIncoming, serverOutgoing);
|
||||
this.debug(`check PONG every ${ttl}ms`);
|
||||
this._ponger = setInterval(() => {
|
||||
const delta = Date.now() - this._lastServerActivityTS;
|
||||
// We wait twice the TTL to be flexible on window's setInterval calls
|
||||
if (delta > ttl * 2) {
|
||||
this.debug(`did not receive server activity for the last ${delta}ms`);
|
||||
this._closeOrDiscardWebsocket();
|
||||
}
|
||||
}, ttl);
|
||||
}
|
||||
}
|
||||
_closeOrDiscardWebsocket() {
|
||||
if (this.discardWebsocketOnCommFailure) {
|
||||
this.debug('Discarding websocket, the underlying socket may linger for a while');
|
||||
this._discardWebsocket();
|
||||
}
|
||||
else {
|
||||
this.debug('Issuing close on the websocket');
|
||||
this._closeWebsocket();
|
||||
}
|
||||
}
|
||||
forceDisconnect() {
|
||||
if (this._webSocket) {
|
||||
if (this._webSocket.readyState === StompSocketState.CONNECTING ||
|
||||
this._webSocket.readyState === StompSocketState.OPEN) {
|
||||
this._closeOrDiscardWebsocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
_closeWebsocket() {
|
||||
this._webSocket.onmessage = () => { }; // ignore messages
|
||||
this._webSocket.close();
|
||||
}
|
||||
_discardWebsocket() {
|
||||
if (!this._webSocket.terminate) {
|
||||
augmentWebsocket(this._webSocket, (msg) => this.debug(msg));
|
||||
}
|
||||
this._webSocket.terminate();
|
||||
}
|
||||
_transmit(params) {
|
||||
const { command, headers, body, binaryBody, skipContentLengthHeader } = params;
|
||||
const frame = new FrameImpl({
|
||||
command,
|
||||
headers,
|
||||
body,
|
||||
binaryBody,
|
||||
escapeHeaderValues: this._escapeHeaderValues,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
let rawChunk = frame.serialize();
|
||||
if (this.logRawCommunication) {
|
||||
this.debug(`>>> ${rawChunk}`);
|
||||
}
|
||||
else {
|
||||
this.debug(`>>> ${frame}`);
|
||||
}
|
||||
if (this.forceBinaryWSFrames && typeof rawChunk === 'string') {
|
||||
rawChunk = new TextEncoder().encode(rawChunk);
|
||||
}
|
||||
if (typeof rawChunk !== 'string' || !this.splitLargeFrames) {
|
||||
this._webSocket.send(rawChunk);
|
||||
}
|
||||
else {
|
||||
let out = rawChunk;
|
||||
while (out.length > 0) {
|
||||
const chunk = out.substring(0, this.maxWebSocketChunkSize);
|
||||
out = out.substring(this.maxWebSocketChunkSize);
|
||||
this._webSocket.send(chunk);
|
||||
this.debug(`chunk sent = ${chunk.length}, remaining = ${out.length}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
dispose() {
|
||||
if (this.connected) {
|
||||
try {
|
||||
// clone before updating
|
||||
const disconnectHeaders = Object.assign({}, this.disconnectHeaders);
|
||||
if (!disconnectHeaders.receipt) {
|
||||
disconnectHeaders.receipt = `close-${this._counter++}`;
|
||||
}
|
||||
this.watchForReceipt(disconnectHeaders.receipt, frame => {
|
||||
this._closeWebsocket();
|
||||
this._cleanUp();
|
||||
this.onDisconnect(frame);
|
||||
});
|
||||
this._transmit({ command: 'DISCONNECT', headers: disconnectHeaders });
|
||||
}
|
||||
catch (error) {
|
||||
this.debug(`Ignoring error during disconnect ${error}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this._webSocket.readyState === StompSocketState.CONNECTING ||
|
||||
this._webSocket.readyState === StompSocketState.OPEN) {
|
||||
this._closeWebsocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
_cleanUp() {
|
||||
this._connected = false;
|
||||
if (this._pinger) {
|
||||
clearInterval(this._pinger);
|
||||
}
|
||||
if (this._ponger) {
|
||||
clearInterval(this._ponger);
|
||||
}
|
||||
}
|
||||
publish(params) {
|
||||
const { destination, headers, body, binaryBody, skipContentLengthHeader } = params;
|
||||
const hdrs = Object.assign({ destination }, headers);
|
||||
this._transmit({
|
||||
command: 'SEND',
|
||||
headers: hdrs,
|
||||
body,
|
||||
binaryBody,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
}
|
||||
watchForReceipt(receiptId, callback) {
|
||||
this._receiptWatchers[receiptId] = callback;
|
||||
}
|
||||
subscribe(destination, callback, headers = {}) {
|
||||
headers = Object.assign({}, headers);
|
||||
if (!headers.id) {
|
||||
headers.id = `sub-${this._counter++}`;
|
||||
}
|
||||
headers.destination = destination;
|
||||
this._subscriptions[headers.id] = callback;
|
||||
this._transmit({ command: 'SUBSCRIBE', headers });
|
||||
const client = this;
|
||||
return {
|
||||
id: headers.id,
|
||||
unsubscribe(hdrs) {
|
||||
return client.unsubscribe(headers.id, hdrs);
|
||||
},
|
||||
};
|
||||
}
|
||||
unsubscribe(id, headers = {}) {
|
||||
headers = Object.assign({}, headers);
|
||||
delete this._subscriptions[id];
|
||||
headers.id = id;
|
||||
this._transmit({ command: 'UNSUBSCRIBE', headers });
|
||||
}
|
||||
begin(transactionId) {
|
||||
const txId = transactionId || `tx-${this._counter++}`;
|
||||
this._transmit({
|
||||
command: 'BEGIN',
|
||||
headers: {
|
||||
transaction: txId,
|
||||
},
|
||||
});
|
||||
const client = this;
|
||||
return {
|
||||
id: txId,
|
||||
commit() {
|
||||
client.commit(txId);
|
||||
},
|
||||
abort() {
|
||||
client.abort(txId);
|
||||
},
|
||||
};
|
||||
}
|
||||
commit(transactionId) {
|
||||
this._transmit({
|
||||
command: 'COMMIT',
|
||||
headers: {
|
||||
transaction: transactionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
abort(transactionId) {
|
||||
this._transmit({
|
||||
command: 'ABORT',
|
||||
headers: {
|
||||
transaction: transactionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
ack(messageId, subscriptionId, headers = {}) {
|
||||
headers = Object.assign({}, headers);
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
headers.id = messageId;
|
||||
}
|
||||
else {
|
||||
headers['message-id'] = messageId;
|
||||
}
|
||||
headers.subscription = subscriptionId;
|
||||
this._transmit({ command: 'ACK', headers });
|
||||
}
|
||||
nack(messageId, subscriptionId, headers = {}) {
|
||||
headers = Object.assign({}, headers);
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
headers.id = messageId;
|
||||
}
|
||||
else {
|
||||
headers['message-id'] = messageId;
|
||||
}
|
||||
headers.subscription = subscriptionId;
|
||||
return this._transmit({ command: 'NACK', headers });
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=stomp-handler.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/stomp-handler.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/stomp-handler.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
12
node_modules/@stomp/stompjs/esm6/stomp-headers.d.ts
generated
vendored
Normal file
12
node_modules/@stomp/stompjs/esm6/stomp-headers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* STOMP headers. Many functions calls will accept headers as parameters.
|
||||
* The headers sent by Broker will be available as [IFrame#headers]{@link IFrame#headers}.
|
||||
*
|
||||
* `key` and `value` must be valid strings.
|
||||
* In addition, `key` must not contain `CR`, `LF`, or `:`.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare class StompHeaders {
|
||||
[key: string]: string;
|
||||
}
|
||||
12
node_modules/@stomp/stompjs/esm6/stomp-headers.js
generated
vendored
Normal file
12
node_modules/@stomp/stompjs/esm6/stomp-headers.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* STOMP headers. Many functions calls will accept headers as parameters.
|
||||
* The headers sent by Broker will be available as [IFrame#headers]{@link IFrame#headers}.
|
||||
*
|
||||
* `key` and `value` must be valid strings.
|
||||
* In addition, `key` must not contain `CR`, `LF`, or `:`.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompHeaders {
|
||||
}
|
||||
//# sourceMappingURL=stomp-headers.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/stomp-headers.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/stomp-headers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stomp-headers.js","sourceRoot":"","sources":["../src/stomp-headers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;CAExB"}
|
||||
16
node_modules/@stomp/stompjs/esm6/stomp-subscription.d.ts
generated
vendored
Normal file
16
node_modules/@stomp/stompjs/esm6/stomp-subscription.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
/**
|
||||
* Call [Client#subscribe]{@link Client#subscribe} to create a StompSubscription.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare class StompSubscription {
|
||||
/**
|
||||
* Id associated with this subscription.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Unsubscribe. See [Client#unsubscribe]{@link Client#unsubscribe} for an example.
|
||||
*/
|
||||
unsubscribe: (headers?: StompHeaders) => void;
|
||||
}
|
||||
8
node_modules/@stomp/stompjs/esm6/stomp-subscription.js
generated
vendored
Normal file
8
node_modules/@stomp/stompjs/esm6/stomp-subscription.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Call [Client#subscribe]{@link Client#subscribe} to create a StompSubscription.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompSubscription {
|
||||
}
|
||||
//# sourceMappingURL=stomp-subscription.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/stomp-subscription.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/stomp-subscription.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stomp-subscription.js","sourceRoot":"","sources":["../src/stomp-subscription.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;CAU7B"}
|
||||
140
node_modules/@stomp/stompjs/esm6/types.d.ts
generated
vendored
Normal file
140
node_modules/@stomp/stompjs/esm6/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
import { IFrame } from './i-frame';
|
||||
import { IMessage } from './i-message';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
/**
|
||||
* This callback will receive a `string` as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type debugFnType = (msg: string) => void;
|
||||
/**
|
||||
* This callback will receive a {@link IMessage} as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type messageCallbackType = (message: IMessage) => void;
|
||||
/**
|
||||
* This callback will receive a {@link IFrame} as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type frameCallbackType = (receipt: IFrame) => void;
|
||||
/**
|
||||
* This callback will receive a [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
|
||||
* as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type closeEventCallbackType<T = any> = (evt: T) => void;
|
||||
/**
|
||||
* This callback will receive an [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
|
||||
* as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare type wsErrorCallbackType<T = any> = (evt: T) => void;
|
||||
/**
|
||||
* Parameters for [Client#publish]{@link Client#publish}.
|
||||
* Aliased as publishParams as well.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export interface IPublishParams {
|
||||
/**
|
||||
* destination end point
|
||||
*/
|
||||
destination: string;
|
||||
/**
|
||||
* headers (optional)
|
||||
*/
|
||||
headers?: StompHeaders;
|
||||
/**
|
||||
* body (optional)
|
||||
*/
|
||||
body?: string;
|
||||
/**
|
||||
* binary body (optional)
|
||||
*/
|
||||
binaryBody?: Uint8Array;
|
||||
/**
|
||||
* By default a `content-length` header will be added in the Frame to the broker.
|
||||
* Set it to `true` for the header to be skipped.
|
||||
*/
|
||||
skipContentLengthHeader?: boolean;
|
||||
}
|
||||
/**
|
||||
* Backward compatibility, switch to {@link IPublishParams}.
|
||||
*/
|
||||
export declare type publishParams = IPublishParams;
|
||||
/**
|
||||
* Used in {@link IRawFrameType}
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export declare type RawHeaderType = [string, string];
|
||||
/**
|
||||
* The parser yield frames in this structure
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface IRawFrameType {
|
||||
command: string;
|
||||
headers: RawHeaderType[];
|
||||
binaryBody: Uint8Array;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface IStompSocketMessageEvent {
|
||||
data?: string | ArrayBuffer;
|
||||
}
|
||||
/**
|
||||
* Copied from Websocket interface to avoid dom typelib dependency.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface IStompSocket {
|
||||
onclose: ((this: IStompSocket, ev?: any) => any) | null;
|
||||
onerror: ((this: IStompSocket, ev: any) => any) | null;
|
||||
onmessage: ((this: IStompSocket, ev: IStompSocketMessageEvent) => any) | null;
|
||||
onopen: ((this: IStompSocket, ev?: any) => any) | null;
|
||||
terminate?: ((this: IStompSocket) => any) | null;
|
||||
/**
|
||||
* Returns a string that indicates how binary data from the socket is exposed to scripts:
|
||||
* We support only 'arraybuffer'.
|
||||
*/
|
||||
binaryType: 'arraybuffer';
|
||||
/**
|
||||
* Returns the state of the socket connection. It can have the values of StompSocketState.
|
||||
*/
|
||||
readonly readyState: number;
|
||||
/**
|
||||
* Closes the connection.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Transmits data using the connection. data can be a string or an ArrayBuffer.
|
||||
*/
|
||||
send(data: string | ArrayBuffer): void;
|
||||
}
|
||||
/**
|
||||
* Possible states for the IStompSocket
|
||||
*/
|
||||
export declare enum StompSocketState {
|
||||
CONNECTING = 0,
|
||||
OPEN = 1,
|
||||
CLOSING = 2,
|
||||
CLOSED = 3
|
||||
}
|
||||
/**
|
||||
* Possible activation state
|
||||
*/
|
||||
export declare enum ActivationState {
|
||||
ACTIVE = 0,
|
||||
DEACTIVATING = 1,
|
||||
INACTIVE = 2
|
||||
}
|
||||
20
node_modules/@stomp/stompjs/esm6/types.js
generated
vendored
Normal file
20
node_modules/@stomp/stompjs/esm6/types.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Possible states for the IStompSocket
|
||||
*/
|
||||
export var StompSocketState;
|
||||
(function (StompSocketState) {
|
||||
StompSocketState[StompSocketState["CONNECTING"] = 0] = "CONNECTING";
|
||||
StompSocketState[StompSocketState["OPEN"] = 1] = "OPEN";
|
||||
StompSocketState[StompSocketState["CLOSING"] = 2] = "CLOSING";
|
||||
StompSocketState[StompSocketState["CLOSED"] = 3] = "CLOSED";
|
||||
})(StompSocketState || (StompSocketState = {}));
|
||||
/**
|
||||
* Possible activation state
|
||||
*/
|
||||
export var ActivationState;
|
||||
(function (ActivationState) {
|
||||
ActivationState[ActivationState["ACTIVE"] = 0] = "ACTIVE";
|
||||
ActivationState[ActivationState["DEACTIVATING"] = 1] = "DEACTIVATING";
|
||||
ActivationState[ActivationState["INACTIVE"] = 2] = "INACTIVE";
|
||||
})(ActivationState || (ActivationState = {}));
|
||||
//# sourceMappingURL=types.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/types.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0IA;;GAEG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mEAAU,CAAA;IACV,uDAAI,CAAA;IACJ,6DAAO,CAAA;IACP,2DAAM,CAAA;AACR,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,yDAAM,CAAA;IACN,qEAAY,CAAA;IACZ,6DAAQ,CAAA;AACV,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B"}
|
||||
39
node_modules/@stomp/stompjs/esm6/versions.d.ts
generated
vendored
Normal file
39
node_modules/@stomp/stompjs/esm6/versions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Supported STOMP versions
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export declare class Versions {
|
||||
versions: string[];
|
||||
/**
|
||||
* Indicates protocol version 1.0
|
||||
*/
|
||||
static V1_0: string;
|
||||
/**
|
||||
* Indicates protocol version 1.1
|
||||
*/
|
||||
static V1_1: string;
|
||||
/**
|
||||
* Indicates protocol version 1.2
|
||||
*/
|
||||
static V1_2: string;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static default: Versions;
|
||||
/**
|
||||
* Takes an array of string of versions, typical elements '1.0', '1.1', or '1.2'
|
||||
*
|
||||
* You will an instance if this class if you want to override supported versions to be declared during
|
||||
* STOMP handshake.
|
||||
*/
|
||||
constructor(versions: string[]);
|
||||
/**
|
||||
* Used as part of CONNECT STOMP Frame
|
||||
*/
|
||||
supportedVersions(): string;
|
||||
/**
|
||||
* Used while creating a WebSocket
|
||||
*/
|
||||
protocolVersions(): string[];
|
||||
}
|
||||
49
node_modules/@stomp/stompjs/esm6/versions.js
generated
vendored
Normal file
49
node_modules/@stomp/stompjs/esm6/versions.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Supported STOMP versions
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class Versions {
|
||||
/**
|
||||
* Takes an array of string of versions, typical elements '1.0', '1.1', or '1.2'
|
||||
*
|
||||
* You will an instance if this class if you want to override supported versions to be declared during
|
||||
* STOMP handshake.
|
||||
*/
|
||||
constructor(versions) {
|
||||
this.versions = versions;
|
||||
}
|
||||
/**
|
||||
* Used as part of CONNECT STOMP Frame
|
||||
*/
|
||||
supportedVersions() {
|
||||
return this.versions.join(',');
|
||||
}
|
||||
/**
|
||||
* Used while creating a WebSocket
|
||||
*/
|
||||
protocolVersions() {
|
||||
return this.versions.map(x => `v${x.replace('.', '')}.stomp`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Indicates protocol version 1.0
|
||||
*/
|
||||
Versions.V1_0 = '1.0';
|
||||
/**
|
||||
* Indicates protocol version 1.1
|
||||
*/
|
||||
Versions.V1_1 = '1.1';
|
||||
/**
|
||||
* Indicates protocol version 1.2
|
||||
*/
|
||||
Versions.V1_2 = '1.2';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
Versions.default = new Versions([
|
||||
Versions.V1_0,
|
||||
Versions.V1_1,
|
||||
Versions.V1_2,
|
||||
]);
|
||||
//# sourceMappingURL=versions.js.map
|
||||
1
node_modules/@stomp/stompjs/esm6/versions.js.map
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/esm6/versions.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../src/versions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IAuBnB;;;;;OAKG;IACH,YAAmB,QAAkB;QAAlB,aAAQ,GAAR,QAAQ,CAAU;IAAG,CAAC;IAEzC;;OAEG;IACI,iBAAiB;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,gBAAgB;QACrB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;;AA1CD;;GAEG;AACW,aAAI,GAAG,KAAK,CAAC;AAC3B;;GAEG;AACW,aAAI,GAAG,KAAK,CAAC;AAC3B;;GAEG;AACW,aAAI,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACW,gBAAO,GAAG,IAAI,QAAQ,CAAC;IACnC,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,IAAI;CACd,CAAC,CAAC"}
|
||||
1
node_modules/@stomp/stompjs/index.d.ts
generated
vendored
Normal file
1
node_modules/@stomp/stompjs/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './esm6/';
|
||||
58
node_modules/@stomp/stompjs/package.json
generated
vendored
Normal file
58
node_modules/@stomp/stompjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "@stomp/stompjs",
|
||||
"version": "6.1.2",
|
||||
"description": "STOMP client for Javascript and Typescript",
|
||||
"scripts": {
|
||||
"clean": "rm -rf bundles esm6",
|
||||
"build-webpack": "webpack && webpack --mode=production --output-filename=stomp.umd.min.js",
|
||||
"build": "npm run clean && npx tsc && npm run build-webpack",
|
||||
"test": "jasmine",
|
||||
"karma": "karma start --single-run",
|
||||
"lint": "tslint 'src/**/*.ts'",
|
||||
"prettier": "prettier --write .",
|
||||
"prepublishOnly": "npm run lint && npm run build && npm run karma && npm run test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/stomp-js/stompjs.git"
|
||||
},
|
||||
"keywords": [
|
||||
"STOMP",
|
||||
"RabbitMQ",
|
||||
"ActiveMQ",
|
||||
"Websocket",
|
||||
"messaging",
|
||||
"queue",
|
||||
"SockJS"
|
||||
],
|
||||
"author": "deepak@kreatio.com",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/stomp-js/stompjs/issues"
|
||||
},
|
||||
"homepage": "https://github.com/stomp-js/stompjs#readme",
|
||||
"devDependencies": {
|
||||
"@chiragrupani/karma-chromium-edge-launcher": "^2.0.0",
|
||||
"awesome-typescript-loader": "^5.2.0",
|
||||
"jasmine": "^3.1.0",
|
||||
"karma": "^5.0.3",
|
||||
"karma-chrome-launcher": "^3.0.0",
|
||||
"karma-firefox-launcher": "^2.0.0",
|
||||
"karma-jasmine": "^4.0.0",
|
||||
"karma-safari-launcher": "git://github.com/RLovelett/karma-safari-launcher.git#safari-webdriver",
|
||||
"karma-summary-reporter": "^2.0.2",
|
||||
"prettier": "^2.1.2",
|
||||
"text-encoding": "^0.7.0",
|
||||
"tslint": "^6.0.0",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"typescript": "=3.6.4",
|
||||
"webpack": "^4.33.0",
|
||||
"webpack-cli": "^3.3.2",
|
||||
"ws": "^8.2.0"
|
||||
},
|
||||
"module": "./esm6/index.js",
|
||||
"main": "bundles/stomp.umd.js",
|
||||
"typings": "index.d.ts",
|
||||
"sideEffects": false,
|
||||
"dependencies": {}
|
||||
}
|
||||
38
node_modules/@stomp/stompjs/src/augment-websocket.ts
generated
vendored
Normal file
38
node_modules/@stomp/stompjs/src/augment-websocket.ts
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { IStompSocket } from './types';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function augmentWebsocket(
|
||||
webSocket: IStompSocket,
|
||||
debug: (msg: string) => void
|
||||
) {
|
||||
webSocket.terminate = function () {
|
||||
const noOp = () => {};
|
||||
|
||||
// set all callbacks to no op
|
||||
this.onerror = noOp;
|
||||
this.onmessage = noOp;
|
||||
this.onopen = noOp;
|
||||
|
||||
const ts = new Date();
|
||||
|
||||
const origOnClose = this.onclose;
|
||||
|
||||
// Track delay in actual closure of the socket
|
||||
this.onclose = closeEvent => {
|
||||
const delay = new Date().getTime() - ts.getTime();
|
||||
debug(
|
||||
`Discarded socket closed after ${delay}ms, with code/reason: ${closeEvent.code}/${closeEvent.reason}`
|
||||
);
|
||||
};
|
||||
|
||||
this.close();
|
||||
|
||||
origOnClose.call(this, {
|
||||
code: 4001,
|
||||
reason: 'Heartbeat failure, discarding the socket',
|
||||
wasClean: false,
|
||||
});
|
||||
};
|
||||
}
|
||||
13
node_modules/@stomp/stompjs/src/byte.ts
generated
vendored
Normal file
13
node_modules/@stomp/stompjs/src/byte.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Some byte values, used as per STOMP specifications.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const BYTE = {
|
||||
// LINEFEED byte (octet 10)
|
||||
LF: '\x0A',
|
||||
// NULL byte (octet 0)
|
||||
NULL: '\x00',
|
||||
};
|
||||
812
node_modules/@stomp/stompjs/src/client.ts
generated
vendored
Normal file
812
node_modules/@stomp/stompjs/src/client.ts
generated
vendored
Normal file
@@ -0,0 +1,812 @@
|
||||
import { ITransaction } from './i-transaction';
|
||||
import { StompConfig } from './stomp-config';
|
||||
import { StompHandler } from './stomp-handler';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { StompSubscription } from './stomp-subscription';
|
||||
import {
|
||||
ActivationState,
|
||||
closeEventCallbackType,
|
||||
debugFnType,
|
||||
frameCallbackType,
|
||||
IPublishParams,
|
||||
IStompSocket,
|
||||
messageCallbackType,
|
||||
StompSocketState,
|
||||
wsErrorCallbackType,
|
||||
} from './types';
|
||||
import { Versions } from './versions';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare const WebSocket: {
|
||||
prototype: IStompSocket;
|
||||
new (url: string, protocols?: string | string[]): IStompSocket;
|
||||
};
|
||||
|
||||
/**
|
||||
* STOMP Client Class.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class Client {
|
||||
/**
|
||||
* The URL for the STOMP broker to connect to.
|
||||
* Typically like `"ws://broker.329broker.com:15674/ws"` or `"wss://broker.329broker.com:15674/ws"`.
|
||||
*
|
||||
* Only one of this or [Client#webSocketFactory]{@link Client#webSocketFactory} need to be set.
|
||||
* If both are set, [Client#webSocketFactory]{@link Client#webSocketFactory} will be used.
|
||||
*
|
||||
* If your environment does not support WebSockets natively, please refer to
|
||||
* [Polyfills]{@link https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/pollyfils-for-stompjs-v5.html}.
|
||||
*/
|
||||
public brokerURL: string;
|
||||
|
||||
/**
|
||||
* STOMP versions to attempt during STOMP handshake. By default versions `1.0`, `1.1`, and `1.2` are attempted.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Try only versions 1.0 and 1.1
|
||||
* client.stompVersions = new Versions(['1.0', '1.1'])
|
||||
* ```
|
||||
*/
|
||||
public stompVersions = Versions.default;
|
||||
|
||||
/**
|
||||
* This function should return a WebSocket or a similar (e.g. SockJS) object.
|
||||
* If your environment does not support WebSockets natively, please refer to
|
||||
* [Polyfills]{@link https://stomp-js.github.io/guide/stompjs/rx-stomp/ng2-stompjs/pollyfils-for-stompjs-v5.html}.
|
||||
* If your STOMP Broker supports WebSockets, prefer setting [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*
|
||||
* If both this and [Client#brokerURL]{@link Client#brokerURL} are set, this will be used.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // use a WebSocket
|
||||
* client.webSocketFactory= function () {
|
||||
* return new WebSocket("wss://broker.329broker.com:15674/ws");
|
||||
* };
|
||||
*
|
||||
* // Typical usage with SockJS
|
||||
* client.webSocketFactory= function () {
|
||||
* return new SockJS("http://broker.329broker.com/stomp");
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
public webSocketFactory: () => IStompSocket;
|
||||
|
||||
/**
|
||||
* Will retry if Stomp connection is not established in specified milliseconds.
|
||||
* Default 0, which implies wait for ever.
|
||||
*/
|
||||
public connectionTimeout: number = 0;
|
||||
|
||||
private _connectionWatcher: number; // Timer
|
||||
|
||||
/**
|
||||
* automatically reconnect with delay in milliseconds, set to 0 to disable.
|
||||
*/
|
||||
public reconnectDelay: number = 5000;
|
||||
|
||||
/**
|
||||
* Incoming heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
public heartbeatIncoming: number = 10000;
|
||||
|
||||
/**
|
||||
* Outgoing heartbeat interval in milliseconds. Set to 0 to disable.
|
||||
*/
|
||||
public heartbeatOutgoing: number = 10000;
|
||||
|
||||
/**
|
||||
* This switches on a non standard behavior while sending WebSocket packets.
|
||||
* It splits larger (text) packets into chunks of [maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
|
||||
* Only Java Spring brokers seems to use this mode.
|
||||
*
|
||||
* WebSockets, by itself, split large (text) packets,
|
||||
* so it is not needed with a truly compliant STOMP/WebSocket broker.
|
||||
* Actually setting it for such broker will cause large messages to fail.
|
||||
*
|
||||
* `false` by default.
|
||||
*
|
||||
* Binary frames are never split.
|
||||
*/
|
||||
public splitLargeFrames: boolean = false;
|
||||
|
||||
/**
|
||||
* See [splitLargeFrames]{@link Client#splitLargeFrames}.
|
||||
* This has no effect if [splitLargeFrames]{@link Client#splitLargeFrames} is `false`.
|
||||
*/
|
||||
public maxWebSocketChunkSize: number = 8 * 1024;
|
||||
|
||||
/**
|
||||
* Usually the
|
||||
* [type of WebSocket frame]{@link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send#Parameters}
|
||||
* is automatically decided by type of the payload.
|
||||
* Default is `false`, which should work with all compliant brokers.
|
||||
*
|
||||
* Set this flag to force binary frames.
|
||||
*/
|
||||
public forceBinaryWSFrames: boolean = false;
|
||||
|
||||
/**
|
||||
* A bug in ReactNative chops a string on occurrence of a NULL.
|
||||
* See issue [https://github.com/stomp-js/stompjs/issues/89]{@link https://github.com/stomp-js/stompjs/issues/89}.
|
||||
* This makes incoming WebSocket messages invalid STOMP packets.
|
||||
* Setting this flag attempts to reverse the damage by appending a NULL.
|
||||
* If the broker splits a large message into multiple WebSocket messages,
|
||||
* this flag will cause data loss and abnormal termination of connection.
|
||||
*
|
||||
* This is not an ideal solution, but a stop gap until the underlying issue is fixed at ReactNative library.
|
||||
*/
|
||||
public appendMissingNULLonIncoming: boolean = false;
|
||||
|
||||
/**
|
||||
* Underlying WebSocket instance, READONLY.
|
||||
*/
|
||||
get webSocket(): IStompSocket {
|
||||
return this._stompHandler ? this._stompHandler._webSocket : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection headers, important keys - `login`, `passcode`, `host`.
|
||||
* Though STOMP 1.2 standard marks these keys to be present, check your broker documentation for
|
||||
* details specific to your broker.
|
||||
*/
|
||||
public connectHeaders: StompHeaders;
|
||||
|
||||
/**
|
||||
* Disconnection headers.
|
||||
*/
|
||||
get disconnectHeaders(): StompHeaders {
|
||||
return this._disconnectHeaders;
|
||||
}
|
||||
|
||||
set disconnectHeaders(value: StompHeaders) {
|
||||
this._disconnectHeaders = value;
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.disconnectHeaders = this._disconnectHeaders;
|
||||
}
|
||||
}
|
||||
private _disconnectHeaders: StompHeaders;
|
||||
|
||||
/**
|
||||
* This function will be called for any unhandled messages.
|
||||
* It is useful for receiving messages sent to RabbitMQ temporary queues.
|
||||
*
|
||||
* It can also get invoked with stray messages while the server is processing
|
||||
* a request to [Client#unsubscribe]{@link Client#unsubscribe}
|
||||
* from an endpoint.
|
||||
*
|
||||
* The actual {@link IMessage} will be passed as parameter to the callback.
|
||||
*/
|
||||
public onUnhandledMessage: messageCallbackType;
|
||||
|
||||
/**
|
||||
* STOMP brokers can be requested to notify when an operation is actually completed.
|
||||
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}. See
|
||||
* [Client#watchForReceipt]{@link Client#watchForReceipt} for examples.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
*/
|
||||
public onUnhandledReceipt: frameCallbackType;
|
||||
|
||||
/**
|
||||
* Will be invoked if {@link FrameImpl} of unknown type is received from the STOMP broker.
|
||||
*
|
||||
* The actual {@link IFrame} will be passed as parameter to the callback.
|
||||
*/
|
||||
public onUnhandledFrame: frameCallbackType;
|
||||
|
||||
/**
|
||||
* `true` if there is a active connection with STOMP Broker
|
||||
*/
|
||||
get connected(): boolean {
|
||||
return !!this._stompHandler && this._stompHandler.connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback, invoked on before a connection connection to the STOMP broker.
|
||||
*
|
||||
* You can change options on the client, which will impact the immediate connect.
|
||||
* It is valid to call [Client#decativate]{@link Client#deactivate} in this callback.
|
||||
*
|
||||
* As of version 5.1, this callback can be
|
||||
* [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
|
||||
* (i.e., it can return a
|
||||
* [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)).
|
||||
* In that case connect will be called only after the Promise is resolved.
|
||||
* This can be used to reliably fetch credentials, access token etc. from some other service
|
||||
* in an asynchronous way.
|
||||
*/
|
||||
public beforeConnect: () => void | Promise<void>;
|
||||
|
||||
/**
|
||||
* Callback, invoked on every successful connection to the STOMP broker.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
* Sometimes clients will like to use headers from this frame.
|
||||
*/
|
||||
public onConnect: frameCallbackType;
|
||||
|
||||
/**
|
||||
* Callback, invoked on every successful disconnection from the STOMP broker. It will not be invoked if
|
||||
* the STOMP broker disconnected due to an error.
|
||||
*
|
||||
* The actual Receipt {@link FrameImpl} acknowledging the DISCONNECT will be passed as parameter to the callback.
|
||||
*
|
||||
* The way STOMP protocol is designed, the connection may close/terminate without the client
|
||||
* receiving the Receipt {@link FrameImpl} acknowledging the DISCONNECT.
|
||||
* You might find [Client#onWebSocketClose]{@link Client#onWebSocketClose} more appropriate to watch
|
||||
* STOMP broker disconnects.
|
||||
*/
|
||||
public onDisconnect: frameCallbackType;
|
||||
|
||||
/**
|
||||
* Callback, invoked on an ERROR frame received from the STOMP Broker.
|
||||
* A compliant STOMP Broker will close the connection after this type of frame.
|
||||
* Please check broker specific documentation for exact behavior.
|
||||
*
|
||||
* The actual {@link IFrame} will be passed as parameter to the callback.
|
||||
*/
|
||||
public onStompError: frameCallbackType;
|
||||
|
||||
/**
|
||||
* Callback, invoked when underlying WebSocket is closed.
|
||||
*
|
||||
* Actual [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
|
||||
* is passed as parameter to the callback.
|
||||
*/
|
||||
public onWebSocketClose: closeEventCallbackType;
|
||||
|
||||
/**
|
||||
* Callback, invoked when underlying WebSocket raises an error.
|
||||
*
|
||||
* Actual [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
|
||||
* is passed as parameter to the callback.
|
||||
*/
|
||||
public onWebSocketError: wsErrorCallbackType;
|
||||
|
||||
/**
|
||||
* Set it to log the actual raw communication with the broker.
|
||||
* When unset, it logs headers of the parsed frames.
|
||||
*
|
||||
* Change in this effects from next broker reconnect.
|
||||
*
|
||||
* **Caution: this assumes that frames only have valid UTF8 strings.**
|
||||
*/
|
||||
public logRawCommunication: boolean;
|
||||
|
||||
/**
|
||||
* By default, debug messages are discarded. To log to `console` following can be used:
|
||||
*
|
||||
* ```javascript
|
||||
* client.debug = function(str) {
|
||||
* console.log(str);
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* Currently this method does not support levels of log. Be aware that the output can be quite verbose
|
||||
* and may contain sensitive information (like passwords, tokens etc.).
|
||||
*/
|
||||
public debug: debugFnType;
|
||||
|
||||
/**
|
||||
* Browsers do not immediately close WebSockets when `.close` is issued.
|
||||
* This may cause reconnection to take a longer on certain type of failures.
|
||||
* In case of incoming heartbeat failure, this experimental flag instructs the library
|
||||
* to discard the socket immediately (even before it is actually closed).
|
||||
*/
|
||||
public discardWebsocketOnCommFailure: boolean;
|
||||
|
||||
/**
|
||||
* version of STOMP protocol negotiated with the server, READONLY
|
||||
*/
|
||||
get connectedVersion(): string {
|
||||
return this._stompHandler ? this._stompHandler.connectedVersion : undefined;
|
||||
}
|
||||
|
||||
private _stompHandler: StompHandler;
|
||||
|
||||
/**
|
||||
* if the client is active (connected or going to reconnect)
|
||||
*/
|
||||
get active(): boolean {
|
||||
return this.state === ActivationState.ACTIVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* It will be called on state change.
|
||||
*
|
||||
* When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
|
||||
*/
|
||||
public onChangeState: (state: ActivationState) => void;
|
||||
|
||||
private _changeState(state: ActivationState) {
|
||||
this.state = state;
|
||||
this.onChangeState(state);
|
||||
}
|
||||
|
||||
// This will mark deactivate to complete, to be called after Websocket is closed
|
||||
private _resolveSocketClose: (value?: PromiseLike<void> | void) => void;
|
||||
|
||||
/**
|
||||
* Activation state.
|
||||
*
|
||||
* It will usually be ACTIVE or INACTIVE.
|
||||
* When deactivating it may go from ACTIVE to INACTIVE without entering DEACTIVATING.
|
||||
*/
|
||||
public state: ActivationState = ActivationState.INACTIVE;
|
||||
|
||||
private _reconnector: any;
|
||||
|
||||
/**
|
||||
* Create an instance.
|
||||
*/
|
||||
constructor(conf: StompConfig = {}) {
|
||||
// Dummy callbacks
|
||||
const noOp = () => {};
|
||||
this.debug = noOp;
|
||||
this.beforeConnect = noOp;
|
||||
this.onConnect = noOp;
|
||||
this.onDisconnect = noOp;
|
||||
this.onUnhandledMessage = noOp;
|
||||
this.onUnhandledReceipt = noOp;
|
||||
this.onUnhandledFrame = noOp;
|
||||
this.onStompError = noOp;
|
||||
this.onWebSocketClose = noOp;
|
||||
this.onWebSocketError = noOp;
|
||||
this.logRawCommunication = false;
|
||||
this.onChangeState = noOp;
|
||||
|
||||
// These parameters would typically get proper values before connect is called
|
||||
this.connectHeaders = {};
|
||||
this._disconnectHeaders = {};
|
||||
|
||||
// Apply configuration
|
||||
this.configure(conf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update configuration.
|
||||
*/
|
||||
public configure(conf: StompConfig): void {
|
||||
// bulk assign all properties to this
|
||||
(Object as any).assign(this, conf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate the connection with the broker.
|
||||
* If the connection breaks, as per [Client#reconnectDelay]{@link Client#reconnectDelay},
|
||||
* it will keep trying to reconnect.
|
||||
*
|
||||
* Call [Client#deactivate]{@link Client#deactivate} to disconnect and stop reconnection attempts.
|
||||
*/
|
||||
public activate(): void {
|
||||
if (this.state === ActivationState.DEACTIVATING) {
|
||||
this.debug(
|
||||
'Still DEACTIVATING, please await call to deactivate before trying to re-activate'
|
||||
);
|
||||
throw new Error('Still DEACTIVATING, can not activate now');
|
||||
}
|
||||
|
||||
if (this.active) {
|
||||
this.debug('Already ACTIVE, ignoring request to activate');
|
||||
return;
|
||||
}
|
||||
|
||||
this._changeState(ActivationState.ACTIVE);
|
||||
|
||||
this._connect();
|
||||
}
|
||||
|
||||
private async _connect(): Promise<void> {
|
||||
if (this.connected) {
|
||||
this.debug('STOMP: already connected, nothing to do');
|
||||
return;
|
||||
}
|
||||
|
||||
await this.beforeConnect();
|
||||
|
||||
if (!this.active) {
|
||||
this.debug(
|
||||
'Client has been marked inactive, will not attempt to connect'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// setup connection watcher
|
||||
if (this.connectionTimeout > 0) {
|
||||
// clear first
|
||||
if (this._connectionWatcher) {
|
||||
clearTimeout(this._connectionWatcher);
|
||||
}
|
||||
this._connectionWatcher = setTimeout(() => {
|
||||
if (this.connected) {
|
||||
return;
|
||||
}
|
||||
// Connection not established, close the underlying socket
|
||||
// a reconnection will be attempted
|
||||
this.debug(
|
||||
`Connection not established in ${this.connectionTimeout}ms, closing socket`
|
||||
);
|
||||
this.forceDisconnect();
|
||||
}, this.connectionTimeout);
|
||||
}
|
||||
|
||||
this.debug('Opening Web Socket...');
|
||||
|
||||
// Get the actual WebSocket (or a similar object)
|
||||
const webSocket = this._createWebSocket();
|
||||
|
||||
this._stompHandler = new StompHandler(this, webSocket, {
|
||||
debug: this.debug,
|
||||
stompVersions: this.stompVersions,
|
||||
connectHeaders: this.connectHeaders,
|
||||
disconnectHeaders: this._disconnectHeaders,
|
||||
heartbeatIncoming: this.heartbeatIncoming,
|
||||
heartbeatOutgoing: this.heartbeatOutgoing,
|
||||
splitLargeFrames: this.splitLargeFrames,
|
||||
maxWebSocketChunkSize: this.maxWebSocketChunkSize,
|
||||
forceBinaryWSFrames: this.forceBinaryWSFrames,
|
||||
logRawCommunication: this.logRawCommunication,
|
||||
appendMissingNULLonIncoming: this.appendMissingNULLonIncoming,
|
||||
discardWebsocketOnCommFailure: this.discardWebsocketOnCommFailure,
|
||||
|
||||
onConnect: frame => {
|
||||
// Successfully connected, stop the connection watcher
|
||||
if (this._connectionWatcher) {
|
||||
clearTimeout(this._connectionWatcher);
|
||||
this._connectionWatcher = undefined;
|
||||
}
|
||||
|
||||
if (!this.active) {
|
||||
this.debug(
|
||||
'STOMP got connected while deactivate was issued, will disconnect now'
|
||||
);
|
||||
this._disposeStompHandler();
|
||||
return;
|
||||
}
|
||||
this.onConnect(frame);
|
||||
},
|
||||
onDisconnect: frame => {
|
||||
this.onDisconnect(frame);
|
||||
},
|
||||
onStompError: frame => {
|
||||
this.onStompError(frame);
|
||||
},
|
||||
onWebSocketClose: evt => {
|
||||
this._stompHandler = undefined; // a new one will be created in case of a reconnect
|
||||
|
||||
if (this.state === ActivationState.DEACTIVATING) {
|
||||
// Mark deactivation complete
|
||||
this._resolveSocketClose();
|
||||
this._resolveSocketClose = undefined;
|
||||
this._changeState(ActivationState.INACTIVE);
|
||||
}
|
||||
|
||||
this.onWebSocketClose(evt);
|
||||
// The callback is called before attempting to reconnect, this would allow the client
|
||||
// to be `deactivated` in the callback.
|
||||
if (this.active) {
|
||||
this._schedule_reconnect();
|
||||
}
|
||||
},
|
||||
onWebSocketError: evt => {
|
||||
this.onWebSocketError(evt);
|
||||
},
|
||||
onUnhandledMessage: message => {
|
||||
this.onUnhandledMessage(message);
|
||||
},
|
||||
onUnhandledReceipt: frame => {
|
||||
this.onUnhandledReceipt(frame);
|
||||
},
|
||||
onUnhandledFrame: frame => {
|
||||
this.onUnhandledFrame(frame);
|
||||
},
|
||||
});
|
||||
|
||||
this._stompHandler.start();
|
||||
}
|
||||
|
||||
private _createWebSocket(): IStompSocket {
|
||||
let webSocket: IStompSocket;
|
||||
|
||||
if (this.webSocketFactory) {
|
||||
webSocket = this.webSocketFactory();
|
||||
} else {
|
||||
webSocket = new WebSocket(
|
||||
this.brokerURL,
|
||||
this.stompVersions.protocolVersions()
|
||||
);
|
||||
}
|
||||
webSocket.binaryType = 'arraybuffer';
|
||||
return webSocket;
|
||||
}
|
||||
|
||||
private _schedule_reconnect(): void {
|
||||
if (this.reconnectDelay > 0) {
|
||||
this.debug(`STOMP: scheduling reconnection in ${this.reconnectDelay}ms`);
|
||||
|
||||
this._reconnector = setTimeout(() => {
|
||||
this._connect();
|
||||
}, this.reconnectDelay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect if connected and stop auto reconnect loop.
|
||||
* Appropriate callbacks will be invoked if underlying STOMP connection was connected.
|
||||
*
|
||||
* This call is async, it will resolve immediately if there is no underlying active websocket,
|
||||
* otherwise, it will resolve after underlying websocket is properly disposed.
|
||||
*
|
||||
* To reactivate you can call [Client#activate]{@link Client#activate}.
|
||||
*/
|
||||
public async deactivate(): Promise<void> {
|
||||
let retPromise: Promise<void>;
|
||||
|
||||
if (this.state !== ActivationState.ACTIVE) {
|
||||
this.debug(
|
||||
`Already ${ActivationState[this.state]}, ignoring call to deactivate`
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this._changeState(ActivationState.DEACTIVATING);
|
||||
|
||||
// Clear if a reconnection was scheduled
|
||||
if (this._reconnector) {
|
||||
clearTimeout(this._reconnector);
|
||||
}
|
||||
|
||||
if (
|
||||
this._stompHandler &&
|
||||
this.webSocket.readyState !== StompSocketState.CLOSED
|
||||
) {
|
||||
// we need to wait for underlying websocket to close
|
||||
retPromise = new Promise<void>((resolve, reject) => {
|
||||
this._resolveSocketClose = resolve;
|
||||
});
|
||||
} else {
|
||||
// indicate that auto reconnect loop should terminate
|
||||
this._changeState(ActivationState.INACTIVE);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
this._disposeStompHandler();
|
||||
|
||||
return retPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force disconnect if there is an active connection by directly closing the underlying WebSocket.
|
||||
* This is different than a normal disconnect where a DISCONNECT sequence is carried out with the broker.
|
||||
* After forcing disconnect, automatic reconnect will be attempted.
|
||||
* To stop further reconnects call [Client#deactivate]{@link Client#deactivate} as well.
|
||||
*/
|
||||
public forceDisconnect() {
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.forceDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private _disposeStompHandler() {
|
||||
// Dispose STOMP Handler
|
||||
if (this._stompHandler) {
|
||||
this._stompHandler.dispose();
|
||||
this._stompHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations.
|
||||
*
|
||||
* STOMP protocol specifies and suggests some headers and also allows broker specific headers.
|
||||
*
|
||||
* `body` must be String.
|
||||
* You will need to covert the payload to string in case it is not string (e.g. JSON).
|
||||
*
|
||||
* To send a binary message body use binaryBody parameter. It should be a
|
||||
* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
|
||||
* Sometimes brokers may not support binary frames out of the box.
|
||||
* Please check your broker documentation.
|
||||
*
|
||||
* `content-length` header is automatically added to the STOMP Frame sent to the broker.
|
||||
* Set `skipContentLengthHeader` to indicate that `content-length` header should not be added.
|
||||
* For binary messages `content-length` header is always added.
|
||||
*
|
||||
* Caution: The broker will, most likely, report an error and disconnect if message body has NULL octet(s)
|
||||
* and `content-length` header is missing.
|
||||
*
|
||||
* ```javascript
|
||||
* client.publish({destination: "/queue/test", headers: {priority: 9}, body: "Hello, STOMP"});
|
||||
*
|
||||
* // Only destination is mandatory parameter
|
||||
* client.publish({destination: "/queue/test", body: "Hello, STOMP"});
|
||||
*
|
||||
* // Skip content-length header in the frame to the broker
|
||||
* client.publish({"/queue/test", body: "Hello, STOMP", skipContentLengthHeader: true});
|
||||
*
|
||||
* var binaryData = generateBinaryData(); // This need to be of type Uint8Array
|
||||
* // setting content-type header is not mandatory, however a good practice
|
||||
* client.publish({destination: '/topic/special', binaryBody: binaryData,
|
||||
* headers: {'content-type': 'application/octet-stream'}});
|
||||
* ```
|
||||
*/
|
||||
public publish(params: IPublishParams) {
|
||||
this._stompHandler.publish(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* STOMP brokers may carry out operation asynchronously and allow requesting for acknowledgement.
|
||||
* To request an acknowledgement, a `receipt` header needs to be sent with the actual request.
|
||||
* The value (say receipt-id) for this header needs to be unique for each use. Typically a sequence, a UUID, a
|
||||
* random number or a combination may be used.
|
||||
*
|
||||
* A complaint broker will send a RECEIPT frame when an operation has actually been completed.
|
||||
* The operation needs to be matched based in the value of the receipt-id.
|
||||
*
|
||||
* This method allow watching for a receipt and invoke the callback
|
||||
* when corresponding receipt has been received.
|
||||
*
|
||||
* The actual {@link FrameImpl} will be passed as parameter to the callback.
|
||||
*
|
||||
* Example:
|
||||
* ```javascript
|
||||
* // Subscribing with acknowledgement
|
||||
* let receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
*
|
||||
* client.subscribe(TEST.destination, onMessage, {receipt: receiptId});
|
||||
*
|
||||
*
|
||||
* // Publishing with acknowledgement
|
||||
* receiptId = randomText();
|
||||
*
|
||||
* client.watchForReceipt(receiptId, function() {
|
||||
* // Will be called after server acknowledges
|
||||
* });
|
||||
* client.publish({destination: TEST.destination, headers: {receipt: receiptId}, body: msg});
|
||||
* ```
|
||||
*/
|
||||
public watchForReceipt(receiptId: string, callback: frameCallbackType): void {
|
||||
this._stompHandler.watchForReceipt(receiptId, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to a STOMP Broker location. The callback will be invoked for each received message with
|
||||
* the {@link IMessage} as argument.
|
||||
*
|
||||
* Note: The library will generate an unique ID if there is none provided in the headers.
|
||||
* To use your own ID, pass it using the headers argument.
|
||||
*
|
||||
* ```javascript
|
||||
* callback = function(message) {
|
||||
* // called when the client receives a STOMP message from the server
|
||||
* if (message.body) {
|
||||
* alert("got message with body " + message.body)
|
||||
* } else {
|
||||
* alert("got empty message");
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* var subscription = client.subscribe("/queue/test", callback);
|
||||
*
|
||||
* // Explicit subscription id
|
||||
* var mySubId = 'my-subscription-id-001';
|
||||
* var subscription = client.subscribe(destination, callback, { id: mySubId });
|
||||
* ```
|
||||
*/
|
||||
public subscribe(
|
||||
destination: string,
|
||||
callback: messageCallbackType,
|
||||
headers: StompHeaders = {}
|
||||
): StompSubscription {
|
||||
return this._stompHandler.subscribe(destination, callback, headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* It is preferable to unsubscribe from a subscription by calling
|
||||
* `unsubscribe()` directly on {@link StompSubscription} returned by `client.subscribe()`:
|
||||
*
|
||||
* ```javascript
|
||||
* var subscription = client.subscribe(destination, onmessage);
|
||||
* // ...
|
||||
* subscription.unsubscribe();
|
||||
* ```
|
||||
*
|
||||
* See: http://stomp.github.com/stomp-specification-1.2.html#UNSUBSCRIBE UNSUBSCRIBE Frame
|
||||
*/
|
||||
public unsubscribe(id: string, headers: StompHeaders = {}): void {
|
||||
this._stompHandler.unsubscribe(id, headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a transaction, the returned {@link ITransaction} has methods - [commit]{@link ITransaction#commit}
|
||||
* and [abort]{@link ITransaction#abort}.
|
||||
*
|
||||
* `transactionId` is optional, if not passed the library will generate it internally.
|
||||
*/
|
||||
public begin(transactionId?: string): ITransaction {
|
||||
return this._stompHandler.begin(transactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit a transaction.
|
||||
*
|
||||
* It is preferable to commit a transaction by calling [commit]{@link ITransaction#commit} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.commit();
|
||||
* ```
|
||||
*/
|
||||
public commit(transactionId: string): void {
|
||||
this._stompHandler.commit(transactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abort a transaction.
|
||||
* It is preferable to abort a transaction by calling [abort]{@link ITransaction#abort} directly on
|
||||
* {@link ITransaction} returned by [client.begin]{@link Client#begin}.
|
||||
*
|
||||
* ```javascript
|
||||
* var tx = client.begin(txId);
|
||||
* //...
|
||||
* tx.abort();
|
||||
* ```
|
||||
*/
|
||||
public abort(transactionId: string): void {
|
||||
this._stompHandler.abort(transactionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* ACK a message. It is preferable to acknowledge a message by calling [ack]{@link IMessage#ack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // acknowledge it
|
||||
* message.ack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
public ack(
|
||||
messageId: string,
|
||||
subscriptionId: string,
|
||||
headers: StompHeaders = {}
|
||||
): void {
|
||||
this._stompHandler.ack(messageId, subscriptionId, headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* NACK a message. It is preferable to acknowledge a message by calling [nack]{@link IMessage#nack} directly
|
||||
* on the {@link IMessage} handled by a subscription callback:
|
||||
*
|
||||
* ```javascript
|
||||
* var callback = function (message) {
|
||||
* // process the message
|
||||
* // an error occurs, nack it
|
||||
* message.nack();
|
||||
* };
|
||||
* client.subscribe(destination, callback, {'ack': 'client'});
|
||||
* ```
|
||||
*/
|
||||
public nack(
|
||||
messageId: string,
|
||||
subscriptionId: string,
|
||||
headers: StompHeaders = {}
|
||||
): void {
|
||||
this._stompHandler.nack(messageId, subscriptionId, headers);
|
||||
}
|
||||
}
|
||||
269
node_modules/@stomp/stompjs/src/compatibility/compat-client.ts
generated
vendored
Normal file
269
node_modules/@stomp/stompjs/src/compatibility/compat-client.ts
generated
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
import { Client } from '../client';
|
||||
import { StompHeaders } from '../stomp-headers';
|
||||
import { frameCallbackType, messageCallbackType } from '../types';
|
||||
import { HeartbeatInfo } from './heartbeat-info';
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
export class CompatClient extends Client {
|
||||
/**
|
||||
* It is no op now. No longer needed. Large packets work out of the box.
|
||||
*/
|
||||
public maxWebSocketFrameSize: number = 16 * 1024;
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using {@link Client}
|
||||
* and [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(webSocketFactory: () => any) {
|
||||
super();
|
||||
this.reconnect_delay = 0;
|
||||
this.webSocketFactory = webSocketFactory;
|
||||
// Default from previous version
|
||||
this.debug = (...message: any[]) => {
|
||||
console.log(...message);
|
||||
};
|
||||
}
|
||||
|
||||
private _parseConnect(...args: any[]): any {
|
||||
let closeEventCallback;
|
||||
let connectCallback;
|
||||
let errorCallback;
|
||||
let headers: StompHeaders = {};
|
||||
if (args.length < 2) {
|
||||
throw new Error('Connect requires at least 2 arguments');
|
||||
}
|
||||
if (typeof args[1] === 'function') {
|
||||
[headers, connectCallback, errorCallback, closeEventCallback] = args;
|
||||
} else {
|
||||
switch (args.length) {
|
||||
case 6:
|
||||
[
|
||||
headers.login,
|
||||
headers.passcode,
|
||||
connectCallback,
|
||||
errorCallback,
|
||||
closeEventCallback,
|
||||
headers.host,
|
||||
] = args;
|
||||
break;
|
||||
default:
|
||||
[
|
||||
headers.login,
|
||||
headers.passcode,
|
||||
connectCallback,
|
||||
errorCallback,
|
||||
closeEventCallback,
|
||||
] = args;
|
||||
}
|
||||
}
|
||||
|
||||
return [headers, connectCallback, errorCallback, closeEventCallback];
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#activate]{@link Client#activate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* The `connect` method accepts different number of arguments and types. See the Overloads list. Use the
|
||||
* version with headers to pass your broker specific options.
|
||||
*
|
||||
* overloads:
|
||||
* - connect(headers, connectCallback)
|
||||
* - connect(headers, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback)
|
||||
* - connect(login, passcode, connectCallback, errorCallback, closeEventCallback, host)
|
||||
*
|
||||
* params:
|
||||
* - headers, see [Client#connectHeaders]{@link Client#connectHeaders}
|
||||
* - connectCallback, see [Client#onConnect]{@link Client#onConnect}
|
||||
* - errorCallback, see [Client#onStompError]{@link Client#onStompError}
|
||||
* - closeEventCallback, see [Client#onWebSocketClose]{@link Client#onWebSocketClose}
|
||||
* - login [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - passcode [String], [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
* - host [String], see [Client#connectHeaders](../classes/Client.html#connectHeaders)
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
public connect(...args: any[]): void {
|
||||
const out = this._parseConnect(...args);
|
||||
|
||||
if (out[0]) {
|
||||
this.connectHeaders = out[0];
|
||||
}
|
||||
if (out[1]) {
|
||||
this.onConnect = out[1];
|
||||
}
|
||||
if (out[2]) {
|
||||
this.onStompError = out[2];
|
||||
}
|
||||
if (out[3]) {
|
||||
this.onWebSocketClose = out[3];
|
||||
}
|
||||
|
||||
super.activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, please shift to using [Client#deactivate]{@link Client#deactivate}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* See:
|
||||
* [Client#onDisconnect]{@link Client#onDisconnect}, and
|
||||
* [Client#disconnectHeaders]{@link Client#disconnectHeaders}
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
public disconnect(
|
||||
disconnectCallback?: any,
|
||||
headers: StompHeaders = {}
|
||||
): void {
|
||||
if (disconnectCallback) {
|
||||
this.onDisconnect = disconnectCallback;
|
||||
}
|
||||
this.disconnectHeaders = headers;
|
||||
|
||||
super.deactivate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, use [Client#publish]{@link Client#publish}.
|
||||
*
|
||||
* Send a message to a named destination. Refer to your STOMP broker documentation for types
|
||||
* and naming of destinations. The headers will, typically, be available to the subscriber.
|
||||
* However, there may be special purpose headers corresponding to your STOMP broker.
|
||||
*
|
||||
* **Deprecated**, use [Client#publish]{@link Client#publish}
|
||||
*
|
||||
* Note: Body must be String. You will need to covert the payload to string in case it is not string (e.g. JSON)
|
||||
*
|
||||
* ```javascript
|
||||
* client.send("/queue/test", {priority: 9}, "Hello, STOMP");
|
||||
*
|
||||
* // If you want to send a message with a body, you must also pass the headers argument.
|
||||
* client.send("/queue/test", {}, "Hello, STOMP");
|
||||
* ```
|
||||
*
|
||||
* To upgrade, please follow the [Upgrade Guide](../additional-documentation/upgrading.html)
|
||||
*/
|
||||
public send(
|
||||
destination: string,
|
||||
headers: { [key: string]: any } = {},
|
||||
body: string = ''
|
||||
): void {
|
||||
headers = (Object as any).assign({}, headers);
|
||||
|
||||
const skipContentLengthHeader = headers['content-length'] === false;
|
||||
if (skipContentLengthHeader) {
|
||||
delete headers['content-length'];
|
||||
}
|
||||
this.publish({
|
||||
destination,
|
||||
headers: headers as StompHeaders,
|
||||
body,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#reconnectDelay]{@link Client#reconnectDelay}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set reconnect_delay(value: number) {
|
||||
this.reconnectDelay = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#webSocket]{@link Client#webSocket}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get ws(): any {
|
||||
return this.webSocket;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#connectedVersion]{@link Client#connectedVersion}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get version() {
|
||||
return this.connectedVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get onreceive(): messageCallbackType {
|
||||
return this.onUnhandledMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set onreceive(value: messageCallbackType) {
|
||||
this.onUnhandledMessage = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
* Prefer using [Client#watchForReceipt]{@link Client#watchForReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get onreceipt(): frameCallbackType {
|
||||
return this.onUnhandledReceipt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set onreceipt(value: frameCallbackType) {
|
||||
this.onUnhandledReceipt = value;
|
||||
}
|
||||
|
||||
private _heartbeatInfo: HeartbeatInfo = new HeartbeatInfo(this);
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
get heartbeat() {
|
||||
return this._heartbeatInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available for backward compatibility, renamed to [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}
|
||||
* [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*
|
||||
* **Deprecated**
|
||||
*/
|
||||
set heartbeat(value: { incoming: number; outgoing: number }) {
|
||||
this.heartbeatIncoming = value.incoming;
|
||||
this.heartbeatOutgoing = value.outgoing;
|
||||
}
|
||||
}
|
||||
26
node_modules/@stomp/stompjs/src/compatibility/heartbeat-info.ts
generated
vendored
Normal file
26
node_modules/@stomp/stompjs/src/compatibility/heartbeat-info.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { CompatClient } from './compat-client';
|
||||
|
||||
/**
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class HeartbeatInfo {
|
||||
constructor(private client: CompatClient) {}
|
||||
|
||||
get outgoing(): number {
|
||||
return this.client.heartbeatOutgoing;
|
||||
}
|
||||
|
||||
set outgoing(value: number) {
|
||||
this.client.heartbeatOutgoing = value;
|
||||
}
|
||||
|
||||
get incoming(): number {
|
||||
return this.client.heartbeatIncoming;
|
||||
}
|
||||
|
||||
set incoming(value: number) {
|
||||
this.client.heartbeatIncoming = value;
|
||||
}
|
||||
}
|
||||
118
node_modules/@stomp/stompjs/src/compatibility/stomp.ts
generated
vendored
Normal file
118
node_modules/@stomp/stompjs/src/compatibility/stomp.ts
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
import { Versions } from '../versions';
|
||||
import { CompatClient } from './compat-client';
|
||||
import { IStompSocket } from '../types';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
declare const WebSocket: {
|
||||
prototype: IStompSocket;
|
||||
new (url: string, protocols?: string | string[]): IStompSocket;
|
||||
};
|
||||
|
||||
/**
|
||||
* STOMP Class, acts like a factory to create {@link Client}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}.
|
||||
*/
|
||||
export class Stomp {
|
||||
/**
|
||||
* In case you need to use a non standard class for WebSocket.
|
||||
*
|
||||
* For example when using within NodeJS environment:
|
||||
*
|
||||
* ```javascript
|
||||
* StompJs = require('../../esm5/');
|
||||
* Stomp = StompJs.Stomp;
|
||||
* Stomp.WebSocketClass = require('websocket').w3cwebsocket;
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
// tslint:disable-next-line:variable-name
|
||||
public static WebSocketClass: any = null;
|
||||
|
||||
/**
|
||||
* This method creates a WebSocket client that is connected to
|
||||
* the STOMP server located at the url.
|
||||
*
|
||||
* ```javascript
|
||||
* var url = "ws://localhost:61614/stomp";
|
||||
* var client = Stomp.client(url);
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*/
|
||||
public static client(url: string, protocols?: string[]): CompatClient {
|
||||
// This is a hack to allow another implementation than the standard
|
||||
// HTML5 WebSocket class.
|
||||
//
|
||||
// It is possible to use another class by calling
|
||||
//
|
||||
// Stomp.WebSocketClass = MozWebSocket
|
||||
//
|
||||
// *prior* to call `Stomp.client()`.
|
||||
//
|
||||
// This hack is deprecated and `Stomp.over()` method should be used
|
||||
// instead.
|
||||
|
||||
// See remarks on the function Stomp.over
|
||||
if (protocols == null) {
|
||||
protocols = Versions.default.protocolVersions();
|
||||
}
|
||||
const wsFn = () => {
|
||||
const klass = Stomp.WebSocketClass || WebSocket;
|
||||
return new klass(url, protocols);
|
||||
};
|
||||
|
||||
return new CompatClient(wsFn);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is an alternative to [Stomp#client]{@link Stomp#client} to let the user
|
||||
* specify the WebSocket to use (either a standard HTML5 WebSocket or
|
||||
* a similar object).
|
||||
*
|
||||
* In order to support reconnection, the function Client._connect should be callable more than once.
|
||||
* While reconnecting
|
||||
* a new instance of underlying transport (TCP Socket, WebSocket or SockJS) will be needed. So, this function
|
||||
* alternatively allows passing a function that should return a new instance of the underlying socket.
|
||||
*
|
||||
* ```javascript
|
||||
* var client = Stomp.over(function(){
|
||||
* return new WebSocket('ws://localhost:15674/ws')
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* **Deprecated**
|
||||
*
|
||||
* It will be removed in next major version. Please switch to {@link Client}
|
||||
* using [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
public static over(ws: any): CompatClient {
|
||||
let wsFn: () => any;
|
||||
|
||||
if (typeof ws === 'function') {
|
||||
wsFn = ws;
|
||||
} else {
|
||||
console.warn(
|
||||
'Stomp.over did not receive a factory, auto reconnect will not work. ' +
|
||||
'Please see https://stomp-js.github.io/api-docs/latest/classes/Stomp.html#over'
|
||||
);
|
||||
wsFn = () => ws;
|
||||
}
|
||||
|
||||
return new CompatClient(wsFn);
|
||||
}
|
||||
}
|
||||
250
node_modules/@stomp/stompjs/src/frame-impl.ts
generated
vendored
Normal file
250
node_modules/@stomp/stompjs/src/frame-impl.ts
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
import { BYTE } from './byte';
|
||||
import { IFrame } from './i-frame';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { IRawFrameType } from './types';
|
||||
|
||||
/**
|
||||
* Frame class represents a STOMP frame.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class FrameImpl implements IFrame {
|
||||
/**
|
||||
* STOMP Command
|
||||
*/
|
||||
public command: string;
|
||||
|
||||
/**
|
||||
* Headers, key value pairs.
|
||||
*/
|
||||
public headers: StompHeaders;
|
||||
|
||||
/**
|
||||
* Is this frame binary (based on whether body/binaryBody was passed when creating this frame).
|
||||
*/
|
||||
public isBinaryBody: boolean;
|
||||
|
||||
/**
|
||||
* body of the frame
|
||||
*/
|
||||
get body(): string {
|
||||
if (!this._body && this.isBinaryBody) {
|
||||
this._body = new TextDecoder().decode(this._binaryBody);
|
||||
}
|
||||
return this._body;
|
||||
}
|
||||
private _body: string;
|
||||
|
||||
/**
|
||||
* body as Uint8Array
|
||||
*/
|
||||
get binaryBody(): Uint8Array {
|
||||
if (!this._binaryBody && !this.isBinaryBody) {
|
||||
this._binaryBody = new TextEncoder().encode(this._body);
|
||||
}
|
||||
return this._binaryBody;
|
||||
}
|
||||
private _binaryBody: Uint8Array;
|
||||
|
||||
private escapeHeaderValues: boolean;
|
||||
private skipContentLengthHeader: boolean;
|
||||
|
||||
/**
|
||||
* Frame constructor. `command`, `headers` and `body` are available as properties.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
constructor(params: {
|
||||
command: string;
|
||||
headers?: StompHeaders;
|
||||
body?: string;
|
||||
binaryBody?: Uint8Array;
|
||||
escapeHeaderValues?: boolean;
|
||||
skipContentLengthHeader?: boolean;
|
||||
}) {
|
||||
const {
|
||||
command,
|
||||
headers,
|
||||
body,
|
||||
binaryBody,
|
||||
escapeHeaderValues,
|
||||
skipContentLengthHeader,
|
||||
} = params;
|
||||
this.command = command;
|
||||
this.headers = (Object as any).assign({}, headers || {});
|
||||
|
||||
if (binaryBody) {
|
||||
this._binaryBody = binaryBody;
|
||||
this.isBinaryBody = true;
|
||||
} else {
|
||||
this._body = body || '';
|
||||
this.isBinaryBody = false;
|
||||
}
|
||||
this.escapeHeaderValues = escapeHeaderValues || false;
|
||||
this.skipContentLengthHeader = skipContentLengthHeader || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* deserialize a STOMP Frame from raw data.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static fromRawFrame(
|
||||
rawFrame: IRawFrameType,
|
||||
escapeHeaderValues: boolean
|
||||
): FrameImpl {
|
||||
const headers: StompHeaders = {};
|
||||
const trim = (str: string): string => str.replace(/^\s+|\s+$/g, '');
|
||||
|
||||
// In case of repeated headers, as per standards, first value need to be used
|
||||
for (const header of rawFrame.headers.reverse()) {
|
||||
const idx = header.indexOf(':');
|
||||
|
||||
const key = trim(header[0]);
|
||||
let value = trim(header[1]);
|
||||
|
||||
if (
|
||||
escapeHeaderValues &&
|
||||
rawFrame.command !== 'CONNECT' &&
|
||||
rawFrame.command !== 'CONNECTED'
|
||||
) {
|
||||
value = FrameImpl.hdrValueUnEscape(value);
|
||||
}
|
||||
|
||||
headers[key] = value;
|
||||
}
|
||||
|
||||
return new FrameImpl({
|
||||
command: rawFrame.command,
|
||||
headers,
|
||||
binaryBody: rawFrame.binaryBody,
|
||||
escapeHeaderValues,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public toString(): string {
|
||||
return this.serializeCmdAndHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* serialize this Frame in a format suitable to be passed to WebSocket.
|
||||
* If the body is string the output will be string.
|
||||
* If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public serialize(): string | ArrayBuffer {
|
||||
const cmdAndHeaders = this.serializeCmdAndHeaders();
|
||||
|
||||
if (this.isBinaryBody) {
|
||||
return FrameImpl.toUnit8Array(cmdAndHeaders, this._binaryBody).buffer;
|
||||
} else {
|
||||
return cmdAndHeaders + this._body + BYTE.NULL;
|
||||
}
|
||||
}
|
||||
|
||||
private serializeCmdAndHeaders(): string {
|
||||
const lines = [this.command];
|
||||
if (this.skipContentLengthHeader) {
|
||||
delete this.headers['content-length'];
|
||||
}
|
||||
|
||||
for (const name of Object.keys(this.headers || {})) {
|
||||
const value = this.headers[name];
|
||||
if (
|
||||
this.escapeHeaderValues &&
|
||||
this.command !== 'CONNECT' &&
|
||||
this.command !== 'CONNECTED'
|
||||
) {
|
||||
lines.push(`${name}:${FrameImpl.hdrValueEscape(`${value}`)}`);
|
||||
} else {
|
||||
lines.push(`${name}:${value}`);
|
||||
}
|
||||
}
|
||||
if (
|
||||
this.isBinaryBody ||
|
||||
(!this.isBodyEmpty() && !this.skipContentLengthHeader)
|
||||
) {
|
||||
lines.push(`content-length:${this.bodyLength()}`);
|
||||
}
|
||||
return lines.join(BYTE.LF) + BYTE.LF + BYTE.LF;
|
||||
}
|
||||
|
||||
private isBodyEmpty(): boolean {
|
||||
return this.bodyLength() === 0;
|
||||
}
|
||||
|
||||
private bodyLength(): number {
|
||||
const binaryBody = this.binaryBody;
|
||||
return binaryBody ? binaryBody.length : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the size of a UTF-8 string by counting its number of bytes
|
||||
* (and not the number of characters composing the string)
|
||||
*/
|
||||
private static sizeOfUTF8(s: string): number {
|
||||
return s ? new TextEncoder().encode(s).length : 0;
|
||||
}
|
||||
|
||||
private static toUnit8Array(
|
||||
cmdAndHeaders: string,
|
||||
binaryBody: Uint8Array
|
||||
): Uint8Array {
|
||||
const uint8CmdAndHeaders = new TextEncoder().encode(cmdAndHeaders);
|
||||
const nullTerminator = new Uint8Array([0]);
|
||||
const uint8Frame = new Uint8Array(
|
||||
uint8CmdAndHeaders.length + binaryBody.length + nullTerminator.length
|
||||
);
|
||||
|
||||
uint8Frame.set(uint8CmdAndHeaders);
|
||||
uint8Frame.set(binaryBody, uint8CmdAndHeaders.length);
|
||||
uint8Frame.set(
|
||||
nullTerminator,
|
||||
uint8CmdAndHeaders.length + binaryBody.length
|
||||
);
|
||||
|
||||
return uint8Frame;
|
||||
}
|
||||
/**
|
||||
* Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static marshall(params: {
|
||||
command: string;
|
||||
headers?: StompHeaders;
|
||||
body?: string;
|
||||
binaryBody?: Uint8Array;
|
||||
escapeHeaderValues?: boolean;
|
||||
skipContentLengthHeader?: boolean;
|
||||
}) {
|
||||
const frame = new FrameImpl(params);
|
||||
return frame.serialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape header values
|
||||
*/
|
||||
private static hdrValueEscape(str: string): string {
|
||||
return str
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\r/g, '\\r')
|
||||
.replace(/\n/g, '\\n')
|
||||
.replace(/:/g, '\\c');
|
||||
}
|
||||
|
||||
/**
|
||||
* UnEscape header values
|
||||
*/
|
||||
private static hdrValueUnEscape(str: string): string {
|
||||
return str
|
||||
.replace(/\\r/g, '\r')
|
||||
.replace(/\\n/g, '\n')
|
||||
.replace(/\\c/g, ':')
|
||||
.replace(/\\\\/g, '\\');
|
||||
}
|
||||
}
|
||||
41
node_modules/@stomp/stompjs/src/i-frame.ts
generated
vendored
Normal file
41
node_modules/@stomp/stompjs/src/i-frame.ts
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
|
||||
/**
|
||||
* It represents a STOMP frame. Many of the callbacks pass an IFrame received from
|
||||
* the STOMP broker. For advanced usage you might need to access [headers]{@link IFrame#headers}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* {@link IMessage} is an extended IFrame.
|
||||
*/
|
||||
export interface IFrame {
|
||||
/**
|
||||
* STOMP Command
|
||||
*/
|
||||
command: string;
|
||||
|
||||
/**
|
||||
* Headers, key value pairs.
|
||||
*/
|
||||
headers: StompHeaders;
|
||||
|
||||
/**
|
||||
* Is this frame binary (based on whether body/binaryBody was passed when creating this frame).
|
||||
*/
|
||||
isBinaryBody: boolean;
|
||||
|
||||
/**
|
||||
* body of the frame as string
|
||||
*/
|
||||
readonly body: string;
|
||||
|
||||
/**
|
||||
* body as Uint8Array
|
||||
*/
|
||||
readonly binaryBody: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for {@link IFrame}
|
||||
*/
|
||||
export type Frame = IFrame;
|
||||
35
node_modules/@stomp/stompjs/src/i-message.ts
generated
vendored
Normal file
35
node_modules/@stomp/stompjs/src/i-message.ts
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { IFrame } from './i-frame';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
|
||||
/**
|
||||
* Instance of Message will be passed to [subscription callback]{@link Client#subscribe}
|
||||
* and [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
* Since it is an extended {@link FrameImpl}, you can access [headers]{@link FrameImpl#headers}
|
||||
* and [body]{@link FrameImpl#body} as properties.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* See [Client#subscribe]{@link Client#subscribe} for example.
|
||||
*/
|
||||
export interface IMessage extends IFrame {
|
||||
/**
|
||||
* When subscribing with manual acknowledgement, call this method on the message to ACK the message.
|
||||
*
|
||||
* See [Client#ack]{@link Client#ack} for an example.
|
||||
*/
|
||||
ack: (headers?: StompHeaders) => void;
|
||||
|
||||
/**
|
||||
* When subscribing with manual acknowledgement, call this method on the message to NACK the message.
|
||||
*
|
||||
* See [Client#nack]{@link Client#nack} for an example.
|
||||
*/
|
||||
nack: (headers?: StompHeaders) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aliased to {@link IMessage}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type Message = IMessage;
|
||||
23
node_modules/@stomp/stompjs/src/i-transaction.ts
generated
vendored
Normal file
23
node_modules/@stomp/stompjs/src/i-transaction.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* A Transaction is created by calling [Client#begin]{@link Client#begin}
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* TODO: Example and caveat
|
||||
*/
|
||||
export interface ITransaction {
|
||||
/**
|
||||
* You will need to access this to send, ack, or nack within this transaction.
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Commit this transaction. See [Client#commit]{@link Client#commit} for an example.
|
||||
*/
|
||||
commit: () => void;
|
||||
|
||||
/**
|
||||
* Abort this transaction. See [Client#abort]{@link Client#abort} for an example.
|
||||
*/
|
||||
abort: () => void;
|
||||
}
|
||||
15
node_modules/@stomp/stompjs/src/index.ts
generated
vendored
Normal file
15
node_modules/@stomp/stompjs/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export * from './client';
|
||||
export * from './frame-impl';
|
||||
export * from './i-frame';
|
||||
export * from './i-message';
|
||||
export * from './parser';
|
||||
export * from './stomp-config';
|
||||
export * from './stomp-headers';
|
||||
export * from './stomp-subscription';
|
||||
export * from './i-transaction';
|
||||
export * from './types';
|
||||
export * from './versions';
|
||||
|
||||
// Compatibility code
|
||||
export * from './compatibility/compat-client';
|
||||
export * from './compatibility/stomp';
|
||||
255
node_modules/@stomp/stompjs/src/parser.ts
generated
vendored
Normal file
255
node_modules/@stomp/stompjs/src/parser.ts
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
import { IRawFrameType } from './types';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const NULL = 0;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const LF = 10;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const CR = 13;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const COLON = 58;
|
||||
|
||||
/**
|
||||
* This is an evented, rec descent parser.
|
||||
* A stream of Octets can be passed and whenever it recognizes
|
||||
* a complete Frame or an incoming ping it will invoke the registered callbacks.
|
||||
*
|
||||
* All incoming Octets are fed into _onByte function.
|
||||
* Depending on current state the _onByte function keeps changing.
|
||||
* Depending on the state it keeps accumulating into _token and _results.
|
||||
* State is indicated by current value of _onByte, all states are named as _collect.
|
||||
*
|
||||
* STOMP standards https://stomp.github.io/stomp-specification-1.2.html
|
||||
* imply that all lengths are considered in bytes (instead of string lengths).
|
||||
* So, before actual parsing, if the incoming data is String it is converted to Octets.
|
||||
* This allows faithful implementation of the protocol and allows NULL Octets to be present in the body.
|
||||
*
|
||||
* There is no peek function on the incoming data.
|
||||
* When a state change occurs based on an Octet without consuming the Octet,
|
||||
* the Octet, after state change, is fed again (_reinjectByte).
|
||||
* This became possible as the state change can be determined by inspecting just one Octet.
|
||||
*
|
||||
* There are two modes to collect the body, if content-length header is there then it by counting Octets
|
||||
* otherwise it is determined by NULL terminator.
|
||||
*
|
||||
* Following the standards, the command and headers are converted to Strings
|
||||
* and the body is returned as Octets.
|
||||
* Headers are returned as an array and not as Hash - to allow multiple occurrence of an header.
|
||||
*
|
||||
* This parser does not use Regular Expressions as that can only operate on Strings.
|
||||
*
|
||||
* It handles if multiple STOMP frames are given as one chunk, a frame is split into multiple chunks, or
|
||||
* any combination there of. The parser remembers its state (any partial frame) and continues when a new chunk
|
||||
* is pushed.
|
||||
*
|
||||
* Typically the higher level function will convert headers to Hash, handle unescaping of header values
|
||||
* (which is protocol version specific), and convert body to text.
|
||||
*
|
||||
* Check the parser.spec.js to understand cases that this parser is supposed to handle.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class Parser {
|
||||
private readonly _encoder = new TextEncoder();
|
||||
private readonly _decoder = new TextDecoder();
|
||||
|
||||
private _results: IRawFrameType;
|
||||
|
||||
private _token: number[] = [];
|
||||
private _headerKey: string;
|
||||
private _bodyBytesRemaining: number;
|
||||
|
||||
private _onByte: (byte: number) => void;
|
||||
|
||||
public constructor(
|
||||
public onFrame: (rawFrame: IRawFrameType) => void,
|
||||
public onIncomingPing: () => void
|
||||
) {
|
||||
this._initState();
|
||||
}
|
||||
|
||||
public parseChunk(
|
||||
segment: string | ArrayBuffer,
|
||||
appendMissingNULLonIncoming: boolean = false
|
||||
) {
|
||||
let chunk: Uint8Array;
|
||||
|
||||
if (segment instanceof ArrayBuffer) {
|
||||
chunk = new Uint8Array(segment);
|
||||
} else {
|
||||
chunk = this._encoder.encode(segment);
|
||||
}
|
||||
|
||||
// See https://github.com/stomp-js/stompjs/issues/89
|
||||
// Remove when underlying issue is fixed.
|
||||
//
|
||||
// Send a NULL byte, if the last byte of a Text frame was not NULL.F
|
||||
if (appendMissingNULLonIncoming && chunk[chunk.length - 1] !== 0) {
|
||||
const chunkWithNull = new Uint8Array(chunk.length + 1);
|
||||
chunkWithNull.set(chunk, 0);
|
||||
chunkWithNull[chunk.length] = 0;
|
||||
chunk = chunkWithNull;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:prefer-for-of
|
||||
for (let i = 0; i < chunk.length; i++) {
|
||||
const byte = chunk[i];
|
||||
this._onByte(byte);
|
||||
}
|
||||
}
|
||||
|
||||
// The following implements a simple Rec Descent Parser.
|
||||
// The grammar is simple and just one byte tells what should be the next state
|
||||
|
||||
private _collectFrame(byte: number): void {
|
||||
if (byte === NULL) {
|
||||
// Ignore
|
||||
return;
|
||||
}
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
// Incoming Ping
|
||||
this.onIncomingPing();
|
||||
return;
|
||||
}
|
||||
|
||||
this._onByte = this._collectCommand;
|
||||
this._reinjectByte(byte);
|
||||
}
|
||||
|
||||
private _collectCommand(byte: number): void {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._results.command = this._consumeTokenAsUTF8();
|
||||
this._onByte = this._collectHeaders;
|
||||
return;
|
||||
}
|
||||
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
|
||||
private _collectHeaders(byte: number): void {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._setupCollectBody();
|
||||
return;
|
||||
}
|
||||
this._onByte = this._collectHeaderKey;
|
||||
this._reinjectByte(byte);
|
||||
}
|
||||
|
||||
private _reinjectByte(byte: number) {
|
||||
this._onByte(byte);
|
||||
}
|
||||
|
||||
private _collectHeaderKey(byte: number): void {
|
||||
if (byte === COLON) {
|
||||
this._headerKey = this._consumeTokenAsUTF8();
|
||||
this._onByte = this._collectHeaderValue;
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
|
||||
private _collectHeaderValue(byte: number): void {
|
||||
if (byte === CR) {
|
||||
// Ignore CR
|
||||
return;
|
||||
}
|
||||
if (byte === LF) {
|
||||
this._results.headers.push([this._headerKey, this._consumeTokenAsUTF8()]);
|
||||
this._headerKey = undefined;
|
||||
this._onByte = this._collectHeaders;
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
|
||||
private _setupCollectBody() {
|
||||
const contentLengthHeader = this._results.headers.filter(
|
||||
(header: [string, string]) => {
|
||||
return header[0] === 'content-length';
|
||||
}
|
||||
)[0];
|
||||
|
||||
if (contentLengthHeader) {
|
||||
this._bodyBytesRemaining = parseInt(contentLengthHeader[1], 10);
|
||||
this._onByte = this._collectBodyFixedSize;
|
||||
} else {
|
||||
this._onByte = this._collectBodyNullTerminated;
|
||||
}
|
||||
}
|
||||
|
||||
private _collectBodyNullTerminated(byte: number): void {
|
||||
if (byte === NULL) {
|
||||
this._retrievedBody();
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
|
||||
private _collectBodyFixedSize(byte: number): void {
|
||||
// It is post decrement, so that we discard the trailing NULL octet
|
||||
if (this._bodyBytesRemaining-- === 0) {
|
||||
this._retrievedBody();
|
||||
return;
|
||||
}
|
||||
this._consumeByte(byte);
|
||||
}
|
||||
|
||||
private _retrievedBody() {
|
||||
this._results.binaryBody = this._consumeTokenAsRaw();
|
||||
|
||||
this.onFrame(this._results);
|
||||
|
||||
this._initState();
|
||||
}
|
||||
|
||||
// Rec Descent Parser helpers
|
||||
|
||||
private _consumeByte(byte: number) {
|
||||
this._token.push(byte);
|
||||
}
|
||||
|
||||
private _consumeTokenAsUTF8() {
|
||||
return this._decoder.decode(this._consumeTokenAsRaw());
|
||||
}
|
||||
|
||||
private _consumeTokenAsRaw() {
|
||||
const rawResult = new Uint8Array(this._token);
|
||||
this._token = [];
|
||||
return rawResult;
|
||||
}
|
||||
|
||||
private _initState() {
|
||||
this._results = {
|
||||
command: undefined,
|
||||
headers: [],
|
||||
binaryBody: undefined,
|
||||
};
|
||||
|
||||
this._token = [];
|
||||
this._headerKey = undefined;
|
||||
|
||||
this._onByte = this._collectFrame;
|
||||
}
|
||||
}
|
||||
152
node_modules/@stomp/stompjs/src/stomp-config.ts
generated
vendored
Normal file
152
node_modules/@stomp/stompjs/src/stomp-config.ts
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import {
|
||||
ActivationState,
|
||||
closeEventCallbackType,
|
||||
debugFnType,
|
||||
frameCallbackType,
|
||||
messageCallbackType,
|
||||
wsErrorCallbackType,
|
||||
} from './types';
|
||||
import { Versions } from './versions';
|
||||
|
||||
/**
|
||||
* Configuration options for STOMP Client, each key corresponds to
|
||||
* field by the same name in {@link Client}. This can be passed to
|
||||
* the constructor of {@link Client} or to [Client#configure]{@link Client#configure}.
|
||||
*
|
||||
* There used to be a class with the same name in `@stomp/ng2-stompjs`, which has been replaced by
|
||||
* {@link RxStompConfig} and {@link InjectableRxStompConfig}.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompConfig {
|
||||
/**
|
||||
* See [Client#brokerURL]{@link Client#brokerURL}.
|
||||
*/
|
||||
public brokerURL?: string;
|
||||
|
||||
/**
|
||||
* See See [Client#stompVersions]{@link Client#stompVersions}.
|
||||
*/
|
||||
public stompVersions?: Versions;
|
||||
|
||||
/**
|
||||
* See [Client#webSocketFactory]{@link Client#webSocketFactory}.
|
||||
*/
|
||||
public webSocketFactory?: () => any;
|
||||
|
||||
/**
|
||||
* See [Client#connectionTimeout]{@link Client#connectionTimeout}.
|
||||
*/
|
||||
public connectionTimeout?: number;
|
||||
|
||||
/**
|
||||
* See [Client#reconnectDelay]{@link Client#reconnectDelay}.
|
||||
*/
|
||||
public reconnectDelay?: number;
|
||||
|
||||
/**
|
||||
* See [Client#heartbeatIncoming]{@link Client#heartbeatIncoming}.
|
||||
*/
|
||||
public heartbeatIncoming?: number;
|
||||
|
||||
/**
|
||||
* See [Client#heartbeatOutgoing]{@link Client#heartbeatOutgoing}.
|
||||
*/
|
||||
public heartbeatOutgoing?: number;
|
||||
|
||||
/**
|
||||
* See [Client#splitLargeFrames]{@link Client#splitLargeFrames}.
|
||||
*/
|
||||
public splitLargeFrames?: boolean;
|
||||
|
||||
/**
|
||||
* See [Client#forceBinaryWSFrames]{@link Client#forceBinaryWSFrames}.
|
||||
*/
|
||||
public forceBinaryWSFrames?: boolean;
|
||||
|
||||
/**
|
||||
* See [Client#appendMissingNULLonIncoming]{@link Client#appendMissingNULLonIncoming}.
|
||||
*/
|
||||
public appendMissingNULLonIncoming?: boolean;
|
||||
|
||||
/**
|
||||
* See [Client#maxWebSocketChunkSize]{@link Client#maxWebSocketChunkSize}.
|
||||
*/
|
||||
public maxWebSocketChunkSize?: number;
|
||||
|
||||
/**
|
||||
* See [Client#connectHeaders]{@link Client#connectHeaders}.
|
||||
*/
|
||||
public connectHeaders?: StompHeaders;
|
||||
|
||||
/**
|
||||
* See [Client#disconnectHeaders]{@link Client#disconnectHeaders}.
|
||||
*/
|
||||
public disconnectHeaders?: StompHeaders;
|
||||
|
||||
/**
|
||||
* See [Client#onUnhandledMessage]{@link Client#onUnhandledMessage}.
|
||||
*/
|
||||
public onUnhandledMessage?: messageCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onUnhandledReceipt]{@link Client#onUnhandledReceipt}.
|
||||
*/
|
||||
public onUnhandledReceipt?: frameCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onUnhandledFrame]{@link Client#onUnhandledFrame}.
|
||||
*/
|
||||
public onUnhandledFrame?: frameCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#beforeConnect]{@link Client#beforeConnect}.
|
||||
*/
|
||||
public beforeConnect?: () => void | Promise<void>;
|
||||
|
||||
/**
|
||||
* See [Client#onConnect]{@link Client#onConnect}.
|
||||
*/
|
||||
public onConnect?: frameCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onDisconnect]{@link Client#onDisconnect}.
|
||||
*/
|
||||
public onDisconnect?: frameCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onStompError]{@link Client#onStompError}.
|
||||
*/
|
||||
public onStompError?: frameCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onWebSocketClose]{@link Client#onWebSocketClose}.
|
||||
*/
|
||||
public onWebSocketClose?: closeEventCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#onWebSocketError]{@link Client#onWebSocketError}.
|
||||
*/
|
||||
public onWebSocketError?: wsErrorCallbackType;
|
||||
|
||||
/**
|
||||
* See [Client#logRawCommunication]{@link Client#logRawCommunication}.
|
||||
*/
|
||||
public logRawCommunication?: boolean;
|
||||
|
||||
/**
|
||||
* See [Client#debug]{@link Client#debug}.
|
||||
*/
|
||||
public debug?: debugFnType;
|
||||
|
||||
/**
|
||||
* See [Client#discardWebsocketOnCommFailure]{@link Client#discardWebsocketOnCommFailure}.
|
||||
*/
|
||||
public discardWebsocketOnCommFailure?: boolean;
|
||||
|
||||
/**
|
||||
* See [Client#onChangeState]{@link Client#onChangeState}.
|
||||
*/
|
||||
public onChangeState?: (state: ActivationState) => void;
|
||||
}
|
||||
539
node_modules/@stomp/stompjs/src/stomp-handler.ts
generated
vendored
Normal file
539
node_modules/@stomp/stompjs/src/stomp-handler.ts
generated
vendored
Normal file
@@ -0,0 +1,539 @@
|
||||
import { BYTE } from './byte';
|
||||
import { Client } from './client';
|
||||
import { FrameImpl } from './frame-impl';
|
||||
import { IMessage } from './i-message';
|
||||
import { ITransaction } from './i-transaction';
|
||||
import { Parser } from './parser';
|
||||
import { StompConfig } from './stomp-config';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
import { StompSubscription } from './stomp-subscription';
|
||||
import {
|
||||
closeEventCallbackType,
|
||||
debugFnType,
|
||||
frameCallbackType,
|
||||
IPublishParams,
|
||||
IStompSocket,
|
||||
IStompSocketMessageEvent,
|
||||
messageCallbackType,
|
||||
StompSocketState,
|
||||
wsErrorCallbackType,
|
||||
} from './types';
|
||||
import { Versions } from './versions';
|
||||
import { augmentWebsocket } from './augment-websocket';
|
||||
|
||||
/**
|
||||
* The STOMP protocol handler
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export class StompHandler {
|
||||
public debug: debugFnType;
|
||||
|
||||
public stompVersions: Versions;
|
||||
|
||||
public connectHeaders: StompHeaders;
|
||||
|
||||
public disconnectHeaders: StompHeaders;
|
||||
|
||||
public heartbeatIncoming: number;
|
||||
|
||||
public heartbeatOutgoing: number;
|
||||
|
||||
public onUnhandledMessage: messageCallbackType;
|
||||
|
||||
public onUnhandledReceipt: frameCallbackType;
|
||||
|
||||
public onUnhandledFrame: frameCallbackType;
|
||||
|
||||
public onConnect: frameCallbackType;
|
||||
|
||||
public onDisconnect: frameCallbackType;
|
||||
|
||||
public onStompError: frameCallbackType;
|
||||
|
||||
public onWebSocketClose: closeEventCallbackType;
|
||||
|
||||
public onWebSocketError: wsErrorCallbackType;
|
||||
|
||||
public logRawCommunication: boolean;
|
||||
|
||||
public splitLargeFrames: boolean;
|
||||
|
||||
public maxWebSocketChunkSize: number;
|
||||
|
||||
public forceBinaryWSFrames: boolean;
|
||||
|
||||
public appendMissingNULLonIncoming: boolean;
|
||||
|
||||
public discardWebsocketOnCommFailure: boolean;
|
||||
|
||||
get connectedVersion(): string {
|
||||
return this._connectedVersion;
|
||||
}
|
||||
private _connectedVersion: string;
|
||||
|
||||
get connected(): boolean {
|
||||
return this._connected;
|
||||
}
|
||||
|
||||
private _connected: boolean;
|
||||
|
||||
private readonly _subscriptions: { [key: string]: messageCallbackType };
|
||||
private readonly _receiptWatchers: { [key: string]: frameCallbackType };
|
||||
private _partialData: string;
|
||||
private _escapeHeaderValues: boolean;
|
||||
private _counter: number;
|
||||
private _pinger: any;
|
||||
private _ponger: any;
|
||||
private _lastServerActivityTS: number;
|
||||
|
||||
private _onclose: (closeEvent: any) => void;
|
||||
|
||||
constructor(
|
||||
private _client: Client,
|
||||
public _webSocket: IStompSocket,
|
||||
config: StompConfig = {}
|
||||
) {
|
||||
// used to index subscribers
|
||||
this._counter = 0;
|
||||
|
||||
// subscription callbacks indexed by subscriber's ID
|
||||
this._subscriptions = {};
|
||||
|
||||
// receipt-watchers indexed by receipts-ids
|
||||
this._receiptWatchers = {};
|
||||
|
||||
this._partialData = '';
|
||||
|
||||
this._escapeHeaderValues = false;
|
||||
|
||||
this._lastServerActivityTS = Date.now();
|
||||
|
||||
this.configure(config);
|
||||
}
|
||||
|
||||
public configure(conf: StompConfig): void {
|
||||
// bulk assign all properties to this
|
||||
(Object as any).assign(this, conf);
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
const parser = new Parser(
|
||||
// On Frame
|
||||
rawFrame => {
|
||||
const frame = FrameImpl.fromRawFrame(
|
||||
rawFrame,
|
||||
this._escapeHeaderValues
|
||||
);
|
||||
|
||||
// if this.logRawCommunication is set, the rawChunk is logged at this._webSocket.onmessage
|
||||
if (!this.logRawCommunication) {
|
||||
this.debug(`<<< ${frame}`);
|
||||
}
|
||||
|
||||
const serverFrameHandler =
|
||||
this._serverFrameHandlers[frame.command] || this.onUnhandledFrame;
|
||||
serverFrameHandler(frame);
|
||||
},
|
||||
// On Incoming Ping
|
||||
() => {
|
||||
this.debug('<<< PONG');
|
||||
}
|
||||
);
|
||||
|
||||
this._webSocket.onmessage = (evt: IStompSocketMessageEvent) => {
|
||||
this.debug('Received data');
|
||||
this._lastServerActivityTS = Date.now();
|
||||
|
||||
if (this.logRawCommunication) {
|
||||
const rawChunkAsString =
|
||||
evt.data instanceof ArrayBuffer
|
||||
? new TextDecoder().decode(evt.data)
|
||||
: evt.data;
|
||||
this.debug(`<<< ${rawChunkAsString}`);
|
||||
}
|
||||
|
||||
parser.parseChunk(evt.data, this.appendMissingNULLonIncoming);
|
||||
};
|
||||
|
||||
this._onclose = (closeEvent): void => {
|
||||
this.debug(`Connection closed to ${this._client.brokerURL}`);
|
||||
this._cleanUp();
|
||||
this.onWebSocketClose(closeEvent);
|
||||
};
|
||||
|
||||
this._webSocket.onclose = this._onclose;
|
||||
|
||||
this._webSocket.onerror = (errorEvent): void => {
|
||||
this.onWebSocketError(errorEvent);
|
||||
};
|
||||
|
||||
this._webSocket.onopen = () => {
|
||||
// Clone before updating
|
||||
const connectHeaders = (Object as any).assign({}, this.connectHeaders);
|
||||
|
||||
this.debug('Web Socket Opened...');
|
||||
connectHeaders['accept-version'] = this.stompVersions.supportedVersions();
|
||||
connectHeaders['heart-beat'] = [
|
||||
this.heartbeatOutgoing,
|
||||
this.heartbeatIncoming,
|
||||
].join(',');
|
||||
this._transmit({ command: 'CONNECT', headers: connectHeaders });
|
||||
};
|
||||
}
|
||||
|
||||
private readonly _serverFrameHandlers: {
|
||||
[key: string]: frameCallbackType;
|
||||
} = {
|
||||
// [CONNECTED Frame](http://stomp.github.com/stomp-specification-1.2.html#CONNECTED_Frame)
|
||||
CONNECTED: frame => {
|
||||
this.debug(`connected to server ${frame.headers.server}`);
|
||||
this._connected = true;
|
||||
this._connectedVersion = frame.headers.version;
|
||||
// STOMP version 1.2 needs header values to be escaped
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
this._escapeHeaderValues = true;
|
||||
}
|
||||
|
||||
this._setupHeartbeat(frame.headers);
|
||||
this.onConnect(frame);
|
||||
},
|
||||
|
||||
// [MESSAGE Frame](http://stomp.github.com/stomp-specification-1.2.html#MESSAGE)
|
||||
MESSAGE: frame => {
|
||||
// the callback is registered when the client calls
|
||||
// `subscribe()`.
|
||||
// If there is no registered subscription for the received message,
|
||||
// the default `onUnhandledMessage` callback is used that the client can set.
|
||||
// This is useful for subscriptions that are automatically created
|
||||
// on the browser side (e.g. [RabbitMQ's temporary
|
||||
// queues](http://www.rabbitmq.com/stomp.html)).
|
||||
const subscription = frame.headers.subscription;
|
||||
const onReceive =
|
||||
this._subscriptions[subscription] || this.onUnhandledMessage;
|
||||
|
||||
// bless the frame to be a Message
|
||||
const message = frame as IMessage;
|
||||
|
||||
const client = this;
|
||||
const messageId =
|
||||
this._connectedVersion === Versions.V1_2
|
||||
? message.headers.ack
|
||||
: message.headers['message-id'];
|
||||
|
||||
// add `ack()` and `nack()` methods directly to the returned frame
|
||||
// so that a simple call to `message.ack()` can acknowledge the message.
|
||||
message.ack = (headers: StompHeaders = {}): void => {
|
||||
return client.ack(messageId, subscription, headers);
|
||||
};
|
||||
message.nack = (headers: StompHeaders = {}): void => {
|
||||
return client.nack(messageId, subscription, headers);
|
||||
};
|
||||
onReceive(message);
|
||||
},
|
||||
|
||||
// [RECEIPT Frame](http://stomp.github.com/stomp-specification-1.2.html#RECEIPT)
|
||||
RECEIPT: frame => {
|
||||
const callback = this._receiptWatchers[frame.headers['receipt-id']];
|
||||
if (callback) {
|
||||
callback(frame);
|
||||
// Server will acknowledge only once, remove the callback
|
||||
delete this._receiptWatchers[frame.headers['receipt-id']];
|
||||
} else {
|
||||
this.onUnhandledReceipt(frame);
|
||||
}
|
||||
},
|
||||
|
||||
// [ERROR Frame](http://stomp.github.com/stomp-specification-1.2.html#ERROR)
|
||||
ERROR: frame => {
|
||||
this.onStompError(frame);
|
||||
},
|
||||
};
|
||||
|
||||
private _setupHeartbeat(headers: StompHeaders): void {
|
||||
if (
|
||||
headers.version !== Versions.V1_1 &&
|
||||
headers.version !== Versions.V1_2
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// It is valid for the server to not send this header
|
||||
// https://stomp.github.io/stomp-specification-1.2.html#Heart-beating
|
||||
if (!headers['heart-beat']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// heart-beat header received from the server looks like:
|
||||
//
|
||||
// heart-beat: sx, sy
|
||||
const [serverOutgoing, serverIncoming] = headers['heart-beat']
|
||||
.split(',')
|
||||
.map((v: string) => parseInt(v, 10));
|
||||
|
||||
if (this.heartbeatOutgoing !== 0 && serverIncoming !== 0) {
|
||||
const ttl: number = Math.max(this.heartbeatOutgoing, serverIncoming);
|
||||
this.debug(`send PING every ${ttl}ms`);
|
||||
this._pinger = setInterval(() => {
|
||||
if (this._webSocket.readyState === StompSocketState.OPEN) {
|
||||
this._webSocket.send(BYTE.LF);
|
||||
this.debug('>>> PING');
|
||||
}
|
||||
}, ttl);
|
||||
}
|
||||
|
||||
if (this.heartbeatIncoming !== 0 && serverOutgoing !== 0) {
|
||||
const ttl: number = Math.max(this.heartbeatIncoming, serverOutgoing);
|
||||
this.debug(`check PONG every ${ttl}ms`);
|
||||
this._ponger = setInterval(() => {
|
||||
const delta = Date.now() - this._lastServerActivityTS;
|
||||
// We wait twice the TTL to be flexible on window's setInterval calls
|
||||
if (delta > ttl * 2) {
|
||||
this.debug(`did not receive server activity for the last ${delta}ms`);
|
||||
this._closeOrDiscardWebsocket();
|
||||
}
|
||||
}, ttl);
|
||||
}
|
||||
}
|
||||
|
||||
private _closeOrDiscardWebsocket() {
|
||||
if (this.discardWebsocketOnCommFailure) {
|
||||
this.debug(
|
||||
'Discarding websocket, the underlying socket may linger for a while'
|
||||
);
|
||||
this._discardWebsocket();
|
||||
} else {
|
||||
this.debug('Issuing close on the websocket');
|
||||
this._closeWebsocket();
|
||||
}
|
||||
}
|
||||
|
||||
public forceDisconnect() {
|
||||
if (this._webSocket) {
|
||||
if (
|
||||
this._webSocket.readyState === StompSocketState.CONNECTING ||
|
||||
this._webSocket.readyState === StompSocketState.OPEN
|
||||
) {
|
||||
this._closeOrDiscardWebsocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public _closeWebsocket() {
|
||||
this._webSocket.onmessage = () => {}; // ignore messages
|
||||
this._webSocket.close();
|
||||
}
|
||||
|
||||
private _discardWebsocket() {
|
||||
if (!this._webSocket.terminate) {
|
||||
augmentWebsocket(this._webSocket, (msg: string) => this.debug(msg));
|
||||
}
|
||||
|
||||
this._webSocket.terminate();
|
||||
}
|
||||
|
||||
private _transmit(params: {
|
||||
command: string;
|
||||
headers?: StompHeaders;
|
||||
body?: string;
|
||||
binaryBody?: Uint8Array;
|
||||
skipContentLengthHeader?: boolean;
|
||||
}): void {
|
||||
const { command, headers, body, binaryBody, skipContentLengthHeader } =
|
||||
params;
|
||||
const frame = new FrameImpl({
|
||||
command,
|
||||
headers,
|
||||
body,
|
||||
binaryBody,
|
||||
escapeHeaderValues: this._escapeHeaderValues,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
|
||||
let rawChunk = frame.serialize();
|
||||
|
||||
if (this.logRawCommunication) {
|
||||
this.debug(`>>> ${rawChunk}`);
|
||||
} else {
|
||||
this.debug(`>>> ${frame}`);
|
||||
}
|
||||
|
||||
if (this.forceBinaryWSFrames && typeof rawChunk === 'string') {
|
||||
rawChunk = new TextEncoder().encode(rawChunk);
|
||||
}
|
||||
|
||||
if (typeof rawChunk !== 'string' || !this.splitLargeFrames) {
|
||||
this._webSocket.send(rawChunk);
|
||||
} else {
|
||||
let out = rawChunk as string;
|
||||
while (out.length > 0) {
|
||||
const chunk = out.substring(0, this.maxWebSocketChunkSize);
|
||||
out = out.substring(this.maxWebSocketChunkSize);
|
||||
this._webSocket.send(chunk);
|
||||
this.debug(`chunk sent = ${chunk.length}, remaining = ${out.length}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this.connected) {
|
||||
try {
|
||||
// clone before updating
|
||||
const disconnectHeaders = (Object as any).assign(
|
||||
{},
|
||||
this.disconnectHeaders
|
||||
);
|
||||
|
||||
if (!disconnectHeaders.receipt) {
|
||||
disconnectHeaders.receipt = `close-${this._counter++}`;
|
||||
}
|
||||
this.watchForReceipt(disconnectHeaders.receipt, frame => {
|
||||
this._closeWebsocket();
|
||||
this._cleanUp();
|
||||
this.onDisconnect(frame);
|
||||
});
|
||||
this._transmit({ command: 'DISCONNECT', headers: disconnectHeaders });
|
||||
} catch (error) {
|
||||
this.debug(`Ignoring error during disconnect ${error}`);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
this._webSocket.readyState === StompSocketState.CONNECTING ||
|
||||
this._webSocket.readyState === StompSocketState.OPEN
|
||||
) {
|
||||
this._closeWebsocket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _cleanUp() {
|
||||
this._connected = false;
|
||||
|
||||
if (this._pinger) {
|
||||
clearInterval(this._pinger);
|
||||
}
|
||||
if (this._ponger) {
|
||||
clearInterval(this._ponger);
|
||||
}
|
||||
}
|
||||
|
||||
public publish(params: IPublishParams): void {
|
||||
const { destination, headers, body, binaryBody, skipContentLengthHeader } =
|
||||
params;
|
||||
const hdrs: StompHeaders = (Object as any).assign({ destination }, headers);
|
||||
this._transmit({
|
||||
command: 'SEND',
|
||||
headers: hdrs,
|
||||
body,
|
||||
binaryBody,
|
||||
skipContentLengthHeader,
|
||||
});
|
||||
}
|
||||
|
||||
public watchForReceipt(receiptId: string, callback: frameCallbackType): void {
|
||||
this._receiptWatchers[receiptId] = callback;
|
||||
}
|
||||
|
||||
public subscribe(
|
||||
destination: string,
|
||||
callback: messageCallbackType,
|
||||
headers: StompHeaders = {}
|
||||
): StompSubscription {
|
||||
headers = (Object as any).assign({}, headers);
|
||||
|
||||
if (!headers.id) {
|
||||
headers.id = `sub-${this._counter++}`;
|
||||
}
|
||||
headers.destination = destination;
|
||||
this._subscriptions[headers.id] = callback;
|
||||
this._transmit({ command: 'SUBSCRIBE', headers });
|
||||
const client = this;
|
||||
return {
|
||||
id: headers.id,
|
||||
|
||||
unsubscribe(hdrs) {
|
||||
return client.unsubscribe(headers.id, hdrs);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public unsubscribe(id: string, headers: StompHeaders = {}): void {
|
||||
headers = (Object as any).assign({}, headers);
|
||||
|
||||
delete this._subscriptions[id];
|
||||
headers.id = id;
|
||||
this._transmit({ command: 'UNSUBSCRIBE', headers });
|
||||
}
|
||||
|
||||
public begin(transactionId: string): ITransaction {
|
||||
const txId = transactionId || `tx-${this._counter++}`;
|
||||
this._transmit({
|
||||
command: 'BEGIN',
|
||||
headers: {
|
||||
transaction: txId,
|
||||
},
|
||||
});
|
||||
const client = this;
|
||||
return {
|
||||
id: txId,
|
||||
commit(): void {
|
||||
client.commit(txId);
|
||||
},
|
||||
abort(): void {
|
||||
client.abort(txId);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public commit(transactionId: string): void {
|
||||
this._transmit({
|
||||
command: 'COMMIT',
|
||||
headers: {
|
||||
transaction: transactionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public abort(transactionId: string): void {
|
||||
this._transmit({
|
||||
command: 'ABORT',
|
||||
headers: {
|
||||
transaction: transactionId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public ack(
|
||||
messageId: string,
|
||||
subscriptionId: string,
|
||||
headers: StompHeaders = {}
|
||||
): void {
|
||||
headers = (Object as any).assign({}, headers);
|
||||
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
headers.id = messageId;
|
||||
} else {
|
||||
headers['message-id'] = messageId;
|
||||
}
|
||||
headers.subscription = subscriptionId;
|
||||
this._transmit({ command: 'ACK', headers });
|
||||
}
|
||||
|
||||
public nack(
|
||||
messageId: string,
|
||||
subscriptionId: string,
|
||||
headers: StompHeaders = {}
|
||||
): void {
|
||||
headers = (Object as any).assign({}, headers);
|
||||
|
||||
if (this._connectedVersion === Versions.V1_2) {
|
||||
headers.id = messageId;
|
||||
} else {
|
||||
headers['message-id'] = messageId;
|
||||
}
|
||||
headers.subscription = subscriptionId;
|
||||
return this._transmit({ command: 'NACK', headers });
|
||||
}
|
||||
}
|
||||
12
node_modules/@stomp/stompjs/src/stomp-headers.ts
generated
vendored
Normal file
12
node_modules/@stomp/stompjs/src/stomp-headers.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* STOMP headers. Many functions calls will accept headers as parameters.
|
||||
* The headers sent by Broker will be available as [IFrame#headers]{@link IFrame#headers}.
|
||||
*
|
||||
* `key` and `value` must be valid strings.
|
||||
* In addition, `key` must not contain `CR`, `LF`, or `:`.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompHeaders {
|
||||
[key: string]: string;
|
||||
}
|
||||
18
node_modules/@stomp/stompjs/src/stomp-subscription.ts
generated
vendored
Normal file
18
node_modules/@stomp/stompjs/src/stomp-subscription.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
|
||||
/**
|
||||
* Call [Client#subscribe]{@link Client#subscribe} to create a StompSubscription.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class StompSubscription {
|
||||
/**
|
||||
* Id associated with this subscription.
|
||||
*/
|
||||
public id: string;
|
||||
|
||||
/**
|
||||
* Unsubscribe. See [Client#unsubscribe]{@link Client#unsubscribe} for an example.
|
||||
*/
|
||||
public unsubscribe: (headers?: StompHeaders) => void;
|
||||
}
|
||||
156
node_modules/@stomp/stompjs/src/types.ts
generated
vendored
Normal file
156
node_modules/@stomp/stompjs/src/types.ts
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
import { IFrame } from './i-frame';
|
||||
import { IMessage } from './i-message';
|
||||
import { StompHeaders } from './stomp-headers';
|
||||
|
||||
/**
|
||||
* This callback will receive a `string` as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type debugFnType = (msg: string) => void;
|
||||
|
||||
/**
|
||||
* This callback will receive a {@link IMessage} as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type messageCallbackType = (message: IMessage) => void;
|
||||
|
||||
/**
|
||||
* This callback will receive a {@link IFrame} as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type frameCallbackType = (receipt: IFrame) => void;
|
||||
|
||||
/**
|
||||
* This callback will receive a [CloseEvent]{@link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent}
|
||||
* as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type closeEventCallbackType<T = any> = (evt: T) => void;
|
||||
|
||||
/**
|
||||
* This callback will receive an [Event]{@link https://developer.mozilla.org/en-US/docs/Web/API/Event}
|
||||
* as parameter.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export type wsErrorCallbackType<T = any> = (evt: T) => void;
|
||||
|
||||
/**
|
||||
* Parameters for [Client#publish]{@link Client#publish}.
|
||||
* Aliased as publishParams as well.
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export interface IPublishParams {
|
||||
/**
|
||||
* destination end point
|
||||
*/
|
||||
destination: string;
|
||||
/**
|
||||
* headers (optional)
|
||||
*/
|
||||
headers?: StompHeaders;
|
||||
/**
|
||||
* body (optional)
|
||||
*/
|
||||
body?: string;
|
||||
/**
|
||||
* binary body (optional)
|
||||
*/
|
||||
binaryBody?: Uint8Array;
|
||||
/**
|
||||
* By default a `content-length` header will be added in the Frame to the broker.
|
||||
* Set it to `true` for the header to be skipped.
|
||||
*/
|
||||
skipContentLengthHeader?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backward compatibility, switch to {@link IPublishParams}.
|
||||
*/
|
||||
export type publishParams = IPublishParams;
|
||||
|
||||
/**
|
||||
* Used in {@link IRawFrameType}
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export type RawHeaderType = [string, string];
|
||||
|
||||
/**
|
||||
* The parser yield frames in this structure
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface IRawFrameType {
|
||||
command: string;
|
||||
headers: RawHeaderType[];
|
||||
binaryBody: Uint8Array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface IStompSocketMessageEvent {
|
||||
data?: string | ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from Websocket interface to avoid dom typelib dependency.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface IStompSocket {
|
||||
onclose: ((this: IStompSocket, ev?: any) => any) | null;
|
||||
onerror: ((this: IStompSocket, ev: any) => any) | null;
|
||||
onmessage: ((this: IStompSocket, ev: IStompSocketMessageEvent) => any) | null;
|
||||
onopen: ((this: IStompSocket, ev?: any) => any) | null;
|
||||
terminate?: ((this: IStompSocket) => any) | null;
|
||||
|
||||
/**
|
||||
* Returns a string that indicates how binary data from the socket is exposed to scripts:
|
||||
* We support only 'arraybuffer'.
|
||||
*/
|
||||
binaryType: 'arraybuffer';
|
||||
|
||||
/**
|
||||
* Returns the state of the socket connection. It can have the values of StompSocketState.
|
||||
*/
|
||||
readonly readyState: number;
|
||||
|
||||
/**
|
||||
* Closes the connection.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Transmits data using the connection. data can be a string or an ArrayBuffer.
|
||||
*/
|
||||
send(data: string | ArrayBuffer): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible states for the IStompSocket
|
||||
*/
|
||||
export enum StompSocketState {
|
||||
CONNECTING,
|
||||
OPEN,
|
||||
CLOSING,
|
||||
CLOSED,
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible activation state
|
||||
*/
|
||||
export enum ActivationState {
|
||||
ACTIVE,
|
||||
DEACTIVATING,
|
||||
INACTIVE,
|
||||
}
|
||||
50
node_modules/@stomp/stompjs/src/versions.ts
generated
vendored
Normal file
50
node_modules/@stomp/stompjs/src/versions.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Supported STOMP versions
|
||||
*
|
||||
* Part of `@stomp/stompjs`.
|
||||
*/
|
||||
export class Versions {
|
||||
/**
|
||||
* Indicates protocol version 1.0
|
||||
*/
|
||||
public static V1_0 = '1.0';
|
||||
/**
|
||||
* Indicates protocol version 1.1
|
||||
*/
|
||||
public static V1_1 = '1.1';
|
||||
/**
|
||||
* Indicates protocol version 1.2
|
||||
*/
|
||||
public static V1_2 = '1.2';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static default = new Versions([
|
||||
Versions.V1_0,
|
||||
Versions.V1_1,
|
||||
Versions.V1_2,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Takes an array of string of versions, typical elements '1.0', '1.1', or '1.2'
|
||||
*
|
||||
* You will an instance if this class if you want to override supported versions to be declared during
|
||||
* STOMP handshake.
|
||||
*/
|
||||
constructor(public versions: string[]) {}
|
||||
|
||||
/**
|
||||
* Used as part of CONNECT STOMP Frame
|
||||
*/
|
||||
public supportedVersions() {
|
||||
return this.versions.join(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* Used while creating a WebSocket
|
||||
*/
|
||||
public protocolVersions() {
|
||||
return this.versions.map(x => `v${x.replace('.', '')}.stomp`);
|
||||
}
|
||||
}
|
||||
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
21
node_modules/@types/node/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
||||
15
node_modules/@types/node/README.md
generated
vendored
Normal file
15
node_modules/@types/node/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# Installation
|
||||
> `npm install --save @types/node`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for node (https://nodejs.org/).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Thu, 19 Feb 2026 00:56:10 GMT
|
||||
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [David Junger](https://github.com/touffy), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Sebastian Silbermann](https://github.com/eps1lon), [Wilco Bakker](https://github.com/WilcoBakker), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), [Dmitry Semigradsky](https://github.com/Semigradsky), [René](https://github.com/Renegade334), and [Yagiz Nizipli](https://github.com/anonrig).
|
||||
955
node_modules/@types/node/assert.d.ts
generated
vendored
Normal file
955
node_modules/@types/node/assert.d.ts
generated
vendored
Normal file
@@ -0,0 +1,955 @@
|
||||
/**
|
||||
* The `node:assert` module provides a set of assertion functions for verifying
|
||||
* invariants.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/assert.js)
|
||||
*/
|
||||
declare module "node:assert" {
|
||||
import strict = require("node:assert/strict");
|
||||
/**
|
||||
* An alias of {@link assert.ok}.
|
||||
* @since v0.5.9
|
||||
* @param value The input that is checked for being truthy.
|
||||
*/
|
||||
function assert(value: unknown, message?: string | Error): asserts value;
|
||||
const kOptions: unique symbol;
|
||||
namespace assert {
|
||||
type AssertMethodNames =
|
||||
| "deepEqual"
|
||||
| "deepStrictEqual"
|
||||
| "doesNotMatch"
|
||||
| "doesNotReject"
|
||||
| "doesNotThrow"
|
||||
| "equal"
|
||||
| "fail"
|
||||
| "ifError"
|
||||
| "match"
|
||||
| "notDeepEqual"
|
||||
| "notDeepStrictEqual"
|
||||
| "notEqual"
|
||||
| "notStrictEqual"
|
||||
| "ok"
|
||||
| "partialDeepStrictEqual"
|
||||
| "rejects"
|
||||
| "strictEqual"
|
||||
| "throws";
|
||||
interface AssertOptions {
|
||||
/**
|
||||
* If set to `'full'`, shows the full diff in assertion errors.
|
||||
* @default 'simple'
|
||||
*/
|
||||
diff?: "simple" | "full" | undefined;
|
||||
/**
|
||||
* If set to `true`, non-strict methods behave like their
|
||||
* corresponding strict methods.
|
||||
* @default true
|
||||
*/
|
||||
strict?: boolean | undefined;
|
||||
/**
|
||||
* If set to `true`, skips prototype and constructor
|
||||
* comparison in deep equality checks.
|
||||
* @since v24.9.0
|
||||
* @default false
|
||||
*/
|
||||
skipPrototype?: boolean | undefined;
|
||||
}
|
||||
interface Assert extends Pick<typeof assert, AssertMethodNames> {
|
||||
readonly [kOptions]: AssertOptions & { strict: false };
|
||||
}
|
||||
interface AssertStrict extends Pick<typeof strict, AssertMethodNames> {
|
||||
readonly [kOptions]: AssertOptions & { strict: true };
|
||||
}
|
||||
/**
|
||||
* The `Assert` class allows creating independent assertion instances with custom options.
|
||||
* @since v24.6.0
|
||||
*/
|
||||
var Assert: {
|
||||
/**
|
||||
* Creates a new assertion instance. The `diff` option controls the verbosity of diffs in assertion error messages.
|
||||
*
|
||||
* ```js
|
||||
* const { Assert } = require('node:assert');
|
||||
* const assertInstance = new Assert({ diff: 'full' });
|
||||
* assertInstance.deepStrictEqual({ a: 1 }, { a: 2 });
|
||||
* // Shows a full diff in the error message.
|
||||
* ```
|
||||
*
|
||||
* **Important**: When destructuring assertion methods from an `Assert` instance,
|
||||
* the methods lose their connection to the instance's configuration options (such
|
||||
* as `diff`, `strict`, and `skipPrototype` settings).
|
||||
* The destructured methods will fall back to default behavior instead.
|
||||
*
|
||||
* ```js
|
||||
* const myAssert = new Assert({ diff: 'full' });
|
||||
*
|
||||
* // This works as expected - uses 'full' diff
|
||||
* myAssert.strictEqual({ a: 1 }, { b: { c: 1 } });
|
||||
*
|
||||
* // This loses the 'full' diff setting - falls back to default 'simple' diff
|
||||
* const { strictEqual } = myAssert;
|
||||
* strictEqual({ a: 1 }, { b: { c: 1 } });
|
||||
* ```
|
||||
*
|
||||
* The `skipPrototype` option affects all deep equality methods:
|
||||
*
|
||||
* ```js
|
||||
* class Foo {
|
||||
* constructor(a) {
|
||||
* this.a = a;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* class Bar {
|
||||
* constructor(a) {
|
||||
* this.a = a;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const foo = new Foo(1);
|
||||
* const bar = new Bar(1);
|
||||
*
|
||||
* // Default behavior - fails due to different constructors
|
||||
* const assert1 = new Assert();
|
||||
* assert1.deepStrictEqual(foo, bar); // AssertionError
|
||||
*
|
||||
* // Skip prototype comparison - passes if properties are equal
|
||||
* const assert2 = new Assert({ skipPrototype: true });
|
||||
* assert2.deepStrictEqual(foo, bar); // OK
|
||||
* ```
|
||||
*
|
||||
* When destructured, methods lose access to the instance's `this` context and revert to default assertion behavior
|
||||
* (diff: 'simple', non-strict mode).
|
||||
* To maintain custom options when using destructured methods, avoid
|
||||
* destructuring and call methods directly on the instance.
|
||||
* @since v24.6.0
|
||||
*/
|
||||
new(
|
||||
options?: AssertOptions & { strict?: true | undefined },
|
||||
): AssertStrict;
|
||||
new(
|
||||
options: AssertOptions,
|
||||
): Assert;
|
||||
};
|
||||
interface AssertionErrorOptions {
|
||||
/**
|
||||
* If provided, the error message is set to this value.
|
||||
*/
|
||||
message?: string | undefined;
|
||||
/**
|
||||
* The `actual` property on the error instance.
|
||||
*/
|
||||
actual?: unknown;
|
||||
/**
|
||||
* The `expected` property on the error instance.
|
||||
*/
|
||||
expected?: unknown;
|
||||
/**
|
||||
* The `operator` property on the error instance.
|
||||
*/
|
||||
operator?: string | undefined;
|
||||
/**
|
||||
* If provided, the generated stack trace omits frames before this function.
|
||||
*/
|
||||
stackStartFn?: Function | undefined;
|
||||
/**
|
||||
* If set to `'full'`, shows the full diff in assertion errors.
|
||||
* @default 'simple'
|
||||
*/
|
||||
diff?: "simple" | "full" | undefined;
|
||||
}
|
||||
/**
|
||||
* Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
|
||||
*/
|
||||
class AssertionError extends Error {
|
||||
constructor(options: AssertionErrorOptions);
|
||||
/**
|
||||
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
||||
*/
|
||||
actual: unknown;
|
||||
/**
|
||||
* Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
|
||||
*/
|
||||
expected: unknown;
|
||||
/**
|
||||
* Indicates if the message was auto-generated (`true`) or not.
|
||||
*/
|
||||
generatedMessage: boolean;
|
||||
/**
|
||||
* Value is always `ERR_ASSERTION` to show that the error is an assertion error.
|
||||
*/
|
||||
code: "ERR_ASSERTION";
|
||||
/**
|
||||
* Set to the passed in operator value.
|
||||
*/
|
||||
operator: string;
|
||||
}
|
||||
type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error;
|
||||
/**
|
||||
* Throws an `AssertionError` with the provided error message or a default
|
||||
* error message. If the `message` parameter is an instance of an `Error` then
|
||||
* it will be thrown instead of the `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.fail();
|
||||
* // AssertionError [ERR_ASSERTION]: Failed
|
||||
*
|
||||
* assert.fail('boom');
|
||||
* // AssertionError [ERR_ASSERTION]: boom
|
||||
*
|
||||
* assert.fail(new TypeError('need array'));
|
||||
* // TypeError: need array
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
* @param [message='Failed']
|
||||
*/
|
||||
function fail(message?: string | Error): never;
|
||||
/**
|
||||
* Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`.
|
||||
*
|
||||
* If `value` is not truthy, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is `undefined`, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
||||
*
|
||||
* Be aware that in the `repl` the error message will be different to the one
|
||||
* thrown in a file! See below for further details.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ok(true);
|
||||
* // OK
|
||||
* assert.ok(1);
|
||||
* // OK
|
||||
*
|
||||
* assert.ok();
|
||||
* // AssertionError: No value argument passed to `assert.ok()`
|
||||
*
|
||||
* assert.ok(false, 'it\'s false');
|
||||
* // AssertionError: it's false
|
||||
*
|
||||
* // In the repl:
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: false == true
|
||||
*
|
||||
* // In a file (e.g. test.js):
|
||||
* assert.ok(typeof 123 === 'string');
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(typeof 123 === 'string')
|
||||
*
|
||||
* assert.ok(false);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(false)
|
||||
*
|
||||
* assert.ok(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert.ok(0)
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* // Using `assert()` works the same:
|
||||
* assert(0);
|
||||
* // AssertionError: The expression evaluated to a falsy value:
|
||||
* //
|
||||
* // assert(0)
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function ok(value: unknown, message?: string | Error): asserts value;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link strictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
||||
* and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.equal(1, 1);
|
||||
* // OK, 1 == 1
|
||||
* assert.equal(1, '1');
|
||||
* // OK, 1 == '1'
|
||||
* assert.equal(NaN, NaN);
|
||||
* // OK
|
||||
*
|
||||
* assert.equal(1, 2);
|
||||
* // AssertionError: 1 == 2
|
||||
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
||||
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
||||
* ```
|
||||
*
|
||||
* If the values are not equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
||||
*
|
||||
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
||||
* specially handled and treated as being identical if both sides are `NaN`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* assert.notEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notEqual(1, 1);
|
||||
* // AssertionError: 1 != 1
|
||||
*
|
||||
* assert.notEqual(1, '1');
|
||||
* // AssertionError: 1 != '1'
|
||||
* ```
|
||||
*
|
||||
* If the values are equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error
|
||||
* message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link deepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
||||
*
|
||||
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
||||
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
||||
* surprising results.
|
||||
*
|
||||
* _Deep equality_ means that the enumerable "own" properties of child objects
|
||||
* are also recursively evaluated by the following rules.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* **Strict assertion mode**
|
||||
*
|
||||
* An alias of {@link notDeepStrictEqual}.
|
||||
*
|
||||
* **Legacy assertion mode**
|
||||
*
|
||||
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
||||
*
|
||||
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert';
|
||||
*
|
||||
* const obj1 = {
|
||||
* a: {
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj2 = {
|
||||
* a: {
|
||||
* b: 2,
|
||||
* },
|
||||
* };
|
||||
* const obj3 = {
|
||||
* a: {
|
||||
* b: 1,
|
||||
* },
|
||||
* };
|
||||
* const obj4 = { __proto__: obj1 };
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj1);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj3);
|
||||
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||
*
|
||||
* assert.notDeepEqual(obj1, obj4);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
|
||||
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests strict equality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.strictEqual(1, 2);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* //
|
||||
* // 1 !== 2
|
||||
*
|
||||
* assert.strictEqual(1, 1);
|
||||
* // OK
|
||||
*
|
||||
* assert.strictEqual('Hello foobar', 'Hello World!');
|
||||
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
||||
* // + actual - expected
|
||||
* //
|
||||
* // + 'Hello foobar'
|
||||
* // - 'Hello World!'
|
||||
* // ^
|
||||
*
|
||||
* const apples = 1;
|
||||
* const oranges = 2;
|
||||
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
||||
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
||||
*
|
||||
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
||||
* // TypeError: Inputs are not identical
|
||||
* ```
|
||||
*
|
||||
* If the values are not strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
|
||||
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests strict inequality between the `actual` and `expected` parameters as
|
||||
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notStrictEqual(1, 2);
|
||||
* // OK
|
||||
*
|
||||
* assert.notStrictEqual(1, 1);
|
||||
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
||||
* //
|
||||
* // 1
|
||||
*
|
||||
* assert.notStrictEqual(1, '1');
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
|
||||
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Tests for deep equality between the `actual` and `expected` parameters.
|
||||
* "Deep" equality means that the enumerable "own" properties of child objects
|
||||
* are recursively evaluated also by the following rules.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
||||
/**
|
||||
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
||||
* with a `message` property set equal to the value of the `message` parameter. If
|
||||
* the `message` parameter is undefined, a default error message is assigned. If
|
||||
* the `message` parameter is an instance of an `Error` then it will be thrown
|
||||
* instead of the `AssertionError`.
|
||||
* @since v1.2.0
|
||||
*/
|
||||
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the function `fn` to throw an error.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* a validation object where each property will be tested for strict deep equality,
|
||||
* or an instance of error where each property will be tested for strict deep
|
||||
* equality including the non-enumerable `message` and `name` properties. When
|
||||
* using an object, it is also possible to use a regular expression, when
|
||||
* validating against a string property. See below for examples.
|
||||
*
|
||||
* If specified, `message` will be appended to the message provided by the `AssertionError` if the `fn` call fails to throw or in case the error validation
|
||||
* fails.
|
||||
*
|
||||
* Custom validation object/error instance:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* const err = new TypeError('Wrong value');
|
||||
* err.code = 404;
|
||||
* err.foo = 'bar';
|
||||
* err.info = {
|
||||
* nested: true,
|
||||
* baz: 'text',
|
||||
* };
|
||||
* err.reg = /abc/i;
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* baz: 'text',
|
||||
* },
|
||||
* // Only properties on the validation object will be tested for.
|
||||
* // Using nested objects requires all properties to be present. Otherwise
|
||||
* // the validation is going to fail.
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* // Using regular expressions to validate error properties:
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw err;
|
||||
* },
|
||||
* {
|
||||
* // The `name` and `message` properties are strings and using regular
|
||||
* // expressions on those will match against the string. If they fail, an
|
||||
* // error is thrown.
|
||||
* name: /^TypeError$/,
|
||||
* message: /Wrong/,
|
||||
* foo: 'bar',
|
||||
* info: {
|
||||
* nested: true,
|
||||
* // It is not possible to use regular expressions for nested properties!
|
||||
* baz: 'text',
|
||||
* },
|
||||
* // The `reg` property contains a regular expression and only if the
|
||||
* // validation object contains an identical regular expression, it is going
|
||||
* // to pass.
|
||||
* reg: /abc/i,
|
||||
* },
|
||||
* );
|
||||
*
|
||||
* // Fails due to the different `message` and `name` properties:
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* const otherErr = new Error('Not found');
|
||||
* // Copy all enumerable properties from `err` to `otherErr`.
|
||||
* for (const [key, value] of Object.entries(err)) {
|
||||
* otherErr[key] = value;
|
||||
* }
|
||||
* throw otherErr;
|
||||
* },
|
||||
* // The error's `message` and `name` properties will also be checked when using
|
||||
* // an error as validation object.
|
||||
* err,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate instanceof using constructor:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* Error,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
||||
*
|
||||
* Using a regular expression runs `.toString` on the error object, and will
|
||||
* therefore also include the error name.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* /^Error: Wrong value$/,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* Custom error validation:
|
||||
*
|
||||
* The function must return `true` to indicate all internal validations passed.
|
||||
* It will otherwise fail with an `AssertionError`.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.throws(
|
||||
* () => {
|
||||
* throw new Error('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert(err instanceof Error);
|
||||
* assert(/value/.test(err));
|
||||
* // Avoid returning anything from validation functions besides `true`.
|
||||
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
||||
* // throw an error about the specific validation that failed (as done in this
|
||||
* // example) and add as much helpful debugging information to that error as
|
||||
* // possible.
|
||||
* return true;
|
||||
* },
|
||||
* 'unexpected error',
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second
|
||||
* argument, then `error` is assumed to be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Using the same
|
||||
* message as the thrown error message is going to result in an `ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
||||
* a string as the second argument gets considered:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* function throwingFirst() {
|
||||
* throw new Error('First');
|
||||
* }
|
||||
*
|
||||
* function throwingSecond() {
|
||||
* throw new Error('Second');
|
||||
* }
|
||||
*
|
||||
* function notThrowing() {}
|
||||
*
|
||||
* // The second argument is a string and the input function threw an Error.
|
||||
* // The first case will not throw as it does not match for the error message
|
||||
* // thrown by the input function!
|
||||
* assert.throws(throwingFirst, 'Second');
|
||||
* // In the next example the message has no benefit over the message from the
|
||||
* // error and since it is not clear if the user intended to actually match
|
||||
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
||||
* assert.throws(throwingSecond, 'Second');
|
||||
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
||||
*
|
||||
* // The string is only used (as message) in case the function does not throw:
|
||||
* assert.throws(notThrowing, 'Second');
|
||||
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
||||
*
|
||||
* // If it was intended to match for the error message do this instead:
|
||||
* // It does not throw because the error messages match.
|
||||
* assert.throws(throwingSecond, /Second$/);
|
||||
*
|
||||
* // If the error message does not match, an AssertionError is thrown.
|
||||
* assert.throws(throwingFirst, /Second$/);
|
||||
* // AssertionError [ERR_ASSERTION]
|
||||
* ```
|
||||
*
|
||||
* Due to the confusing error-prone notation, avoid a string as the second
|
||||
* argument.
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function throws(block: () => unknown, message?: string | Error): void;
|
||||
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Asserts that the function `fn` does not throw an error.
|
||||
*
|
||||
* Using `assert.doesNotThrow()` is actually not useful because there
|
||||
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
||||
* adding a comment next to the specific code path that should not throw and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* When `assert.doesNotThrow()` is called, it will immediately call the `fn` function.
|
||||
*
|
||||
* If an error is thrown and it is the same type as that specified by the `error` parameter, then an `AssertionError` is thrown. If the error is of a
|
||||
* different type, or if the `error` parameter is undefined, the error is
|
||||
* propagated back to the caller.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* The following, for instance, will throw the `TypeError` because there is no
|
||||
* matching error type in the assertion:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* However, the following will result in an `AssertionError` with the message
|
||||
* 'Got unwanted exception...':
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* TypeError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* If an `AssertionError` is thrown and a value is provided for the `message` parameter, the value of `message` will be appended to the `AssertionError` message:
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotThrow(
|
||||
* () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* /Wrong value/,
|
||||
* 'Whoops',
|
||||
* );
|
||||
* // Throws: AssertionError: Got unwanted exception: Whoops
|
||||
* ```
|
||||
* @since v0.1.21
|
||||
*/
|
||||
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
||||
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
||||
/**
|
||||
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
||||
* testing the `error` argument in callbacks. The stack trace contains all frames
|
||||
* from the error passed to `ifError()` including the potential new frames for `ifError()` itself.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.ifError(null);
|
||||
* // OK
|
||||
* assert.ifError(0);
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
||||
* assert.ifError('error');
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
||||
* assert.ifError(new Error());
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
||||
*
|
||||
* // Create some random error frames.
|
||||
* let err;
|
||||
* (function errorFrame() {
|
||||
* err = new Error('test error');
|
||||
* })();
|
||||
*
|
||||
* (function ifErrorFrame() {
|
||||
* assert.ifError(err);
|
||||
* })();
|
||||
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
||||
* // at ifErrorFrame
|
||||
* // at errorFrame
|
||||
* ```
|
||||
* @since v0.1.97
|
||||
*/
|
||||
function ifError(value: unknown): asserts value is null | undefined;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously, `assert.rejects()` will return a rejected `Promise` with that error. If the
|
||||
* function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value)
|
||||
* error. In both cases the error handler is skipped.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
||||
* an object where each property will be tested for, or an instance of error where
|
||||
* each property will be tested for including the non-enumerable `message` and `name` properties.
|
||||
*
|
||||
* If specified, `message` will be the message provided by the `{@link AssertionError}` if the `asyncFn` fails to reject.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* {
|
||||
* name: 'TypeError',
|
||||
* message: 'Wrong value',
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.rejects(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* (err) => {
|
||||
* assert.strictEqual(err.name, 'TypeError');
|
||||
* assert.strictEqual(err.message, 'Wrong value');
|
||||
* return true;
|
||||
* },
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.rejects(
|
||||
* Promise.reject(new Error('Wrong value')),
|
||||
* Error,
|
||||
* ).then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* `error` cannot be a string. If a string is provided as the second argument, then `error` is assumed to
|
||||
* be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Please read the
|
||||
* example in {@link throws} carefully if using a string as the second argument gets considered.
|
||||
* @since v10.0.0
|
||||
*/
|
||||
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
||||
function rejects(
|
||||
block: (() => Promise<unknown>) | Promise<unknown>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
||||
* calls the function and awaits the returned promise to complete. It will then
|
||||
* check that the promise is not rejected.
|
||||
*
|
||||
* If `asyncFn` is a function and it throws an error synchronously, `assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
||||
* the function does not return a promise, `assert.doesNotReject()` will return a
|
||||
* rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value) error. In both cases
|
||||
* the error handler is skipped.
|
||||
*
|
||||
* Using `assert.doesNotReject()` is actually not useful because there is little
|
||||
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
||||
* adding a comment next to the specific code path that should not reject and keep
|
||||
* error messages as expressive as possible.
|
||||
*
|
||||
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
||||
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
||||
* function. See {@link throws} for more details.
|
||||
*
|
||||
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* await assert.doesNotReject(
|
||||
* async () => {
|
||||
* throw new TypeError('Wrong value');
|
||||
* },
|
||||
* SyntaxError,
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
||||
* .then(() => {
|
||||
* // ...
|
||||
* });
|
||||
* ```
|
||||
* @since v10.0.0
|
||||
*/
|
||||
function doesNotReject(
|
||||
block: (() => Promise<unknown>) | Promise<unknown>,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
function doesNotReject(
|
||||
block: (() => Promise<unknown>) | Promise<unknown>,
|
||||
error: AssertPredicate,
|
||||
message?: string | Error,
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Expects the `string` input to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.match('I will fail', /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
||||
*
|
||||
* assert.match(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.match('I will pass', /pass/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do not match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
/**
|
||||
* Expects the `string` input not to match the regular expression.
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
*
|
||||
* assert.doesNotMatch('I will fail', /fail/);
|
||||
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
||||
*
|
||||
* assert.doesNotMatch(123, /pass/);
|
||||
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
||||
*
|
||||
* assert.doesNotMatch('I will pass', /different/);
|
||||
* // OK
|
||||
* ```
|
||||
*
|
||||
* If the values do match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
|
||||
* to the value of the `message` parameter. If the `message` parameter is
|
||||
* undefined, a default error message is assigned. If the `message` parameter is an
|
||||
* instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
|
||||
* @since v13.6.0, v12.16.0
|
||||
*/
|
||||
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
||||
/**
|
||||
* Tests for partial deep equality between the `actual` and `expected` parameters.
|
||||
* "Deep" equality means that the enumerable "own" properties of child objects
|
||||
* are recursively evaluated also by the following rules. "Partial" equality means
|
||||
* that only properties that exist on the `expected` parameter are going to be
|
||||
* compared.
|
||||
*
|
||||
* This method always passes the same test cases as `assert.deepStrictEqual()`,
|
||||
* behaving as a super set of it.
|
||||
* @since v22.13.0
|
||||
*/
|
||||
function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
||||
}
|
||||
namespace assert {
|
||||
export { strict };
|
||||
}
|
||||
export = assert;
|
||||
}
|
||||
declare module "assert" {
|
||||
import assert = require("node:assert");
|
||||
export = assert;
|
||||
}
|
||||
105
node_modules/@types/node/assert/strict.d.ts
generated
vendored
Normal file
105
node_modules/@types/node/assert/strict.d.ts
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* In strict assertion mode, non-strict methods behave like their corresponding
|
||||
* strict methods. For example, `assert.deepEqual()` will behave like
|
||||
* `assert.deepStrictEqual()`.
|
||||
*
|
||||
* In strict assertion mode, error messages for objects display a diff. In legacy
|
||||
* assertion mode, error messages for objects display the objects, often truncated.
|
||||
*
|
||||
* To use strict assertion mode:
|
||||
*
|
||||
* ```js
|
||||
* import { strict as assert } from 'node:assert';
|
||||
* ```
|
||||
*
|
||||
* ```js
|
||||
* import assert from 'node:assert/strict';
|
||||
* ```
|
||||
*
|
||||
* Example error diff:
|
||||
*
|
||||
* ```js
|
||||
* import { strict as assert } from 'node:assert';
|
||||
*
|
||||
* assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
|
||||
* // AssertionError: Expected inputs to be strictly deep-equal:
|
||||
* // + actual - expected ... Lines skipped
|
||||
* //
|
||||
* // [
|
||||
* // [
|
||||
* // ...
|
||||
* // 2,
|
||||
* // + 3
|
||||
* // - '3'
|
||||
* // ],
|
||||
* // ...
|
||||
* // 5
|
||||
* // ]
|
||||
* ```
|
||||
*
|
||||
* To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS`
|
||||
* environment variables. This will also deactivate the colors in the REPL. For
|
||||
* more on color support in terminal environments, read the tty
|
||||
* [`getColorDepth()`](https://nodejs.org/docs/latest-v25.x/api/tty.html#writestreamgetcolordepthenv) documentation.
|
||||
* @since v15.0.0
|
||||
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/assert/strict.js)
|
||||
*/
|
||||
declare module "node:assert/strict" {
|
||||
import {
|
||||
Assert,
|
||||
AssertionError,
|
||||
AssertionErrorOptions,
|
||||
AssertOptions,
|
||||
AssertPredicate,
|
||||
AssertStrict,
|
||||
deepStrictEqual,
|
||||
doesNotMatch,
|
||||
doesNotReject,
|
||||
doesNotThrow,
|
||||
fail,
|
||||
ifError,
|
||||
match,
|
||||
notDeepStrictEqual,
|
||||
notStrictEqual,
|
||||
ok,
|
||||
partialDeepStrictEqual,
|
||||
rejects,
|
||||
strictEqual,
|
||||
throws,
|
||||
} from "node:assert";
|
||||
function strict(value: unknown, message?: string | Error): asserts value;
|
||||
namespace strict {
|
||||
export {
|
||||
Assert,
|
||||
AssertionError,
|
||||
AssertionErrorOptions,
|
||||
AssertOptions,
|
||||
AssertPredicate,
|
||||
AssertStrict,
|
||||
deepStrictEqual,
|
||||
deepStrictEqual as deepEqual,
|
||||
doesNotMatch,
|
||||
doesNotReject,
|
||||
doesNotThrow,
|
||||
fail,
|
||||
ifError,
|
||||
match,
|
||||
notDeepStrictEqual,
|
||||
notDeepStrictEqual as notDeepEqual,
|
||||
notStrictEqual,
|
||||
notStrictEqual as notEqual,
|
||||
ok,
|
||||
partialDeepStrictEqual,
|
||||
rejects,
|
||||
strict,
|
||||
strictEqual,
|
||||
strictEqual as equal,
|
||||
throws,
|
||||
};
|
||||
}
|
||||
export = strict;
|
||||
}
|
||||
declare module "assert/strict" {
|
||||
import strict = require("node:assert/strict");
|
||||
export = strict;
|
||||
}
|
||||
623
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Normal file
623
node_modules/@types/node/async_hooks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,623 @@
|
||||
/**
|
||||
* We strongly discourage the use of the `async_hooks` API.
|
||||
* Other APIs that can cover most of its use cases include:
|
||||
*
|
||||
* * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v25.x/api/async_context.html#class-asynclocalstorage) tracks async context
|
||||
* * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
|
||||
*
|
||||
* The `node:async_hooks` module provides an API to track asynchronous resources.
|
||||
* It can be accessed using:
|
||||
*
|
||||
* ```js
|
||||
* import async_hooks from 'node:async_hooks';
|
||||
* ```
|
||||
* @experimental
|
||||
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/async_hooks.js)
|
||||
*/
|
||||
declare module "node:async_hooks" {
|
||||
/**
|
||||
* ```js
|
||||
* import { executionAsyncId } from 'node:async_hooks';
|
||||
* import fs from 'node:fs';
|
||||
*
|
||||
* console.log(executionAsyncId()); // 1 - bootstrap
|
||||
* const path = '.';
|
||||
* fs.open(path, 'r', (err, fd) => {
|
||||
* console.log(executionAsyncId()); // 6 - open()
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
||||
* causality (which is covered by `triggerAsyncId()`):
|
||||
*
|
||||
* ```js
|
||||
* const server = net.createServer((conn) => {
|
||||
* // Returns the ID of the server, not of the new connection, because the
|
||||
* // callback runs in the execution scope of the server's MakeCallback().
|
||||
* async_hooks.executionAsyncId();
|
||||
*
|
||||
* }).listen(port, () => {
|
||||
* // Returns the ID of a TickObject (process.nextTick()) because all
|
||||
* // callbacks passed to .listen() are wrapped in a nextTick().
|
||||
* async_hooks.executionAsyncId();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get precise `executionAsyncIds` by default.
|
||||
* See the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
|
||||
* @since v8.1.0
|
||||
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
||||
*/
|
||||
function executionAsyncId(): number;
|
||||
/**
|
||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||
* on the object is likely to crash your application and should be avoided.
|
||||
*
|
||||
* Using `executionAsyncResource()` in the top-level execution context will
|
||||
* return an empty object as there is no handle or request object to use,
|
||||
* but having an object representing the top-level can be helpful.
|
||||
*
|
||||
* ```js
|
||||
* import { open } from 'node:fs';
|
||||
* import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
|
||||
*
|
||||
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
||||
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
||||
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This can be used to implement continuation local storage without the
|
||||
* use of a tracking `Map` to store the metadata:
|
||||
*
|
||||
* ```js
|
||||
* import { createServer } from 'node:http';
|
||||
* import {
|
||||
* executionAsyncId,
|
||||
* executionAsyncResource,
|
||||
* createHook,
|
||||
* } from 'node:async_hooks';
|
||||
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||
*
|
||||
* createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) {
|
||||
* const cr = executionAsyncResource();
|
||||
* if (cr) {
|
||||
* resource[sym] = cr[sym];
|
||||
* }
|
||||
* },
|
||||
* }).enable();
|
||||
*
|
||||
* const server = createServer((req, res) => {
|
||||
* executionAsyncResource()[sym] = { state: req.url };
|
||||
* setTimeout(function() {
|
||||
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
||||
* }, 100);
|
||||
* }).listen(3000);
|
||||
* ```
|
||||
* @since v13.9.0, v12.17.0
|
||||
* @return The resource representing the current execution. Useful to store data within the resource.
|
||||
*/
|
||||
function executionAsyncResource(): object;
|
||||
/**
|
||||
* ```js
|
||||
* const server = net.createServer((conn) => {
|
||||
* // The resource that caused (or triggered) this callback to be called
|
||||
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
||||
* // is the asyncId of "conn".
|
||||
* async_hooks.triggerAsyncId();
|
||||
*
|
||||
* }).listen(port, () => {
|
||||
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
||||
* // the callback itself exists because the call to the server's .listen()
|
||||
* // was made. So the return value would be the ID of the server.
|
||||
* async_hooks.triggerAsyncId();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||
* the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
|
||||
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||
*/
|
||||
function triggerAsyncId(): number;
|
||||
interface HookCallbacks {
|
||||
/**
|
||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||
* @param asyncId A unique ID for the async resource
|
||||
* @param type The type of the async resource
|
||||
* @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
|
||||
* @param resource Reference to the resource representing the async operation, needs to be released during destroy
|
||||
*/
|
||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||
/**
|
||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||
* The before callback is called just before said callback is executed.
|
||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||
*/
|
||||
before?(asyncId: number): void;
|
||||
/**
|
||||
* Called immediately after the callback specified in `before` is completed.
|
||||
*
|
||||
* If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
|
||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||
*/
|
||||
after?(asyncId: number): void;
|
||||
/**
|
||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||
* as the promise itself.
|
||||
* @param asyncId the unique id for the promise that was resolve()d.
|
||||
*/
|
||||
promiseResolve?(asyncId: number): void;
|
||||
/**
|
||||
* Called after the resource corresponding to asyncId is destroyed
|
||||
* @param asyncId a unique ID for the async resource
|
||||
*/
|
||||
destroy?(asyncId: number): void;
|
||||
}
|
||||
interface AsyncHook {
|
||||
/**
|
||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||
*/
|
||||
enable(): this;
|
||||
/**
|
||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||
*/
|
||||
disable(): this;
|
||||
}
|
||||
/**
|
||||
* Registers functions to be called for different lifetime events of each async
|
||||
* operation.
|
||||
*
|
||||
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
||||
* respective asynchronous event during a resource's lifetime.
|
||||
*
|
||||
* All callbacks are optional. For example, if only resource cleanup needs to
|
||||
* be tracked, then only the `destroy` callback needs to be passed. The
|
||||
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
||||
*
|
||||
* ```js
|
||||
* import { createHook } from 'node:async_hooks';
|
||||
*
|
||||
* const asyncHook = createHook({
|
||||
* init(asyncId, type, triggerAsyncId, resource) { },
|
||||
* destroy(asyncId) { },
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* The callbacks will be inherited via the prototype chain:
|
||||
*
|
||||
* ```js
|
||||
* class MyAsyncCallbacks {
|
||||
* init(asyncId, type, triggerAsyncId, resource) { }
|
||||
* destroy(asyncId) {}
|
||||
* }
|
||||
*
|
||||
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
||||
* before(asyncId) { }
|
||||
* after(asyncId) { }
|
||||
* }
|
||||
*
|
||||
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
||||
* ```
|
||||
*
|
||||
* Because promises are asynchronous resources whose lifecycle is tracked
|
||||
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
||||
* @since v8.1.0
|
||||
* @param callbacks The `Hook Callbacks` to register
|
||||
* @return Instance used for disabling and enabling hooks
|
||||
*/
|
||||
function createHook(callbacks: HookCallbacks): AsyncHook;
|
||||
interface AsyncResourceOptions {
|
||||
/**
|
||||
* The ID of the execution context that created this async event.
|
||||
* @default executionAsyncId()
|
||||
*/
|
||||
triggerAsyncId?: number | undefined;
|
||||
/**
|
||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||
* This usually does not need to be set (even if `emitDestroy` is called
|
||||
* manually), unless the resource's `asyncId` is retrieved and the
|
||||
* sensitive API's `emitDestroy` is called with it.
|
||||
* @default false
|
||||
*/
|
||||
requireManualDestroy?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* The class `AsyncResource` is designed to be extended by the embedder's async
|
||||
* resources. Using this, users can easily trigger the lifetime events of their
|
||||
* own resources.
|
||||
*
|
||||
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
||||
*
|
||||
* The following is an overview of the `AsyncResource` API.
|
||||
*
|
||||
* ```js
|
||||
* import { AsyncResource, executionAsyncId } from 'node:async_hooks';
|
||||
*
|
||||
* // AsyncResource() is meant to be extended. Instantiating a
|
||||
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||
* // async_hook.executionAsyncId() is used.
|
||||
* const asyncResource = new AsyncResource(
|
||||
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
|
||||
* );
|
||||
*
|
||||
* // Run a function in the execution context of the resource. This will
|
||||
* // * establish the context of the resource
|
||||
* // * trigger the AsyncHooks before callbacks
|
||||
* // * call the provided function `fn` with the supplied arguments
|
||||
* // * trigger the AsyncHooks after callbacks
|
||||
* // * restore the original execution context
|
||||
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
||||
*
|
||||
* // Call AsyncHooks destroy callbacks.
|
||||
* asyncResource.emitDestroy();
|
||||
*
|
||||
* // Return the unique ID assigned to the AsyncResource instance.
|
||||
* asyncResource.asyncId();
|
||||
*
|
||||
* // Return the trigger ID for the AsyncResource instance.
|
||||
* asyncResource.triggerAsyncId();
|
||||
* ```
|
||||
*/
|
||||
class AsyncResource {
|
||||
/**
|
||||
* AsyncResource() is meant to be extended. Instantiating a
|
||||
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||
* async_hook.executionAsyncId() is used.
|
||||
* @param type The type of async event.
|
||||
* @param triggerAsyncId The ID of the execution context that created
|
||||
* this async event (default: `executionAsyncId()`), or an
|
||||
* AsyncResourceOptions object (since v9.3.0)
|
||||
*/
|
||||
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||
*/
|
||||
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||
fn: Func,
|
||||
type?: string,
|
||||
thisArg?: ThisArg,
|
||||
): Func;
|
||||
/**
|
||||
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||
* @since v14.8.0, v12.19.0
|
||||
* @param fn The function to bind to the current `AsyncResource`.
|
||||
*/
|
||||
bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
||||
/**
|
||||
* Call the provided function with the provided arguments in the execution context
|
||||
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||
* then restore the original execution context.
|
||||
* @since v9.6.0
|
||||
* @param fn The function to call in the execution context of this async resource.
|
||||
* @param thisArg The receiver to be used for the function call.
|
||||
* @param args Optional arguments to pass to the function.
|
||||
*/
|
||||
runInAsyncScope<This, Result>(
|
||||
fn: (this: This, ...args: any[]) => Result,
|
||||
thisArg?: This,
|
||||
...args: any[]
|
||||
): Result;
|
||||
/**
|
||||
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||
* be thrown if it is called more than once. This **must** be manually called. If
|
||||
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||
* never be called.
|
||||
* @return A reference to `asyncResource`.
|
||||
*/
|
||||
emitDestroy(): this;
|
||||
/**
|
||||
* @return The unique `asyncId` assigned to the resource.
|
||||
*/
|
||||
asyncId(): number;
|
||||
/**
|
||||
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
||||
*/
|
||||
triggerAsyncId(): number;
|
||||
}
|
||||
interface AsyncLocalStorageOptions {
|
||||
/**
|
||||
* The default value to be used when no store is provided.
|
||||
*/
|
||||
defaultValue?: any;
|
||||
/**
|
||||
* A name for the `AsyncLocalStorage` value.
|
||||
*/
|
||||
name?: string | undefined;
|
||||
}
|
||||
/**
|
||||
* This class creates stores that stay coherent through asynchronous operations.
|
||||
*
|
||||
* While you can create your own implementation on top of the `node:async_hooks` module, `AsyncLocalStorage` should be preferred as it is a performant and memory
|
||||
* safe implementation that involves significant optimizations that are non-obvious
|
||||
* to implement.
|
||||
*
|
||||
* The following example uses `AsyncLocalStorage` to build a simple logger
|
||||
* that assigns IDs to incoming HTTP requests and includes them in messages
|
||||
* logged within each request.
|
||||
*
|
||||
* ```js
|
||||
* import http from 'node:http';
|
||||
* import { AsyncLocalStorage } from 'node:async_hooks';
|
||||
*
|
||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||
*
|
||||
* function logWithId(msg) {
|
||||
* const id = asyncLocalStorage.getStore();
|
||||
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
||||
* }
|
||||
*
|
||||
* let idSeq = 0;
|
||||
* http.createServer((req, res) => {
|
||||
* asyncLocalStorage.run(idSeq++, () => {
|
||||
* logWithId('start');
|
||||
* // Imagine any chain of async operations here
|
||||
* setImmediate(() => {
|
||||
* logWithId('finish');
|
||||
* res.end();
|
||||
* });
|
||||
* });
|
||||
* }).listen(8080);
|
||||
*
|
||||
* http.get('http://localhost:8080');
|
||||
* http.get('http://localhost:8080');
|
||||
* // Prints:
|
||||
* // 0: start
|
||||
* // 0: finish
|
||||
* // 1: start
|
||||
* // 1: finish
|
||||
* ```
|
||||
*
|
||||
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||
* with each other's data.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
class AsyncLocalStorage<T> {
|
||||
/**
|
||||
* Creates a new instance of `AsyncLocalStorage`. Store is only provided within a
|
||||
* `run()` call or after an `enterWith()` call.
|
||||
*/
|
||||
constructor(options?: AsyncLocalStorageOptions);
|
||||
/**
|
||||
* Binds the given function to the current execution context.
|
||||
* @since v19.8.0
|
||||
* @param fn The function to bind to the current execution context.
|
||||
* @return A new function that calls `fn` within the captured execution context.
|
||||
*/
|
||||
static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
||||
/**
|
||||
* Captures the current execution context and returns a function that accepts a
|
||||
* function as an argument. Whenever the returned function is called, it
|
||||
* calls the function passed to it within the captured context.
|
||||
*
|
||||
* ```js
|
||||
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||
* const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
|
||||
* const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
|
||||
* console.log(result); // returns 123
|
||||
* ```
|
||||
*
|
||||
* AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
|
||||
* async context tracking purposes, for example:
|
||||
*
|
||||
* ```js
|
||||
* class Foo {
|
||||
* #runInAsyncScope = AsyncLocalStorage.snapshot();
|
||||
*
|
||||
* get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
|
||||
* }
|
||||
*
|
||||
* const foo = asyncLocalStorage.run(123, () => new Foo());
|
||||
* console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
|
||||
* ```
|
||||
* @since v19.8.0
|
||||
* @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
|
||||
*/
|
||||
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
||||
/**
|
||||
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||
* to `asyncLocalStorage.getStore()` will return `undefined` until `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||
*
|
||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||
* instance will be exited.
|
||||
*
|
||||
* Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||
* along with the corresponding async resources.
|
||||
*
|
||||
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||
* in the current process.
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
disable(): void;
|
||||
/**
|
||||
* Returns the current store.
|
||||
* If called outside of an asynchronous context initialized by
|
||||
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||
* returns `undefined`.
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
getStore(): T | undefined;
|
||||
/**
|
||||
* The name of the `AsyncLocalStorage` instance if provided.
|
||||
* @since v24.0.0
|
||||
*/
|
||||
readonly name: string;
|
||||
/**
|
||||
* Runs a function synchronously within a context and returns its
|
||||
* return value. The store is not accessible outside of the callback function.
|
||||
* The store is accessible to any asynchronous operations created within the
|
||||
* callback.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `run()` too.
|
||||
* The stacktrace is not impacted by this call and the context is exited.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 2 };
|
||||
* try {
|
||||
* asyncLocalStorage.run(store, () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* setTimeout(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* }, 200);
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
*/
|
||||
run<R>(store: T, callback: () => R): R;
|
||||
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Runs a function synchronously outside of a context and returns its
|
||||
* return value. The store is not accessible within the callback function or
|
||||
* the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
|
||||
*
|
||||
* The optional `args` are passed to the callback function.
|
||||
*
|
||||
* If the callback function throws an error, the error is thrown by `exit()` too.
|
||||
* The stacktrace is not impacted by this call and the context is re-entered.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* // Within a call to run
|
||||
* try {
|
||||
* asyncLocalStorage.getStore(); // Returns the store object or value
|
||||
* asyncLocalStorage.exit(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* throw new Error();
|
||||
* });
|
||||
* } catch (e) {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object or value
|
||||
* // The error will be caught here
|
||||
* }
|
||||
* ```
|
||||
* @since v13.10.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||
/**
|
||||
* Transitions into the context for the remainder of the current
|
||||
* synchronous execution and then persists the store through any following
|
||||
* asynchronous calls.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
* // Replaces previous store with the given store object
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* asyncLocalStorage.getStore(); // Returns the store object
|
||||
* someAsyncOperation(() => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This transition will continue for the _entire_ synchronous execution.
|
||||
* This means that if, for example, the context is entered within an event
|
||||
* handler subsequent event handlers will also run within that context unless
|
||||
* specifically bound to another context with an `AsyncResource`. That is why `run()` should be preferred over `enterWith()` unless there are strong reasons
|
||||
* to use the latter method.
|
||||
*
|
||||
* ```js
|
||||
* const store = { id: 1 };
|
||||
*
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.enterWith(store);
|
||||
* });
|
||||
* emitter.on('my-event', () => {
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* });
|
||||
*
|
||||
* asyncLocalStorage.getStore(); // Returns undefined
|
||||
* emitter.emit('my-event');
|
||||
* asyncLocalStorage.getStore(); // Returns the same object
|
||||
* ```
|
||||
* @since v13.11.0, v12.17.0
|
||||
* @experimental
|
||||
*/
|
||||
enterWith(store: T): void;
|
||||
}
|
||||
/**
|
||||
* @since v17.2.0, v16.14.0
|
||||
* @return A map of provider types to the corresponding numeric id.
|
||||
* This map contains all the event types that might be emitted by the `async_hooks.init()` event.
|
||||
*/
|
||||
namespace asyncWrapProviders {
|
||||
const NONE: number;
|
||||
const DIRHANDLE: number;
|
||||
const DNSCHANNEL: number;
|
||||
const ELDHISTOGRAM: number;
|
||||
const FILEHANDLE: number;
|
||||
const FILEHANDLECLOSEREQ: number;
|
||||
const FIXEDSIZEBLOBCOPY: number;
|
||||
const FSEVENTWRAP: number;
|
||||
const FSREQCALLBACK: number;
|
||||
const FSREQPROMISE: number;
|
||||
const GETADDRINFOREQWRAP: number;
|
||||
const GETNAMEINFOREQWRAP: number;
|
||||
const HEAPSNAPSHOT: number;
|
||||
const HTTP2SESSION: number;
|
||||
const HTTP2STREAM: number;
|
||||
const HTTP2PING: number;
|
||||
const HTTP2SETTINGS: number;
|
||||
const HTTPINCOMINGMESSAGE: number;
|
||||
const HTTPCLIENTREQUEST: number;
|
||||
const JSSTREAM: number;
|
||||
const JSUDPWRAP: number;
|
||||
const MESSAGEPORT: number;
|
||||
const PIPECONNECTWRAP: number;
|
||||
const PIPESERVERWRAP: number;
|
||||
const PIPEWRAP: number;
|
||||
const PROCESSWRAP: number;
|
||||
const PROMISE: number;
|
||||
const QUERYWRAP: number;
|
||||
const SHUTDOWNWRAP: number;
|
||||
const SIGNALWRAP: number;
|
||||
const STATWATCHER: number;
|
||||
const STREAMPIPE: number;
|
||||
const TCPCONNECTWRAP: number;
|
||||
const TCPSERVERWRAP: number;
|
||||
const TCPWRAP: number;
|
||||
const TTYWRAP: number;
|
||||
const UDPSENDWRAP: number;
|
||||
const UDPWRAP: number;
|
||||
const SIGINTWATCHDOG: number;
|
||||
const WORKER: number;
|
||||
const WORKERHEAPSNAPSHOT: number;
|
||||
const WRITEWRAP: number;
|
||||
const ZLIB: number;
|
||||
const CHECKPRIMEREQUEST: number;
|
||||
const PBKDF2REQUEST: number;
|
||||
const KEYPAIRGENREQUEST: number;
|
||||
const KEYGENREQUEST: number;
|
||||
const KEYEXPORTREQUEST: number;
|
||||
const CIPHERREQUEST: number;
|
||||
const DERIVEBITSREQUEST: number;
|
||||
const HASHREQUEST: number;
|
||||
const RANDOMBYTESREQUEST: number;
|
||||
const RANDOMPRIMEREQUEST: number;
|
||||
const SCRYPTREQUEST: number;
|
||||
const SIGNREQUEST: number;
|
||||
const TLSWRAP: number;
|
||||
const VERIFYREQUEST: number;
|
||||
}
|
||||
}
|
||||
declare module "async_hooks" {
|
||||
export * from "node:async_hooks";
|
||||
}
|
||||
466
node_modules/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
466
node_modules/@types/node/buffer.buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,466 @@
|
||||
declare module "node:buffer" {
|
||||
type ImplicitArrayBuffer<T extends WithImplicitCoercion<ArrayBufferLike>> = T extends
|
||||
{ valueOf(): infer V extends ArrayBufferLike } ? V : T;
|
||||
global {
|
||||
interface BufferConstructor {
|
||||
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
||||
*/
|
||||
new(str: string, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
||||
*/
|
||||
new(size: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
||||
*/
|
||||
new(array: ArrayLike<number>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
new<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(arrayBuffer: TArrayBuffer): Buffer<TArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
||||
* Array entries outside that range will be truncated to fit into it.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
||||
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
||||
* ```
|
||||
*
|
||||
* If `array` is an `Array`-like object (that is, one with a `length` property of
|
||||
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
||||
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an
|
||||
* `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
|
||||
* `Buffer.copyBytesFrom()`.
|
||||
*
|
||||
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
||||
* appropriate for `Buffer.from()` variants.
|
||||
*
|
||||
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal
|
||||
* `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v5.10.0
|
||||
*/
|
||||
from(array: WithImplicitCoercion<ArrayLike<number>>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* This creates a view of the `ArrayBuffer` without copying the underlying
|
||||
* memory. For example, when passed a reference to the `.buffer` property of a
|
||||
* `TypedArray` instance, the newly created `Buffer` will share the same
|
||||
* allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const arr = new Uint16Array(2);
|
||||
*
|
||||
* arr[0] = 5000;
|
||||
* arr[1] = 4000;
|
||||
*
|
||||
* // Shares memory with `arr`.
|
||||
* const buf = Buffer.from(arr.buffer);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 88 13 a0 0f>
|
||||
*
|
||||
* // Changing the original Uint16Array changes the Buffer also.
|
||||
* arr[1] = 6000;
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 88 13 70 17>
|
||||
* ```
|
||||
*
|
||||
* The optional `byteOffset` and `length` arguments specify a memory range within
|
||||
* the `arrayBuffer` that will be shared by the `Buffer`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const ab = new ArrayBuffer(10);
|
||||
* const buf = Buffer.from(ab, 0, 2);
|
||||
*
|
||||
* console.log(buf.length);
|
||||
* // Prints: 2
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer` or a
|
||||
* `SharedArrayBuffer` or another type appropriate for `Buffer.from()`
|
||||
* variants.
|
||||
*
|
||||
* It is important to remember that a backing `ArrayBuffer` can cover a range
|
||||
* of memory that extends beyond the bounds of a `TypedArray` view. A new
|
||||
* `Buffer` created using the `buffer` property of a `TypedArray` may extend
|
||||
* beyond the range of the `TypedArray`:
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements
|
||||
* const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements
|
||||
* console.log(arrA.buffer === arrB.buffer); // true
|
||||
*
|
||||
* const buf = Buffer.from(arrB.buffer);
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 63 64 65 66>
|
||||
* ```
|
||||
* @since v5.10.0
|
||||
* @param arrayBuffer An `ArrayBuffer`, `SharedArrayBuffer`, for example the
|
||||
* `.buffer` property of a `TypedArray`.
|
||||
* @param byteOffset Index of first byte to expose. **Default:** `0`.
|
||||
* @param length Number of bytes to expose. **Default:**
|
||||
* `arrayBuffer.byteLength - byteOffset`.
|
||||
*/
|
||||
from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(
|
||||
arrayBuffer: TArrayBuffer,
|
||||
byteOffset?: number,
|
||||
length?: number,
|
||||
): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;
|
||||
/**
|
||||
* Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
|
||||
* the character encoding to be used when converting `string` into bytes.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf1 = Buffer.from('this is a tést');
|
||||
* const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
||||
*
|
||||
* console.log(buf1.toString());
|
||||
* // Prints: this is a tést
|
||||
* console.log(buf2.toString());
|
||||
* // Prints: this is a tést
|
||||
* console.log(buf1.toString('latin1'));
|
||||
* // Prints: this is a tést
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `string` is not a string or another type
|
||||
* appropriate for `Buffer.from()` variants.
|
||||
*
|
||||
* `Buffer.from(string)` may also use the internal `Buffer` pool like
|
||||
* `Buffer.allocUnsafe()` does.
|
||||
* @since v5.10.0
|
||||
* @param string A string to encode.
|
||||
* @param encoding The encoding of `string`. **Default:** `'utf8'`.
|
||||
*/
|
||||
from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
from(arrayOrString: WithImplicitCoercion<ArrayLike<number> | string>): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param values to create a new Buffer
|
||||
*/
|
||||
of(...items: number[]): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
||||
*
|
||||
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
||||
*
|
||||
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
||||
* in `list` by adding their lengths.
|
||||
*
|
||||
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
||||
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
||||
* truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
|
||||
* less than `totalLength`, the remaining space is filled with zeros.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
||||
*
|
||||
* const buf1 = Buffer.alloc(10);
|
||||
* const buf2 = Buffer.alloc(14);
|
||||
* const buf3 = Buffer.alloc(18);
|
||||
* const totalLength = buf1.length + buf2.length + buf3.length;
|
||||
*
|
||||
* console.log(totalLength);
|
||||
* // Prints: 42
|
||||
*
|
||||
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
||||
*
|
||||
* console.log(bufA);
|
||||
* // Prints: <Buffer 00 00 00 00 ...>
|
||||
* console.log(bufA.length);
|
||||
* // Prints: 42
|
||||
* ```
|
||||
*
|
||||
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
||||
* @since v0.7.11
|
||||
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
||||
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
||||
*/
|
||||
concat(list: readonly Uint8Array[], totalLength?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Copies the underlying memory of `view` into a new `Buffer`.
|
||||
*
|
||||
* ```js
|
||||
* const u16 = new Uint16Array([0, 0xffff]);
|
||||
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
||||
* u16[1] = 0;
|
||||
* console.log(buf.length); // 2
|
||||
* console.log(buf[0]); // 255
|
||||
* console.log(buf[1]); // 255
|
||||
* ```
|
||||
* @since v19.8.0
|
||||
* @param view The {TypedArray} to copy.
|
||||
* @param [offset=0] The starting offset within `view`.
|
||||
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
||||
*/
|
||||
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(5, 'a');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 61 61 61 61 61>
|
||||
* ```
|
||||
*
|
||||
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
* initialized by calling `buf.fill(fill, encoding)`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
* ```
|
||||
*
|
||||
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
||||
* contents will never contain sensitive data from previous allocations, including
|
||||
* data that might not have been allocated for `Buffer`s.
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
||||
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
||||
*/
|
||||
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.allocUnsafe(10);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
||||
*
|
||||
* buf.fill(0);
|
||||
*
|
||||
* console.log(buf);
|
||||
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
*
|
||||
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
||||
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
||||
*
|
||||
* Use of this pre-allocated internal memory pool is a key difference between
|
||||
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
||||
* than or equal to half `Buffer.poolSize`. The
|
||||
* difference is subtle but can be important when an application requires the
|
||||
* additional performance that `Buffer.allocUnsafe()` provides.
|
||||
* @since v5.10.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafe(size: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
||||
* `size` is 0.
|
||||
*
|
||||
* The underlying memory for `Buffer` instances created in this way is _not_
|
||||
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
||||
* such `Buffer` instances with zeroes.
|
||||
*
|
||||
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
||||
* allows applications to avoid the garbage collection overhead of creating many
|
||||
* individually allocated `Buffer` instances. This approach improves both
|
||||
* performance and memory usage by eliminating the need to track and clean up as
|
||||
* many individual `ArrayBuffer` objects.
|
||||
*
|
||||
* However, in the case where a developer may need to retain a small chunk of
|
||||
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
||||
* then copying out the relevant bits.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Need to keep around a few small chunks of memory.
|
||||
* const store = [];
|
||||
*
|
||||
* socket.on('readable', () => {
|
||||
* let data;
|
||||
* while (null !== (data = readable.read())) {
|
||||
* // Allocate for retained data.
|
||||
* const sb = Buffer.allocUnsafeSlow(10);
|
||||
*
|
||||
* // Copy the data into the new allocation.
|
||||
* data.copy(sb, 0, 0, 10);
|
||||
*
|
||||
* store.push(sb);
|
||||
* }
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* A `TypeError` will be thrown if `size` is not a number.
|
||||
* @since v5.12.0
|
||||
* @param size The desired length of the new `Buffer`.
|
||||
*/
|
||||
allocUnsafeSlow(size: number): Buffer<ArrayBuffer>;
|
||||
}
|
||||
interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
|
||||
// see buffer.d.ts for implementation shared with all TypeScript versions
|
||||
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
||||
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
||||
* copiedBuf[0]++;
|
||||
* console.log(copiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
*
|
||||
* console.log(buf.toString());
|
||||
* // Prints: buffer
|
||||
*
|
||||
* // With buf.slice(), the original buffer is modified.
|
||||
* const notReallyCopiedBuf = buf.slice();
|
||||
* notReallyCopiedBuf[0]++;
|
||||
* console.log(notReallyCopiedBuf.toString());
|
||||
* // Prints: cuffer
|
||||
* console.log(buf.toString());
|
||||
* // Also prints: cuffer (!)
|
||||
* ```
|
||||
* @since v0.3.0
|
||||
* @deprecated Use `subarray` instead.
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
slice(start?: number, end?: number): Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* Returns a new `Buffer` that references the same memory as the original, but
|
||||
* offset and cropped by the `start` and `end` indices.
|
||||
*
|
||||
* Specifying `end` greater than `buf.length` will return the same result as
|
||||
* that of `end` equal to `buf.length`.
|
||||
*
|
||||
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
||||
*
|
||||
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
||||
* // from the original `Buffer`.
|
||||
*
|
||||
* const buf1 = Buffer.allocUnsafe(26);
|
||||
*
|
||||
* for (let i = 0; i < 26; i++) {
|
||||
* // 97 is the decimal ASCII value for 'a'.
|
||||
* buf1[i] = i + 97;
|
||||
* }
|
||||
*
|
||||
* const buf2 = buf1.subarray(0, 3);
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: abc
|
||||
*
|
||||
* buf1[0] = 33;
|
||||
*
|
||||
* console.log(buf2.toString('ascii', 0, buf2.length));
|
||||
* // Prints: !bc
|
||||
* ```
|
||||
*
|
||||
* Specifying negative indexes causes the slice to be generated relative to the
|
||||
* end of `buf` rather than the beginning.
|
||||
*
|
||||
* ```js
|
||||
* import { Buffer } from 'node:buffer';
|
||||
*
|
||||
* const buf = Buffer.from('buffer');
|
||||
*
|
||||
* console.log(buf.subarray(-6, -1).toString());
|
||||
* // Prints: buffe
|
||||
* // (Equivalent to buf.subarray(0, 5).)
|
||||
*
|
||||
* console.log(buf.subarray(-6, -2).toString());
|
||||
* // Prints: buff
|
||||
* // (Equivalent to buf.subarray(0, 4).)
|
||||
*
|
||||
* console.log(buf.subarray(-5, -2).toString());
|
||||
* // Prints: uff
|
||||
* // (Equivalent to buf.subarray(1, 4).)
|
||||
* ```
|
||||
* @since v3.0.0
|
||||
* @param [start=0] Where the new `Buffer` will start.
|
||||
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
||||
*/
|
||||
subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
|
||||
}
|
||||
// TODO: remove globals in future version
|
||||
/**
|
||||
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
|
||||
* TypeScript versions earlier than 5.7.
|
||||
*/
|
||||
type NonSharedBuffer = Buffer<ArrayBuffer>;
|
||||
/**
|
||||
* @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
|
||||
* TypeScript versions earlier than 5.7.
|
||||
*/
|
||||
type AllowSharedBuffer = Buffer<ArrayBufferLike>;
|
||||
}
|
||||
}
|
||||
1810
node_modules/@types/node/buffer.d.ts
generated
vendored
Normal file
1810
node_modules/@types/node/buffer.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1428
node_modules/@types/node/child_process.d.ts
generated
vendored
Normal file
1428
node_modules/@types/node/child_process.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
486
node_modules/@types/node/cluster.d.ts
generated
vendored
Normal file
486
node_modules/@types/node/cluster.d.ts
generated
vendored
Normal file
@@ -0,0 +1,486 @@
|
||||
/**
|
||||
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
||||
* that can distribute workloads among their application threads. When process isolation
|
||||
* is not needed, use the [`worker_threads`](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html)
|
||||
* module instead, which allows running multiple application threads within a single Node.js instance.
|
||||
*
|
||||
* The cluster module allows easy creation of child processes that all share
|
||||
* server ports.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log(`worker ${worker.process.pid} died`);
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection
|
||||
* // In this case it is an HTTP server
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end('hello world\n');
|
||||
* }).listen(8000);
|
||||
*
|
||||
* console.log(`Worker ${process.pid} started`);
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Running Node.js will now share port 8000 between the workers:
|
||||
*
|
||||
* ```console
|
||||
* $ node server.js
|
||||
* Primary 3596 is running
|
||||
* Worker 4324 started
|
||||
* Worker 4520 started
|
||||
* Worker 6056 started
|
||||
* Worker 5644 started
|
||||
* ```
|
||||
*
|
||||
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
||||
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/cluster.js)
|
||||
*/
|
||||
declare module "node:cluster" {
|
||||
import * as child_process from "node:child_process";
|
||||
import { EventEmitter, InternalEventEmitter } from "node:events";
|
||||
class Worker implements EventEmitter {
|
||||
constructor(options?: cluster.WorkerOptions);
|
||||
/**
|
||||
* Each new worker is given its own unique id, this id is stored in the `id`.
|
||||
*
|
||||
* While a worker is alive, this is the key that indexes it in `cluster.workers`.
|
||||
* @since v0.8.0
|
||||
*/
|
||||
id: number;
|
||||
/**
|
||||
* All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
|
||||
* from this function is stored as `.process`. In a worker, the global `process` is stored.
|
||||
*
|
||||
* See: [Child Process module](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options).
|
||||
*
|
||||
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
||||
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
||||
* accidental disconnection.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
process: child_process.ChildProcess;
|
||||
/**
|
||||
* Send a message to a worker or primary, optionally with a handle.
|
||||
*
|
||||
* In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
|
||||
*
|
||||
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
|
||||
*
|
||||
* This example will echo back all messages from the primary:
|
||||
*
|
||||
* ```js
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* worker.send('hi there');
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* process.on('message', (msg) => {
|
||||
* process.send(msg);
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles.
|
||||
*/
|
||||
send(message: child_process.Serializable, callback?: (error: Error | null) => void): boolean;
|
||||
send(
|
||||
message: child_process.Serializable,
|
||||
sendHandle: child_process.SendHandle,
|
||||
callback?: (error: Error | null) => void,
|
||||
): boolean;
|
||||
send(
|
||||
message: child_process.Serializable,
|
||||
sendHandle: child_process.SendHandle,
|
||||
options?: child_process.MessageOptions,
|
||||
callback?: (error: Error | null) => void,
|
||||
): boolean;
|
||||
/**
|
||||
* This function will kill the worker. In the primary worker, it does this by
|
||||
* disconnecting the `worker.process`, and once disconnected, killing with `signal`. In the worker, it does it by killing the process with `signal`.
|
||||
*
|
||||
* The `kill()` function kills the worker process without waiting for a graceful
|
||||
* disconnect, it has the same behavior as `worker.process.kill()`.
|
||||
*
|
||||
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
||||
*
|
||||
* In a worker, `process.kill()` exists, but it is not this function;
|
||||
* it is [`kill()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processkillpid-signal).
|
||||
* @since v0.9.12
|
||||
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
||||
*/
|
||||
kill(signal?: string): void;
|
||||
destroy(signal?: string): void;
|
||||
/**
|
||||
* In a worker, this function will close all servers, wait for the `'close'` event
|
||||
* on those servers, and then disconnect the IPC channel.
|
||||
*
|
||||
* In the primary, an internal message is sent to the worker causing it to call `.disconnect()` on itself.
|
||||
*
|
||||
* Causes `.exitedAfterDisconnect` to be set.
|
||||
*
|
||||
* After a server is closed, it will no longer accept new connections,
|
||||
* but connections may be accepted by any other listening worker. Existing
|
||||
* connections will be allowed to close as usual. When no more connections exist,
|
||||
* see `server.close()`, the IPC channel to the worker will close allowing it
|
||||
* to die gracefully.
|
||||
*
|
||||
* The above applies _only_ to server connections, client connections are not
|
||||
* automatically closed by workers, and disconnect does not wait for them to close
|
||||
* before exiting.
|
||||
*
|
||||
* In a worker, `process.disconnect` exists, but it is not this function;
|
||||
* it is `disconnect()`.
|
||||
*
|
||||
* Because long living server connections may block workers from disconnecting, it
|
||||
* may be useful to send a message, so application specific actions may be taken to
|
||||
* close them. It also may be useful to implement a timeout, killing a worker if
|
||||
* the `'disconnect'` event has not been emitted after some time.
|
||||
*
|
||||
* ```js
|
||||
* import net from 'node:net';
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* const worker = cluster.fork();
|
||||
* let timeout;
|
||||
*
|
||||
* worker.on('listening', (address) => {
|
||||
* worker.send('shutdown');
|
||||
* worker.disconnect();
|
||||
* timeout = setTimeout(() => {
|
||||
* worker.kill();
|
||||
* }, 2000);
|
||||
* });
|
||||
*
|
||||
* worker.on('disconnect', () => {
|
||||
* clearTimeout(timeout);
|
||||
* });
|
||||
*
|
||||
* } else if (cluster.isWorker) {
|
||||
* const server = net.createServer((socket) => {
|
||||
* // Connections never end
|
||||
* });
|
||||
*
|
||||
* server.listen(8000);
|
||||
*
|
||||
* process.on('message', (msg) => {
|
||||
* if (msg === 'shutdown') {
|
||||
* // Initiate graceful close of any connections to server
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.7
|
||||
* @return A reference to `worker`.
|
||||
*/
|
||||
disconnect(): this;
|
||||
/**
|
||||
* This function returns `true` if the worker is connected to its primary via its
|
||||
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
||||
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isConnected(): boolean;
|
||||
/**
|
||||
* This function returns `true` if the worker's process has terminated (either
|
||||
* because of exiting or being signaled). Otherwise, it returns `false`.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
* import http from 'node:http';
|
||||
* import { availableParallelism } from 'node:os';
|
||||
* import process from 'node:process';
|
||||
*
|
||||
* const numCPUs = availableParallelism();
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log(`Primary ${process.pid} is running`);
|
||||
*
|
||||
* // Fork workers.
|
||||
* for (let i = 0; i < numCPUs; i++) {
|
||||
* cluster.fork();
|
||||
* }
|
||||
*
|
||||
* cluster.on('fork', (worker) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
*
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* console.log('worker is dead:', worker.isDead());
|
||||
* });
|
||||
* } else {
|
||||
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
||||
* http.createServer((req, res) => {
|
||||
* res.writeHead(200);
|
||||
* res.end(`Current process\n ${process.pid}`);
|
||||
* process.kill(process.pid);
|
||||
* }).listen(8000);
|
||||
* }
|
||||
* ```
|
||||
* @since v0.11.14
|
||||
*/
|
||||
isDead(): boolean;
|
||||
/**
|
||||
* This property is `true` if the worker exited due to `.disconnect()`.
|
||||
* If the worker exited any other way, it is `false`. If the
|
||||
* worker has not exited, it is `undefined`.
|
||||
*
|
||||
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
||||
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
||||
* based on this value.
|
||||
*
|
||||
* ```js
|
||||
* cluster.on('exit', (worker, code, signal) => {
|
||||
* if (worker.exitedAfterDisconnect === true) {
|
||||
* console.log('Oh, it was just voluntary – no need to worry');
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* // kill worker
|
||||
* worker.kill();
|
||||
* ```
|
||||
* @since v6.0.0
|
||||
*/
|
||||
exitedAfterDisconnect: boolean;
|
||||
}
|
||||
interface Worker extends InternalEventEmitter<cluster.WorkerEventMap> {}
|
||||
type _Worker = Worker;
|
||||
namespace cluster {
|
||||
interface Worker extends _Worker {}
|
||||
interface WorkerOptions {
|
||||
id?: number | undefined;
|
||||
process?: child_process.ChildProcess | undefined;
|
||||
state?: string | undefined;
|
||||
}
|
||||
interface WorkerEventMap {
|
||||
"disconnect": [];
|
||||
"error": [error: Error];
|
||||
"exit": [code: number, signal: string];
|
||||
"listening": [address: Address];
|
||||
"message": [message: any, handle: child_process.SendHandle];
|
||||
"online": [];
|
||||
}
|
||||
interface ClusterSettings {
|
||||
/**
|
||||
* List of string arguments passed to the Node.js executable.
|
||||
* @default process.execArgv
|
||||
*/
|
||||
execArgv?: string[] | undefined;
|
||||
/**
|
||||
* File path to worker file.
|
||||
* @default process.argv[1]
|
||||
*/
|
||||
exec?: string | undefined;
|
||||
/**
|
||||
* String arguments passed to worker.
|
||||
* @default process.argv.slice(2)
|
||||
*/
|
||||
args?: readonly string[] | undefined;
|
||||
/**
|
||||
* Whether or not to send output to parent's stdio.
|
||||
* @default false
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
|
||||
* contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processspawncommand-args-options)'s
|
||||
* [`stdio`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#optionsstdio).
|
||||
*/
|
||||
stdio?: any[] | undefined;
|
||||
/**
|
||||
* Sets the user identity of the process. (See [`setuid(2)`](https://man7.org/linux/man-pages/man2/setuid.2.html).)
|
||||
*/
|
||||
uid?: number | undefined;
|
||||
/**
|
||||
* Sets the group identity of the process. (See [`setgid(2)`](https://man7.org/linux/man-pages/man2/setgid.2.html).)
|
||||
*/
|
||||
gid?: number | undefined;
|
||||
/**
|
||||
* Sets inspector port of worker. This can be a number, or a function that takes no arguments and returns a number.
|
||||
* By default each worker gets its own port, incremented from the primary's `process.debugPort`.
|
||||
*/
|
||||
inspectPort?: number | (() => number) | undefined;
|
||||
/**
|
||||
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
|
||||
* See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#advanced-serialization) for more details.
|
||||
* @default false
|
||||
*/
|
||||
serialization?: "json" | "advanced" | undefined;
|
||||
/**
|
||||
* Current working directory of the worker process.
|
||||
* @default undefined (inherits from parent process)
|
||||
*/
|
||||
cwd?: string | undefined;
|
||||
/**
|
||||
* Hide the forked processes console window that would normally be created on Windows systems.
|
||||
* @default false
|
||||
*/
|
||||
windowsHide?: boolean | undefined;
|
||||
}
|
||||
interface Address {
|
||||
address: string;
|
||||
port: number;
|
||||
/**
|
||||
* The `addressType` is one of:
|
||||
*
|
||||
* * `4` (TCPv4)
|
||||
* * `6` (TCPv6)
|
||||
* * `-1` (Unix domain socket)
|
||||
* * `'udp4'` or `'udp6'` (UDPv4 or UDPv6)
|
||||
*/
|
||||
addressType: 4 | 6 | -1 | "udp4" | "udp6";
|
||||
}
|
||||
interface ClusterEventMap {
|
||||
"disconnect": [worker: Worker];
|
||||
"exit": [worker: Worker, code: number, signal: string];
|
||||
"fork": [worker: Worker];
|
||||
"listening": [worker: Worker, address: Address];
|
||||
"message": [worker: Worker, message: any, handle: child_process.SendHandle];
|
||||
"online": [worker: Worker];
|
||||
"setup": [settings: ClusterSettings];
|
||||
}
|
||||
interface Cluster extends InternalEventEmitter<ClusterEventMap> {
|
||||
/**
|
||||
* A `Worker` object contains all public information and method about a worker.
|
||||
* In the primary it can be obtained using `cluster.workers`. In a worker
|
||||
* it can be obtained using `cluster.worker`.
|
||||
* @since v0.7.0
|
||||
*/
|
||||
Worker: typeof Worker;
|
||||
disconnect(callback?: () => void): void;
|
||||
/**
|
||||
* Spawn a new worker process.
|
||||
*
|
||||
* This can only be called from the primary process.
|
||||
* @param env Key/value pairs to add to worker process environment.
|
||||
* @since v0.6.0
|
||||
*/
|
||||
fork(env?: any): Worker;
|
||||
/** @deprecated since v16.0.0 - use isPrimary. */
|
||||
readonly isMaster: boolean;
|
||||
/**
|
||||
* True if the process is a primary. This is determined by the `process.env.NODE_UNIQUE_ID`. If `process.env.NODE_UNIQUE_ID`
|
||||
* is undefined, then `isPrimary` is `true`.
|
||||
* @since v16.0.0
|
||||
*/
|
||||
readonly isPrimary: boolean;
|
||||
/**
|
||||
* True if the process is not a primary (it is the negation of `cluster.isPrimary`).
|
||||
* @since v0.6.0
|
||||
*/
|
||||
readonly isWorker: boolean;
|
||||
/**
|
||||
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
|
||||
* global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
|
||||
* is called, whichever comes first.
|
||||
*
|
||||
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
|
||||
* IOCP handles without incurring a large performance hit.
|
||||
*
|
||||
* `cluster.schedulingPolicy` can also be set through the `NODE_CLUSTER_SCHED_POLICY` environment variable. Valid values are `'rr'` and `'none'`.
|
||||
* @since v0.11.2
|
||||
*/
|
||||
schedulingPolicy: number;
|
||||
/**
|
||||
* After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
|
||||
* (or [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)) this settings object will contain
|
||||
* the settings, including the default values.
|
||||
*
|
||||
* This object is not intended to be changed or set manually.
|
||||
* @since v0.7.1
|
||||
*/
|
||||
readonly settings: ClusterSettings;
|
||||
/** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings) instead. */
|
||||
setupMaster(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
|
||||
*
|
||||
* Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)
|
||||
* and have no effect on workers that are already running.
|
||||
*
|
||||
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
|
||||
* [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv).
|
||||
*
|
||||
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
|
||||
* `cluster.setupPrimary()` is called.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* cluster.setupPrimary({
|
||||
* exec: 'worker.js',
|
||||
* args: ['--use', 'https'],
|
||||
* silent: true,
|
||||
* });
|
||||
* cluster.fork(); // https worker
|
||||
* cluster.setupPrimary({
|
||||
* exec: 'worker.js',
|
||||
* args: ['--use', 'http'],
|
||||
* });
|
||||
* cluster.fork(); // http worker
|
||||
* ```
|
||||
*
|
||||
* This can only be called from the primary process.
|
||||
* @since v16.0.0
|
||||
*/
|
||||
setupPrimary(settings?: ClusterSettings): void;
|
||||
/**
|
||||
* A reference to the current worker object. Not available in the primary process.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* console.log('I am primary');
|
||||
* cluster.fork();
|
||||
* cluster.fork();
|
||||
* } else if (cluster.isWorker) {
|
||||
* console.log(`I am worker #${cluster.worker.id}`);
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
*/
|
||||
readonly worker?: Worker;
|
||||
/**
|
||||
* A hash that stores the active worker objects, keyed by `id` field. This makes it easy to loop through all the workers. It is only available in the primary process.
|
||||
*
|
||||
* A worker is removed from `cluster.workers` after the worker has disconnected _and_ exited. The order between these two events cannot be determined in advance. However, it
|
||||
* is guaranteed that the removal from the `cluster.workers` list happens before the last `'disconnect'` or `'exit'` event is emitted.
|
||||
*
|
||||
* ```js
|
||||
* import cluster from 'node:cluster';
|
||||
*
|
||||
* for (const worker of Object.values(cluster.workers)) {
|
||||
* worker.send('big announcement to all workers');
|
||||
* }
|
||||
* ```
|
||||
* @since v0.7.0
|
||||
*/
|
||||
readonly workers?: NodeJS.Dict<Worker>;
|
||||
readonly SCHED_NONE: number;
|
||||
readonly SCHED_RR: number;
|
||||
}
|
||||
}
|
||||
var cluster: cluster.Cluster;
|
||||
export = cluster;
|
||||
}
|
||||
declare module "cluster" {
|
||||
import cluster = require("node:cluster");
|
||||
export = cluster;
|
||||
}
|
||||
21
node_modules/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
21
node_modules/@types/node/compatibility/iterators.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Backwards-compatible iterator interfaces, augmented with iterator helper methods by lib.esnext.iterator in TypeScript 5.6.
|
||||
// The IterableIterator interface does not contain these methods, which creates assignability issues in places where IteratorObjects
|
||||
// are expected (eg. DOM-compatible APIs) if lib.esnext.iterator is loaded.
|
||||
// Also ensures that iterators returned by the Node API, which inherit from Iterator.prototype, correctly expose the iterator helper methods
|
||||
// if lib.esnext.iterator is loaded.
|
||||
// TODO: remove once this package no longer supports TS 5.5, and replace NodeJS.BuiltinIteratorReturn with BuiltinIteratorReturn.
|
||||
|
||||
// Placeholders for TS <5.6
|
||||
interface IteratorObject<T, TReturn, TNext> {}
|
||||
interface AsyncIteratorObject<T, TReturn, TNext> {}
|
||||
|
||||
declare namespace NodeJS {
|
||||
// Populate iterator methods for TS <5.6
|
||||
interface Iterator<T, TReturn, TNext> extends globalThis.Iterator<T, TReturn, TNext> {}
|
||||
interface AsyncIterator<T, TReturn, TNext> extends globalThis.AsyncIterator<T, TReturn, TNext> {}
|
||||
|
||||
// Polyfill for TS 5.6's instrinsic BuiltinIteratorReturn type, required for DOM-compatible iterators
|
||||
type BuiltinIteratorReturn = ReturnType<any[][typeof Symbol.iterator]> extends
|
||||
globalThis.Iterator<any, infer TReturn> ? TReturn
|
||||
: any;
|
||||
}
|
||||
151
node_modules/@types/node/console.d.ts
generated
vendored
Normal file
151
node_modules/@types/node/console.d.ts
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* The `node:console` module provides a simple debugging console that is similar to
|
||||
* the JavaScript console mechanism provided by web browsers.
|
||||
*
|
||||
* The module exports two specific components:
|
||||
*
|
||||
* * A `Console` class with methods such as `console.log()`, `console.error()`, and `console.warn()` that can be used to write to any Node.js stream.
|
||||
* * A global `console` instance configured to write to [`process.stdout`](https://nodejs.org/docs/latest-v25.x/api/process.html#processstdout) and
|
||||
* [`process.stderr`](https://nodejs.org/docs/latest-v25.x/api/process.html#processstderr). The global `console` can be used without importing the `node:console` module.
|
||||
*
|
||||
* _**Warning**_: The global console object's methods are neither consistently
|
||||
* synchronous like the browser APIs they resemble, nor are they consistently
|
||||
* asynchronous like all other Node.js streams. See the [`note on process I/O`](https://nodejs.org/docs/latest-v25.x/api/process.html#a-note-on-process-io) for
|
||||
* more information.
|
||||
*
|
||||
* Example using the global `console`:
|
||||
*
|
||||
* ```js
|
||||
* console.log('hello world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.log('hello %s', 'world');
|
||||
* // Prints: hello world, to stdout
|
||||
* console.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints error message and stack trace to stderr:
|
||||
* // Error: Whoops, something bad happened
|
||||
* // at [eval]:5:15
|
||||
* // at Script.runInThisContext (node:vm:132:18)
|
||||
* // at Object.runInThisContext (node:vm:309:38)
|
||||
* // at node:internal/process/execution:77:19
|
||||
* // at [eval]-wrapper:6:22
|
||||
* // at evalScript (node:internal/process/execution:76:60)
|
||||
* // at node:internal/main/eval_string:23:3
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* console.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to stderr
|
||||
* ```
|
||||
*
|
||||
* Example using the `Console` class:
|
||||
*
|
||||
* ```js
|
||||
* const out = getStreamSomehow();
|
||||
* const err = getStreamSomehow();
|
||||
* const myConsole = new console.Console(out, err);
|
||||
*
|
||||
* myConsole.log('hello world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.log('hello %s', 'world');
|
||||
* // Prints: hello world, to out
|
||||
* myConsole.error(new Error('Whoops, something bad happened'));
|
||||
* // Prints: [Error: Whoops, something bad happened], to err
|
||||
*
|
||||
* const name = 'Will Robinson';
|
||||
* myConsole.warn(`Danger ${name}! Danger!`);
|
||||
* // Prints: Danger Will Robinson! Danger!, to err
|
||||
* ```
|
||||
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/console.js)
|
||||
*/
|
||||
declare module "node:console" {
|
||||
import { InspectOptions } from "node:util";
|
||||
namespace console {
|
||||
interface ConsoleOptions {
|
||||
stdout: NodeJS.WritableStream;
|
||||
stderr?: NodeJS.WritableStream | undefined;
|
||||
/**
|
||||
* Ignore errors when writing to the underlying streams.
|
||||
* @default true
|
||||
*/
|
||||
ignoreErrors?: boolean | undefined;
|
||||
/**
|
||||
* Set color support for this `Console` instance. Setting to true enables coloring while inspecting
|
||||
* values. Setting to `false` disables coloring while inspecting values. Setting to `'auto'` makes color
|
||||
* support depend on the value of the `isTTY` property and the value returned by `getColorDepth()` on the
|
||||
* respective stream. This option can not be used, if `inspectOptions.colors` is set as well.
|
||||
* @default 'auto'
|
||||
*/
|
||||
colorMode?: boolean | "auto" | undefined;
|
||||
/**
|
||||
* Specifies options that are passed along to
|
||||
* [`util.inspect()`](https://nodejs.org/docs/latest-v25.x/api/util.html#utilinspectobject-options).
|
||||
*/
|
||||
inspectOptions?: InspectOptions | ReadonlyMap<NodeJS.WritableStream, InspectOptions> | undefined;
|
||||
/**
|
||||
* Set group indentation.
|
||||
* @default 2
|
||||
*/
|
||||
groupIndentation?: number | undefined;
|
||||
}
|
||||
interface Console {
|
||||
readonly Console: {
|
||||
prototype: Console;
|
||||
new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
||||
new(options: ConsoleOptions): Console;
|
||||
};
|
||||
assert(condition?: unknown, ...data: any[]): void;
|
||||
clear(): void;
|
||||
count(label?: string): void;
|
||||
countReset(label?: string): void;
|
||||
debug(...data: any[]): void;
|
||||
dir(item?: any, options?: InspectOptions): void;
|
||||
dirxml(...data: any[]): void;
|
||||
error(...data: any[]): void;
|
||||
group(...data: any[]): void;
|
||||
groupCollapsed(...data: any[]): void;
|
||||
groupEnd(): void;
|
||||
info(...data: any[]): void;
|
||||
log(...data: any[]): void;
|
||||
table(tabularData?: any, properties?: string[]): void;
|
||||
time(label?: string): void;
|
||||
timeEnd(label?: string): void;
|
||||
timeLog(label?: string, ...data: any[]): void;
|
||||
trace(...data: any[]): void;
|
||||
warn(...data: any[]): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector. The `console.profile()`
|
||||
* method starts a JavaScript CPU profile with an optional label until {@link profileEnd}
|
||||
* is called. The profile is then added to the Profile panel of the inspector.
|
||||
*
|
||||
* ```js
|
||||
* console.profile('MyLabel');
|
||||
* // Some code
|
||||
* console.profileEnd('MyLabel');
|
||||
* // Adds the profile 'MyLabel' to the Profiles panel of the inspector.
|
||||
* ```
|
||||
* @since v8.0.0
|
||||
*/
|
||||
profile(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector. Stops the current
|
||||
* JavaScript CPU profiling session if one has been started and prints the report to the
|
||||
* Profiles panel of the inspector. See {@link profile} for an example.
|
||||
*
|
||||
* If this method is called without a label, the most recently started profile is stopped.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
profileEnd(label?: string): void;
|
||||
/**
|
||||
* This method does not display anything unless used in the inspector. The `console.timeStamp()`
|
||||
* method adds an event with the label `'label'` to the Timeline panel of the inspector.
|
||||
* @since v8.0.0
|
||||
*/
|
||||
timeStamp(label?: string): void;
|
||||
}
|
||||
}
|
||||
var console: console.Console;
|
||||
export = console;
|
||||
}
|
||||
declare module "console" {
|
||||
import console = require("node:console");
|
||||
export = console;
|
||||
}
|
||||
20
node_modules/@types/node/constants.d.ts
generated
vendored
Normal file
20
node_modules/@types/node/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @deprecated The `node:constants` module is deprecated. When requiring access to constants
|
||||
* relevant to specific Node.js builtin modules, developers should instead refer
|
||||
* to the `constants` property exposed by the relevant module. For instance,
|
||||
* `require('node:fs').constants` and `require('node:os').constants`.
|
||||
*/
|
||||
declare module "node:constants" {
|
||||
const constants:
|
||||
& typeof import("node:os").constants.dlopen
|
||||
& typeof import("node:os").constants.errno
|
||||
& typeof import("node:os").constants.priority
|
||||
& typeof import("node:os").constants.signals
|
||||
& typeof import("node:fs").constants
|
||||
& typeof import("node:crypto").constants;
|
||||
export = constants;
|
||||
}
|
||||
declare module "constants" {
|
||||
import constants = require("node:constants");
|
||||
export = constants;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user